jonas-schievink / rubble

(going to be a) BLE stack for embedded Rust
BSD Zero Clause License
398 stars 55 forks source link

Support for closing connections #147

Open daboross opened 3 years ago

daboross commented 3 years ago

Right now, there isn't any way to properly close a connection, flush the associated queues, and turn off the radio.

Supporting this isn't necessarily trivial, however. Quoting from @jonas-schievink from https://github.com/jonas-schievink/rubble/pull/140#issuecomment-669101680 (on a simple-and-incorrect radio shutdown PR):

Hmm, yeah, we want something like this eventually, but getting it correct is a bit more involved. For example, the low-priority part of the stack needs to know that the connection is being teared down to drain the packet queue before the operation can complete (otherwise establishing a new connection will start processing and transmitting packets from the old connection, which is pretty bad).

Fixing this would mean adding the ability to properly close a connection from the device, and fixing "start_advertising" so that it uses this method to close any active connections before advertising.

See also #70.