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,
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);
* 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);