mirror of
https://github.com/alexhopeoconnor/firmware.git
synced 2026-10-04 03:18:10 +10:00
logging: audit log strings for terseness, reclaiming ~6.8 KB of string data (#11374)
* logging: strip redundant punctuation, level prefixes, and 'successfully' from log strings The logger already appends a newline and prints the level tag, so trailing '.', '!', '...', literal \n, and 'Error:'/'Warning:' prefixes inside format strings are wasted flash bytes. Same for 'successfully' (the affirmative form already implies it). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LBiZc9sfPrH1MZ2L3Fxgt1 * logging: tighten verbose log strings in modules, radio, platform, and system code Rewrite wordy log messages to terser equivalents - drop filler words (articles, 'attempting', 'due to', 'please'), use 'Can't X'/'X failed' phrasing, and abbreviate where the codebase already does (config, init, msg, BT). Format specifiers and argument lists are unchanged; distinctive greppable tokens are preserved. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LBiZc9sfPrH1MZ2L3Fxgt1 * logging: tighten verbose log strings in telemetry sensors and GPS Same terseness pass: drop filler, 'Can't X'/'X failed' phrasing, common abbreviations (temp, msg). Specifiers, arguments, and sensor-name prefixes unchanged. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LBiZc9sfPrH1MZ2L3Fxgt1 * logging: tighten verbose log strings in mesh core Same terseness pass over NodeDB, Router, MeshService, PhoneAPI, RadioInterface, NextHopRouter, and PacketHistory: 'X failed'/'Can't X' phrasing, imperative verbs, dropped filler. Specifiers and arguments unchanged; duplicate literals kept identical to preserve linker string dedup. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LBiZc9sfPrH1MZ2L3Fxgt1 * logging: 'Unable to/Could not/Cannot' -> "Can't" in log strings Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LBiZc9sfPrH1MZ2L3Fxgt1 * logging: clang-format rewrap after string shortening Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LBiZc9sfPrH1MZ2L3Fxgt1 * logging: restore boot-logo trailing newline and progress-dot strings The terseness pass over-trimmed: the Meshtastic ASCII boot logo kept its blank line via a trailing \n, and three bare "." progress ticks were reduced to empty strings. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LBiZc9sfPrH1MZ2L3Fxgt1 * Update src/mesh/wifi/WiFiAPClient.cpp Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * logging: address review feedback on the terseness audit - Node/packet IDs use the repo's 0x%08x convention in NextHopRouter, NodeDB, AdminModule and CannedMessageModule. The sibling log in each if/else pair is converted too, so a pair isn't split across two formats. next_hop stays 0x%x - it's the last-byte relay hint, not a NodeNum. - RTC: the read-path and set-path "not found" warnings were byte-identical, so the linker deduped them and the log couldn't say which one fired. Split into "RTC read:" / "RTC set:". (The four sites live in mutually exclusive #ifdef branches, so the RTC family was never ambiguous.) - SCD4X getAmbientPressure()/setAmbientPressure() logged "altitude", and SCD30 getASC() logged "Can't send command" for a read. Both now name the operation they actually perform. - LOG_ERROR already carries the level: ". Error: %u" -> ", rc=%u" (matching the existing rc=%d house style) and "Error executing X()" -> "X() failed". - Typos and wording: "OTA partiton. (Reason" -> "OTA partition (reason", "CST3530 not response ~" -> "CST3530 no response", "Packet received with to: of 0" -> "to=0", HostMetrics "Error decoding" -> "Can't decode", and the dangling ": " on the NextHopRouter retransmission line. Printf specifier sequences are byte-identical on all 37 touched lines apart from the 6 deliberate %x/%u -> %08x node-ID widenings, all on uint32_t args. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
This commit is contained in:
co-authored by
Claude Opus 5
coderabbitai[bot]
Ben Meadors
parent
5692518306
commit
cd716fe384
+75
-76
@@ -486,12 +486,12 @@ NodeDB::NodeDB()
|
||||
preferences.begin("meshtastic", false);
|
||||
myNodeInfo.reboot_count = preferences.getUInt("rebootCounter", 0);
|
||||
preferences.end();
|
||||
LOG_DEBUG("Number of Device Reboots: %d", myNodeInfo.reboot_count);
|
||||
LOG_DEBUG("Device reboots: %d", myNodeInfo.reboot_count);
|
||||
#endif
|
||||
|
||||
// UA_868 is obsolete; migrate to EU_868 before resetRadioConfig() below validates the region.
|
||||
if (config.lora.region == meshtastic_Config_LoRaConfig_RegionCode_UA_868) {
|
||||
LOG_INFO("UA_868 region is obsolete, migrating saved config to EU_868");
|
||||
LOG_INFO("UA_868 obsolete, migrating config to EU_868");
|
||||
config.lora.region = meshtastic_Config_LoRaConfig_RegionCode_EU_868;
|
||||
}
|
||||
|
||||
@@ -504,7 +504,7 @@ NodeDB::NodeDB()
|
||||
// If we are setup to broadcast on any default channel slot (with default frequency slot semantics),
|
||||
// ensure that the telemetry intervals are coerced to the role-aware minimum value.
|
||||
if (channels.hasDefaultChannel()) {
|
||||
LOG_DEBUG("Coerce telemetry to role-aware minimum on defaults");
|
||||
LOG_DEBUG("Coerce telemetry to role-aware min on defaults");
|
||||
moduleConfig.telemetry.device_update_interval = Default::getConfiguredOrMinimumValue(
|
||||
moduleConfig.telemetry.device_update_interval, min_default_telemetry_interval_secs);
|
||||
moduleConfig.telemetry.environment_update_interval = Default::getConfiguredOrMinimumValue(
|
||||
@@ -527,7 +527,7 @@ NodeDB::NodeDB()
|
||||
}
|
||||
}
|
||||
if (positionUsesDefaultChannel) {
|
||||
LOG_DEBUG("Coerce position broadcasts to role-aware minimum and smart broadcast min of 5 minutes on defaults");
|
||||
LOG_DEBUG("Coerce position broadcasts to role-aware min and smart broadcast min of 5 min on defaults");
|
||||
config.position.position_broadcast_secs =
|
||||
Default::getConfiguredOrMinimumValue(config.position.position_broadcast_secs, min_default_broadcast_interval_secs);
|
||||
config.position.broadcast_smart_minimum_interval_secs = Default::getConfiguredOrMinimumValue(
|
||||
@@ -738,7 +738,7 @@ void NodeDB::resetRadioConfig(bool is_fresh_install)
|
||||
}
|
||||
|
||||
if (channelFile.channels_count != MAX_NUM_CHANNELS) {
|
||||
LOG_INFO("Set default channel and radio preferences!");
|
||||
LOG_INFO("Set default channel and radio prefs");
|
||||
|
||||
channels.initDefaults();
|
||||
// Defaults ship the public PSK, so strip it again before onConfigChanged() publishes hashes;
|
||||
@@ -755,14 +755,14 @@ void NodeDB::resetRadioConfig(bool is_fresh_install)
|
||||
|
||||
bool NodeDB::factoryReset(bool eraseBleBonds)
|
||||
{
|
||||
LOG_INFO("Perform factory reset!");
|
||||
LOG_INFO("Factory reset");
|
||||
// first, remove the "/prefs" (this removes most prefs)
|
||||
spiLock->lock();
|
||||
rmDir("/prefs"); // this uses spilock internally...
|
||||
|
||||
#ifdef FSCom
|
||||
if (FSCom.exists("/static/rangetest.csv") && !FSCom.remove("/static/rangetest.csv")) {
|
||||
LOG_ERROR("Could not remove rangetest.csv file");
|
||||
LOG_ERROR("Can't remove rangetest.csv");
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -806,7 +806,7 @@ bool NodeDB::factoryReset(bool eraseBleBonds)
|
||||
#endif
|
||||
|
||||
#ifdef ARCH_NRF52
|
||||
LOG_INFO("Clear bluetooth bonds!");
|
||||
LOG_INFO("Clear bluetooth bonds");
|
||||
bond_print_list(BLE_GAP_ROLE_PERIPH);
|
||||
bond_print_list(BLE_GAP_ROLE_CENTRAL);
|
||||
Bluefruit.Periph.clearBonds();
|
||||
@@ -884,7 +884,7 @@ void NodeDB::installDefaultConfig(bool preserveKey = false)
|
||||
// Restrict ROUTER*, LOST AND FOUND roles for security reasons
|
||||
if (IS_ONE_OF(USERPREFS_CONFIG_DEVICE_ROLE, meshtastic_Config_DeviceConfig_Role_ROUTER,
|
||||
meshtastic_Config_DeviceConfig_Role_ROUTER_LATE, meshtastic_Config_DeviceConfig_Role_LOST_AND_FOUND)) {
|
||||
LOG_WARN("ROUTER roles are restricted, falling back to CLIENT role");
|
||||
LOG_WARN("ROUTER roles restricted, fall back to CLIENT");
|
||||
config.device.role = meshtastic_Config_DeviceConfig_Role_CLIENT;
|
||||
} else {
|
||||
config.device.role = USERPREFS_CONFIG_DEVICE_ROLE;
|
||||
@@ -1627,7 +1627,7 @@ void NodeDB::resetNodes(bool keepFavorites)
|
||||
NodeNum ourNum = getNodeNum();
|
||||
numMeshNodes = 1;
|
||||
if (keepFavorites) {
|
||||
LOG_INFO("Clearing node database - preserving favorites");
|
||||
LOG_INFO("Clear node database, keep favorites");
|
||||
// Compact favorites into contiguous low slots: zeroing in place leaves one above
|
||||
// numMeshNodes, invisible to every `i < numMeshNodes` scan yet still serialized to flash.
|
||||
for (size_t i = 1; i < meshNodes->size(); i++) {
|
||||
@@ -1642,7 +1642,7 @@ void NodeDB::resetNodes(bool keepFavorites)
|
||||
}
|
||||
std::fill(nodeDatabase.nodes.begin() + numMeshNodes, nodeDatabase.nodes.end(), meshtastic_NodeInfoLite());
|
||||
} else {
|
||||
LOG_INFO("Clearing node database - removing favorites");
|
||||
LOG_INFO("Clear node database, remove favorites");
|
||||
for (size_t i = 1; i < meshNodes->size(); i++) {
|
||||
const NodeNum gone = meshNodes->at(i).num;
|
||||
if (gone)
|
||||
@@ -1698,7 +1698,7 @@ void NodeDB::removeNodeByNum(NodeNum nodeNum)
|
||||
trafficManagementModule->purgeNode(nodeNum);
|
||||
#endif
|
||||
|
||||
LOG_DEBUG("NodeDB::removeNodeByNum purged %d entries. Save changes", removed);
|
||||
LOG_DEBUG("NodeDB::removeNodeByNum purged %d entries, saving", removed);
|
||||
saveNodeDatabaseToDisk();
|
||||
}
|
||||
|
||||
@@ -2040,7 +2040,7 @@ void NodeDB::pickNewNodeNum()
|
||||
(nodeNum == NODENUM_BROADCAST || nodeNum < NUM_RESERVED)) {
|
||||
NodeNum candidate = random(NUM_RESERVED, LONG_MAX); // try a new random choice
|
||||
if (found)
|
||||
LOG_WARN("NOTE! Our desired nodenum 0x%08x is invalid or in use, picking 0x%08x", nodeNum, candidate);
|
||||
LOG_WARN("NOTE! Desired nodenum 0x%08x invalid or in use, picking 0x%08x", nodeNum, candidate);
|
||||
nodeNum = candidate;
|
||||
}
|
||||
LOG_DEBUG("Use nodenum 0x%08x ", nodeNum);
|
||||
@@ -2072,11 +2072,11 @@ LoadFileResult NodeDB::loadProto(const char *filename, size_t protoSize, size_t
|
||||
if (fields != &meshtastic_NodeDatabase_msg)
|
||||
memset(dest_struct, 0, objSize);
|
||||
if (!pb_decode(&stream, fields, dest_struct)) {
|
||||
LOG_ERROR("Error: can't decode protobuf %s", PB_GET_ERROR(&stream));
|
||||
LOG_ERROR("Can't decode protobuf %s", PB_GET_ERROR(&stream));
|
||||
state = LoadFileResult::DECODE_FAILED;
|
||||
storageCorruptThisLoad = true;
|
||||
} else {
|
||||
LOG_INFO("Loaded encrypted %s successfully", filename);
|
||||
LOG_INFO("Loaded encrypted %s", filename);
|
||||
state = LoadFileResult::LOAD_SUCCESS;
|
||||
}
|
||||
} else {
|
||||
@@ -2100,18 +2100,18 @@ LoadFileResult NodeDB::loadProto(const char *filename, size_t protoSize, size_t
|
||||
fields != &meshtastic_NodeDatabase_Legacy_msg) // both NodeDatabase descriptors contain std::vector members
|
||||
memset(dest_struct, 0, objSize);
|
||||
if (!pb_decode(&stream, fields, dest_struct)) {
|
||||
LOG_ERROR("Error: can't decode protobuf %s", PB_GET_ERROR(&stream));
|
||||
LOG_ERROR("Can't decode protobuf %s", PB_GET_ERROR(&stream));
|
||||
state = LoadFileResult::DECODE_FAILED;
|
||||
} else {
|
||||
LOG_INFO("Loaded %s successfully", filename);
|
||||
LOG_INFO("Loaded %s", filename);
|
||||
state = LoadFileResult::LOAD_SUCCESS;
|
||||
}
|
||||
f.close();
|
||||
} else {
|
||||
LOG_ERROR("Could not open / read %s", filename);
|
||||
LOG_ERROR("Can't open/read %s", filename);
|
||||
}
|
||||
#else
|
||||
LOG_ERROR("ERROR: Filesystem not implemented");
|
||||
LOG_ERROR("Filesystem not implemented");
|
||||
state = LoadFileResult::NO_FILESYSTEM;
|
||||
#endif
|
||||
return state;
|
||||
@@ -2250,7 +2250,7 @@ void NodeDB::loadFromDisk()
|
||||
spiLock->lock();
|
||||
for (const char *filename : eventProfileFiles) {
|
||||
if (FSCom.exists(filename) && !FSCom.remove(filename))
|
||||
LOG_WARN("Unable to remove stale event profile file %s", filename);
|
||||
LOG_WARN("Can't remove stale event profile file %s", filename);
|
||||
}
|
||||
spiLock->unlock();
|
||||
#endif
|
||||
@@ -2268,7 +2268,7 @@ void NodeDB::loadFromDisk()
|
||||
const size_t usedBytes = fsUsedBytes();
|
||||
eventProfileStorageUnavailable = !hasEventProfileStorageSpace(totalBytes, usedBytes);
|
||||
if (eventProfileStorageUnavailable) {
|
||||
LOG_ERROR("Event profile requires %u bytes free; only %u bytes available. Profile changes will not persist.",
|
||||
LOG_ERROR("Event profile needs %u bytes free; only %u available. Changes won't persist",
|
||||
static_cast<unsigned>(EVENT_PROFILE_STORAGE_RESERVATION_BYTES),
|
||||
static_cast<unsigned>(totalBytes >= usedBytes ? totalBytes - usedBytes : 0));
|
||||
}
|
||||
@@ -2292,7 +2292,7 @@ void NodeDB::loadFromDisk()
|
||||
#if defined(FACTORY_INSTALL) && !defined(ARCH_PORTDUINO)
|
||||
spiLock->lock();
|
||||
if (!FSCom.exists("/prefs/" xstr(BUILD_EPOCH))) {
|
||||
LOG_WARN("Factory Install Reset!");
|
||||
LOG_WARN("Factory Install Reset");
|
||||
rmDir("/prefs");
|
||||
FSCom.mkdir("/prefs");
|
||||
File f2 = FSCom.open("/prefs/" xstr(BUILD_EPOCH), FILE_O_WRITE);
|
||||
@@ -2306,11 +2306,11 @@ void NodeDB::loadFromDisk()
|
||||
spiLock->lock();
|
||||
if (FSCom.exists(legacyPrefFileName)) {
|
||||
spiLock->unlock();
|
||||
LOG_WARN("Legacy prefs version found, factory resetting");
|
||||
LOG_WARN("Legacy prefs version, factory reset");
|
||||
if (loadProto(configFileName, meshtastic_LocalConfig_size, sizeof(meshtastic_LocalConfig), &meshtastic_LocalConfig_msg,
|
||||
&config) == LoadFileResult::LOAD_SUCCESS &&
|
||||
config.has_security && config.security.private_key.size > 0) {
|
||||
LOG_DEBUG("Saving backup of security config and keys");
|
||||
LOG_DEBUG("Backup security config and keys");
|
||||
backupSecurity = config.security;
|
||||
}
|
||||
spiLock->lock();
|
||||
@@ -2331,7 +2331,7 @@ void NodeDB::loadFromDisk()
|
||||
// Encrypted storage is locked. Install defaults and wait for the
|
||||
// passphrase over BLE/serial; PhoneAPI::handleLockdownAuthInline
|
||||
// calls reloadFromDisk() once the storage is unlocked.
|
||||
LOG_WARN("NodeDB: Encrypted storage locked, using default config until unlocked");
|
||||
LOG_WARN("NodeDB: Encrypted storage locked, default config until unlocked");
|
||||
installDefaultNodeDatabase();
|
||||
installDefaultDeviceState();
|
||||
installDefaultConfig();
|
||||
@@ -2442,7 +2442,7 @@ void NodeDB::loadFromDisk()
|
||||
// Attempt recovery of owner fields from our own NodeDB entry if available.
|
||||
const meshtastic_NodeInfoLite *us = getMeshNode(getNodeNum());
|
||||
if (nodeInfoLiteHasUser(us)) {
|
||||
LOG_WARN("Restoring owner fields (long_name/short_name/is_licensed/is_unmessagable) from NodeDB for our node 0x%08x",
|
||||
LOG_WARN("Restore owner fields (long_name/short_name/is_licensed/is_unmessagable) from NodeDB for node 0x%08x",
|
||||
us->num);
|
||||
// owner.long_name (40) is wider than the lite source (25); bound by the source
|
||||
memcpy(owner.long_name, us->long_name, sizeof(us->long_name));
|
||||
@@ -2457,7 +2457,7 @@ void NodeDB::loadFromDisk()
|
||||
saveToDisk(SEGMENT_DEVICESTATE);
|
||||
}
|
||||
} else {
|
||||
LOG_INFO("Loaded saved devicestate version %d", devicestate.version);
|
||||
LOG_INFO("Loaded saved devicestate v%d", devicestate.version);
|
||||
}
|
||||
|
||||
// Devicestate saved by firmware that allowed 39-byte names gets clamped on
|
||||
@@ -2483,7 +2483,7 @@ void NodeDB::loadFromDisk()
|
||||
config.lora = eventLora;
|
||||
state = LoadFileResult::LOAD_SUCCESS;
|
||||
initializedEventConfig = true;
|
||||
LOG_INFO("Initialized event config without modifying %s", STANDARD_CONFIG_FILE_NAME);
|
||||
LOG_INFO("Init event config without modifying %s", STANDARD_CONFIG_FILE_NAME);
|
||||
} else {
|
||||
// Keep the event load outcome because loadProto() clears config before decoding.
|
||||
// A normal decode failure must not create a replacement identity.
|
||||
@@ -2497,7 +2497,7 @@ void NodeDB::loadFromDisk()
|
||||
// our NodeNum (== crc32(public_key)) and orphan us on the mesh. configDecodeFailed freezes identity and
|
||||
// skips persisting (see ctor), so a transient failure self-heals on the next clean boot. A genuinely
|
||||
// absent config returns OTHER_FAILURE, so this never fires on first boot. Boot degraded + radio-silent.
|
||||
LOG_ERROR("Config decode failed - freezing identity, booting degraded (radio silent until restored)");
|
||||
LOG_ERROR("Config decode failed - freeze identity, boot degraded (radio silent until restored)");
|
||||
configDecodeFailed = true;
|
||||
installDefaultConfig(true);
|
||||
config.lora.region = meshtastic_Config_LoRaConfig_RegionCode_UNSET;
|
||||
@@ -2510,7 +2510,7 @@ void NodeDB::loadFromDisk()
|
||||
LOG_WARN("config %d is old, discard", config.version);
|
||||
installDefaultConfig(true);
|
||||
} else {
|
||||
LOG_INFO("Loaded saved config version %d", config.version);
|
||||
LOG_INFO("Loaded saved config v%d", config.version);
|
||||
}
|
||||
configLoadComplete = true;
|
||||
|
||||
@@ -2558,12 +2558,12 @@ void NodeDB::loadFromDisk()
|
||||
// This is the first durable event-profile write. A failed write is
|
||||
// safe: normal files remain untouched and the next event boot retries.
|
||||
if (!saveToDisk(SEGMENT_CONFIG))
|
||||
LOG_ERROR("Unable to persist initial event config");
|
||||
LOG_ERROR("Can't persist initial event config");
|
||||
}
|
||||
#endif
|
||||
|
||||
if (backupSecurity.private_key.size > 0) {
|
||||
LOG_DEBUG("Restoring backup of security config");
|
||||
LOG_DEBUG("Restore security config backup");
|
||||
config.security = backupSecurity;
|
||||
saveToDisk(SEGMENT_CONFIG);
|
||||
}
|
||||
@@ -2582,7 +2582,7 @@ void NodeDB::loadFromDisk()
|
||||
}
|
||||
if (sum == 0) {
|
||||
numAdminKeys += 1;
|
||||
LOG_INFO("Admin 0 key zero. Loading hard coded key from user preferences.");
|
||||
LOG_INFO("Admin 0 key zero. Load hard coded key from user prefs");
|
||||
memcpy(config.security.admin_key[0].bytes, userprefs_admin_key_0, 32);
|
||||
config.security.admin_key[0].size = 32;
|
||||
}
|
||||
@@ -2595,7 +2595,7 @@ void NodeDB::loadFromDisk()
|
||||
}
|
||||
if (sum == 0) {
|
||||
numAdminKeys += 1;
|
||||
LOG_INFO("Admin 1 key zero. Loading hard coded key from user preferences.");
|
||||
LOG_INFO("Admin 1 key zero. Load hard coded key from user prefs");
|
||||
memcpy(config.security.admin_key[1].bytes, userprefs_admin_key_1, 32);
|
||||
config.security.admin_key[1].size = 32;
|
||||
}
|
||||
@@ -2608,14 +2608,14 @@ void NodeDB::loadFromDisk()
|
||||
}
|
||||
if (sum == 0) {
|
||||
numAdminKeys += 1;
|
||||
LOG_INFO("Admin 2 key zero. Loading hard coded key from user preferences.");
|
||||
LOG_INFO("Admin 2 key zero. Load hard coded key from user prefs");
|
||||
memcpy(config.security.admin_key[2].bytes, userprefs_admin_key_2, 32);
|
||||
config.security.admin_key[2].size = 32;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (numAdminKeys > 0) {
|
||||
LOG_INFO("Saving %d hard coded admin keys.", numAdminKeys);
|
||||
LOG_INFO("Saving %d hard coded admin keys", numAdminKeys);
|
||||
config.security.admin_key_count = numAdminKeys;
|
||||
saveToDisk(SEGMENT_CONFIG);
|
||||
}
|
||||
@@ -2629,7 +2629,7 @@ void NodeDB::loadFromDisk()
|
||||
LOG_WARN("moduleConfig %d is old, discard", moduleConfig.version);
|
||||
installDefaultModuleConfig();
|
||||
} else {
|
||||
LOG_INFO("Loaded saved moduleConfig version %d", moduleConfig.version);
|
||||
LOG_INFO("Loaded saved moduleConfig v%d", moduleConfig.version);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2652,7 +2652,7 @@ void NodeDB::loadFromDisk()
|
||||
LOG_WARN("channelFile %d is old, discard", channelFile.version);
|
||||
installDefaultChannels();
|
||||
} else {
|
||||
LOG_INFO("Loaded saved channelFile version %d", channelFile.version);
|
||||
LOG_INFO("Loaded saved channelFile v%d", channelFile.version);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2704,7 +2704,7 @@ void NodeDB::loadFromDisk()
|
||||
if (activeBackupExists && !EncryptedStorage::isEncrypted(backupFileName)) {
|
||||
LOG_INFO("Migrating %s to encrypted storage", backupFileName);
|
||||
if (!EncryptedStorage::migrateFile(backupFileName)) {
|
||||
LOG_ERROR("Unable to migrate %s to encrypted storage", backupFileName);
|
||||
LOG_ERROR("Can't migrate %s to encrypted storage", backupFileName);
|
||||
storageCorruptThisLoad = true;
|
||||
}
|
||||
}
|
||||
@@ -2723,7 +2723,7 @@ void NodeDB::loadFromDisk()
|
||||
if (exists && !EncryptedStorage::isEncrypted(fn)) {
|
||||
LOG_INFO("Migrating inactive radio profile %s to encrypted storage", fn);
|
||||
if (!EncryptedStorage::migrateFile(fn)) {
|
||||
LOG_ERROR("Unable to migrate %s to encrypted storage", fn);
|
||||
LOG_ERROR("Can't migrate %s to encrypted storage", fn);
|
||||
storageCorruptThisLoad = true;
|
||||
}
|
||||
}
|
||||
@@ -2735,7 +2735,7 @@ void NodeDB::loadFromDisk()
|
||||
|
||||
// 2.4.X - configuration migration to update new default intervals
|
||||
if (moduleConfig.version < 23) {
|
||||
LOG_DEBUG("ModuleConfig version %d is stale, upgrading to new default intervals", moduleConfig.version);
|
||||
LOG_DEBUG("ModuleConfig v%d stale, upgrade to new default intervals", moduleConfig.version);
|
||||
moduleConfig.version = DEVICESTATE_CUR_VER;
|
||||
if (moduleConfig.telemetry.device_update_interval == 900)
|
||||
moduleConfig.telemetry.device_update_interval = 0;
|
||||
@@ -2829,7 +2829,7 @@ bool NodeDB::reloadFromDisk()
|
||||
loadFromDisk();
|
||||
|
||||
if (storageCorruptThisLoad) {
|
||||
LOG_ERROR("NodeDB: storage decrypt/decode failed during reload - surfacing as corrupt");
|
||||
LOG_ERROR("NodeDB: reload decrypt/decode failed - treat as corrupt");
|
||||
// Leave the radio sleeping. Caller will lock storage and emit
|
||||
// a LOCKED(storage_corrupt) status; we must not reconfigure
|
||||
// the chip with the locked-default placeholder values still
|
||||
@@ -2874,7 +2874,7 @@ bool NodeDB::disableLockdownToPlaintext()
|
||||
moduleConfigFileName, deviceStateFileName, nodeDatabaseFileName};
|
||||
for (const char *fn : filesToCheck) {
|
||||
if (!EncryptedStorage::migrateFileToPlaintext(fn)) {
|
||||
LOG_ERROR("NodeDB: failed to revert %s to plaintext; aborting disable (device stays in lockdown)", fn);
|
||||
LOG_ERROR("NodeDB: revert %s to plaintext failed; abort disable (stays in lockdown)", fn);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -2903,7 +2903,7 @@ bool NodeDB::saveProto(const char *filename, size_t protoSize, const pb_msgdesc_
|
||||
// do not try to save anything if power level is not safe. In many cases flash will be lock-protected
|
||||
// and all writes will fail anyway. Device should be sleeping at this point anyway.
|
||||
if (!powerHAL_isPowerLevelSafe()) {
|
||||
LOG_ERROR("Error: trying to saveProto() on unsafe device power level.");
|
||||
LOG_ERROR("saveProto() on unsafe device power level");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -2925,7 +2925,7 @@ bool NodeDB::saveProto(const char *filename, size_t protoSize, const pb_msgdesc_
|
||||
|
||||
pb_ostream_t stream = pb_ostream_from_buffer(pbBuf.get(), protoSize);
|
||||
if (!pb_encode(&stream, fields, dest_struct)) {
|
||||
LOG_ERROR("Error: can't encode protobuf %s", PB_GET_ERROR(&stream));
|
||||
LOG_ERROR("Can't encode protobuf %s", PB_GET_ERROR(&stream));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -2933,7 +2933,7 @@ bool NodeDB::saveProto(const char *filename, size_t protoSize, const pb_msgdesc_
|
||||
bool ok = EncryptedStorage::encryptAndWrite(filename, pbBuf.get(), encodedSize, fullAtomic);
|
||||
|
||||
if (!ok) {
|
||||
LOG_ERROR("EncryptedStorage: Failed to encrypt and write %s", filename);
|
||||
LOG_ERROR("EncryptedStorage: encrypt+write %s failed", filename);
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
@@ -2947,7 +2947,7 @@ bool NodeDB::saveProto(const char *filename, size_t protoSize, const pb_msgdesc_
|
||||
pb_ostream_t stream = {&writecb, static_cast<Print *>(&f), protoSize};
|
||||
|
||||
if (!pb_encode(&stream, fields, dest_struct)) {
|
||||
LOG_ERROR("Error: can't encode protobuf %s", PB_GET_ERROR(&stream));
|
||||
LOG_ERROR("Can't encode protobuf %s", PB_GET_ERROR(&stream));
|
||||
} else {
|
||||
okay = true;
|
||||
}
|
||||
@@ -2955,10 +2955,10 @@ bool NodeDB::saveProto(const char *filename, size_t protoSize, const pb_msgdesc_
|
||||
bool writeSucceeded = f.close();
|
||||
|
||||
if (!okay || !writeSucceeded) {
|
||||
LOG_ERROR("Can't write prefs!");
|
||||
LOG_ERROR("Can't write prefs");
|
||||
}
|
||||
#else
|
||||
LOG_ERROR("ERROR: Filesystem not implemented");
|
||||
LOG_ERROR("Filesystem not implemented");
|
||||
#endif
|
||||
return okay;
|
||||
}
|
||||
@@ -2969,7 +2969,7 @@ bool NodeDB::saveChannelsToDisk()
|
||||
// do not try to save anything if power level is not safe. In many cases flash will be lock-protected
|
||||
// and all writes will fail anyway.
|
||||
if (!powerHAL_isPowerLevelSafe()) {
|
||||
LOG_ERROR("Error: trying to saveChannelsToDisk() on unsafe device power level.");
|
||||
LOG_ERROR("saveChannelsToDisk() on unsafe device power level");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -2988,7 +2988,7 @@ bool NodeDB::saveDeviceStateToDisk()
|
||||
// do not try to save anything if power level is not safe. In many cases flash will be lock-protected
|
||||
// and all writes will fail anyway. Device should be sleeping at this point anyway.
|
||||
if (!powerHAL_isPowerLevelSafe()) {
|
||||
LOG_ERROR("Error: trying to saveDeviceStateToDisk() on unsafe device power level.");
|
||||
LOG_ERROR("saveDeviceStateToDisk() on unsafe device power level");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -3016,7 +3016,7 @@ bool NodeDB::saveNodeDatabaseToDisk()
|
||||
// do not try to save anything if power level is not safe. In many cases flash will be lock-protected
|
||||
// and all writes will fail anyway. Device should be sleeping at this point anyway.
|
||||
if (!powerHAL_isPowerLevelSafe()) {
|
||||
LOG_ERROR("Error: trying to saveNodeDatabaseToDisk() on unsafe device power level.");
|
||||
LOG_ERROR("saveNodeDatabaseToDisk() on unsafe device power level");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -3024,7 +3024,7 @@ bool NodeDB::saveNodeDatabaseToDisk()
|
||||
// would propagate through saveToDisk() and trigger fsFormat() mid-transfer.
|
||||
#ifdef FSCom
|
||||
if (xModem.isBusy()) {
|
||||
LOG_DEBUG("Deferring NodeDB save: xmodem transfer in progress");
|
||||
LOG_DEBUG("Defer NodeDB save: xmodem in progress");
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
@@ -3125,7 +3125,7 @@ bool NodeDB::saveToDiskNoRetry(int saveWhat)
|
||||
// do not try to save anything if power level is not safe. In many cases flash will be lock-protected
|
||||
// and all writes will fail anyway. Device should be sleeping at this point anyway.
|
||||
if (!powerHAL_isPowerLevelSafe()) {
|
||||
LOG_ERROR("Error: trying to saveToDiskNoRetry() on unsafe device power level.");
|
||||
LOG_ERROR("saveToDiskNoRetry() on unsafe device power level");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -3155,11 +3155,11 @@ bool NodeDB::saveToDiskNoRetry(int saveWhat)
|
||||
#if USERPREFS_EVENT_MODE
|
||||
if (eventProfileStorageUnavailable) {
|
||||
if (saveWhat & SEGMENT_CONFIG) {
|
||||
LOG_WARN("Skipping event config write: insufficient profile storage at boot");
|
||||
LOG_WARN("Skip event config write: insufficient profile storage at boot");
|
||||
saveWhat &= ~SEGMENT_CONFIG;
|
||||
}
|
||||
if (saveWhat & SEGMENT_CHANNELS) {
|
||||
LOG_WARN("Skipping event channel write: insufficient profile storage at boot");
|
||||
LOG_WARN("Skip event channel write: insufficient profile storage at boot");
|
||||
saveWhat &= ~SEGMENT_CHANNELS;
|
||||
}
|
||||
}
|
||||
@@ -3223,14 +3223,14 @@ bool NodeDB::saveToDisk(int saveWhat)
|
||||
// do not try to save anything if power level is not safe. In many cases flash will be lock-protected
|
||||
// and all writes will fail anyway. Device should be sleeping at this point anyway.
|
||||
if (!powerHAL_isPowerLevelSafe()) {
|
||||
LOG_ERROR("Error: trying to saveToDisk() on unsafe device power level.");
|
||||
LOG_ERROR("saveToDisk() on unsafe device power level");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool success = saveToDiskNoRetry(saveWhat);
|
||||
|
||||
if (!success) {
|
||||
LOG_ERROR("Failed to save to disk, retrying");
|
||||
LOG_ERROR("Save to disk failed, retry");
|
||||
spiLock->lock();
|
||||
fsFormat();
|
||||
spiLock->unlock();
|
||||
@@ -3536,7 +3536,7 @@ bool NodeDB::updateUser(uint32_t nodeId, meshtastic_User &p, uint8_t channelInde
|
||||
// Only a signed update may change the identity of a proven signer; our own record is exempt.
|
||||
// Checked before getOrCreateMeshNode so a refusal cannot evict; isKnownXeddsaSigner covers the warm tier.
|
||||
if (nodeId != getNodeNum() && isKnownXeddsaSigner(nodeId) && !xeddsaSigned) {
|
||||
LOG_WARN("Refusing unsigned identity update for node 0x%08x that previously signed", nodeId);
|
||||
LOG_WARN("Refuse unsigned identity update for 0x%08x that previously signed", nodeId);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -3577,12 +3577,12 @@ bool NodeDB::updateUser(uint32_t nodeId, meshtastic_User &p, uint8_t channelInde
|
||||
if (info->public_key.size == 32) { // if we have a key for this user already, don't overwrite with a new one
|
||||
// if the key doesn't match, don't update nodeDB at all.
|
||||
if (p.public_key.size != 32 || (memcmp(p.public_key.bytes, info->public_key.bytes, 32) != 0)) {
|
||||
LOG_WARN("Public Key mismatch, dropping NodeInfo");
|
||||
LOG_WARN("Public Key mismatch, drop NodeInfo");
|
||||
return false;
|
||||
}
|
||||
LOG_INFO("Public Key set for node, not updating!");
|
||||
LOG_INFO("Public Key set, not updating");
|
||||
} else if (p.public_key.size == 32) {
|
||||
LOG_INFO("Update Node Pubkey!");
|
||||
LOG_INFO("Update Node Pubkey");
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -3617,7 +3617,7 @@ bool NodeDB::updateUser(uint32_t nodeId, meshtastic_User &p, uint8_t channelInde
|
||||
saveToDisk(SEGMENT_NODEDATABASE);
|
||||
lastNodeDbSave = millis();
|
||||
} else {
|
||||
LOG_DEBUG("Defer NodeDB saveToDisk for now");
|
||||
LOG_DEBUG("Defer NodeDB saveToDisk");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3851,7 +3851,7 @@ void NodeDB::sortMeshDB()
|
||||
}
|
||||
}
|
||||
}
|
||||
LOG_INFO("Sort took %u milliseconds", millis() - lastSort);
|
||||
LOG_INFO("Sort took %u ms", millis() - lastSort);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4091,8 +4091,7 @@ meshtastic_NodeInfoLite *NodeDB::getOrCreateMeshNode(NodeNum n)
|
||||
|
||||
if (!lite) {
|
||||
if (isFull()) {
|
||||
LOG_INFO("Node database full with %i nodes and %u bytes free. Erasing oldest entry", numMeshNodes,
|
||||
memGet.getFreeHeap());
|
||||
LOG_INFO("Node database full: %i nodes, %u bytes free. Erase oldest", numMeshNodes, memGet.getFreeHeap());
|
||||
// look for oldest node and erase it
|
||||
uint32_t oldest = UINT32_MAX;
|
||||
uint32_t oldestBoring = UINT32_MAX;
|
||||
@@ -4187,7 +4186,7 @@ meshtastic_NodeInfoLite *NodeDB::getOrCreateMeshNode(NodeNum n)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
LOG_INFO("Adding node to database with %i nodes and %u bytes free!", numMeshNodes, memGet.getFreeHeap());
|
||||
LOG_INFO("Add node to database: %i nodes, %u bytes free", numMeshNodes, memGet.getFreeHeap());
|
||||
}
|
||||
|
||||
return lite;
|
||||
@@ -4264,14 +4263,14 @@ bool NodeDB::generateCryptoKeyPair(const uint8_t *privateKey)
|
||||
if (crypto->regeneratePublicKey(config.security.public_key.bytes, config.security.private_key.bytes)) {
|
||||
keygenSuccess = true;
|
||||
} else {
|
||||
LOG_ERROR("Failed to generate public key from provided private key");
|
||||
LOG_ERROR("Can't generate public key from private key");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// Try to regenerate public key from existing private key if it's valid and not low entropy
|
||||
else if (config.security.private_key.size == 32 && !keyIsLowEntropy) {
|
||||
config.security.public_key.size = 32;
|
||||
LOG_DEBUG("Regenerate PKI public key from existing private key");
|
||||
LOG_DEBUG("Regenerate PKI public key from private key");
|
||||
if (crypto->regeneratePublicKey(config.security.public_key.bytes, config.security.private_key.bytes)) {
|
||||
keygenSuccess = true;
|
||||
}
|
||||
@@ -4331,7 +4330,7 @@ bool NodeDB::createNewIdentity()
|
||||
// still streamed to clients, and made any DM/admin aimed at it fail forever with PKI_SEND_FAIL_PUBLIC_KEY.
|
||||
// removeNodeByNum() drops the lite entry, its satellite stores, and the warm-tier copy.
|
||||
if (getMeshNode(oldNodeNum) != NULL) {
|
||||
LOG_DEBUG("Old node num %u is now %u, removing stale identity", oldNodeNum, newNodeNum);
|
||||
LOG_DEBUG("Old node num 0x%08x now 0x%08x, remove stale identity", oldNodeNum, newNodeNum);
|
||||
removeNodeByNum(oldNodeNum);
|
||||
} else {
|
||||
// Lite entry already absent: drop any orphaned satellite-store entries directly.
|
||||
@@ -4377,7 +4376,7 @@ bool NodeDB::backupPreferences(meshtastic_AdminMessage_BackupLocation location)
|
||||
if (success) {
|
||||
LOG_INFO("Saved backup preferences");
|
||||
} else {
|
||||
LOG_ERROR("Failed to save backup preferences to file");
|
||||
LOG_ERROR("Save backup prefs to file failed");
|
||||
}
|
||||
} else if (location == meshtastic_AdminMessage_BackupLocation_SD) {
|
||||
// TODO: After more mainline SD card support
|
||||
@@ -4394,7 +4393,7 @@ bool NodeDB::restorePreferences(meshtastic_AdminMessage_BackupLocation location,
|
||||
spiLock->lock();
|
||||
if (!FSCom.exists(backupFileName)) {
|
||||
spiLock->unlock();
|
||||
LOG_WARN("Could not restore. No backup file found");
|
||||
LOG_WARN("Can't restore, no backup file");
|
||||
return false;
|
||||
} else {
|
||||
spiLock->unlock();
|
||||
@@ -4429,12 +4428,12 @@ bool NodeDB::restorePreferences(meshtastic_AdminMessage_BackupLocation location,
|
||||
|
||||
success = saveToDisk(restoreWhat);
|
||||
if (success) {
|
||||
LOG_INFO("Restored preferences from backup");
|
||||
LOG_INFO("Restored prefs from backup");
|
||||
} else {
|
||||
LOG_ERROR("Failed to save restored preferences to flash");
|
||||
LOG_ERROR("Save restored prefs to flash failed");
|
||||
}
|
||||
} else {
|
||||
LOG_ERROR("Failed to restore preferences from backup file");
|
||||
LOG_ERROR("Restore prefs from backup failed");
|
||||
}
|
||||
} else if (location == meshtastic_AdminMessage_BackupLocation_SD) {
|
||||
// TODO: After more mainline SD card support
|
||||
@@ -4458,7 +4457,7 @@ void recordCriticalError(meshtastic_CriticalErrorCode code, uint32_t address, co
|
||||
|
||||
// Currently portuino is mostly used for simulation. Make sure the user notices something really bad happened
|
||||
#ifdef ARCH_PORTDUINO
|
||||
LOG_ERROR("A critical failure occurred");
|
||||
LOG_ERROR("Critical failure");
|
||||
// TODO: Determine if other critical errors should also cause an immediate exit
|
||||
if (code == meshtastic_CriticalErrorCode_FLASH_CORRUPTION_RECOVERABLE ||
|
||||
code == meshtastic_CriticalErrorCode_FLASH_CORRUPTION_UNRECOVERABLE)
|
||||
|
||||
Reference in New Issue
Block a user