Mesh: Handle timeout for missing request 55/242355/1
authorAbhay Agarwal <ay.agarwal@samsung.com>
Tue, 25 Aug 2020 12:52:26 +0000 (18:22 +0530)
committerAbhay Agarwal <ay.agarwal@samsung.com>
Tue, 25 Aug 2020 15:45:17 +0000 (21:15 +0530)
This patch handles
- Fix reset scan and provision states on app deinit.
- Fix group message response processing
- Handles timeout for publication get/set
- Handles timeout for model appkey bind/unbind.

Change-Id: I6a4425f39f6db3697d6f610bf614129dfa7e0e33
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
bt-service/services/mesh/bt-service-mesh-config-client.c
bt-service/services/mesh/bt-service-mesh-main.c
bt-service/services/mesh/bt-service-mesh-model.c

index 28f5afd..d005d1f 100644 (file)
@@ -320,6 +320,28 @@ static void __bt_mesh_wait_response_timeout(
                                BT_MESH_MODEL_CONFIG_GROUP_SUB, req->data,
                                        sizeof(bluetooth_mesh_model_configure_t));
                break;
+       case MESH_OPCODE_CONFIG_MODEL_PUB_GET:
+               /* Send event with timeout */
+               __bt_mesh_handle_pending_dev_config_request_info(
+                       BLUETOOTH_ERROR_TIMEOUT,
+                               BT_MESH_MODEL_GET_PUBLICATION, req->data,
+                               sizeof(bluetooth_mesh_model_configure_t));
+               break;
+       case MESH_OPCODE_CONFIG_MODEL_PUB_SET:
+               /* Send event with timeout */
+               __bt_mesh_handle_pending_dev_config_request_info(
+                       BLUETOOTH_ERROR_TIMEOUT,
+                               BT_MESH_MODEL_SET_PUBLICATION, req->data,
+                               sizeof(bluetooth_mesh_model_configure_t));
+               break;
+       case MESH_OPCODE_MODEL_APP_BIND:
+       case MESH_OPCODE_MODEL_APP_UNBIND:
+               /* Send event with timeout */
+               __bt_mesh_handle_pending_dev_config_request_info(
+                       BLUETOOTH_ERROR_TIMEOUT,
+                               BT_MESH_MODEL_CONFIGURE_APPKEY, req->data,
+                               sizeof(bluetooth_mesh_model_configure_t));
+               break;
        default:
                break;
        }
index e3ccbce..9d4198f 100644 (file)
@@ -926,6 +926,11 @@ int _bt_mesh_deinit(const char *sender)
 
        if (mesh_app_ref_count == 1) {
                BT_INFO("Mesh: Only one app using Mesh Stack: Unload & reduce ref count");
+
+               /* Reset states */
+               _bt_mesh_set_scanning_state(false);
+               _bt_mesh_set_provisioning_state(false);
+
                /* Terminate bluetooth-meshd */
                ret = actd_stop_unit(UNIT_CONTROL_BUS_TYPE_SYSTEM,
                                MESH_SYSTEMD_SERVICE_NAME, 5000);
index d38db10..1e191b3 100644 (file)
@@ -196,7 +196,6 @@ static struct mesh_pending_request *__bt_mesh_get_request_by_response(
        for (; entry; entry = entry->next) {
                struct mesh_pending_request *req = entry->data;
 
-               /* Test */
                BT_INFO("Mesh: Req addr [0x%4.4x] req opcode [0x%4.4x] res [0x%4.4x]", req->addr, req->cmd->opcode, req->cmd->response);
                BT_INFO("Mesh: Current req addr [0x%4.4x] res [0x%4.4x]", addr, response);
                _bt_mesh_util_convert_hex_to_string((uint8_t *) net_uuid, 16, uuid_str,
@@ -206,8 +205,8 @@ static struct mesh_pending_request *__bt_mesh_get_request_by_response(
                _bt_mesh_util_convert_hex_to_string((uint8_t *) req->net_uuid, 16, uuid_str1,
                                BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1);
                BT_INFO("Mesh: Net UUID1[%s]", uuid_str1);
+               /* Do not compare addr - In case of group message address may not match */
                if (!memcmp(net_uuid, req->net_uuid, 16) &&
-                               req->addr == addr &&
                                req->cmd->response == response)
                        return req;
        }
@@ -279,8 +278,7 @@ static void __bt_mesh_handle_pending_msg_request_info(int result,
 
                        BT_DBG("Request Sender: [%s]", req_info->sender);
                        /* Match Network and Remote Node unicast*/
-                       if (!g_strcmp0(event->net_uuid, req->net_uuid) &&
-                               event->primary_unicast == req->primary_unicast) {
+                       if (!g_strcmp0(event->net_uuid, req->net_uuid)) {
                                event->elem_index = req->elem_index;
 
                                /* Send Event */