Microchip® Advanced Software Framework

hid_device.h File Reference

HID Device Profile Declarations.

Copyright (c) 2017-2018 Microchip Technology Inc. and its subsidiaries.

#include "at_ble_api.h"

Data Structures

struct  hid_boot_ntf
 HID boot notification or indication, notify to user. More...
 
struct  hid_control_mode_ntf
 HID control point info, notify to user when control point change by user. More...
 
struct  hid_gatt_serv_handler
 
struct  hid_info
 HID info of device. More...
 
struct  hid_prf_info_t
 HID profile application info. More...
 
struct  hid_proto_mode_ntf
 HID protocol mode info, notify to user when protocol mode change by user. More...
 
struct  hid_report_map
 HID Report Map Information. More...
 
struct  hid_report_ntf
 HID report notification or indication, notify to user. More...
 
struct  hid_report_ref
 HID Report Reference Descriptor. More...
 

Macros

#define ADV_DATA_APPEARANCE_DATA   (0x03C2)
 Number of characteristic for HID. More...
 
#define ADV_DATA_APPEARANCE_DATA   (0x03C1)
 Number of characteristic for HID. More...
 
#define ADV_DATA_APPEARANCE_LEN   (2)
 Advertisement data appearance len. More...
 
#define ADV_DATA_APPEARANCE_TYPE   (0x19)
 Advertisement appearance type. More...
 
#define ADV_DATA_NAME_DATA   ("ATMEL-HID")
 
#define ADV_DATA_NAME_LEN   (9)
 Advertisement data name appearance len. More...
 
#define ADV_DATA_NAME_TYPE   (0x09)
 Advertisement data name type. More...
 
#define ADV_DATA_UUID_LEN   (2)
 Advertisement data UUID length. More...
 
#define ADV_DATA_UUID_TYPE   (0x03)
 Advertisement UUID type. More...
 
#define ADV_TYPE_LEN   (0x01)
 Advertisement type length. More...
 
#define APP_HID_ADV_TIMEOUT   (655)
 APP_HID_ADV_TIMEOUT Advertising time-out between 0x0001 and 0x028F in seconds, 0x0000 disables time-out. More...
 
#define APP_HID_FAST_ADV   (160)
 APP_HID_FAST_ADV between 0x0020 and 0x4000 in 0.625 ms units (20ms to 10.24s). More...
 
#define HID_CHARACTERISTIC_NUM   (HID_DEFAULT_CHARACTERISITC_NUM + HID_NUM_OF_REPORT + 1)
 
#define HID_CHARACTERISTIC_NUM   (HID_DEFAULT_CHARACTERISITC_NUM + HID_NUM_OF_REPORT + 2)
 
#define HID_DEFAULT_CHARACTERISITC_NUM   (4)
 Default number of characteristic. More...
 
#define HID_MAX_REPORT_NUM   (10)
 Number of Report. More...
 
#define HID_MAX_SERV_INST   (2)
 HID Max Service Instance. More...
 
#define HID_NUM_OF_REPORT   (1)
 Number of Report : Configure by user. More...
 
#define HID_SERV_INST   (1)
 HID Service Instance : Configure by user. More...
 
#define SCAN_RESP_LEN   (10)
 scan_resp_len is the length of the scan response data More...
 

Typedefs

typedef void(* boot_ntf_callback_t )(hid_boot_ntf_t *)
 Boot notification callback. More...
 
typedef void(* control_point_ntf_callback_t )(hid_control_mode_ntf_t *)
 COntrol point notification callback. More...
 
typedef struct hid_boot_ntf hid_boot_ntf_t
 HID boot notification or indication, notify to user. More...
 
typedef struct hid_control_mode_ntf hid_control_mode_ntf_t
 HID control point info, notify to user when control point change by user. More...
 
typedef struct
hid_gatt_serv_handler 
hid_gatt_serv_handler_t
 
typedef struct hid_info hid_info_t
 HID info of device. More...
 
typedef struct hid_proto_mode_ntf hid_proto_mode_ntf_t
 HID protocol mode info, notify to user when protocol mode change by user. More...
 
typedef struct hid_report_map hid_report_map_t
 HID Report Map Information. More...
 
typedef struct hid_report_ntf hid_report_ntf_t
 HID report notification or indication, notify to user. More...
 
typedef struct hid_report_ref hid_report_ref_t
 HID Report Reference Descriptor. More...
 
typedef void(* protocol_mode_ntf_callback_t )(hid_proto_mode_ntf_t *)
 Protocol mode notification callback. More...
 
typedef void(* report_ntf_callback_t )(hid_report_ntf_t *)
 Report notification callback. More...
 

Enumerations

