mirror of
https://github.com/meshtastic/firmware.git
synced 2025-04-28 18:47:40 +00:00
Merge branch 'master' into metadata-phone-api
This commit is contained in:
commit
b78e0dce46
@ -77,6 +77,8 @@ void MeshModule::callPlugins(const meshtastic_MeshPacket &mp, RxSource src)
|
|||||||
|
|
||||||
currentReply = NULL; // No reply yet
|
currentReply = NULL; // No reply yet
|
||||||
|
|
||||||
|
bool ignoreRequest = false; // No module asked to ignore the request yet
|
||||||
|
|
||||||
// Was this message directed to us specifically? Will be false if we are sniffing someone elses packets
|
// Was this message directed to us specifically? Will be false if we are sniffing someone elses packets
|
||||||
auto ourNodeNum = nodeDB.getNodeNum();
|
auto ourNodeNum = nodeDB.getNodeNum();
|
||||||
bool toUs = mp.to == NODENUM_BROADCAST || mp.to == ourNodeNum;
|
bool toUs = mp.to == NODENUM_BROADCAST || mp.to == ourNodeNum;
|
||||||
@ -135,7 +137,8 @@ void MeshModule::callPlugins(const meshtastic_MeshPacket &mp, RxSource src)
|
|||||||
// any other node.
|
// any other node.
|
||||||
if (mp.decoded.want_response && toUs && (getFrom(&mp) != ourNodeNum || mp.to == ourNodeNum) && !currentReply) {
|
if (mp.decoded.want_response && toUs && (getFrom(&mp) != ourNodeNum || mp.to == ourNodeNum) && !currentReply) {
|
||||||
pi.sendResponse(mp);
|
pi.sendResponse(mp);
|
||||||
LOG_INFO("Module '%s' sent a response\n", pi.name);
|
ignoreRequest = ignoreRequest || pi.ignoreRequest; // If at least one module asks it, we may ignore a request
|
||||||
|
LOG_INFO("Asked module '%s' to send a response\n", pi.name);
|
||||||
} else {
|
} else {
|
||||||
LOG_DEBUG("Module '%s' considered\n", pi.name);
|
LOG_DEBUG("Module '%s' considered\n", pi.name);
|
||||||
}
|
}
|
||||||
@ -162,8 +165,9 @@ void MeshModule::callPlugins(const meshtastic_MeshPacket &mp, RxSource src)
|
|||||||
printPacket("Sending response", currentReply);
|
printPacket("Sending response", currentReply);
|
||||||
service.sendToMesh(currentReply);
|
service.sendToMesh(currentReply);
|
||||||
currentReply = NULL;
|
currentReply = NULL;
|
||||||
} else if (mp.from != ourNodeNum) {
|
} else if (mp.from != ourNodeNum && !ignoreRequest) {
|
||||||
// Note: if the message started with the local node we don't want to send a no response reply
|
// Note: if the message started with the local node or a module asked to ignore the request, we don't want to send a
|
||||||
|
// no response reply
|
||||||
|
|
||||||
// No one wanted to reply to this requst, tell the requster that happened
|
// No one wanted to reply to this requst, tell the requster that happened
|
||||||
LOG_DEBUG("No one responded, send a nak\n");
|
LOG_DEBUG("No one responded, send a nak\n");
|
||||||
|
@ -94,6 +94,9 @@ class MeshModule
|
|||||||
* flag */
|
* flag */
|
||||||
bool encryptedOk = false;
|
bool encryptedOk = false;
|
||||||
|
|
||||||
|
/* We allow modules to ignore a request without sending an error if they have a specific reason for it. */
|
||||||
|
bool ignoreRequest = false;
|
||||||
|
|
||||||
/** If a bound channel name is set, we will only accept received packets that come in on that channel.
|
/** If a bound channel name is set, we will only accept received packets that come in on that channel.
|
||||||
* A special exception (FIXME, not sure if this is a good idea) - packets that arrive on the local interface
|
* A special exception (FIXME, not sure if this is a good idea) - packets that arrive on the local interface
|
||||||
* are allowed on any channel (this lets the local user do anything).
|
* are allowed on any channel (this lets the local user do anything).
|
||||||
|
@ -34,6 +34,7 @@ void NodeInfoModule::sendOurNodeInfo(NodeNum dest, bool wantReplies)
|
|||||||
service.cancelSending(prevPacketId);
|
service.cancelSending(prevPacketId);
|
||||||
|
|
||||||
meshtastic_MeshPacket *p = allocReply();
|
meshtastic_MeshPacket *p = allocReply();
|
||||||
|
if (p) { // Check whether we didn't ignore it
|
||||||
p->to = dest;
|
p->to = dest;
|
||||||
p->decoded.want_response = wantReplies;
|
p->decoded.want_response = wantReplies;
|
||||||
p->priority = meshtastic_MeshPacket_Priority_BACKGROUND;
|
p->priority = meshtastic_MeshPacket_Priority_BACKGROUND;
|
||||||
@ -41,14 +42,25 @@ void NodeInfoModule::sendOurNodeInfo(NodeNum dest, bool wantReplies)
|
|||||||
|
|
||||||
service.sendToMesh(p);
|
service.sendToMesh(p);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
meshtastic_MeshPacket *NodeInfoModule::allocReply()
|
meshtastic_MeshPacket *NodeInfoModule::allocReply()
|
||||||
{
|
{
|
||||||
|
uint32_t now = millis();
|
||||||
|
// If we sent our NodeInfo less than 1 min. ago, don't send it again as it may be still underway.
|
||||||
|
if (lastSentToMesh && (now - lastSentToMesh) < 60 * 1000) {
|
||||||
|
LOG_DEBUG("Sending NodeInfo will be ignored since we just sent it.\n");
|
||||||
|
ignoreRequest = true; // Mark it as ignored for MeshModule
|
||||||
|
return NULL;
|
||||||
|
} else {
|
||||||
|
ignoreRequest = false; // Don't ignore requests anymore
|
||||||
meshtastic_User &u = owner;
|
meshtastic_User &u = owner;
|
||||||
|
|
||||||
LOG_INFO("sending owner %s/%s/%s\n", u.id, u.long_name, u.short_name);
|
LOG_INFO("sending owner %s/%s/%s\n", u.id, u.long_name, u.short_name);
|
||||||
|
lastSentToMesh = now;
|
||||||
return allocDataProtobuf(u);
|
return allocDataProtobuf(u);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
NodeInfoModule::NodeInfoModule()
|
NodeInfoModule::NodeInfoModule()
|
||||||
: ProtobufModule("nodeinfo", meshtastic_PortNum_NODEINFO_APP, &meshtastic_User_msg), concurrency::OSThread("NodeInfoModule")
|
: ProtobufModule("nodeinfo", meshtastic_PortNum_NODEINFO_APP, &meshtastic_User_msg), concurrency::OSThread("NodeInfoModule")
|
||||||
|
@ -35,6 +35,9 @@ class NodeInfoModule : public ProtobufModule<meshtastic_User>, private concurren
|
|||||||
|
|
||||||
/** Does our periodic broadcast */
|
/** Does our periodic broadcast */
|
||||||
virtual int32_t runOnce() override;
|
virtual int32_t runOnce() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
uint32_t lastSentToMesh = 0; // Last time we sent our NodeInfo to the mesh
|
||||||
};
|
};
|
||||||
|
|
||||||
extern NodeInfoModule *nodeInfoModule;
|
extern NodeInfoModule *nodeInfoModule;
|
||||||
|
Loading…
Reference in New Issue
Block a user