very important: don't allow immediate sends if we have pending ISRs

1.2-legacy
geeksville 2020-05-01 08:32:16 -07:00
rodzic 82c1752d85
commit 31eb2f5337
6 zmienionych plików z 30 dodań i 28 usunięć

Wyświetl plik

@ -106,18 +106,9 @@ void RF95Interface::startReceive()
}
/** Could we send right now (i.e. either not actively receving or transmitting)? */
bool RF95Interface::canSendImmediately()
bool RF95Interface::isActivelyReceiving()
{
// We wait _if_ we are partially though receiving a packet (rather than just merely waiting for one).
// To do otherwise would be doubly bad because not only would we drop the packet that was on the way in,
// we almost certainly guarantee no one outside will like the packet we are sending.
bool busyTx = sendingPacket != NULL;
bool busyRx = isReceiving && lora->isReceiving();
if (busyTx || busyRx)
DEBUG_MSG("Can not set now, busyTx=%d, busyRx=%d\n", busyTx, busyRx);
return !busyTx && !busyRx;
return lora->isReceiving();
}
bool RF95Interface::sleep()

Wyświetl plik

@ -38,9 +38,9 @@ class RF95Interface : public RadioLibInterface
*/
virtual void enableInterrupt(void (*callback)()) { lora->setDio0Action(callback); }
/** Could we send right now (i.e. either not actively receiving or transmitting)? */
virtual bool canSendImmediately();
/** are we actively receiving a packet (only called during receiving state) */
virtual bool isActivelyReceiving();
/**
* Start waiting to receive a message
*/

Wyświetl plik

@ -64,6 +64,22 @@ void RadioLibInterface::applyModemConfig()
}
}
/** Could we send right now (i.e. either not actively receving or transmitting)? */
bool RadioLibInterface::canSendImmediately()
{
// We wait _if_ we are partially though receiving a packet (rather than just merely waiting for one).
// To do otherwise would be doubly bad because not only would we drop the packet that was on the way in,
// we almost certainly guarantee no one outside will like the packet we are sending.
PendingISR isPending = pending;
bool busyTx = sendingPacket != NULL;
bool busyRx = isReceiving && isActivelyReceiving();
if (busyTx || busyRx || isPending)
DEBUG_MSG("Can not send yet, busyTx=%d, busyRx=%d, intPend=%d\n", busyTx, busyRx, isPending);
return !busyTx && !busyRx && !isPending;
}
/// Send a packet (possibly by enquing in a private fifo). This routine will
/// later free() the packet to pool. This routine is not allowed to stall because it is called from
/// bluetooth comms code. If the txmit queue is empty it might return an error

Wyświetl plik

@ -101,7 +101,10 @@ class RadioLibInterface : public RadioInterface
void applyModemConfig();
/** Could we send right now (i.e. either not actively receiving or transmitting)? */
virtual bool canSendImmediately() = 0;
virtual bool canSendImmediately();
/** are we actively receiving a packet (only called during receiving state) */
virtual bool isActivelyReceiving() = 0;
/**
* Start waiting to receive a message

Wyświetl plik

@ -100,18 +100,9 @@ void SX1262Interface::startReceive()
}
/** Could we send right now (i.e. either not actively receving or transmitting)? */
bool SX1262Interface::canSendImmediately()
bool SX1262Interface::isActivelyReceiving()
{
// We wait _if_ we are partially though receiving a packet (rather than just merely waiting for one).
// To do otherwise would be doubly bad because not only would we drop the packet that was on the way in,
// we almost certainly guarantee no one outside will like the packet we are sending.
bool busyTx = sendingPacket != NULL;
bool busyRx = isReceiving && lora.getPacketLength() > 0;
if (busyTx || busyRx)
DEBUG_MSG("Can not set now, busyTx=%d, busyRx=%d\n", busyTx, busyRx);
return !busyTx && !busyRx;
return lora.getPacketLength() > 0;
}
bool SX1262Interface::sleep()

Wyświetl plik

@ -36,8 +36,8 @@ class SX1262Interface : public RadioLibInterface
*/
virtual void enableInterrupt(void (*callback)()) { lora.setDio1Action(callback); }
/** Could we send right now (i.e. either not actively receiving or transmitting)? */
virtual bool canSendImmediately();
/** are we actively receiving a packet (only called during receiving state) */
virtual bool isActivelyReceiving();
/**
* Start waiting to receive a message
@ -47,6 +47,7 @@ class SX1262Interface : public RadioLibInterface
* Add SNR data to received messages
*/
virtual void addReceiveMetadata(MeshPacket *mp);
private:
void setStandby();
};