summaryrefslogtreecommitdiffstats
path: root/plugins/lib/bluetooth
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/lib/bluetooth')
-rw-r--r--plugins/lib/bluetooth/hal-bt.c34
-rw-r--r--plugins/lib/bluetooth/hal-bt.h1
2 files changed, 17 insertions, 18 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)) ||
diff --git a/plugins/lib/bluetooth/hal-bt.h b/plugins/lib/bluetooth/hal-bt.h
index 120c166..f4e2a48 100644
--- a/plugins/lib/bluetooth/hal-bt.h
+++ b/plugins/lib/bluetooth/hal-bt.h
@@ -25,7 +25,6 @@
#define HAL_BT_PLUGIN_NAME "hal-bt"
#define BT_MANAGER_API "Bluetooth-Manager"
-#define BT_MANAGER_GET_ADAPTER_INFO "adapter_state"
#define BT_MANAGER_SUBSCRIBE_VERB "subscribe"
#define BT_MANAGER_GET_DEVICES_VERB "managed_objects"