NOTE: This API is in Beta- the names and functionality may change. Specifically we expect to replace the Ipse name with Pipe before launch
Each service offered by the IoT device is exposed with a websocket-like interface that will be familiar to web-developers. Each service is accessed by name e.g.:var camPipe = duct.createDataChannel("camera", {});Once opened a pipe can be used:
camPipe.onopen = function() { camPipe.send(JSON.stringify({command: "read"})); };The exact semantics of each pipe depend on it's purpose. See "Supported Services" for more details. In general however each pipe looks a lot like a websocket, supporting onopen,onmessage,onclose events and a send() message. Most pipes send and recieve JSON messages, but some do not.
ipsecert.ksin the current directory.
claim.htmlpage to scan the QRCode and thereby validating their proximity to (hence implied ownership of) the new device.
PipeDB.whoAmI(gotId, function(err) { console.log("could not create identity " + err); });
function gotId(id){ duct = new PipeDuct(id); duct.getWs.onopen = function() { chooseDevice(); } }
function chooseDevice(){ PipeDb.dbListPrint(makeDc); }
function makeDc(friends) { duct.setNonce(""); duct.setTo(friends[friends.length -1].finger); camPipe = pipe.createDataChannel("camera", {}); camPipe.onopen = function() { camPipe.send(JSON.stringify({command: "read"})); }; camPipe.onmessage = onDcMessage; }
feature | label | usage | Device dependencies | JSON? | description | example | doc |
---|---|---|---|---|---|---|---|
echo | echo | ch.send("hello"); | none | no | Device echos all received messages | Echo | |
tick | tick | none | no | sends a timestamp every second | Tick | ||
cert | cert | {id: "1", action: "list"} | none | yes | CRUD for certs | claim.html | Cert |
shell | shell | {command: "write",text:"ls -l"} | none | yes | runs "/bin/sh -i" on the device, sending received commands to the shell and returning stdout and stderr responses | shell.html | |
test | test | none | no | ||||
Beaglebone Analog in | AIN[0-6] | {command: "start"} | BeagleBone only | no | Sends values(voltages) read from /sys/devices/ocp.*/helper.*/AIN* every 30 seconds | solar.html | |
Artik Analog in | in_voltage0_raw | {command: "start"} | Artik only | yes | Reads from /sys/devices/126c0000.adc/ on Artik | park.html | |
DigitalOut | GPIO60 | {command: "write",value:"1"} | /sys/class/gpio/GPIO60 | yes | Reads and writes to GPIO digital pin | ||
PWM out | pwm[1-4] | {command: "write",value:"1000000"} | /sys/class/pwm/pwmchip0/ (Edison only) | yes | Sends duty cycle value for digital output | tardis.html | |
CPU Temperature | thermal_zone[0-4] | {command: "start"} | /sys/class/thermal/thermal_zone | yes | Reads from /sys/class/thermal/thermal_zone0/temp and sends back values every 5s | tbone.html | |
Open Pixel Command | opc:127.0.0.1:7890 | { command: "paint", pixels: [0x0,0xffffff]} | assumes LedScape is running on localhost | yes | Send array of pixel RGB values to LedScape neopixel driver | morse.html | |
Bidirectional realtime audio | rtpmic | {type:"upgrade",time:Date.now()} | rtpmic script, softphone, mic | yes | Upgrades peer connection to support realtime bi-directional audio over RTP - uses opus codec. Script starts local 'softphone' with rtp parameters pointing at localhost | rtpmic.html | |
Stills camera | camera | {command: "read"} | camera.sh script and mjpeg camera pipe to camera on device or local network | yes | Runs local script './camera.sh' to capture mjpegs from camera and write them into the named pipe './camera' - most recent frame is base64 encoded and sent on read command | camera.html | |
Write to display | screen | {command:"show",tag:b64image} | only supported on screens running Xwindows | yes | Allows browser to send base64 encoded jpeg to show on device screen | none | |
Database access | redis | {command: "zrange", args : [hourS,"0","-1"]} | redis running on localhost | yes | Provides read/search access to stored sensor data on device. | ||
Write to pipe | fakerfid | {command: "write", value:"rfid=1234"}; | named pipe 'fakerfid' | yes | Writes to the file './fakerfid' whci may be a named pipe - other processes can read from that file | fakerfid.html | |
Proxy for Node.js | tcp/127.0.0.1/9000 | none | no | Opens a bidirectional socket to port 9000 on the device and proxies data with the channel in the browser | compass.html | ||
Proxy for websocket | ws://localhost:8181/websocket or ws://localhost:8181/websocket_api or ws://localhost:8181/bin_ws | none | no | Opens a bidirectional websocket proxy to a websocket local to the device. Useful for wrapping pre-existing web admin consoles | none | ||
Proxy for http | http://localhost:8181/ or http://localhost:8080/ | {command:"index.html",method:"GET"} | webservice running on device, bound to localhost | yes | Opens a http 1.1 connection to a device-local webserver, serves only GET requests returns JSON containing status, headers and a base64 encoded body | none | |
Remote terminal | term | mypty/pty | no | Opens a bidirectional connectio to a unix ptty which spawns a shell as the local user. Useful in combination with terminal.js - disable on prduction devices | term.html | ||
Temp friend | iphonetempfriend | {action: "introduce" ,id:"FF..."} | none | yes | Performs temp introduction - cert isn't stored. Devices can only support a single temp-friend at a time. Used to support ephermeral users - and early safari versions | ishake.html |
PipeDb.dbDelPrint(tofinger, dcb);to do that. (see delete.html)