enum  hid_char_type_t {
  PROTOCOL_MODE,
  REPORT_MAP,
  CHAR_REPORT,
  CHAR_REPORT_CCD,
  BOOT_MOUSE_INPUT_REPORT,
  BOOT_KEY_OUTPUT_REPORT,
  BOOT_KEY_INPUT_REPORT,
  HID_INFORMATION,
  CONTROL_POINT
}
 HID characteristic. More...
 
enum  hid_prf_error_t {
  HID_PRF_SUCESS = 0,
  HID_PRF_INSTANCE_OUT_RANGE,
  HID_PRF_NO_INSTANCE
}
 HID Profile error code. More...
 

Functions

void hid_prf_boot_keyboardreport_update (at_ble_handle_t conn_handle, uint8_t serv_inst, uint8_t *bootreport, uint16_t len)
 Called by user to notify boot report for keyboard to HID host. More...
 
void hid_prf_boot_mousereport_update (at_ble_handle_t conn_handle, uint8_t serv_inst, uint8_t *bootreport, uint16_t len)
 Called by user to notify boot report for mouse to HID host. More...
 
at_ble_status_t hid_prf_char_changed_handler (void *params)
 Service characteristic change handler function. More...
 
uint8_t hid_prf_conf (hid_prf_info_t *ref)
 HID device profile configuration function. More...
 
void hid_prf_dev_adv (void)
 HID profile advertisement function. More...
 
at_ble_status_t hid_prf_disconnect_event_handler (void *params)
 HID device disconnected handler function. More...
 
void hid_prf_init (void *param)
 HID device profile initialization function. More...
 
void hid_prf_report_update (uint16_t conn_handle, uint8_t serv_inst, uint8_t reportid, uint8_t *report, uint16_t len)
 Called by user to notify report to HID host. More...
 
void notify_boot_ntf_handler (boot_ntf_callback_t boot_ntf_fn)
 Boot notification handler function. More...
 
void notify_control_point_handler (control_point_ntf_callback_t control_mode_ntf_fn)
 Control point notification handler function. More...
 
void notify_protocol_mode_handler (protocol_mode_ntf_callback_t proto_mode_ntf_fn)
 Protocol mode handler function. More...
 
void notify_report_ntf_handler (report_ntf_callback_t report_ntf_fn)
 Report notification handler function. More...
 

#define ADV_DATA_APPEARANCE_DATA   (0x03C2)

Number of characteristic for HID.

Enable by user for keyboard application : Configure by user.

Enable by user for mouse application : Configure by user.

#define ADV_DATA_APPEARANCE_DATA   (0x03C1)

Number of characteristic for HID.

Enable by user for keyboard application : Configure by user.

Enable by user for mouse application : Configure by user.

#define ADV_DATA_APPEARANCE_LEN   (2)

Advertisement data appearance len.

#define ADV_DATA_APPEARANCE_TYPE   (0x19)

Advertisement appearance type.

#define ADV_DATA_NAME_DATA   ("ATMEL-HID")
#define ADV_DATA_NAME_LEN   (9)

Advertisement data name appearance len.

#define ADV_DATA_NAME_TYPE   (0x09)

Advertisement data name type.

#define ADV_DATA_UUID_LEN   (2)

Advertisement data UUID length.

#define ADV_DATA_UUID_TYPE   (0x03)

Advertisement UUID type.

#define ADV_TYPE_LEN   (0x01)

Advertisement type length.

#define APP_HID_ADV_TIMEOUT   (655)

APP_HID_ADV_TIMEOUT Advertising time-out between 0x0001 and 0x028F in seconds, 0x0000 disables time-out.

Referenced by hid_prf_dev_adv(), and hid_prf_disconnect_event_handler().

#define APP_HID_FAST_ADV   (160)

APP_HID_FAST_ADV between 0x0020 and 0x4000 in 0.625 ms units (20ms to 10.24s).

Referenced by hid_prf_dev_adv(), and hid_prf_disconnect_event_handler().

#define HID_CHARACTERISTIC_NUM   (HID_DEFAULT_CHARACTERISITC_NUM + HID_NUM_OF_REPORT + 1)

Referenced by hid_serv_init().

#define HID_CHARACTERISTIC_NUM   (HID_DEFAULT_CHARACTERISITC_NUM + HID_NUM_OF_REPORT + 2)
#define HID_DEFAULT_CHARACTERISITC_NUM   (4)

Default number of characteristic.

#define HID_MAX_REPORT_NUM   (10)

Number of Report.

#define HID_MAX_SERV_INST   (2)

HID Max Service Instance.

Referenced by hid_prf_conf(), hid_prf_init(), and hid_serv_get_instance().

#define HID_NUM_OF_REPORT   (1)
#define HID_SERV_INST   (1)

HID Service Instance : Configure by user.

#define SCAN_RESP_LEN   (10)

scan_resp_len is the length of the scan response data

typedef void(* boot_ntf_callback_t)(hid_boot_ntf_t *)

Boot notification callback.

