diff options
author | Jonathan Aillet <jonathan.aillet@iot.bzh> | 2018-09-12 17:54:04 +0200 |
---|---|---|
committer | Jonathan Aillet <jonathan.aillet@iot.bzh> | 2018-10-08 15:57:27 +0200 |
commit | c5d3dee7873e53c907efdcc232770568d3c635dc (patch) | |
tree | be2bcdf2b80ec57a0245244a5f3eb54dbc4a3d80 /plugins/lib | |
parent | 38744722cb6dd9cc655fd8585d6bcc6c855830e5 (diff) |
Get bluetooth device interface from path in HalBt
In Hal-Bt plugin, get bluetooth device 'hci' interface
from 'Path' key send by 'Bluetooth-Manager'.
As, the 'Path' key contains the whole path of the device, some string
manipulations are necessary ...
Change-Id: I320a41fb1589214b0ae6999e1c8b793c7cdd41a7
Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
Diffstat (limited to 'plugins/lib')
-rw-r--r-- | plugins/lib/bluetooth/hal-bt-data.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/plugins/lib/bluetooth/hal-bt-data.c b/plugins/lib/bluetooth/hal-bt-data.c index 2723d1d..f3cb0e4 100644 --- a/plugins/lib/bluetooth/hal-bt-data.c +++ b/plugins/lib/bluetooth/hal-bt-data.c @@ -67,7 +67,7 @@ int HalBtDataRemoveSelectedBtDeviceFromList(struct HalBtDeviceData **firstBtDevi struct HalBtDeviceData *HalBtDataAddBtDeviceToBtDeviceList(struct HalBtDeviceData **firstBtDeviceData, json_object *currentSingleBtDeviceDataJ) { - char *currentBtDeviceName, *currentBtDeviceAddress; + char *currentBtDeviceName, *currentBtDeviceAddress, *currentBtDevicePath, *currentBtDeviceHci; struct HalBtDeviceData *currentBtDeviceData; @@ -94,11 +94,11 @@ struct HalBtDeviceData *HalBtDataAddBtDeviceToBtDeviceList(struct HalBtDeviceDat currentBtDeviceData = currentBtDeviceData->next; } - // TODO JAI : get hci device of bt device here if(wrap_json_unpack(currentSingleBtDeviceDataJ, - "{s:s s:s}", + "{s:s s:s s:s}", "Name", ¤tBtDeviceName, - "Address", ¤tBtDeviceAddress)) { + "Address", ¤tBtDeviceAddress, + "Path", ¤tBtDevicePath)) { HalBtDataRemoveSelectedBtDeviceFromList(firstBtDeviceData, currentBtDeviceData); return NULL; } @@ -108,8 +108,11 @@ struct HalBtDeviceData *HalBtDataAddBtDeviceToBtDeviceList(struct HalBtDeviceDat return NULL; } - // JAI : WARNING : hci bt device is currently harcoded - if(! (currentBtDeviceData->hci = strdup("hci0"))) { + currentBtDeviceHci = strtok(currentBtDevicePath, "/"); + while(currentBtDeviceHci && strncmp(currentBtDeviceHci, "hci", 3)) + currentBtDeviceHci = strtok(NULL, "/"); + + if((! currentBtDeviceHci) || (! (currentBtDeviceData->hci = strdup(currentBtDeviceHci)))) { HalBtDataRemoveSelectedBtDeviceFromList(firstBtDeviceData, currentBtDeviceData); return NULL; } |