more G-Labs products

Author Topic: UDP Capability from Scripts  (Read 2157 times)

November 22, 2014, 01:37:00 PM
Read 2157 times

smeghead

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

November 29, 2014, 10:16:56 PM
Reply #1

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer
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.

November 30, 2014, 02:12:41 PM
Reply #2

smeghead

  • *
  • Information
  • Newbie
  • Posts: 17
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://www.milight.com/

Cheers
Smeghead

November 30, 2014, 02:19:06 PM
Reply #3

smeghead

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

November 30, 2014, 02:42:22 PM
Reply #4

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer
Yes it it... =) thanks for the fix, I'll apply this to the next commit.

Cheers,
g.

December 01, 2014, 12:45:23 AM
Reply #5

smeghead

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

December 18, 2014, 09:32:44 PM
Reply #6

Bitcraze

  • ***
  • Information
  • Full Member
  • Posts: 73
Hi,

MiLight Bridge: Wifi removed and connected directly to Raspberyy 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.