From cc720a7a240bab9fe3e3063d7d99155ab50ac59d Mon Sep 17 00:00:00 2001 From: jgromes Date: Sun, 20 Oct 2024 14:25:27 +0100 Subject: [PATCH] [SX127x] Added reset to home channel to FHSS examples (#1266) --- examples/SX127x/SX127x_Receive_FHSS/SX127x_Receive_FHSS.ino | 4 ++++ examples/SX127x/SX127x_Transmit_FHSS/SX127x_Transmit_FHSS.ino | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/examples/SX127x/SX127x_Receive_FHSS/SX127x_Receive_FHSS.ino b/examples/SX127x/SX127x_Receive_FHSS/SX127x_Receive_FHSS.ino index 7785a173..ede24586 100644 --- a/examples/SX127x/SX127x_Receive_FHSS/SX127x_Receive_FHSS.ino +++ b/examples/SX127x/SX127x_Receive_FHSS/SX127x_Receive_FHSS.ino @@ -86,6 +86,7 @@ void setup() { // set hop period in symbols // this will also enable FHSS + Serial.print(F("[SX1278] Setting hopping period ... ")); state = radio.setFHSSHoppingPeriod(9); if (state == RADIOLIB_ERR_NONE) { Serial.println(F("success!")); @@ -153,6 +154,9 @@ void loop() { // reset the counter hopsCompleted = 0; + // return to home channel before the next transaction + radio.setFrequency(channels[0]); + // put the module back to listen mode radio.startReceive(); diff --git a/examples/SX127x/SX127x_Transmit_FHSS/SX127x_Transmit_FHSS.ino b/examples/SX127x/SX127x_Transmit_FHSS/SX127x_Transmit_FHSS.ino index 5c2297db..d7210af6 100644 --- a/examples/SX127x/SX127x_Transmit_FHSS/SX127x_Transmit_FHSS.ino +++ b/examples/SX127x/SX127x_Transmit_FHSS/SX127x_Transmit_FHSS.ino @@ -98,6 +98,7 @@ void setup() { // set hop period in symbols // this will also enable FHSS + Serial.print(F("[SX1278] Setting hopping period ... ")); state = radio.setFHSSHoppingPeriod(9); if (state == RADIOLIB_ERR_NONE) { Serial.println(F("success!")); @@ -147,7 +148,7 @@ void loop() { hopsCompleted = 0; // return to home channel before the next transaction - radio.setFrequency(channels[radio.getFHSSChannel() % numberOfChannels]); + radio.setFrequency(channels[0]); // wait a second before transmitting again delay(1000);