Need help correctly setting up new device on WisGate Edge Lite 2 RAK7268\RAK7268C

I have a WisGate Edge Lite 2 RAK7268\RAK7268C and a LoRa Enabled ESP32. I would like to accomplish sending a message from my ESP32 to the WisGate and have it publish that message to my local mqtt server.

I have tried setting it up in the following way:

  • WisGate is plugged into my Local Network via Ethernet
  • I have it in Network Server mode
  • Under LORA Network > Gateway I have it pointed to my MQTT Server
  • I created an Application and then within that Application I created a Device
  • I am using US Frequencies

Things I’m unclear about:

  • For the device specifically, I made up a Device EUI (0102030405060708) and Device Address 123456789. Is this valid for a local/private setup? I don’t totally understand this
  • For the Application Session and Application Network Key I was given a string. I believe that needs to be converted to a 32bit hex for my ESP32, see code below along with the screenshot from RAK
// LoRaWAN NwkSKey, network session key
static const PROGMEM u1_t NWKSKEY[64] = { 0x64, 0x36, 0x32, 0x34, 0x38, 0x37, 0x30, 0x35, 0x30, 0x66, 0x32, 0x64, 0x38, 0x30, 0x37, 0x65, 0x61, 0x63, 0x38, 0x35, 0x30, 0x66, 0x36, 0x32, 0x62, 0x63, 0x33, 0x61, 0x65, 0x38, 0x34, 0x33 };

// LoRaWAN AppSKey, application session key
static const u1_t PROGMEM APPSKEY[64] = { 0x30, 0x66, 0x62, 0x30, 0x38, 0x39, 0x64, 0x31, 0x62, 0x35, 0x30, 0x30, 0x35, 0x33, 0x30, 0x31, 0x61, 0x61, 0x31, 0x31, 0x66, 0x32, 0x30, 0x61, 0x37, 0x31, 0x64, 0x32, 0x61, 0x61, 0x34, 0x36 };

// LoRaWAN end-device address (DevAddr)
static const u4_t DEVADDR = 0x123456789;

(yes I know I’m exposing keys, this is just a test and they will be changed)

When my ESP32 device publishes a LORA message, it is not being picked up. I feel quite lost and would appreciate any pointers/help on getting this up and running.

Welcome to the forum @hummmingbear

First thing I saw is that the NWSKEY and APPSKEY from your ESP32 code is different from the Application Session Key and Network Session Key on the LoRaWAN server. They must be the same. Both are in HEX format, so if you set the Application Session Key to 0fb089d1b5005301aa11f20a71d2aa46 the APPSKEY in your code must be {0x0f, 0xb0, 0x89, 0xd1, 0xb5, 0x00, 0x53, 0x01, 0xaa, 0x11, 0xf2, 0x0a, 0x71, 0xd2, 0xaa, 0x46};, not the Ascii values.

I do not know what LoRaWAN library you use, some of them use LSB format, the network server is using MSB format

Is your ESP32 using the same LoRaWAN region as the gateway?

Do you see any packets in the RAK7268 LoRaWAN Packet Logger

Thank you for the reply, much appreciated. That totally worked! I had to covert both AppSessionKey and NetworkSessionKey to the format you provided. Woohoo!!

The only thing I had to change is for some reason it is seeing my device address as 23456789. On the ESP I have it set as static const u4_t DEVADDR = 0x123456789; I’m sure I’m misunderstanding this hex or type value?

One more question - Is there anyway to tell the RAK software to automatically decode the Base64 data/message before publishing it to MQTT?

About the dev addr, it is a 32bit number, but you set a 40bit in your code, so the upper 8 bit are discarded.

For the data sent over MQTT, as far as I know (I am not the gateway expert here), you need to decode the data on the network server. The internal network server supports only CayenneLPP format.
You can enable this in the Application => Payload Formats:

As I am always sending my data in Cayenne LPP format, I get the decoded data on the MQTT broker:

In Arduino, I use the CayenneLPP library. It is quite easy to use.

1 Like

Thank you for the help! That all makes sense, I’ll try that library out