typedef void(* control_point_ntf_callback_t)(hid_control_mode_ntf_t *)

COntrol point notification callback.

typedef struct hid_boot_ntf hid_boot_ntf_t

HID boot notification or indication, notify to user.

HID control point info, notify to user when control point change by user.

typedef struct hid_info hid_info_t

HID info of device.

HID protocol mode info, notify to user when protocol mode change by user.

HID Report Map Information.

HID report notification or indication, notify to user.

HID Report Reference Descriptor.

typedef void(* protocol_mode_ntf_callback_t)(hid_proto_mode_ntf_t *)

Protocol mode notification callback.

typedef void(* report_ntf_callback_t)(hid_report_ntf_t *)

Report notification callback.

HID characteristic.

Enumerator
PROTOCOL_MODE 
REPORT_MAP 
CHAR_REPORT 
CHAR_REPORT_CCD 
BOOT_MOUSE_INPUT_REPORT 
BOOT_KEY_OUTPUT_REPORT 
BOOT_KEY_INPUT_REPORT 
HID_INFORMATION 
CONTROL_POINT 

HID Profile error code.

Enumerator
HID_PRF_SUCESS 
HID_PRF_INSTANCE_OUT_RANGE 
HID_PRF_NO_INSTANCE 

void hid_prf_boot_keyboardreport_update ( at_ble_handle_t  conn_handle,
uint8_t  serv_inst,
uint8_t *  bootreport,
uint16_t  len 
)

Called by user to notify boot report for keyboard to HID host.

Parameters
[in]conn_handleConnection handle
[in]serv_instService instance
[in]bootreportReport info that need to send to host
[in]lenReport length

Called by user to notify boot report for keyboard to HID host.

References hid_boot_keyboardreport_update().

void hid_prf_boot_mousereport_update ( at_ble_handle_t  conn_handle,
uint8_t  serv_inst,
uint8_t *  bootreport,
uint16_t  len 
)

Called by user to notify boot report for mouse to HID host.

Parameters
[in]conn_handleConnection handle
[in]serv_instService instance
[in]bootreportReport info that need to send to host
[in]lenReport length

Called by user to notify boot report for mouse to HID host.

References hid_boot_mousereport_update().

uint8_t hid_prf_conf ( hid_prf_info_t ref)

HID device profile configuration function.

Parameters
[in]refHID profile application info
Returns
HID_PRF_SUCESS operation completed successfully
HID_PRF_INSTANCE_OUT_RANGE Service cannot be registered
HID_PRF_NO_INSTANCE ref value is NULL

HID device profile configuration function.

References HID_MAX_SERV_INST, HID_PRF_INSTANCE_OUT_RANGE, HID_PRF_NO_INSTANCE, HID_PRF_SUCESS, hid_prf_info_t::hid_serv_instance, and NULL.

Referenced by hid_keyboard_app_init(), and hid_mouse_app_init().

void hid_prf_dev_adv ( void  )
at_ble_status_t hid_prf_disconnect_event_handler ( void *  params)

HID device disconnected handler function.

Parameters
[in]disconnectdisconnect info
Returns
AT_BLE_SUCCESS operation completed successfully

HID device disconnected handler function.

References ALL_UNUSED, APP_HID_ADV_TIMEOUT, APP_HID_FAST_ADV, AT_BLE_ADV_FP_ANY, AT_BLE_ADV_GEN_DISCOVERABLE, at_ble_adv_start(), AT_BLE_ADV_TYPE_UNDIRECTED, AT_BLE_SUCCESS, DBG_LOG, and NULL.

void hid_prf_report_update ( at_ble_handle_t  conn_handle,
uint8_t  serv_inst,
uint8_t  reportid,
uint8_t *  report,
uint16_t  len 
)

Called by user to notify report to HID host.

Parameters
[in]conn_handleConnection handle
[in]serv_instService instance
[in]reportidReport ID corresponding to report
[in]reportReport info that need to send to host
[in]lenReport length

Called by user to notify report to HID host.

References hid_serv_report_update().

Referenced by main().

void notify_boot_ntf_handler ( boot_ntf_callback_t  boot_ntf_fn)

Boot notification handler function.

Boot notification handler function.

References boot_ntf_cb.

Referenced by main().

void notify_control_point_handler ( control_point_ntf_callback_t  control_mode_ntf_fn)

Control point notification handler function.

Control point notification handler function.

References control_point_ntf_cb.

Referenced by main().

void notify_protocol_mode_handler ( protocol_mode_ntf_callback_t  proto_mode_ntf_fn)

Protocol mode handler function.

Protocol mode handler function.

References mode_ntf_cb.

Referenced by main().

void notify_report_ntf_handler ( report_ntf_callback_t  report_ntf_fn)

Report notification handler function.

Report notification handler function.

References report_ntf_cb.

Referenced by main().