Mesh: Reset launch timer ID upon expiry 02/241302/2
authorAnupam Roy <anupam.r@samsung.com>
Wed, 19 Aug 2020 05:40:19 +0000 (11:10 +0530)
committerAnupam Roy <anupam.r@samsung.com>
Wed, 19 Aug 2020 05:52:43 +0000 (05:52 +0000)
This patch resets timer ID, upon timer expiry.
If timer ID is not expired, other application
gets timed out on MESH INIT request, as status
remains in progress.

This patch also handles, stack initialization done
error in FRWK. Already done should be treated as
success.

Change-Id: Ic334498ccfbeca18c7c18efceffd1a03129f9241
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
bt-api/bt-mesh.c
bt-service/services/mesh/bt-service-mesh-main.c

index 07af058..fa20b68 100644 (file)
@@ -47,7 +47,8 @@ BT_EXPORT_API int bluetooth_mesh_init(mesh_cb_func_ptr cb,
 
        BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
 
-       if (ret != BLUETOOTH_ERROR_NONE) {
+       if (ret != BLUETOOTH_ERROR_NONE &&
+                       ret != BLUETOOTH_ERROR_ALREADY_INITIALIZED) {
                BT_ERR("Fail to init the mesh in bt-service");
                return ret;
        }
index 56dc71b..ee82600 100644 (file)
@@ -775,18 +775,21 @@ static int __bt_mesh_enable()
        oal_status_t status = OAL_STATUS_SUCCESS;
        BT_INFO("Mesh: Set dbus callbacks");
        status = mesh_enable();
-       if (OAL_STATUS_SUCCESS != status) {
+       if (OAL_STATUS_SUCCESS != status &&
+                       OAL_STATUS_ALREADY_DONE != status) {
                BT_ERR("Mesh: Failed to enable mesh interface, status: %d",
                                status);
                return BLUETOOTH_ERROR_INTERNAL;
        }
-       BT_INFO("Mesh: Stack Initialization Done successfully");
+       BT_INFO("Mesh: Stack Initialization Done successfully: status [%d]",
+                       status);
 
        /* Register MESH event handler */
        _bt_service_register_event_handler_callback(BT_MESH_MODULE,
                        __handle_mesh_events);
 
-       return BLUETOOTH_ERROR_NONE;
+       return (status == OAL_STATUS_SUCCESS ? BLUETOOTH_ERROR_NONE : \
+                       BLUETOOTH_ERROR_ALREADY_INITIALIZED);
 }
 
 static gboolean __bt_mesh_launch_timer_expired_cb(gpointer data)
@@ -794,7 +797,8 @@ static gboolean __bt_mesh_launch_timer_expired_cb(gpointer data)
        BT_INFO("Mesh: Enable Mesh dbus");
        int ret = BLUETOOTH_ERROR_NONE;
        ret = __bt_mesh_enable();
-       if (BLUETOOTH_ERROR_NONE != ret)
+       if (BLUETOOTH_ERROR_NONE != ret &&
+               BLUETOOTH_ERROR_ALREADY_INITIALIZED != ret)
                BT_ERR("Mesh: Mesh enable failed: %d", ret);
 
        /* Handle DBUS Context return */
@@ -802,6 +806,10 @@ static gboolean __bt_mesh_launch_timer_expired_cb(gpointer data)
        __bt_mesh_handle_pending_request_info(ret,
                        BT_MESH_INIT,
                        NULL, 0);
+
+       /* Reset launch timer ID */
+       launch_timer = 0;
+
        return FALSE;
 }
 
@@ -809,6 +817,7 @@ int _bt_mesh_init(void)
 {
        int ret = BLUETOOTH_ERROR_NONE;
 
+       BT_INFO("Mesh: Launch Timer val [%u]", launch_timer);
        if (launch_timer > 0) {
                BT_INFO("Mesh: BT_MESH_INIT in progress");
                return ret;