Skip to content

Commit e47e68e

Browse files
committed
Separate the default settings from the values in settings.h
1 parent 546da66 commit e47e68e

File tree

4 files changed

+23
-3
lines changed

4 files changed

+23
-3
lines changed

Firmware/LoRaSerial/Commands.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ bool commandAT(const char * commandString)
130130
return true;
131131

132132
case ('F'): //ATF - Restore default parameters
133-
settings = defaultSettings; //Overwrite all system settings with defaults
133+
getDefaultSettings(&settings); //Overwrite all system settings with defaults
134134

135135
validateSettings(); //Modify defaults for each radio type (915, 868, 433, etc)
136136

Firmware/LoRaSerial/LoRaSerial.ino

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,6 @@ unsigned long retransmitTimeout = 0; //Throttle back re-transmits
518518

519519
//Global variables
520520
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
521-
const Settings defaultSettings;
522521
Settings settings; //Active settings used by the radio
523522
Settings tempSettings; //Temporary settings used for command processing
524523
Settings trainingSettings; //Settings used for training other radios
@@ -629,6 +628,15 @@ void setup()
629628
arch.beginBoard(); //Initialize the board specific hardware, and ID platform type
630629

631630
loadSettings(); //Load settings from EEPROM
631+
632+
//Use the current radio settings if they are already set
633+
if (!settings.radioBandwidth)
634+
{
635+
//Set the initial radio parameters
636+
getDefaultSettings(&settings);
637+
recordSystemSettings();
638+
}
639+
632640
serialOperatingMode = settings.operatingMode;
633641

634642
beginSerial(settings.serialSpeed);

Firmware/LoRaSerial/NVM.ino

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ void loadSettings()
33
{
44
arch.eepromBegin();
55

6+
//Use the default settings
7+
getDefaultSettings(&settings);
8+
69
//Check to see if EEPROM is blank
710
uint32_t testRead = 0;
811
if (EEPROM.get(0, testRead) == 0xFFFFFFFF)
@@ -55,6 +58,15 @@ void loadSettings()
5558
recordSystemSettings();
5659
}
5760

61+
//Merge the default settings with the default radio settings
62+
void getDefaultSettings(Settings * newSettings)
63+
{
64+
const Settings defaultSettings;
65+
66+
//Set the initial radio parameters
67+
*newSettings = defaultSettings;
68+
}
69+
5870
//Modify defaults for each radio type (915, 868, 433, etc)
5971
//Confirm various settings are within regulatory bounds
6072
void validateSettings()

Firmware/LoRaSerial/Train.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ void beginTrainingServer()
101101
void commonTrainingInitialization()
102102
{
103103
//Use common radio settings between the client and server for training
104-
settings = defaultSettings;
104+
getDefaultSettings(&settings);
105105
settings.dataScrambling = true; //Scramble the data
106106
settings.enableCRC16 = true; //Use CRC-16
107107
settings.encryptData = true; //Enable packet encryption

0 commit comments

Comments
 (0)