mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
* Dispatcher: more stats added
This commit is contained in:
parent
67b0dfa868
commit
382b73f6c5
4 changed files with 37 additions and 1 deletions
|
|
@ -64,6 +64,9 @@ struct RepeaterStats {
|
||||||
uint32_t n_packets_sent;
|
uint32_t n_packets_sent;
|
||||||
uint32_t total_air_time_secs;
|
uint32_t total_air_time_secs;
|
||||||
uint32_t total_up_time_secs;
|
uint32_t total_up_time_secs;
|
||||||
|
uint32_t n_sent_flood, n_sent_direct;
|
||||||
|
uint32_t n_recv_flood, n_recv_direct;
|
||||||
|
uint32_t n_full_events;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ClientInfo {
|
struct ClientInfo {
|
||||||
|
|
@ -120,6 +123,11 @@ class MyMesh : public mesh::Mesh {
|
||||||
stats.n_packets_sent = my_radio->getPacketsSent();
|
stats.n_packets_sent = my_radio->getPacketsSent();
|
||||||
stats.total_air_time_secs = getTotalAirTime() / 1000;
|
stats.total_air_time_secs = getTotalAirTime() / 1000;
|
||||||
stats.total_up_time_secs = _ms->getMillis() / 1000;
|
stats.total_up_time_secs = _ms->getMillis() / 1000;
|
||||||
|
stats.n_sent_flood = getNumSentFlood();
|
||||||
|
stats.n_sent_direct = getNumSentDirect();
|
||||||
|
stats.n_recv_flood = getNumRecvFlood();
|
||||||
|
stats.n_recv_direct = getNumRecvDirect();
|
||||||
|
stats.n_full_events = getNumFullEvents();
|
||||||
|
|
||||||
memcpy(&reply_data[4], &stats, sizeof(stats));
|
memcpy(&reply_data[4], &stats, sizeof(stats));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,9 @@ struct RepeaterStats {
|
||||||
uint32_t n_packets_sent;
|
uint32_t n_packets_sent;
|
||||||
uint32_t total_air_time_secs;
|
uint32_t total_air_time_secs;
|
||||||
uint32_t total_up_time_secs;
|
uint32_t total_up_time_secs;
|
||||||
|
uint32_t n_sent_flood, n_sent_direct;
|
||||||
|
uint32_t n_recv_flood, n_recv_direct;
|
||||||
|
uint32_t n_full_events;
|
||||||
};
|
};
|
||||||
|
|
||||||
class MyMesh : public mesh::Mesh {
|
class MyMesh : public mesh::Mesh {
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,10 @@
|
||||||
namespace mesh {
|
namespace mesh {
|
||||||
|
|
||||||
void Dispatcher::begin() {
|
void Dispatcher::begin() {
|
||||||
|
n_sent_flood = n_sent_direct = 0;
|
||||||
|
n_recv_flood = n_recv_direct = 0;
|
||||||
|
n_full_events = 0;
|
||||||
|
|
||||||
_radio->begin();
|
_radio->begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -26,6 +30,11 @@ void Dispatcher::loop() {
|
||||||
|
|
||||||
_radio->onSendFinished();
|
_radio->onSendFinished();
|
||||||
onPacketSent(outbound);
|
onPacketSent(outbound);
|
||||||
|
if (outbound->isRouteFlood()) {
|
||||||
|
n_sent_flood++;
|
||||||
|
} else {
|
||||||
|
n_sent_direct++;
|
||||||
|
}
|
||||||
outbound = NULL;
|
outbound = NULL;
|
||||||
} else if (millisHasNowPassed(outbound_expiry)) {
|
} else if (millisHasNowPassed(outbound_expiry)) {
|
||||||
MESH_DEBUG_PRINTLN("Dispatcher::loop(): WARNING: outbound packed send timed out!");
|
MESH_DEBUG_PRINTLN("Dispatcher::loop(): WARNING: outbound packed send timed out!");
|
||||||
|
|
@ -85,6 +94,11 @@ void Dispatcher::checkRecv() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (pkt) {
|
if (pkt) {
|
||||||
|
if (pkt->isRouteFlood()) {
|
||||||
|
n_recv_flood++;
|
||||||
|
} else {
|
||||||
|
n_recv_direct++;
|
||||||
|
}
|
||||||
#if MESH_PACKET_LOGGING
|
#if MESH_PACKET_LOGGING
|
||||||
Serial.printf("PACKET: recv, len=%d (type=%d, route=%s, payload_len=%d) SNR=%d RSSI=%d\n",
|
Serial.printf("PACKET: recv, len=%d (type=%d, route=%s, payload_len=%d) SNR=%d RSSI=%d\n",
|
||||||
2 + pkt->path_len + pkt->payload_len, pkt->getPayloadType(), pkt->isRouteDirect() ? "D" : "F", pkt->payload_len,
|
2 + pkt->path_len + pkt->payload_len, pkt->getPayloadType(), pkt->isRouteDirect() ? "D" : "F", pkt->payload_len,
|
||||||
|
|
@ -142,7 +156,10 @@ void Dispatcher::checkSend() {
|
||||||
}
|
}
|
||||||
|
|
||||||
Packet* Dispatcher::obtainNewPacket() {
|
Packet* Dispatcher::obtainNewPacket() {
|
||||||
return _mgr->allocNew(); // TODO: zero out all fields
|
auto pkt = _mgr->allocNew(); // TODO: zero out all fields
|
||||||
|
if (pkt == NULL) n_full_events++;
|
||||||
|
|
||||||
|
return pkt;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dispatcher::releasePacket(Packet* packet) {
|
void Dispatcher::releasePacket(Packet* packet) {
|
||||||
|
|
|
||||||
|
|
@ -94,6 +94,9 @@ class Dispatcher {
|
||||||
Packet* outbound; // current outbound packet
|
Packet* outbound; // current outbound packet
|
||||||
unsigned long outbound_expiry, outbound_start, total_air_time;
|
unsigned long outbound_expiry, outbound_start, total_air_time;
|
||||||
unsigned long next_tx_time;
|
unsigned long next_tx_time;
|
||||||
|
uint32_t n_sent_flood, n_sent_direct;
|
||||||
|
uint32_t n_recv_flood, n_recv_direct;
|
||||||
|
uint32_t n_full_events;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
PacketManager* _mgr;
|
PacketManager* _mgr;
|
||||||
|
|
@ -119,6 +122,11 @@ public:
|
||||||
void sendPacket(Packet* packet, uint8_t priority, uint32_t delay_millis=0);
|
void sendPacket(Packet* packet, uint8_t priority, uint32_t delay_millis=0);
|
||||||
|
|
||||||
unsigned long getTotalAirTime() const { return total_air_time; } // in milliseconds
|
unsigned long getTotalAirTime() const { return total_air_time; } // in milliseconds
|
||||||
|
uint32_t getNumSentFlood() const { return n_sent_flood; }
|
||||||
|
uint32_t getNumSentDirect() const { return n_sent_direct; }
|
||||||
|
uint32_t getNumRecvFlood() const { return n_recv_flood; }
|
||||||
|
uint32_t getNumRecvDirect() const { return n_recv_direct; }
|
||||||
|
uint32_t getNumFullEvents() const { return n_full_events; }
|
||||||
|
|
||||||
// helper methods
|
// helper methods
|
||||||
bool millisHasNowPassed(unsigned long timestamp) const;
|
bool millisHasNowPassed(unsigned long timestamp) const;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue