summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md10
-rw-r--r--binding/bluetooth-api.c37
2 files changed, 33 insertions, 14 deletions
diff --git a/README.md b/README.md
index 162e550..6cd4b50 100644
--- a/README.md
+++ b/README.md
@@ -129,7 +129,7 @@ This verb allows an client to get initial paired devices, and discovered unpaire
### adapter_state verb
-adapter_state verb allows setting and retrieving of requested adapter settings:
+#### adapter_state verb allows setting and retrieving of requested adapter settings
| Name | Description |
|-----------------|------------------------------------------------------------------------|
@@ -137,7 +137,13 @@ adapter_state verb allows setting and retrieving of requested adapter settings:
| discovery | Discover nearby broadcasting devices |
| discoverable | Allow other devices to detect this device |
| powered | Adapter power state (optional, rfkill should be disabled already) |
-| filter | Display devices only with respective UUIDS listed (write only setting) |
+
+#### adapter_state verb write-only parameters
+
+| Name | Description |
+|-----------------|--------------------------------------------------------------------------|
+| filter | Scan for devices only with respective UUIDS listed |
+| transport | Scan for devices with only defined transport type (e.g. auto, bredr, le) |
#### avrcp_controls verb
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",