mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-30 22:50:57 +00:00
Shorter nodeinfo timeout redux (#4458)
* Add shorterTimeout bool to sendOurNodeInfo * Respond to likely PKI decode errors with a quick nodeinfo * Protbufs * Move to PKI_UNKNOWN_PUBKEY for PKI decode error
This commit is contained in:
@@ -32,19 +32,22 @@ bool NodeInfoModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, mes
|
||||
return false; // Let others look at this message also if they want
|
||||
}
|
||||
|
||||
void NodeInfoModule::sendOurNodeInfo(NodeNum dest, bool wantReplies, uint8_t channel)
|
||||
void NodeInfoModule::sendOurNodeInfo(NodeNum dest, bool wantReplies, uint8_t channel, bool _shorterTimeout)
|
||||
{
|
||||
// cancel any not yet sent (now stale) position packets
|
||||
if (prevPacketId) // if we wrap around to zero, we'll simply fail to cancel in that rare case (no big deal)
|
||||
service->cancelSending(prevPacketId);
|
||||
|
||||
shorterTimeout = _shorterTimeout;
|
||||
meshtastic_MeshPacket *p = allocReply();
|
||||
if (p) { // Check whether we didn't ignore it
|
||||
p->to = dest;
|
||||
p->decoded.want_response = (config.device.role != meshtastic_Config_DeviceConfig_Role_TRACKER &&
|
||||
config.device.role != meshtastic_Config_DeviceConfig_Role_SENSOR) &&
|
||||
wantReplies;
|
||||
p->priority = meshtastic_MeshPacket_Priority_BACKGROUND;
|
||||
if (_shorterTimeout)
|
||||
p->priority = meshtastic_MeshPacket_Priority_DEFAULT;
|
||||
else
|
||||
p->priority = meshtastic_MeshPacket_Priority_BACKGROUND;
|
||||
if (channel > 0) {
|
||||
LOG_DEBUG("sending ourNodeInfo to channel %d\n", channel);
|
||||
p->channel = channel;
|
||||
@@ -53,6 +56,7 @@ void NodeInfoModule::sendOurNodeInfo(NodeNum dest, bool wantReplies, uint8_t cha
|
||||
prevPacketId = p->id;
|
||||
|
||||
service->sendToMesh(p);
|
||||
shorterTimeout = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,10 +69,14 @@ meshtastic_MeshPacket *NodeInfoModule::allocReply()
|
||||
}
|
||||
uint32_t now = millis();
|
||||
// If we sent our NodeInfo less than 5 min. ago, don't send it again as it may be still underway.
|
||||
if (lastSentToMesh && (now - lastSentToMesh) < (5 * 60 * 1000)) {
|
||||
if (!shorterTimeout && lastSentToMesh && (now - lastSentToMesh) < (5 * 60 * 1000)) {
|
||||
LOG_DEBUG("Skip sending NodeInfo since we just sent it less than 5 minutes ago.\n");
|
||||
ignoreRequest = true; // Mark it as ignored for MeshModule
|
||||
return NULL;
|
||||
} else if (shorterTimeout && lastSentToMesh && (now - lastSentToMesh) < (60 * 1000)) {
|
||||
LOG_DEBUG("Skip sending actively requested NodeInfo since we just sent it less than 60 seconds ago.\n");
|
||||
ignoreRequest = true; // Mark it as ignored for MeshModule
|
||||
return NULL;
|
||||
} else {
|
||||
ignoreRequest = false; // Don't ignore requests anymore
|
||||
meshtastic_User &u = owner;
|
||||
|
||||
@@ -20,7 +20,8 @@ class NodeInfoModule : public ProtobufModule<meshtastic_User>, private concurren
|
||||
/**
|
||||
* Send our NodeInfo into the mesh
|
||||
*/
|
||||
void sendOurNodeInfo(NodeNum dest = NODENUM_BROADCAST, bool wantReplies = false, uint8_t channel = 0);
|
||||
void sendOurNodeInfo(NodeNum dest = NODENUM_BROADCAST, bool wantReplies = false, uint8_t channel = 0,
|
||||
bool _shorterTimeout = false);
|
||||
|
||||
protected:
|
||||
/** Called to handle a particular incoming message
|
||||
@@ -38,6 +39,7 @@ class NodeInfoModule : public ProtobufModule<meshtastic_User>, private concurren
|
||||
|
||||
private:
|
||||
uint32_t lastSentToMesh = 0; // Last time we sent our NodeInfo to the mesh
|
||||
bool shorterTimeout = false;
|
||||
};
|
||||
|
||||
extern NodeInfoModule *nodeInfoModule;
|
||||
|
||||
Reference in New Issue
Block a user