Microchip® Advanced Software Framework

hid.c File Reference

HID Service.

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

#include "stddef.h"
#include "stdio.h"
#include "string.h"
#include "at_ble_api.h"
#include "ble_manager.h"
#include "hid.h"
#include "hid_device.h"

Functions

void hid_boot_keyboardreport_update (at_ble_handle_t conn_handle, uint8_t serv_inst, uint8_t *bootreport, uint16_t len)
 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)
 to update the boot mouse report. More...
 
uint8_t hid_get_reportchar (uint16_t handle, uint8_t serv, uint8_t reportid)
 to get the report characteristic id. More...
 
uint8_t hid_get_reportid (uint8_t serv, uint16_t handle, uint8_t reportnum)
 to get the report ID. More...
 
uint8_t hid_ntf_instance (uint8_t serv_num, uint16_t char_handle)
 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)
 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)
 service Configuration function More...
 
void hid_serv_report_map (uint8_t servinst, uint8_t *report_info, uint16_t len)
 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)
 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 HID service. More...
 

Variables

uint8_t ctrl_point [1]
 
hid_gatt_serv_handler_t hid_inst [HID_MAX_SERV_INST]
 
hid_serv_t hid_serv_inst [HID_MAX_SERV_INST]
 
uint8_t keyb_in_report [8]
 
uint8_t Keyb_out_report [1]
 
int8_t mouse_in_report [4]
 
at_ble_generic_att_desc_t report_desc [HID_NUM_OF_REPORT]
 

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

to update the boot keyboard 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, and length.

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 
)

to update the boot mouse 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, and length.

Referenced by hid_prf_boot_mousereport_update().

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

to get the report characteristic id.

Function to get report characteristic id.

References at_ble_descriptor_value_get(), AT_BLE_SUCCESS, DBG_LOG_DEV, HID_INVALID_INST, and HID_NUM_OF_REPORT.

Referenced by hid_serv_report_update().

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

to get the report ID.

Function to get the report ID.

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

Referenced by hid_prf_char_changed_handler().

uint8_t hid_ntf_instance ( uint8_t  serv_num,
uint16_t  char_handle 
)

to get the notification instance.

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)

to get service instance.

Function to get service instance.

References DBG_LOG_DEV, and HID_MAX_SERV_INST.

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 
)

service Configuration function

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, 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, 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, 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 
)

update the report descriptor for HID device

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, 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 
)
uint16_t hid_service_dbreg ( uint8_t  inst,
uint8_t *  report_type,
uint8_t *  report_id,
uint8_t  report_num 
)

uint8_t ctrl_point[1]

Referenced by hid_serv_init().

hid_serv_t hid_serv_inst[HID_MAX_SERV_INST]
uint8_t keyb_in_report[8]

Referenced by hid_serv_init().

uint8_t Keyb_out_report[1]

Referenced by hid_serv_init().

int8_t mouse_in_report[4]

Referenced by hid_serv_init().