From 38c89bb1b787ecaadaf06c8fdbafdec93ebe70cf Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Thu, 3 Dec 2020 20:25:14 +0100 Subject: [PATCH] sm: add SM_EVENT_PAIRING_STARTED --- src/btstack_defines.h | 17 +++++++++++++---- src/btstack_event.h | 30 ++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/src/btstack_defines.h b/src/btstack_defines.h index 449266a98..0708afdd5 100644 --- a/src/btstack_defines.h +++ b/src/btstack_defines.h @@ -1282,7 +1282,16 @@ typedef uint8_t sm_key_t[16]; */ #define SM_EVENT_IDENTITY_CREATED 0xDB - /** +/** + * @brief Emitted to inform app that pairing has started. + * @format H1B + * @param handle + * @param addr_type + * @param address + */ +#define SM_EVENT_PAIRING_STARTED 0xDC + +/** * @brief Emitted to inform app that pairing is complete. Possible status values: * ERROR_CODE_SUCCESS -> pairing success * ERROR_CODE_CONNECTION_TIMEOUT -> timeout @@ -1296,7 +1305,7 @@ typedef uint8_t sm_key_t[16]; * @param status * @param reason if status == ERROR_CODE_AUTHENTICATION_FAILURE */ -#define SM_EVENT_PAIRING_COMPLETE 0xDC +#define SM_EVENT_PAIRING_COMPLETE 0xDD /** @@ -1306,7 +1315,7 @@ typedef uint8_t sm_key_t[16]; * @param addr_type * @param address */ -#define SM_EVENT_REENCRYPTION_STARTED 0xDD +#define SM_EVENT_REENCRYPTION_STARTED 0xDE /** * @brief Proactive Authentication for bonded devices complete. Possible status values: @@ -1319,7 +1328,7 @@ typedef uint8_t sm_key_t[16]; * @param address * @param status */ -#define SM_EVENT_REENCRYPTION_COMPLETE 0xDE +#define SM_EVENT_REENCRYPTION_COMPLETE 0xDF // GAP diff --git a/src/btstack_event.h b/src/btstack_event.h index 318382fb7..5ade56878 100644 --- a/src/btstack_event.h +++ b/src/btstack_event.h @@ -2974,6 +2974,36 @@ static inline uint16_t sm_event_identity_created_get_index(const uint8_t * event } #endif +#ifdef ENABLE_BLE +/** + * @brief Get field handle from event SM_EVENT_PAIRING_STARTED + * @param event packet + * @return handle + * @note: btstack_type H + */ +static inline hci_con_handle_t sm_event_pairing_started_get_handle(const uint8_t * event){ + return little_endian_read_16(event, 2); +} +/** + * @brief Get field addr_type from event SM_EVENT_PAIRING_STARTED + * @param event packet + * @return addr_type + * @note: btstack_type 1 + */ +static inline uint8_t sm_event_pairing_started_get_addr_type(const uint8_t * event){ + return event[4]; +} +/** + * @brief Get field address from event SM_EVENT_PAIRING_STARTED + * @param event packet + * @param Pointer to storage for address + * @note: btstack_type B + */ +static inline void sm_event_pairing_started_get_address(const uint8_t * event, bd_addr_t address){ + reverse_bytes(&event[5], address, 6); +} +#endif + #ifdef ENABLE_BLE /** * @brief Get field handle from event SM_EVENT_PAIRING_COMPLETE