Skip to content

Commit 75e8379

Browse files
committed
stm32wl: exclude backup preferences via MESHTASTIC_EXCLUDE_BACKUP
backup.proto requires 2 LittleFS blocks (4 KB) and is only written on an explicit admin command. On a flash-constrained node with 12 usable blocks, this is headroom better preserved for normal operation. Guard the three AdminModule case handlers and NodeDB declarations/implementations behind #if !MESHTASTIC_EXCLUDE_BACKUP, matching the pattern used by existing MESHTASTIC_EXCLUDE_* flags throughout the codebase. Signed-off-by: Andrew Yong <me@ndoo.sg>
1 parent 6459b72 commit 75e8379

4 files changed

Lines changed: 13 additions & 2 deletions

File tree

src/mesh/NodeDB.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2190,6 +2190,7 @@ bool NodeDB::checkLowEntropyPublicKey(const meshtastic_Config_SecurityConfig_pub
21902190
}
21912191
#endif
21922192

2193+
#if !MESHTASTIC_EXCLUDE_BACKUP
21932194
bool NodeDB::backupPreferences(meshtastic_AdminMessage_BackupLocation location)
21942195
{
21952196
bool success = false;
@@ -2277,6 +2278,7 @@ bool NodeDB::restorePreferences(meshtastic_AdminMessage_BackupLocation location,
22772278
#endif
22782279
return success;
22792280
}
2281+
#endif // !MESHTASTIC_EXCLUDE_BACKUP
22802282

22812283
/// Record an error that should be reported via analytics
22822284
void recordCriticalError(meshtastic_CriticalErrorCode code, uint32_t address, const char *filename)

src/mesh/NodeDB.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,9 @@ static constexpr const char *configFileName = "/prefs/config.proto";
102102
static constexpr const char *uiconfigFileName = "/prefs/uiconfig.proto";
103103
static constexpr const char *moduleConfigFileName = "/prefs/module.proto";
104104
static constexpr const char *channelFileName = "/prefs/channels.proto";
105+
#if !MESHTASTIC_EXCLUDE_BACKUP
105106
static constexpr const char *backupFileName = "/backups/backup.proto";
107+
#endif
106108

107109
/// Given a node, return how many seconds in the past (vs now) that we last heard from it
108110
uint32_t sinceLastSeen(const meshtastic_NodeInfoLite *n);
@@ -316,9 +318,11 @@ class NodeDB
316318
bool checkLowEntropyPublicKey(const meshtastic_Config_SecurityConfig_public_key_t &keyToTest);
317319
#endif
318320

321+
#if !MESHTASTIC_EXCLUDE_BACKUP
319322
bool backupPreferences(meshtastic_AdminMessage_BackupLocation location);
320323
bool restorePreferences(meshtastic_AdminMessage_BackupLocation location,
321324
int restoreWhat = SEGMENT_CONFIG | SEGMENT_MODULECONFIG | SEGMENT_DEVICESTATE | SEGMENT_CHANNELS);
325+
#endif
322326

323327
/// Notify observers of changes to the DB
324328
void notifyObservers(bool forceUpdate = false)
@@ -331,9 +335,11 @@ class NodeDB
331335
private:
332336
bool duplicateWarned = false;
333337
bool localPositionUpdatedSinceBoot = false;
334-
uint32_t lastNodeDbSave = 0; // when we last saved our db to flash
338+
uint32_t lastNodeDbSave = 0; // when we last saved our db to flash
339+
#if !MESHTASTIC_EXCLUDE_BACKUP
335340
uint32_t lastBackupAttempt = 0; // when we last tried a backup automatically or manually
336-
uint32_t lastSort = 0; // When last sorted the nodeDB
341+
#endif
342+
uint32_t lastSort = 0; // When last sorted the nodeDB
337343
/// Find a node in our DB, create an empty NodeInfoLite if missing
338344
meshtastic_NodeInfoLite *getOrCreateMeshNode(NodeNum n);
339345

src/modules/AdminModule.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,7 @@ bool AdminModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshta
499499
#endif
500500
break;
501501
}
502+
#if !MESHTASTIC_EXCLUDE_BACKUP
502503
case meshtastic_AdminMessage_backup_preferences_tag: {
503504
LOG_INFO("Client requesting to backup preferences");
504505
if (nodeDB->backupPreferences(r->backup_preferences)) {
@@ -535,6 +536,7 @@ bool AdminModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshta
535536
#endif
536537
break;
537538
}
539+
#endif // !MESHTASTIC_EXCLUDE_BACKUP
538540
case meshtastic_AdminMessage_send_input_event_tag: {
539541
LOG_INFO("Client requesting to send input event");
540542
handleSendInputEvent(r->send_input_event);

variants/stm32/stm32.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ build_flags =
2525
-DMESHTASTIC_EXCLUDE_BLUETOOTH=1
2626
-DMESHTASTIC_EXCLUDE_WIFI=1
2727
-DMESHTASTIC_EXCLUDE_TZ=1 ; Exclude TZ to save some flash space.
28+
-DMESHTASTIC_EXCLUDE_BACKUP=1 ; Backup preferences require 2 flash blocks (4 KB); not useful on a flash-constrained node.
2829
-DSERIAL_RX_BUFFER_SIZE=256 ; For GPS - the default of 64 is too small.
2930
-DHAS_SCREEN=0 ; Always disable screen for STM32, it is not supported.
3031
;-DPIO_FRAMEWORK_ARDUINO_NANOLIB_FLOAT_PRINTF ; Enable this if enabling debugg logging. It is REQUIRED for at least traceroute debug prints - without it the length returned by printf ends up uninitialized.

0 commit comments

Comments
 (0)