Skip to content

Commit

Permalink
adopt to RadioLib 6.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
designer2k2 committed Jun 14, 2024
1 parent 851ae03 commit b6cd13a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
26 changes: 14 additions & 12 deletions main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ void build_mapper_packet() {

/// Blow away our prefs (i.e. to rejoin from scratch)
void ttn_erase_prefs() {
node.wipe();
node.clearSession();
Preferences p;
if (p.begin("lora", false)) {
p.clear();
Expand Down Expand Up @@ -285,9 +285,9 @@ boolean send_uplink(uint8_t *txBuffer, uint8_t length, uint8_t fport, boolean co
Serial.print(downlinkDetails.power);
Serial.println(F(" dBm"));
Serial.print(F("[LoRaWAN] Frame count:\t"));
Serial.println(downlinkDetails.fcnt);
Serial.println(downlinkDetails.fCnt);
Serial.print(F("[LoRaWAN] Port:\t\t"));
Serial.println(downlinkDetails.port);
Serial.println(downlinkDetails.fPort);

uint8_t margin = 0;
uint8_t gwCnt = 0;
Expand All @@ -310,7 +310,7 @@ boolean send_uplink(uint8_t *txBuffer, uint8_t length, uint8_t fport, boolean co

// Helium requires a re-join / reset of count to avoid 16bit count rollover
// Hopefully a device reboot every 50k uplinks is no problem.
if (node.getFcntUp() > MAX_FCOUNT) {
if (node.getFCntUp() > MAX_FCOUNT) {
Serial.println("FCount Rollover!");

// I don't understand why this doesn't show at all
Expand Down Expand Up @@ -392,7 +392,7 @@ enum mapper_uplink_result mapper_uplink() {
return MAPPER_UPLINK_NOLORA;

// LoRa is not ready for a new packet, maybe still sending the last one.
if (!node.isJoined())
if (!node.isActivated())
return MAPPER_UPLINK_NOLORA;

// Check if there is not a current TX/RX job running
Expand All @@ -418,7 +418,7 @@ enum mapper_uplink_result mapper_uplink() {
if (justSendNow) {
confirmed = true;
} else {
confirmed = (lorawanAck > 0) && (node.getFcntUp() % lorawanAck == 0);
confirmed = (lorawanAck > 0) && (node.getFCntUp() % lorawanAck == 0);
}

char because = '?';
Expand All @@ -442,7 +442,7 @@ enum mapper_uplink_result mapper_uplink() {
if (dist_moved > 1000000)
dist_moved = 0;

snprintf(buffer, sizeof(buffer), "\n%d %c %4lus %4.0fm ", node.getFcntUp(), because, (now - last_send_ms) / 1000,
snprintf(buffer, sizeof(buffer), "\n%d %c %4lus %4.0fm ", node.getFCntUp(), because, (now - last_send_ms) / 1000,
dist_moved);
screen_print(buffer);

Expand Down Expand Up @@ -569,7 +569,7 @@ void lorawan_save_prefs(void) {
p.putString("server", lorawanServer);
p.putUChar("sf", lorawan_sf);
p.putUChar("ack", lorawanAck);
node.saveSession();
//node.saveSession();
p.putBytes("nonces", node.getBufferNonces(), RADIOLIB_LORAWAN_NONCES_BUF_SIZE);
p.putBytes("session", node.getBufferSession(), RADIOLIB_LORAWAN_SESSION_BUF_SIZE);
p.end();
Expand All @@ -579,7 +579,7 @@ void lorawan_save_prefs(void) {
// Clear all saves surrounding the Lora setting
void lorawan_erase_prefs(void) {
Preferences p;
node.wipe();
node.clearSession();
if (p.begin("lora", false)) {
p.clear();
p.end();
Expand Down Expand Up @@ -978,7 +978,8 @@ void setup() {
lorawan_restore_prefs();
lora_msg_callback(EV_JOINING);

state = node.beginOTAA(joinEUI, devEUI, nwkKey, appKey);
node.beginOTAA(joinEUI, devEUI, nwkKey, appKey);
state = node.activateOTAA();
// state = RADIOLIB_ERR_CHECKSUM_MISMATCH;

if (state == RADIOLIB_ERR_NONE) {
Expand All @@ -990,7 +991,8 @@ void setup() {
// node.wipe();

Serial.print(F("[LoRaWAN] Attempting over-the-air activation ... "));
state = node.beginOTAA(joinEUI, devEUI, nwkKey, appKey, true);
node.beginOTAA(joinEUI, devEUI, nwkKey, appKey);
state = node.activateOTAA();

node.setADR(false);

Expand All @@ -1016,7 +1018,7 @@ void setup() {

// on EEPROM enabled boards, you can save the current session
// by calling "saveSession" which allows retrieving the session after reboot or deepsleep
node.saveSession();
// node.saveSession();
lorawan_save_prefs();

/**
Expand Down
2 changes: 1 addition & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ lib_deps =
thingpulse/ESP8266 and ESP32 OLED driver for SSD1306 displays@^4.5.0
mikalhart/TinyGPSPlus@^1.0.3
lewisxhe/XPowersLib@^0.2.2
jgromes/RadioLib@^6.5.0
jgromes/RadioLib@^6.6.0
sparkfun/SparkFun u-blox GNSS Arduino Library@^2.2.25

monitor_speed = 115200
Expand Down

0 comments on commit b6cd13a

Please sign in to comment.