aioble server - what is the correct way to handle 'silent' disconnect? #13326
Replies: 2 comments 1 reply
-
@lievenleroy MicroPython listens for the host stack's "central disconnected" event, which happens regardless of how the host stack realises that it's disconnected (e.g. explicitly or because it's timed out etc). So I think what you're describing means that the host stack (NimBLE) thinks the connection is still active. I guess the first thing to confirm is that we are indeed not receiving a disconnect event from the host stack. If you're able to put a custom version of aioble's def _peripheral_irq(event, data):
...
elif event == _IRQ_CENTRAL_DISCONNECT:
print("disconnect", data) # Just add this line, keep everything else the same
... |
Beta Was this translation helpful? Give feedback.
-
Hello @jimmo . Thank you for the suggestion! Apologies for my slow reply. I ended up working around this with:
This is not ideal, but it does allow me to recover in the scenario I was running into with If I get time to test your suggestion, I will report back. Thanks again! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
In the aioble lib server examples, there is an expectation that a connected client will explicitly disconnect (so the server knows to advertise again). But that's not always the case, the client can crash or sleep. In that case, the server never starts advertising again and cannot be discovered again. (Short of resetting the device.)
I've tried watching for presence of a client using aioble.indicate() and a timeout for response. But restarting advertising based on that generates internal aioble errors. Is there a better way to do this? Thanks!
Beta Was this translation helpful? Give feedback.
All reactions