From: Anupam Roy Date: Fri, 17 Jul 2020 18:13:57 +0000 (+0530) Subject: Mesh: Create & attach ELL main loop X-Git-Tag: submit/tizen/20200724.011403~8 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=afbdbaa68dc90bd1d44c4f6fe61a380587089180;p=platform%2Fcore%2Fconnectivity%2Fbluetooth-frwk.git Mesh: Create & attach ELL main loop This patch primarily attaches bt-service with ELL mainloop and also initializes OAL Change-Id: I2cb5d5afe77051160e530ffb74d44de409d35e18 Signed-off-by: Anupam Roy --- diff --git a/bt-oal/bluez_hal/src/bt-hal-bluetooth.c b/bt-oal/bluez_hal/src/bt-hal-bluetooth.c index 691bf16..cf409a0 100644 --- a/bt-oal/bluez_hal/src/bt-hal-bluetooth.c +++ b/bt-oal/bluez_hal/src/bt-hal-bluetooth.c @@ -47,6 +47,7 @@ #include #endif #include +#include #define enum_prop_to_hal(prop, hal_prop, type) do { \ static type e; \ @@ -309,6 +310,11 @@ static const void *get_profile_interface(const char *profile_id) if (!strcmp(profile_id, BT_PROFILE_ADVANCED_AUDIO_SINK_ID)) return bt_get_a2dp_sink_interface(); + if (!strcmp(profile_id, BT_PROFILE_MESH_ID)) { + INFO("Mesh: Get MESH Stack Interface"); + return bt_get_mesh_interface(); + } + return NULL; } diff --git a/bt-service/services/adapter/bt-service-core-adapter.c b/bt-service/services/adapter/bt-service-core-adapter.c index f17dbff..ecf4aca 100644 --- a/bt-service/services/adapter/bt-service-core-adapter.c +++ b/bt-service/services/adapter/bt-service-core-adapter.c @@ -35,6 +35,7 @@ #include "bt-service-common.h" #include "bt-service-util.h" #include "bt-service-main.h" +#include "bt-service-mesh-main.h" #include "bt-service-core-adapter.h" #include "bt-service-core-device.h" #include "bt-service-event-receiver.h" @@ -1307,6 +1308,10 @@ int _bt_init_profiles() if (ret != BLUETOOTH_ERROR_NONE) BT_ERR("_bt_audio_initialize(BT_HFP_MODULE) Failed"); + /* Mesh Init */ + ret = _bt_mesh_init(); + if (ret != BLUETOOTH_ERROR_NONE) + BT_ERR("Mesh Initialization Failed!!"); return BLUETOOTH_ERROR_NONE; } diff --git a/bt-service/services/bt-service-main.c b/bt-service/services/bt-service-main.c index ea38343..782eaf2 100644 --- a/bt-service/services/bt-service-main.c +++ b/bt-service/services/bt-service-main.c @@ -23,8 +23,11 @@ #include #endif +#include +#include #include #include +#include #include "bt-internal-types.h" #include "bt-service-common.h" @@ -46,6 +49,32 @@ #include #include +/* ELL Start */ +struct ell_event_source { + GSource source; + GPollFD pollfd; +}; + +static gboolean event_prepare(GSource *source, gint *timeout) +{ + int r = l_main_prepare(); + *timeout = r; + + return FALSE; +} + +static gboolean event_check(GSource *source) +{ + l_main_iterate(0); + return FALSE; +} + +static GSourceFuncs event_funcs = { + .prepare = event_prepare, + .check = event_check, +}; +/* ELL End */ + static GMainLoop *main_loop; static gboolean terminated = FALSE; static gboolean is_initialized = FALSE; @@ -349,6 +378,9 @@ int _bt_service_initialize(void) int main(void) { struct sigaction sa; + /* ELL Start */ + struct ell_event_source *source; + /* ELL End */ BT_INFO_C("### Starting the bt-service daemon"); if (!TIZEN_FEATURE_BT_SUPPORTED) { @@ -374,12 +406,29 @@ int main(void) return 0; } + /* ELL Start */ + BT_INFO("ELL Main init"); + l_main_init(); + /* ELL End */ + bluetooth_plugin_init(); g_log_set_default_handler(__on_log_glib, NULL); main_loop = g_main_loop_new(NULL, FALSE); + /* ELL Start */ + source = (struct ell_event_source *) g_source_new(&event_funcs, + sizeof(struct ell_event_source)); + + source->pollfd.fd = l_main_get_epoll_fd(); + source->pollfd.events = G_IO_IN | G_IO_HUP | G_IO_ERR; + + g_source_add_poll((GSource *)source, &source->pollfd); + g_source_attach((GSource *) source, + g_main_loop_get_context(main_loop)); + + /* ELL End */ g_main_loop_run(main_loop); BT_DBG("g_main_loop_quit called!"); @@ -387,12 +436,20 @@ int main(void) _bt_service_unref_connection(); + /* ELL Start */ + g_source_destroy((GSource *) source); + /* ELL End */ + if (main_loop != NULL) g_main_loop_unref(main_loop); if (terminated == FALSE) __bt_release_service(); + /* ELL Start */ + l_main_exit(); + /* ELL End */ + return 0; } diff --git a/bt-service/services/include/bt-service-mesh-main.h b/bt-service/services/include/bt-service-mesh-main.h new file mode 100644 index 0000000..33ec0d1 --- /dev/null +++ b/bt-service/services/include/bt-service-mesh-main.h @@ -0,0 +1,42 @@ +/* + * Bluetooth-frwk + * + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * @author: Anupam Roy + * + * 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_MAIN_H_ +#define BT_SERVICE_MESH_MAIN_H_ + +#include +#include +#include "bluetooth-api.h" +#include "bluetooth-mesh-api.h" +#include + +#ifdef __cplusplus +extern "C" { +#endif + +int _bt_mesh_init(void); + +int _bt_mesh_deinit(void); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ +#endif /* BT_SERVICE_MESH_MAIN_H_ */