This is an abbreviated version of Part 2, the full article is on the Z-Wave Alliance Web site.
Introduction
How do you get started in developing a wireless IoT product using Z-Wave? Assuming you’ve chosen a silicon vendor from Part 1 of this blog, the next step is to become familiar with the tools, developer kits and software of the respective vendors, Silicon Labs and Trident IoT. Both vendors utilize the popular Microsoft Visual Studio (VS) Code Integrated Debug Environment (IDE). Each has developed an extension to customize VS Code for their respective SDK. If you’re not already a VS Code user, you should be. The Intellisense AI feature is a game changer for managing the large amount of code in the SDK you will be interfacing with for your project. I am relatively new to VS Code and I am still in the learning phase. Please comment on this blog If you know of any time saving tricks that I’ll be happy to pass on to the rest of the community.
I highly recommend taking the training and reading documentation from each vendor on using their tools and developers kits. In later postings I’ll be using these tools and assume you are already familiar with them.
Software Architecture, FreeRTOS and the SDK
Fundamentally the Z-Wave SDK relies on the open-source FreeRTOS real time operating system. FreeRTOS provides many resources such as multitasking, software timers, memory management and security. The Z-Wave SDK is in one task, your application code is in another task and then there are a few utility tasks. The use of an RTOS makes the code more modular but also more complex. Instead of simply calling a function to send a message over the radio, the application task sends the message through a queue to the Z-Wave task which then sends it over the radio and later returns the result to a callback function you passed through the queue. When the RTOS determines there’s nothing to do, it will put the chip to sleep. An always-on device will only put the CPU to sleep and leave the radio on, but battery powered devices will go into a low power mode.
Each vendor has some amount of the SDK pre-compiled into a library. Mostly this provides an abstraction layer that gives the vendor a level of intellectual property protection. Much of the code is in source code form and you will compile the SDK with your code as well. Trident has a method to compile all the source code into your project which can make debugging the SDK possible. The SDK includes lots of helper APIs and code for many common command classes. If the command class you need is not available (yet), you will want to copy the code of a similar command class. To be efficient, you need to reuse as much code as possible. Gotta love copy and paste.
What to Customize Next
Below is a list of things I customize for any new project. I’m using the Silicon Labs SDK in this case but Trident is similar and starts by editing the app/CMakeLists.txt file. Open the .slcp file in Simplicity Studio V6, click on Software Components, then Installed, then open the Z-Wave list.
- Z-Wave Core Component – Select the Z-Wave Region to match your location
- Max Tx Power will need customization when preparing for regulatory approval
- Z-Wave Version Numbers – Turn on (True) Use Application Version and enter version numbers
- The Minor Version MUST be incremented for OTA firmware update
- Z-Wave ZAF Component – Several items must be customized for your product
- The Manufacturer Specific ID, Product Type and Product ID are a 48-bit unique identifier for the product – basically a fingerprint
- Command Classes – Association CC – Recommend a single Lifeline NodeID
- Uncheck Installed – then install Z-Wave Debug
- This will uninstall Z-Wave Release which uses higher compiler optimization and the debugger is unable to accurately single step C source code
- Note that OTA fails when DEBUG is enabled due to code size with the lower optimization
- Z-Wave Log – optionally turn on more logging which will print more messages out the UART
- Entering vcom into all 4 debug levels will print a lot of messages
- Be sure to turn this OFF when getting close to a release
- Note that the sending text out the UART is a blocking operation and will change how the code runs and may cause a watchdog reset
These customizations are just the start! From here you will install other command classes, SPI, I2C or UART drivers and of course your own custom code.
See more details at the full blog posting on the Alliance Web Site via this link: https://z-wavealliance.org/a-z-wave-developers-journey-part-2-2/
Please comment below on this or any of the topics in the Developers Journey.
Join me at the Z-Wave Summit May 27-29 in Vienna Austria. Unplug Fest is the afternoon of the 27th which I will be coordinating. We’re not doing range testing this time around but will be demonstrating some of the main features of Z-Wave including SmartStart, Multicast, Mesh routing and more. Bring your new devices and test them with several ecosystem players to see Z-Wave interoperability in the real world.
