Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions Firmware/LoRaSerial/NVM.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
79 changes: 54 additions & 25 deletions Firmware/LoRaSerial/States.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/

//====================
Expand Down Expand Up @@ -1629,9 +1639,19 @@ void updateRadioState()
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

/*
beginTrainingServer

Command Mode 5 second button press
| |
| ATT |
| |
V |
+<---------------------'
|
V
commandSaveSettings
|
| Save current settings
V
beginTrainingServer
|
V
+<--------------------------------.
Expand All @@ -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
*/

//====================
Expand Down