kopia lustrzana https://github.com/meshtastic/firmware
very important: don't allow immediate sends if we have pending ISRs
rodzic
82c1752d85
commit
31eb2f5337
|
@ -106,18 +106,9 @@ void RF95Interface::startReceive()
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Could we send right now (i.e. either not actively receving or transmitting)? */
|
/** 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).
|
return lora->isReceiving();
|
||||||
// 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RF95Interface::sleep()
|
bool RF95Interface::sleep()
|
||||||
|
|
|
@ -38,9 +38,9 @@ class RF95Interface : public RadioLibInterface
|
||||||
*/
|
*/
|
||||||
virtual void enableInterrupt(void (*callback)()) { lora->setDio0Action(callback); }
|
virtual void enableInterrupt(void (*callback)()) { lora->setDio0Action(callback); }
|
||||||
|
|
||||||
/** Could we send right now (i.e. either not actively receiving or transmitting)? */
|
/** are we actively receiving a packet (only called during receiving state) */
|
||||||
virtual bool canSendImmediately();
|
virtual bool isActivelyReceiving();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start waiting to receive a message
|
* Start waiting to receive a message
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -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
|
/// 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
|
/// 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
|
/// bluetooth comms code. If the txmit queue is empty it might return an error
|
||||||
|
|
|
@ -101,7 +101,10 @@ class RadioLibInterface : public RadioInterface
|
||||||
void applyModemConfig();
|
void applyModemConfig();
|
||||||
|
|
||||||
/** Could we send right now (i.e. either not actively receiving or transmitting)? */
|
/** 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
|
* Start waiting to receive a message
|
||||||
|
|
|
@ -100,18 +100,9 @@ void SX1262Interface::startReceive()
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Could we send right now (i.e. either not actively receving or transmitting)? */
|
/** 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).
|
return lora.getPacketLength() > 0;
|
||||||
// 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SX1262Interface::sleep()
|
bool SX1262Interface::sleep()
|
||||||
|
|
|
@ -36,8 +36,8 @@ class SX1262Interface : public RadioLibInterface
|
||||||
*/
|
*/
|
||||||
virtual void enableInterrupt(void (*callback)()) { lora.setDio1Action(callback); }
|
virtual void enableInterrupt(void (*callback)()) { lora.setDio1Action(callback); }
|
||||||
|
|
||||||
/** Could we send right now (i.e. either not actively receiving or transmitting)? */
|
/** are we actively receiving a packet (only called during receiving state) */
|
||||||
virtual bool canSendImmediately();
|
virtual bool isActivelyReceiving();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start waiting to receive a message
|
* Start waiting to receive a message
|
||||||
|
@ -47,6 +47,7 @@ class SX1262Interface : public RadioLibInterface
|
||||||
* Add SNR data to received messages
|
* Add SNR data to received messages
|
||||||
*/
|
*/
|
||||||
virtual void addReceiveMetadata(MeshPacket *mp);
|
virtual void addReceiveMetadata(MeshPacket *mp);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setStandby();
|
void setStandby();
|
||||||
};
|
};
|
Ładowanie…
Reference in New Issue