HomeGenie Forum

Development => Feature request => Topic started by: smeghead on November 22, 2014, 01:37:00 PM

Title: UDP Capability from Scripts
Post by: smeghead on November 22, 2014, 01:37:00 PM
Hi All

TCP capability was added several months ago, I'm asking here as a feature request for UDP capability because the MiLight series of Home Automation LED lights use a 3 byte protocol to a UDP port on the WiFi control box.  I already have this working as a prototype and will post the app as a plugin scripting at some point over the coming weeks when I have tidied it up.

In the mean time, attached are the C# library files I have created in HomeGenie to add UDP capability, can you please review and incorporate in to the main build.  They are a copy of the TCP files with minor adjustments so there shouldn't be any surprises. I have properly tested the sending of data but only done partial testing on the receipt of data. 
As well as the 2 files in the zip file I have also added the following:
In CSharpAppFactory.cs
            compilerParams.ReferencedAssemblies.Add("UdpClientLib.dll");

And copied the Tcp code to create a Udp equivalent in ScriptingHost.cs

Thanks
Title: Re: UDP Capability from Scripts
Post by: Gene on November 29, 2014, 10:16:56 PM
Hi smeghead,

thanks for sharing this. I've added it with some minor changes to HG.
I'll be committing the new code by tomorrow.
Do you have any chance to test from source code or do you need a testing package (deb or tgz)?


Cheers,
g.
Title: Re: UDP Capability from Scripts
Post by: smeghead on November 30, 2014, 02:12:41 PM
Hi G,

Thanks for the update. I've grabbed build r434 this morning and had a couple of problems building it, easy things for you to update though:

I had to alter (I did it with a text editor) the windows solution and project files to search and replace TcpClientLib to NetClientLib

And secondly, I had to add the following to ScriptingHost.cs
Code: [Select]
        public UdpClientHelper UdpClient
        {
            get
            {
                return udpClientHelper;
            }
        }

This allowed my "MiLight" script to use the UdpClient OK.  It only sends udp data and then only 3 bytes at a time so it's not really a proper test.  I'll try and rig up a separate udp sender programme to send data for HG to receive and see how it goes.

I'm ready to upload my "MiLight" script for wider community use but do you want me to wait until you've made the changes to the core software and released it, I'm sorry but I don't really know the process for this kind of thing

The MiLight script also works with EasyBulb, they're basically the same with a different label on it. You can find them here:
http://easybulb.com/en/ (http://easybulb.com/en/)
http://www.milight.com/ (http://www.milight.com/)

Cheers
Smeghead
Title: Re: UDP Capability from Scripts
Post by: smeghead on November 30, 2014, 02:19:06 PM
Hi G,

.... and 1 more thing I changed in the main build r434, I forgot to mention it.   I changed this line in CSharpAppFactory.cs

Code: [Select]
            compilerParams.ReferencedAssemblies.Add("TcpClientLib.dll");to
 
Code: [Select]
           compilerParams.ReferencedAssemblies.Add("NetClientLib.dll");
I'm not sure if this is important though?

Cheers
Smeghead
Title: Re: UDP Capability from Scripts
Post by: Gene on November 30, 2014, 02:42:22 PM
Yes it it... =) thanks for the fix, I'll apply this to the next commit.

Cheers,
g.
Title: Re: UDP Capability from Scripts
Post by: smeghead on December 01, 2014, 12:45:23 AM
Hi Gene,

I grabbed r435 and it still didn't build and run first time, a couple of things similar to last time:

This code:
Code: [Select]
        public UdpClientHelper UdpClient
        {
            get
            {
                return udpClientHelper;
            }
        }

Needs adding to ScriptingHost.cs and the VS10 solution file still referenced TcpClientLib instead of NetClientLib in HomeGenie_VS10.sln like this:

Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetClientLib", "..\MigFiles\SupportLibraries\NetClientLib\NetClientLib.csproj", "{318D2523-3C8B-4273-B1EA-DE339868403C}"
EndProject

Cheers
Smeghead
Title: Re: UDP Capability from Scripts
Post by: Bitcraze on December 18, 2014, 09:32:44 PM
Hi,

MiLight Bridge: Wifi removed and connected directly to Raspberyy PI:

http://servernetworktech.com/2014/09/limitlessled-wifi-bridge-4-0-conversion-raspberry-pi/ (http://servernetworktech.com/2014/09/limitlessled-wifi-bridge-4-0-conversion-raspberry-pi/)


Something to keep in mind, as people have mentioned the Wireless on the Bridge is flaky.