we now always listen before transmit - even if we have just completed a packet

This commit is contained in:
geeksville
2020-05-02 08:29:51 -07:00
parent 4735b3ff5b
commit 2ad314f150
6 changed files with 115 additions and 53 deletions

View File

@@ -14,9 +14,10 @@
class RadioLibInterface : public RadioInterface
{
/// Used as our notification from the ISR
enum PendingISR { ISR_NONE = 0, ISR_RX, ISR_TX };
enum PendingISR { ISR_NONE = 0, ISR_RX, ISR_TX, TRANSMIT_DELAY_COMPLETED };
volatile PendingISR pending = ISR_NONE;
volatile bool timerRunning = false;
/** Our ISR code currently needs this to find our active instance
*/
@@ -25,7 +26,7 @@ class RadioLibInterface : public RadioInterface
/**
* Raw ISR handler that just calls our polymorphic method
*/
static void isrTxLevel0();
static void isrTxLevel0(), isrLevel0Common(PendingISR code);
/**
* Debugging counts
@@ -43,8 +44,8 @@ class RadioLibInterface : public RadioInterface
*/
uint8_t syncWord = SX126X_SYNC_WORD_PRIVATE;
float currentLimit = 100; // FIXME
uint16_t preambleLength = 8; // 8 is default, but FIXME use longer to increase the amount of sleep time when receiving
float currentLimit = 100; // FIXME
uint16_t preambleLength = 32; // 8 is default, but FIXME use longer to increase the amount of sleep time when receiving
Module module; // The HW interface to the radio
@@ -83,12 +84,18 @@ class RadioLibInterface : public RadioInterface
/** start an immediate transmit */
void startSend(MeshPacket *txp);
/** start a queued transmit (if we have one), else start receiving */
void startNextWork();
/** if we have something waiting to send, start a short random timer so we can come check for collision before actually doing
* the transmit
*
* If the timer was already running, we just wait for that one to occur.
* */
void startTransmitTimer(bool withDelay = true);
void handleTransmitInterrupt();
void handleReceiveInterrupt();
static void timerCallback(void *p1, uint32_t p2);
protected:
/**
* Convert our modemConfig enum into wf, sf, etc...