From f1179bd3eaae7f3d7663c9b473847eda0ed92ee7 Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Sat, 5 Dec 2020 08:46:19 +0800 Subject: [PATCH] positions now sent using the new API --- docs/software/TODO.md | 5 +++-- proto | 2 +- src/mesh/MeshService.cpp | 21 +++++++++------------ 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/docs/software/TODO.md b/docs/software/TODO.md index 492d51def..1ec5719d1 100644 --- a/docs/software/TODO.md +++ b/docs/software/TODO.md @@ -8,13 +8,14 @@ For app cleanup: * require a recent python api to talk to these new device loads * on android for received positions handle either old or new positions * on android side send old or new positions as needed -* fix position sending to use new plugin +* DONE fix position sending to use new plugin * Add SinglePortNumPlugin - as the new most useful baseclass -* move positions into regular data packets (use new app framework) +* DONE move positions into regular data packets (use new app framework) * move user info into regular data packets (use new app framework) * test that positions, text messages and user info still work * test that position, text messages and user info work properly with new android app and old device code * call the plugin setup functions +* fix the RTC drift bug For high speed/lots of devices/short range tasks: diff --git a/proto b/proto index 8b24fbab1..be48f1cbe 160000 --- a/proto +++ b/proto @@ -1 +1 @@ -Subproject commit 8b24fbab195ca76932e70456750cd0172d47db79 +Subproject commit be48f1cbef1f00a4dbe67c81780dc53916ba5335 diff --git a/src/mesh/MeshService.cpp b/src/mesh/MeshService.cpp index 9c45853f7..a02de4184 100644 --- a/src/mesh/MeshService.cpp +++ b/src/mesh/MeshService.cpp @@ -284,10 +284,10 @@ void MeshService::sendNetworkPing(NodeNum dest, bool wantReplies) int MeshService::onGPSChanged(const meshtastic::GPSStatus *unused) { // Update our local node info with our position (even if we don't decide to update anyone else) - MeshPacket *p = router->allocForSending(); - p->decoded.which_payload = SubPacket_position_tag; - Position &pos = p->decoded.position; + Position pos; + + memset(&pos, 0, sizeof(pos)); if (gps->hasLock()) { if (gps->altitude != 0) @@ -304,20 +304,17 @@ int MeshService::onGPSChanged(const meshtastic::GPSStatus *unused) // DEBUG_MSG("got gps notify time=%u, lat=%d, bat=%d\n", pos.latitude_i, pos.time, pos.battery_level); + // Update our current position in the local DB + nodeDB.updatePosition(nodeDB.getNodeNum(), pos); + // We limit our GPS broadcasts to a max rate static uint32_t lastGpsSend; uint32_t now = millis(); if (lastGpsSend == 0 || now - lastGpsSend > getPref_position_broadcast_secs() * 1000) { lastGpsSend = now; - DEBUG_MSG("Sending position to mesh\n"); - - sendToMesh(p); - } else { - // We don't need to send this packet to anyone else, but it still serves as a nice uniform way to update our local state - nodeDB.updateFrom(*p); - - releaseToPool(p); - } + DEBUG_MSG("Sending position to mesh (not requesting replies)\n"); + positionPlugin.sendOurPosition(); + } return 0; }