diff --git a/Firmware/LoRaSerial/Commands.ino b/Firmware/LoRaSerial/Commands.ino index 80495997..d8e25ef1 100644 --- a/Firmware/LoRaSerial/Commands.ino +++ b/Firmware/LoRaSerial/Commands.ino @@ -130,7 +130,7 @@ bool commandAT(const char * commandString) return true; case ('F'): //ATF - Restore default parameters - settings = defaultSettings; //Overwrite all system settings with defaults + getDefaultSettings(&settings); //Overwrite all system settings with defaults validateSettings(); //Modify defaults for each radio type (915, 868, 433, etc) diff --git a/Firmware/LoRaSerial/LoRaSerial.ino b/Firmware/LoRaSerial/LoRaSerial.ino index 4f688231..dfad1fb7 100644 --- a/Firmware/LoRaSerial/LoRaSerial.ino +++ b/Firmware/LoRaSerial/LoRaSerial.ino @@ -518,7 +518,6 @@ unsigned long retransmitTimeout = 0; //Throttle back re-transmits //Global variables //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -const Settings defaultSettings; Settings settings; //Active settings used by the radio Settings tempSettings; //Temporary settings used for command processing Settings trainingSettings; //Settings used for training other radios @@ -629,6 +628,15 @@ void setup() arch.beginBoard(); //Initialize the board specific hardware, and ID platform type loadSettings(); //Load settings from EEPROM + + //Use the current radio settings if they are already set + if (!settings.radioBandwidth) + { + //Set the initial radio parameters + getDefaultSettings(&settings); + recordSystemSettings(); + } + serialOperatingMode = settings.operatingMode; beginSerial(settings.serialSpeed); diff --git a/Firmware/LoRaSerial/NVM.ino b/Firmware/LoRaSerial/NVM.ino index 5eb7e703..7d6e007b 100644 --- a/Firmware/LoRaSerial/NVM.ino +++ b/Firmware/LoRaSerial/NVM.ino @@ -3,6 +3,9 @@ void loadSettings() { arch.eepromBegin(); + //Use the default settings + getDefaultSettings(&settings); + //Check to see if EEPROM is blank uint32_t testRead = 0; if (EEPROM.get(0, testRead) == 0xFFFFFFFF) @@ -55,6 +58,15 @@ void loadSettings() recordSystemSettings(); } +//Merge the default settings with the default radio settings +void getDefaultSettings(Settings * newSettings) +{ + const Settings defaultSettings; + + //Set the initial radio parameters + *newSettings = defaultSettings; +} + //Modify defaults for each radio type (915, 868, 433, etc) //Confirm various settings are within regulatory bounds void validateSettings() diff --git a/Firmware/LoRaSerial/System.ino b/Firmware/LoRaSerial/System.ino index 0da76963..d87939c6 100644 --- a/Firmware/LoRaSerial/System.ino +++ b/Firmware/LoRaSerial/System.ino @@ -985,8 +985,7 @@ void multiPointLeds() blinkRadioRssiLed(); //Update the hop LED - if ((millis() - radioCallHistory[RADIO_CALL_hopChannel]) >= RADIO_USE_BLINK_MILLIS) - digitalWrite(YELLOW_LED, LED_OFF); + blinkChannelHopLed(false); //Update the HEARTBEAT LED blinkHeartbeatLed(false); @@ -1006,8 +1005,7 @@ void p2pLeds() //Leave the LINK LED (GREEN_LED_2) off //Update the hop LED - if ((millis() - radioCallHistory[RADIO_CALL_hopChannel]) >= RADIO_USE_BLINK_MILLIS) - digitalWrite(YELLOW_LED, LED_OFF); + blinkChannelHopLed(false); //Update the HEARTBEAT LED blinkHeartbeatLed(false); @@ -1049,8 +1047,7 @@ void vcLeds() //Serial RX displayed on the LINK LED (GREEN_LED_2) by blinkSerialRxLed //Update the hop LED - if ((millis() - radioCallHistory[RADIO_CALL_hopChannel]) >= RADIO_USE_BLINK_MILLIS) - digitalWrite(YELLOW_LED, LED_OFF); + blinkChannelHopLed(false); //Update the HEARTBEAT LED blinkHeartbeatLed(false); diff --git a/Firmware/LoRaSerial/Train.ino b/Firmware/LoRaSerial/Train.ino index 1e2bb312..1da7d882 100644 --- a/Firmware/LoRaSerial/Train.ino +++ b/Firmware/LoRaSerial/Train.ino @@ -101,7 +101,7 @@ void beginTrainingServer() void commonTrainingInitialization() { //Use common radio settings between the client and server for training - settings = defaultSettings; + getDefaultSettings(&settings); settings.dataScrambling = true; //Scramble the data settings.enableCRC16 = true; //Use CRC-16 settings.encryptData = true; //Enable packet encryption