ArduinoBLE icon indicating copy to clipboard operation
ArduinoBLE copied to clipboard

Central "is still connected" after calling BLE.end() and BLE.begin()

Open mcxiv opened this issue 4 years ago • 1 comments

Hi,

I'm working with a MKR1010 and I realised something was wrong with the detection of a connected central.

In my code, I'm using ArduinoLowPower and ArduinoBLE library.

Let's say my smartphone is connected to my MKR1010.

After X seconds, I'm putting the duino in deepsleep where I shut down everything, including the BLE, with BLE.end(). The duino wakes up if a button (attach to pin 5) is pressed and I turn on everything back again.

And here comes the problem : In my loop() there is a condition if (central.connected()) which will be true even though nothing is connected. (Assuming BLE.end() disconnect everything.) The only solution I found is to use central.disconnect() before going into sleep mode.

It looks familiar with #33.

mcxiv avatar Mar 24 '21 09:03 mcxiv

Hi @MCXIV , this is related to https://github.com/arduino-libraries/ArduinoBLE/issues/127 An end function should be added to the ATT class, in order to clean up the library's state. However your workaround seems nice to me

polldo avatar May 24 '21 10:05 polldo