Hi all,
I finally completed a working version of the program.
Some questions:
1. I suppose Program.RaiseEvent() is needed, as without it I cannot see the widget change when the light is turned on/off (Control.On and Control.Off). Is it needed even in Control.Level and Control.ColorHsb?
2. When the light is turned off, brightness is turned to 0. When the light is turned on, brightness is turned to 100. Why?
3. For each message to send, the program open a new TCP connection, send the message and then close it. Is it correct? What is the best way?
4. In the log, for each sent message, there is this error:
2016-01-31 23:11:27.8442 Info HomeAutomation.WiFiLed 0 WiFiLed Light Status.Level 0
2016-01-31 23:11:27.8475 Info WebServiceGateway 192.168.0.2 HTTP GET 200 /api/HomeAutomation.WiFiLed/0/Control.Off/null/ [CLOSED AFTER 2,485 seconds]
System.IO.IOException: Read failure ---> System.ObjectDisposedException: The object was used after being disposed.
at System.Net.Sockets.Socket.Receive (System.Byte[] buffer, Int32 offset, Int32 size, SocketFlags flags) [0x00000] in <filename unknown>:0
at System.Net.Sockets.NetworkStream.Read (System.Byte[] buffer, Int32 offset, Int32 size) [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at System.Net.Sockets.NetworkStream.Read (System.Byte[] buffer, Int32 offset, Int32 size) [0x00000] in <filename unknown>:0
at NetClientLib.TcpClient.ReceiverLoop (System.Object obj) [0x00000] in <filename unknown>:0
2016-01-31 23:11:29.8522 Info HomeAutomation.WiFiLed 0 WiFiLed Light Status.Level 1
Maybe this is related to point 4.
Thank you all for your help.