Expected completion time of this lab: 30 min.
Import the Node-RED flow
JSON version of the flow
[{"id":"199af7.a1743509","type":"comment","z":"c139f50c.3569c8","name":"Receive (OAP) Data from Motes","info":"","x":144.5,"y":41.399993896484375,"wires":[]},{"id":"49df2dc8.d46e94","type":"http in","z":"c139f50c.3569c8","name":"","url":"/oap","method":"post","swaggerDoc":"","x":154.50001525878906,"y":91.80000305175781,"wires":[["c8b75215.b6828","d6286a67.b8c818"]]},{"id":"c8b75215.b6828","type":"http response","z":"c139f50c.3569c8","name":"","x":283.5000305175781,"y":125.80000305175781,"wires":[]},{"id":"d6286a67.b8c818","type":"debug","z":"c139f50c.3569c8","name":"OAP data","active":false,"console":"false","complete":"payload","x":487.49998474121094,"y":91,"wires":[]},{"id":"7d30604e.95298","type":"comment","z":"c139f50c.3569c8","name":"Receive Network Events","info":"","x":126,"y":174.1999969482422,"wires":[]},{"id":"4b28489a.1c2fa8","type":"http in","z":"c139f50c.3569c8","name":"","url":"/event","method":"post","swaggerDoc":"","x":166.1999969482422,"y":220.1999969482422,"wires":[["a47b7d8.7d1628","d68f4ba8.043958"]]},{"id":"a47b7d8.7d1628","type":"http response","z":"c139f50c.3569c8","name":"","x":285.20001220703125,"y":254.1999969482422,"wires":[]},{"id":"d68f4ba8.043958","type":"debug","z":"c139f50c.3569c8","name":"network events","active":false,"console":"false","complete":"payload","x":509.19996643066406,"y":219.39999389648438,"wires":[]},{"id":"d433e897.8b8cb8","type":"comment","z":"c139f50c.3569c8","name":"Receive Health Reports from Motes","info":"","x":159.1999969482422,"y":296.2000274658203,"wires":[]},{"id":"a9e59d5c.9567b","type":"http in","z":"c139f50c.3569c8","name":"","url":"/hr","method":"post","swaggerDoc":"","x":155.39999389648438,"y":338.20001220703125,"wires":[["2b219055.ab415","8a469c05.278e9"]]},{"id":"2b219055.ab415","type":"http response","z":"c139f50c.3569c8","name":"","x":284.40000915527344,"y":372.20001220703125,"wires":[]},{"id":"8a469c05.278e9","type":"debug","z":"c139f50c.3569c8","name":"health reports","active":false,"console":"false","complete":"payload","x":508.39996337890625,"y":337.40000915527344,"wires":[]},{"id":"5ee2ed7d.828904","type":"comment","z":"c139f50c.3569c8","name":"Control LED","info":"","x":88.19999694824219,"y":419.2000274658203,"wires":[]},{"id":"29849f11.52853","type":"inject","z":"c139f50c.3569c8","name":"ON","topic":"","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"x":81.5,"y":468.80003356933594,"wires":[["ff888848.377278"]]},{"id":"61aeaeaa.a4de8","type":"inject","z":"c139f50c.3569c8","name":"OFF","topic":"","payload":"0","payloadType":"num","repeat":"","crontab":"","once":false,"x":84.19999694824219,"y":521.2000274658203,"wires":[["ff888848.377278"]]},{"id":"273c8a.e391b376","type":"http request","z":"c139f50c.3569c8","name":"","method":"use","ret":"obj","url":"","tls":"","x":541.5000152587891,"y":494.00013732910156,"wires":[["559b3921.d3c1c8"]]},{"id":"ff888848.377278","type":"change","z":"c139f50c.3569c8","name":"mote label","rules":[{"t":"set","p":"motelabel","pt":"msg","to":"58f578","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":234.5000457763672,"y":495.80003356933594,"wires":[["4962ba44.c5fe54"]]},{"id":"4962ba44.c5fe54","type":"function","z":"c139f50c.3569c8","name":"","func":"msg.method = 'PUT';\nmsg.url = 'http://127.0.0.1:8080/api/v1/oap/00-17-0d-00-00-58-f5-78/digital_out/INDICATOR_0';\nmsg.payload = {\n 'value': msg.payload\n};\nreturn msg;","outputs":1,"noerr":0,"x":383.49998474121094,"y":496.0000762939453,"wires":[["273c8a.e391b376"]]},{"id":"559b3921.d3c1c8","type":"debug","z":"c139f50c.3569c8","name":"response","active":false,"console":"false","complete":"payload","x":693.2000274658203,"y":492.2000274658203,"wires":[]}]
To import the flow above in your Node-RED instance:
- copy the string above (triple-click to select, then copy with Ctrl+C)
- in your Node-RED editor, on the hamburger menu on the upper right, select "Import" > "Clipboard"
- paste the string (Ctrl+V) and click "Import"
- activate the flow by clicking on the "Deploy" button
Receive (OAP) Data from Motes
- enable the "OAP data" debug node
- each OAP data notifications received by the manager from a mote appears in the debug panel
- unfold one of the events of with the "channel_str" of "temperature". The temperature reported by the node is the
fields/samples[0]
sample, in 1/100th of a degree C. In the example above, 27.03 C - disable the "OAP data" debug node
Receive Network Events
- enable the "network events" debug node
- to generate network events, power cycle a node (switch it off, then on)
- a series of network events are reported by the manager, and displayed in the debug panel
- when power cycling a node, the following event happens:
- "eventPathDelete": the mote re-joins, so the manager deletes all the paths (wireless communication opportunities) with its neighbors
- "eventMoteJoin": the mote initiated a joining procedure
- "eventPathCreate": the mote creates new paths to its neighbors
- "eventMoteOperational": the mote has fully joined the network
- disable the "network events" debug node
Receive Health Reports from Motes
- enable the "network events" debug node
- whenever the manager received a health report from a mote, it appears in the debug panel
- disable the "network events" debug node
Control LEDs
- enable the "network events" debug node
- choose a node in your network, ensure:
- its "LED EN" jumper is in place (so the LEDs are enabled)
- both green LED are on (meaning the mote has joined the network)
- read the unique identifier of the node from the QR-code sticker
- double-click on the "mote label" node and enter the 6-digits exactly as printed on the sticker, then click "Done"
- Click "Deploy" to activate your changes
You can now click on the ON and OFF nodes to control the LED
switch the (blue) LED on switch the (blue) LED off