Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome General
 PowerHome Messageboard : PowerHome General
Subject Topic: UDP packets Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
narc
Groupie
Groupie
Avatar

Joined: November 21 2006
Location: United States
Online Status: Offline
Posts: 49
Posted: January 25 2007 at 01:05 | IP Logged Quote narc

And before I forget...

Can I send a UDP (user datagram protocol) packet out on the network? I like to use UDP to tell other servers status updates. I have LCD's in my house that display status, and they listen for UDP packets.

So far, the best I have been able to do is use a macro to call a VB program which creates a socket then sends the packet and exits. Not very efficient.

While we are on the topic, is there a way to listen on a port for a packet to arrive. I am aware of the socket server, but that is TCP and is heavyweight. I'm looking for a lightweight UDP socket to respond to packets.

- jason
Back to Top View narc's Profile Search for other posts by narc
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: January 25 2007 at 07:59 | IP Logged Quote TonyNo

Not sure if this is TCP or UDP, but...

What about the ph_sendsocketdata formula?

ph_sendsocketdata ( url, port, data )

For receiving packets, I believe that you need to set up a trigger of type Socket.
Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
narc
Groupie
Groupie
Avatar

Joined: November 21 2006
Location: United States
Online Status: Offline
Posts: 49
Posted: January 25 2007 at 11:37 | IP Logged Quote narc

I just tested ph_sendsocketdata("192.168.0.2",9000,"test") and it connects using TCP. It works, but I would love to have UDP for broadcast. With UDP you can set the destination address to "255.255.255.255" and all of your listening servers will get the info at about the same time. It is an excellent way to cut down network traffic.

- jason
Back to Top View narc's Profile Search for other posts by narc
 
narc
Groupie
Groupie
Avatar

Joined: November 21 2006
Location: United States
Online Status: Offline
Posts: 49
Posted: January 25 2007 at 11:38 | IP Logged Quote narc

Ok, the socket triggers are tough :)

Here is what I have done. I encoded jason:none into base64. I can connect to the PH socket server and send it text. I'm sure that I am connecting. Here is the text that I send it:

FORMULA\nAuthorization: Basic amFzb246bm9uZQ==\nContent-Length: 15\n\nph_tts("Hello")

I have a socket trigger setup to call a macro called TEST. I know that ph_tts works because I have called it from other macros. I neither hear text nor have macro TEST run. I am guessing that the socket server does not like my data.

- jason

Edited by narc - January 25 2007 at 11:53
Back to Top View narc's Profile Search for other posts by narc
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: January 25 2007 at 12:27 | IP Logged Quote dhoward

Jason,

PowerHome currently only has the Socket formulas. No support for UDP at the moment (I'll have to do some reading and educate myself ). If you've got some simple VB type code or similar that illustrates the functionality, I'll be happy to add support.

Yep, ph_sendsocketdata is TCP. You may also want to check out the ph_ping function for Ping capabilities.

Currently, the only way to listen on a port is with the Socket Server or the Web Server. With the next beta though, you'll be able to code up a simple ActiveX control in VB that can listen on any port for any type of traffic that you're interested in and respond to triggers or whatever.

The Socket Triggers work with the Socket Server. It's just a way to fire a trigger based upon an incoming Socket Server command. The Socket triggers do not work independently. You could get away without even having a Socket Trigger if you use a Socket Server command type of FORMULA and just pass the actual formula that you want to have evaluated. You can use the ph_ssrequest function in another instance of PowerHome or the DCC to create properly formatted Socket Server requests. Also, on the download page, check out the VB source code for PHSSCMD.EXE to see just how to put together a Socket Server command request.

Concerning your SS request string...it looks ok from this end. It should do the TTS just fine as long as the authorization matches your SS and of course the port and SS is setup and enabled. However, FORMULA will not fire a trigger and would require you to use FORMULATRIGGER to run a formula AND fire a trigger. You could also use TRIGGER1 thru TRIGGER5 to just fire the appropriate trigger without evaluating the formula.

Let me know if this helps,

Dave.
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
narc
Groupie
Groupie
Avatar

Joined: November 21 2006
Location: United States
Online Status: Offline
Posts: 49
Posted: January 25 2007 at 13:20 | IP Logged Quote narc

UDP is insanely easy. To do a UDP send in Visual Basic, you add a Winsock control. The following code will broadcast a packet:

winsockout.Protocol = sckUDPProtocol
winsockout.RemoteHost = "255.255.255.255"
winsockout.RemotePort = 1000
winsockout.SendData = "hello"

It is a connectionless protocol, so there is no connect or close.

On the other end, to set up a listener, you do the following:

winsockin.bind 1000

When a packet arrives, it will show up in the winsockin_DataArrival function. You get the data with

winsockin.GetData strData

That's it. I would like to be able to bind to a port, and when data arrives on that port, fire off a triggered event.

I would also like to be able to call a function like this:

ph_sendudp("255.255.255.255", 1000, "hello")

and that would send a UDP packet out to the broadcast address. My entire HA is done with UDP so I can share more if you like.

- jason
Back to Top View narc's Profile Search for other posts by narc
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: January 25 2007 at 15:14 | IP Logged Quote dhoward

Looks pretty easy. I'll code it up so it'll be in the next beta.

Dave.
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
narc
Groupie
Groupie
Avatar

Joined: November 21 2006
Location: United States
Online Status: Offline
Posts: 49
Posted: January 25 2007 at 15:23 | IP Logged Quote narc

Thanks! Between UDP, more than 5 com handles and a plug in archtitechture, I think I'll be really happy.

Thanks for all the hard work.

- jason
Back to Top View narc's Profile Search for other posts by narc
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: January 25 2007 at 17:23 | IP Logged Quote dhoward

Already coded it up. There is a new ph_sendudp function built-in to PowerHome and Ive gone ahead and created a UDP Listener Plugin that utilizes the new PowerHome plugin architecture.

Dave.
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
narc
Groupie
Groupie
Avatar

Joined: November 21 2006
Location: United States
Online Status: Offline
Posts: 49
Posted: January 25 2007 at 18:14 | IP Logged Quote narc

Sweet! That was fast. So when will the beta be available?

- jason
Back to Top View narc's Profile Search for other posts by narc
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: January 26 2007 at 17:34 | IP Logged Quote dhoward

Jason,

Heh, hopefully very soon. Im right in the middle of recoding the Insteon to handle the new Status and level methodology. There are over a 1000 lines of code that has to change just for this 1 modification (I got a little over 300 done last night).

Anyways, there are a few more tweaks that I need to get in and then I've got to code up the Database Upgrade Utility. If I had to put a time on it (people that have been around here awhile know how much I hate to do that ), I would probably say Im looking at a little less than 2 weeks.

Dave.
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
narc
Groupie
Groupie
Avatar

Joined: November 21 2006
Location: United States
Online Status: Offline
Posts: 49
Posted: February 12 2007 at 10:54 | IP Logged Quote narc

(warning: hot stick poking to follow)

So I waited the required 2 weeks before bugging you again.

Any idea when the new beta will be out? I'm very excited about the controller arch changes and the UDP stuff.

- jason
Back to Top View narc's Profile Search for other posts by narc
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum