From 9c2a2be0dfbda5902e00fdd944cea2b248faa593 Mon Sep 17 00:00:00 2001 From: faradaym Date: Thu, 11 Jun 2026 12:40:53 -0500 Subject: [PATCH 1/2] change counter to json Signed-off-by: faradaym --- src/Ducks/Duck.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Ducks/Duck.h b/src/Ducks/Duck.h index f9d5cb9b..73719836 100644 --- a/src/Ducks/Duck.h +++ b/src/Ducks/Duck.h @@ -368,8 +368,14 @@ class Duck { */ static bool sendHealth(void* p){ Duck* duckInstance = static_cast(p); - std::string message = "C:" + std::to_string(duckInstance->counter) + "|" + "FM:" + std::to_string(freeMemory()); - int err = duckInstance->sendData(topics::health, message); + + JsonDocument doc; + doc["C"] = std::to_string(duckInstance->counter); + doc["FM"] = std::to_string(freeMemory()); + std::string jsonString; + serializeJson(doc, jsonString); + + int err = duckInstance->sendData(topics::health, jsonString); if (err != DUCK_ERR_NONE) { duckInstance->counter++; loginfo_ln("[DUCK] health message failed to send."); From d553ad59fe7c809a4170ef4b216cd73aaa600fa9 Mon Sep 17 00:00:00 2001 From: TimoWielink Date: Mon, 15 Jun 2026 20:13:54 +0200 Subject: [PATCH 2/2] fixed after crashing Signed-off-by: TimoWielink --- src/routing/RouteJSON.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/routing/RouteJSON.h b/src/routing/RouteJSON.h index be76f671..dab0dc46 100644 --- a/src/routing/RouteJSON.h +++ b/src/routing/RouteJSON.h @@ -49,11 +49,14 @@ class RouteJSON { } origin = json["origin"].as(); destination = json["destination"].as(); - logdbg_ln("Built RouteJSON from packet data: %s",json.as().c_str()); + const std::string serialized = asString(); + logdbg_ln("Built RouteJSON from packet data: %s", serialized.c_str()); } std::string asString(){ - return json.as(); + std::string out; + serializeJson(json, out); + return out; } std::string convertReqToRep(){ @@ -67,7 +70,7 @@ class RouteJSON { std::string log; serializeJson(json, log); - return json.as(); + return asString(); } Duid getOrigin(){ Duid originDuid; @@ -95,7 +98,7 @@ class RouteJSON { serializeJson(json, log); logdbg_ln("RREQ: %s", log.c_str()); #endif - return json.as(); + return asString(); //add rssi snr } @@ -131,7 +134,7 @@ class RouteJSON { serializeJson(json, log); logdbg_ln("Packet: %s", log.c_str()); - return json.as(); + return asString(); } private: @@ -150,4 +153,4 @@ class RouteJSON { } }; - #endif \ No newline at end of file + #endif