diff --git a/src/gap.h b/src/gap.h index 00313dc3b..0b627ee25 100644 --- a/src/gap.h +++ b/src/gap.h @@ -128,6 +128,13 @@ gap_connection_type_t gap_get_connection_type(hci_con_handle_t connection_handle */ void gap_set_local_name(const char * local_name); +/** + * @brief Set Extended Inquiry Response data + * @param eir_data size 240 bytes, is not copied make sure memory is accessible during stack startup + * @note has to be done before stack starts up + */ +void gap_set_extended_inquiry_response(const uint8_t * data); + /** * @brief Set class of device that will be set during Bluetooth init. * @note has to be done before stack starts up diff --git a/src/hci.c b/src/hci.c index b807eef1b..4b0d9d1a7 100644 --- a/src/hci.c +++ b/src/hci.c @@ -1082,6 +1082,9 @@ static void hci_initializing_run(void){ hci_send_cmd(&hci_write_local_name, local_name); } break; + case HCI_INIT_WRITE_EIR_DATA: + hci_send_cmd(&hci_write_extended_inquiry_response, 0, hci_stack->eir_data); + break; case HCI_INIT_WRITE_INQUIRY_MODE: hci_send_cmd(&hci_write_inquiry_mode, (int) hci_stack->inquiry_mode); hci_stack->substate = HCI_INIT_W4_WRITE_INQUIRY_MODE; @@ -1342,6 +1345,11 @@ static void hci_initializing_event_handler(uint8_t * packet, uint16_t size){ if (hci_stack->local_supported_commands[0] & 0x02) break; hci_stack->substate = HCI_INIT_LE_SET_SCAN_PARAMETERS; return; + case HCI_INIT_W4_WRITE_LOCAL_NAME: + // skip write eir data if no eir data set + if (hci_stack->eir_data) break; + hci_stack->substate = HCI_INIT_WRITE_INQUIRY_MODE; + return; #ifdef ENABLE_SCO_OVER_HCI case HCI_INIT_W4_WRITE_SCAN_ENABLE: @@ -3590,6 +3598,15 @@ void gap_auto_connection_stop_all(void){ #endif +/** + * @brief Set Extended Inquiry Response data + * @param eir_data size 240 bytes, is not copied make sure memory is accessible during stack startup + * @note has to be done before stack starts up + */ +void gap_set_extended_inquiry_response(const uint8_t * data){ + hci_stack->eir_data = data; +} + /** * @brief Set inquiry mode: standard, with RSSI, with RSSI + Extended Inquiry Results. Has to be called before power on. * @param inquriy_mode see bluetooth_defines.h diff --git a/src/hci.h b/src/hci.h index 6bfb69373..cdb2dfeef 100644 --- a/src/hci.h +++ b/src/hci.h @@ -488,6 +488,8 @@ typedef enum hci_init_state{ HCI_INIT_W4_WRITE_CLASS_OF_DEVICE, HCI_INIT_WRITE_LOCAL_NAME, HCI_INIT_W4_WRITE_LOCAL_NAME, + HCI_INIT_WRITE_EIR_DATA, + HCI_INIT_W4_WRITE_EIR_DATA, HCI_INIT_WRITE_INQUIRY_MODE, HCI_INIT_W4_WRITE_INQUIRY_MODE, HCI_INIT_WRITE_SCAN_ENABLE, @@ -576,6 +578,7 @@ typedef struct { // basic configuration const char * local_name; + const uint8_t * eir_data; uint32_t class_of_device; bd_addr_t local_bd_addr; uint8_t ssp_enable;