jonas-schievink / rubble

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

Wait for ongoing transmissions before changing DMA state #104

Closed thalesfragoso closed 4 years ago

thalesfragoso commented 4 years ago

Since configure_receiver stops the DMA and we call it just after processing a data packet, we need to wait for ongoing transmissions to finish before continuing.

In case of a lost connection event we don't need to check for it, in this case I was expecting the radio to be in the RX mode, but I found out through testing that this isn't a reliable behavior, so I added a flag to skip waiting in case of a timeout, in this case there isn't a problem in direct disabling the DMA since we shouldn't be transmitting anything in the first place.

I also added a check in the tx_payload_buf method and changed timer.now() for rx_end in process_data_packet because I believe it will give us a better anchor point. I disabled the end_disable shortcut in transmit_data because my understanding is that we should only hit the disabled interrupt after receiving a packet, this wasn't a problem in the demo because we only call that from inside the interrupt, feel free to correct me if I'm wrong.

Tested both in debug and release with a nRF52832.

Closes https://github.com/jonas-schievink/rubble/issues/94 and closes https://github.com/jonas-schievink/rubble/issues/67.

thalesfragoso commented 4 years ago

What happened to CI ?

jonas-schievink commented 4 years ago

Travis has passed: https://travis-ci.org/github/jonas-schievink/rubble/builds/666601578

No idea why it doesn't show up on GitHub though.