Enable GATT server indication for Tizen Speaker 95/213895/6
authorAnupam Roy <anupam.r@samsung.com>
Thu, 19 Sep 2019 01:24:11 +0000 (10:24 +0900)
committerDoHyun Pyun <dh79.pyun@samsung.com>
Tue, 1 Oct 2019 00:03:03 +0000 (09:03 +0900)
Change-Id: I7511f1ab1d2b010e0caf353ee51ef8eea67e244c
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
resource/csdk/connectivity/src/bt_le_adapter/tizen/caleserver_vd.c

index 68ad1f5..380778c 100644 (file)
@@ -809,6 +809,9 @@ CAResult_t CAAddNewCharacteristicsToGattServer(const bt_gatt_h svcPath, const ch
         properties = BT_GATT_PROPERTY_WRITE | BT_GATT_PROPERTY_READ;
     }
 
+    /* Add Indicate property by default */
+    properties |= BT_GATT_PROPERTY_INDICATE;
+
     bt_gatt_h charPath = NULL;
 
     int ret = bt_gatt_characteristic_create(charUUID, permissions, properties, charValue,
@@ -824,26 +827,23 @@ CAResult_t CAAddNewCharacteristicsToGattServer(const bt_gatt_h svcPath, const ch
     OIC_LOG_V(DEBUG, TAG,
               "bt_gatt_characteristic_create charPath obtained: %s", (char *)charPath);
 
-    if (read)
-    {
 #ifdef BLE_TIZEN_30
-        ret = bt_gatt_server_set_characteristic_notification_state_change_cb(charPath,
-                                                                             CALENotificationCb,
-                                                                             NULL);
+    ret = bt_gatt_server_set_characteristic_notification_state_change_cb(charPath,
+                                                                         CALENotificationCb,
+                                                                         NULL);
 #else
-        ret = bt_gatt_server_set_notification_state_change_cb(charPath, CALENotificationCb, NULL);
+    ret = bt_gatt_server_set_notification_state_change_cb(charPath, CALENotificationCb, NULL);
 #endif
-        if (0 != ret)
-        {
-            OIC_LOG_V(ERROR, TAG,
+    if (0 != ret)
+    {
+        OIC_LOG_V(ERROR, TAG,
 #ifdef BLE_TIZEN_30
-                      "bt_gatt_server_set_characteristic_notification_state_change_cb failed with ret[%s]",
+                  "bt_gatt_server_set_characteristic_notification_state_change_cb failed with ret[%s]",
 #else
-                      "bt_gatt_server_set_notification_state_change_cb  failed with ret[%s]",
+                  "bt_gatt_server_set_notification_state_change_cb  failed with ret[%s]",
 #endif
-                      CALEGetErrorMsg(ret));
-            return CA_STATUS_FAILED;
-        }
+        CALEGetErrorMsg(ret));
+        return CA_STATUS_FAILED;
     }
 
     ret =  bt_gatt_service_add_characteristic(svcPath, charPath);
@@ -864,34 +864,33 @@ CAResult_t CAAddNewCharacteristicsToGattServer(const bt_gatt_h svcPath, const ch
       * workaround for now so that it should work with both Android and Tizen devices.
       */
     if (read)
+        g_gattReadCharPath = charPath;
+    else
+        g_gattWriteCharPath = charPath;
+
+    char desc_value[2] = {0, 0};  // Notification enabled.
+    bt_gatt_h descriptor = NULL;
+    permissions = BT_GATT_PERMISSION_READ | BT_GATT_PERMISSION_WRITE;
+    ret = bt_gatt_descriptor_create(CA_GATT_CONFIGURATION_DESC_UUID, permissions,
+                                    desc_value, sizeof(desc_value),
+                                    &descriptor);
+    if (0 != ret)
     {
-            g_gattReadCharPath = charPath;
-    } else {
-        char desc_value[2] = {0, 0};  // Notification enabled.
-        bt_gatt_h descriptor = NULL;
-        permissions = BT_GATT_PERMISSION_READ | BT_GATT_PERMISSION_WRITE;
-        ret = bt_gatt_descriptor_create(CA_GATT_CONFIGURATION_DESC_UUID, permissions,
-                                        desc_value, sizeof(desc_value),
-                                        &descriptor);
-        if (0 != ret)
-        {
-            oc_mutex_unlock(g_leCharacteristicMutex);
-            OIC_LOG_V(ERROR, TAG,
-                      "bt_gatt_descriptor_create  failed with ret[%s]",
-                      CALEGetErrorMsg(ret));
-            return CA_STATUS_FAILED;
-        }
+        oc_mutex_unlock(g_leCharacteristicMutex);
+        OIC_LOG_V(ERROR, TAG,
+                  "bt_gatt_descriptor_create  failed with ret[%s]",
+                  CALEGetErrorMsg(ret));
+        return CA_STATUS_FAILED;
+    }
 
-        ret = bt_gatt_characteristic_add_descriptor(charPath, descriptor);
-        if (0 != ret)
-        {
-            oc_mutex_unlock(g_leCharacteristicMutex);
-            OIC_LOG_V(ERROR, TAG,
-                      "bt_gatt_characteristic_add_descriptor  failed with ret[%s]",
-                      CALEGetErrorMsg(ret));
-            return CA_STATUS_FAILED;
-        }
-        g_gattWriteCharPath = charPath;
+    ret = bt_gatt_characteristic_add_descriptor(charPath, descriptor);
+    if (0 != ret)
+    {
+        oc_mutex_unlock(g_leCharacteristicMutex);
+        OIC_LOG_V(ERROR, TAG,
+                  "bt_gatt_characteristic_add_descriptor  failed with ret[%s]",
+                  CALEGetErrorMsg(ret));
+        return CA_STATUS_FAILED;
     }
 
     oc_mutex_unlock(g_leCharacteristicMutex);