From: lly Date: Mon, 2 Sep 2019 06:38:12 +0000 (+0800) Subject: ble_mesh: add error checks for scan start/stop X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3e47f3ec87a4f297a8e4b5fda189d4d4a3c23b70;p=esp-idf ble_mesh: add error checks for scan start/stop --- diff --git a/components/bt/esp_ble_mesh/mesh_core/adv.c b/components/bt/esp_ble_mesh/mesh_core/adv.c index 87ef363061..a1c4cf9825 100644 --- a/components/bt/esp_ble_mesh/mesh_core/adv.c +++ b/components/bt/esp_ble_mesh/mesh_core/adv.c @@ -7,6 +7,9 @@ * SPDX-License-Identifier: Apache-2.0 */ +#include +#include + #include "freertos/FreeRTOS.h" #include "freertos/queue.h" #include "freertos/task.h" @@ -387,6 +390,8 @@ void bt_mesh_adv_init(void) int bt_mesh_scan_enable(void) { + int err; + struct bt_mesh_scan_param scan_param = { .type = BLE_MESH_SCAN_PASSIVE, #if defined(CONFIG_BLE_MESH_USE_DUPLICATE_SCAN) @@ -400,12 +405,26 @@ int bt_mesh_scan_enable(void) BT_DBG("%s", __func__); - return bt_le_scan_start(&scan_param, bt_mesh_scan_cb); + err = bt_le_scan_start(&scan_param, bt_mesh_scan_cb); + if (err && err != -EALREADY) { + BT_ERR("starting scan failed (err %d)", err); + return err; + } + + return 0; } int bt_mesh_scan_disable(void) { + int err; + BT_DBG("%s", __func__); - return bt_le_scan_stop(); + err = bt_le_scan_stop(); + if (err && err != -EALREADY) { + BT_ERR("stopping scan failed (err %d)", err); + return err; + } + + return 0; }