From 8362d86ace1284132cb757c3a0ad64d464d89277 Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Fri, 13 May 2016 12:17:43 +0200 Subject: [PATCH] sm: add SM_EVENT_NUMERIC_COMPARISON_REQUEST and SM_EVENT_NUMERIC_COMPARISON_CANCEL events for Numeric Comparison --- src/btstack_defines.h | 29 ++++++++++++++---- src/btstack_event.h | 69 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+), 6 deletions(-) diff --git a/src/btstack_defines.h b/src/btstack_defines.h index 6057c61c0..29e868a80 100644 --- a/src/btstack_defines.h +++ b/src/btstack_defines.h @@ -735,12 +735,21 @@ typedef uint8_t sm_key_t[16]; #define SM_EVENT_PASSKEY_INPUT_CANCEL 0xD5 /** - * @format H1B + * @format H1B4 + * @param handle + * @param addr_type + * @param address + * @param passkey + */ +#define SM_EVENT_NUMERIC_COMPARISON_REQUEST 0xD6 + + /** + * @format H1B4 * @param handle * @param addr_type * @param address */ -#define SM_EVENT_IDENTITY_RESOLVING_STARTED 0xD6 +#define SM_EVENT_NUMERIC_COMPARISON_CANCEL 0xD7 /** * @format H1B @@ -748,7 +757,15 @@ typedef uint8_t sm_key_t[16]; * @param addr_type * @param address */ -#define SM_EVENT_IDENTITY_RESOLVING_FAILED 0xD7 +#define SM_EVENT_IDENTITY_RESOLVING_STARTED 0xD8 + + /** + * @format H1B + * @param handle + * @param addr_type + * @param address + */ +#define SM_EVENT_IDENTITY_RESOLVING_FAILED 0xD9 /** * @format H1B2 @@ -757,7 +774,7 @@ typedef uint8_t sm_key_t[16]; * @param address * @param le_device_db_index */ -#define SM_EVENT_IDENTITY_RESOLVING_SUCCEEDED 0xD8 +#define SM_EVENT_IDENTITY_RESOLVING_SUCCEEDED 0xDA /** * @format H1B @@ -765,7 +782,7 @@ typedef uint8_t sm_key_t[16]; * @param addr_type * @param address */ -#define SM_EVENT_AUTHORIZATION_REQUEST 0xD9 +#define SM_EVENT_AUTHORIZATION_REQUEST 0xDB /** * @format H1B1 @@ -774,7 +791,7 @@ typedef uint8_t sm_key_t[16]; * @param address * @param authorization_result */ -#define SM_EVENT_AUTHORIZATION_RESULT 0xDA +#define SM_EVENT_AUTHORIZATION_RESULT 0xDC // GAP diff --git a/src/btstack_event.h b/src/btstack_event.h index 04001c73a..30dc65300 100644 --- a/src/btstack_event.h +++ b/src/btstack_event.h @@ -2180,6 +2180,75 @@ static inline void sm_event_passkey_input_cancel_get_address(const uint8_t * eve } #endif +#ifdef ENABLE_BLE +/** + * @brief Get field handle from event SM_EVENT_NUMERIC_COMPARISON_REQUEST + * @param event packet + * @return handle + * @note: btstack_type H + */ +static inline hci_con_handle_t sm_event_numeric_comparison_request_get_handle(const uint8_t * event){ + return little_endian_read_16(event, 2); +} +/** + * @brief Get field addr_type from event SM_EVENT_NUMERIC_COMPARISON_REQUEST + * @param event packet + * @return addr_type + * @note: btstack_type 1 + */ +static inline uint8_t sm_event_numeric_comparison_request_get_addr_type(const uint8_t * event){ + return event[4]; +} +/** + * @brief Get field address from event SM_EVENT_NUMERIC_COMPARISON_REQUEST + * @param event packet + * @param Pointer to storage for address + * @note: btstack_type B + */ +static inline void sm_event_numeric_comparison_request_get_address(const uint8_t * event, bd_addr_t address){ + reverse_bd_addr(&event[5], address); +} +/** + * @brief Get field passkey from event SM_EVENT_NUMERIC_COMPARISON_REQUEST + * @param event packet + * @return passkey + * @note: btstack_type 4 + */ +static inline uint32_t sm_event_numeric_comparison_request_get_passkey(const uint8_t * event){ + return little_endian_read_32(event, 11); +} +#endif + +#ifdef ENABLE_BLE +/** + * @brief Get field handle from event SM_EVENT_NUMERIC_COMPARISON_CANCEL + * @param event packet + * @return handle + * @note: btstack_type H + */ +static inline hci_con_handle_t sm_event_numeric_comparison_cancel_get_handle(const uint8_t * event){ + return little_endian_read_16(event, 2); +} +/** + * @brief Get field addr_type from event SM_EVENT_NUMERIC_COMPARISON_CANCEL + * @param event packet + * @return addr_type + * @note: btstack_type 1 + */ +static inline uint8_t sm_event_numeric_comparison_cancel_get_addr_type(const uint8_t * event){ + return event[4]; +} +/** + * @brief Get field address from event SM_EVENT_NUMERIC_COMPARISON_CANCEL + * @param event packet + * @param Pointer to storage for address + * @note: btstack_type B + */ +static inline void sm_event_numeric_comparison_cancel_get_address(const uint8_t * event, bd_addr_t address){ + reverse_bd_addr(&event[5], address); +} +#endif + #ifdef ENABLE_BLE /** * @brief Get field handle from event SM_EVENT_IDENTITY_RESOLVING_STARTED