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.c44
1 files changed, 17 insertions, 27 deletions
diff --git a/plugins/lib/bluetooth/hal-bt.c b/plugins/lib/bluetooth/hal-bt.c
index a4791e1..1a53c0d 100644
--- a/plugins/lib/bluetooth/hal-bt.c
+++ b/plugins/lib/bluetooth/hal-bt.c
@@ -49,7 +49,8 @@ CTLP_INIT(plugin, callbacks)
unsigned int idx;
- char *btStreamZone, *returnedInfo;
+ char *btStreamZone;
+ struct json_object *returnedState;
CtlConfigT *ctrlConfig;
@@ -80,19 +81,18 @@ CTLP_INIT(plugin, callbacks)
return -3;
}
- if(AFB_ServiceSync(plugin->api, BT_MANAGER_API, BT_MANAGER_GET_POWER_INFO, NULL, &returnedJ)) {
- if((! wrap_json_unpack(returnedJ, "{s:{s:s}}", "request", "info", &returnedInfo)) &&
- (! strncmp(returnedInfo, "Unable to get power status", strlen(returnedInfo)))) {
+ 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 disable because not reachable",
- BT_MANAGER_GET_POWER_INFO,
+ "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_POWER_INFO,
+ BT_MANAGER_GET_ADAPTER_INFO,
BT_MANAGER_API,
json_object_get_string(returnedJ));
return -4;
@@ -106,7 +106,7 @@ CTLP_INIT(plugin, callbacks)
}
wrap_json_pack(&actionsToAdd, "{s:s s:s}",
- "uid", "Bluetooth-Manager/device_updated",
+ "uid", "Bluetooth-Manager/media",
"action", "plugin://hal-bt#events");
if(currentHalData->status != HAL_STATUS_AVAILABLE) {
@@ -298,7 +298,7 @@ CTLP_CAPI(init, source, argsJ, queryJ)
return -6;
}
- else if(! wrap_json_unpack(returnedJ, "{s:{s:s}}", "request", "info", &returnedInfo)) {
+ else if(wrap_json_unpack(returnedJ, "{s:{s:s}}", "request", "info", &returnedInfo)) {
AFB_ApiError(source->api,
"Couldn't subscribe to event '%s' during call to verb '%s' of api '%s' (error '%s')",
BT_MANAGER_DEVICE_UPDATE_EVENT,
@@ -311,24 +311,14 @@ CTLP_CAPI(init, source, argsJ, queryJ)
json_object_put(returnedJ);
if(AFB_ServiceSync(source->api, BT_MANAGER_API, BT_MANAGER_GET_DEVICES_VERB, NULL, &returnedJ)) {
- if((! wrap_json_unpack(returnedJ, "{s:{s:s}}", "request", "info", &returnedInfo)) &&
- (! strncmp(returnedInfo, "No find devices", strlen(returnedInfo)))) {
- AFB_ApiInfo(source->api,
- "No bluetooth devices returned by call to verb '%s' of '%s' api",
- BT_MANAGER_GET_DEVICES_VERB,
- BT_MANAGER_API);
- }
- else {
- AFB_ApiError(source->api,
- "Error during call to verb '%s' of '%s' api (%s)",
- BT_MANAGER_GET_DEVICES_VERB,
- BT_MANAGER_API,
- json_object_get_string(returnedJ));
-
+ AFB_ApiError(source->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 -7;
- }
}
- else if(wrap_json_unpack(returnedJ, "{s:{s:o}}", "response", "list", &returnedBtList)) {
+ else if(wrap_json_unpack(returnedJ, "{s:{s:o}}", "response", "devices", &returnedBtList)) {
AFB_ApiError(source->api,
"Couldn't get bluetooth device list during call to verb '%s' of api '%s'",
BT_MANAGER_GET_DEVICES_VERB,
@@ -375,7 +365,7 @@ CTLP_CAPI(events, source, argsJ, queryJ)
return 0;
}
- if(HalBtDataHandleReceivedSingleBtDeviceData(&localHalBtPluginData, queryJ)) {
+ if(HalBtDataHandleReceivedMediaBtDeviceData(&localHalBtPluginData, queryJ)) {
AFB_ApiError(source->api, "Error while decoding bluetooth event received json (%s)", json_object_get_string(queryJ));
return -1;
}
@@ -403,4 +393,4 @@ CTLP_CAPI(events, source, argsJ, queryJ)
}
return 0;
-} \ No newline at end of file
+}