* CommonCLI: added "clear stats" command

This commit is contained in:
Scott Powell 2025-05-13 18:12:58 +10:00
parent 177dd90ca1
commit 805ca7b900
9 changed files with 29 additions and 2 deletions

View file

@ -686,7 +686,13 @@ public:
*dp = 0; // null terminator
}
const uint8_t* getSelfIdPubKey() { return self_id.pub_key; }
const uint8_t* getSelfIdPubKey() override { return self_id.pub_key; }
void clearStats() override {
radio_driver.resetStats();
resetStats();
((SimpleMeshTables *)getTables())->resetStats();
}
void loop() {
mesh::Mesh::loop();

View file

@ -821,7 +821,13 @@ public:
strcpy(reply, "not supported");
}
const uint8_t* getSelfIdPubKey() { return self_id.pub_key; }
const uint8_t* getSelfIdPubKey() override { return self_id.pub_key; }
void clearStats() override {
radio_driver.resetStats();
resetStats();
((SimpleMeshTables *)getTables())->resetStats();
}
void loop() {
mesh::Mesh::loop();

View file

@ -14,8 +14,10 @@ void Dispatcher::begin() {
n_sent_flood = n_sent_direct = 0;
n_recv_flood = n_recv_direct = 0;
_err_flags = 0;
radio_nonrx_start = _ms->getMillis();
_radio->begin();
prev_isrecv_mode = _radio->isInRecvMode();
}
float Dispatcher::getAirtimeBudgetFactor() const {

View file

@ -156,6 +156,10 @@ public:
uint32_t getNumSentDirect() const { return n_sent_direct; }
uint32_t getNumRecvFlood() const { return n_recv_flood; }
uint32_t getNumRecvDirect() const { return n_recv_direct; }
void resetStats() {
n_sent_flood = n_sent_direct = n_recv_flood = n_recv_direct = 0;
_err_flags = 0;
}
// helper methods
bool millisHasNowPassed(unsigned long timestamp) const;

View file

@ -169,6 +169,9 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, const char* command, ch
checkAdvertInterval();
savePrefs();
sprintf(reply, "password now: %s", _prefs->password); // echo back just to let admin know for sure!!
} else if (memcmp(command, "clear stats", 11) == 0) {
_callbacks->clearStats();
strcpy(reply, "(OK - stats reset)");
} else if (memcmp(command, "get ", 4) == 0) {
const char* config = &command[4];
if (memcmp(config, "af", 2) == 0) {

View file

@ -42,6 +42,7 @@ public:
virtual void setTxPower(uint8_t power_dbm) = 0;
virtual void formatNeighborsReply(char *reply) = 0;
virtual const uint8_t* getSelfIdPubKey() = 0;
virtual void clearStats() = 0;
};
class CommonCLI {

View file

@ -26,6 +26,8 @@ public:
uint32_t getPacketsRecv() const { return n_recv; }
uint32_t getPacketsSent() const { return n_sent; }
void resetStats() { n_recv = n_sent = 0; }
virtual float getLastRSSI() const override;
virtual float getLastSNR() const override;

View file

@ -83,4 +83,5 @@ public:
uint32_t getNumDirectDups() const { return _direct_dups; }
uint32_t getNumFloodDups() const { return _flood_dups; }
void resetStats() { _direct_dups = _flood_dups = 0; }
};

View file

@ -19,6 +19,8 @@ public:
uint32_t getPacketsRecv() const { return n_recv; }
uint32_t getPacketsSent() const { return n_sent; }
void resetStats() { n_recv = n_sent = 0; }
virtual float getLastRSSI() const override;
virtual float getLastSNR() const override;