sforkowany z mirror/meshtastic-firmware
commit
4940822ae8
|
@ -160,9 +160,15 @@ uint32_t RadioInterface::getPacketTime(MeshPacket *p)
|
||||||
uint32_t RadioInterface::getRetransmissionMsec(const MeshPacket *p)
|
uint32_t RadioInterface::getRetransmissionMsec(const MeshPacket *p)
|
||||||
{
|
{
|
||||||
assert(shortPacketMsec); // Better be non zero
|
assert(shortPacketMsec); // Better be non zero
|
||||||
|
static uint8_t bytes[MAX_RHPACKETLEN];
|
||||||
// was 20 and 22 secs respectively, but now with shortPacketMsec as 2269, this should give the same range
|
size_t numbytes = pb_encode_to_bytes(bytes, sizeof(bytes), Data_fields, &p->decoded);
|
||||||
return random(9 * shortPacketMsec, 10 * shortPacketMsec);
|
uint32_t packetAirtime = getPacketTime(numbytes + sizeof(PacketHeader));
|
||||||
|
uint32_t tCADmsec = 2 * (1 << sf) / bw; // duration of CAD is roughly 2 symbols according to SX127x datasheet
|
||||||
|
/* Make sure enough time has elapsed for this packet to be sent and an ACK is received.
|
||||||
|
* Right now we have to wait until another node floods the same packet, as that is our implicit ACK.
|
||||||
|
* TODO: Revise when want_ack will be used (right now it is always set to 0 afterwards).
|
||||||
|
*/
|
||||||
|
return 2*packetAirtime + 2*MIN_TX_WAIT_MSEC + shortPacketMsec + shortPacketMsec*2 + PROCESSING_TIME_MSEC + 2*tCADmsec;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The delay to use when we want to send something but the ether is busy */
|
/** The delay to use when we want to send something but the ether is busy */
|
||||||
|
|
|
@ -63,6 +63,8 @@ class RadioInterface
|
||||||
uint8_t cr = 7;
|
uint8_t cr = 7;
|
||||||
|
|
||||||
uint16_t preambleLength = 32; // 8 is default, but we use longer to increase the amount of sleep time when receiving
|
uint16_t preambleLength = 32; // 8 is default, but we use longer to increase the amount of sleep time when receiving
|
||||||
|
const uint32_t MIN_TX_WAIT_MSEC = 100; // minimum time to wait before transmitting after sensing the channel in ms
|
||||||
|
const uint32_t PROCESSING_TIME_MSEC = 4500; // time to construct, process and construct a packet again (empirically determined)
|
||||||
|
|
||||||
MeshPacket *sendingPacket = NULL; // The packet we are currently sending
|
MeshPacket *sendingPacket = NULL; // The packet we are currently sending
|
||||||
uint32_t lastTxStart = 0L;
|
uint32_t lastTxStart = 0L;
|
||||||
|
|
|
@ -150,7 +150,7 @@ bool ReliableRouter::stopRetransmission(GlobalPacketId key)
|
||||||
if (old) {
|
if (old) {
|
||||||
auto numErased = pending.erase(key);
|
auto numErased = pending.erase(key);
|
||||||
assert(numErased == 1);
|
assert(numErased == 1);
|
||||||
packetPool.release(old->packet);
|
cancelSending(getFrom(old->packet), old->packet->id);
|
||||||
return true;
|
return true;
|
||||||
} else
|
} else
|
||||||
return false;
|
return false;
|
||||||
|
|
Ładowanie…
Reference in New Issue