Skip to content

Commit

Permalink
StoreForward: (tapback) reply support (#5585)
Browse files Browse the repository at this point in the history
  • Loading branch information
GUVWAF authored Dec 15, 2024
1 parent 09c082f commit 69d01a8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/modules/StoreForwardModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<PacketHistoryStruct *>(ps_calloc(numberOfPackets, sizeof(PacketHistoryStruct)));
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -617,4 +623,4 @@ StoreForwardModule::StoreForwardModule()
disable();
}
#endif
}
}
3 changes: 3 additions & 0 deletions src/modules/StoreForwardModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down

0 comments on commit 69d01a8

Please sign in to comment.