#NuttX OS doesn't handle the Join Response from #LoRaWAN Gateway ... Let's fix this
Run Log: https://gist.github.com/lupyuen/a8e834e7b4267345f01b6629fb7f5e33
Our #NuttX App was waiting for the #LoRaWAN Join Request to be transmitted before receiving the Join Response ... But because we're polling SX1262, we missed the Join Response ... Let's fix this with the multithreading functions from NimBLE Porting Layer
Log: https://gist.github.com/lupyuen/d3d9db37a40d7560fc211408db04a81b
To build NumBLE Porting Layer on #NuttX OS we need to enable: 1️⃣ POSIX Timers & Message Queues 2️⃣ Clock Monotonic 3️⃣ Work Queues 4️⃣ SIGEV_THHREAD
#LoRaWAN runs neater on Apache #NuttX OS ... After implementing Timers and Multithreading with NimBLE Porting Layer ... No more polling and sleep()!
https://gist.github.com/lupyuen/cad58115be4cabe8a8a49c0e498f1c95
Here's how we check the SX1262 Busy Pin on #NuttX OS ... By reading the GPIO Input
https://github.com/lupyuen/lora-sx1262/blob/lorawan/src/sx126x-nuttx.c#L184-L199
SX1262 will trigger a GPIO Interrupt on #NuttX OS when it receives a #LoRa Packet ... We wait for the GPIO Interrupt to be Signalled in a Background Thread
https://github.com/lupyuen/lora-sx1262/blob/lorawan/src/sx126x-nuttx.c#L742-L778
We handle GPIO Interrupts (SX1262 DIO1) in a #NuttX Background Thread ... Awaiting the Signal for GPIO Interrupt
https://github.com/lupyuen/lora-sx1262/blob/lorawan/src/sx126x-nuttx.c#L835-L861
Our #NuttX Background Thread handles the GPIO Interrupts (SX1262 DIO1) ... By adding to the #LoRaWAN Event Queue
https://github.com/lupyuen/lora-sx1262/blob/lorawan/src/sx126x-nuttx.c#L863-L892
Our #NuttX App resends the same Nonce to the #LoRaWAN Gateway ... Which (silently) rejects the Join Request due to Duplicate Nonce ... Let's fix our Random Number Generator
https://gist.github.com/lupyuen/b38434c3d27500444382bb4a066691e5
#LoRaWAN gets the Nonce from the Secure Element's Random Number Generator ... Let's simulate the Secure Element on Apache #NuttX OS
https://github.com/lupyuen/LoRaMac-node-nuttx/blob/master/src/mac/LoRaMacCrypto.c#L980-L996
Here's how we generate #LoRaWAN Nonces on #NuttX OS ... With Strong Random Numbers thanks to Entropy Pool
https://github.com/lupyuen/LoRaMac-node-nuttx/blob/master/src/nuttx.c#L136-L153
Our #NuttX App now sends Random #LoRaWAN Nonces to the LoRaWAN Gateway ... And are happily accepted by the gateway! 🎉
Log: https://gist.github.com/lupyuen/8f012856b9eb6b9a762160afd83df7f8
Our #NuttX App was too busy to receive the #LoRaWAN Join Response ... Let's disable the logging
Log: https://gist.github.com/lupyuen/8f012856b9eb6b9a762160afd83df7f8
After disabling logging, our #NuttX App successfully joins the #LoRaWAN Network! 🎉 Now we transmit some Data Packets over LoRaWAN
Log: https://gist.github.com/lupyuen/0d301216bbf937147778bb57ab0ccf89
Our #LoRaWAN Gateway receives Data Packets from #NuttX OS! 🎉 The Message Payload is empty ... Let's figure out why 🤔
Log: https://gist.github.com/lupyuen/0d301216bbf937147778bb57ab0ccf89
Our #NuttX App sent an empty #LoRaWAN Message because our message is too long for LoRaWAN Data Rate 2 (max 11 bytes) ... Let's increase the Data Rate to 3
https://gist.github.com/lupyuen/5fc07695a6c4bb48b5e4d10eb05ca9bf
Here's how we increase the #LoRaWAN Data Rate to 3 in our #NuttX App
https://github.com/lupyuen/lorawan_test/blob/main/lorawan_test_main.c#L57-L70
#LoRaWAN Data Rate has been increased to 3 ... Max Message Size is now 53 bytes for our #NuttX App
https://gist.github.com/lupyuen/83be5da091273bb39bad6e77cc91b68d
#LoRaWAN Gateway now receives the correct Data Packet from our #NuttX App! 🎉
https://gist.github.com/lupyuen/83be5da091273bb39bad6e77cc91b68d
Here's how we send a #LoRaWAN Data Packet on #NuttX OS ... And validate the Packet Size before sending
https://github.com/lupyuen/lorawan_test/blob/main/lorawan_test_main.c#L311-L339
NimBLE Porting Layer doesn't work for multiple Callout Timers on #NuttX OS, unless we loop the thread ... Will submit a Pull Request to Apache NimBLE 👍
Switching a #NuttX GPIO Interrupt Pin to Trigger On Rising Edge ... Crashes with an Assertion Failure ... I'll submit a NuttX Issue, meanwhile I have disabled the assertion
https://github.com/lupyuen/incubator-nuttx/blob/lorawan/drivers/ioexpander/gpio.c#L544-L547
Here's why we need GPIO Interrupts Triggered on Rising Edge for #LoRa on #NuttX
https://lupyuen.github.io/articles/sx1262?88#initialise-gpio
We handle SX1262 GPIO Interrupts in #NuttX with a Background Thread ... That inserts into an Event Queue
https://lupyuen.github.io/articles/sx1262?89#start-dio1-thread
How we handle SX1262 GPIO Interrupts in #NuttX OS ... With NimBLE Porting Layer
https://lupyuen.github.io/articles/sx1262?90#multithreading-with-nimble-porting-layer
#LoRaWAN on #Apache NuttX OS ... Here's what we'll do
https://lupyuen.github.io/articles/lorawan3?4#lorawan-objective
Here's what we'll do with #LoRaWAN on Apache #NuttX OS
https://lupyuen.github.io/articles/lorawan3?5#lorawan-objective
Source Code for #LoRaWAN on Apache #NuttX OS
https://lupyuen.github.io/articles/lorawan3?6#download-source-code
Setting the #LoRaWAN Device EUI and App Key in #NuttX OS
https://lupyuen.github.io/articles/lorawan3?7#device-eui-join-eui-and-app-key
Setting the #LoRaWAN Frequency for #NuttX OS
https://lupyuen.github.io/articles/lorawan3?9#lorawan-frequency
Our #LoRaWAN Library needs a Strong Random Number Generator with Entropy Pool on #NuttX OS
https://lupyuen.github.io/articles/lorawan3?12#appendix-random-number-generator-with-entropy-pool
Building the #LoRaWAN Firmware for Apache #NuttX OS
https://lupyuen.github.io/articles/lorawan3?15#build-the-firmware
Running the #LoRaWAN Firmware for Apache #NuttX OS ... To join a LoRaWAN Network
https://lupyuen.github.io/articles/lorawan3?16#run-the-firmware
Here's how we join a #LoRaWAN Network in our #NuttX App
https://lupyuen.github.io/articles/lorawan3?17#join-lorawan-network
#NuttX joins #LoRaWAN Network ... Watch what happens at the LoRaWAN Gateway
https://lupyuen.github.io/articles/lorawan3?18#check-lorawan-gateway
Here's how we transmit a #LoRaWAN Data Packet in our #NuttX App
https://lupyuen.github.io/articles/lorawan3?19#send-data-to-lorawan
#LoRaWAN Max Message Size depends on 1️⃣ Data Rate 2️⃣ LoRaWAN Region
How often can we send a #LoRaWAN Message? Check the LoRaWAN Airtime Calculator
https://lupyuen.github.io/articles/lorawan3?21#message-interval
Running our #LoRaWAN Firmware on Apache #NuttX OS ... And transmitting LoRaWAN Messages
https://lupyuen.github.io/articles/lorawan3?22#rerun-the-firmware
Inspecting the ChirpStack Log ... For #LoRaWAN Messages transmitted by Apache #NuttX OS
https://lupyuen.github.io/articles/lorawan3?23#check-lorawan-gateway-1
Here's why #LoRaWAN on #NuttX needs a Strong Random Number Generator (with Entropy Pool)
https://lupyuen.github.io/articles/lorawan3?24#lorawan-nonce
How we generate #LoRaWAN Nonces ... With the Strong Random Number Generator on #NuttX OS
https://lupyuen.github.io/articles/lorawan3?25#strong-random-number-generator
How we handle #LoRaWAN Events ... With NimBLE Porting Layer on Apache #NuttX OS
https://lupyuen.github.io/articles/lorawan3?26#lorawan-event-loop
Inside our #LoRaWAN Event Loop for Apache #NuttX OS
https://lupyuen.github.io/articles/lorawan3?27#lorawan-event-loop
Troubleshooting #LoRaWAN on Apache #NuttX OS
https://lupyuen.github.io/articles/lorawan3?28#troubleshoot-lorawan
#LoRaWAN is Time Sensitive! Here's why
https://lupyuen.github.io/articles/lorawan3?29#lorawan-is-time-sensitive
Watch out for Empty #LoRaWAN Message Payloads
https://lupyuen.github.io/articles/lorawan3?30#empty-lorawan-message
@lupyuen
I just use /dev/random for all my RNG needs.
On #NuttX OS, NimBLE Porting Library needs POSIX Timers and Message Queues
https://lupyuen.github.io/articles/lorawan3?11#appendix-posix-timers-and-message-queues