diff --git a/Firmware/LoRaSerial/NVM.ino b/Firmware/LoRaSerial/NVM.ino index 46460446..5eb7e703 100644 --- a/Firmware/LoRaSerial/NVM.ino +++ b/Firmware/LoRaSerial/NVM.ino @@ -198,3 +198,29 @@ void nvmSaveVcUniqueId(int8_t vc) if (memcmp(id, virtualCircuitList[vc].uniqueId, sizeof(id)) != 0) nvmSaveUniqueId(vc, virtualCircuitList[vc].uniqueId); } + +//Erase the entire EEPROM +void nvmErase() +{ + int address; + int length; + uint8_t value[64]; + + //Get the EEPROM length + length = EEPROM.length(); + + //Set the erase value + memset(&value, NVM_ERASE_VALUE, sizeof(value)); + + //Erase the EEPROM + address = 0; + while (address < length) + { + petWDT(); + EEPROM.put(address, value); + address += sizeof(value); + } + + //Finish the write + arch.eepromCommit(); +} diff --git a/Firmware/LoRaSerial/States.ino b/Firmware/LoRaSerial/States.ino index 8e519494..e7ec6b54 100644 --- a/Firmware/LoRaSerial/States.ino +++ b/Firmware/LoRaSerial/States.ino @@ -1483,33 +1483,43 @@ void updateRadioState() //=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= /* - beginTrainingClient - | - | Save current settings - | - V - +<--------------------------------. - | | - | Send FIND_PARTNER | - | | - V | - RADIO_TRAIN_WAIT_TX_FIND_PARTNER_DONE | - | | - V | Timeout - RADIO_TRAIN_WAIT_RX_RADIO_PARAMETERS -----' - | - | Save settings - | Send ACK + + 2 Second Button Press ATT Command + | | + | | + +--------------------------------------------' | V - RADIO_TRAIN_WAIT_TX_ACK_DONE + commandSaveSettings | V - endTrainingClientServer - | - | Reboot + beginTrainingClient | V + +<--------------------------------------. + | | + | Send FIND_PARTNER | + | | Timeout + V | + RADIO_TRAIN_WAIT_TX_FIND_PARTNER_DONE | + | | + V | + RADIO_TRAIN_WAIT_RX_RADIO_PARAMETERS ---------->+ + | | + | RX RADIO_PARAMETERS | + | ATO | or 2 Second + | Send ACK ATZ | Button Push + V | && (! Command Mode) + RADIO_TRAIN_WAIT_TX_ACK_DONE | + | V + V commandRestoreSettings(writeOnCommandExit) + endTrainingClientServer | + | | + | | + | commandRestoreSettings(true) | + V V + Reboot Return to + Previous mode */ //==================== @@ -1629,9 +1639,19 @@ void updateRadioState() //=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= /* - beginTrainingServer + + Command Mode 5 second button press + | | + | ATT | + | | + V | + +<---------------------' + | + V + commandSaveSettings | - | Save current settings + V + beginTrainingServer | V +<--------------------------------. @@ -1645,12 +1665,21 @@ void updateRadioState() | RADIO_TRAIN_WAIT_TX_RADIO_PARAMS_DONE -----' | | + | ATO, ATZ or (2 second training button press && ! command mode) + | `---------------. - | ATZ command | - | Reboot + V + commandRestoreSettings(writeOnCommandExit) | V + +----------------------------. + | | + | ATZ command | ATO command + | | + V V + Reboot Return to + Previous Mode */ //====================