more G-Labs products

Author Topic: Wi Fi Led Controller  (Read 1461 times)

January 04, 2016, 11:48:46 PM
Read 1461 times

marnic

  • *
  • Information
  • Newbie
  • Posts: 4
Hi,

please integrate an additional RGB LED controller, it's called "Wi Fi LED CONTROLLER".

This is a picture of the controller:
http://ecx.images-amazon.com/images/I/31pwKyafBCL._SX342_.jpg
It is wi-fi host that can be connected to an existing Wi-Fi network.

It can be controlled using the LED Magic Color Controller v2 Android app:
https://play.google.com/store/apps/details?id=com.Zengge.LEDWifiMagicColor

I googled to check how the app communicates with the controller and I see that it works using TCP messages. I also tested them and they works fine!

I am thinking to an RGB module, like Color Led here: https://www.youtube.com/watch?v=qRUlqEmEm2c. This module needs two parameters: TCP address and port (default: 5577)

TCP PROTOCOL
All commands are hexadecimal.

Turn on
cc 23 33

Turn off
cc 24 33

Color levels

56 <RR> <GG> <BB> aa

Examples:

- maximum color levels
56 ff ff ff aa

- maximum red level
56 ff 00 00 aa

- maximum green level
56 00 ff 00 aa

- maximum blue level
56 00 00 ff aa

Status

ef 01 77

This is a query command and the controller replies with its current status in this way:

bytes 0 1: fixed header
66 01

bytes 2: on/off status
23: on
24: off

byte 3:  use user input levels
41: user input levels
(any other value: preset mode)

byte 4: preset mode
20: no preset mode
21: preset mode (not used if byte 3 is 41)

byte 5: preset mode speed
<xx>
(not used if byte 3 is 41)

bytes 6 7 8: RGB channel levels
<RR> <GG> <BB>

bytes 9 10: fixed footer
<01> <99>


I suppose that user preset are not useful in HG, so bytes 3, 4, 5 can be simply ignored.

I can test the program and even try to debug/fix it: I only need a good starting point :)

Thank you so much for your work and Happy New Year!
« Last Edit: January 05, 2016, 08:39:35 AM by marnic »

January 05, 2016, 04:02:09 AM
Reply #1

dani

  • *****
  • Information
  • Global Moderator
  • Posts: 535
One question : one controler can control only one light ?
What is the price  for one light with its controler ?

January 05, 2016, 08:03:33 AM
Reply #2

KaZe

  • ****
  • Information
  • Sr. Member
  • Posts: 219
Hi!

I think you should check the MiLight control program in program list. (Program list/Devices and Thinks/MiLight control) This is the similar what you need. I think the best way to modifiy this program.

January 05, 2016, 10:47:45 AM
Reply #3

marnic

  • *
  • Information
  • Newbie
  • Posts: 4
@Dani
Yes, each controller controls a single RGB strip LED
The price is around 30-35€

@KaZe
Thanks

February 01, 2016, 12:14:06 AM
Reply #4

marnic

  • *
  • Information
  • Newbie
  • Posts: 4
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.