Hi Dave
Thanks for advice. I'm not at home right now, so can not check it (I'll do it tonight). But I'm sure, I'm not catching an error.
Program.RaiseEvent(module, "Status.Level", "1", "Switch" + switchid);
module.Parameter("Status.Level").Value ="1";
are executed.
My widget reacting on Control.ON/Off action, but arduino node is not receiving any message.
By saying "I would also check the status of module", you mean variable module in not null in my script when webservicecall happening?
I've tested this node using "Mycontroller.org" and relay is reacting on web requests(node receiving a proper message).
BTW: I'm not sure but, is not that serial communication using com port exclusively? I mean ,once port is opened and "listener" (read from port) is enabled, the same thread can not use it for (write) at the same time? Is SerialPort Helper handling async read/write?
Or maybe
Program.RunAsyncTask(()=>{
SerialPort.SendMessage(node+";"+switchid+";1;0;2;1");
return true;
});
will do the job? I'm not an expert just guessing ;-)
switch(command)
{
case "Control.On":
SerialPort.SendMessage(node+";"+switchid+";1;0;2;1");
Program.RaiseEvent(module, "Status.Level", "1", "Switch" + switchid);
module.Parameter("Status.Level").Value ="1";
res = "{ 'ResponseValue' : 'OK' }";
break;
// eg. http://hg_address/api/HomeAutomation.ArduinoSwitches/1/Control.Off
case "Control.Off":
SerialPort.SendMessage(node+";"+switchid+";1;0;2;0");
Program.RaiseEvent(module, "Status.Level", "0", "Switch " + switchid);
module.Parameter("Status.Level").Value ="0";
res = "{ 'ResponseValue' : 'OK' }";
break;
}
Thanks again
Cheers,
siepacz