summaryrefslogtreecommitdiffstats
path: root/binding/bluetooth-api.c
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 16:00:38 -0800
commit64ef3e7466081153a687f66b28fc0c252b1d6940 (patch)
treefcd977f5b16ac3282fe897ffcbc444c7d8cfabaf /binding/bluetooth-api.c
parenta7b32137538def69922d178d7091046a361a6063 (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/bluetooth-api.c')
-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",