Let's build an #IoT App with #ZigLang and #LoRaWAN ... To show that we can maintain and extend Complex IoT Apps with Zig!
https://github.com/lupyuen/zig-bl602-nuttx#convert-lorawan-app-to-zig
We take this #LoRaWAN App in C and convert to #ZigLang ... 700 Lines of C Code, no sweat!
https://github.com/lupyuen/zig-bl602-nuttx#convert-lorawan-app-to-zig
Here's how we import #LoRaWAN Library from C into #ZigLang ... Yep Zig understands C Header Files! 👍
https://github.com/lupyuen/zig-bl602-nuttx#convert-lorawan-app-to-zig
This is how we call the #LoRaWAN Library from #ZigLang
https://github.com/lupyuen/zig-bl602-nuttx#convert-lorawan-app-to-zig
#ZigLang Compiler will helpfully Auto-Translate our code from C to Zig ... Rewriting C to Zig gets so much easier 👍
https://github.com/lupyuen/zig-bl602-nuttx#auto-translate-lorawan-app-to-zig
Our #LoRaWAN App ... Original C code vs Auto-Translated #ZigLang code
https://github.com/lupyuen/zig-bl602-nuttx#auto-translate-lorawan-app-to-zig
After fixing the code, our #LoRaWAN #ZigLang App runs perfectly on Apache #NuttX RTOS! 🎉 (670 lines of Zig code!)
https://github.com/lupyuen/zig-bl602-nuttx#lorawan-zig-app-runs-ok
#ZigLang Compiler reveals fascinating insights about Safety Checks when it auto-translates C code to Zig ... Here's how it handles a potential Integer Overflow
Here's our #LoRaWAN App in C vs #ZigLang ... After some hand-scrubbing
https://github.com/lupyuen/zig-bl602-nuttx#compare-c-and-zig
Our #LoRaWAN Stack for #ZigLang is in C ... And that's perfectly OK!
https://lupyuen.github.io/articles/iot?2#lorawan-network-stack
Importing the #LoRaWAN Library from C into #ZigLang ... Piece of cake!
https://lupyuen.github.io/articles/iot?3#import-lorawan-library
#ZigLang does Type Conversion with Runtime Checks 👍
https://lupyuen.github.io/articles/iot?5#convert-integer-type
How our #ZigLang App transmits a #LoRaWAN Packet
https://lupyuen.github.io/articles/iot?6#transmit-data-packet
#ZigLang's Auto-Translator reveals interesting differences between C and Zig
#ZigLang helpfully catches all kinds of Runtime Errors: Underflow, Overflow, Array Out-Of-Bounds, ...
Our #ZigLang App handles #LoRaWAN Events ... By calling NimBLE Porting Layer
https://lupyuen.github.io/articles/iot?12#appendix-handle-lorawan-events
#ZigLang Compiler won't init this C Struct ... So we init the struct ourselves
https://github.com/lupyuen/zig-bl602-nuttx#struct-initialisation-error