sforkowany z mirror/meshtastic-firmware
Merge pull request #901 from a-f-G-U-C/rx-src-user
add the user as distinct message source - fixing #9001.2-legacy
commit
4e5ac1ac07
|
@ -140,7 +140,7 @@ void MeshService::handleToRadio(MeshPacket &p)
|
||||||
|
|
||||||
// Send the packet into the mesh
|
// Send the packet into the mesh
|
||||||
|
|
||||||
sendToMesh(packetPool.allocCopy(p));
|
sendToMesh(packetPool.allocCopy(p), RX_SRC_USER);
|
||||||
|
|
||||||
bool loopback = false; // if true send any packet the phone sends back itself (for testing)
|
bool loopback = false; // if true send any packet the phone sends back itself (for testing)
|
||||||
if (loopback) {
|
if (loopback) {
|
||||||
|
@ -157,12 +157,12 @@ bool MeshService::cancelSending(PacketId id)
|
||||||
return router->cancelSending(nodeDB.getNodeNum(), id);
|
return router->cancelSending(nodeDB.getNodeNum(), id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MeshService::sendToMesh(MeshPacket *p)
|
void MeshService::sendToMesh(MeshPacket *p, RxSource src)
|
||||||
{
|
{
|
||||||
nodeDB.updateFrom(*p); // update our local DB for this packet (because phone might have sent position packets etc...)
|
nodeDB.updateFrom(*p); // update our local DB for this packet (because phone might have sent position packets etc...)
|
||||||
|
|
||||||
// Note: We might return !OK if our fifo was full, at that point the only option we have is to drop it
|
// Note: We might return !OK if our fifo was full, at that point the only option we have is to drop it
|
||||||
router->sendLocal(p);
|
router->sendLocal(p, src);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MeshService::sendNetworkPing(NodeNum dest, bool wantReplies)
|
void MeshService::sendNetworkPing(NodeNum dest, bool wantReplies)
|
||||||
|
|
|
@ -75,7 +75,7 @@ class MeshService
|
||||||
/// Send a packet into the mesh - note p must have been allocated from packetPool. We will return it to that pool after
|
/// Send a packet into the mesh - note p must have been allocated from packetPool. We will return it to that pool after
|
||||||
/// sending. This is the ONLY function you should use for sending messages into the mesh, because it also updates the nodedb
|
/// sending. This is the ONLY function you should use for sending messages into the mesh, because it also updates the nodedb
|
||||||
/// cache
|
/// cache
|
||||||
void sendToMesh(MeshPacket *p);
|
void sendToMesh(MeshPacket *p, RxSource src = RX_SRC_LOCAL);
|
||||||
|
|
||||||
/** Attempt to cancel a previously sent packet from this _local_ node. Returns true if a packet was found we could cancel */
|
/** Attempt to cancel a previously sent packet from this _local_ node. Returns true if a packet was found we could cancel */
|
||||||
bool cancelSending(PacketId id);
|
bool cancelSending(PacketId id);
|
||||||
|
|
|
@ -20,7 +20,8 @@ typedef uint32_t PacketId; // A packet sequence number
|
||||||
*/
|
*/
|
||||||
enum RxSource {
|
enum RxSource {
|
||||||
RX_SRC_LOCAL, // message was generated locally
|
RX_SRC_LOCAL, // message was generated locally
|
||||||
RX_SRC_RADIO // message was received from radio mesh
|
RX_SRC_RADIO, // message was received from radio mesh
|
||||||
|
RX_SRC_USER // message was received from end-user device
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -145,7 +145,7 @@ void Router::setReceivedMessage()
|
||||||
runASAP = true;
|
runASAP = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorCode Router::sendLocal(MeshPacket *p)
|
ErrorCode Router::sendLocal(MeshPacket *p, RxSource src)
|
||||||
{
|
{
|
||||||
// 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()) {
|
||||||
|
@ -161,7 +161,7 @@ ErrorCode Router::sendLocal(MeshPacket *p)
|
||||||
// If we are sending a broadcast, we also treat it as if we just received it ourself
|
// If we are sending a broadcast, we also treat it as if we just received it ourself
|
||||||
// this allows local apps (and PCs) to see broadcasts sourced locally
|
// this allows local apps (and PCs) to see broadcasts sourced locally
|
||||||
if (p->to == NODENUM_BROADCAST) {
|
if (p->to == NODENUM_BROADCAST) {
|
||||||
handleReceived(p, RX_SRC_LOCAL);
|
handleReceived(p, src);
|
||||||
}
|
}
|
||||||
|
|
||||||
return send(p);
|
return send(p);
|
||||||
|
|
|
@ -45,7 +45,7 @@ class Router : protected concurrency::OSThread
|
||||||
*
|
*
|
||||||
* NOTE: This method will free the provided packet (even if we return an error code)
|
* NOTE: This method will free the provided packet (even if we return an error code)
|
||||||
*/
|
*/
|
||||||
ErrorCode sendLocal(MeshPacket *p);
|
ErrorCode sendLocal(MeshPacket *p, RxSource src = RX_SRC_RADIO);
|
||||||
|
|
||||||
/** Attempt to cancel a previously sent packet. Returns true if a packet was found we could cancel */
|
/** Attempt to cancel a previously sent packet. Returns true if a packet was found we could cancel */
|
||||||
bool cancelSending(NodeNum from, PacketId id);
|
bool cancelSending(NodeNum from, PacketId id);
|
||||||
|
|
Ładowanie…
Reference in New Issue