summaryrefslogtreecommitdiffstats
path: root/binding
diff options
context:
space:
mode:
authorMatt Ranostay <matt.ranostay@konsulko.com>2019-01-02 15:20:20 -0800
committerMatt Ranostay <matt.ranostay@konsulko.com>2019-01-02 15:59:43 -0800
commit4030f19f4e3bea44f5df7cbbc0e526e719391bea (patch)
tree98e51136d5a03df45bc03b7318f5dd7835deed75 /binding
parent2b9c8dffa2cb6d4e9b273c897f9f45355bb8d516 (diff)
binding: bluetooth: add Transport parameter to discovery filter
Allow clients to select what Bluetooth transport they want a discovery scan to attempt to detect. This will improve scanning in for example when a client only wants to detect bredr or ble devices . Bug-AGL: SPEC-2094 Change-Id: I2a983f5243aefcb582a7476bbae34d6ba88c39a6 Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
Diffstat (limited to 'binding')
-rw-r--r--binding/bluetooth-api.c37
1 files changed, 25 insertions, 12 deletions
diff --git a/binding/bluetooth-api.c b/binding/bluetooth-api.c
index 8388695..3f66033 100644
--- a/binding/bluetooth-api.c
+++ b/binding/bluetooth-api.c
@@ -777,7 +777,7 @@ static void bluetooth_adapter(afb_req_t request)
struct bluetooth_state *ns = bluetooth_get_userdata(request);
GError *error = NULL;
const char *adapter = afb_req_value(request, "adapter");
- const char *scan, *discoverable, *powered, *filter;
+ const char *scan, *discoverable, *powered, *filter, *transport;
adapter = BLUEZ_ROOT_PATH(adapter ? adapter : ns->default_adapter);
@@ -837,28 +837,41 @@ static void bluetooth_adapter(afb_req_t request)
}
filter = afb_req_value(request, "filter");
- if (filter) {
- json_object *jobj = json_tokener_parse(filter);
+ transport = afb_req_value(request, "transport");
+
+ if (filter || transport) {
GVariantBuilder builder;
GVariant *flt, *reply;
- gchar **uuid = NULL;
- if (json_object_get_type(jobj) != json_type_array) {
- afb_req_fail_f(request, "failed", "invalid discovery filter");
- return;
+ g_variant_builder_init(&builder, G_VARIANT_TYPE("a{sv}"));
+
+ if (filter) {
+ json_object *jobj = json_tokener_parse(filter);
+ gchar **uuid = NULL;
+
+ if (json_object_get_type(jobj) != json_type_array) {
+ afb_req_fail_f(request, "failed", "invalid discovery filter");
+ return;
+ }
+
+ uuid = json_array_to_strv(jobj);
+ g_variant_builder_add(&builder, "{sv}", "UUIDs",
+ g_variant_new_strv((const gchar * const *) uuid, -1));
+
+ g_strfreev(uuid);
}
- g_variant_builder_init(&builder, G_VARIANT_TYPE("a{sv}"));
+ if (transport) {
+ g_variant_builder_add(&builder, "{sv}", "Transport",
+ g_variant_new_string(transport));
+
+ }
- uuid = json_array_to_strv(jobj);
- g_variant_builder_add(&builder, "{sv}", "UUIDs",
- g_variant_new_strv((const gchar * const *) uuid, -1));
flt = g_variant_builder_end(&builder);
reply = adapter_call(ns, adapter, "SetDiscoveryFilter",
g_variant_new("(@a{sv})", flt), &error);
- g_strfreev(uuid);
if (!reply) {
afb_req_fail_f(request, "failed",