From 635ec90f0484d7bdca47a30b0ea2d758676d1dd5 Mon Sep 17 00:00:00 2001 From: Trail Mate Dev Date: Tue, 2 Jun 2026 09:23:47 +0800 Subject: [PATCH] fix(meshcore): sync radio RX state after direct TX (#49) --- .../chat/infra/meshcore/meshcore_adapter.cpp | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/platform/esp/arduino_common/src/chat/infra/meshcore/meshcore_adapter.cpp b/platform/esp/arduino_common/src/chat/infra/meshcore/meshcore_adapter.cpp index 114dc316..26ecc00a 100644 --- a/platform/esp/arduino_common/src/chat/infra/meshcore/meshcore_adapter.cpp +++ b/platform/esp/arduino_common/src/chat/infra/meshcore/meshcore_adapter.cpp @@ -10,6 +10,7 @@ #include "chat/infra/meshcore/meshcore_protocol_helpers.h" #include "chat/time_utils.h" #include "mesh/protocol/meshcore/meshcore_protocol_strategy.h" +#include "platform/esp/arduino_common/app_tasks.h" #include "sys/event_bus.h" #include #include @@ -1682,6 +1683,7 @@ MeshActionResult MeshCoreAdapter::transmitFrameNowDetailed(const uint8_t* data, int state = RADIOLIB_ERR_UNSUPPORTED; #if defined(ARDUINO_LILYGO_LORA_SX1262) || defined(ARDUINO_LILYGO_LORA_SX1280) || \ defined(ARDUINO_LILYGO_LORA_LR1121) + app::AppTasks::requestRadioReceiveRestart(); state = board_.transmitRadio(data, len); #endif if (state == RADIOLIB_ERR_NONE) @@ -1698,17 +1700,28 @@ MeshActionResult MeshCoreAdapter::transmitFrameNowDetailed(const uint8_t* data, int rx_state = board_.startRadioReceive(); if (rx_state != RADIOLIB_ERR_NONE) { + app::AppTasks::requestRadioReceiveRestart(); MESHCORE_LOG("[MESHCORE] RX restart fail state=%d\n", rx_state); } - else if (parsePacket(data, len, &parsed)) + else { - MESHCORE_LOG("[MESHCORE] RX restart ok after_tx route=%u type=%u len=%u\n", - static_cast(parsed.route_type), - static_cast(parsed.payload_type), - static_cast(len)); + app::AppTasks::setRadioReceiveActive(true); + if (parsePacket(data, len, &parsed)) + { + MESHCORE_LOG("[MESHCORE] RX restart ok after_tx route=%u type=%u len=%u\n", + static_cast(parsed.route_type), + static_cast(parsed.payload_type), + static_cast(len)); + } + else + { + MESHCORE_LOG("[MESHCORE] RX restart ok after_tx len=%u\n", + static_cast(len)); + } } return MeshActionResult::success(); } + app::AppTasks::requestRadioReceiveRestart(); return MeshActionResult::fail(state == RADIOLIB_ERR_SPI_WRITE_FAILED ? MeshOperationFailure::Busy : MeshOperationFailure::RadioTxFailed,