Pyboard-D BLE unsolicited disconnects on handle 65535
I have reported this on the forum, but think maybe it is a bug and so reporting it here.
I am getting 'unsolicited' disconnect interrupts with handle 65535, this will happen for sure if a device is connected and you do a soft reboot, it appears that during the restart the device is disconnected but as it does not have a valid handle for the new session, that it will trigger this event.
But I also get it intermittently without a restart, and immediately following this 65535 disconnect, the next connection will fail.
extmod/bluetooth: handling of disconnect in ble_simple_central.py example is misleading
The handling of the disconnect event in ble_simple_central.py is misleading. The condition if conn_handle == self._conn_handle:
(line 108) makes it look as if a different value for conn_handle would mean that there's nothing to do, but this is not the case. In particular, a disconnect can happen during the connection process, at least with nimble on the esp32, in which case self._conn_handle is still None and conn_handle != self._conn_handle but calling self._reset() is necessary.
https://github.com/micropython/micropython/blob/203e1d2a65273db3f6ff063ba1124a89c3482c0f/examples/bluetooth/ble_simple_central.py#L108