From 69d01a8088d89753cea18502e44777764774d765 Mon Sep 17 00:00:00 2001 From: GUVWAF <78759985+GUVWAF@users.noreply.github.com> Date: Sun, 15 Dec 2024 20:11:13 +0100 Subject: [PATCH] StoreForward: (tapback) reply support (#5585) --- src/modules/StoreForwardModule.cpp | 12 +++++++++--- src/modules/StoreForwardModule.h | 3 +++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/modules/StoreForwardModule.cpp b/src/modules/StoreForwardModule.cpp index 4cf06f5d25..0a6e1b4c49 100644 --- a/src/modules/StoreForwardModule.cpp +++ b/src/modules/StoreForwardModule.cpp @@ -73,11 +73,11 @@ void StoreForwardModule::populatePSRAM() LOG_DEBUG("Before PSRAM init: heap %d/%d PSRAM %d/%d", memGet.getFreeHeap(), memGet.getHeapSize(), memGet.getFreePsram(), memGet.getPsramSize()); - /* Use a maximum of 2/3 the available PSRAM unless otherwise specified. + /* Use a maximum of 3/4 the available PSRAM unless otherwise specified. Note: This needs to be done after every thing that would use PSRAM */ uint32_t numberOfPackets = - (this->records ? this->records : (((memGet.getFreePsram() / 3) * 2) / sizeof(PacketHistoryStruct))); + (this->records ? this->records : (((memGet.getFreePsram() / 4) * 3) / sizeof(PacketHistoryStruct))); this->records = numberOfPackets; #if defined(ARCH_ESP32) this->packetHistory = static_cast(ps_calloc(numberOfPackets, sizeof(PacketHistoryStruct))); @@ -198,6 +198,9 @@ void StoreForwardModule::historyAdd(const meshtastic_MeshPacket &mp) this->packetHistory[this->packetHistoryTotalCount].to = mp.to; this->packetHistory[this->packetHistoryTotalCount].channel = mp.channel; this->packetHistory[this->packetHistoryTotalCount].from = getFrom(&mp); + this->packetHistory[this->packetHistoryTotalCount].id = mp.id; + this->packetHistory[this->packetHistoryTotalCount].reply_id = p.reply_id; + this->packetHistory[this->packetHistoryTotalCount].emoji = (bool)p.emoji; this->packetHistory[this->packetHistoryTotalCount].payload_size = p.payload.size; memcpy(this->packetHistory[this->packetHistoryTotalCount].payload, p.payload.bytes, meshtastic_Constants_DATA_PAYLOAD_LEN); @@ -244,8 +247,11 @@ meshtastic_MeshPacket *StoreForwardModule::preparePayload(NodeNum dest, uint32_t p->to = local ? this->packetHistory[i].to : dest; // PhoneAPI can handle original `to` p->from = this->packetHistory[i].from; + p->id = this->packetHistory[i].id; p->channel = this->packetHistory[i].channel; + p->decoded.reply_id = this->packetHistory[i].reply_id; p->rx_time = this->packetHistory[i].time; + p->decoded.emoji = (uint32_t)this->packetHistory[i].emoji; // Let's assume that if the server received the S&F request that the client is in range. // TODO: Make this configurable. @@ -617,4 +623,4 @@ StoreForwardModule::StoreForwardModule() disable(); } #endif -} +} \ No newline at end of file diff --git a/src/modules/StoreForwardModule.h b/src/modules/StoreForwardModule.h index e3273470b6..30db1625cf 100644 --- a/src/modules/StoreForwardModule.h +++ b/src/modules/StoreForwardModule.h @@ -13,7 +13,10 @@ struct PacketHistoryStruct { uint32_t time; uint32_t to; uint32_t from; + uint32_t id; uint8_t channel; + uint32_t reply_id; + bool emoji; uint8_t payload[meshtastic_Constants_DATA_PAYLOAD_LEN]; pb_size_t payload_size; };