diff --git a/src/btstack_defines.h b/src/btstack_defines.h index 397aa0379..6df8d31b8 100644 --- a/src/btstack_defines.h +++ b/src/btstack_defines.h @@ -935,6 +935,7 @@ typedef uint8_t sm_key_t[16]; #define HCI_EVENT_AVRCP_META 0xEC #define HCI_EVENT_GOEP_META 0xED #define HCI_EVENT_PBAP_META 0xEE +#define HCI_EVENT_HID_META 0xEF // Potential other meta groups // #define HCI_EVENT_BNEP_META 0xxx @@ -1551,4 +1552,29 @@ typedef uint8_t sm_key_t[16]; */ #define PBAP_SUBEVENT_OPERATION_COMPLETED 0x03 +/** + * @format 121BH1 + * @param subevent_code + * @param hid_cid + * @param status + * @param bd_addr + * @param con_handle + * @param incoming + */ +#define HID_SUBEVENT_CONNECTION_OPENED 0x01 + +/** + * @format 12 + * @param subevent_code + * @param hid_cid +*/ +#define HID_SUBEVENT_CONNECTION_CLOSED 0x02 + +/** + * @format 12 + * @param subevent_code + * @param hid_cid +*/ +#define HID_SUBEVENT_CAN_SEND_NOW 0x03 + #endif diff --git a/src/btstack_event.h b/src/btstack_event.h index e0f76ed93..970a8f129 100644 --- a/src/btstack_event.h +++ b/src/btstack_event.h @@ -133,6 +133,14 @@ static inline uint8_t hci_event_pbap_meta_get_subevent_code(const uint8_t * even static inline uint8_t hci_event_le_meta_get_subevent_code(const uint8_t * event){ return event[2]; } +/*** + * @brief Get subevent code for hid event + * @param event packet + * @return subevent_code + */ +static inline uint8_t hci_event_hid_meta_get_subevent_code(const uint8_t * event){ + return event[2]; +} /** * @brief Get field status from event HCI_EVENT_INQUIRY_COMPLETE * @param event packet @@ -4975,6 +4983,72 @@ static inline uint8_t pbap_subevent_operation_completed_get_status(const uint8_t return event[5]; } +/** + * @brief Get field hid_cid from event HID_SUBEVENT_CONNECTION_OPENED + * @param event packet + * @return hid_cid + * @note: btstack_type 2 + */ +static inline uint16_t hid_subevent_connection_opened_get_hid_cid(const uint8_t * event){ + return little_endian_read_16(event, 3); +} +/** + * @brief Get field status from event HID_SUBEVENT_CONNECTION_OPENED + * @param event packet + * @return status + * @note: btstack_type 1 + */ +static inline uint8_t hid_subevent_connection_opened_get_status(const uint8_t * event){ + return event[5]; +} +/** + * @brief Get field bd_addr from event HID_SUBEVENT_CONNECTION_OPENED + * @param event packet + * @param Pointer to storage for bd_addr + * @note: btstack_type B + */ +static inline void hid_subevent_connection_opened_get_bd_addr(const uint8_t * event, bd_addr_t bd_addr){ + reverse_bd_addr(&event[6], bd_addr); +} +/** + * @brief Get field con_handle from event HID_SUBEVENT_CONNECTION_OPENED + * @param event packet + * @return con_handle + * @note: btstack_type H + */ +static inline hci_con_handle_t hid_subevent_connection_opened_get_con_handle(const uint8_t * event){ + return little_endian_read_16(event, 12); +} +/** + * @brief Get field incoming from event HID_SUBEVENT_CONNECTION_OPENED + * @param event packet + * @return incoming + * @note: btstack_type 1 + */ +static inline uint8_t hid_subevent_connection_opened_get_incoming(const uint8_t * event){ + return event[14]; +} + +/** + * @brief Get field hid_cid from event HID_SUBEVENT_CONNECTION_CLOSED + * @param event packet + * @return hid_cid + * @note: btstack_type 2 + */ +static inline uint16_t hid_subevent_connection_closed_get_hid_cid(const uint8_t * event){ + return little_endian_read_16(event, 3); +} + +/** + * @brief Get field hid_cid from event HID_SUBEVENT_CAN_SEND_NOW + * @param event packet + * @return hid_cid + * @note: btstack_type 2 + */ +static inline uint16_t hid_subevent_can_send_now_get_hid_cid(const uint8_t * event){ + return little_endian_read_16(event, 3); +} + /* API_END */ diff --git a/tool/btstack_event_generator.py b/tool/btstack_event_generator.py index 1955a3602..a563ada52 100755 --- a/tool/btstack_event_generator.py +++ b/tool/btstack_event_generator.py @@ -16,7 +16,8 @@ meta_events = [ 'HFP', 'HSP', 'PBAP', - 'LE' + 'LE', + 'HID', ] supported_event_groups = meta_events + [ @@ -30,6 +31,7 @@ supported_event_groups = meta_events + [ 'GATT', 'BNEP', 'ATT', + 'HID', ] program_info = '''