diff options
-rw-r--r-- | README.md | 16 | ||||
-rw-r--r-- | binding/bluetooth-api.c | 23 |
2 files changed, 25 insertions, 14 deletions
@@ -209,7 +209,21 @@ Sample of adding new adapter event: } </pre> -Sample of adapter being remove: +Sample of adapter property changes: + +<pre> +{ + "adapter": "hci0", + "action": "changed", + "properties": { + "powered": false, + "discovering": false, + "discoverable": false + } +} +</pre> + +Sample of adapter being removed: <pre> { diff --git a/binding/bluetooth-api.c b/binding/bluetooth-api.c index f849301..8905c6a 100644 --- a/binding/bluetooth-api.c +++ b/binding/bluetooth-api.c @@ -417,7 +417,8 @@ static void bluez_devices_signal_callback( g_variant_get(parameters, "(&sa{sv}as)", &path, &array, &array1); - if (!g_strcmp0(path, BLUEZ_DEVICE_INTERFACE)) { + if (!g_strcmp0(path, BLUEZ_DEVICE_INTERFACE) || + !g_strcmp0(path, BLUEZ_ADAPTER_INTERFACE)) { int cnt = 0; jresp = json_object_new_object(); @@ -429,8 +430,15 @@ static void bluez_devices_signal_callback( jobj = json_object_new_object(); while (g_variant_iter_next(array, "{&sv}", &key, &var)) { - ret = device_property_dbus2json(jobj, + if (!g_strcmp0(path, BLUEZ_DEVICE_INTERFACE)) { + ret = device_property_dbus2json(jobj, key, var, &is_config, &error); + event = ns->device_changes_event; + } else { + ret = adapter_property_dbus2json(jobj, + key, var, &is_config, &error); + event = ns->adapter_changes_event; + } g_variant_unref(var); if (!ret) { AFB_DEBUG("%s property %s - %s", @@ -852,7 +860,6 @@ static void bluetooth_adapter(afb_req_t request) int ret = adapter_set_property(ns, adapter, FALSE, "Powered", json_object_new_boolean(str2boolean(powered)), &error); - json_object *jresp = NULL; if (!ret) { afb_req_fail_f(request, "failed", @@ -861,16 +868,6 @@ static void bluetooth_adapter(afb_req_t request) g_error_free(error); return; } - - jresp = json_object_new_object(); - - json_process_path(jresp, adapter); - json_object_object_add(jresp, "action", - json_object_new_string("changed")); - json_object_object_add(jresp, "powered", - json_object_new_boolean(str2boolean(powered))); - - afb_event_push(ns->device_changes_event, jresp); } filter = afb_req_value(request, "filter"); |