Skip to content

Commit 61cd01d

Browse files
authored
Merge pull request #1003 from liamcottle/feature/increased-max-uptime
Increase max uptime stats from 49 days to 136 years
2 parents 63c3342 + 273a54f commit 61cd01d

File tree

4 files changed

+20
-2
lines changed

4 files changed

+20
-2
lines changed

examples/simple_repeater/MyMesh.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ int MyMesh::handleRequest(ClientInfo *sender, uint32_t sender_timestamp, uint8_t
149149
stats.n_packets_recv = radio_driver.getPacketsRecv();
150150
stats.n_packets_sent = radio_driver.getPacketsSent();
151151
stats.total_air_time_secs = getTotalAirTime() / 1000;
152-
stats.total_up_time_secs = _ms->getMillis() / 1000;
152+
stats.total_up_time_secs = uptime_millis / 1000;
153153
stats.n_sent_flood = getNumSentFlood();
154154
stats.n_sent_direct = getNumSentDirect();
155155
stats.n_recv_flood = getNumRecvFlood();
@@ -594,6 +594,8 @@ MyMesh::MyMesh(mesh::MainBoard &board, mesh::Radio &radio, mesh::MillisecondCloc
594594
, bridge(&_prefs, _mgr, &rtc)
595595
#endif
596596
{
597+
last_millis = 0;
598+
uptime_millis = 0;
597599
next_local_advert = next_flood_advert = 0;
598600
dirty_contacts_expiry = 0;
599601
set_radio_at = revert_radio_at = 0;
@@ -891,4 +893,9 @@ void MyMesh::loop() {
891893
acl.save(_fs);
892894
dirty_contacts_expiry = 0;
893895
}
896+
897+
// update uptime
898+
uint32_t now = millis();
899+
uptime_millis += now - last_millis;
900+
last_millis = now;
894901
}

examples/simple_repeater/MyMesh.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ struct NeighbourInfo {
7878

7979
class MyMesh : public mesh::Mesh, public CommonCLICallbacks {
8080
FILESYSTEM* _fs;
81+
uint32_t last_millis;
82+
uint64_t uptime_millis;
8183
unsigned long next_local_advert, next_flood_advert;
8284
bool _logging;
8385
NodePrefs _prefs;

examples/simple_room_server/MyMesh.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ int MyMesh::handleRequest(ClientInfo *sender, uint32_t sender_timestamp, uint8_t
144144
stats.n_packets_recv = radio_driver.getPacketsRecv();
145145
stats.n_packets_sent = radio_driver.getPacketsSent();
146146
stats.total_air_time_secs = getTotalAirTime() / 1000;
147-
stats.total_up_time_secs = _ms->getMillis() / 1000;
147+
stats.total_up_time_secs = uptime_millis / 1000;
148148
stats.n_sent_flood = getNumSentFlood();
149149
stats.n_sent_direct = getNumSentDirect();
150150
stats.n_recv_flood = getNumRecvFlood();
@@ -581,6 +581,8 @@ MyMesh::MyMesh(mesh::MainBoard &board, mesh::Radio &radio, mesh::MillisecondCloc
581581
mesh::RTCClock &rtc, mesh::MeshTables &tables)
582582
: mesh::Mesh(radio, ms, rng, rtc, *new StaticPoolPacketManager(32), tables),
583583
_cli(board, rtc, sensors, &_prefs, this), telemetry(MAX_PACKET_PAYLOAD - 4) {
584+
last_millis = 0;
585+
uptime_millis = 0;
584586
next_local_advert = next_flood_advert = 0;
585587
dirty_contacts_expiry = 0;
586588
_logging = false;
@@ -858,4 +860,9 @@ void MyMesh::loop() {
858860
}
859861

860862
// TODO: periodically check for OLD/inactive entries in known_clients[], and evict
863+
864+
// update uptime
865+
uint32_t now = millis();
866+
uptime_millis += now - last_millis;
867+
last_millis = now;
861868
}

examples/simple_room_server/MyMesh.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ struct PostInfo {
8888

8989
class MyMesh : public mesh::Mesh, public CommonCLICallbacks {
9090
FILESYSTEM* _fs;
91+
uint32_t last_millis;
92+
uint64_t uptime_millis;
9193
unsigned long next_local_advert, next_flood_advert;
9294
bool _logging;
9395
NodePrefs _prefs;

0 commit comments

Comments
 (0)