diff --git a/lib/auto_interface/AutoInterface.cpp b/lib/auto_interface/AutoInterface.cpp index a438c0de..4354f2ef 100644 --- a/lib/auto_interface/AutoInterface.cpp +++ b/lib/auto_interface/AutoInterface.cpp @@ -1,6 +1,6 @@ #include "AutoInterface.h" -#include "Log.h" -#include "Utilities/OS.h" +#include +#include #include #include @@ -290,17 +290,17 @@ void AutoInterface::loop() { } } -void AutoInterface::send_outgoing(const Bytes& data) { +bool AutoInterface::send_outgoing(const Bytes& data) { DEBUG(toString() + ".send_outgoing: data: " + data.toHex()); - if (!_online) return; + if (!_online) return false; #ifdef ARDUINO // ESP32: Send to all known peers via unicast using persistent raw IPv6 socket // (WiFiUDP doesn't support IPv6) if (_data_socket < 0) { WARNING("AutoInterface: Data socket not ready, cannot send"); - return; + return false; } for (const auto& peer : _peers) { @@ -330,6 +330,7 @@ void AutoInterface::send_outgoing(const Bytes& data) { // Perform post-send housekeeping InterfaceImpl::handle_outgoing(data); + return true; #else // POSIX: Send to all known peers via unicast for (const auto& peer : _peers) { @@ -354,6 +355,7 @@ void AutoInterface::send_outgoing(const Bytes& data) { // Perform post-send housekeeping InterfaceImpl::handle_outgoing(data); + return true; #endif } diff --git a/lib/auto_interface/AutoInterface.h b/lib/auto_interface/AutoInterface.h index 48b283fe..221bcb0c 100644 --- a/lib/auto_interface/AutoInterface.h +++ b/lib/auto_interface/AutoInterface.h @@ -1,9 +1,9 @@ #pragma once -#include "Interface.h" -#include "Identity.h" -#include "Bytes.h" -#include "Type.h" +#include +#include +#include +#include #include "AutoInterfacePeer.h" #ifdef ARDUINO @@ -81,7 +81,7 @@ public: bool is_timed_out() const { return _timed_out; } protected: - virtual void send_outgoing(const RNS::Bytes& data) override; + virtual bool send_outgoing(const RNS::Bytes& data) override; private: // Discovery and addressing diff --git a/lib/ble_interface/BLEFragmenter.cpp b/lib/ble_interface/BLEFragmenter.cpp index d45682c0..cbd7b8a5 100644 --- a/lib/ble_interface/BLEFragmenter.cpp +++ b/lib/ble_interface/BLEFragmenter.cpp @@ -4,7 +4,7 @@ */ #include "BLEFragmenter.h" -#include "Log.h" +#include namespace RNS { namespace BLE { diff --git a/lib/ble_interface/BLEFragmenter.h b/lib/ble_interface/BLEFragmenter.h index ffdc9a40..285c4c89 100644 --- a/lib/ble_interface/BLEFragmenter.h +++ b/lib/ble_interface/BLEFragmenter.h @@ -15,7 +15,7 @@ #pragma once #include "BLETypes.h" -#include "Bytes.h" +#include #include #include diff --git a/lib/ble_interface/BLEIdentityManager.cpp b/lib/ble_interface/BLEIdentityManager.cpp index efefc31f..70a375a2 100644 --- a/lib/ble_interface/BLEIdentityManager.cpp +++ b/lib/ble_interface/BLEIdentityManager.cpp @@ -6,7 +6,7 @@ */ #include "BLEIdentityManager.h" -#include "Log.h" +#include namespace RNS { namespace BLE { diff --git a/lib/ble_interface/BLEIdentityManager.h b/lib/ble_interface/BLEIdentityManager.h index 1694c33f..7cf2bb76 100644 --- a/lib/ble_interface/BLEIdentityManager.h +++ b/lib/ble_interface/BLEIdentityManager.h @@ -18,8 +18,8 @@ #pragma once #include "BLETypes.h" -#include "Bytes.h" -#include "Utilities/OS.h" +#include +#include #include #include diff --git a/lib/ble_interface/BLEInterface.cpp b/lib/ble_interface/BLEInterface.cpp index 31ddee4e..293eaefa 100644 --- a/lib/ble_interface/BLEInterface.cpp +++ b/lib/ble_interface/BLEInterface.cpp @@ -4,8 +4,8 @@ */ #include "BLEInterface.h" -#include "Log.h" -#include "Utilities/OS.h" +#include +#include #ifdef ARDUINO #include @@ -311,9 +311,9 @@ void BLEInterface::loop() { // Data Transfer //============================================================================= -void BLEInterface::send_outgoing(const Bytes& data) { +bool BLEInterface::send_outgoing(const Bytes& data) { if (!_platform || !_platform->isRunning()) { - return; + return false; } // Non-blocking lock: if BLE task holds _mutex (maintenance, connect, etc.), @@ -321,7 +321,7 @@ void BLEInterface::send_outgoing(const Bytes& data) { // retransmission at the transport layer. if (!_mutex.try_lock()) { TRACE("BLEInterface: send_outgoing skipped - BLE task busy"); - return; + return false; } std::lock_guard lock(_mutex, std::adopt_lock); @@ -330,7 +330,7 @@ void BLEInterface::send_outgoing(const Bytes& data) { if (connected_peers.empty()) { TRACE("BLEInterface: No connected peers, dropping packet"); - return; + return false; } // Count peers with identity @@ -352,6 +352,7 @@ void BLEInterface::send_outgoing(const Bytes& data) { // Track outgoing stats handle_outgoing(data); + return true; } bool BLEInterface::sendToPeer(const Bytes& peer_identity, const Bytes& data) { diff --git a/lib/ble_interface/BLEInterface.h b/lib/ble_interface/BLEInterface.h index 35397a17..421251b3 100644 --- a/lib/ble_interface/BLEInterface.h +++ b/lib/ble_interface/BLEInterface.h @@ -16,9 +16,9 @@ */ #pragma once -#include "Interface.h" -#include "Bytes.h" -#include "Type.h" +#include +#include +#include #include "BLETypes.h" #include "BLEPlatform.h" #include "BLEFragmenter.h" @@ -166,7 +166,7 @@ public: bool is_task_running() const { return _task_handle != nullptr; } protected: - virtual void send_outgoing(const RNS::Bytes& data) override; + virtual bool send_outgoing(const RNS::Bytes& data) override; private: //========================================================================= diff --git a/lib/ble_interface/BLEOperationQueue.cpp b/lib/ble_interface/BLEOperationQueue.cpp index 60f5793b..fd9d6ee8 100644 --- a/lib/ble_interface/BLEOperationQueue.cpp +++ b/lib/ble_interface/BLEOperationQueue.cpp @@ -4,7 +4,7 @@ */ #include "BLEOperationQueue.h" -#include "Log.h" +#include namespace RNS { namespace BLE { diff --git a/lib/ble_interface/BLEOperationQueue.h b/lib/ble_interface/BLEOperationQueue.h index 8fd73645..cd4c9e74 100644 --- a/lib/ble_interface/BLEOperationQueue.h +++ b/lib/ble_interface/BLEOperationQueue.h @@ -13,8 +13,8 @@ #pragma once #include "BLETypes.h" -#include "Bytes.h" -#include "Utilities/OS.h" +#include +#include #include #include diff --git a/lib/ble_interface/BLEPeerManager.cpp b/lib/ble_interface/BLEPeerManager.cpp index 5e1eed6f..091da587 100644 --- a/lib/ble_interface/BLEPeerManager.cpp +++ b/lib/ble_interface/BLEPeerManager.cpp @@ -6,7 +6,7 @@ */ #include "BLEPeerManager.h" -#include "Log.h" +#include #include #include diff --git a/lib/ble_interface/BLEPeerManager.h b/lib/ble_interface/BLEPeerManager.h index 10e5feb6..22016803 100644 --- a/lib/ble_interface/BLEPeerManager.h +++ b/lib/ble_interface/BLEPeerManager.h @@ -13,8 +13,8 @@ #pragma once #include "BLETypes.h" -#include "Bytes.h" -#include "Utilities/OS.h" +#include +#include #include diff --git a/lib/ble_interface/BLEPlatform.cpp b/lib/ble_interface/BLEPlatform.cpp index 1e2a0f6c..ea7f41b0 100644 --- a/lib/ble_interface/BLEPlatform.cpp +++ b/lib/ble_interface/BLEPlatform.cpp @@ -4,7 +4,7 @@ */ #include "BLEPlatform.h" -#include "Log.h" +#include // Include platform implementations based on compile-time detection #if defined(ESP32) && (defined(USE_NIMBLE) || defined(CONFIG_BT_NIMBLE_ENABLED)) diff --git a/lib/ble_interface/BLEPlatform.h b/lib/ble_interface/BLEPlatform.h index 85bc357e..86e6df17 100644 --- a/lib/ble_interface/BLEPlatform.h +++ b/lib/ble_interface/BLEPlatform.h @@ -16,7 +16,7 @@ #pragma once #include "BLETypes.h" -#include "Bytes.h" +#include #include #include diff --git a/lib/ble_interface/BLEReassembler.cpp b/lib/ble_interface/BLEReassembler.cpp index 53c7a059..bd94f87a 100644 --- a/lib/ble_interface/BLEReassembler.cpp +++ b/lib/ble_interface/BLEReassembler.cpp @@ -6,7 +6,7 @@ */ #include "BLEReassembler.h" -#include "Log.h" +#include namespace RNS { namespace BLE { diff --git a/lib/ble_interface/BLEReassembler.h b/lib/ble_interface/BLEReassembler.h index f4116313..fecfe662 100644 --- a/lib/ble_interface/BLEReassembler.h +++ b/lib/ble_interface/BLEReassembler.h @@ -16,8 +16,8 @@ #include "BLETypes.h" #include "BLEFragmenter.h" -#include "Bytes.h" -#include "Utilities/OS.h" +#include +#include #include #include diff --git a/lib/ble_interface/BLETypes.h b/lib/ble_interface/BLETypes.h index 8f23ad62..9907ddfe 100644 --- a/lib/ble_interface/BLETypes.h +++ b/lib/ble_interface/BLETypes.h @@ -8,8 +8,8 @@ */ #pragma once -#include "Bytes.h" -#include "Log.h" +#include +#include #include #include diff --git a/lib/ble_interface/platforms/NimBLEPlatform.cpp b/lib/ble_interface/platforms/NimBLEPlatform.cpp index b8240f91..8088606a 100644 --- a/lib/ble_interface/platforms/NimBLEPlatform.cpp +++ b/lib/ble_interface/platforms/NimBLEPlatform.cpp @@ -7,8 +7,8 @@ #if defined(ESP32) && (defined(USE_NIMBLE) || defined(CONFIG_BT_NIMBLE_ENABLED)) -#include "Log.h" -#include "Identity.h" +#include +#include #include #include diff --git a/lib/microreticulum-shim/BytesPool.h b/lib/microreticulum-shim/BytesPool.h index 4ff7be6f..a83a1de2 100644 --- a/lib/microreticulum-shim/BytesPool.h +++ b/lib/microreticulum-shim/BytesPool.h @@ -36,7 +36,7 @@ */ #include "PSRAMAllocator.h" -#include "Log.h" +#include #include #include diff --git a/lib/microreticulum-shim/Cryptography/BZ2.cpp b/lib/microreticulum-shim/Cryptography/BZ2.cpp deleted file mode 100644 index 718429e9..00000000 --- a/lib/microreticulum-shim/Cryptography/BZ2.cpp +++ /dev/null @@ -1,179 +0,0 @@ -#include "BZ2.h" - -#if defined(NATIVE) -#include -#elif defined(ARDUINO) -#include "bzlib.h" -#endif - -#include -#include -#include - -#ifdef ARDUINO -#include -#endif - -namespace RNS { namespace Cryptography { - -const Bytes bz2_decompress(const Bytes& data) { -#if defined(NATIVE) || defined(ARDUINO) - if (data.empty()) { - return Bytes(); - } - -#ifdef ARDUINO - // ESP32: Use smaller buffers to fit in memory, grow if needed - // Start with 64KB and grow up to 512KB max - const size_t MIN_OUTPUT_SIZE = 64 * 1024; // 64KB initial - const size_t MAX_OUTPUT_SIZE = 512 * 1024; // 512KB max -#else - // Native: Use larger buffers for efficiency - const size_t MIN_OUTPUT_SIZE = 2 * 1024 * 1024; // 2MB minimum - const size_t MAX_OUTPUT_SIZE = 16 * 1024 * 1024; // 16MB max -#endif - size_t output_size = std::min(std::max(data.size() * 100, MIN_OUTPUT_SIZE), MAX_OUTPUT_SIZE); - -#ifdef ARDUINO - // Allocate from PSRAM if available - char* output = (char*)heap_caps_malloc(output_size, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT); - if (!output) { - // Fall back to regular heap - output = (char*)malloc(output_size); - } - if (!output) { - ERROR("bz2_decompress: Failed to allocate output buffer"); - return Bytes(); - } -#else - std::vector output_vec(output_size); - char* output = output_vec.data(); -#endif - - bz_stream stream; - memset(&stream, 0, sizeof(stream)); - - int ret = BZ2_bzDecompressInit(&stream, 0, 0); - if (ret != BZ_OK) { -#ifdef ARDUINO - free(output); -#endif - return Bytes(); - } - - stream.next_in = const_cast(reinterpret_cast(data.data())); - stream.avail_in = data.size(); - stream.next_out = output; - stream.avail_out = output_size; - - Bytes result; - int iteration = 0; - do { - ret = BZ2_bzDecompress(&stream); - iteration++; - - if (ret == BZ_OK || ret == BZ_STREAM_END) { - // Append decompressed data - size_t decompressed = output_size - stream.avail_out; - result.append(reinterpret_cast(output), decompressed); - - DEBUGF("bz2_decompress: iter=%d, ret=%d, decompressed=%zu, total=%zu, avail_in=%u", - iteration, ret, decompressed, result.size(), stream.avail_in); - - if (ret == BZ_STREAM_END) { - break; - } - - // Reset output buffer for more data - stream.next_out = output; - stream.avail_out = output_size; - } else { - DEBUGF("bz2_decompress: iter=%d, FAILED ret=%d", iteration, ret); - BZ2_bzDecompressEnd(&stream); -#ifdef ARDUINO - free(output); -#endif - return Bytes(); - } - } while (stream.avail_in > 0 || ret != BZ_STREAM_END); - - BZ2_bzDecompressEnd(&stream); -#ifdef ARDUINO - free(output); -#endif - DEBUGF("bz2_decompress: final output size=%zu", result.size()); - return result; -#else - ERROR("bz2_decompress: BZ2 support not available on this platform"); - return Bytes(); -#endif -} - -const Bytes bz2_compress(const Bytes& data) { -#if defined(NATIVE) || defined(ARDUINO) - if (data.empty()) { - return Bytes(); - } - - // Compressed size is at most input size + 1% + 600 bytes - size_t output_size = data.size() + data.size() / 100 + 600; - -#ifdef ARDUINO - // Allocate from PSRAM if available - char* output = (char*)heap_caps_malloc(output_size, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT); - if (!output) { - output = (char*)malloc(output_size); - } - if (!output) { - ERROR("bz2_compress: Failed to allocate output buffer"); - return Bytes(); - } - // Use smaller block size (1 = 100k) on ESP32 to reduce memory usage - const int block_size = 1; -#else - std::vector output_vec(output_size); - char* output = output_vec.data(); - // Use largest block size (9 = 900k) on native for best compression - const int block_size = 9; -#endif - - bz_stream stream; - memset(&stream, 0, sizeof(stream)); - - int ret = BZ2_bzCompressInit(&stream, block_size, 0, 0); - if (ret != BZ_OK) { -#ifdef ARDUINO - free(output); -#endif - return Bytes(); - } - - stream.next_in = const_cast(reinterpret_cast(data.data())); - stream.avail_in = data.size(); - stream.next_out = output; - stream.avail_out = output_size; - - ret = BZ2_bzCompress(&stream, BZ_FINISH); - if (ret != BZ_STREAM_END) { - BZ2_bzCompressEnd(&stream); -#ifdef ARDUINO - free(output); -#endif - return Bytes(); - } - - size_t compressed_size = output_size - stream.avail_out; - BZ2_bzCompressEnd(&stream); - - Bytes result(reinterpret_cast(output), compressed_size); -#ifdef ARDUINO - free(output); -#endif - return result; -#else - ERROR("bz2_compress: BZ2 support not available on this platform"); - return Bytes(); -#endif -} - -} } diff --git a/lib/microreticulum-shim/Cryptography/BZ2.h b/lib/microreticulum-shim/Cryptography/BZ2.h deleted file mode 100644 index 2050d594..00000000 --- a/lib/microreticulum-shim/Cryptography/BZ2.h +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once - -#include - -namespace RNS { namespace Cryptography { - - const Bytes bz2_decompress(const Bytes& data); - const Bytes bz2_compress(const Bytes& data); - -} } diff --git a/lib/microreticulum-shim/Display.cpp b/lib/microreticulum-shim/Display.cpp index c2141eb6..5c2e9f5e 100644 --- a/lib/microreticulum-shim/Display.cpp +++ b/lib/microreticulum-shim/Display.cpp @@ -7,12 +7,12 @@ #ifdef HAS_DISPLAY #include "DisplayGraphics.h" -#include "Identity.h" -#include "Interface.h" -#include "Reticulum.h" -#include "Transport.h" -#include "Log.h" -#include "Utilities/OS.h" +#include +#include +#include +#include +#include +#include // Display library includes (board-specific) #ifdef ARDUINO diff --git a/lib/microreticulum-shim/Display.h b/lib/microreticulum-shim/Display.h index 644caf2e..5d69b255 100644 --- a/lib/microreticulum-shim/Display.h +++ b/lib/microreticulum-shim/Display.h @@ -7,8 +7,8 @@ #pragma once -#include "Type.h" -#include "Bytes.h" +#include +#include #include #include diff --git a/lib/microreticulum-shim/FileStream.h b/lib/microreticulum-shim/FileStream.h index 6b69d655..f2962d0c 100644 --- a/lib/microreticulum-shim/FileStream.h +++ b/lib/microreticulum-shim/FileStream.h @@ -1,9 +1,9 @@ #pragma once -#include "Utilities/Crc.h" -#include "Log.h" -#include "Bytes.h" -#include "Type.h" +#include +#include +#include +#include #ifdef ARDUINO #include diff --git a/lib/microreticulum-shim/FileSystem.h b/lib/microreticulum-shim/FileSystem.h index f224420b..1a75c3db 100644 --- a/lib/microreticulum-shim/FileSystem.h +++ b/lib/microreticulum-shim/FileSystem.h @@ -1,9 +1,9 @@ #pragma once #include "FileStream.h" -#include "Log.h" -#include "Bytes.h" -#include "Type.h" +#include +#include +#include #include #include diff --git a/lib/microreticulum-shim/Instrumentation/BootProfiler.cpp b/lib/microreticulum-shim/Instrumentation/BootProfiler.cpp index de2c2a4a..0eb289a8 100644 --- a/lib/microreticulum-shim/Instrumentation/BootProfiler.cpp +++ b/lib/microreticulum-shim/Instrumentation/BootProfiler.cpp @@ -15,7 +15,7 @@ #ifdef BOOT_PROFILING_ENABLED -#include +#include #include #include diff --git a/lib/microreticulum-shim/Instrumentation/MemoryMonitor.cpp b/lib/microreticulum-shim/Instrumentation/MemoryMonitor.cpp index 3990d9b4..79cf0e98 100644 --- a/lib/microreticulum-shim/Instrumentation/MemoryMonitor.cpp +++ b/lib/microreticulum-shim/Instrumentation/MemoryMonitor.cpp @@ -15,7 +15,7 @@ #ifdef MEMORY_INSTRUMENTATION_ENABLED -#include +#include #include #include diff --git a/lib/microreticulum-shim/MessageBase.h b/lib/microreticulum-shim/MessageBase.h index 8b5c91d7..0e3fb596 100644 --- a/lib/microreticulum-shim/MessageBase.h +++ b/lib/microreticulum-shim/MessageBase.h @@ -3,7 +3,7 @@ #ifndef RNS_MESSAGE_BASE_H #define RNS_MESSAGE_BASE_H -#include "Bytes.h" +#include namespace RNS { diff --git a/lib/sx1262_interface/SX1262Interface.cpp b/lib/sx1262_interface/SX1262Interface.cpp index c82b06aa..01ab71cd 100644 --- a/lib/sx1262_interface/SX1262Interface.cpp +++ b/lib/sx1262_interface/SX1262Interface.cpp @@ -2,8 +2,8 @@ // SPDX-License-Identifier: MIT #include "SX1262Interface.h" -#include "Log.h" -#include "Utilities/OS.h" +#include +#include #ifdef ARDUINO #include @@ -239,11 +239,11 @@ void SX1262Interface::loop() { #endif } -void SX1262Interface::send_outgoing(const Bytes& data) { - if (!_online) return; +bool SX1262Interface::send_outgoing(const Bytes& data) { + if (!_online) return false; #ifdef ARDUINO - if (_radio == nullptr) return; + if (_radio == nullptr) return false; DEBUG(toString() + ": Sending " + std::to_string(data.size()) + " bytes"); @@ -254,7 +254,7 @@ void SX1262Interface::send_outgoing(const Bytes& data) { size_t len = 1 + data.size(); if (len > HW_MTU) { ERROR("SX1262Interface: Packet too large (" + std::to_string(len) + " > " + std::to_string(HW_MTU) + ")"); - return; + return false; } uint8_t* buf = new uint8_t[len]; @@ -265,7 +265,7 @@ void SX1262Interface::send_outgoing(const Bytes& data) { if (xSemaphoreTake(_spi_mutex, pdMS_TO_TICKS(1000)) != pdTRUE) { ERROR("SX1262Interface: Failed to acquire SPI mutex for TX"); delete[] buf; - return; + return false; } _transmitting = true; @@ -289,10 +289,13 @@ void SX1262Interface::send_outgoing(const Bytes& data) { DEBUG("SX1262Interface: Sent " + std::to_string(len) + " bytes"); // Perform post-send housekeeping InterfaceImpl::handle_outgoing(data); + return true; } else { ERROR("SX1262Interface: Transmit failed, code " + std::to_string(state)); + return false; } #endif + return false; } void SX1262Interface::on_incoming(const Bytes& data) { diff --git a/lib/sx1262_interface/SX1262Interface.h b/lib/sx1262_interface/SX1262Interface.h index ee800fb3..cd9b9397 100644 --- a/lib/sx1262_interface/SX1262Interface.h +++ b/lib/sx1262_interface/SX1262Interface.h @@ -3,10 +3,10 @@ #pragma once -#include "Interface.h" -#include "Bytes.h" -#include "Type.h" -#include "Cryptography/Random.h" +#include +#include +#include +#include #ifdef ARDUINO #include @@ -81,7 +81,7 @@ public: virtual std::string toString() const override; protected: - virtual void send_outgoing(const RNS::Bytes& data) override; + virtual bool send_outgoing(const RNS::Bytes& data) override; private: void on_incoming(const RNS::Bytes& data); diff --git a/lib/tdeck_ui/Display.cpp b/lib/tdeck_ui/Display.cpp index c2141eb6..5c2e9f5e 100644 --- a/lib/tdeck_ui/Display.cpp +++ b/lib/tdeck_ui/Display.cpp @@ -7,12 +7,12 @@ #ifdef HAS_DISPLAY #include "DisplayGraphics.h" -#include "Identity.h" -#include "Interface.h" -#include "Reticulum.h" -#include "Transport.h" -#include "Log.h" -#include "Utilities/OS.h" +#include +#include +#include +#include +#include +#include // Display library includes (board-specific) #ifdef ARDUINO diff --git a/lib/tdeck_ui/Display.h b/lib/tdeck_ui/Display.h index 644caf2e..5d69b255 100644 --- a/lib/tdeck_ui/Display.h +++ b/lib/tdeck_ui/Display.h @@ -7,8 +7,8 @@ #pragma once -#include "Type.h" -#include "Bytes.h" +#include +#include #include #include diff --git a/lib/tdeck_ui/Hardware/TDeck/Display.cpp b/lib/tdeck_ui/Hardware/TDeck/Display.cpp index 8c463b78..dccf4297 100644 --- a/lib/tdeck_ui/Hardware/TDeck/Display.cpp +++ b/lib/tdeck_ui/Hardware/TDeck/Display.cpp @@ -6,7 +6,7 @@ #ifdef ARDUINO -#include "Log.h" +#include #include #if __has_include("SplashImage.h") diff --git a/lib/tdeck_ui/Hardware/TDeck/Keyboard.cpp b/lib/tdeck_ui/Hardware/TDeck/Keyboard.cpp index a409e1a8..07ce4edc 100644 --- a/lib/tdeck_ui/Hardware/TDeck/Keyboard.cpp +++ b/lib/tdeck_ui/Hardware/TDeck/Keyboard.cpp @@ -5,7 +5,7 @@ #ifdef ARDUINO -#include "Log.h" +#include using namespace RNS; diff --git a/lib/tdeck_ui/Hardware/TDeck/SDAccess.cpp b/lib/tdeck_ui/Hardware/TDeck/SDAccess.cpp index 9e1cb029..f0498e15 100644 --- a/lib/tdeck_ui/Hardware/TDeck/SDAccess.cpp +++ b/lib/tdeck_ui/Hardware/TDeck/SDAccess.cpp @@ -5,7 +5,7 @@ #ifdef ARDUINO -#include +#include using namespace RNS; diff --git a/lib/tdeck_ui/Hardware/TDeck/SDArchiveFileSystem.h b/lib/tdeck_ui/Hardware/TDeck/SDArchiveFileSystem.h index 00527e94..c3693a87 100644 --- a/lib/tdeck_ui/Hardware/TDeck/SDArchiveFileSystem.h +++ b/lib/tdeck_ui/Hardware/TDeck/SDArchiveFileSystem.h @@ -124,7 +124,7 @@ public: virtual ~FileSystemImpl() {} // SD is already mounted by SDAccess::init() — we don't re-mount. - virtual bool init() override { return SDAccess::is_ready(); } + virtual bool init(bool reformatOnFail = true) override { return SDAccess::is_ready(); } virtual bool format() override { return false; } virtual microStore::File open(const char* path, microStore::File::Mode mode, diff --git a/lib/tdeck_ui/Hardware/TDeck/SDLogger.h b/lib/tdeck_ui/Hardware/TDeck/SDLogger.h index 9b76d38d..e58ca5ab 100644 --- a/lib/tdeck_ui/Hardware/TDeck/SDLogger.h +++ b/lib/tdeck_ui/Hardware/TDeck/SDLogger.h @@ -6,7 +6,7 @@ #include "Config.h" #include "SDAccess.h" -#include +#include #ifdef ARDUINO #include diff --git a/lib/tdeck_ui/Hardware/TDeck/Touch.cpp b/lib/tdeck_ui/Hardware/TDeck/Touch.cpp index f7bf0294..ec838f44 100644 --- a/lib/tdeck_ui/Hardware/TDeck/Touch.cpp +++ b/lib/tdeck_ui/Hardware/TDeck/Touch.cpp @@ -5,7 +5,7 @@ #ifdef ARDUINO -#include "Log.h" +#include using namespace RNS; diff --git a/lib/tdeck_ui/Hardware/TDeck/Trackball.cpp b/lib/tdeck_ui/Hardware/TDeck/Trackball.cpp index 0f696d2e..21c16730 100644 --- a/lib/tdeck_ui/Hardware/TDeck/Trackball.cpp +++ b/lib/tdeck_ui/Hardware/TDeck/Trackball.cpp @@ -5,7 +5,7 @@ #ifdef ARDUINO -#include "Log.h" +#include #include using namespace RNS; diff --git a/lib/tdeck_ui/UI/LVGL/LVGLInit.cpp b/lib/tdeck_ui/UI/LVGL/LVGLInit.cpp index 2ee429bd..75e09ef6 100644 --- a/lib/tdeck_ui/UI/LVGL/LVGLInit.cpp +++ b/lib/tdeck_ui/UI/LVGL/LVGLInit.cpp @@ -7,7 +7,7 @@ #include "esp_task_wdt.h" -#include "Log.h" +#include #include "../../Hardware/TDeck/Display.h" #include "../../Hardware/TDeck/Keyboard.h" #include "../../Hardware/TDeck/Touch.h" diff --git a/lib/tdeck_ui/UI/LXMF/AnnounceListScreen.cpp b/lib/tdeck_ui/UI/LXMF/AnnounceListScreen.cpp index e80d4ebe..ea7064e8 100644 --- a/lib/tdeck_ui/UI/LXMF/AnnounceListScreen.cpp +++ b/lib/tdeck_ui/UI/LXMF/AnnounceListScreen.cpp @@ -6,13 +6,13 @@ #ifdef ARDUINO -#include "Log.h" +#include #include "../LVGL/LVGLLock.h" -#include "Transport.h" -#include "Identity.h" -#include "Destination.h" -#include "Persistence/DestinationEntry.h" // RNS::Persistence::DestinationEntry (post-graft path) -#include "Utilities/OS.h" +#include +#include +#include +#include // RNS::Persistence::DestinationEntry (post-graft path) +#include #include "../LVGL/LVGLInit.h" #include @@ -141,7 +141,7 @@ void AnnounceListScreen::refresh() { // Get path table from Transport. Pre-graft the fork called this // get_destination_table(); upstream microReticulum @ 0.3.0 renamed it // to get_path_table() (the same map of dest_hash → DestinationEntry). - const auto& dest_table = Transport::get_path_table(); + const auto& dest_table = Transport::path_table(); // Compute name_hash for lxmf.delivery to filter announces Bytes lxmf_delivery_name_hash = Destination::name_hash("lxmf", "delivery"); diff --git a/lib/tdeck_ui/UI/LXMF/AnnounceListScreen.h b/lib/tdeck_ui/UI/LXMF/AnnounceListScreen.h index 41e7ee90..fc0843ea 100644 --- a/lib/tdeck_ui/UI/LXMF/AnnounceListScreen.h +++ b/lib/tdeck_ui/UI/LXMF/AnnounceListScreen.h @@ -10,7 +10,7 @@ #include #include #include -#include "Bytes.h" +#include namespace UI { namespace LXMF { diff --git a/lib/tdeck_ui/UI/LXMF/CallScreen.h b/lib/tdeck_ui/UI/LXMF/CallScreen.h index 6a0572de..547a761d 100644 --- a/lib/tdeck_ui/UI/LXMF/CallScreen.h +++ b/lib/tdeck_ui/UI/LXMF/CallScreen.h @@ -8,7 +8,7 @@ #include #include #include -#include "Bytes.h" +#include namespace UI { namespace LXMF { diff --git a/lib/tdeck_ui/UI/LXMF/ChatScreen.cpp b/lib/tdeck_ui/UI/LXMF/ChatScreen.cpp index 8cc41ba0..d53d863f 100644 --- a/lib/tdeck_ui/UI/LXMF/ChatScreen.cpp +++ b/lib/tdeck_ui/UI/LXMF/ChatScreen.cpp @@ -6,8 +6,8 @@ #ifdef ARDUINO -#include "Log.h" -#include "Identity.h" +#include +#include #include "../LVGL/LVGLInit.h" #include "../LVGL/LVGLLock.h" #include "../Clipboard.h" diff --git a/lib/tdeck_ui/UI/LXMF/ChatScreen.h b/lib/tdeck_ui/UI/LXMF/ChatScreen.h index 41d1c16e..a28d39e5 100644 --- a/lib/tdeck_ui/UI/LXMF/ChatScreen.h +++ b/lib/tdeck_ui/UI/LXMF/ChatScreen.h @@ -11,7 +11,7 @@ #include #include #include -#include "Bytes.h" +#include #include "LXMF/LXMessage.h" #include "LXMF/MessageStore.h" diff --git a/lib/tdeck_ui/UI/LXMF/ComposeScreen.cpp b/lib/tdeck_ui/UI/LXMF/ComposeScreen.cpp index b4c68499..fb3bf2c0 100644 --- a/lib/tdeck_ui/UI/LXMF/ComposeScreen.cpp +++ b/lib/tdeck_ui/UI/LXMF/ComposeScreen.cpp @@ -6,7 +6,7 @@ #ifdef ARDUINO -#include "Log.h" +#include #include "../LVGL/LVGLLock.h" #include "../LVGL/LVGLInit.h" #include "../TextAreaHelper.h" diff --git a/lib/tdeck_ui/UI/LXMF/ComposeScreen.h b/lib/tdeck_ui/UI/LXMF/ComposeScreen.h index 713d16ec..8c37277e 100644 --- a/lib/tdeck_ui/UI/LXMF/ComposeScreen.h +++ b/lib/tdeck_ui/UI/LXMF/ComposeScreen.h @@ -8,7 +8,7 @@ #include #include #include -#include "Bytes.h" +#include namespace UI { namespace LXMF { diff --git a/lib/tdeck_ui/UI/LXMF/ConversationListScreen.cpp b/lib/tdeck_ui/UI/LXMF/ConversationListScreen.cpp index e0cef3cf..6fb7adf3 100644 --- a/lib/tdeck_ui/UI/LXMF/ConversationListScreen.cpp +++ b/lib/tdeck_ui/UI/LXMF/ConversationListScreen.cpp @@ -6,9 +6,9 @@ #ifdef ARDUINO #include "Theme.h" -#include "Log.h" -#include "Identity.h" -#include "Utilities/OS.h" +#include +#include +#include #include "../../Hardware/TDeck/Config.h" #include "../LVGL/LVGLInit.h" #include "../LVGL/LVGLLock.h" diff --git a/lib/tdeck_ui/UI/LXMF/ConversationListScreen.h b/lib/tdeck_ui/UI/LXMF/ConversationListScreen.h index 29f88ec9..d9b1b431 100644 --- a/lib/tdeck_ui/UI/LXMF/ConversationListScreen.h +++ b/lib/tdeck_ui/UI/LXMF/ConversationListScreen.h @@ -11,9 +11,9 @@ #include #include #include -#include "Bytes.h" +#include #include "LXMF/MessageStore.h" -#include "Interface.h" +#include // TinyGPS++ pulled in for TinyGPSCustom (the in-view-satellites parser // hook; declared as a member below). The forward decl on TinyGPSPlus diff --git a/lib/tdeck_ui/UI/LXMF/PropagationNodesScreen.cpp b/lib/tdeck_ui/UI/LXMF/PropagationNodesScreen.cpp index 2f22c523..a72eb3cf 100644 --- a/lib/tdeck_ui/UI/LXMF/PropagationNodesScreen.cpp +++ b/lib/tdeck_ui/UI/LXMF/PropagationNodesScreen.cpp @@ -6,9 +6,9 @@ #ifdef ARDUINO -#include "Log.h" +#include #include "LXMF/PropagationNodeManager.h" -#include "Utilities/OS.h" +#include #include "../LVGL/LVGLInit.h" #include "../LVGL/LVGLLock.h" #include "../TextAreaHelper.h" diff --git a/lib/tdeck_ui/UI/LXMF/PropagationNodesScreen.h b/lib/tdeck_ui/UI/LXMF/PropagationNodesScreen.h index 15a34ee9..70a913d7 100644 --- a/lib/tdeck_ui/UI/LXMF/PropagationNodesScreen.h +++ b/lib/tdeck_ui/UI/LXMF/PropagationNodesScreen.h @@ -9,7 +9,7 @@ #include #include #include -#include "Bytes.h" +#include namespace LXMF { class PropagationNodeManager; diff --git a/lib/tdeck_ui/UI/LXMF/QRScreen.cpp b/lib/tdeck_ui/UI/LXMF/QRScreen.cpp index 2ad36905..f9f13594 100644 --- a/lib/tdeck_ui/UI/LXMF/QRScreen.cpp +++ b/lib/tdeck_ui/UI/LXMF/QRScreen.cpp @@ -5,7 +5,7 @@ #ifdef ARDUINO -#include "Log.h" +#include #include "../LVGL/LVGLInit.h" #include "../LVGL/LVGLLock.h" diff --git a/lib/tdeck_ui/UI/LXMF/QRScreen.h b/lib/tdeck_ui/UI/LXMF/QRScreen.h index c12d5756..fee31b98 100644 --- a/lib/tdeck_ui/UI/LXMF/QRScreen.h +++ b/lib/tdeck_ui/UI/LXMF/QRScreen.h @@ -8,8 +8,8 @@ #include #include #include -#include "Bytes.h" -#include "Identity.h" +#include +#include namespace UI { namespace LXMF { diff --git a/lib/tdeck_ui/UI/LXMF/SettingsScreen.cpp b/lib/tdeck_ui/UI/LXMF/SettingsScreen.cpp index 32a6e179..7db717c8 100644 --- a/lib/tdeck_ui/UI/LXMF/SettingsScreen.cpp +++ b/lib/tdeck_ui/UI/LXMF/SettingsScreen.cpp @@ -10,8 +10,8 @@ #include "../LVGL/LVGLLock.h" #include #include -#include "Log.h" -#include "Utilities/OS.h" +#include +#include #include "../LVGL/LVGLInit.h" #include "../TextAreaHelper.h" diff --git a/lib/tdeck_ui/UI/LXMF/SettingsScreen.h b/lib/tdeck_ui/UI/LXMF/SettingsScreen.h index 52517ab8..db96ab1d 100644 --- a/lib/tdeck_ui/UI/LXMF/SettingsScreen.h +++ b/lib/tdeck_ui/UI/LXMF/SettingsScreen.h @@ -9,8 +9,8 @@ #include #include #include -#include "Bytes.h" -#include "Identity.h" +#include +#include // Forward declaration class TinyGPSPlus; diff --git a/lib/tdeck_ui/UI/LXMF/StatusScreen.cpp b/lib/tdeck_ui/UI/LXMF/StatusScreen.cpp index 718ad621..88ea8a2a 100644 --- a/lib/tdeck_ui/UI/LXMF/StatusScreen.cpp +++ b/lib/tdeck_ui/UI/LXMF/StatusScreen.cpp @@ -7,7 +7,7 @@ #ifdef ARDUINO #include -#include "Log.h" +#include #include "../LVGL/LVGLInit.h" #include "../LVGL/LVGLLock.h" diff --git a/lib/tdeck_ui/UI/LXMF/StatusScreen.h b/lib/tdeck_ui/UI/LXMF/StatusScreen.h index aea416fa..a865e7f1 100644 --- a/lib/tdeck_ui/UI/LXMF/StatusScreen.h +++ b/lib/tdeck_ui/UI/LXMF/StatusScreen.h @@ -9,8 +9,8 @@ #include #include #include -#include "Bytes.h" -#include "Identity.h" +#include +#include namespace UI { namespace LXMF { diff --git a/lib/tdeck_ui/UI/LXMF/UIManager.cpp b/lib/tdeck_ui/UI/LXMF/UIManager.cpp index 94077f03..5bf17431 100644 --- a/lib/tdeck_ui/UI/LXMF/UIManager.cpp +++ b/lib/tdeck_ui/UI/LXMF/UIManager.cpp @@ -7,16 +7,16 @@ #include #include -#include "Log.h" +#include #ifdef PYXIS_TEST_HOOKS #include "pyxis_test_hooks.h" #endif #include "Tone.h" #include "../LVGL/LVGLLock.h" #include "lxst_audio.h" -#include "Packet.h" -#include "Transport.h" -#include "Destination.h" +#include +#include +#include using namespace RNS; diff --git a/lib/tdeck_ui/UI/LXMF/UIManager.h b/lib/tdeck_ui/UI/LXMF/UIManager.h index 0300d471..65b25c25 100644 --- a/lib/tdeck_ui/UI/LXMF/UIManager.h +++ b/lib/tdeck_ui/UI/LXMF/UIManager.h @@ -20,8 +20,8 @@ #include "LXMF/LXMRouter.h" #include "LXMF/PropagationNodeManager.h" #include "LXMF/MessageStore.h" -#include "Reticulum.h" -#include "Link.h" +#include +#include class LXSTAudio; diff --git a/lib/universal_filesystem/UniversalFileSystem.cpp b/lib/universal_filesystem/UniversalFileSystem.cpp index 1584bf7a..f7d0bd6c 100644 --- a/lib/universal_filesystem/UniversalFileSystem.cpp +++ b/lib/universal_filesystem/UniversalFileSystem.cpp @@ -1,7 +1,7 @@ #include "UniversalFileSystem.h" -#include -#include +#include +#include #ifdef ARDUINO void UniversalFileSystem::listDir(const char* dir) { diff --git a/lib/universal_filesystem/UniversalFileSystem.h b/lib/universal_filesystem/UniversalFileSystem.h index 3d00e44b..607518e3 100644 --- a/lib/universal_filesystem/UniversalFileSystem.h +++ b/lib/universal_filesystem/UniversalFileSystem.h @@ -2,7 +2,7 @@ #include #include -#include +#include #ifdef ARDUINO #ifdef BOARD_ESP32 diff --git a/patch_littlefs_paths.py b/patch_littlefs_paths.py new file mode 100644 index 00000000..725efdb9 --- /dev/null +++ b/patch_littlefs_paths.py @@ -0,0 +1,95 @@ +""" +PlatformIO pre-build script: patches the libdeps copy of microStore's +LittleFSFileSystem adapter so every file path is normalized to a leading "/". + +Why: ESP32's Arduino LittleFS/VFS rejects any path that does not start with +"/" (it logs nothing and returns an invalid File). But microStore's own +adapter init-test uses "./__init_test__" and microReticulum's Transport path +store uses "./path_store" -> "./path_store_0.dat". Both are relative ("./") +paths that work on native POSIX but fail on-device: the LittleFS check +"fails" and reformats every boot, and `open_segment` can never open +"./path_store_0.dat", so the path table never persists and pyxis never learns +any peer's path ("Failed to add destination ... to path table!"). That blocks +all LXMF messaging. + +This is a platform-correctness concern that belongs in the ESP32 adapter, so +we normalize "./x" / "x" -> "/x" at each LittleFS.* call site there. Native +builds (PosixFileSystem) are unaffected — they don't use this adapter. + +Idempotent: detects the already-patched state via the _pyxis_norm_path marker. + +TODO(upstream): attermann/microStore's LittleFSFileSystem adapter should +normalize paths to a leading "/" itself (file an issue / PR on the fork). +""" +Import("env") # noqa: F821 +import os +import sys + +ADAPTER_H = os.path.join( + env.get("PROJECT_DIR", "."), # noqa: F821 + ".pio", "libdeps", env.get("PIOENV", "tdeck"), # noqa: F821 + "microStore", "include", "microStore", "Adapters", "LittleFSFileSystem.h", +) + +MARKER = "_pyxis_norm_path" + +HELPER = """namespace microStore { namespace Adapters { + +// patched-by-pyxis: ESP32 Arduino LittleFS requires a leading "/". microStore +// and microReticulum use "./"-prefixed paths that work on POSIX but fail here. +static inline std::string _pyxis_norm_path(const char* p) { +\tstd::string s(p ? p : ""); +\tif (s.rfind("./", 0) == 0) s.erase(0, 2); +\tif (s.empty() || s.front() != '/') s.insert(s.begin(), '/'); +\treturn s; +} +""" + +# (old, new) — order matters so the more-specific open() forms are rewritten +# before the bare open(path) form (which is a non-overlapping distinct string). +REPLACEMENTS = [ + ("LittleFS.open(path, pmode)", "LittleFS.open(_pyxis_norm_path(path).c_str(), pmode)"), + ("LittleFS.open(path, FILE_READ)", "LittleFS.open(_pyxis_norm_path(path).c_str(), FILE_READ)"), + ("LittleFS.open(path)", "LittleFS.open(_pyxis_norm_path(path).c_str())"), + ("LittleFS.exists(path)", "LittleFS.exists(_pyxis_norm_path(path).c_str())"), + ("LittleFS.remove(path)", "LittleFS.remove(_pyxis_norm_path(path).c_str())"), + ("LittleFS.rename(from_path, to_path)","LittleFS.rename(_pyxis_norm_path(from_path).c_str(), _pyxis_norm_path(to_path).c_str())"), + ("LittleFS.mkdir(path)", "LittleFS.mkdir(_pyxis_norm_path(path).c_str())"), + ("LittleFS.rmdir(path)", "LittleFS.rmdir(_pyxis_norm_path(path).c_str())"), +] + + +def main(): + if not os.path.exists(ADAPTER_H): + # libdeps not fetched yet on a clean tree — PIO runs this again post-fetch. + print(f"[patch_littlefs_paths] {ADAPTER_H} not present yet; skipping") + return + with open(ADAPTER_H) as f: + src = f.read() + if MARKER in src: + print("[patch_littlefs_paths] already patched; skipping") + return + + if "#include " not in src: + src = src.replace("#include ", + "#include \n#include ", 1) + + # Inject the helper by expanding the namespace-open line. + anchor = "namespace microStore { namespace Adapters {" + if anchor not in src: + print(f"[patch_littlefs_paths] FATAL: namespace anchor not found in {ADAPTER_H}") + sys.exit(1) + src = src.replace(anchor, HELPER, 1) + + for old, new in REPLACEMENTS: + if old not in src: + print(f"[patch_littlefs_paths] FATAL: expected call site not found: {old!r}") + sys.exit(1) + src = src.replace(old, new) + + with open(ADAPTER_H, "w") as f: + f.write(src) + print("[patch_littlefs_paths] normalized LittleFS adapter paths to leading '/'") + + +main() diff --git a/platformio.ini b/platformio.ini index 04e68a9d..f9f430a0 100644 --- a/platformio.ini +++ b/platformio.ini @@ -10,6 +10,10 @@ extra_scripts = ; PYXIS_FILESTORE_DIAG=1 to also enable exists()/put() diagnostic ; prints when investigating path-store drift. pre:patch_filestore.py + ; patch_littlefs_paths.py normalizes microStore's LittleFS adapter paths to + ; a leading "/" — ESP32 Arduino LittleFS rejects "./"-prefixed paths, which + ; broke the path store (no peer paths learned). See the script header. + pre:patch_littlefs_paths.py ; sync_file_libdeps.py mirrors file:// lib_deps source trees into ; .pio/libdeps before each build. PIO doesn't re-sync file:// deps ; after first install — without this, edits to ~/repos/ @@ -61,10 +65,17 @@ lib_deps = ; proof + Resource progress-callback firing fixes. Bump SHA in ; tandem with conformance-bridge/CMakeLists.txt's FetchContent ; tag if either side updates. - https://github.com/torlando-tech/microReticulum.git#3ee2bd8337801173ed107c8d1deb6865739d37ff - ; microLXMF — pinned to main HEAD. Same coordination rule as - ; microReticulum: bump both pins together if upstream changes. - https://github.com/torlando-tech/microLXMF.git#9876dfff8ec4a2ed1e28adef4375ec57b7e9eb4b + ; microReticulum: torlando-tech/microReticulum:pyxis-fixes-on-0.4.1 — + ; upstream attermann/microReticulum master (0.4.1+16) + the small + ; still-needed fixes: PKCS7/HMAC/X25519 crypto (proven byte-identical to + ; python RNS 1.3.1), Packet link-proof callback, Identity short-sig guard, + ; and the bz2 layer + decompress-on-receive in Resource::assemble(). The + ; far-diverged 0.3.0 fork's Resource/Transport/Identity work is subsumed by + ; upstream's reimplementation. Bump in lockstep with microLXMF below. + https://github.com/torlando-tech/microReticulum.git#2f21feef9ff30ebde86370b56335813232a0d3e1 + ; microLXMF: chore/microreticulum-0.4.1-layout — includes namespaced to + ; for the 0.4.x src/microReticulum/ layout. + https://github.com/torlando-tech/microLXMF.git#33760d0d38d81a9fc3bc07693ffeb7dd678a414c lvgl/lvgl@^8.3.11 bblanchon/ArduinoJson@^7.4.2 hideakitai/MsgPack@^0.4.2 @@ -92,11 +103,11 @@ lib_deps = ; been validated against pyxis's MessageStore / path-store usage ; patterns. Bump the SHA when ready to re-validate. Matches the ; same pin used in conformance bridge builds. - https://github.com/attermann/microStore.git#ceea8f585c8b22ad238fb290961b8311cb83c516 + https://github.com/attermann/microStore.git#c5fb69d68229e684c7fbd17692a67ae8193b84e2 ; Build configuration build_flags = - -std=gnu++11 + -std=gnu++17 -DBOARD_HAS_PSRAM -DBOARD_ESP32 ; Arduino loop task stack — Codec2 decode (lpc_post_filter + kiss_fft) diff --git a/src/HDLC.h b/src/HDLC.h index 960a3caa..fc8827c0 100644 --- a/src/HDLC.h +++ b/src/HDLC.h @@ -1,6 +1,6 @@ #pragma once -#include "Bytes.h" +#include #include diff --git a/src/TCPClientInterface.cpp b/src/TCPClientInterface.cpp index 90440d01..36cbe9e7 100644 --- a/src/TCPClientInterface.cpp +++ b/src/TCPClientInterface.cpp @@ -1,8 +1,8 @@ #include "TCPClientInterface.h" #include "HDLC.h" -#include -#include +#include +#include #include @@ -440,12 +440,12 @@ void TCPClientInterface::extract_and_process_frames() { } } -/*virtual*/ void TCPClientInterface::send_outgoing(const Bytes& data) { +/*virtual*/ bool TCPClientInterface::send_outgoing(const Bytes& data) { DEBUG(toString() + ".send_outgoing: data: " + std::to_string(data.size()) + " bytes"); if (!_online) { DEBUG("TCPClientInterface: Not connected, cannot send"); - return; + return false; } try { @@ -484,7 +484,7 @@ void TCPClientInterface::extract_and_process_frames() { ERROR("TCPClientInterface: Write incomplete, " + std::to_string(written) + " of " + std::to_string(framed.size()) + " bytes"); handle_disconnect(); - return; + return false; } _client.flush(); #else @@ -492,21 +492,23 @@ void TCPClientInterface::extract_and_process_frames() { if (written < 0) { ERROR("TCPClientInterface: send error " + std::to_string(errno)); handle_disconnect(); - return; + return false; } if (static_cast(written) != framed.size()) { ERROR("TCPClientInterface: Write incomplete, " + std::to_string(written) + " of " + std::to_string(framed.size()) + " bytes"); handle_disconnect(); - return; + return false; } #endif // Perform post-send housekeeping InterfaceImpl::handle_outgoing(data); + return true; } catch (std::exception& e) { ERROR("TCPClientInterface: Exception during send: " + std::string(e.what())); handle_disconnect(); } + return false; } diff --git a/src/TCPClientInterface.h b/src/TCPClientInterface.h index fb6c57a3..5157e21e 100644 --- a/src/TCPClientInterface.h +++ b/src/TCPClientInterface.h @@ -1,8 +1,8 @@ #pragma once -#include "Interface.h" -#include "Bytes.h" -#include "Type.h" +#include +#include +#include #ifdef ARDUINO #include @@ -69,7 +69,7 @@ public: } protected: - virtual void send_outgoing(const RNS::Bytes& data); + virtual bool send_outgoing(const RNS::Bytes& data); private: // Connection management diff --git a/src/main.cpp b/src/main.cpp index 8f5b0e80..50cc9110 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -16,8 +16,8 @@ #include // Reticulum -#include -#include +#include +#include // Filesystem // Was: (pyxis-provided RNS::FileSystem wrapper). @@ -30,10 +30,10 @@ // LittleFS reuses the same partition (label "spiffs") and reformats it // on first boot. #include -#include -#include -#include -#include +#include +#include +#include +#include // TCP Client Interface #include "TCPClientInterface.h" @@ -76,7 +76,7 @@ #include "Tone.h" // Logging -#include +#include // SD Card access and logging #include @@ -1742,7 +1742,7 @@ static void handle_test_hook_command(const String& line) { Serial.println("T:OK announced"); } else if (cmd == "T:PATHS") { - const auto& path_table = RNS::Transport::get_path_table(); + const auto& path_table = RNS::Transport::path_table(); Serial.print("T:OK count="); Serial.println(String((unsigned)path_table.size())); for (const auto& kv : path_table) { @@ -1757,7 +1757,7 @@ static void handle_test_hook_command(const String& line) { // Diagnostic: also dump whether the in-memory _path_table has it, // and the size of each store. They should match when the dual- // write fix is working. - const auto& mem_table = RNS::Transport::get_path_table(); + const auto& mem_table = RNS::Transport::path_table(); bool mem_has = (mem_table.find(dest) != mem_table.end()); Serial.print("T:OK "); Serial.print(has ? "1" : "0");