summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Ranostay <matt.ranostay@konsulko.com>2017-08-22 14:35:06 -0700
committerMatt Ranostay <matt.ranostay@konsulko.com>2017-08-22 15:29:22 -0700
commitee0b6c81188c1b3a10b877e6244c186e65d9b8a1 (patch)
tree88e1b698d36ccc3e30c922c2bb29964b35c3ab18
parent2260e85751467db9c361346e5bea5bd6b41b1718 (diff)
binding: bluetooth: add verb to export paired device priorities
Add device_priorities verb to export paired device priorities in an array. Bug-AGL: SPEC-839 Change-Id: I83dc17a2a8f755235b0b35a12d2cae8388b69c85 Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
-rw-r--r--binding-bluetooth/bluetooth-api.c14
-rw-r--r--binding-bluetooth/bluetooth-manager.c19
-rw-r--r--binding-bluetooth/bluetooth-manager.h1
3 files changed, 34 insertions, 0 deletions
diff --git a/binding-bluetooth/bluetooth-api.c b/binding-bluetooth/bluetooth-api.c
index ed5fef8..3da59d9 100644
--- a/binding-bluetooth/bluetooth-api.c
+++ b/binding-bluetooth/bluetooth-api.c
@@ -567,6 +567,19 @@ static void bt_remove_device (struct afb_req request)
}
+static void bt_device_priorities_cb (json_object *array, gchar *str)
+{
+ json_object_array_add(array, json_object_new_string(str));
+}
+
+static void bt_device_priorities (struct afb_req request)
+{
+ json_object *jarray = json_object_new_array();
+
+ device_priority_list(&bt_device_priorities_cb, jarray);
+
+ afb_req_success(request, jarray, "Display paired device priority");
+}
/**/
static void bt_set_device_property (struct afb_req request)
@@ -836,6 +849,7 @@ static const struct afb_verb_v2 binding_verbs[]= {
{ .verb = "cancel_pair", .session = AFB_SESSION_NONE, .callback = bt_cancel_pairing, .info = "Cancel the pairing process" },
{ .verb = "connect", .session = AFB_SESSION_NONE, .callback = bt_connect, .info = "Connect to special device" },
{ .verb = "disconnect", .session = AFB_SESSION_NONE, .callback = bt_disconnect, .info = "Disconnect special device" },
+{ .verb = "device_priorities", .session = AFB_SESSION_NONE, .callback = bt_device_priorities, .info = "Get BT paired device priorites" },
{ .verb = "set_device_property", .session = AFB_SESSION_NONE, .callback = bt_set_device_property, .info = "Set special device property" },
{ .verb = "set_property", .session = AFB_SESSION_NONE, .callback = bt_set_property, .info = "Set Bluetooth property" },
{ .verb = "set_avrcp_controls", .session = AFB_SESSION_NONE, .callback = bt_set_avrcp_controls, .info = "Set Bluetooth AVRCP controls" },
diff --git a/binding-bluetooth/bluetooth-manager.c b/binding-bluetooth/bluetooth-manager.c
index 2ff8925..f1d7895 100644
--- a/binding-bluetooth/bluetooth-manager.c
+++ b/binding-bluetooth/bluetooth-manager.c
@@ -190,6 +190,25 @@ GSList *bt_priority_list()
return list;
}
+int device_priority_list(void *(object_cb)(void *, gchar *), void *ptr)
+{
+ GSList *tmp;
+
+ devices_list_lock();
+
+ tmp = BluetoothManage.priorities;
+
+ while (tmp)
+ {
+ object_cb(ptr, tmp->data);
+ tmp = tmp->next;
+ }
+
+ devices_list_unlock();
+
+ return 0;
+}
+
static int device_path_cmp(struct btd_device * device, const gchar* pPath )
{
return !g_str_has_prefix (pPath, device->path);
diff --git a/binding-bluetooth/bluetooth-manager.h b/binding-bluetooth/bluetooth-manager.h
index 36222df..b469f0b 100644
--- a/binding-bluetooth/bluetooth-manager.h
+++ b/binding-bluetooth/bluetooth-manager.h
@@ -198,6 +198,7 @@ int device_connect(const gchar *addr, const gchar *uuid);
int device_disconnect(const gchar *addr, const gchar *uuid);
int device_set_property(const gchar * bdaddr, const gchar *property, const gchar *value);
int device_call_avrcp_method(const gchar* device, const gchar* method);
+int device_priority_list(void *(object_cb)(void *, gchar *), void *ptr);
int adapter_set_property(const gchar* property, gboolean value) ;