Site icon Renzo Mischianti

E22 channel scanner needs help

I want to scan LoRa frequencies to choose a low traffic channel for a LoRaWAN.  sendTester.ino below sends a transparent mode message on channel 0x23 every second and scanner.ino listens cycling through a small range of channels that includes 0x23. It reports channels with non-zero rssi values. The problem is that scanner.ino hears a few consecutive (5 - 10) messages on 0x23 but then goes deaf. I'm baffled. Is a buffer overflowing? sendTest.ino
/*
* sends a message on channel 23 at 1 second intervals
*/

#include "Arduino.h"
#include "LoRa_E22.h"

// ---------- esp32 pins --------------
LoRa_E22 e22ttl(&Serial2, 15, 21, 19); // RX AUX M0 M1

void setup() {
Serial.begin(9600);
delay(500);

// Startup all pins and UART
e22ttl.begin();

// If you have ever change configuration you must restore It
ResponseStructContainer c;
c = e22ttl.getConfiguration();
Configuration configuration = *(Configuration*) c.data;
Serial.println(c.status.getResponseDescription());
configuration.ADDL = 0x03;
configuration.ADDH = 0x00;
configuration.NETID = 0x00;

configuration.CHAN = 0x23;

configuration.SPED.uartBaudRate = UART_BPS_9600;
configuration.SPED.airDataRate = AIR_DATA_RATE_010_24;
configuration.SPED.uartParity = MODE_00_8N1;

configuration.OPTION.subPacketSetting = SPS_240_00;
configuration.OPTION.RSSIAmbientNoise = RSSI_AMBIENT_NOISE_DISABLED;
configuration.OPTION.transmissionPower = POWER_22;

configuration.TRANSMISSION_MODE.enableRSSI = RSSI_ENABLED;
configuration.TRANSMISSION_MODE.fixedTransmission = FT_TRANSPARENT_TRANSMISSION;
configuration.TRANSMISSION_MODE.enableRepeater = REPEATER_DISABLED;
configuration.TRANSMISSION_MODE.enableLBT = LBT_DISABLED;
configuration.TRANSMISSION_MODE.WORTransceiverControl = WOR_RECEIVER;
configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011;
e22ttl.setConfiguration(configuration, WRITE_CFG_PWR_DWN_SAVE);
c.close();
}

void loop() {
// Send message

ResponseStatus rs = e22ttl.sendMessage("Hello, world?");
// Check if problem with sending
Serial.println(rs.getResponseDescription());
delay(1000);
}
<div></div> scanner.ino
/* Look for LoRa transmissions - test with sendTester.ino
* scans channels 0 - 80
* receives in transparent mode
* writes received channel id, RSSI, message to stdout
*/

#include "Arduino.h"
#include "LoRa_E22.h"

// ---------- esp32 pins --------------
LoRa_E22 e22ttl(&Serial2, 15, 21, 19); // RX AUX M0 M1

#define ENABLE_RSSI true

Configuration configuration;
ResponseStructContainer c;

int channel = 0x00;

void setup() {
Serial.begin(9600);
delay(500);

// Startup all pins and UART
e22ttl.begin();
c = e22ttl.getConfiguration();
configuration = *(Configuration*) c.data;
Serial.println(c.status.getResponseDescription());

configuration.ADDL = 0x03;
configuration.ADDH = 0x00;
configuration.NETID = 0x00;
// configuration.CHAN = 0x23;
configuration.SPED.uartBaudRate = UART_BPS_9600;
configuration.SPED.airDataRate = AIR_DATA_RATE_010_24;
configuration.SPED.uartParity = MODE_00_8N1;
configuration.OPTION.subPacketSetting = SPS_240_00;
configuration.OPTION.RSSIAmbientNoise = RSSI_AMBIENT_NOISE_DISABLED;
configuration.OPTION.transmissionPower = POWER_22;
configuration.TRANSMISSION_MODE.enableRSSI = RSSI_ENABLED;
configuration.TRANSMISSION_MODE.fixedTransmission = FT_TRANSPARENT_TRANSMISSION;
configuration.TRANSMISSION_MODE.enableRepeater = REPEATER_DISABLED;
configuration.TRANSMISSION_MODE.enableLBT = LBT_DISABLED;
configuration.TRANSMISSION_MODE.WORTransceiverControl = WOR_RECEIVER;
configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011;

e22ttl.setConfiguration(configuration, WRITE_CFG_PWR_DWN_SAVE);
c.close();
}

void loop() {
channel = channel % 0x25; // scan only 0x22 - 0x24 for testing
if (channel == 0x00) { channel = 0x22; }

c = e22ttl.getConfiguration(); // change to next channel
configuration = *(Configuration*) c.data;
configuration.CHAN = channel;
e22ttl.setConfiguration(configuration, WRITE_CFG_PWR_DWN_SAVE);
Serial.print("channel "); Serial.println(channel);
c.close();
delay(1000);

while (!e22ttl.available()>1) { ;} // wait for message
ResponseContainer rc = e22ttl.receiveMessageRSSI(); // read the String message
// If something goes wrong print error
if (rc.status.code!=1) {
Serial.print("1 "); Serial.println(rc.status.getResponseDescription());
}
else if (rc.rssi > 0) {
// Print the data received
Serial.print(channel);
Serial.print("\t");
Serial.print(rc.rssi);
Serial.print("\t");
Serial.print(rc.data);
Serial.print("\n");
}
channel++;
}
Exit mobile version