I'm trying to build a robust peripheral in a nano 33 BLE that can survive a loss of connectivity to the central, and can subsequently reconnect, in the style of many commercially available Bluetooth products. Using any of the Arduino example sketches - eg LED, I find that when the central is connected, and moves out of Bluetooth range of the peripheral, and then returns, it is not possible to reconnect. I have tried a number of different iOS central applications - either nRF Connect, LightBlue, or my own iOS app. All of these notify and drop the session and survive the session loss when they move too far away. They are ready to reconnect either immediately or when their scan finds the Arduino BLE advertising again. The nano 33 is neither accepting connections nor advertising again. The central will find it again after it is rebooted, but I would prefer a less drastic solution. Inside the peripheral code, I note that central.connected() remains TRUE after the loss of connection, so the program remains in its loop waiting for requests. I have done lots of google searches and find no guidelines or examples of how to code recovery from session loss using the ArduinoBLE library. I would have thought when the connection is lost, central.connected() would return FALSE or BLE.central() would be nil to indicate session loss. Neither of these occurs within many minutes after the session is lost. If central.connection() would return FALSE, then the sample program might just work as provided, or perhaps with the addition of a BLE.advertise() call after the session loss.
So is this a bug? Or am I supposed to detect the situation and call central.disconnect() or BLE.disconnect()? I have tried various combinations of such actions without success.
I even tried BLE.end(), but this causes a subsequent BLE.begin() to fail.
I am surprised that I could not find on the forum or elsewhere any discussion of recovering lost connections. Isn't that a pretty common requirement for Bluetooth sessions?
I'm using Arduino IDE 1.8.10; macOS 10.14.6; Arduino Nano 33 BLE; ArduinoBLE 1.1.1;
The code I'm using is the the LED example from the ArduinoBLE library.