Microchip® Advanced Software Framework

hid.h File Reference

HID Service Declarations.

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

#include "hid_device.h"

Data Structures

struct  hid_reportref_desc
 HID report reference descriptor instance for device role. More...
 
struct  hid_serv
 HID service instance for device role. More...
 

Typedefs

typedef struct hid_reportref_desc hid_reportref_desc_t
 HID report reference descriptor instance for device role. More...
 
typedef struct hid_serv hid_serv_t
 HID service instance for device role. More...
 

Enumerations

enum  hid_control_mode {
  SUSPEND = 0,
  EXIT_SUSPEND
}
 HID control point. More...
 
enum  hid_dev_type {
  HID_MOUSE_MODE = 1,
  HID_KEYBOARD_MODE
}
 Protocol Mode Value. More...
 
enum  hid_proto_mode {
  HID_BOOT_PROTOCOL_MODE = 0,
  HID_REPORT_PROTOCOL_MODE
}
 Protocol Mode Value. More...
 
enum  hid_report_type {
  INPUT_REPORT = 1,
  OUTPUT_REPORT,
  FEATURE_REPORT
}
 HID control point. More...
 
enum  hid_serv_status {
  HID_SERV_FAILED = -1,
  HID_SERV_SUCESS = 0,
  HID_SERV_REG_FAILED,
  HID_INVALID_INST = 0xFF
}
 Error Code for HID service operation. More...
 

Functions

void hid_boot_keyboardreport_update (at_ble_handle_t conn_handle, uint8_t serv_inst, uint8_t *bootreport, uint16_t len)
 Function to update the boot keyboard report. More...
 
void hid_boot_mousereport_update (at_ble_handle_t conn_handle, uint8_t serv_inst, uint8_t *bootreport, uint16_t len)
 Function to update the boot mouse report. More...
 
uint8_t hid_get_reportchar (uint16_t handle, uint8_t serv, uint8_t reportid)
 Function to get report characteristic id. More...
 
uint8_t hid_get_reportid (uint8_t serv, uint16_t handle, uint8_t reportnum)
 Function to get the report ID. More...
 
uint8_t hid_ntf_instance (uint8_t serv_num, uint16_t char_handle)
 Function to get the notification instance. More...
 
void hid_serv_def_init (uint8_t servnum)
 service definition initialization function More...
 
uint8_t hid_serv_get_instance (uint16_t handle)
 Function to get service instance. More...
 
void hid_serv_init (uint8_t servinst, uint8_t device, uint8_t *mode, uint8_t report_num, uint8_t *report_type, uint8_t **report_val, uint8_t *report_len, hid_info_t *info)
 Initialize the hid profile based on user input. More...
 
void hid_serv_report_map (uint8_t servinst, uint8_t *report_info, uint16_t len)
 Function update the report descriptor for HID device. More...
 
void hid_serv_report_update (uint16_t conn_handle, uint8_t serv_inst, uint8_t reportid, uint8_t *report, uint16_t len)
 Function to update the report. More...
 
uint16_t hid_service_dbreg (uint8_t inst, uint8_t *report_type, uint8_t *report_id, uint8_t report_num)
 Register the service into database. More...
 

HID report reference descriptor instance for device role.

typedef struct hid_serv hid_serv_t

HID service instance for device role.

HID control point.

Enumerator
SUSPEND 

Enable suspend mode.

EXIT_SUSPEND 

Exit suspend mode.

Protocol Mode Value.

Enumerator
HID_MOUSE_MODE 

Enable boot protocol mode.

HID_KEYBOARD_MODE 

Enable report protocol mode.

Protocol Mode Value.

Enumerator
HID_BOOT_PROTOCOL_MODE 

Enable boot protocol mode.

HID_REPORT_PROTOCOL_MODE 

Enable report protocol mode.

HID control point.

Enumerator
INPUT_REPORT 

Input report.

OUTPUT_REPORT 

Input report.

FEATURE_REPORT 

Input report.

Error Code for HID service operation.

Enumerator
HID_SERV_FAILED 

HID Service Registration Failed.

HID_SERV_SUCESS 

HID Service Operation Pass.

HID_SERV_REG_FAILED 

HID Service Registration Failed.

HID_INVALID_INST 

HID Report ID Not Found.

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

Function to update the boot keyboard report.

