cordova-plugin-bluetoothle
cordova-plugin-bluetoothle copied to clipboard
Error on getUUID when get services is call in Windows
I used the function .services to get services on already paired device on Windows.
Error message: Exception is about to be caught by JavaScript library code at line 1010, column 3 in ms-appx://io.cordova.hellocordova/www/plugins/cordova-plugin-bluetoothle/src/windows/BluetoothLEPlugin.js 0x800a138f - JavaScript runtime error: Unable to get property '1' of undefined or null reference occurred
On: function getUUID(service) { var UuidRe = /([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/i; var serviceId = UuidRe.exec(service.uuid)[1]; <<<<<<<<<<<<<<<<<<<<<< var re = /0000([0-9a-f]{4})-0000-1000-8000-00805f9b34fb/; var shortUuidMatch = re.exec(serviceId); if (shortUuidMatch !== null) { serviceId = shortUuidMatch[1]; }
My function (same as describe in the github example):
function getDeviceServices(address) {
log("Getting device services...", "status");
var platform = window.cordova.platformId;
if (platform === "android") {
new Promise(function (resolve, reject) {
bluetoothle.discover(resolve, reject,
{ address: address });
}).then(discoverSuccess, handleError);
}
else if (platform === "windows") {
new Promise(function (resolve, reject) {
bluetoothle.services(resolve, reject,
{ address: address });
}).then(servicesSuccess, handleError);
}
else {
log("Unsupported platform: '" + window.cordova.platformId + "'", "error");
}
}
My bluetooth device has {e0cbf06c-cd8b-4647-bb8a-263b43f0f974} as a classguid. In services, I found this selector : System.Devices.InterfaceClassGuid:="{6E3BB679-4372-40C8-9EAA-4509DF260CD8}"
It is not the same.