From 9289da1a1950622e19b738973fbcf698e83c483e Mon Sep 17 00:00:00 2001 From: Chad Attermann Date: Sun, 1 Mar 2026 12:45:35 -0700 Subject: [PATCH] Bump to version 0.2.7. --- .../common/lora_interface/LoRaInterface.cpp | 2 +- library.json | 2 +- library.properties | 2 +- src/Identity.cpp | 2 +- src/Link.cpp | 2 +- src/Log.h | 6 +- test/test_transport/test_main.cpp | 98 ++++++++++++------- 7 files changed, 68 insertions(+), 46 deletions(-) diff --git a/examples/common/lora_interface/LoRaInterface.cpp b/examples/common/lora_interface/LoRaInterface.cpp index 89d3c17..4d6f01a 100644 --- a/examples/common/lora_interface/LoRaInterface.cpp +++ b/examples/common/lora_interface/LoRaInterface.cpp @@ -66,7 +66,7 @@ delay(1500); LoRa.setTxPower(power); INFO("LoRa init succeeded."); - TRACEF("LoRa bandwidth is %s Kbps", std::to_string(Utilities::OS::round(_bitrate/1000.0, 2)).c_str()); + TRACEF("LoRa bandwidth is %.2f Kbps", Utilities::OS::round(_bitrate/1000.0, 2)); #endif _online = true; diff --git a/library.json b/library.json index 047c826..4e667c4 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "microReticulum", - "version": "0.2.6", + "version": "0.2.7", "description": "Port of Reticulum Network Stack to C++ specifically but not exclusively targeting 32-bit and better MCUs", "keywords": "reticulum, rns, mesh, embedded, mcu, esp32, nrf52, native", "repository": diff --git a/library.properties b/library.properties index f4f7437..43b13b5 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=microReticulum -version=0.2.6 +version=0.2.7 author=Chad Attermann maintainer=Chad Attermann sentence=Port of Reticulum Network Stack to C++ diff --git a/src/Identity.cpp b/src/Identity.cpp index 03b84f1..0915386 100644 --- a/src/Identity.cpp +++ b/src/Identity.cpp @@ -607,7 +607,7 @@ const Bytes Identity::decrypt(const Bytes& ciphertext_token) const { TRACEF("Identity::decrypt: ciphertext: %s", ciphertext.toHex().c_str()); plaintext = token.decrypt(ciphertext); TRACEF("Identity::decrypt: plaintext: %s", plaintext.toHex().c_str()); - //TRACEF("Identity::decrypt: Token decrypted data of length %s", std::to_string(plaintext.size()).c_str()); + //TRACEF("Identity::decrypt: Token decrypted data of length %zu", plaintext.size()); } catch (std::exception& e) { DEBUGF("Decryption by %s failed: %s", toString().c_str(), e.what()); diff --git a/src/Link.cpp b/src/Link.cpp index fcc8954..4a25699 100644 --- a/src/Link.cpp +++ b/src/Link.cpp @@ -356,7 +356,7 @@ void Link::validate_proof(const Packet& packet) { _object->_activated_at = OS::time(); _object->_last_proof = _object->_activated_at; Transport::activate_link(*this); - VERBOSEF("Link %s established with %s, RTT is %f s", toString().c_str(), _object->_destination.toString().c_str(), OS::round(_object->_rtt, 3)); + VERBOSEF("Link %s established with %s, RTT is %.3f s", toString().c_str(), _object->_destination.toString().c_str(), OS::round(_object->_rtt, 3)); //p if _object->_rtt != None and _object->_establishment_cost != None and _object->_rtt > 0 and _object->_establishment_cost > 0: if (_object->_rtt != 0.0 && _object->_establishment_cost != 0 && _object->_rtt > 0 and _object->_establishment_cost > 0) { diff --git a/src/Log.h b/src/Log.h index 4b9b9eb..34f44c0 100644 --- a/src/Log.h +++ b/src/Log.h @@ -92,11 +92,11 @@ namespace RNS { #endif inline void log(const char* msg, LogLevel level = LOG_NOTICE) { doLog(level, msg); } - //inline void log(const std::string& msg, LogLevel level = LOG_NOTICE) { doLog(level, msg.c_str()); } + inline void log(const std::string& msg, LogLevel level = LOG_NOTICE) { doLog(level, msg.c_str()); } inline void logf(LogLevel level, const char* msg, ...) { va_list vlist; va_start(vlist, msg); doLog(level, msg, vlist); va_end(vlist); } #ifdef ARDUINO - //inline void log(const String& msg, LogLevel level = LOG_NOTICE) { doLog(level, msg.c_str()); } - //inline void log(const StringSumHelper& msg, LogLevel level = LOG_NOTICE) { doLog(level, msg.c_str()); } + inline void log(const String& msg, LogLevel level = LOG_NOTICE) { doLog(level, msg.c_str()); } + inline void log(const StringSumHelper& msg, LogLevel level = LOG_NOTICE) { doLog(level, msg.c_str()); } //inline void log(const __FlashStringHelper* msg, LogLevel level = LOG_NOTICE) { doLog(level, msg); } //inline void logf(LogLevel level, const __FlashStringHelper* msg, ...) { va_list vlist; va_start(vlist, msg); doLog(level, msg, vlist); va_end(vlist); } #endif diff --git a/test/test_transport/test_main.cpp b/test/test_transport/test_main.cpp index 2e4656f..deffe3c 100644 --- a/test/test_transport/test_main.cpp +++ b/test/test_transport/test_main.cpp @@ -399,30 +399,40 @@ void test_incoming_announce_limit() { if ((RNS::Utilities::OS::ltime() - start_time) >= (num_announces * announces_period + 10000)) { break; } - if (announce_count < num_announces && (RNS::Utilities::OS::ltime() - announce_time) >= announces_period) { - printf("***** test_incoming_announce_limit: Sending announce #%d\n", announce_count + 1); - RNS::Identity temp_id(true); - RNS::Destination temp_dest(temp_id, RNS::Type::Destination::IN, - RNS::Type::Destination::SINGLE, "test", "announce"); - temp_dest.set_proof_strategy(RNS::Type::Destination::PROVE_ALL); + try { + if (announce_count < num_announces && (RNS::Utilities::OS::ltime() - announce_time) >= announces_period) { + printf("***** test_incoming_announce_limit: Sending announce #%d\n", announce_count + 1); + RNS::Identity temp_id(true); + RNS::Destination temp_dest(temp_id, RNS::Type::Destination::IN, + RNS::Type::Destination::SINGLE, "test", "announce"); + temp_dest.set_proof_strategy(RNS::Type::Destination::PROVE_ALL); - // Announce - std::string app_data = "test_announce_" + std::to_string(announce_count + 1); - RNS::Packet announce_packet = temp_dest.announce(app_data, false, {RNS::Type::NONE}, {RNS::Type::NONE}, false); - announce_packet.pack(); + // Announce + std::string app_data = "test_announce_" + std::to_string(announce_count + 1); + RNS::Packet announce_packet = temp_dest.announce(app_data, false, {RNS::Type::NONE}, {RNS::Type::NONE}, false); + announce_packet.pack(); - // Must deregister destination so that the ANNOUNCE appears to be from a remote node - RNS::Transport::deregister_destination(temp_dest); + // Must deregister destination so that the ANNOUNCE appears to be from a remote node + RNS::Transport::deregister_destination(temp_dest); - in_interface.handle_incoming(announce_packet.raw()); + in_interface.handle_incoming(announce_packet.raw()); - announce_time = RNS::Utilities::OS::ltime(); - ++announce_count; + announce_time = RNS::Utilities::OS::ltime(); + ++announce_count; + } + test_reticulum.loop(); + if ((RNS::Utilities::OS::ltime() - log_time) >= 5000) { + RNS::Transport::dump_stats(); + log_time = RNS::Utilities::OS::ltime(); + } } - test_reticulum.loop(); - if ((RNS::Utilities::OS::ltime() - log_time) >= 5000) { - RNS::Transport::dump_stats(); - log_time = RNS::Utilities::OS::ltime(); + catch (const std::bad_alloc&) { + ERROR("test_incoming_announce_limit: bad_alloc - out of memory"); + break; + } + catch (const std::exception& e) { + ERRORF("test_incoming_announce_limit: exception: %s", e.what()); + break; } RNS::Utilities::OS::sleep(0.1); } @@ -450,30 +460,40 @@ void test_incoming_announce_over_limit() { if ((RNS::Utilities::OS::ltime() - start_time) >= (num_announces * announces_period + 10000)) { break; } - if (announce_count < num_announces && (RNS::Utilities::OS::ltime() - announce_time) >= announces_period) { - printf("***** test_incoming_announce_over_limit: Sending announce #%d\n", announce_count + 1); - RNS::Identity temp_id(true); - RNS::Destination temp_dest(temp_id, RNS::Type::Destination::IN, - RNS::Type::Destination::SINGLE, "test", "announce"); - temp_dest.set_proof_strategy(RNS::Type::Destination::PROVE_ALL); + try { + if (announce_count < num_announces && (RNS::Utilities::OS::ltime() - announce_time) >= announces_period) { + printf("***** test_incoming_announce_over_limit: Sending announce #%d\n", announce_count + 1); + RNS::Identity temp_id(true); + RNS::Destination temp_dest(temp_id, RNS::Type::Destination::IN, + RNS::Type::Destination::SINGLE, "test", "announce"); + temp_dest.set_proof_strategy(RNS::Type::Destination::PROVE_ALL); - // Announce - std::string app_data = "test_announce_" + std::to_string(announce_count + 1); - RNS::Packet announce_packet = temp_dest.announce(app_data, false, {RNS::Type::NONE}, {RNS::Type::NONE}, false); - announce_packet.pack(); + // Announce + std::string app_data = "test_announce_" + std::to_string(announce_count + 1); + RNS::Packet announce_packet = temp_dest.announce(app_data, false, {RNS::Type::NONE}, {RNS::Type::NONE}, false); + announce_packet.pack(); - // Must deregister destination so that the ANNOUNCE appears to be from a remote node - RNS::Transport::deregister_destination(temp_dest); + // Must deregister destination so that the ANNOUNCE appears to be from a remote node + RNS::Transport::deregister_destination(temp_dest); - in_interface.handle_incoming(announce_packet.raw()); + in_interface.handle_incoming(announce_packet.raw()); - announce_time = RNS::Utilities::OS::ltime(); - ++announce_count; + announce_time = RNS::Utilities::OS::ltime(); + ++announce_count; + } + test_reticulum.loop(); + if ((RNS::Utilities::OS::ltime() - log_time) >= 5000) { + RNS::Transport::dump_stats(); + log_time = RNS::Utilities::OS::ltime(); + } } - test_reticulum.loop(); - if ((RNS::Utilities::OS::ltime() - log_time) >= 5000) { - RNS::Transport::dump_stats(); - log_time = RNS::Utilities::OS::ltime(); + catch (const std::bad_alloc&) { + ERROR("test_incoming_announce_over_limit: bad_alloc - out of memory"); + break; + } + catch (const std::exception& e) { + ERRORF("test_incoming_announce_over_limit: exception: %s", e.what()); + break; } RNS::Utilities::OS::sleep(0.1); } @@ -560,6 +580,7 @@ void tearDown(void) {} int runUnityTests(void) { UNITY_BEGIN(); +/* // Transport receipt lifecycle RUN_TEST(test_receipt_creation_and_culling); RUN_TEST(test_receipt_rapid_fire); @@ -580,6 +601,7 @@ int runUnityTests(void) { RUN_TEST(test_destination_packet_cycle); //RUN_TEST(test_incoming_announce_limit); +*/ RUN_TEST(test_incoming_announce_over_limit); //RUN_TEST(test_incoming_announce_stress);