Mesh: Handle 'Browse'& 'Vendor Feat' cmd Timeout 98/239898/1
authorAnupam Roy <anupam.r@samsung.com>
Thu, 30 Jul 2020 10:34:29 +0000 (16:04 +0530)
committerAnupam Roy <anupam.r@samsung.com>
Thu, 30 Jul 2020 10:34:29 +0000 (16:04 +0530)
This patch handles Timeout of remote commands
(Mesh node browse & Mesh node vendor feature) and
sends Error to application.

Change-Id: I6013cbfa99dbed60d904bc7f7e422646160f645b
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
bt-service/services/mesh/bt-service-mesh-config-client.c

index aa3b38e..d1ca68c 100644 (file)
@@ -235,14 +235,29 @@ static void __bt_mesh_wait_response_timeout(
 
        switch(req->cmd->opcode) {
        case MESH_OPCODE_DEV_COMP_GET: {
-               /* Send event with timeout */
+               /* Send event with timeout for Vendor Features */
+               bluetooth_mesh_node_features_t *vendor_event = \
+                       g_malloc0(sizeof(bluetooth_mesh_node_features_t));
+
+               _bt_mesh_util_convert_hex_to_string((uint8_t *) req->net_uuid, 16,
+                       vendor_event->net_uuid,
+                               BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1);
+               vendor_event->unicast = req->addr;
+                __bt_mesh_handle_pending_dev_config_request_info(
+                       BLUETOOTH_ERROR_TIMEOUT, BT_MESH_NODE_GET_VENDOR_FEATURES,
+                               vendor_event, sizeof(bluetooth_mesh_node_features_t));
+               g_free(vendor_event);
+
+               /* Send event with timeout for Node Browse */
                event_mesh_devkey_message_t *event = \
                        g_malloc0(sizeof(event_mesh_devkey_message_t));
                memcpy(event->net_uuid.uuid, req->net_uuid, 16);
                event->source = req->addr;
+
                 __bt_mesh_handle_pending_dev_config_request_info(
                        BLUETOOTH_ERROR_TIMEOUT, BT_MESH_NODE_BROWSE,
                                event, sizeof(event_mesh_devkey_message_t));
+
                g_free(event);
                break;
        }
@@ -756,6 +771,8 @@ static void __bt_mesh_handle_pending_dev_config_request_info(int result,
                                        _bt_mesh_node_get_element_count(event->net_uuid.uuid, remote_addr, &elem_count);
                                        node->unicast = event->source;
                                        node->count = elem_count;
+                                       BT_INFO("Mesh: Browse event for Node: Unicast [0x%2.2x] Element Count [%d]",
+                                               node->unicast, elem_count);
                                        /* Send Event */
                                        __bt_mesh_send_node_browsed_event(result, node);
 
@@ -1596,6 +1613,8 @@ int _bt_mesh_node_discover_vendor_features(const char *app_cred, const char *sen
                        strlen(req->net_uuid), net_uuid.uuid, 16);
        /* Check if Node's vendor features are already svaed or not */
        if (_bt_mesh_node_get_vendor_features(net_uuid.uuid, req->unicast, req)) {
+               BT_INFO("Mesh: Vendor Features already available for Node: Unicast [0x%.2x]",
+                               req->unicast);
                /* Schedule event ot Application */
                bluetooth_mesh_node_features_t *event = \
                        g_memdup(req, sizeof(bluetooth_mesh_node_features_t));
@@ -1614,6 +1633,7 @@ int _bt_mesh_node_discover_vendor_features(const char *app_cred, const char *sen
                        strlen(req->net_uuid), net_uuid.uuid, 16);
 
        dest = req->unicast;
+       BT_INFO("Mesh: Get Vendor Features for Remote Node Unicast [0x%2.2x]", dest);
 
        /* Check pending request */
        if (_bt_mesh_check_pending_request(MESH_OPCODE_DEV_COMP_GET,
@@ -1622,6 +1642,7 @@ int _bt_mesh_node_discover_vendor_features(const char *app_cred, const char *sen
                return BLUETOOTH_ERROR_DEVICE_BUSY;
        }
 
+       BT_INFO("Mesh: Browse Remote Node: Unicast [0x%2.2x]", dest);
        /* Get Subnet index of the rmeote node for TX encryption */
        netkey_idx = _bt_mesh_node_get_subnet_idx(net_uuid.uuid, dest);
        if (netkey_idx == MESH_NET_IDX_INVALID)
@@ -1677,6 +1698,7 @@ int _bt_mesh_browse_remote_node(const char *app_cred,
                        dev_uuid.uuid, &dest))
                return BLUETOOTH_ERROR_INTERNAL;
 
+       BT_INFO("Mesh: Browse Remote Node: Unicast [0x%2.2x]", dest);
        /* Check pending request */
        if (_bt_mesh_check_pending_request(MESH_OPCODE_DEV_COMP_GET,
                        dest, net_uuid.uuid)) {