Fixed zero length data of descriptor read 86/181986/2
authorAmit Purwar <amit.purwar@samsung.com>
Tue, 19 Jun 2018 10:23:42 +0000 (15:53 +0530)
committerAmit Purwar <amit.purwar@samsung.com>
Wed, 20 Jun 2018 03:04:33 +0000 (08:34 +0530)
Change-Id: If1fe3d0ed882ae9ab9dc1b9d808f5f45c17d4fc1
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
bt-api/bt-event-handler.c
bt-service-adaptation/services/gatt/bt-service-gatt.c

index d1d52d5..a435157 100644 (file)
@@ -3646,7 +3646,11 @@ static void __bt_gatt_client_event_filter(GDBusConnection *connection,
                BT_DBG("GATT Client Descriptor Val len: [%d]", desc_prop.val_len);
 
                /* Copy Data */
-               memcpy(&desc_prop.value, g_variant_get_data(data_var), desc_prop.val_len);
+               if (desc_prop.val_len > 0) {
+                       BT_INFO("Get the desc read data");
+                       memcpy(&desc_prop.value, g_variant_get_data(data_var), desc_prop.val_len);
+               }
+
                memcpy(&desc_prop.prop.uuid, g_variant_get_data(desc_uuid_var), 16);
 
                /* Copy Char Data */
index 365bb55..61c4987 100644 (file)
@@ -3462,6 +3462,7 @@ static void __bt_handle_client_descriptor_read_data(
        if (event_data->uuid_status.conn_status.status != OAL_STATUS_SUCCESS)
                result = BLUETOOTH_ERROR_INTERNAL;
        else {
+               BT_INFO("desc data len:", event_data->data_len);
                if (event_data->data_len > 0) {
                        /* DEBUG */
                        for (i = 0; i < event_data->data_len; i++)
@@ -3475,55 +3476,60 @@ static void __bt_handle_client_descriptor_read_data(
                                        read_val,
                                        event_data->data_len,
                                        TRUE, NULL, NULL);
-                       /* SVC uuid */
-                       svc_uuid = g_memdup(&event_data->uuid_status.srvc_id.id.uuid.uuid[0], uuid_len);
+               } else {
+                       BT_INFO("Descriptor Read success, but no data!!!");
 
-                       data_svc_uuid = g_variant_new_from_data(
+                       data = g_variant_new_from_data(
                                        G_VARIANT_TYPE_BYTESTRING,
-                                       svc_uuid,
-                                       16,
-                                       TRUE, NULL, NULL);
+                                       NULL,
+                                       0,
+                                       FALSE, NULL, NULL);
+               }
+               /* SVC uuid */
+               svc_uuid = g_memdup(&event_data->uuid_status.srvc_id.id.uuid.uuid[0], uuid_len);
+
+               data_svc_uuid = g_variant_new_from_data(
+                               G_VARIANT_TYPE_BYTESTRING,
+                               svc_uuid,
+                               16,
+                               TRUE, NULL, NULL);
 
-                       /* Char uuid */
-                       char_uuid = g_memdup(&event_data->uuid_status.char_id.uuid.uuid[0], uuid_len);
+               /* Char uuid */
+               char_uuid = g_memdup(&event_data->uuid_status.char_id.uuid.uuid[0], uuid_len);
 
-                       data_char_uuid = g_variant_new_from_data(
-                                       G_VARIANT_TYPE_BYTESTRING,
-                                       char_uuid,
-                                       16,
-                                       TRUE, NULL, NULL);
+               data_char_uuid = g_variant_new_from_data(
+                               G_VARIANT_TYPE_BYTESTRING,
+                               char_uuid,
+                               16,
+                               TRUE, NULL, NULL);
 
-                       /* Desc uuid */
-                       desc_uuid = g_memdup(&event_data->uuid_status.descr_id.uuid.uuid[0], uuid_len);
+               /* Desc uuid */
+               desc_uuid = g_memdup(&event_data->uuid_status.descr_id.uuid.uuid[0], uuid_len);
 
-                       data_desc_uuid = g_variant_new_from_data(
-                                       G_VARIANT_TYPE_BYTESTRING,
-                                       desc_uuid,
-                                       16,
-                                       TRUE, NULL, NULL);
+               data_desc_uuid = g_variant_new_from_data(
+                               G_VARIANT_TYPE_BYTESTRING,
+                               desc_uuid,
+                               16,
+                               TRUE, NULL, NULL);
 
-                       param = g_variant_new("(isn@ayin@ayin@ayin@ay)", result,
-                                       conn_info->addr,
-                                       uuid_len,
-                                       data_svc_uuid,
-                                       event_data->uuid_status.srvc_id.id.inst_id,
-                                       16,
-                                       data_char_uuid,
-                                       event_data->uuid_status.char_id.inst_id,
-                                       16,
-                                       data_desc_uuid,
-                                       event_data->uuid_status.descr_id.inst_id,
-                                       event_data->data_len,
-                                       data);
+               param = g_variant_new("(isn@ayin@ayin@ayin@ay)", result,
+                               conn_info->addr,
+                               uuid_len,
+                               data_svc_uuid,
+                               event_data->uuid_status.srvc_id.id.inst_id,
+                               16,
+                               data_char_uuid,
+                               event_data->uuid_status.char_id.inst_id,
+                               16,
+                               data_desc_uuid,
+                               event_data->uuid_status.descr_id.inst_id,
+                               event_data->data_len,
+                               data);
 
-                       /* Send Event */
-                       _bt_send_event(BT_GATT_CLIENT_EVENT,
+               /* Send Event */
+               _bt_send_event(BT_GATT_CLIENT_EVENT,
                                        BLUETOOTH_EVENT_GATT_READ_DESC,
                                        param);
-               } else {
-                       BT_ERR("Descriptor Read success, but no data!!!");
-                       result = BLUETOOTH_ERROR_INTERNAL;
-               }
        }
        BT_INFO("Send DBUS rpely for GATT Read Descriptor");
        /* Send DBUS return */