Okay, so now I’m having an issue when trying to receive and then transmit data. If there’s data to receive, then the transmit works just fine, but if the receive times out, then the transmit will also time out. Is there something I need to do to take it out of receive mode after a timeout? Standby() doesn’t seem to do it.
Thanks for your time!
#include <Arduino.h>
#include <SX126x-RAK4630.h>
#include <SPI.h>
#define LORA_OUTPWR 22 // dBm
#define LORA_BNDWTH 0 // 0: 125kHz, 1: 250kHz, 2: 500kHz
#define LORA_DATARATE 7 // 6: 64, 7: 128, 8: 256, 9: 512, 10: 1024, 11: 2048, 12: 4096 chips
#define LORA_CODINGRATE 1 // 1: 4/5, 2: 4/6, 3: 4/7, 4: 4/8
#define LORA_PREAMBLELEN 8 // # of symbols
#define LORA_FIXLEN false // fixed length packets
#define LORA_SYMBTIMEOUT 0 // # of symbols
#define LORA_CRC true // error checking on
#define LORA_HOPPERIOD 0 // # of symbols
#define LORA_IQINV false // Invert IQ symbols
#define LORA_RXCONT true // Continuous read mode on the SX126X (set to true, the library allows longer timeouts)
#define LORA_RXTIMEOUT 3000 //ms
#define LORA_TXTIMEOUT 3000 // ms
RadioEvents_t callbacks;
uint8_t buffer[3] = {1,2,3};
void setup() {
Serial.begin(9600);
while(!Serial)
delay(10);
Serial.println("Init");
lora_rak4630_init();
callbacks.RxTimeout = RxTimeout;
callbacks.TxTimeout = TxTimeout;
callbacks.RxDone = RxDone;
callbacks.TxDone = TxDone;
Radio.Init(&callbacks);
Radio.SetChannel(915000000);
Radio.SetPublicNetwork(false);
Radio.SetTxConfig(MODEM_LORA, LORA_OUTPWR, 0, LORA_BNDWTH, LORA_DATARATE,
LORA_CODINGRATE, LORA_PREAMBLELEN, LORA_FIXLEN, LORA_CRC,
0, LORA_HOPPERIOD, LORA_IQINV, LORA_TXTIMEOUT);
Radio.SetRxConfig(MODEM_LORA, LORA_BNDWTH, LORA_DATARATE, LORA_CODINGRATE,
0, LORA_PREAMBLELEN, LORA_SYMBTIMEOUT, LORA_FIXLEN, 0,
LORA_CRC, false, LORA_HOPPERIOD, LORA_IQINV, LORA_RXCONT);
Serial.println("RX");
Radio.Rx(1000);
}
void loop() {}
void RxTimeout() {
Serial.println("RxTimeout");
Radio.Standby();
Serial.println("Sending");
Radio.Send(buffer, 2);
}
void RxDone(uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr) {
Serial.println("RxDone");
Radio.Standby();
Serial.println("Sending");
Radio.Send(buffer, 2);
}
void TxDone() { Serial.println("TxDone"); }
void TxTimeout() { Serial.println("TxTimeout"); }