Page 1 of 1

Need Help with sending IP commands

Posted: Wed Apr 06, 2016 9:27 am
by Cheesegeezer
Hi again,

I've recently purchased a VeraPlus home controller to look after everything non-AV such as lights, cameras, etc.

I'm trying to get Demopad to use predefined commands to send data to the Vera controller.

I've set up new device in a test app prior to moving it over to the proper one, just so i don't wreck the main one i've been working on, but anyway.

I can "send data to a website" using http address and info no problems.



I open the Pre-defined Commands window and add a command as you can see in the screenshot below. When i hit the Test Command, it says it's send the command but nothing happens in the real world. Now I have tried adding various suffix's such as HTTP/1.0\x0D\x0A and variations of this. I've also tried using PUT and GET HTTP requests, using the variations of the suffix's.

I'm going nuts. Please can you help where I'm going wrong or what i've missed.

Image

Re: Need Help with sending IP commands

Posted: Wed Apr 06, 2016 9:39 am
by DemoPad

Re: Need Help with sending IP commands

Posted: Wed Apr 06, 2016 9:52 am
by Cheesegeezer
Thanks for the quick response...

Unfortunately it doesn't. i've read that post about a hundred times and nothing seems to work when i physically add a pre-defined command.

As stated, if I "send data to website" then a button will work, however this doesn't help with appliance state feedback.

Is there something i've missed in the pre-defined command. Also when the IP address is entered into the Device config, is this sent with a http:// prefix or not.

It appears that others are having similar issues using pre-defined commands (i did a search)

Re: Need Help with sending IP commands

Posted: Wed Apr 06, 2016 9:59 am
by DemoPad
The IP address should not have a http:// at the beginning

A simple GET command is as follows:

GET /somepage.html HTTP/1.0\x0D\x0A\x0D\x0A

However, different web servers require different parameters, for example HTTP/1.1 requires a host header, POST requests require Content-Length etc

If the 'send data to website' works (which is a GET request), then you could point the IP address at your computer & have Hercules running as a TCP Server with port 80, to see exactly what data is being sent out, and duplicate that.

This page, whilst quite old, is worth a read: https://www.jmarshall.com/easy/http/

Re: Need Help with sending IP commands

Posted: Wed Apr 06, 2016 10:42 am
by Cheesegeezer
Thanks again for the reply.

Well it connects to the socket. But it doesn't seem to send the information to the Vera or the Vera doesn't like the information it's receiving. I can see it in the TCP listener when i use the ip of the laptop.

Image

I've used an app on the ipad "HTTP Worker" which i can see the HTTP responses however that only sends the URL not a URI so i always get a 200 code back.

I'd really like to get to the bottom of this with your help if you don't mind.

Thanks in advance

Re: Need Help with sending IP commands

Posted: Wed Apr 06, 2016 11:33 am
by DemoPad
That looks like your command, not the 'send data to website' command that the iPad would send out if you didn't use a device / pre-defined commands. That is what you should look at - use 'send data to website' to fire commands to the Vera, to check they work, then change the IP address of the command to your laptop & see what the command is through Hercules. Also, right click the Hercules window & choose Hex Chars / Hex Special Chars so you can see all the carriage returns etc

Re: Need Help with sending IP commands

Posted: Wed Apr 06, 2016 3:05 pm
by Cheesegeezer
BOOOOM!! You are a legend.

Thanks so much. So it turns out i was adding the port to the host for HTTP/1.1 protocol. Doh!!

However I have to press the button twice in order for it to work.

Once I get this working fully i'll post up a tutorial.

Re: Need Help with sending IP commands

Posted: Wed Apr 06, 2016 3:15 pm
by Cheesegeezer
Just so you can see the full response to the request in Hercules :

Code: Select all

GET /data_request?id=action&DeviceNum=7&serviceId=urn:upnp-org:serviceId:Dimming1&action=SetLoadLevelTarget&newLoadlevelTarget=10 HTTP/1.1
Host: 192.168.0.107
Connection: keep-alive
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.110 Safari/537.36
Accept-Encoding: gzip, deflate, sdch
Accept-Language: en,en-US;q=0.8