We worked really hard to resolve several issues affecting the sNET library for Arduino. But, first of all, we would like to say thank you to Rob Jann who gave us precious info to address them.
The new 0.2 version is now on our public github account (http://github.com/airqnetworks) and can be easily downloaded using git. We suggest downloading always versions that have reached a stable code point. Every time we are sure that the library is usable at all we release a new tag. The list of tags can be reached at https://github.com/airqnetworks/snet-arduino/tags.
This new release introduces a really important feature: library can now check if the status of relays is effectively changed when requested. Since sNET Protocol is a best effort protocol, it does nothing to ensure that a message is received by a device and version 0.1 of the library does nothing to address this. With this new release we introduced status check, and it can easily used passing an additional parameter to setRELAYx() method of an AIRQ310 or AIRQ300 object. Let’s see an example.
#include <sNET.h> #include <SoftwareSerial.h> sNET snet(1); void setup() { snet.begin(); } void loop() { AIRQ310 *board; snet.processMessages(); /* We ask the sNET object to give us the reference the device object * corresponding to 4.0.1.2 board. The method sNET::getDeviceForDeviceID() * will return a pointer to an AIR310 object if the object was already created, * otherwise it returns 0 (NULL). The device object is created as soon as * sNET library captures a message coming from that device */ if((board = (AIRQ310 *)snet.getDeviceForDeviceID(4,0,1,2)) != 0) { /* Ok, the AIRQ310 object was created and we can turn RELAY1 on */ board->setRELAY1(ON, true); /* This will block until library detects that RELAY1 is ON */ while(1); /* Job done. We stop here */ } }
Although we have done the best to reduce the size of the whole library, status check requires additional code that increases the total size of library of at least 500 bytes. If your application doesn’t need this feature, you can comment the macro SNET_ENABLE_CONFIRM in the sNET.h header file:
#ifndef __SNET_H #define __SNET_H #define SNET_ENABLE_CONFIRM //COMMENT THIS IF YOU DON'T NEED STATUS CHECK #include <Arduino.h> #include <SoftwareSerial.h> .....
However, to have a better experience using our control boards we suggest to leave that macro uncommented and use status check feature.