mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-26 02:37:41 +00:00
gap: add gap_bonded to check if bonding information is available for active connection
This commit is contained in:
parent
99c44ab2c7
commit
1e122704da
@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
||||
|
||||
### Added
|
||||
- GAP: add `gap_get_link_key_for_bd_addr`
|
||||
- GAP: add `gap_bonded` to check if bonding information is available for active connection
|
||||
- SM: support h7 for CTKD
|
||||
|
||||
### Changed
|
||||
|
@ -552,6 +552,14 @@ int gap_secure_connection(hci_con_handle_t con_handle);
|
||||
*/
|
||||
authorization_state_t gap_authorization_state(hci_con_handle_t con_handle);
|
||||
|
||||
/**
|
||||
* @brief Get bonded property (BR/EDR/LE)
|
||||
* @note LE: has to be called after identity resolving is complete
|
||||
* @param con_handle
|
||||
* @return true if bonded
|
||||
*/
|
||||
bool gap_bonded(hci_con_handle_t con_handle);
|
||||
|
||||
// Classic
|
||||
|
||||
/**
|
||||
|
21
src/hci.c
21
src/hci.c
@ -5953,6 +5953,27 @@ int gap_secure_connection(hci_con_handle_t con_handle){
|
||||
}
|
||||
}
|
||||
|
||||
bool gap_bonded(hci_con_handle_t con_handle){
|
||||
hci_connection_t * hci_connection = hci_connection_for_handle(con_handle);
|
||||
if (hci_connection == NULL) return 0;
|
||||
|
||||
link_key_t link_key;
|
||||
link_key_type_t link_key_type;
|
||||
switch (hci_connection->address_type){
|
||||
case BD_ADDR_TYPE_LE_PUBLIC:
|
||||
case BD_ADDR_TYPE_LE_RANDOM:
|
||||
return hci_connection->sm_connection.sm_le_db_index >= 0;
|
||||
#ifdef ENABLE_CLASSIC
|
||||
case BD_ADDR_TYPE_SCO:
|
||||
case BD_ADDR_TYPE_ACL:
|
||||
return hci_stack->link_key_db && hci_stack->link_key_db->get_link_key(hci_connection->address, link_key, &link_key_type);
|
||||
#endif
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
authorization_state_t gap_authorization_state(hci_con_handle_t con_handle){
|
||||
sm_connection_t * sm_conn = sm_get_connection_for_handle(con_handle);
|
||||
if (!sm_conn) return AUTHORIZATION_UNKNOWN; // wrong connection
|
||||
|
Loading…
x
Reference in New Issue
Block a user