#include "bt-service-core-device.h"
#include "bt-service-oob.h"
#include "bt-service-battery-monitor.h"
+#include "bt-service-mesh-common.h"
#include <oal-hardware.h>
#include <oal-manager.h>
static gboolean is_le_scan_hold = FALSE;
static gboolean scan_filter_enabled = FALSE;
static gboolean scan_stop_requested = FALSE;
+static gboolean is_mesh_le_scan_stop_hold = FALSE;
static bluetooth_le_scan_params_t le_scan_params = { BT_LE_ACTIVE_SCAN, 0, 0 };
scanner_list = g_slist_append(scanner_list, scanner);
}
+ BT_INFO("LE scan start request, Do not stop LE scan on mesh deinit");
+ is_mesh_le_scan_stop_hold = false;
+
/* Check scanning is in progress or not */
if (scanner->is_scanning) {
BT_ERR("BT is already in LE scanning");
_bt_set_le_scan_stop_requested(FALSE);
is_le_scan_hold = FALSE;
result = BLUETOOTH_ERROR_INTERNAL;
+ } else if (_bt_is_mesh_initialized()) {
+ /* Do not stop LE scan if BLE mesh running */
+ int value = 0;
+ g_idle_add(__send_le_scan_reply, (void *)(intptr_t)value);
+
+ BT_INFO("Hold LE scan stop, sets to stop on mesh deinit");
+ _bt_set_le_scan_stop_requested(FALSE);
+ is_mesh_le_scan_stop_hold = true;
+ result = BLUETOOTH_ERROR_NONE;
} else {
BT_INFO("Just stop LE scan");
ret = gattc_stop_le_discovery(g_gatt_client_id);
BT_ERR("gattc_start_le_discovery failed");
}
+void _bt_mesh_deinitialized() {
+ int ret;
+
+ if (!is_mesh_le_scan_stop_hold) {
+ BT_INFO("Not required to stop scan");
+ return;
+ }
+
+ BT_INFO("Gatt stop LE discovery was on hold for mesh");
+ BT_INFO("stop LE discovery");
+ ret = gattc_stop_le_discovery(g_gatt_client_id);
+ if (OAL_STATUS_SUCCESS == ret) {
+ _bt_set_le_scan_stop_requested(TRUE);
+ } else {
+ BT_ERR("gattc_stop_le_discovery failed");
+ }
+
+ is_mesh_le_scan_stop_hold = false;
+ return;
+}
+
static void _bt_disable_all_scanner_status(void)
{
GSList *l;
--- /dev/null
+/*
+ * Bluetooth-frwk
+ *
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * @author: Abhay Agarwal <ay.agarwal@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef BT_SERVICE_MESH_COMMON_H_
+#define BT_SERVICE_MESH_COMMON_H_
+
+#include <glib.h>
+#include <sys/types.h>
+#include "bluetooth-api.h"
+#include "bluetooth-mesh-api.h"
+#include <json-c/json.h>
+#include "oal-mesh.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void _bt_mesh_deinitialized();
+
+bool _bt_is_mesh_initialized();
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* BT_SERVICE_MESH_COMMON_H_*/
#include "bt-service-mesh-nodes.h"
#include "bt-service-mesh-config-client.h"
#include "bt-service-mesh-model.h"
+#include "bt-service-mesh-common.h"
#include <oal-mesh.h>
_bt_service_unregister_event_handler_callback(BT_MESH_MODULE);
}
+bool _bt_is_mesh_initialized()
+{
+ return (mesh_app_ref_count ? true : false);
+}
+
/* Event handlers */
static void __bt_mesh_handle_pending_request_info(int result,
int service_function, void *param,
apps = g_slist_remove(apps, owner);
g_free(owner);
+ _bt_mesh_deinitialized();
+
return BLUETOOTH_ERROR_NONE;
}