Parameters
[in]conn_handleConnection handle
[in]serv_instService Instance
[in]bootreportReport to be send
[in]lenLength of report

Function to update the boot keyboard report.

References ALL_UNUSED, at_ble_characteristic_value_get(), at_ble_characteristic_value_set(), at_ble_notification_send(), AT_BLE_SUCCESS, DBG_LOG_DEV, length, and status.

Referenced by hid_prf_boot_keyboardreport_update().

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

Function to update the boot mouse report.

Parameters
[in]conn_handleConnection handle
[in]serv_instService Instance
[in]bootreportReport to be send
[in]lenLength of report

Function to update the boot mouse report.

References ALL_UNUSED, at_ble_characteristic_value_get(), at_ble_characteristic_value_set(), at_ble_notification_send(), AT_BLE_SUCCESS, DBG_LOG_DEV, length, and status.

Referenced by hid_prf_boot_mousereport_update().

uint8_t hid_get_reportchar ( uint16_t  handle,
uint8_t  serv,
uint8_t  reportid 
)

Function to get report characteristic id.

Parameters
[in]handleConnection handle
[in]servService Instance
[in]reportidReport id

Function to get report characteristic id.

References at_ble_descriptor_value_get(), AT_BLE_SUCCESS, DBG_LOG_DEV, HID_INVALID_INST, HID_NUM_OF_REPORT, id, len, and status.

Referenced by hid_serv_report_update().

uint8_t hid_get_reportid ( uint8_t  serv,
uint16_t  handle,
uint8_t  reportnum 
)

Function to get the report ID.

Parameters
[in]servHID service instance
[in]handleConnection handle
[in]report_numNumber of report

Function to get the report ID.

References at_ble_descriptor_value_get(), AT_BLE_SUCCESS, DBG_LOG_DEV, HID_INVALID_INST, len, and status.

Referenced by hid_prf_char_changed_handler().

uint8_t hid_ntf_instance ( uint8_t  serv_num,
uint16_t  char_handle 
)

Function to get the notification instance.

Parameters
[in]serv_numService Instance
[in]char_handleCharacter Handle

Function to get the notification instance.

References BOOT_KEY_INPUT_REPORT, BOOT_MOUSE_INPUT_REPORT, CHAR_REPORT, CHAR_REPORT_CCD, CONTROL_POINT, DBG_LOG_DEV, HID_NUM_OF_REPORT, and PROTOCOL_MODE.

Referenced by hid_prf_char_changed_handler().

uint8_t hid_serv_get_instance ( uint16_t  handle)

Function to get service instance.

Parameters
[in]handleConnection handle

Function to get service instance.

References DBG_LOG_DEV, HID_MAX_SERV_INST, and id.

Referenced by hid_prf_char_changed_handler().

void hid_serv_init ( uint8_t  servinst,
uint8_t  device,
uint8_t *  mode,
uint8_t  report_num,
uint8_t *  report_type,
uint8_t **  report_val,
uint8_t *  report_len,
hid_info_t info 
)

Initialize the hid profile based on user input.

Parameters
[in]servinstHID service instance
[in]deviceHID device
[in]modeHID mode
[in]report_numNumber of report
[in]report_typeReport Type
[in]report_valReport Value
[in]report_lenReport Length
[in]infoHID device info

Initialize the hid profile based on user input.

