mirror of
https://github.com/alexhopeoconnor/firmware.git
synced 2026-10-17 00:51:30 +10:00
Merge branch 'master' into backup-restore
This commit is contained in:
+31
-5
@@ -400,9 +400,16 @@ bool isBroadcast(uint32_t dest)
|
||||
return dest == NODENUM_BROADCAST || dest == NODENUM_BROADCAST_NO_LORA;
|
||||
}
|
||||
|
||||
void NodeDB::resetRadioConfig()
|
||||
void NodeDB::resetRadioConfig(bool is_fresh_install)
|
||||
{
|
||||
bool didFactoryReset = false;
|
||||
|
||||
radioGeneration++;
|
||||
|
||||
if (is_fresh_install) {
|
||||
radioGeneration++;
|
||||
}
|
||||
|
||||
if (channelFile.channels_count != MAX_NUM_CHANNELS) {
|
||||
LOG_INFO("Set default channel and radio preferences!");
|
||||
|
||||
@@ -411,6 +418,13 @@ void NodeDB::resetRadioConfig()
|
||||
channels.onConfigChanged();
|
||||
// Update the global myRegion
|
||||
initRegion();
|
||||
|
||||
#if (defined(T_DECK) || defined(T_WATCH_S3) || defined(UNPHONE) || defined(PICOMPUTER_S3)) && HAS_TFT
|
||||
// as long as PhoneAPI shares BT and TFT app switch BT off
|
||||
config.bluetooth.enabled = false;
|
||||
if (moduleConfig.external_notification.nag_timeout == 60)
|
||||
moduleConfig.external_notification.nag_timeout = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool NodeDB::factoryReset(bool eraseBleBonds)
|
||||
@@ -561,14 +575,18 @@ void NodeDB::installDefaultConfig(bool preserveKey = false)
|
||||
#else
|
||||
config.position.gps_mode = meshtastic_Config_PositionConfig_GpsMode_ENABLED;
|
||||
#endif
|
||||
#ifdef USERPREFS_CONFIG_SMART_POSITION_ENABLED
|
||||
config.position.position_broadcast_smart_enabled = USERPREFS_CONFIG_SMART_POSITION_ENABLED;
|
||||
#else
|
||||
config.position.position_broadcast_smart_enabled = true;
|
||||
#endif
|
||||
config.position.broadcast_smart_minimum_distance = 100;
|
||||
config.position.broadcast_smart_minimum_interval_secs = 30;
|
||||
if (config.device.role != meshtastic_Config_DeviceConfig_Role_ROUTER)
|
||||
config.device.node_info_broadcast_secs = default_node_info_broadcast_secs;
|
||||
config.security.serial_enabled = true;
|
||||
config.security.admin_channel_enabled = false;
|
||||
resetRadioConfig();
|
||||
resetRadioConfig(false, true); // This also triggers NodeInfo/Position requests since we're fresh
|
||||
strncpy(config.network.ntp_server, "meshtastic.pool.ntp.org", 32);
|
||||
|
||||
#if (defined(T_DECK) || defined(T_WATCH_S3) || defined(UNPHONE) || defined(PICOMPUTER_S3) || defined(SENSECAP_INDICATOR)) && \
|
||||
@@ -631,8 +649,16 @@ void NodeDB::installDefaultConfig(bool preserveKey = false)
|
||||
|
||||
void NodeDB::initConfigIntervals()
|
||||
{
|
||||
#ifdef USERPREFS_CONFIG_GPS_UPDATE_INTERVAL
|
||||
config.position.gps_update_interval = USERPREFS_CONFIG_GPS_UPDATE_INTERVAL;
|
||||
#else
|
||||
config.position.gps_update_interval = default_gps_update_interval;
|
||||
#endif
|
||||
#ifdef USERPREFS_CONFIG_POSITION_BROADCAST_INTERVAL
|
||||
config.position.position_broadcast_secs = USERPREFS_CONFIG_POSITION_BROADCAST_INTERVAL;
|
||||
#else
|
||||
config.position.position_broadcast_secs = default_broadcast_interval_secs;
|
||||
#endif
|
||||
|
||||
config.power.ls_secs = default_ls_secs;
|
||||
config.power.min_wake_secs = default_min_wake_secs;
|
||||
@@ -874,12 +900,12 @@ void NodeDB::installDefaultDeviceState()
|
||||
// Set default owner name
|
||||
pickNewNodeNum(); // based on macaddr now
|
||||
#ifdef USERPREFS_CONFIG_OWNER_LONG_NAME
|
||||
snprintf(owner.long_name, sizeof(owner.long_name), USERPREFS_CONFIG_OWNER_LONG_NAME);
|
||||
snprintf(owner.long_name, sizeof(owner.long_name), (const char *)USERPREFS_CONFIG_OWNER_LONG_NAME);
|
||||
#else
|
||||
snprintf(owner.long_name, sizeof(owner.long_name), "Meshtastic %04x", getNodeNum() & 0x0ffff);
|
||||
#endif
|
||||
#ifdef USERPREFS_CONFIG_OWNER_SHORT_NAME
|
||||
snprintf(owner.short_name, sizeof(owner.short_name), USERPREFS_CONFIG_OWNER_SHORT_NAME);
|
||||
snprintf(owner.short_name, sizeof(owner.short_name), (const char *)USERPREFS_CONFIG_OWNER_SHORT_NAME);
|
||||
#else
|
||||
snprintf(owner.short_name, sizeof(owner.short_name), "%04x", getNodeNum() & 0x0ffff);
|
||||
#endif
|
||||
@@ -1697,4 +1723,4 @@ void recordCriticalError(meshtastic_CriticalErrorCode code, uint32_t address, co
|
||||
LOG_ERROR("A critical failure occurred, portduino is exiting");
|
||||
exit(2);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user