hci/gap: save the le connection interval on connection complete and connection update

This commit is contained in:
Milanka Ringwald 2018-11-12 15:00:10 +01:00
parent 900fc9c688
commit c9db5c2133
3 changed files with 24 additions and 4 deletions

View File

@ -396,6 +396,12 @@ int gap_auto_connection_stop(bd_addr_type_t address_typ, bd_addr_t address);
*/
void gap_auto_connection_stop_all(void);
/**
* @brief Get connection interval
* @return connection interval, otherwise 0 if error
*/
uint16_t gap_le_connection_interval(hci_con_handle_t connection_handle);
/**
*
* @brief Get encryption key size.

View File

@ -2384,8 +2384,9 @@ static void event_handler(uint8_t *packet, int size){
conn->state = OPEN;
conn->role = packet[6];
conn->con_handle = little_endian_read_16(packet, 4);
conn->con_handle = hci_subevent_le_connection_complete_get_connection_handle(packet);
conn->le_connection_interval = hci_subevent_le_connection_complete_get_conn_interval(packet);
#ifdef ENABLE_LE_PERIPHERAL
if (packet[6] == HCI_ROLE_SLAVE){
hci_reenable_advertisements_if_needed();
@ -2403,8 +2404,14 @@ static void event_handler(uint8_t *packet, int size){
hci_emit_nr_connections_changed();
break;
// log_info("LE buffer size: %u, count %u", little_endian_read_16(packet,6), packet[8]);
// log_info("LE buffer size: %u, count %u", little_endian_read_16(packet,6), packet[8]);
case HCI_SUBEVENT_LE_CONNECTION_UPDATE_COMPLETE:
handle = hci_subevent_le_connection_update_complete_get_connection_handle(packet);
conn = hci_connection_for_handle(handle);
if (!conn) break;
conn->le_connection_interval = hci_subevent_le_connection_update_complete_get_conn_interval(packet);
break;
case HCI_SUBEVENT_LE_REMOTE_CONNECTION_PARAMETER_REQUEST:
// connection
handle = hci_subevent_le_remote_connection_parameter_request_get_connection_handle(packet);
@ -4599,6 +4606,12 @@ void gap_auto_connection_stop_all(void){
}
hci_run();
}
uint16_t gap_le_connection_interval(hci_con_handle_t connection_handle){
hci_connection_t * conn = hci_connection_for_handle(connection_handle);
if (!conn) return 0;
return conn->le_connection_interval;
}
#endif
#endif

View File

@ -526,6 +526,7 @@ typedef struct {
uint16_t le_supervision_timeout;
#ifdef ENABLE_BLE
uint16_t le_connection_interval;
// LE Security Manager
sm_connection_t sm_connection;