mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-25 07:43:38 +00:00
add gap_get_connection_type
This commit is contained in:
parent
61d2c63ca6
commit
cf288f1ce3
14
src/gap.h
14
src/gap.h
@ -77,6 +77,13 @@ typedef enum {
|
||||
// GAP_SECURITY_AUTHORIZED
|
||||
} gap_security_state;
|
||||
|
||||
typedef enum {
|
||||
GAP_CONNECTION_INVALID,
|
||||
GAP_CONNECTION_ACL,
|
||||
GAP_CONNECTION_SCO,
|
||||
GAP_CONNECTION_LE
|
||||
} gap_connection_type_t;
|
||||
|
||||
/* API_START */
|
||||
|
||||
/**
|
||||
@ -114,6 +121,13 @@ int gap_mitm_protection_required_for_security_level(gap_security_level_t level)
|
||||
void gap_set_local_name(const char * local_name);
|
||||
/* API_END*/
|
||||
|
||||
/**
|
||||
* @brief Get connection type
|
||||
* @param con_handle
|
||||
* @result connection_type
|
||||
*/
|
||||
gap_connection_type_t gap_get_connection_type(hci_con_handle_t connection_handle);
|
||||
|
||||
#if defined __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
21
src/hci.c
21
src/hci.c
@ -3217,6 +3217,27 @@ le_command_status_t gap_disconnect(hci_con_handle_t handle){
|
||||
return BLE_PERIPHERAL_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get connection type
|
||||
* @param con_handle
|
||||
* @result connection_type
|
||||
*/
|
||||
gap_connection_type_t gap_get_connection_type(hci_con_handle_t connection_handle){
|
||||
hci_connection_t * conn = hci_connection_for_handle(connection_handle);
|
||||
if (!conn) return GAP_CONNECTION_INVALID;
|
||||
switch (conn->address_type){
|
||||
case BD_ADDR_TYPE_LE_PUBLIC:
|
||||
case BD_ADDR_TYPE_LE_RANDOM:
|
||||
return GAP_CONNECTION_LE;
|
||||
case BD_ADDR_TYPE_SCO:
|
||||
return GAP_CONNECTION_SCO;
|
||||
case BD_ADDR_TYPE_CLASSIC:
|
||||
return GAP_CONNECTION_ACL;
|
||||
default:
|
||||
return GAP_CONNECTION_INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_BLE
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user