HPS: Assign SIG defined UUIDs for HPS attributes 90/59490/4
authorh.sandeep <h.sandeep@samsung.com>
Tue, 16 Feb 2016 04:59:32 +0000 (10:29 +0530)
committerh.sandeep <h.sandeep@samsung.com>
Mon, 21 Nov 2016 04:18:34 +0000 (09:48 +0530)
Change-Id: I4fdb50bd416e8b2a88eefa31a81446a99e9551f3
Signed-off-by: h.sandeep <h.sandeep@samsung.com>
bt-httpproxy/bt-httpproxy.c
bt-httpproxy/bt-httpproxy.h [changed mode: 0755->0644]

index 50e3de4..a345501 100644 (file)
@@ -110,6 +110,33 @@ static void _hps_convert_address_to_hex(bluetooth_device_address_t *addr_hex, co
                addr_hex->addr[i] = (unsigned char)addr[i];
 }
 
+static char *__hps_convert_uuid_to_uuid128(const char *uuid)
+{
+       int len;
+       char *uuid128;
+
+       len = strlen(uuid);
+
+       switch (len) {
+       case 4:         /* UUID 16bits */
+               uuid128 = g_strdup_printf("0000%s-0000-1000-8000-00805F9B34FB", uuid);
+               break;
+
+       case 8:         /* UUID 32bits */
+               uuid128 = g_strdup_printf("%s-0000-1000-8000-00805F9B34FB", uuid);
+               break;
+
+       case 36:        /* UUID 128bits */
+               uuid128 = strdup(uuid);
+               break;
+
+       default:
+               return NULL;
+       }
+
+       return uuid128;
+}
+
 static void _bt_hps_send_status_notification(unsigned short http_status,
                        unsigned char data_status,
                        bluetooth_device_address_t *unicast_address)
@@ -1390,8 +1417,7 @@ int _bt_hps_set_advertising_data(void)
        int ret;
        BT_DBG("");
 
-       // Temporary UUID is used. SIG have not yet defined the UUID yet
-       guint8 data[4]  = {0x03, 0x02, 0x00, 0x19};
+       guint8 data[4]  = {0x03, 0x02, 0x23, 0x18};
        bluetooth_advertising_data_t adv;
 
        BT_DBG("%x %x %x %x", data[0], data[1], data[2], data[3]);
@@ -1433,7 +1459,7 @@ int _bt_hps_prepare_httpproxy(void)
                goto fail;
        }
 
-       service_uuid = g_strdup(HPS_UUID);
+       service_uuid = __hps_convert_uuid_to_uuid128(HPS_UUID);
        ret = bluetooth_gatt_add_service(service_uuid, &hps_obj_path);
        if (ret != BLUETOOTH_ERROR_NONE) {
                BT_ERR("Failed to add service %d", ret);
@@ -1441,9 +1467,8 @@ int _bt_hps_prepare_httpproxy(void)
        }
 
        /* Characteristic URI */
