Add null check for packet allocation and clean up Dispatcher
This commit is contained in:
@@ -774,9 +774,16 @@ public:
|
||||
#endif
|
||||
|
||||
if (f16 == crc) {
|
||||
mesh::Packet *pkt = _mgr->allocNew();
|
||||
Packet *pkt = _mgr->allocNew();
|
||||
|
||||
if (pkt != NULL) {
|
||||
pkt->readFrom(bytes, len);
|
||||
_mgr->queueInbound(pkt, millis());
|
||||
} else {
|
||||
#if MESH_PACKET_LOGGING
|
||||
Serial.printf("BRIDGE: Unable to allocate new Packet *pkt");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,7 +104,6 @@ void Dispatcher::loop() {
|
||||
processRecvPacket(pkt);
|
||||
}
|
||||
}
|
||||
|
||||
checkRecv();
|
||||
checkSend();
|
||||
}
|
||||
@@ -116,7 +115,6 @@ void Dispatcher::checkRecv() {
|
||||
{
|
||||
uint8_t raw[MAX_TRANS_UNIT+1];
|
||||
int len = _radio->recvRaw(raw, MAX_TRANS_UNIT);
|
||||
|
||||
if (len > 0) {
|
||||
logRxRaw(_radio->getLastSNR(), _radio->getLastRSSI(), raw, len);
|
||||
|
||||
@@ -330,4 +328,5 @@ bool Dispatcher::millisHasNowPassed(unsigned long timestamp) const {
|
||||
unsigned long Dispatcher::futureMillis(int millis_from_now) const {
|
||||
return _ms->getMillis() + millis_from_now;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user