From 398ab102a417d0133e49b98e817748f18f38875a Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Tue, 22 Aug 2017 12:28:02 +0200 Subject: [PATCH] ancs_client: only send ANCS_SUBEVENT_CLIENT_DISCONNECTED if correct handle disconnected and connected event was sent before --- src/ble/ancs_client.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/ble/ancs_client.c b/src/ble/ancs_client.c index cfe6ee4a3..cf25411ab 100644 --- a/src/ble/ancs_client.c +++ b/src/ble/ancs_client.c @@ -220,7 +220,12 @@ static void handle_hci_event(uint8_t packet_type, uint16_t channel, uint8_t *pac return; case HCI_EVENT_DISCONNECTION_COMPLETE: - notify_client_simple(ANCS_SUBEVENT_CLIENT_DISCONNECTED); + if (hci_event_disconnection_complete_get_connection_handle(packet) != gc_handle) break; + if (tc_state == TC_SUBSCRIBED){ + notify_client_simple(ANCS_SUBEVENT_CLIENT_DISCONNECTED); + } + tc_state = TC_IDLE; + gc_handle = 0; return; default: @@ -319,7 +324,7 @@ static void handle_hci_event(uint8_t packet_type, uint16_t channel, uint8_t *pac value_length = little_endian_read_16(packet, 6); value = &packet[8]; - log_info("ANCS Ntoficiation, value handle %u", value_handle); + log_info("ANCS Notification, value handle %u", value_handle); if (value_handle == ancs_data_source_characteristic.value_handle){ int i;