Replies: 5 comments
-
@barart Please remove the bug tag amd move this to discussion board.
|
Beta Was this translation helpful? Give feedback.
-
@mutasimissa THanks, will check, i cant change the label (i dont have permission) |
Beta Was this translation helpful? Give feedback.
-
i would like to ask a enhancement on this, actually all the functions thow a error "Bluetooth LE not initialized." if it is not initialized, the isEnabled() suppose to return true or false if is enabled o not, but, if it is not initialized it dont return "false" it throws the error mentioned, so, all functions "knows" that ble is not initialized but as error; based on this, i think the isEnabled() function should returns false if BLE is not initialized instead throwing a error, maybe more complete, it could return true, false, notinitialized and this would be helpful to know if ble was initialized or not, atm my workaround was to create promise listener and check if it was true, if not then read the error message and compare the string "Bluetooth LE not initialized." with the error, at this point my app will now if its initialized or not, |
Beta Was this translation helpful? Give feedback.
-
Your app has to call let isInitialized = false;
try {
await BleClient.initialize();
isInitialized = true;
} catch (error) {
console.error(error);
} I don't think |
Beta Was this translation helpful? Give feedback.
-
Yes and no, in my case, the use of ble is optional (not mandatory), so, i dont want to ask/initialize it when the app launch, only when user wants to use the device, when user want to connect and/or scan device is when i want to initialize it, its in one component.. BUT my app has a 2nd component that check if th BLE is connected or not, if the user previously connected a device the other component start its process, but, if for some reason the ble device disconnects, the app closes or something, the other component tried to reconnect to it all the time, so, in resume, both components needs to know if its initialized or not but independent so they dont initialized it again, in my tests (and i dont know if it is the way that ble works or it was designed or not) ble disconnects after some hours and module needs to be initialized again, so my 2nd component check that, if i use a variable as you suggest, 2nd component will receive true when those hours passed, so using a variable is not a solution (at least for me) i need explicit to know if module was initialized or not so it can re-connect without user intervention.. Actually what i found in my tests on ios (android im working on it), the bledevice remains connected to the iosdevice forever (is what i want) but it stopped reading data after some hours and i need to re-launch the app (close completely and open it), im thinking that module restart and needs to be re-initialized or module unsubscribe to ble characteristic when in background after xx hours, idk im testing, but thats why i need to know if module was initialized or not, because i found that at some point it need to be re-initialized again, is strange, and yes i added the bluetooth-central tag |
Beta Was this translation helpful? Give feedback.
-
Is there a way to check if its already initialized? the isEnabled() is for check if bt is enabled on system, no if the component was already initialized, the initialize() function dont return anything to see if it was initialized or not
Beta Was this translation helpful? Give feedback.
All reactions