by
1,488 14
0
5
1,453
1
Top 1% !
Popular
Famous
Specified
OpenSource
Created
Modified Jan 21, 2018

Published on:

No tags for this snippet yet.
Languagehtml
LicenseMIT_X11
OSmongoose

Using simple RPC service

Use simple rpc script to call RPC service on small IOT devices
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/3424724/Using-simple-RPC-service?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
<html> <head> <script src="simple_rpc_service.js"></script> </head> <body onLoad='startup();'> <h4 id="hostname"> </h4> <p>Hello, see <a target="_blank" href="/rpc/Config.Get">rpc</a> <br><a target="_blank" href="/rpc/clearAll">clear strip</a> <p><table> <tr><td>Pin</td> <td><input type="number" id="GPIO.pin" value='2'/></td></tr> <tr><td>Red</td><td><input type="range" id="rval" name="rval" min="0" max="255" value='0' onchange="setPixel()"/></td></tr> <tr><td>Green</td><td><input type="range" id="gval" name="gval" min="0" max="255" value='0' onchange="setPixel()"/></td></tr> <tr><td>Blue</td><td><input type="range" id="bval" name="bval" min="0" max="255" value='0' onchange="setPixel()"/></td></tr> </table> <p><button href="#" id="setPixel" onclick="setPixel()">Set Pixel</button> <button href="#" id="clearAll" onclick="callRPCService('clearAll')">Clear All Pixel</button> <p><button href="#" id="setPixel" onclick="rebootDevice()">Reboot</button> <script> var log = function(msg) { console.log(msg); }; log('Starting ...'); function setPixel() { log("setPixel..."); var pin = parseInt(document.getElementById("GPIO.pin").value); var rv = parseInt(document.getElementById("rval").value); var gv = parseInt(document.getElementById("gval").value); var bv = parseInt(document.getElementById("bval").value); callRPCService('setPixel',{px:pin, r:rv, g:gv, b:bv}); }; </script> </body> </html>
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus