mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-25 18:35:17 +00:00
sm: fix Random Address generation when enabled before HCI is working
This commit is contained in:
parent
804d3e67ed
commit
52b551c3a3
@ -2890,13 +2890,17 @@ static void sm_event_packet_handler (uint8_t packet_type, uint16_t channel, uint
|
||||
le_device_db_set_local_bd_addr(local_bd_addr);
|
||||
|
||||
dkg_state = sm_persistent_irk_ready ? DKG_CALC_DHK : DKG_CALC_IRK;
|
||||
rau_state = RAU_IDLE;
|
||||
#ifdef ENABLE_LE_SECURE_CONNECTIONS
|
||||
if (!sm_have_ec_keypair){
|
||||
setup->sm_passkey_bit = 0;
|
||||
ec_key_generation_state = EC_KEY_GENERATION_ACTIVE;
|
||||
}
|
||||
#endif
|
||||
// trigger Random Address generation if requested before
|
||||
rau_state = RAU_IDLE;
|
||||
if (gap_random_adress_type != GAP_RANDOM_ADDRESS_TYPE_OFF) {
|
||||
gap_random_address_trigger();
|
||||
}
|
||||
sm_run();
|
||||
}
|
||||
break;
|
||||
|
@ -283,7 +283,6 @@ int sm_le_device_index(hci_con_handle_t con_handle );
|
||||
|
||||
/**
|
||||
* @brief Set Elliptic Key Public/Private Keypair
|
||||
* @note Creating a new key pair requires about 4600 bytes additional when used with MBEDTLS EC
|
||||
* @note Using the same key for more than one device is not recommended.
|
||||
* @param qx 32 bytes
|
||||
* @param qy 32 bytes
|
||||
|
@ -2026,6 +2026,7 @@ static void hci_state_reset(void){
|
||||
|
||||
// LE
|
||||
hci_stack->adv_addr_type = 0;
|
||||
hci_stack->le_advertisements_random_address_set = 0;
|
||||
memset(hci_stack->adv_address, 0, 6);
|
||||
hci_stack->le_scanning_state = LE_SCAN_IDLE;
|
||||
hci_stack->le_scan_type = 0xff;
|
||||
@ -2546,7 +2547,9 @@ static void hci_run(void){
|
||||
hci_stack->le_scan_response_data);
|
||||
return;
|
||||
}
|
||||
if (hci_stack->le_advertisements_todo & LE_ADVERTISEMENT_TASKS_ENABLE){
|
||||
// Random address needs to be set before enabling advertisements
|
||||
if ((hci_stack->le_advertisements_todo & LE_ADVERTISEMENT_TASKS_ENABLE)
|
||||
&& (hci_stack->le_advertisements_own_address_type == 0 || hci_stack->le_advertisements_random_address_set)){
|
||||
hci_stack->le_advertisements_todo &= ~LE_ADVERTISEMENT_TASKS_ENABLE;
|
||||
hci_send_cmd(&hci_le_set_advertise_enable, 1);
|
||||
return;
|
||||
@ -2979,6 +2982,7 @@ int hci_send_cmd_packet(uint8_t *packet, int size){
|
||||
hci_stack->adv_addr_type = packet[8];
|
||||
}
|
||||
if (IS_COMMAND(packet, hci_le_set_random_address)){
|
||||
hci_stack->le_advertisements_random_address_set = 1;
|
||||
reverse_bd_addr(&packet[3], hci_stack->adv_address);
|
||||
}
|
||||
if (IS_COMMAND(packet, hci_le_set_advertise_enable)){
|
||||
|
@ -642,7 +642,7 @@ typedef struct {
|
||||
/* buffer for scan enable cmd - 0xff no change */
|
||||
uint8_t new_scan_enable_value;
|
||||
|
||||
uint16_t sco_voice_setting;
|
||||
uint16_t sco_voice_setting;
|
||||
|
||||
uint8_t loopback_mode;
|
||||
|
||||
@ -672,6 +672,7 @@ typedef struct {
|
||||
uint8_t le_advertisements_active;
|
||||
uint8_t le_advertisements_enabled;
|
||||
uint8_t le_advertisements_todo;
|
||||
uint8_t le_advertisements_random_address_set;
|
||||
|
||||
uint16_t le_advertisements_interval_min;
|
||||
uint16_t le_advertisements_interval_max;
|
||||
|
Loading…
x
Reference in New Issue
Block a user