add gap_get_connection_type

This commit is contained in:
Matthias Ringwald 2015-11-11 11:51:17 +01:00
parent 61d2c63ca6
commit cf288f1ce3
2 changed files with 35 additions and 0 deletions

View File

@ -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

View File

@ -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
/**