From: Abhay Agarwal Date: Thu, 20 Aug 2020 07:35:01 +0000 (+0530) Subject: Mesh: Enable simultaneous LE scan operations X-Git-Tag: accepted/tizen/unified/20200831.002545~1^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F89%2F241889%2F3;p=platform%2Fcore%2Fconnectivity%2Fbluetooth-frwk.git Mesh: Enable simultaneous LE scan operations Mesh operations over PB-ADV requires continous LE scan on HCI. When using HCI RAW channel for mesh operations, LE scan should not be disabled for their continous execution. This patch modifies to allow such simulataneous LE scan operations on bluetoothd and meshd. Change-Id: I6f1825d3a48536269fa1b520fd2171b7283f60b4 Signed-off-by: Abhay Agarwal --- diff --git a/bt-service/services/adapter/bt-service-core-adapter-le.c b/bt-service/services/adapter/bt-service-core-adapter-le.c index c03ec3f..99d7bb6 100644 --- a/bt-service/services/adapter/bt-service-core-adapter-le.c +++ b/bt-service/services/adapter/bt-service-core-adapter-le.c @@ -35,6 +35,7 @@ #include "bt-service-core-device.h" #include "bt-service-oob.h" #include "bt-service-battery-monitor.h" +#include "bt-service-mesh-common.h" #include #include @@ -106,6 +107,7 @@ static gboolean is_le_scanning = FALSE; 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 }; @@ -2054,6 +2056,9 @@ int _bt_start_le_scan(const char *sender, uid_t uid, pid_t pid) 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"); @@ -2158,6 +2163,15 @@ int _bt_stop_le_scan(const char *sender) _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); @@ -2240,6 +2254,27 @@ void _bt_restart_le_scan(void) 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; diff --git a/bt-service/services/include/bt-service-mesh-common.h b/bt-service/services/include/bt-service-mesh-common.h new file mode 100644 index 0000000..92471d8 --- /dev/null +++ b/bt-service/services/include/bt-service-mesh-common.h @@ -0,0 +1,43 @@ +/* + * Bluetooth-frwk + * + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * @author: Abhay Agarwal + * + * 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 +#include +#include "bluetooth-api.h" +#include "bluetooth-mesh-api.h" +#include +#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_*/ diff --git a/bt-service/services/mesh/bt-service-mesh-main.c b/bt-service/services/mesh/bt-service-mesh-main.c index 276ee95..89bbd9c 100644 --- a/bt-service/services/mesh/bt-service-mesh-main.c +++ b/bt-service/services/mesh/bt-service-mesh-main.c @@ -43,6 +43,7 @@ #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 @@ -108,6 +109,11 @@ static void __bt_mesh_terminate() _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, @@ -995,6 +1001,8 @@ int _bt_mesh_deinit(const char *sender) apps = g_slist_remove(apps, owner); g_free(owner); + _bt_mesh_deinitialized(); + return BLUETOOTH_ERROR_NONE; }