summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Ranostay <matt.ranostay@konsulko.com>2017-06-06 20:01:16 -0700
committerMatt Ranostay <matt.ranostay@konsulko.com>2017-06-07 13:41:18 -0700
commitd074104294bf19d9bda3ddd6ddb110d3563472a7 (patch)
tree6f9ec2b63bbbd454a9da90ee27ba20b4423031b0
parent8ee62398d467a4031a4307199687812f5105e500 (diff)
binding: bluetooth: available BT UUID profiles reporting
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>
-rw-r--r--bluetooth-api.c23
-rw-r--r--bluetooth-api.h1
-rw-r--r--bluetooth-manager.c8
-rw-r--r--bluetooth-manager.h1
-rw-r--r--bluez-client.c20
-rw-r--r--bluez-client.h2
6 files changed, 45 insertions, 10 deletions
diff --git a/bluetooth-api.c b/bluetooth-api.c
index 78fd87b..04fb259 100644
--- a/bluetooth-api.c
+++ b/bluetooth-api.c
@@ -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);
diff --git a/bluetooth-api.h b/bluetooth-api.h
index 4223ae0..b1dbd45 100644
--- a/bluetooth-api.h
+++ b/bluetooth-api.h
@@ -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 ----------------- */
diff --git a/bluetooth-manager.c b/bluetooth-manager.c
index 525d034..5ce90ce 100644
--- a/bluetooth-manager.c
+++ b/bluetooth-manager.c
@@ -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;
}
diff --git a/bluetooth-manager.h b/bluetooth-manager.h
index e05fcb1..b11b11d 100644
--- a/bluetooth-manager.h
+++ b/bluetooth-manager.h
@@ -147,6 +147,7 @@ struct btd_device {
gboolean connected;
gboolean avconnected;
gboolean hfpconnected;
+ GList *uuids;
};
typedef struct {
diff --git a/bluez-client.c b/bluez-client.c
index 334a2b6..d078d06 100644
--- a/bluez-client.c
+++ b/bluez-client.c
@@ -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));
+ }
}
}
diff --git a/bluez-client.h b/bluez-client.h
index 64ee9ad..17f82f0 100644
--- a/bluez-client.h
+++ b/bluez-client.h
@@ -39,7 +39,7 @@ struct bt_device {
gboolean avconnected;
gboolean legacypairing;
gint16 rssi;
- GVariant *uuids;
+ GList *uuids;
};
typedef struct {