Nasty OTAA connect
After getting basic connectivity for my RAK811 LPWAN Evaluation Board(EVB) and STM32F691DISCOVERY test rig sorted. I wanted to see if I could get the device connected to The Things Network(TTN) via the RAK7246G LPWAN Developer Gateway which was on my desk. I had got the EVB configuration sorted with an Arduino Uno R3 device so I was confident it should work.

My Over the Air Activation(OTAA) implementation is pretty “nasty” I assumed that there would be no timeouts or failures and I only send one BCD message “48656c6c6f204c6f526157414e” which is “hello LoRaWAN”
I configured the RAK811 module for LoRaWAN
// Set the Working mode to LoRaWAN bytesWritten = outputDataWriter.WriteString("at+set_config=lora:work_mode:0\r\n"); Debug.WriteLine($"TX: work_mode {outputDataWriter.UnstoredBufferLength} bytes to output stream."); txByteCount = outputDataWriter.Store(); Debug.WriteLine($"TX: {txByteCount} bytes via {serialDevice.PortName}"); // Read the response bytesRead = inputDataReader.Load(128); if (bytesRead > 0) { string response = inputDataReader.ReadString(bytesRead); Debug.WriteLine($"RX sync:{response}"); }
Then just sequentially stepped through the necessary configuration to join the TTN network
// Set the Region to AS923 bytesWritten = outputDataWriter.WriteString("at+set_config=lora:region:AS923\r\n"); Debug.WriteLine($"TX: region {outputDataWriter.UnstoredBufferLength} bytes to output stream."); txByteCount = outputDataWriter.Store(); Debug.WriteLine($"TX: {txByteCount} bytes via {serialDevice.PortName}"); // Read the response bytesRead = inputDataReader.Load(128); if (bytesRead > 0) { String response = inputDataReader.ReadString(bytesRead); Debug.WriteLine($"RX sync:{response}"); } // Set the JoinMode bytesWritten = outputDataWriter.WriteString($"at+set_config=lora:join_mode:0\r\n"); Debug.WriteLine($"TX: join_mode {outputDataWriter.UnstoredBufferLength} bytes to output stream."); txByteCount = outputDataWriter.Store(); Debug.WriteLine($"TX: {txByteCount} bytes via {serialDevice.PortName}"); // Read the response bytesRead = inputDataReader.Load(128); if (bytesRead > 0) { String response = inputDataReader.ReadString(bytesRead); Debug.WriteLine($"RX sync:{response}"); } // OTAA set the devEUI bytesWritten = outputDataWriter.WriteString($"at+set_config=lora:dev_eui:{devEui}\r\n"); Debug.WriteLine($"TX: dev_eui {outputDataWriter.UnstoredBufferLength} bytes to output stream."); txByteCount = outputDataWriter.Store(); Debug.WriteLine($"TX: {txByteCount} bytes via {serialDevice.PortName}"); // Read the response bytesRead = inputDataReader.Load(128); if (bytesRead > 0) { String response = inputDataReader.ReadString(bytesRead); Debug.WriteLine($"RX sync:{response}"); } ...
The code is not suitable for production but it confirmed my software and hardware configuration worked.
The thread '<No Name>' (0x2) has exited with code 0 (0x0). devMobile.IoT.Rak811.NetworkJoinOTAA starting COM5,COM6 TX: work_mode 32 bytes to output stream. TX: 32 bytes via COM6 RX sync:UART1 work mode: RUI_UART_NORAMAL Current work_mode:LoRaWAN, join_mode:OTAA, Class: A Initialization OK TX: region 33 bytes to output stream. TX: 33 bytes via COM6 RX sync:OK TX: join_mode 32 bytes to output stream. TX: 32 bytes via COM6 RX sync:OK TX: dev_eui 45 bytes to output stream. TX: 45 bytes via COM6 RX sync:OK TX: app_eui 45 bytes to output stream. TX: 45 bytes via COM6 RX sync:OK TX: app_key 61 bytes to output stream. TX: 61 bytes via COM6 RX sync:OK TX: confirm 30 bytes to output stream. TX: 30 bytes via COM6 RX sync:OK TX: join 9 bytes to output stream. TX: 9 bytes via COM6 RX sync: RX sync: RX sync: RX sync: RX sync:OK Join Success TX: send 43 bytes to output stream. TX: 43 bytes via COM6 TX: send 43 bytes to output stream. TX: 43 bytes via COM6 RX sync:OK at+recv=0,-59,9,0
In the Visual Studio 2019 debug out put I could see messages getting sent and then after a short delay they were visible in the TTN console.

I then modified the confirmed flag and in the TTN console I could see how they were processed differently.


I could receive messages but as the RAK 811 module can be configured to be a Class C device there didn’t appear to be a way to receive a message without sending one which seemed a bit odd.
The next step is to get Authentication By Personalisation(ABP) working.
Pingback: nanoFramework RAK811 LoRaWAN library Part5 | devMobile's blog
Pingback: TinyCLR OS V2 RC1 RAK811 LoRaWAN library Part2 | devMobile's blog