From d1f4727b778c24b9fcc257d4404144f04c7af66d Mon Sep 17 00:00:00 2001 From: Szymon Janc Date: Fri, 18 Apr 2014 09:58:40 +0200 Subject: [PATCH] android/bluetooth: Fix bt_le_discovery_stop This fix invalid use of adapter.exp_discovery_type and not clearing callback. --- android/bluetooth.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/android/bluetooth.c b/android/bluetooth.c index 3a44dead9..20937309f 100644 --- a/android/bluetooth.c +++ b/android/bluetooth.c @@ -2956,18 +2956,23 @@ bool bt_le_set_advertising(bool advertising, bt_le_set_advertising_done cb, bool bt_le_discovery_stop(bt_le_discovery_stopped cb) { - if (!adapter.cur_discovery_type) { + if (adapter.cur_discovery_type != SCAN_TYPE_LE) { if (cb) cb(); + + gatt_device_found_cb = NULL; + return true; } - gatt_discovery_stopped_cb = cb; - /* Remove device found callback */ + if (!stop_discovery(SCAN_TYPE_LE)) + return false; + gatt_device_found_cb = NULL; - adapter.exp_discovery_type &= ~SCAN_TYPE_LE; + gatt_discovery_stopped_cb = cb; + adapter.exp_discovery_type = SCAN_TYPE_NONE; - return stop_discovery(adapter.cur_discovery_type); + return true; } bool bt_le_discovery_start(bt_le_device_found cb) -- 2.47.3