diff --git a/Firmware/LoRaSerial/Commands.ino b/Firmware/LoRaSerial/Commands.ino index ac8b1cdf..35f21e29 100644 --- a/Firmware/LoRaSerial/Commands.ino +++ b/Firmware/LoRaSerial/Commands.ino @@ -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 diff --git a/Firmware/LoRaSerial/LoRaSerial.ino b/Firmware/LoRaSerial/LoRaSerial.ino index 02345167..718cafbc 100644 --- a/Firmware/LoRaSerial/LoRaSerial.ino +++ b/Firmware/LoRaSerial/LoRaSerial.ino @@ -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" diff --git a/Firmware/LoRaSerial/Train.ino b/Firmware/LoRaSerial/Train.ino index bb8ae162..2333c1f4 100644 --- a/Firmware/LoRaSerial/Train.ino +++ b/Firmware/LoRaSerial/Train.ino @@ -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)) { @@ -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); diff --git a/Firmware/LoRaSerial/settings.h b/Firmware/LoRaSerial/settings.h index f0bae7e3..77df43bb 100644 --- a/Firmware/LoRaSerial/settings.h +++ b/Firmware/LoRaSerial/settings.h @@ -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, @@ -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 {