RadioLib: LoRaWan - Raspberry Pi 3B error -6 on method LoRaWANNode::sendReceive()

Hi!

Im using Raspberry Pi 3B to transmit LoRaWAN messages but im getting the error -6 on method sendReceive(). The module im using is the SX1272.

Pinout: NSS pin: 8 DIO0 pin: 17 DIO1 pin: 13 RST pin: 4

The following code is:

#include <RadioLib.h>
#include "PiHal.h"
#include <string>
#include <stdio.h>


PiHal* hal = new PiHal(1);

SX1272 radio = new Module(hal, 8, 17, 4, 13);

LoRaWANNode node(&radio, &US915, 2);

uint32_t devAddr = 0x2******3;

uint64_t devEUI = 0x2**************3;

uint8_t nwkKey[] = { 0x2B, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0x3C };

uint8_t appKey[] = { 0x2B, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0x3C };

int beginRadio(SX1272 radio){
  int state = radio.begin();
  if(state == RADIOLIB_ERR_NONE){
    printf("[Radio Begin]...ok!\n");
    return (state);
  } else {
    printf("[Radio Begin]...error: %i\n",state);
    return (-1);
  }
}


int beginABPLora(){
  int state = node.beginABP(devAddr, nwkKey, appKey);
  if(state >= RADIOLIB_ERR_NONE){
    printf("[LoRa ABP Begin]...ok!\n");
    return(state);
  } else{
    printf("[LoRa ABP Begin]...error: %i\n",state);
    return (-1);
  }
}
int main(){
  printf("[Radio]...ok!\n");
  printf("[LoRa Node]...ok!\n");

  int state = beginRadio(radio);
  state = beginABPLora();

  // node.setADR(true);
  // node.setDutyCycle(true, 1250);
  // node.setDwellTime(true, 1000);
  
  uint8_t count = 0;
  while(true){
    const char *strUp = "hello!";
    uint8_t strDown[256];
    size_t lenDown = 0;
    uint8_t port = 10;
    int16_t state = node.sendReceive(strUp, port, strDown, &lenDown);
    // int16_t state = node.uplink(strUp, port);
    if(state == RADIOLIB_ERR_NONE){
      printf("[LoRa sendReceive]...ok!\n");
      printf("[LoRaWAN] Data:\t\t");
      size_t dataDownLength = sizeof(strDown) / sizeof(strDown[0]);

      if(dataDownLength > 0){
        printf("%s",strDown);
      } else {
        printf("<MAC commands only>");
      }
    } else{
      printf("[LoRa sendReceive]...error: %i\n",state);
      return (-1);
    }

    uint32_t minimunDelay = 60000;
    uint32_t interval = node.timeUntilUplink();
    uint32_t delayMs = std::max(interval,minimunDelay);
    hal->delay(delayMs);
  }
  return(0);
}

The error im getting:

[Radio]...ok!
[LoRa Node]...ok!
[Radio Begin]...ok!
[LoRa ABP Begin]...ok!
[LoRa sendReceive]...error: -6

Additional information:

  • Library version 6.4.2

About this issue

  • Original URL
  • State: closed
  • Created 3 months ago
  • Comments: 18

Most upvoted comments

RadioLib is developed by volunteers. There are no restrictions on using it for commercial projects AFAIK and if you were using TTS, LW1.1 and suitable known good tested MCU platform we’d not be here.

But you are using a RPi with an unsupported LW version on an LNS that could have any number of changes that we aren’t aware of for a commercial project.

Phrases like “because my gateway does NOT send a downlink in response,” indicate that you have some way to go before you understand what LW is all about and LW is not a system that falls neatly in to place even with known setups.

It’s not appropriate to expect free assistance to help solve what can only be described as a disaster that’s potentially not finished unfolding. And FWIW, it’s not fair on you for someone to expect you to learn new tech AND use a non-standard setup.

You may want to hunt out a Pi implementation of LMIC which is only 1.0.3. Or there is a python version, not sure what version that supports. Or commission someone to sort this out but I’d suspect they will ask a lot of WHY questions (like why change the LNS, why use ABP, why use a Pi as a device) and then recommend reverting to standard kit to get the project done.

Good luck!

Closing as OP unwilling to conform to given feedback, and instead bends universe against the law and intentionally breaking functionality.