From 5437569d899b2de454eb6af3fe5739fab77403cc Mon Sep 17 00:00:00 2001 From: Szymon Janc Date: Fri, 18 Apr 2014 09:56:38 +0200 Subject: [PATCH] android/bluetooth: Fix bt_le_discovery_start This fix wrong use of adapter.exp_discovery_type and setting callback even if failed to start discovery. --- android/bluetooth.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/android/bluetooth.c b/android/bluetooth.c index a119c47ed..3a44dead9 100644 --- a/android/bluetooth.c +++ b/android/bluetooth.c @@ -2975,15 +2975,18 @@ bool bt_le_discovery_start(bt_le_device_found cb) if (!(adapter.current_settings & MGMT_SETTING_POWERED)) return false; - gatt_device_found_cb = cb; - - adapter.exp_discovery_type |= SCAN_TYPE_LE; - /* If core is discovering, don't bother */ - if (adapter.cur_discovery_type) + if (adapter.cur_discovery_type != SCAN_TYPE_NONE) { + gatt_device_found_cb = cb; return true; + } - return start_discovery(adapter.exp_discovery_type); + if (start_discovery(SCAN_TYPE_LE)) { + gatt_device_found_cb = cb; + return true; + } + + return false; } static uint8_t set_adapter_scan_mode(const void *buf, uint16_t len) -- 2.47.3