binding: bluetooth: available BT UUID profiles reporting 33/9633/1
authorMatt Ranostay <matt.ranostay@konsulko.com>
Wed, 7 Jun 2017 03:01:16 +0000 (20:01 -0700)
committerMatt Ranostay <matt.ranostay@konsulko.com>
Wed, 7 Jun 2017 20:41:18 +0000 (13:41 -0700)
Since selection connect/disconnect can be done to a certain
BT UUID profiles the available ones need to be listed to
subscribers.

Change-Id: I4497838ef2f9dd5e6fc40f1364a8b5f165a1831d
Bug-AGL: SPEC-638
Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
binding-bluetooth/bluetooth-api.c
binding-bluetooth/bluetooth-api.h
binding-bluetooth/bluetooth-manager.c
binding-bluetooth/bluetooth-manager.h
binding-bluetooth/bluez-client.c
binding-bluetooth/bluez-client.h

index 78fd87b..04fb259 100644 (file)
@@ -274,6 +274,23 @@ static json_object *new_json_object_from_device(struct btd_device *BDdevice, uns
         json_object_object_add(jresp, "HFPConnected", jstring);
     }
 
+    if (BD_UUID_PROFILES & filter)
+    {
+        GList *list = BDdevice->uuids;
+
+        if (list)
+        {
+            json_object *jarray = json_object_new_array();
+
+            for (;list;list=list->next)
+            {
+                jstring = json_object_new_string(list->data);
+                json_object_array_add(jarray, jstring);
+            }
+            json_object_object_add(jresp, "UUIDs", jarray);
+        }
+    }
+
     return jresp;
 }
 
@@ -398,7 +415,7 @@ static void bt_discovery_result (struct afb_req request)
         struct btd_device *BDdevice = tmp->data;
         //LOGD("\n%s\t%s\n",BDdevice->bdaddr,BDdevice->name);
 
-        unsigned int filter = BD_ADDER|BD_NAME|BD_PAIRED|BD_ACLCONNECTED|BD_AVCONNECTED|BD_HFPCONNECTED;
+        unsigned int filter = BD_ADDER|BD_NAME|BD_PAIRED|BD_ACLCONNECTED|BD_AVCONNECTED|BD_HFPCONNECTED|BD_UUID_PROFILES;
 
         json_object *jresp = new_json_object_from_device(BDdevice, filter);
 
@@ -733,7 +750,7 @@ static void eventpush (struct afb_req request)
  */
 void bt_broadcast_device_added(struct btd_device *BDdevice)
 {
-    unsigned int filter = BD_ADDER|BD_NAME|BD_PAIRED|BD_ACLCONNECTED|BD_AVCONNECTED|BD_HFPCONNECTED;
+    unsigned int filter = BD_ADDER|BD_NAME|BD_PAIRED|BD_ACLCONNECTED|BD_AVCONNECTED|BD_HFPCONNECTED|BD_UUID_PROFILES;
     int ret;
     json_object *jresp = new_json_object_from_device(BDdevice, filter);
 
@@ -765,7 +782,7 @@ void bt_broadcast_device_removed(struct btd_device *BDdevice)
 void bt_broadcast_device_properties_change(struct btd_device *BDdevice)
 {
 
-    unsigned int filter = BD_ADDER|BD_NAME|BD_PAIRED|BD_ACLCONNECTED|BD_AVCONNECTED|BD_HFPCONNECTED|BD_AVRCP_TITLE|BD_AVRCP_ARTIST|BD_AVRCP_STATUS|BD_AVRCP_DURATION|BD_AVRCP_POSITION|BD_TRANSPORT_STATE|BD_TRANSPORT_VOLUME;
+    unsigned int filter = BD_ADDER|BD_NAME|BD_PAIRED|BD_ACLCONNECTED|BD_AVCONNECTED|BD_HFPCONNECTED|BD_AVRCP_TITLE|BD_AVRCP_ARTIST|BD_AVRCP_STATUS|BD_AVRCP_DURATION|BD_AVRCP_POSITION|BD_TRANSPORT_STATE|BD_TRANSPORT_VOLUME|BD_UUID_PROFILES;
 
     int ret;
     json_object *jresp = new_json_object_from_device(BDdevice, filter);
index 4223ae0..b1dbd45 100644 (file)
@@ -40,6 +40,7 @@
 #define BD_AVRCP_POSITION LEFT_SHIFT(16)
 #define BD_TRANSPORT_STATE LEFT_SHIFT(17)
 #define BD_TRANSPORT_VOLUME LEFT_SHIFT(18)
+#define BD_UUID_PROFILES LEFT_SHIFT(19)
 
 
 /* -------------- PLUGIN DEFINITIONS ----------------- */
index 525d034..5ce90ce 100644 (file)
@@ -127,6 +127,7 @@ struct btd_device *device_copy(struct btd_device* device)
     temp->connected = device->connected;
     temp->avconnected = device->avconnected;
     temp->hfpconnected = device->hfpconnected;
+    temp->uuids = g_list_copy_deep(device->uuids, g_strdup, NULL);
 
     return temp;
 }
@@ -181,6 +182,12 @@ void device_free(struct btd_device* device)
         device->transport_state = NULL;
     }
 
