Mesh: Error handling in Model Publication Status 69/240569/1
authorAnupam Roy <anupam.r@samsung.com>
Fri, 7 Aug 2020 14:34:21 +0000 (20:04 +0530)
committerAnupam Roy <anupam.r@samsung.com>
Fri, 7 Aug 2020 14:34:21 +0000 (20:04 +0530)
This patch adds logic to send error event
to application, when error is
received in "Model Publication Status" event
from a node. For example, if provisioner
sends wrong appkey index, node will send
error to indicate operation is failed.

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

index ef3436c..f450f26 100644 (file)
@@ -500,6 +500,8 @@ static void __bt_mesh_send_model_publication_status_event(
        GArray *info = NULL;
 
        if (BLUETOOTH_ERROR_NONE == result) {
+               BT_INFO("Mesh: Model ID [0x%4.4x]", evt->model);
+               BT_INFO("Mesh: Model Publication Address [0x%2.2x]", evt->pub_addr);
                /* Send event */
                info = g_array_new(FALSE, FALSE, sizeof(gchar));
                g_array_append_vals(info, evt,
@@ -993,6 +995,7 @@ static void __bt_mesh_handle_pending_dev_config_request_info(int result,
                        break;
                }
                case BT_MESH_MODEL_GET_PUBLICATION: {
+                       BT_INFO("Mesh: Event for Model Get Publication Request");
                        bluetooth_mesh_model_configure_t *event;
                        bluetooth_mesh_model_configure_t *req;
 
@@ -1002,6 +1005,7 @@ static void __bt_mesh_handle_pending_dev_config_request_info(int result,
                        if (!g_strcmp0(req->net_uuid, event->net_uuid) &&
                                        req->primary_unicast == event->primary_unicast) {
                                /* Send Event */
+                               BT_INFO("Mesh: Send Model Publication status for Get Request");
                                __bt_mesh_send_model_publication_status_event( \
                                                BLUETOOTH_EVENT_MESH_MODEL_PUBLICATION_STATUS, \
                                                result, event);
@@ -1017,6 +1021,7 @@ static void __bt_mesh_handle_pending_dev_config_request_info(int result,
                        break;
                }
                case BT_MESH_MODEL_SET_PUBLICATION: {
+                       BT_INFO("Mesh: Event for Model Set Publication Request");
                        bluetooth_mesh_model_configure_t *event;
                        bluetooth_mesh_model_configure_t *req;
 
@@ -1026,6 +1031,7 @@ static void __bt_mesh_handle_pending_dev_config_request_info(int result,
                        if (!g_strcmp0(req->net_uuid, event->net_uuid) &&
                                req->primary_unicast == event->primary_unicast) {
                                /* Send Event */
+                               BT_INFO("Mesh: Send Model Publication status for Set Request");
                                __bt_mesh_send_model_publication_status_event( \
                                        BLUETOOTH_EVENT_MESH_MODEL_PUBLICATION_STATUS, \
                                                result, req);
@@ -1165,7 +1171,7 @@ void _bt_mesh_config_client_devkey_msg_handler(
                                event->source, __mesh_status_to_string(data[0]));
 
                if (data[0] != MESH_STATUS_SUCCESS)
-                       break;
+                       result = BLUETOOTH_ERROR_INTERNAL;
 
                /* Extract Element Address */
                ele_addr = l_get_le16(data + 1);
@@ -1181,16 +1187,22 @@ void _bt_mesh_config_client_devkey_msg_handler(
                        mod_id = MESH_VENDOR_ID_MASK | mod_id;
                }
 
+               param.model = mod_id;
+               BT_INFO("Model ID\t%4.4x\n", mod_id);
+
                param.primary_unicast = event->source;
                param.elem_index = ele_addr - event->source;
                /* Extract Publish Address */
                param.pub_addr = l_get_le16(data + 3);
+               BT_INFO("Mesh: Pub Address [0x%2.2x]", param.pub_addr);
 
                /* Extract Appkey Index */
                param.appkey_idx =  l_get_le16(data + 5);
+               BT_INFO("Mesh: AppKey Idx [0x%2.2x]", param.appkey_idx);
 
                /* Extract TTL */
                param.ttl = data[6];
+               BT_INFO("Mesh: TTL [0x%x]", param.ttl);
 
                /* Extract Period */
                param.period = data[7];