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.
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 changedtimer.now()
forrx_end
inprocess_data_packet
because I believe it will give us a better anchor point. I disabled theend_disable
shortcut intransmit_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.