References at_ble_chr_t::additional_desc_count, at_ble_chr_t::additional_desc_list, AT_BLE_ATTR_NO_PERMISSIONS, AT_BLE_ATTR_READABLE_NO_AUTHN_NO_AUTHR, AT_BLE_ATTR_READABLE_REQ_AUTHN_NO_AUTHR, AT_BLE_ATTR_WRITABLE_NO_AUTHN_NO_AUTHR, AT_BLE_ATTR_WRITABLE_REQ_AUTHN_NO_AUTHR, AT_BLE_CHAR_NOTIFY, AT_BLE_CHAR_READ, AT_BLE_CHAR_WRITE, AT_BLE_CHAR_WRITE_WITHOUT_RESPONSE, AT_BLE_UUID_16, BLE_PAIR_ENABLE, at_ble_service_t::char_count, at_ble_service_t::char_list, at_ble_chr_t::char_val, at_ble_chr_t::client_config_desc, ctrl_point, DBG_LOG, DBG_LOG_PTS, at_ble_generic_att_desc_t::desc_val_length, at_ble_generic_att_desc_t::desc_val_max_length, FEATURE_REPORT, at_ble_generic_att_desc_t::handle, at_ble_server_config_desc_t::handle, at_ble_user_desc_t::handle, at_ble_char_val_t::handle, at_ble_service_t::handle, HID_CHARACTERISTIC_NUM, hid_serv::hid_control_point, hid_serv::hid_dev_boot_keyboard_in_report, hid_serv::hid_dev_boot_keyboard_out_report, hid_serv::hid_dev_boot_mouse_in_report, hid_serv::hid_dev_info, hid_serv::hid_dev_proto_mode_char, hid_serv::hid_dev_report_map_char, hid_serv::hid_dev_report_val_char, hid_serv::hid_dev_serv_handle, hid_serv::hid_dev_serv_uuid, HID_KEYBOARD_MODE, HID_MOUSE_MODE, HID_REPORT_REF_DESC, HID_SERV_UUID, HID_UUID_CHAR_BOOT_KEY_INPUT_REPORT, HID_UUID_CHAR_BOOT_KEY_OUTPUT_REPORT, HID_UUID_CHAR_BOOT_MOUSE_INPUT_REPORT, HID_UUID_CHAR_HID_CONTROL_POINT, HID_UUID_CHAR_HID_INFORMATION, HID_UUID_CHAR_PROTOCOL_MODE, HID_UUID_CHAR_REPORT, HID_UUID_CHAR_REPORT_MAP, i, id, at_ble_service_t::inc_list, at_ble_service_t::included_count, at_ble_char_val_t::init_value, INPUT_REPORT, keyb_in_report, Keyb_out_report, at_ble_user_desc_t::len, at_ble_char_val_t::len, at_ble_char_val_t::max_len, mode, mouse_in_report, NULL, OUTPUT_REPORT, at_ble_generic_att_desc_t::perm, at_ble_server_config_desc_t::perm, at_ble_service_t::perm, at_ble_user_desc_t::permissions, at_ble_char_val_t::permissions, at_ble_chr_t::presentation_format, PRIMARY_SERVICE, printf, at_ble_char_val_t::properties, hid_gatt_serv_handler::serv, hid_gatt_serv_handler::serv_chars, hid_gatt_serv_handler::serv_desc, at_ble_chr_t::server_config_desc, at_ble_uuid_t::type, at_ble_service_t::type, at_ble_chr_t::user_desc, at_ble_user_desc_t::user_description, at_ble_uuid_t::uuid, at_ble_generic_att_desc_t::uuid, at_ble_char_val_t::uuid, and at_ble_service_t::uuid.

Referenced by hid_prf_init().

void hid_serv_report_map ( uint8_t  servinst,
uint8_t *  report_info,
uint16_t  len 
)

Function update the report descriptor for HID device.

Parameters
[in]servinstHID service instance
[in]report_infoReport Info
[in]lenLength of report

Function update the report descriptor for HID device.

References at_ble_chr_t::char_val, hid_serv::hid_dev_report_map_char, at_ble_char_val_t::init_value, len, at_ble_char_val_t::len, at_ble_char_val_t::max_len, and hid_gatt_serv_handler::serv_chars.

Referenced by hid_prf_init().

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

Function to update the report.

Parameters
[in]conn_handleConnection handle
[in]serv_instService Instance
[in]report_idReport ID
[in]reportReport to be send
[in]lenLength of report

Function to update the report.

References at_ble_characteristic_value_set(), at_ble_notification_send(), AT_BLE_SUCCESS, DBG_LOG, DBG_LOG_DEV, hid_get_reportchar(), HID_INVALID_INST, id, and status.

Referenced by hid_prf_report_update().

uint16_t hid_service_dbreg ( uint8_t  inst,
uint8_t *  report_type,
uint8_t *  report_id,
uint8_t  report_num 
)

Register the service into database.

Parameters
[in]instHID service instance
[in]report_typeReport Type
[in]report_idReport ID
[in]report_numNumber of report

Register the service into database.

References at_ble_descriptor_value_set(), at_ble_service_define(), AT_BLE_SUCCESS, DBG_LOG, DBG_LOG_DEV, delay_ms, at_ble_service_t::handle, HID_SERV_FAILED, id, hid_gatt_serv_handler::serv, and status.

Referenced by hid_prf_init().