Get GATT specification Name from UUID 27/215527/1
authorAnupam Roy <anupam.r@samsung.com>
Thu, 10 Oct 2019 06:20:52 +0000 (11:50 +0530)
committerAnupam Roy <anupam.r@samsung.com>
Thu, 10 Oct 2019 06:20:52 +0000 (11:50 +0530)
This API will return GATT specification name
based on UUID provided by API caller.

Remarks: memory (name) should be freed by API caller.

Change-Id: If58204140538b17c619cc597417b3401651ecd5a
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
src/bluetooth-gatt.c
test/bt_unit_test.c
test/bt_unit_test.h

index a2b17334dc1c9e09fde8ecb3a0e0ce2ddeacccde..3b4578920c53b13f3d05e868cfc53daf8a37ce7c 100644 (file)
@@ -5073,3 +5073,24 @@ int bt_gatt_client_unset_att_mtu_changed_cb(bt_gatt_client_h client)
 
        return BT_ERROR_NONE;
 }
+
+int bt_gatt_get_uuid_specification_name(const char *uuid, char **name)
+{
+       int error_code = BT_ERROR_NONE;
+
+       BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_COMMON);
+       BT_CHECK_INPUT_PARAMETER(uuid);
+       BT_CHECK_INPUT_PARAMETER(name);
+
+       BT_INFO("UUID [%s]", uuid);
+
+       error_code = _bt_get_error_code(bluetooth_get_uuid_name(uuid, name));
+       if (error_code != BT_ERROR_NONE) { /* LCOV_EXCL_LINE */
+               BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), /* LCOV_EXCL_LINE */
+                               error_code); /* LCOV_EXCL_LINE */
+               return error_code; /* LCOV_EXCL_LINE */
+       }
+
+       BT_INFO("Specification Name [%s]", *name);
+       return BT_ERROR_NONE;
+}
index ee3c185006f03e699c71e3270fa4d5ef2a6545f6..6760f26ce5d7ca8d4ad35549e8b7092eb8409680 100644 (file)
@@ -643,6 +643,8 @@ tc_table_t tc_gatt[] = {
                , BT_UNIT_TEST_FUNCTION_GATT_SERVER_CHANGE_CUSTOM_VAL},
        {"Start Server"
                , BT_UNIT_TEST_FUNCTION_GATT_START_SERVER},
+       {"Get Specification Name from UUID"
+               , BT_UNIT_TEST_FUNCTION_GATT_GET_SPEC_NAME_FROM_UUID},
        {"ANCS (Pair)"
                , BT_UNIT_TEST_FUNCTION_ANCS_PAIR},
        {"ANCS (Watch notification)"
@@ -6967,6 +6969,17 @@ int test_input_callback(void *data)
                        TC_PRT("bt_gatt_server_register_service : %s\n", __bt_get_error_message(ret));
                        break;
                }
+               case BT_UNIT_TEST_FUNCTION_GATT_GET_SPEC_NAME_FROM_UUID: {
+                       char *name = NULL;
+                       char *uuid = "0000180F-0000-1000-8000-00805F9B34FB";
+                       ret = bt_gatt_get_uuid_specification_name(uuid, &name);
+                       TC_PRT("bt_gatt_get_uuid_specification_name : %s\n", __bt_get_error_message(ret));
+                       if (BT_ERROR_NONE == ret) {
+                               TC_PRT("UUID [%s] Specification Name [%s]", uuid, name);
+                               free(name);
+                       }
+                       break;
+               }
                case BT_UNIT_TEST_FUNCTION_GATT_SERVER_FOREACH_SERVICES: {
 #ifdef ARCH64
                        ret = bt_gatt_server_foreach_services(server,
index 2278306742b11ad616805522a7c691acf7dd271d..53b7add1d034e8ac5a389d6238bb8883824b7c79 100644 (file)
@@ -274,6 +274,7 @@ BT_UNIT_TEST_FUNCTION_ADAPTER_LE_SET_SCAN_TYPE,
        BT_UNIT_TEST_FUNCTION_GATT_SERVER_REGISTER_CUSTOM_SVC,
        BT_UNIT_TEST_FUNCTION_GATT_SERVER_CHANGE_CUSTOM_VAL,
        BT_UNIT_TEST_FUNCTION_GATT_START_SERVER,
+       BT_UNIT_TEST_FUNCTION_GATT_GET_SPEC_NAME_FROM_UUID,
        BT_UNIT_TEST_FUNCTION_ANCS_PAIR,
        BT_UNIT_TEST_FUNCTION_ANCS_WATCH,
        BT_UNIT_TEST_FUNCTION_ANCS_POSITIVE_ACTION,