mirror of
https://github.com/meshtastic/firmware.git
synced 2025-05-01 03:39:18 +00:00
Position fwd phone (#1413)
* Correct factory reset code for NRF (from 1.2) * Changes from 1.2 * Update proto ref * Whoops Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
This commit is contained in:
parent
04723bd1a0
commit
359b41d869
@ -71,17 +71,7 @@ int MeshService::handleFromRadio(const MeshPacket *mp)
|
|||||||
printPacket("Forwarding to phone", mp);
|
printPacket("Forwarding to phone", mp);
|
||||||
nodeDB.updateFrom(*mp); // update our DB state based off sniffing every RX packet from the radio
|
nodeDB.updateFrom(*mp); // update our DB state based off sniffing every RX packet from the radio
|
||||||
|
|
||||||
fromNum++;
|
sendToPhone((MeshPacket *)mp);
|
||||||
|
|
||||||
if (toPhoneQueue.numFree() == 0) {
|
|
||||||
DEBUG_MSG("NOTE: tophone queue is full, discarding oldest\n");
|
|
||||||
MeshPacket *d = toPhoneQueue.dequeuePtr(0);
|
|
||||||
if (d)
|
|
||||||
releaseToPool(d);
|
|
||||||
}
|
|
||||||
|
|
||||||
MeshPacket *copied = packetPool.allocCopy(*mp);
|
|
||||||
assert(toPhoneQueue.enqueue(copied, 0)); // FIXME, instead of failing for full queue, delete the oldest mssages
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -161,12 +151,16 @@ bool MeshService::cancelSending(PacketId id)
|
|||||||
return router->cancelSending(nodeDB.getNodeNum(), id);
|
return router->cancelSending(nodeDB.getNodeNum(), id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MeshService::sendToMesh(MeshPacket *p, RxSource src)
|
void MeshService::sendToMesh(MeshPacket *p, RxSource src, bool ccToPhone)
|
||||||
{
|
{
|
||||||
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, src);
|
router->sendLocal(p, src);
|
||||||
|
|
||||||
|
if (ccToPhone) {
|
||||||
|
sendToPhone(p);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MeshService::sendNetworkPing(NodeNum dest, bool wantReplies)
|
void MeshService::sendNetworkPing(NodeNum dest, bool wantReplies)
|
||||||
@ -187,6 +181,20 @@ void MeshService::sendNetworkPing(NodeNum dest, bool wantReplies)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MeshService::sendToPhone(MeshPacket *p) {
|
||||||
|
if (toPhoneQueue.numFree() == 0) {
|
||||||
|
DEBUG_MSG("NOTE: tophone queue is full, discarding oldest\n");
|
||||||
|
MeshPacket *d = toPhoneQueue.dequeuePtr(0);
|
||||||
|
if (d)
|
||||||
|
releaseToPool(d);
|
||||||
|
}
|
||||||
|
|
||||||
|
MeshPacket *copied = packetPool.allocCopy(*p);
|
||||||
|
perhapsDecode(copied);
|
||||||
|
assert(toPhoneQueue.enqueue(copied, 0)); // FIXME, instead of failing for full queue, delete the oldest mssages
|
||||||
|
fromNum++;
|
||||||
|
}
|
||||||
|
|
||||||
NodeInfo *MeshService::refreshMyNodeInfo()
|
NodeInfo *MeshService::refreshMyNodeInfo()
|
||||||
{
|
{
|
||||||
NodeInfo *node = nodeDB.getNode(nodeDB.getNodeNum());
|
NodeInfo *node = nodeDB.getNode(nodeDB.getNodeNum());
|
||||||
|
@ -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, RxSource src = RX_SRC_LOCAL);
|
void sendToMesh(MeshPacket *p, RxSource src = RX_SRC_LOCAL, bool ccToPhone = false);
|
||||||
|
|
||||||
/** 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);
|
||||||
@ -83,6 +83,9 @@ class MeshService
|
|||||||
/// Pull the latest power and time info into my nodeinfo
|
/// Pull the latest power and time info into my nodeinfo
|
||||||
NodeInfo *refreshMyNodeInfo();
|
NodeInfo *refreshMyNodeInfo();
|
||||||
|
|
||||||
|
/// Send a packet to the phone
|
||||||
|
void sendToPhone(MeshPacket *p);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Called when our gps position has changed - updates nodedb and sends Location message out into the mesh
|
/// Called when our gps position has changed - updates nodedb and sends Location message out into the mesh
|
||||||
/// returns 0 to allow futher processing
|
/// returns 0 to allow futher processing
|
||||||
|
@ -118,7 +118,7 @@ void PositionModule::sendOurPosition(NodeNum dest, bool wantReplies)
|
|||||||
p->priority = MeshPacket_Priority_BACKGROUND;
|
p->priority = MeshPacket_Priority_BACKGROUND;
|
||||||
prevPacketId = p->id;
|
prevPacketId = p->id;
|
||||||
|
|
||||||
service.sendToMesh(p);
|
service.sendToMesh(p, RX_SRC_LOCAL, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t PositionModule::runOnce()
|
int32_t PositionModule::runOnce()
|
||||||
|
Loading…
Reference in New Issue
Block a user