mirror of
https://github.com/meshtastic/firmware.git
synced 2025-04-29 11:01:15 +00:00
properly discard messages with fromradio queue is full (Rather than blocking forever)
This commit is contained in:
parent
9a86d52d00
commit
78c665abb9
@ -6,10 +6,10 @@ You probably don't care about this section - skip to the next one.
|
|||||||
|
|
||||||
* DONE test latest firmware update with is_router
|
* DONE test latest firmware update with is_router
|
||||||
* DONE firmware OTA updates of is_router true nodes fails?
|
* DONE firmware OTA updates of is_router true nodes fails?
|
||||||
* add UI in android app to reset to defaults https://github.com/meshtastic/Meshtastic-Android/issues/263
|
* DONE add UI in android app to reset to defaults https://github.com/meshtastic/Meshtastic-Android/issues/263
|
||||||
* TEST THIS! changing channels requires a reboot to take effect https://github.com/meshtastic/Meshtastic-device/issues/752
|
* DONE TEST THIS! changing channels requires a reboot to take effect https://github.com/meshtastic/Meshtastic-device/issues/752
|
||||||
* bug report with remote info request timing out
|
* DIBE bug report with remote info request timing out
|
||||||
* retest channel changing in android (using sim?)
|
* DONE retest channel changing in android (using sim?)
|
||||||
* DONE move remote admin doc from forum into git
|
* DONE move remote admin doc from forum into git
|
||||||
* DONE check crashlytics
|
* DONE check crashlytics
|
||||||
* DONE ask for a documentation czar
|
* DONE ask for a documentation czar
|
||||||
|
@ -115,7 +115,8 @@ void Router::abortSendAndNak(Routing_Error err, MeshPacket *p)
|
|||||||
packetPool.release(p);
|
packetPool.release(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Router::setReceivedMessage() {
|
void Router::setReceivedMessage()
|
||||||
|
{
|
||||||
setInterval(0); // Run ASAP, so we can figure out our correct sleep time
|
setInterval(0); // Run ASAP, so we can figure out our correct sleep time
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,9 +124,13 @@ ErrorCode Router::sendLocal(MeshPacket *p)
|
|||||||
{
|
{
|
||||||
// No need to deliver externally if the destination is the local node
|
// No need to deliver externally if the destination is the local node
|
||||||
if (p->to == nodeDB.getNodeNum()) {
|
if (p->to == nodeDB.getNodeNum()) {
|
||||||
printPacket("Enqueuing local", p);
|
if (fromRadioQueue.enqueue(p, 0)) {
|
||||||
fromRadioQueue.enqueue(p);
|
printPacket("Enqueued local", p);
|
||||||
setReceivedMessage();
|
setReceivedMessage();
|
||||||
|
} else {
|
||||||
|
printPacket("BUG! fromRadioQueue is full! Discarding!", p);
|
||||||
|
packetPool.release(p);
|
||||||
|
}
|
||||||
return ERRNO_OK;
|
return ERRNO_OK;
|
||||||
} else if (!iface) {
|
} else if (!iface) {
|
||||||
// We must be sending to remote nodes also, fail if no interface found
|
// We must be sending to remote nodes also, fail if no interface found
|
||||||
@ -143,9 +148,10 @@ ErrorCode Router::sendLocal(MeshPacket *p)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void printBytes(const char *label, const uint8_t *p, size_t numbytes) {
|
void printBytes(const char *label, const uint8_t *p, size_t numbytes)
|
||||||
|
{
|
||||||
DEBUG_MSG("%s: ", label);
|
DEBUG_MSG("%s: ", label);
|
||||||
for(size_t i = 0; i < numbytes; i++)
|
for (size_t i = 0; i < numbytes; i++)
|
||||||
DEBUG_MSG("%02x ", p[i]);
|
DEBUG_MSG("%02x ", p[i]);
|
||||||
DEBUG_MSG("\n");
|
DEBUG_MSG("\n");
|
||||||
}
|
}
|
||||||
@ -189,7 +195,7 @@ ErrorCode Router::send(MeshPacket *p)
|
|||||||
return ERRNO_TOO_LARGE;
|
return ERRNO_TOO_LARGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
//printBytes("plaintext", bytes, numbytes);
|
// printBytes("plaintext", bytes, numbytes);
|
||||||
|
|
||||||
auto hash = channels.setActiveByIndex(p->channel);
|
auto hash = channels.setActiveByIndex(p->channel);
|
||||||
if (hash < 0) {
|
if (hash < 0) {
|
||||||
@ -247,19 +253,18 @@ bool Router::perhapsDecode(MeshPacket *p)
|
|||||||
rawSize); // we have to copy into a scratch buffer, because these bytes are a union with the decoded protobuf
|
rawSize); // we have to copy into a scratch buffer, because these bytes are a union with the decoded protobuf
|
||||||
crypto->decrypt(p->from, p->id, rawSize, bytes);
|
crypto->decrypt(p->from, p->id, rawSize, bytes);
|
||||||
|
|
||||||
//printBytes("plaintext", bytes, p->encrypted.size);
|
// printBytes("plaintext", bytes, p->encrypted.size);
|
||||||
|
|
||||||
// Take those raw bytes and convert them back into a well structured protobuf we can understand
|
// Take those raw bytes and convert them back into a well structured protobuf we can understand
|
||||||
memset(&p->decoded, 0, sizeof(p->decoded));
|
memset(&p->decoded, 0, sizeof(p->decoded));
|
||||||
if (!pb_decode_from_bytes(bytes, rawSize, Data_fields, &p->decoded)) {
|
if (!pb_decode_from_bytes(bytes, rawSize, Data_fields, &p->decoded)) {
|
||||||
DEBUG_MSG("Invalid protobufs in received mesh packet (bad psk?)!\n");
|
DEBUG_MSG("Invalid protobufs in received mesh packet (bad psk?)!\n");
|
||||||
} else if(p->decoded.portnum == PortNum_UNKNOWN_APP) {
|
} else if (p->decoded.portnum == PortNum_UNKNOWN_APP) {
|
||||||
DEBUG_MSG("Invalid portnum (bad psk?)!\n");
|
DEBUG_MSG("Invalid portnum (bad psk?)!\n");
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// parsing was successful
|
// parsing was successful
|
||||||
p->which_payloadVariant = MeshPacket_decoded_tag; // change type to decoded
|
p->which_payloadVariant = MeshPacket_decoded_tag; // change type to decoded
|
||||||
p->channel = chIndex; // change to store the index instead of the hash
|
p->channel = chIndex; // change to store the index instead of the hash
|
||||||
printPacket("decoded message", p);
|
printPacket("decoded message", p);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -293,18 +298,20 @@ void Router::handleReceived(MeshPacket *p)
|
|||||||
// call any promiscious plugins here, make a (non promisiocous) plugin for forwarding messages to phone api
|
// call any promiscious plugins here, make a (non promisiocous) plugin for forwarding messages to phone api
|
||||||
// sniffReceived(p);
|
// sniffReceived(p);
|
||||||
MeshPlugin::callPlugins(*p);
|
MeshPlugin::callPlugins(*p);
|
||||||
|
} else {
|
||||||
|
DEBUG_MSG("packet decoding failed\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Router::perhapsHandleReceived(MeshPacket *p)
|
void Router::perhapsHandleReceived(MeshPacket *p)
|
||||||
{
|
{
|
||||||
assert(radioConfig.has_preferences);
|
assert(radioConfig.has_preferences);
|
||||||
bool ignore = is_in_repeated(radioConfig.preferences.ignore_incoming, getFrom(p));
|
bool ignore = is_in_repeated(radioConfig.preferences.ignore_incoming, p->from);
|
||||||
|
|
||||||
if (ignore)
|
if (ignore)
|
||||||
DEBUG_MSG("Ignoring incoming message, 0x%x is in our ignore list\n", p->from);
|
DEBUG_MSG("Ignoring incoming message, 0x%x is in our ignore list\n", p->from);
|
||||||
else if (ignore |= shouldFilterReceived(p)) {
|
else if (ignore |= shouldFilterReceived(p)) {
|
||||||
// DEBUG_MSG("Incoming message was filtered 0x%x\n", p->from);
|
DEBUG_MSG("Incoming message was filtered 0x%x\n", p->from);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note: we avoid calling shouldFilterReceived if we are supposed to ignore certain nodes - because some overrides might
|
// Note: we avoid calling shouldFilterReceived if we are supposed to ignore certain nodes - because some overrides might
|
||||||
|
@ -31,7 +31,9 @@ template <class T> class TypedQueue
|
|||||||
|
|
||||||
bool isEmpty() { return uxQueueMessagesWaiting(h) == 0; }
|
bool isEmpty() { return uxQueueMessagesWaiting(h) == 0; }
|
||||||
|
|
||||||
bool enqueue(T x, TickType_t maxWait = portMAX_DELAY)
|
/** euqueue a packet. Also, maxWait used to default to portMAX_DELAY, but we now want to callers to THINK about what blocking
|
||||||
|
* they want */
|
||||||
|
bool enqueue(T x, TickType_t maxWait)
|
||||||
{
|
{
|
||||||
if (reader) {
|
if (reader) {
|
||||||
reader->setInterval(0);
|
reader->setInterval(0);
|
||||||
|
Loading…
Reference in New Issue
Block a user