Languages

Menu
Sites
Language
Getting characteristic and descriptor for Bluetooth LE device by UUID

There is option in native application just like as in android and iOS to get the characteristic and descriptor by their UUID. An example code is given below

char *svc_uuid = "0000180f-0000-1000-8000-00805f9b34fb"; /* Battery service */
char *chr_uuid = "00002a19-0000-1000-8000-00805f9b34fb"; /* Battery level */
/* Client characteristic configuration */
char *desc_uuid = "00002902-0000-1000-8000-00805f9b34fb";
bt_gatt_h svc = NULL;
bt_gatt_h chr = NULL;
bt_gatt_h desc = NULL;

ret = bt_gatt_client_get_service(client, svc_uuid, &svc);
if (ret != BT_ERROR_NONE) {
    dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_client_get_service failed: %d", ret);

    return;
}

ret = bt_gatt_service_get_characteristic(svc, chr_uuid, &chr);
if (ret != BT_ERROR_NONE) {
    dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_service_get_characteristic failed: %d", ret);

    return;
}

ret = bt_gatt_characteristic_get_descriptor(chr, desc_uuid, &desc);
if (ret != BT_ERROR_NONE) {
    dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_characteristic_get_descriptor failed: %d", ret);

    return;
}

ret = __bt_gatt_client_set_value("int32", "1234", desc);
if (ret != BT_ERROR_NONE) {
    dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_set_value failed: %d", ret);

    return;
}

ret = bt_gatt_client_write_value(desc, __bt_gatt_client_write_complete_cb, NULL);

if (ret != BT_ERROR_NONE) {
    dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_client_write_value failed: %d", ret);

    return;
}

But I couldn't find any such methods for web applications. Is there any way to get the required descriptor and characteristic without having to loop through the entire characteristics?

Responses

1 Replies
André Reus

hi Aldrin Joe Mathew

You may check this document

https://developer.tizen.org/development/guides/web-application/connectivity-and-wireless/bluetooth#Connecting

here all the examples are given with loop. I also checked for a function in API reference. No function is found to directly get the required Descriptor or Characteristic. 

https://developer.tizen.org/development/api-references/web-application?redirect=/dev-guide/2.4/org.tizen.web.apireference/html/device_api/mobile/tizen/bluetooth.html#BluetoothGATTService

If you found, please let us know!