From 04225f7bc29c7d8834f245863cd0eff9237b3dde Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Fri, 26 Mar 2021 09:30:15 +0800 Subject: [PATCH] change! time of last packet rx in node->last_heard instead of node->position.time --- docs/software/TODO.md | 9 ++++++--- src/mesh/MeshService.cpp | 2 +- src/mesh/NodeDB.cpp | 11 ++++------- src/mesh/generated/deviceonly.pb.h | 2 +- src/mesh/generated/mesh.pb.h | 9 ++++++--- 5 files changed, 18 insertions(+), 15 deletions(-) diff --git a/docs/software/TODO.md b/docs/software/TODO.md index 39dfa69c7..1571caeff 100644 --- a/docs/software/TODO.md +++ b/docs/software/TODO.md @@ -4,13 +4,16 @@ You probably don't care about this section - skip to the next one. ## before next release -* turn off bluetooth interface ENTIRELY while using serial API (was python client times out on connect sometimes) -* gps assistance from phone not working? +* split position.time and last_heard +* update android app to use last_heard +* have android fill in if local GPS has poor signal +* DONE turn off bluetooth interface ENTIRELY while using serial API (was python client times out on connect sometimes) +* DONE gps assistance from phone not working? * DONE test latest firmware update with is_router * DONE firmware OTA updates of is_router true nodes fails? * DONE add UI in android app to reset to defaults https://github.com/meshtastic/Meshtastic-Android/issues/263 * DONE TEST THIS! changing channels requires a reboot to take effect https://github.com/meshtastic/Meshtastic-device/issues/752 -* DIBE bug report with remote info request timing out +* DONE bug report with remote info request timing out * DONE retest channel changing in android (using sim?) * DONE move remote admin doc from forum into git * DONE check crashlytics diff --git a/src/mesh/MeshService.cpp b/src/mesh/MeshService.cpp index e270b5a2c..bc14d057a 100644 --- a/src/mesh/MeshService.cpp +++ b/src/mesh/MeshService.cpp @@ -198,7 +198,7 @@ NodeInfo *MeshService::refreshMyNodeInfo() Position &position = node->position; // Update our local node info with our position (even if we don't decide to update anyone else) - position.time = + node->last_heard = getValidTime(RTCQualityFromNet); // This nodedb timestamp might be stale, so update it if our clock is kinda valid position.battery_level = powerStatus->getBatteryChargePercent(); diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index bc71dab3d..aa346aca4 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -408,8 +408,7 @@ uint32_t sinceLastSeen(const NodeInfo *n) { uint32_t now = getTime(); - uint32_t last_seen = n->position.time; - int delta = (int)(now - last_seen); + int delta = (int)(now - n->last_heard); if (delta < 0) // our clock must be slightly off still - not set from GPS yet delta = 0; @@ -443,7 +442,7 @@ void NodeDB::updatePosition(uint32_t nodeId, const Position &p) // Be careful to only update fields that have been set by the sender // A lot of position reports don't have time populated. In that case, be careful to not blow away the time we // recorded based on the packet rxTime - if (!info->position.time && p.time) + if (p.time) info->position.time = p.time; if (p.battery_level) info->position.battery_level = p.battery_level; @@ -493,10 +492,8 @@ void NodeDB::updateFrom(const MeshPacket &mp) NodeInfo *info = getOrCreateNode(getFrom(&mp)); - if (mp.rx_time) { // if the packet has a valid timestamp use it to update our last_seen - info->has_position = true; // at least the time is valid - info->position.time = mp.rx_time; - } + if (mp.rx_time) // if the packet has a valid timestamp use it to update our last_heard + info->last_heard = mp.rx_time; if (mp.rx_snr) info->snr = mp.rx_snr; // keep the most recent SNR we received for this node. diff --git a/src/mesh/generated/deviceonly.pb.h b/src/mesh/generated/deviceonly.pb.h index ababb0e0c..2a9082f69 100644 --- a/src/mesh/generated/deviceonly.pb.h +++ b/src/mesh/generated/deviceonly.pb.h @@ -125,7 +125,7 @@ extern const pb_msgdesc_t ChannelFile_msg; /* Maximum encoded size of messages (where known) */ #define LegacyRadioConfig_size 4 #define LegacyRadioConfig_LegacyPreferences_size 2 -#define DeviceState_size 4920 +#define DeviceState_size 5112 #define ChannelFile_size 832 #ifdef __cplusplus diff --git a/src/mesh/generated/mesh.pb.h b/src/mesh/generated/mesh.pb.h index 566efc1f0..bd59b8b9b 100644 --- a/src/mesh/generated/mesh.pb.h +++ b/src/mesh/generated/mesh.pb.h @@ -161,6 +161,7 @@ typedef struct _NodeInfo { User user; bool has_position; Position position; + uint32_t last_heard; float snr; } NodeInfo; @@ -233,7 +234,7 @@ extern "C" { #define Routing_init_default {0, {RouteDiscovery_init_default}} #define Data_init_default {_PortNum_MIN, {0, {0}}, 0, 0, 0, 0} #define MeshPacket_init_default {0, 0, 0, 0, {Data_init_default}, 0, 0, 0, 0, 0, _MeshPacket_Priority_MIN, 0} -#define NodeInfo_init_default {0, false, User_init_default, false, Position_init_default, 0} +#define NodeInfo_init_default {0, false, User_init_default, false, Position_init_default, 0, 0} #define MyNodeInfo_init_default {0, 0, 0, "", "", "", _CriticalErrorCode_MIN, 0, 0, 0, 0, 0} #define LogRecord_init_default {"", 0, "", _LogRecord_Level_MIN} #define FromRadio_init_default {0, 0, {MyNodeInfo_init_default}} @@ -244,7 +245,7 @@ extern "C" { #define Routing_init_zero {0, {RouteDiscovery_init_zero}} #define Data_init_zero {_PortNum_MIN, {0, {0}}, 0, 0, 0, 0} #define MeshPacket_init_zero {0, 0, 0, 0, {Data_init_zero}, 0, 0, 0, 0, 0, _MeshPacket_Priority_MIN, 0} -#define NodeInfo_init_zero {0, false, User_init_zero, false, Position_init_zero, 0} +#define NodeInfo_init_zero {0, false, User_init_zero, false, Position_init_zero, 0, 0} #define MyNodeInfo_init_zero {0, 0, 0, "", "", "", _CriticalErrorCode_MIN, 0, 0, 0, 0, 0} #define LogRecord_init_zero {"", 0, "", _LogRecord_Level_MIN} #define FromRadio_init_zero {0, 0, {MyNodeInfo_init_zero}} @@ -299,6 +300,7 @@ extern "C" { #define NodeInfo_num_tag 1 #define NodeInfo_user_tag 2 #define NodeInfo_position_tag 3 +#define NodeInfo_last_heard_tag 4 #define NodeInfo_snr_tag 7 #define Routing_route_request_tag 1 #define Routing_route_reply_tag 2 @@ -378,6 +380,7 @@ X(a, STATIC, SINGULAR, INT32, rx_rssi, 13) X(a, STATIC, SINGULAR, UINT32, num, 1) \ X(a, STATIC, OPTIONAL, MESSAGE, user, 2) \ X(a, STATIC, OPTIONAL, MESSAGE, position, 3) \ +X(a, STATIC, SINGULAR, FIXED32, last_heard, 4) \ X(a, STATIC, SINGULAR, FLOAT, snr, 7) #define NodeInfo_CALLBACK NULL #define NodeInfo_DEFAULT NULL @@ -463,7 +466,7 @@ extern const pb_msgdesc_t ToRadio_msg; #define Routing_size 42 #define Data_size 260 #define MeshPacket_size 309 -#define NodeInfo_size 126 +#define NodeInfo_size 131 #define MyNodeInfo_size 89 #define LogRecord_size 81 #define FromRadio_size 318