-       props = BLUETOOTH_GATT_CHARACTERISTIC_PROPERTY_READ |
-                       BLUETOOTH_GATT_CHARACTERISTIC_PROPERTY_WRITE;
-       char_uuid = g_strdup(HTTP_URI_UUID);
+       props = BLUETOOTH_GATT_CHARACTERISTIC_PROPERTY_WRITE;
+       char_uuid = __hps_convert_uuid_to_uuid128(HTTP_URI_UUID);
        ret = bluetooth_gatt_add_new_characteristic(hps_obj_path, char_uuid, 0, props, &http_uri_obj_path);
        if (ret != BLUETOOTH_ERROR_NONE) {
                BT_ERR("Failed to add new char %d", ret);
@@ -1467,7 +1492,7 @@ int _bt_hps_prepare_httpproxy(void)
        /* Characteristic HTTP Headers */
        props = BLUETOOTH_GATT_CHARACTERISTIC_PROPERTY_READ |
                        BLUETOOTH_GATT_CHARACTERISTIC_PROPERTY_WRITE;
-       char_uuid = g_strdup(HTTP_HDR_UUID);
+       char_uuid = __hps_convert_uuid_to_uuid128(HTTP_HDR_UUID);
        ret = bluetooth_gatt_add_new_characteristic(hps_obj_path, char_uuid, 0, props, &http_hdr_obj_path);
        if (ret != BLUETOOTH_ERROR_NONE) {
                BT_ERR("Failed to add new char %d", ret);
@@ -1490,7 +1515,7 @@ int _bt_hps_prepare_httpproxy(void)
        /* Characteristic HTTP Entity Body */
        props = BLUETOOTH_GATT_CHARACTERISTIC_PROPERTY_READ |
                        BLUETOOTH_GATT_CHARACTERISTIC_PROPERTY_WRITE;
-       char_uuid = g_strdup(HTTP_ENTITY_UUID);
+       char_uuid = __hps_convert_uuid_to_uuid128(HTTP_ENTITY_UUID);
        ret = bluetooth_gatt_add_new_characteristic(hps_obj_path, char_uuid, 0, props, &http_entity_obj_path);
        if (ret != BLUETOOTH_ERROR_NONE) {
                BT_ERR("Failed to add new char %d", ret);
@@ -1511,9 +1536,8 @@ int _bt_hps_prepare_httpproxy(void)
 #endif
 
        /* Characteristic HTTP Control Point */
-       props = BLUETOOTH_GATT_CHARACTERISTIC_PROPERTY_READ |
-                       BLUETOOTH_GATT_CHARACTERISTIC_PROPERTY_WRITE;
-       char_uuid = g_strdup(HTTP_CP_UUID);
+       props = BLUETOOTH_GATT_CHARACTERISTIC_PROPERTY_WRITE;
+       char_uuid = __hps_convert_uuid_to_uuid128(HTTP_CP_UUID);
        ret = bluetooth_gatt_add_new_characteristic(hps_obj_path, char_uuid, 0, props, &http_cp_obj_path);
        if (ret != BLUETOOTH_ERROR_NONE) {
                BT_ERR("Failed to add new char %d", ret);
@@ -1534,10 +1558,8 @@ int _bt_hps_prepare_httpproxy(void)
 #endif
 
        /* Characteristic HTTP Status Code */
-       props = BLUETOOTH_GATT_CHARACTERISTIC_PROPERTY_READ |
-                       BLUETOOTH_GATT_CHARACTERISTIC_PROPERTY_WRITE |
-                       BLUETOOTH_GATT_CHARACTERISTIC_PROPERTY_NOTIFY;
-       char_uuid = g_strdup(HTTP_STATUS_UUID);
+       props =  BLUETOOTH_GATT_CHARACTERISTIC_PROPERTY_NOTIFY;
+       char_uuid = __hps_convert_uuid_to_uuid128(HTTP_STATUS_UUID);
        ret = bluetooth_gatt_add_new_characteristic(hps_obj_path, char_uuid, 0, props, &http_status_obj_path);
        if (ret != BLUETOOTH_ERROR_NONE) {
                BT_ERR("Failed to add new char %d", ret);
@@ -1550,7 +1572,7 @@ int _bt_hps_prepare_httpproxy(void)
                goto fail;
        }
 #endif
-       desc_uuid = g_strdup(HTTP_STATUS_CCC_DESC_UUID);
+       desc_uuid = __hps_convert_uuid_to_uuid128(HTTP_STATUS_CCC_DESC_UUID);
        ret = bluetooth_gatt_add_descriptor(http_status_obj_path, desc_uuid,
                                        (BLUETOOTH_GATT_PERMISSION_READ | BLUETOOTH_GATT_PERMISSION_WRITE),
                                        &http_status_desc_obj_path);
@@ -1567,9 +1589,8 @@ int _bt_hps_prepare_httpproxy(void)
 #endif
 
        /* Characteristic HTTPS Security */
-       props = BLUETOOTH_GATT_CHARACTERISTIC_PROPERTY_READ |
-                       BLUETOOTH_GATT_CHARACTERISTIC_PROPERTY_WRITE;
-       char_uuid = g_strdup(HTTP_SECURITY_UUID);
+       props = BLUETOOTH_GATT_CHARACTERISTIC_PROPERTY_READ;
+       char_uuid = __hps_convert_uuid_to_uuid128(HTTP_SECURITY_UUID);
        ret = bluetooth_gatt_add_new_characteristic(hps_obj_path, char_uuid, 0, props, &http_security_obj_path);
        if (ret != BLUETOOTH_ERROR_NONE) {
                BT_ERR("Failed to add new char %d", ret);
old mode 100755 (executable)
new mode 100644 (file)
index b1b02da..e0e575a
@@ -77,16 +77,16 @@ typedef enum http_request_state_tag {
 } http_request_state;
 
 
-// Temporary UUIDs. SIG has to define the UUIDs yet.
-#define HPS_UUID "00001900-0000-1000-8000-00805f9b34fb"
-#define HTTP_URI_UUID "00001901-0000-1000-8000-00805f9b34fb"
-#define HTTP_HDR_UUID "00001902-0000-1000-8000-00805f9b34fb"
-#define HTTP_ENTITY_UUID "00001903-0000-1000-8000-00805f9b34fb"
-#define HTTP_CP_UUID "00001904-0000-1000-8000-00805f9b34fb"
-#define HTTP_STATUS_UUID "00001905-0000-1000-8000-00805f9b34fb"
+/* HPS UUIDs. defined by SIG */
+#define HPS_UUID "1823"
+#define HTTP_URI_UUID "2ab6"
+#define HTTP_HDR_UUID "2ab7"
+#define HTTP_ENTITY_UUID "2ab9"
+#define HTTP_CP_UUID "2aba"
+#define HTTP_STATUS_UUID "2ab8"
+#define HTTP_SECURITY_UUID "2abb"
 /* CCC descriptor UUID is predefined by SIG */
 #define HTTP_STATUS_CCC_DESC_UUID "2902"
-#define HTTP_SECURITY_UUID "00001906-0000-1000-8000-00805f9b34fb"
 
 void _bt_hps_exit(void);
 int _bt_hps_prepare_httpproxy(void);