Home AMX User Forum NetLinx Studio

Need Help Programming For Proliphix IP Thermostat

Updated: I have Figured out most of my problems, but still would like some help on one thing.

Here is what I am using for the SET command that works well and lets me set multiple OID's in one command:
UTTON_EVENT[tpTHERM1,150] // Send a SET command to the T-STAT
{
  PUSH:
  {
    IF(CONNECTED)
    {
		nTSTAT_COMMAND = "'OID4.1.5=650&OID4.1.6=770&submit=Submit'"
		SEND_STRING dvIP_TSTAT, "'GET pdp?',nTSTAT_COMMAND,' HTTP/1.1' ,crlf"
		SEND_STRING dvIP_TSTAT, "'Authorization: Basic ',Base64 ("'admin', ':',pass"),crlf"
		SEND_STRING dvIP_TSTAT, "'Host: ', myIPAddress.HostName,crlf"
		SEND_STRING dvIP_TSTAT, "crlf"
    }
  }
}
The SET code does not require the Content-Length: line in the header so I am ok there. Here is what I have for the GET commands:
BUTTON_EVENT[tpTHERM1,151] // Send a GET request to T-Stat
{
  PUSH:
  {
    IF(CONNECTED)
    {
		nTSTAT_COMMAND = "'?OID4.1.5='"
      SEND_STRING dvIP_TSTAT, "'POST /get',nTSTAT_COMMAND,' HTTP/1.1' ,crlf"
		SEND_STRING dvIP_TSTAT, "'Authorization: Basic ',Base64 ("'admin', ':',pass"),crlf"
		SEND_STRING dvIP_TSTAT, "'Host: ', myIPAddress.HostName,crlf"
		SEND_STRING dvIP_TSTAT, "'CONTENT-LENGTH: ', LENGTH_STRING(nTSTAT_COMMAND)"
		SEND_STRING dvIP_TSTAT, "crlf"
    }
  }
}
The problem is I cannot get the Content-Length: line of the header. If I need to request an OID with an index number (OID4.3.2.3) the content length is incorrect and therefore does not return anything.
If I try to request more than one OID in the same command, as the protocol shows, it just causes the thermostat to restart.
I think the reboot problem is because of an incorrect Content-Length:

Is there a better way to calculate the length? How do I take octets into account for longer content?

Thanks.

Comments

  • adysadys Posts: 395
    did you try to send hard coded string with hard coded size to see if this is the cause of the problem?

    if you performing get from IE is it work? like this?

    http://192.168.1.100:8100/get?OID4.1.13=

    or set?

    http://192.168.1.100:8100/pdp?OID4.1.1=2&submit=Submit
  • the8thstthe8thst Posts: 470
    Its always something simple .......

    I fixed my problems by changing the order of the strings to this:
    		IP_CLIENT_OPEN(dvIP_TSTAT.Port,'13.19.17.23',80,1)
    		CLEAR_BUFFER sIP_CLIENT_BUFFER
    		{
    			nTSTAT_COMMAND = "'/get?OID4.3.2.1=&OID4.1.5=&OID4.1.6=&OID4.1.1=&OID4.1.3=&OID4.1.9='"
    			SEND_STRING dvIP_TSTAT, "'GET ',nTSTAT_COMMAND,' HTTP/1.1' ,crlf"
    			SEND_STRING dvIP_TSTAT, "'Host: ',myIPAddress.HostName,crlf"
    			SEND_STRING dvIP_TSTAT, "'Authorization: Basic ',Base64 ("'admin', ':','whaley'"),crlf"
    			SEND_STRING dvIP_TSTAT, "crlf"
    

    The HTTP header needs to be in the correct order (duh).
    GET <directory and command> HTTP/1.1
    Host: your host information
    Authorization: Basic (un:pass pair)
    <blank line>

    Before I had the authorization and host lines reversed and it was causing all kinds of problems. Just thought I would share in case anyone else has a brain crash.
Sign In or Register to comment.