summaryrefslogtreecommitdiffstats
path: root/plugins/lib/bluetooth/hal-bt.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/lib/bluetooth/hal-bt.c')
-rw-r--r--plugins/lib/bluetooth/hal-bt.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/plugins/lib/bluetooth/hal-bt.c b/plugins/lib/bluetooth/hal-bt.c
index 1a53c0d..96ca080 100644
--- a/plugins/lib/bluetooth/hal-bt.c
+++ b/plugins/lib/bluetooth/hal-bt.c
@@ -50,7 +50,7 @@ CTLP_INIT(plugin, callbacks)
unsigned int idx;
char *btStreamZone;
- struct json_object *returnedState;
+ struct json_object *returnedAdapters;
CtlConfigT *ctrlConfig;
@@ -81,22 +81,22 @@ CTLP_INIT(plugin, callbacks)
return -3;
}
- if(AFB_ServiceSync(plugin->api, BT_MANAGER_API, BT_MANAGER_GET_ADAPTER_INFO, NULL, &returnedJ)) {
- if(wrap_json_unpack(returnedJ, "{s:{s:b}}", "response", "powered", &returnedState)) {
- AFB_ApiWarning(plugin->api,
- "No bluetooth receiver detected when calling verb '%s' of '%s' api, bluetooth is disabled because not reachable",
- BT_MANAGER_GET_ADAPTER_INFO,
- BT_MANAGER_API);
- return 0;
- }
- else {
- AFB_ApiError(plugin->api,
- "Error during call to verb '%s' of '%s' api (%s)",
- BT_MANAGER_GET_ADAPTER_INFO,
- BT_MANAGER_API,
- json_object_get_string(returnedJ));
- return -4;
- }
+ if(AFB_ServiceSync(plugin->api, BT_MANAGER_API, BT_MANAGER_GET_DEVICES_VERB, NULL, &returnedJ) ||
+ wrap_json_unpack(returnedJ, "{s:{s:o}}", "response", "adapters", &returnedAdapters) ||
+ (! json_object_is_type(returnedAdapters, json_type_array))) {
+ AFB_ApiError(plugin->api,
+ "Error during call to verb '%s' of '%s' api (%s)",
+ BT_MANAGER_GET_DEVICES_VERB,
+ BT_MANAGER_API,
+ json_object_get_string(returnedJ));
+ return -4;
+ }
+ else if(! json_object_array_length(returnedAdapters)) {
+ AFB_ApiWarning(plugin->api,
+ "No bluetooth receiver detected when calling verb '%s' of '%s' api, bluetooth is disabled because not reachable",
+ BT_MANAGER_GET_DEVICES_VERB,
+ BT_MANAGER_API);
+ return 0;
}
if((! json_object_is_type(plugin->paramsJ, json_type_object)) ||