diff options
author | Matt Ranostay <matt.ranostay@konsulko.com> | 2018-10-29 17:44:38 -0700 |
---|---|---|
committer | Matt Ranostay <matt.ranostay@konsulko.com> | 2018-11-12 03:58:47 -0800 |
commit | f05fd30507b218bd06d6ecdb5ddcd07de3927f82 (patch) | |
tree | 76b203898675f8c2388be22d3eca0af9bcd8b690 /binding/bluetooth-api.c | |
parent | 3d2a18623f663ddf201f60ef93405b2f03b5f979 (diff) |
binding: bluetooth: add BLUEZ_DEFAULT_ADAPTER
Bug-AGL: SPEC-1630
Change-Id: I8e55d273ab58992e6f6327523853c6d330505278
Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
Diffstat (limited to 'binding/bluetooth-api.c')
-rw-r--r-- | binding/bluetooth-api.c | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/binding/bluetooth-api.c b/binding/bluetooth-api.c index e9c339f..58c326c 100644 --- a/binding/bluetooth-api.c +++ b/binding/bluetooth-api.c @@ -599,14 +599,9 @@ static void bluetooth_state(afb_req_t request) struct bluetooth_state *ns = bluetooth_get_userdata(request); GError *error = NULL; json_object *jresp; - const char *adapter; + const char *adapter = afb_req_value(request, "adapter"); - adapter = afb_req_value(request, "adapter"); - if (!adapter) { - afb_req_fail(request, "failed", "No adapter give to return state"); - return; - } - adapter = BLUEZ_ROOT_PATH(adapter); + adapter = BLUEZ_ROOT_PATH(adapter ? adapter : BLUEZ_DEFAULT_ADAPTER); jresp = adapter_properties(ns, &error, adapter); if (!jresp) { @@ -622,14 +617,10 @@ static void bluetooth_adapter(afb_req_t request) { struct bluetooth_state *ns = bluetooth_get_userdata(request); GError *error = NULL; - const char *adapter, *scan, *discoverable, *powered; + const char *adapter = afb_req_value(request, "adapter"); + const char *scan, *discoverable, *powered; - adapter = afb_req_value(request, "adapter"); - if (!adapter) { - afb_req_fail(request, "failed", "No adapter given to configure"); - return; - } - adapter = BLUEZ_ROOT_PATH(adapter); + adapter = BLUEZ_ROOT_PATH(adapter ? adapter : BLUEZ_DEFAULT_ADAPTER); scan = afb_req_value(request, "discovery"); if (scan) { |