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
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
#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
Auto-Translating C to #ZigLang is not perfect (like for C Bit Fields) ... But we can fix it ourselves
https://github.com/lupyuen/zig-bl602-nuttx#opaque-type-error
#ZigLang Compiler can't Auto-Translate some tricky C Macros into Zig ... Here's a workaround
#ZigLang Compiler won't init this C Struct ... So we init the struct ourselves
https://github.com/lupyuen/zig-bl602-nuttx#struct-initialisation-error
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
This is how we call the #LoRaWAN Library from #ZigLang
https://github.com/lupyuen/zig-bl602-nuttx#convert-lorawan-app-to-zig