mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-29 22:20:37 +00:00
gap: add gap_reconnect_security_setup_active indicating security setup as central
This commit is contained in:
parent
d4af1595c7
commit
dcd6c9b595
23
src/ble/sm.c
23
src/ble/sm.c
@ -4044,3 +4044,26 @@ void gap_advertisements_set_params(uint16_t adv_int_min, uint16_t adv_int_max, u
|
||||
direct_address_typ, direct_address, channel_map, filter_policy);
|
||||
}
|
||||
#endif
|
||||
|
||||
int gap_reconnect_security_setup_active(hci_con_handle_t con_handle){
|
||||
sm_connection_t * sm_conn = sm_get_connection_for_handle(con_handle);
|
||||
// wrong connection
|
||||
if (!sm_conn) return 0;
|
||||
// already encrypted
|
||||
if (sm_conn->sm_connection_encrypted) return 0;
|
||||
// only central can re-encrypt
|
||||
if (sm_conn->sm_role == HCI_ROLE_SLAVE) return 0;
|
||||
// irk status?
|
||||
switch(sm_conn->sm_irk_lookup_state){
|
||||
case IRK_LOOKUP_FAILED:
|
||||
// done, cannot setup encryption
|
||||
return 0;
|
||||
case IRK_LOOKUP_SUCCEEDED:
|
||||
break;
|
||||
default:
|
||||
// IR Lookup pending
|
||||
return 1;
|
||||
}
|
||||
// IRK Lookup Succeeded, re-encryption should be initiated. When done, state gets reset
|
||||
return sm_conn->sm_engine_state != SM_INITIATOR_CONNECTED;
|
||||
}
|
||||
|
@ -555,6 +555,15 @@ int gap_ssp_confirmation_negative(bd_addr_t addr);
|
||||
void gap_le_get_own_address(uint8_t * addr_type, bd_addr_t addr);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get state of connection re-encryptiong for bonded devices when in central role
|
||||
* @note used by gatt_client and att_server to wait for re-encryption
|
||||
* @param con_handle
|
||||
* @return 1 if security setup is active
|
||||
*/
|
||||
int gap_reconnect_security_setup_active(hci_con_handle_t con_handle);
|
||||
|
||||
|
||||
/* API_END*/
|
||||
|
||||
#if defined __cplusplus
|
||||
|
Loading…
x
Reference in New Issue
Block a user