From 774db595f91bdc15a0f97bd2c28161440a261f1c Mon Sep 17 00:00:00 2001 From: Christopher Collins Date: Tue, 14 Aug 2018 15:25:23 -0700 Subject: [PATCH] nimble/host: Remove spurious conn-update callback The GAP callback was incorrectly being called with an event type of BLE_GAP_EVENT_CONN_UPDATE each time a connection was terminated. For example, a typical disconnect event might look like this in the log: 023276 [ts=181843696us, mod=82 level=1] connection update; rc=531 023277 [ts=181921816us, mod=82 level=1] disconnect; reason=531 In most cases, only the second line should be present. The "connection update" event should only be signaled on termination if an update procedure for the connection happened to be in progress at the time. In that case, the connection termination causes the update procedure to fail. --- nimble/host/src/ble_gap.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/nimble/host/src/ble_gap.c b/nimble/host/src/ble_gap.c index bca989251..835afe72a 100644 --- a/nimble/host/src/ble_gap.c +++ b/nimble/host/src/ble_gap.c @@ -1004,8 +1004,10 @@ ble_gap_conn_broken(uint16_t conn_handle, int reason) entry = ble_gap_update_entry_remove(conn_handle); ble_hs_unlock(); - ble_gap_update_notify(conn_handle, reason); - ble_gap_update_entry_free(entry); + if (entry != NULL) { + ble_gap_update_notify(conn_handle, reason); + ble_gap_update_entry_free(entry); + } /* Indicate the connection termination to each module. The order matters * here: gatts must come before gattc to ensure the application does not