Skip to content
Open
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
75 changes: 0 additions & 75 deletions Firmware/LoRaSerial/Begin.ino
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,6 @@ void blinkStartup()

//=========================================================================================

//Initialize the radio layer
void beginLoRa()
{
radio = arch.radio();

float centerFreq = (settings.frequencyMax - settings.frequencyMin) / 2;
centerFreq += settings.frequencyMin;

int state = radio.begin(centerFreq); //Doesn't matter what freq we start at
if (state != RADIOLIB_ERR_NONE)
{
systemPrint("Radio init failed with code: ");
systemPrintln(state);
waitForever("Radio init failed!");
}

changeState(RADIO_RESET);
}

//=========================================================================================

//Initialize the button driver
void beginButton()
{
Expand Down Expand Up @@ -94,57 +73,3 @@ void petWDT()
arch.petWDT();
}
}

//=========================================================================================

void CheckChannelHopAndKickWatchdog(void)
{
if (timeToHop == true) //If the channelTimer has expired, move to next frequency
hopChannel();

petWDT();
}

//=========================================================================================

void CheckChannelHop(void)
{
if (timeToHop == true) //If the channelTimer has expired, move to next frequency
hopChannel();
}

//=========================================================================================

//Start the timer measuring the dwell interval and indicating that it is time to
//hop channels
void beginChannelTimer()
{
if (channelTimer.attachInterruptInterval_MS(settings.maxDwellTime, channelTimerHandler) == false)
systemPrintln("Error starting ChannelTimer!");

stopChannelTimer(); //Start timer in state machine - beginChannelTimer
}

//=========================================================================================

//ISR that fires when channel timer expires
void channelTimerHandler()
{
channelTimerStart = millis(); //Record when this ISR happened. Used for calculating clock sync.
radioCallHistory[RADIO_CALL_channelTimerHandler] = channelTimerStart;

//If the last timer was used to sync clocks, restore full timer interval
if (reloadChannelTimer == true)
{
reloadChannelTimer = false;
channelTimer.setInterval_MS(settings.maxDwellTime, channelTimerHandler);
channelTimerMsec = settings.maxDwellTime; //ISR update
}

if (settings.frequencyHop)
{
digitalWrite(pin_hop_timer, ((channelNumber + 1) % settings.numberOfChannels) & 1);
triggerEvent(TRIGGER_CHANNEL_TIMER_ISR);
timeToHop = true;
}
}
12 changes: 4 additions & 8 deletions Firmware/LoRaSerial/Commands.ino
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ bool commandAT(const char * commandString)
systemPrintln(" ATI1 - Show board variant");
systemPrintln(" ATI2 - Show firmware version");
systemPrintln(" ATI3 - Display RSSI value");
systemPrintln(" ATI4 - Get random byte from RSSI");
systemPrintln(" ATI5 - Show max possible bytes per second");
systemPrintln(" ATI6 - Display AES key");
systemPrintln(" ATI7 - Show current FHSS channel");
Expand Down Expand Up @@ -258,11 +257,7 @@ bool commandAT(const char * commandString)
return true;

case ('3'): //ATI3 - Display latest RSSI
systemPrintln(radio.getRSSI());
return true;

case ('4'): //ATI4 - Get random byte from RSSI
systemPrintln(radio.randomByte());
systemPrintln(radioGetRSSI());
return true;

case ('5'): //ATI5 - Show max possible bytes per second
Expand Down Expand Up @@ -559,12 +554,12 @@ bool commandAT(const char * commandString)
}
else
systemPrintln("None");
systemPrint(" radio.startReceive Failure: ");
systemPrint(" radioStartReceive Failure: ");
if (startReceiveFailureMillis)
{
systemPrintTimestamp(startReceiveFailureMillis + timestampOffset);
systemPrintln();
systemPrint(" radio.startReceive Status: ");
systemPrint(" radioStartReceive Status: ");
systemPrintln(startReceiveFailureState);
}
else
Expand Down Expand Up @@ -1375,6 +1370,7 @@ const COMMAND_ENTRY commands[] =
{'P', 1, 0, 0, 1, 0, TYPE_BOOL, valInt, "CopyTriggers", &tempSettings.copyTriggers},
{'P', 1, 0, 0, 0xffffffff, 0, TYPE_U32, valInt, "TriggerEnable_31-0", &tempSettings.triggerEnable},
{'P', 1, 0, 0, 0xffffffff, 0, TYPE_U32, valInt, "TriggerEnable_63-32", &tempSettings.triggerEnable2},
{'P', 1, 0, 0, 0xffffffff, 0, TYPE_U32, valInt, "TriggerEnable_95-64", &tempSettings.triggerEnable3},
{'P', 1, 0, 1, 255, 0, TYPE_U8, valInt, "TriggerWidth", &tempSettings.triggerWidth},
{'P', 1, 0, 0, 1, 0, TYPE_BOOL, valInt, "TriggerWidthIsMultiplier", &tempSettings.triggerWidthIsMultiplier},

Expand Down
6 changes: 1 addition & 5 deletions Firmware/LoRaSerial/LoRaSerial.ino
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ uint8_t pin_hop_timer = PIN_UNDEFINED;
//Radio Library
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
#include <RadioLib.h> //Click here to get the library: http://librarymanager/All#RadioLib v5.6.0
SX1276 radio = NULL; //We can't instantiate here because we don't yet know what pin numbers to use

float *channels;
uint8_t channelNumber = 0;
Expand Down Expand Up @@ -190,7 +189,6 @@ bool inTraining; //True if training is in process
SAMDTimer channelTimer(TIMER_TCC); //Available: TC3, TC4, TC5, TCC, TCC1 or TCC2
volatile uint16_t channelTimerMsec; //Last value programmed into the channel timer
volatile unsigned long channelTimerStart = 0; //Tracks how long our timer has been running since last hop
volatile bool timeToHop = false; //Set by channelTimerHandler to indicate that hopChannel needs to be called
volatile bool reloadChannelTimer = false; //When set channel timer interval needs to be reloaded with settings.maxDwellTime
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Expand Down Expand Up @@ -658,12 +656,10 @@ void setup()

arch.uniqueID(myUniqueId); //Get the unique ID

beginLoRa(); //Start radio
radioBeginLoRa(); //Start radio

beginButton(); //Start watching the train button

beginChannelTimer(); //Setup (but do not start) hardware timer for channel hopping

updateRTS(true); //We're ready for more data

systemPrintTimestamp();
Expand Down
Loading