+    if (device->uuids) {
+        D_PRINTF("uuids: xxx\n");
+        g_list_free_full(device->uuids, g_free);
+        device->uuids = NULL;
+    }
+
     g_free(device);
 }
 
@@ -587,6 +594,7 @@ struct btd_device *device_copy_from_bluez(struct bt_device* device)
     temp->trusted = device->trusted;
     temp->connected = device->connected;
     temp->avconnected = device->avconnected;
+    temp->uuids = g_list_copy_deep(device->uuids, g_strdup, NULL);
 
     return temp;
 }
index e05fcb1..b11b11d 100644 (file)
@@ -147,6 +147,7 @@ struct btd_device {
     gboolean    connected;
     gboolean    avconnected;
     gboolean    hfpconnected;
+    GList   *uuids;
 };
 
 typedef struct {
index 334a2b6..d078d06 100644 (file)
@@ -58,7 +58,7 @@ static struct bt_device *bluez_device_copy(struct bt_device* device)
     temp->avconnected = device->avconnected;
     temp->legacypairing = device->legacypairing;
     temp->rssi = device->rssi;
-    temp->uuids = g_variant_ref(device->uuids);
+    temp->uuids = g_list_copy(device->uuids);
 
     return temp;
 }
@@ -96,7 +96,7 @@ static void bluez_device_free(struct bt_device* device)
 
     if (device->uuids){
         D_PRINTF("uuids xxx\n");
-        g_variant_unref(device->uuids);
+        g_list_free_full(device->uuids, g_free);
         device->uuids = NULL;
     }
 
@@ -310,11 +310,19 @@ bluez_device1_properties_update(struct bt_device *device, GVariant *value)
             device->rssi = value_n;
 
         }else if (0==g_strcmp0(key,"UUIDs")) {
-            //g_print ("type '%s'\n", g_variant_get_type_string (subValue));
-            if (device->uuids)
-                g_variant_unref(device->uuids);
-            device->uuids = g_variant_new_variant(subValue);
+            GVariantIter iter;
+            gchar *val;
 
+            //g_print ("type '%s'\n", g_variant_get_type_string (subValue));
+            if (device->uuids) {
+                g_list_free_full(device->uuids, g_free);
+            }
+
+            g_variant_iter_init (&iter, subValue);
+            while (g_variant_iter_next (&iter, "s", &val))
+            {
+                device->uuids = g_list_append(device->uuids, g_strdup(val));
+            }
         }
     }
 
index 64ee9ad..17f82f0 100644 (file)
@@ -39,7 +39,7 @@ struct bt_device {
     gboolean    avconnected;
     gboolean    legacypairing;
     gint16      rssi;
-    GVariant    *uuids;
+    GList   *uuids;
 };
 
 typedef struct {