@Tango2 I had been doing this a different way until I noticed the GW should be able to do it. BTW, It is only working on one node, not sure why :(.
Anyway, my alternate solution allows be to send "settings: to the nodes. For example, change the loop time or measurement unit.
This is not the complete code, just the relevant parts (hopefully).
void setup()
{
gw.begin(incomingMessage, nodeID);
}
void loop()
{
gw.process();
}
void incomingMessage(const MyMessage &message) {
if (message.type == 97) {
Serial.print("Recvd Time");
Serial.println(time);
timeReceived=true;
}
if (message.type == 98) {
int reqsleep = atoi( message.data );
SLEEP_TIME = reqsleep*1000;
Serial.print( "Changing sleep to: " );
Serial.println( String(reqsleep) );
}
if (message.type == 99) {
int requnit = atoi( message.data );
Serial.print( "Changing units to: " );
if(requnit == M){
metric = true;
Serial.println( "metric" );
} else {
metric = false;
Serial.println( "imprerial" );
}
}
}
Using this code, I can send things from openhab, or any serial command I suppose.
My openhab rules
Send Units:
sendCommand(Arduino, "101;99;1;0;99;M\n")
Send Time:
var Number time1
time1 = now().getMillis() / 1000
sendCommand(Arduino, "101;97;1;0;97;" + time1 + "\n")