diff options
author | Thierry Bultel <thierry.bultel@iot.bzh> | 2018-09-12 16:55:55 +0200 |
---|---|---|
committer | Jonathan Aillet <jonathan.aillet@iot.bzh> | 2018-10-08 15:57:27 +0200 |
commit | 9f88b345bb8e4ccab4f2ab9a20c79802e9f9485e (patch) | |
tree | 429fa482dda6489a0f829163bcad2accaf6e76b4 | |
parent | 43129f229bc970209695c9438bc70377ed085f1b (diff) |
hal-bt-data: ignore devices with no UUIDs
just ignore devices that do not have any UUIDs
Change-Id: Ic3cb25d8f8521e8f6c73afa173745a26e9c873ce
Signed-off-by: Thierry Bultel <thierry.bultel@iot.bzh>
-rw-r--r-- | plugins/lib/bluetooth/hal-bt-data.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/plugins/lib/bluetooth/hal-bt-data.c b/plugins/lib/bluetooth/hal-bt-data.c index eefd9f1..61d774b 100644 --- a/plugins/lib/bluetooth/hal-bt-data.c +++ b/plugins/lib/bluetooth/hal-bt-data.c @@ -173,14 +173,14 @@ int HalBtDataHandleReceivedSingleBtDeviceData(struct HalBtPluginData *halBtPlugi char *currentBtDeviceAddress, *currentBtDeviceIsConnectedString, *currentBtDeviceIsAVPConnectedString; - json_object *currentBtAllProfilesJ, *currentBtCurrentProfileJ; + json_object *currentBtAllProfilesJ = NULL, *currentBtCurrentProfileJ; struct HalBtDeviceData *currentBtDevice; if(! halBtPluginData || ! currentSingleBtDeviceDataJ) return -1; if(wrap_json_unpack(currentSingleBtDeviceDataJ, - "{s:s s:s s:s s:o}", + "{s:s s:s s:s s?:o}", "Address", ¤tBtDeviceAddress, "Connected", ¤tBtDeviceIsConnectedString, "AVPConnected", ¤tBtDeviceIsAVPConnectedString, @@ -188,6 +188,11 @@ int HalBtDataHandleReceivedSingleBtDeviceData(struct HalBtPluginData *halBtPlugi return -2; } + if(! currentBtAllProfilesJ) { + AFB_ApiInfo(halBtPluginData->currentHalApiHandle, "Bluetooth device (address = %s) has no specified profiles, ignore it", currentBtDeviceAddress); + return 0; + } + if(json_object_is_type(currentBtAllProfilesJ, json_type_array)) { btProfilesCount = json_object_array_length(currentBtAllProfilesJ); @@ -260,9 +265,10 @@ int HalBtDataHandleReceivedMutlipleBtDeviceData(struct HalBtPluginData *halBtPlu btDeviceNumber = json_object_array_length(currentMultipleBtDeviceDataJ); for(idx = 0; idx < btDeviceNumber; idx++) { - if((err = HalBtDataHandleReceivedSingleBtDeviceData(halBtPluginData, json_object_array_get_idx(currentMultipleBtDeviceDataJ, (unsigned int) idx)))) + if((err = HalBtDataHandleReceivedSingleBtDeviceData(halBtPluginData, json_object_array_get_idx(currentMultipleBtDeviceDataJ, (unsigned int) idx)))) { return ((int) idx * err * 10); + } } return 0; -}
\ No newline at end of file +} |