mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-29 12:32:54 +00:00
hci: emit dedicated bonding complete before disconnection complete
This commit is contained in:
parent
672e36abdf
commit
046ec007c6
21
src/hci.c
21
src/hci.c
@ -2405,12 +2405,19 @@ static void event_handler(uint8_t *packet, int size){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// re-enable advertisements for le connections if active
|
|
||||||
conn = hci_connection_for_handle(handle);
|
conn = hci_connection_for_handle(handle);
|
||||||
if (!conn) break;
|
if (!conn) break;
|
||||||
|
// mark connection for shutdown
|
||||||
conn->state = RECEIVED_DISCONNECTION_COMPLETE;
|
conn->state = RECEIVED_DISCONNECTION_COMPLETE;
|
||||||
|
|
||||||
|
// emit dedicatd bonding event
|
||||||
|
if (conn->bonding_flags & BONDING_EMIT_COMPLETE_ON_DISCONNECT){
|
||||||
|
hci_emit_dedicated_bonding_result(conn->address, conn->bonding_status);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_BLE
|
#ifdef ENABLE_BLE
|
||||||
#ifdef ENABLE_LE_PERIPHERAL
|
#ifdef ENABLE_LE_PERIPHERAL
|
||||||
|
// re-enable advertisements for le connections if active
|
||||||
if (hci_is_le_connection(conn)){
|
if (hci_is_le_connection(conn)){
|
||||||
hci_reenable_advertisements_if_needed();
|
hci_reenable_advertisements_if_needed();
|
||||||
}
|
}
|
||||||
@ -2624,18 +2631,10 @@ static void event_handler(uint8_t *packet, int size){
|
|||||||
handle = little_endian_read_16(packet, 3);
|
handle = little_endian_read_16(packet, 3);
|
||||||
hci_connection_t * aConn = hci_connection_for_handle(handle);
|
hci_connection_t * aConn = hci_connection_for_handle(handle);
|
||||||
if (aConn) {
|
if (aConn) {
|
||||||
uint8_t status = aConn->bonding_status;
|
// discard connection if app did not trigger a reconnect in the event handler
|
||||||
uint16_t flags = aConn->bonding_flags;
|
|
||||||
bd_addr_t bd_address;
|
|
||||||
(void)memcpy(&bd_address, aConn->address, 6);
|
|
||||||
// only discard connection if app did not trigger a reconnect
|
|
||||||
if (aConn->state == RECEIVED_DISCONNECTION_COMPLETE){
|
if (aConn->state == RECEIVED_DISCONNECTION_COMPLETE){
|
||||||
hci_shutdown_connection(aConn);
|
hci_shutdown_connection(aConn);
|
||||||
}
|
}
|
||||||
// connection struct might be gone, don't access anymore
|
|
||||||
if (flags & BONDING_EMIT_COMPLETE_ON_DISCONNECT){
|
|
||||||
hci_emit_dedicated_bonding_result(bd_address, status);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user