[Bluetooth][Pre-6.0] Fix BluetoothLEDevice::getServiceAllUuids()
[Bug] When some remote device advertises non-standard UUID, it was invalidly
translated to 16bit UUID. Which caused "NotFoundError: Service not found" error
in case of reading this service.
Inlcudes:
* fix for BluetoothLEDevice::getServiceAllUuids based on 6.0 implementation
* moving toLowerCase() from messaging to common module (needed for a fix)
[Verification]
Auto TCT 100% pass.
Tested in console:
Precondition:
Remote device need to have a GATT server advertising some non-standard UUID service, e.g.
"
12341234-1234-1234-1234-
123412341234". Below code should work if your remote device "MyDevice"
has proper service with a characteristic.
Last result will be something like "Value read from 1 characteristic -> 116,101,115,116"
var testDeviceName = "MyDevice";
var nonStandardUUID = "
12341234-1234-1234-1234-
123412341234";
var device;
function testBle(name) {
var adapter = tizen.bluetooth.getLEAdapter();
adapter.startScan(function (device_) {
device = device_;
//Item one occurs here:
if (device.name)
console.log("Found: " + JSON.stringify(device))
if (device.name === name) {
console.log("[Found device] address: " + JSON.stringify(device));
adapter.stopScan();
device.connect(function () {
console.log("[Connected]");
uuids = device.getServiceAllUuids();
console.log("all UUIDS\n" + JSON.stringify(uuids))
if (uuids.includes(nonStandardUUID)) {
console.log("Reading: " + nonStandardUUID);
var service = device.getService(nonStandardUUID);
if (service.characteristics.length > 0) {
for (j = 0; j < service.characteristics.length; ++j) {
var characteristic = service.characteristics[j];
characteristic.readValue(function (val) {
console.log("Value read from " + j + " characteristic -> " + val);
});
}
} else {
console.log("no characteristics found for service: " + uuid)
}
} else {
console.error("UUID " + nonStandardUUID + " not found ");
}
}, (e) => console.log(e));
}
}, (e) => console.log(e))
}
testBle(testDeviceName)
Change-Id: I38494b6b5037cf06ee7c4bc32d2f8f5e8e6ce97e