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
2 changes: 1 addition & 1 deletion Firmware/LoRaSerial/Commands.ino
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ bool commandAT(const char * commandString)
return true;

case ('G'): //ATG - Generate a new netID and encryption key
generateRandomKeysID();
generateRandomKeysID(&tempSettings);
return true;

case ('I'): //ATI
Expand Down
1 change: 1 addition & 0 deletions Firmware/LoRaSerial/LoRaSerial.ino
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,7 @@ unsigned long retransmitTimeout = 0; //Throttle back re-transmits
//Global variables
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
const Settings defaultSettings;
Settings settings; //Active settings used by the radio
Settings tempSettings; //Create a duplicate of settings during training so that we can resort as needed

char platformPrefix[25]; //Used for printing platform specific device name, ie "SAMD21 1W 915MHz"
Expand Down
10 changes: 5 additions & 5 deletions Firmware/LoRaSerial/Train.ino
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ void selectTraining()
//Generate new netID/AES key to share
//We assume the user needs to maintain their settings (airSpeed, numberOfChannels, freq min/max, bandwidth/spread/hop)
//but need to be on a different netID/AES key.
void generateRandomKeysID()
void generateRandomKeysID(Settings * radioSettings)
{
if ((settings.debug == true) || (settings.debugTraining == true))
{
Expand All @@ -22,24 +22,24 @@ void generateRandomKeysID()
randomSeed(radio.randomByte());

//Generate new NetID
settings.netID = random(0, 256); //Inclusive, exclusive
radioSettings->netID = random(0, 256); //Inclusive, exclusive

//Generate new AES Key. User may not be using AES but we still need both radios to have the same key in case they do enable AES.
for (int x = 0 ; x < 16 ; x++)
settings.encryptionKey[x] = random(0, 256); //Inclusive, exclusive
radioSettings->encryptionKey[x] = random(0, 256); //Inclusive, exclusive

//We do not generate new AES Initial Values here. Those are generated during generateHopTable() based on the unit's settings.

if ((settings.debug == true) || (settings.debugTraining == true))
{
systemPrint("Select new NetID: ");
systemPrintln(settings.netID);
systemPrintln(radioSettings->netID);

systemPrint("Select new Encryption Key:");
for (uint8_t i = 0 ; i < 16 ; i++)
{
systemPrint(" ");
systemPrint(settings.encryptionKey[i], HEX);
systemPrint(radioSettings->encryptionKey[i], HEX);
}
systemPrintln();
outputSerialData(true);
Expand Down
3 changes: 1 addition & 2 deletions Firmware/LoRaSerial/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ typedef enum
RADIO_DISCOVER_SCANNING,
RADIO_DISCOVER_WAIT_TX_FIND_PARTNER_DONE,
RADIO_DISCOVER_STANDBY,

//Multi-Point: Datagrams
RADIO_MP_STANDBY,
RADIO_MP_WAIT_TX_DONE,
Expand Down Expand Up @@ -518,7 +518,6 @@ typedef struct struct_settings {
//-- Add commands to set the parameters
//-- Add parameters to routine updateRadioParameters
} Settings;
Settings settings;

//Monitor which devices on the device are on or offline.
struct struct_online {
Expand Down