← index #5307Issue #10755
Off-topic · high · value 1.180
QUERY · ISSUE

Pyboard-D BLE unsolicited disconnects on handle 65535

openby diginfoopened 2019-11-08updated 2019-11-11
port-stm32

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.

CANDIDATE · ISSUE

There is mistake in BLE simple central when disconnect is called

closedby cz8pruopened 2023-02-14updated 2023-02-15

There is code in git:
https://github.com/micropython/micropython/blob/41ed01f1394ea608bf9d055120d671e2765cd9b7/examples/bluetooth/ble_simple_central.py#L181-L185

I used that code and my device never disconnected, I found problem in "if" condition and change it to following code, which works for me:

def disconnect(self):
        if self._conn_handle is None:
            return
        self._ble.gap_disconnect(self._conn_handle)):
        self._reset()

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied