From 94155f170e64c84289acc745a62fc3d1d97bd1bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Sat, 26 Oct 2024 13:58:29 +0200 Subject: [PATCH] fix compilation, double macros resolved --- src/graphics/images.h | 2 +- src/modules/StoreForwardModule.cpp | 28 ++++++++++++++++++++-------- src/modules/StoreForwardModule.h | 4 ++-- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/graphics/images.h b/src/graphics/images.h index 1d6168c8c..5ce40f26a 100644 --- a/src/graphics/images.h +++ b/src/graphics/images.h @@ -21,7 +21,7 @@ const uint8_t bluetoothConnectedIcon[36] PROGMEM = {0xfe, 0x01, 0xff, 0x03, 0x03 #endif #if (defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ILI9342_DRIVER) || defined(ST7701_CS) || defined(ST7735_CS) || \ - defined(ST7789_CS) || defined(USE_ST7789) || defined(HX8357_CS)) && \ + defined(ST7789_CS) || defined(USE_ST7789) || defined(HX8357_CS)) && \ !defined(DISPLAY_FORCE_SMALL_FONTS) const uint8_t imgQuestionL1[] PROGMEM = {0xff, 0x01, 0x01, 0x32, 0x7b, 0x49, 0x49, 0x6f, 0x26, 0x01, 0x01, 0xff}; const uint8_t imgQuestionL2[] PROGMEM = {0x0f, 0x08, 0x08, 0x08, 0x06, 0x0f, 0x0f, 0x06, 0x08, 0x08, 0x08, 0x0f}; diff --git a/src/modules/StoreForwardModule.cpp b/src/modules/StoreForwardModule.cpp index 8f76bd047..c111d5299 100644 --- a/src/modules/StoreForwardModule.cpp +++ b/src/modules/StoreForwardModule.cpp @@ -89,7 +89,7 @@ void StoreForwardModule::populatePSRAM() LOG_DEBUG("After PSRAM init: heap %d/%d PSRAM %d/%d", memGet.getFreeHeap(), memGet.getHeapSize(), memGet.getFreePsram(), memGet.getPsramSize()); LOG_DEBUG("numberOfPackets for packetHistory - %u", numberOfPackets); - this->storageType = StorageType::PSRAM; + this->storageType = StorageType::ST_PSRAM; } /** @@ -156,7 +156,7 @@ uint32_t StoreForwardModule::getNumAvailablePackets(NodeNum dest, uint32_t last_ lastRequest.emplace(dest, 0); } for (uint32_t i = lastRequest[dest]; i < this->packetHistoryTotalCount; i++) { - if (this->storageType == StorageType::PSRAM) { + if (this->storageType == StorageType::ST_PSRAM) { if (this->packetHistory[i].time && (this->packetHistory[i].time > last_time)) { // Client is only interested in packets not from itself and only in broadcast packets or packets towards it. if (this->packetHistory[i].from != dest && @@ -164,7 +164,8 @@ uint32_t StoreForwardModule::getNumAvailablePackets(NodeNum dest, uint32_t last_ count++; } } - } else { + } else if (this->storageType == StorageType::ST_SDCARD) { +#if defined(HAS_SDCARD) auto handler = SD.open("/storeforward/" + String(i), FILE_READ); if (handler) { handler.read((uint8_t *)&this->packetHistory[0], sizeof(PacketHistoryStruct)); @@ -177,6 +178,9 @@ uint32_t StoreForwardModule::getNumAvailablePackets(NodeNum dest, uint32_t last_ } } } +#endif + } else { + LOG_ERROR("S&F: Unknown storage type"); } } return count; @@ -230,7 +234,7 @@ void StoreForwardModule::historyAdd(const meshtastic_MeshPacket &mp) } } - if (this->storageType == StorageType::PSRAM) { + if (this->storageType == StorageType::ST_PSRAM) { this->packetHistory[this->packetHistoryTotalCount].time = getTime(); this->packetHistory[this->packetHistoryTotalCount].to = mp.to; this->packetHistory[this->packetHistoryTotalCount].channel = mp.channel; @@ -238,8 +242,9 @@ void StoreForwardModule::historyAdd(const meshtastic_MeshPacket &mp) this->packetHistory[this->packetHistoryTotalCount].payload_size = p.payload.size; memcpy(this->packetHistory[this->packetHistoryTotalCount].payload, p.payload.bytes, meshtastic_Constants_DATA_PAYLOAD_LEN); - } else { - // Save to SDCARD + } else if (this->storageType == StorageType::ST_SDCARD) { +// Save to SDCARD +#if defined(HAS_SDCARD) this->packetHistory[0].time = getTime(); this->packetHistory[0].to = mp.to; this->packetHistory[0].channel = mp.channel; @@ -249,6 +254,9 @@ void StoreForwardModule::historyAdd(const meshtastic_MeshPacket &mp) auto handler = SD.open("/storeforward/" + String(this->packetHistoryTotalCount), FILE_WRITE); handler.write((uint8_t *)&this->packetHistory, sizeof(PacketHistoryStruct)); handler.close(); +#endif + } else { + LOG_ERROR("S&F: Unknown storage type"); } this->packetHistoryTotalCount++; @@ -283,7 +291,7 @@ bool StoreForwardModule::sendPayload(NodeNum dest, uint32_t last_time) meshtastic_MeshPacket *StoreForwardModule::preparePayload(NodeNum dest, uint32_t last_time, bool local) { for (uint32_t i = lastRequest[dest]; i < this->packetHistoryTotalCount; i++) { - if (this->storageType == StorageType::PSRAM) { + if (this->storageType == StorageType::ST_PSRAM) { if (this->packetHistory[i].time && (this->packetHistory[i].time > last_time)) { /* Copy the messages that were received by the server in the last msAgo @@ -327,7 +335,8 @@ meshtastic_MeshPacket *StoreForwardModule::preparePayload(NodeNum dest, uint32_t return p; } } - } else { + } else if (this->storageType == StorageType::ST_SDCARD) { +#if defined(HAS_SDCARD) auto handler = SD.open("/storeforward/" + String(i), FILE_READ); if (handler) { handler.read((uint8_t *)&this->packetHistory[0], sizeof(PacketHistoryStruct)); @@ -371,6 +380,9 @@ meshtastic_MeshPacket *StoreForwardModule::preparePayload(NodeNum dest, uint32_t } } } +#endif + } else { + LOG_ERROR("S&F: Unknown storage type"); } } return nullptr; diff --git a/src/modules/StoreForwardModule.h b/src/modules/StoreForwardModule.h index 3a5032737..5756d9de5 100644 --- a/src/modules/StoreForwardModule.h +++ b/src/modules/StoreForwardModule.h @@ -23,7 +23,7 @@ struct PacketHistoryStruct { }; // enum for the storage type -enum StorageType { PSRAM, SDCARD }; +enum StorageType { ST_PSRAM, ST_SDCARD }; class StoreForwardModule : private concurrency::OSThread, public ProtobufModule { @@ -90,7 +90,7 @@ class StoreForwardModule : private concurrency::OSThread, public ProtobufModule< void populateSDCard(); // Storage Type - StorageType storageType = PSRAM; + StorageType storageType = ST_PSRAM; // S&F Defaults uint32_t historyReturnMax = 25; // Return maximum of 25 records by default.