Deeper insight into Z-Uno
Z-Uno firmware consist of four parts:
- User code also known as sketch written by you in a simplified C language (see Z-Uno language reference) and loaded into Z-Uno using Arduino IDE. User code controls all pins and logics of the device. You decide how to user all connected peripherals!
- User code bootloader sets up Z-Wave Application layer according to User code settings, configures Channels, defines Associations groups and select power management mode. It also handler service buttons to allow inclusion in existing Z-Wave network or run in Rescue mode and service LEDs to show current state of Z-Uno. But the main role of this layer is to call callbacks in User code on Get and Set packets coming from Z-Wave Application layer as well as run loop every time lower layers are idle. This layer is the «core» of Z-Uno firmware.
- Z-Wave Application layer maps Z-Uno Channel's capabilities and Association groups to Z-Wave Command Classes to fully conform Z-Wave Plus protocol. This layer also provides standard Z-Wave features like firmware upgrade by air or by USB (OTA and OTW), AES encryption of all radio packets, radio power metering, battery monitoring, wakeup configuration and basic information about the device itself.
- Z-Wave Network layer based on Sigma Designs 6.5x SDK handles network and radio layers of Z-Wave communications establishing reliable two-way mesh network between all devices in your smart home. This layer calculates routes to reach destination, prepares and sends radio packets and receives packets from other devices.
User code (also called sketch) should be compiled in Arduino IDE with additional Z-Uno Core Libraries installed (see how to install it). Like Arduino sketches, Z-Uno sketches are ordinary firmwares compiled for corresponding microcontroller. But in contrast to Arduino based on AVR microcontrollers, Z-Uno is based on Z-Wave microcontroller, which is 8051 compatible. Hence, instead of AVRDUDE Z-Uno uses SDCC compiler.
There is one more difference from Arduino sketches: Z-Uno sketches need to interact with three other layers of Z-Uno. This interaction is done via Z-Uno Core Libraries compiled together with your sketch.
User code can be loaded into Z-Uno from Arduino IDE via «Over-The-Wire» firmware upgrade (connect your Z-Uno via micro USB cable) or via «Over-The-Air» from any Z-Wave controller supporting firmware upgrade of Z-Wave devices.
All there underlying layers (User code bootoader, Z-Wave Application and Network layers — all together) can also be uploaded via USB (use «Upload Bootloader» in Arduino IDE menu) or via Z-Wave firmware upgrade.
Note! If you change number or type of Channels or Association groups or power mode, new sketch will be applied only after exlcusion-inclusion process. This means that you can change logic of your sketch on the fly, but you can not change Z-Wave characteristics. For fast development you can use special configuration parameter to make these changes immediate. Note that this will not work on all controllers. But hopefully RaZberry/Z-Way can handle Channels and Associations changes after a simple «Force Interviewe», while power mode change will require Re-Inclusion of Z-Uno (without exclusion).