So, keep banging my head at this one...
I've got the MIDI-Relay server responding, but not reacting as I would have hoped...
I have the server responding just fine to a /refresh call, that was no problem with a regular HTTP Post as soon as I put a NULL in the datafield...
However, when trying to send a JSON command in the DataField with the asyncHTTP, I get a syntax error from the server.
I've recently contacted the developer of the MIDI-Relay software, so it might as well just be something on that end, but then again, he has some DashBoard examples on his site, so maybe someone might point me in the right direction here as well...
Here is the DashBoard used to send messages to the MIDI_Relay software:
<abs contexttype="opengear" dblinqport="2222" gridsize="20" id="_top" keepalive="true">
<meta>
<params>
<param access="1" maxlength="0" name="JSON CMD" oid="JSON_CMD" type="STRING" value="{midiport:'USB Midi 4i4o',midicommand:'noteon',channel:1,note:21,velocity:100}" widget="text"/>
</params>
</meta>
<button buttontype="push" height="120" left="40" name="<html><center>SEND TO<br/>MIDI RELAY</center></html>" top="40" width="140">
<task tasktype="ogscript">/*! block id=1002,1005 !*/
ogscript.asyncHTTP("http://127.0.0.1:4000/sendmidi", "POST", "application/json", params.getValue('JSON_CMD', 0), null);
/*!!
<block id="1002" type="ogscript_async" x="329" y="52" w="318" URL="http://127.0.0.1:4000/sendmidi" METHOD="POST" TYPE="application/json" DATA="ID:1005" CALLBACK="null" />
<block id="1005" type="param__top&amp;JSON CMD (JSON_CMD)[0]" x="32" y="89" w="243" SET="" />
!!*/
/*!!<checksum>a9542906b7bca962416de27520cabeea</checksum>!!*/</task>
</button>
<button buttontype="push" height="120" left="480" name="<html><center>REFRESH<br/>MIDI RELAY</center></html>" top="40" width="200">
<task tasktype="ogscript">/*! block id=1004 !*/
ogscript.asyncPost("http://127.0.0.1:4000/refresh",null, null);
/*!!
<block id="1004" type="ogscript_httppost" x="495" y="160" w="318" URL="http://127.0.0.1:4000/refresh" DATA="null" CALLBACK="null" />
!!*/
/*!!<checksum>72715f77abcaa8a60211fd1101a79a09</checksum>!!*/</task>
</button>
<param expand="true" height="40" left="40" oid="JSON_CMD" top="180" width="640"/>
<label height="40" left="40" name="Enter JSON command above and send to MIDI-Relay server" style="txt-align:west" top="220" width="640"/>
</abs>
And here is the response I get from the server when trying to send the message that is in the message field atm:
SyntaxError: Unexpected token m in JSON at position 1
at JSON.parse (<anonymous>)
at parse (C:\snapshot\midi-relay\node_modules\body-parser\lib\types\json.js:89:19)
at C:\snapshot\midi-relay\node_modules\body-parser\lib\read.js:121:18
at invokeCallback (C:\snapshot\midi-relay\node_modules\raw-body\index.js:224:16)
at done (C:\snapshot\midi-relay\node_modules\raw-body\index.js:213:7)
at IncomingMessage.onEnd (C:\snapshot\midi-relay\node_modules\raw-body\index.js:273:7)
at emitNone (events.js:111:20)
at IncomingMessage.emit (events.js:208:7)
at endReadableNT (_stream_readable.js:1064:12)
at _combinedTickCallback (internal/process/next_tick.js:139:11)
I've tried JSON.encode on the string. I've tried encodeURI, with either no response or same response.
I've tried setting it to something other than "application/JSON", no response at all.
I've tried setting server IP to 10.0.0.10 as well... Same results...
Does the function asyncHTTP do something under the hood that could mess this up?
Is this a character encoding issue I might have here?
#DashBoard