Home AMX User Forum AMX Technical Discussion

SC-N8002 Javascript JSON requests

Hi All,

I am new to AMX control gear and have been asked to control some third party devices with an SC-N8002 using a JSON request. I have only really used the SC-N8002 to control third party devices with Ascii and Hex.

The JSON interface uses the following paramaters

http://<serverIP>/triplecare/JsonRpcHandler.php]http:///triplecare/JsonRpcHandler.php?
call={"jsonrpc":"2.0","method":"ChannelUp","params":[1]}

From what I can tell the SC-N8002 is utilizing some javascript. Is it capable of performing these requests? Can I do it with a 'xmlhttprequest'?

For example I was trying to do something like this.

var xhttp = new XMLHttpRequest();
xhttp.open("POST", "http://192.168.1.1/triplecare/JsonRPCHandler.php?");
xhttp.setRequestHeader("Content-type", "application/json");
xhttp.send(JSON.stringify({
"jsonrpc": "2.0",
"method": "ChannelUp",
"params": [5462]
}));

Thank you for your help

Comments

  • I am assuming you're looking to do this control from Panel Builder? In which case, yes, it should be supported (simple test is to open a new panel, preview it, and test/load it in console).

    If you're trying to do it from external control via a script or macro - then no, it wouldn't currently be supported.

  • LongLarryLongLarry Posts: 3

    Yes I am doing this in panel builder. I was just putting this script within a buttons conditions. Should this activate when a button is pressed? Or am I missing a line of code somewhere for this to run.
    Thanks

  • I would create a function in the setup script and then call it from the button press. That way it'd be easier to adjust to the different buttons/commands and parse feedback.

    I would have to have a device to use/test with to be more easily able to setup and help.

    Can you execute this from a browser directly (IE, create a new panel, preview it, and then execute it in console) to test it first?

  • LongLarryLongLarry Posts: 3

    That was a good idea. Thankyou! I was able to see through the console that there was a problem with the URL. I was using a capital letter when it should have been lowercase.

    Thanks again!

Sign In or Register to comment.