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-cb.c4
-rw-r--r--plugins/lib/bluetooth/hal-bt-data.c16
-rw-r--r--plugins/lib/bluetooth/hal-bt-data.h2
-rw-r--r--plugins/lib/bluetooth/hal-bt-mixer-link.c18
-rw-r--r--plugins/lib/bluetooth/hal-bt.c25
5 files changed, 50 insertions, 15 deletions
diff --git a/plugins/lib/bluetooth/hal-bt-cb.c b/plugins/lib/bluetooth/hal-bt-cb.c
index c75830d..82fc2ba 100644
--- a/plugins/lib/bluetooth/hal-bt-cb.c
+++ b/plugins/lib/bluetooth/hal-bt-cb.c
@@ -118,7 +118,7 @@ void HalBtGetA2DPBluetoothDevices(AFB_ReqT request)
while(currentBtDeviceData) {
wrap_json_pack(&currentBtDeviceObjectJ,
"{s:s s:s s:s s:b}",
- "Hci", currentBtDeviceData->hci,
+ "Interface", currentBtDeviceData->hci,
"Name", currentBtDeviceData->name,
"Address", currentBtDeviceData->address);
json_object_array_add(requestAnswer, currentBtDeviceObjectJ);
@@ -147,7 +147,7 @@ void HalBtGetSelectedA2DPBluetoothDevice(AFB_ReqT request)
wrap_json_pack(&selectedBtDeviceObject,
"{s:s s:s s:s s:b}",
- "Hci", localHalBtPluginData->selectedBtDevice->hci,
+ "Interface", localHalBtPluginData->selectedBtDevice->hci,
"Name", localHalBtPluginData->selectedBtDevice->name,
"Address", localHalBtPluginData->selectedBtDevice->address);
diff --git a/plugins/lib/bluetooth/hal-bt-data.c b/plugins/lib/bluetooth/hal-bt-data.c
index cfcb57d..eefd9f1 100644
--- a/plugins/lib/bluetooth/hal-bt-data.c
+++ b/plugins/lib/bluetooth/hal-bt-data.c
@@ -220,15 +220,27 @@ int HalBtDataHandleReceivedSingleBtDeviceData(struct HalBtPluginData *halBtPlugi
if(HalBtDataRemoveSelectedBtDeviceFromList(&halBtPluginData->first, currentBtDevice))
return -3;
- if(halBtPluginData->selectedBtDevice == currentBtDevice)
+ AFB_ApiInfo(halBtPluginData->currentHalApiHandle, "Bluetooth device (address = %s) successfully removed from list", currentBtDeviceAddress);
+
+ if(halBtPluginData->selectedBtDevice == currentBtDevice) {
halBtPluginData->selectedBtDevice = halBtPluginData->first;
+ AFB_ApiDebug(halBtPluginData->currentHalApiHandle,
+ "Bluetooth selected device changed to '%s'",
+ halBtPluginData->selectedBtDevice ? halBtPluginData->selectedBtDevice->address : "none");
+ }
}
else if(! currentBtDevice && currentBtDeviceIsConnected) {
if(! HalBtDataAddBtDeviceToBtDeviceList(&halBtPluginData->first, currentSingleBtDeviceDataJ))
return -4;
- if(! halBtPluginData->selectedBtDevice)
+ AFB_ApiInfo(halBtPluginData->currentHalApiHandle, "Bluetooth device (address = %s) successfully added from list", currentBtDeviceAddress);
+
+ if(! halBtPluginData->selectedBtDevice) {
halBtPluginData->selectedBtDevice = halBtPluginData->first;
+ AFB_ApiDebug(halBtPluginData->currentHalApiHandle,
+ "Bluetooth selected device changed to '%s'",
+ halBtPluginData->selectedBtDevice ? halBtPluginData->selectedBtDevice->address : "none");
+ }
}
return 0;
diff --git a/plugins/lib/bluetooth/hal-bt-data.h b/plugins/lib/bluetooth/hal-bt-data.h
index e57f02f..36e0430 100644
--- a/plugins/lib/bluetooth/hal-bt-data.h
+++ b/plugins/lib/bluetooth/hal-bt-data.h
@@ -45,6 +45,8 @@ struct HalBtDeviceData {
struct HalBtPluginData {
unsigned int halBtPluginEnabled;
+ AFB_ApiT currentHalApiHandle;
+
struct SpecificHalData *currentHalData;
unsigned int btStreamEnabled;
diff --git a/plugins/lib/bluetooth/hal-bt-mixer-link.c b/plugins/lib/bluetooth/hal-bt-mixer-link.c
index 865d63d..714c4e8 100644
--- a/plugins/lib/bluetooth/hal-bt-mixer-link.c
+++ b/plugins/lib/bluetooth/hal-bt-mixer-link.c
@@ -40,12 +40,17 @@ int HalBtMixerLinkSetBtStreamingSettings(AFB_ApiT apiHandle, char *mixerApiName,
if(! apiHandle || ! mixerApiName)
return -1;
- if(! btStreamStatus)
+ if(! btStreamStatus) {
+ AFB_ApiDebug(apiHandle, "Will try to disable bluetooth streamed device");
toSendJ = NULL;
- else if(btStreamStatus == 1 && hci && btAddress)
+ }
+ else if(btStreamStatus == 1 && hci && btAddress) {
+ AFB_ApiDebug(apiHandle, "Will try to change bluetooth streamed device to hci='%s' address='%s'", hci, btAddress);
wrap_json_pack(&toSendJ, "{s:s s:s s:s}", "interface", hci, "device", btAddress, "profile", "a2dp");
- else
- return -3;
+ }
+ else {
+ return -2;
+ }
if(AFB_ServiceSync(apiHandle, mixerApiName, MIXER_SET_STREAMED_BT_DEVICE_VERB, toSendJ, &returnedJ)) {
AFB_ApiError(apiHandle,
@@ -63,5 +68,10 @@ int HalBtMixerLinkSetBtStreamingSettings(AFB_ApiT apiHandle, char *mixerApiName,
return -4;
}
+ if(btStreamStatus)
+ AFB_ApiInfo(apiHandle, "Bluetooth streamed device changed to hci='%s' address='%s'", hci, btAddress);
+ else
+ AFB_ApiInfo(apiHandle, "Bluetooth streamed device disbaled");
+
return 0;
} \ No newline at end of file
diff --git a/plugins/lib/bluetooth/hal-bt.c b/plugins/lib/bluetooth/hal-bt.c
index 408b232..113c411 100644
--- a/plugins/lib/bluetooth/hal-bt.c
+++ b/plugins/lib/bluetooth/hal-bt.c
@@ -40,10 +40,12 @@ CTLP_ONLOAD(plugin, callbacks)
{
CtlConfigT *ctrlConfig;
- AFB_ApiNotice(plugin->api, "Hal-Bt Plugin Registered: uid='%s' 'info='%s'", plugin->uid, plugin->info);
+ AFB_ApiInfo(plugin->api, "Hal-Bt Plugin Registering: uid='%s' 'info='%s'", plugin->uid, plugin->info);
memset(&localHalBtPluginData, '\0', sizeof(localHalBtPluginData));
+ localHalBtPluginData.currentHalApiHandle = plugin->api;
+
if(AFB_RequireApi(plugin->api, BT_MANAGER_API, 1)) {
AFB_ApiWarning(plugin->api, "Didn't succeed to require %s api, bluetooth is disable because not reachable", BT_MANAGER_API);
return 0;
@@ -61,6 +63,8 @@ CTLP_ONLOAD(plugin, callbacks)
localHalBtPluginData.halBtPluginEnabled = 1;
+ AFB_ApiNotice(plugin->api, "Hal-Bt Plugin Registered correctly: uid='%s' 'info='%s'", plugin->uid, plugin->info);
+
/* TDB JAI :
- Register 'init' plugin function (HAL_BT_PLUGIN_NAME#init) as onload action here (to avoid adding it in json)
- Register 'event' plugin function (HAL_BT_PLUGIN_NAME#event) as action for BT_MANAGER_API#BT_MANAGER_DEVICE_UPDATE_EVENT event here (to avoid adding it in json)
@@ -74,6 +78,8 @@ CTLP_CAPI(init, source, argsJ, queryJ)
{
unsigned int err;
+ char *returnedInfo;
+
struct json_object *toSendJ, *returnedJ, *returnedBtList = NULL;
if(! localHalBtPluginData.halBtPluginEnabled) {
@@ -81,7 +87,7 @@ CTLP_CAPI(init, source, argsJ, queryJ)
return 0;
}
- AFB_ApiNotice(source->api, "Initializing HAL-BT plugin");
+ AFB_ApiInfo(source->api, "Controller onload initialization of HAL-BT plugin");
// Loading hal BT plugin specific verbs
if(afb_dynapi_add_verb(source->api,
@@ -146,16 +152,17 @@ CTLP_CAPI(init, source, argsJ, queryJ)
"Error during call to verb '%s' of '%s' api (%s)",
BT_MANAGER_SUBSCRIBE_VERB,
BT_MANAGER_API,
- json_object_get_string(returnedJ));
+ json_object_get_string(returnedJ));
return -6;
}
- else if(! wrap_json_unpack(returnedJ, "{s:{s:s}}", "request", "info", NULL)) {
+ 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'",
+ "Couldn't subscribe to event '%s' during call to verb '%s' of api '%s' (error '%s')",
BT_MANAGER_DEVICE_UPDATE_EVENT,
BT_MANAGER_SUBSCRIBE_VERB,
- BT_MANAGER_API);
+ BT_MANAGER_API,
+ returnedInfo);
return -6;
}
@@ -164,7 +171,7 @@ CTLP_CAPI(init, source, argsJ, queryJ)
"Error during call to verb '%s' of '%s' api (%s)",
BT_MANAGER_GET_DEVICES_VERB,
BT_MANAGER_API,
- json_object_get_string(returnedJ));
+ json_object_get_string(returnedJ));
return -7;
}
@@ -182,6 +189,8 @@ CTLP_CAPI(init, source, argsJ, queryJ)
if(localHalBtPluginData.selectedBtDevice) {
localHalBtPluginData.btStreamEnabled = 1;
+ AFB_ApiInfo(source->api, "Useable bluetooth device detected at initialization, will try to use it");
+
if(HalBtMixerLinkSetBtStreamingSettings(source->api,
localHalBtPluginData.currentHalData->ctlHalSpecificData->mixerApiName,
localHalBtPluginData.btStreamEnabled,
@@ -195,6 +204,8 @@ CTLP_CAPI(init, source, argsJ, queryJ)
}
}
+ AFB_ApiNotice(source->api, "Controller onload initialization of HAL-BT plugin correctly done");
+
return 0;
}