Home AMX User Forum NetLinx Studio

Need Help with http Code

I am trying to send a http string to the web server of a video IP box so it will change the video channel it is looking at on the network. Here is what I put into the Firefox address bar to get it to change to ch 1:

http://169.254.4.132/cgi-bin/c.cgi?1

Here is one example of a string I have tried to send that does not work. I have tried many variations.

SEND_STRING dvAAVARA,"'POST http//169.254.4.132/cgi-bin/c.cgi?1'"

Clearly I am missing something that probably involves using http 'GET' or 'POST' correctly. AMX email tech support tells me that this can be done. Can someone please show me the correct way to send this string?

Thanks,
Jay Sulzberg

Comments

  • AMXJeffAMXJeff Posts: 450
    drplaid wrote: »
    Clearly I am missing something?


    // try this...
    SEND_STRING dvAAVARA,"'POST /cgi-bin/c.cgi?1 HTTP/1.1',13,10,13,10"
    

    // or try this...
    SEND_STRING dvAAVARA,"'GET /cgi-bin/c.cgi?1  HTTP/1.1',13,10,13,10"
    

    // or even this...
    SEND_STRING dvAAVARA,"'GET /cgi-bin/c.cgi?1  HTTP/1.1',13,10,'Host: 169.254.4.132',13,10,13,10"
    
  • nickmnickm Posts: 152
    drplaid wrote: »
    I am trying to send a http string to the web server of a video IP box so it will change the video channel it is looking at on the network. Here is what I put into the Firefox address bar to get it to change to ch 1:

    http://169.254.4.132/cgi-bin/c.cgi?1

    Here is one example of a string I have tried to send that does not work. I have tried many variations.

    SEND_STRING dvAAVARA,"'POST http//169.254.4.132/cgi-bin/c.cgi?1'"

    Clearly I am missing something that probably involves using http 'GET' or 'POST' correctly. AMX email tech support tells me that this can be done. Can someone please show me the correct way to send this string?

    Thanks,
    Jay Sulzberg

    First things first. Are you familiar with socket connections, particularly their behavior in regards to the HTTP protocol? If not, here's a rough outline of the process:

    1. Open client connection from AMX to device
    2. Verify socket has opened properly and without error.
    3. Send HTTP header (in the form of a GET or POST).
    4. Await and collect the response from the device.
    5. Once the response reaches the delimiter ("$0d,$0a,$0d,$0A"), close the socket.
    6. Profit????

    If you need help with the general process, there are lots of resources already posted to this forum. I, for one, have open sourced my module for Boxee Box/XBMC (you should be able to find it via search). Others have posted on the topic as well.

    Best of luck.
  • drplaiddrplaid Posts: 7
    Thanks AMX Jeff

    The last example you showed me worked.
    (SEND_STRING dvAAVARA,"'GET /cgi-bin/c.cgi?1 HTTP/1.1',13,10,'Host: 169.254.4.132',13,10,13,10")
    Thanks for the help. The 'Host:' is not needed as you will see in the final code below.

    In case anyone else comes across these HDMI to IP boxes from Aavara, here is what I am sending to get a receiving box to change the video stream 'channel' it is looking for:

    DEFINE_CALL 'SWITCH TO CH'(DISPLAY,CH)
    {
    SEND_STRING dvAAVARA,"'GET /cgi-bin/c.cgi?',ITOA(CH),'HTTP/1.1',13,10,AAVARA_ADDRESS[DISPLAY],13,10,13,10
    }

    In this call, AAVARA_ADDRESS[DISPLAY] is a array of the IP addresses of the RX boxes so the command knows which box IP to send to. 'CH' is the stream channel to switch to. The call is sent simple integers like 5,17. It's just like sending input and output to a switcher. CH is the input, DISPLAY is the output.
    The only down side to this way of doing it is that you have to make and maintain IP connections to all of your display boxes, which in this case is 68.(!)

    Fortunately, there is another way to do it which is to send a command to a transmitting box and it will relay it out to the receiving box. That way, I have to only maintain a connection to one TX box.
    That looks like this:
    SEND_STRING dvAAVARA,"'GET /cgi-bin/tele_r_ch_switch.cgi?',AAVARA_ADDRESS[DISPLAY],'%20',ITOA(CH),' HTTP/1.1',13,10,13,10"

    Again, thanks for the help. I hope this helps anyone who needs it.
Sign In or Register to comment.