nkolban / esp32-snippets

Sample ESP32 snippets and code fragments
https://leanpub.com/kolban-ESP32
Apache License 2.0
2.37k stars 710 forks source link

Checking BLE initialization #845

Open msmigielski opened 5 years ago

msmigielski commented 5 years ago

In my program I would like to handle cases such as incorrect BLE initialization to prevent total crash on my esp32 device. In the function BLEDevice::init(std::string deviceName) there are many assertions checking the correct execution of this function and return from it if fail occurs. However, the initialised flag is set at the very beginning of this function and even if the error occurs, initialized flag is set to true. In my opinion the flag should be set at the very end of the function so it can be checked if the initialization was successful.

I mean then we could write for example: BLEDevice::init("myDevice"); if (~BLEDevice::getInitialized()) throw exception; // or reset device

Is there any other possibility to check if BLEDevice was initialized correctly?

Sladerix commented 2 years ago

Hi, did you solve?