Agile oximeter with auto-reconnect

Monitoring every 15 sec the device connection status, and auto-reconnecting it, when it goes disconnected.

[{"id":"b27afe09.e7525","type":"debug","z":"aa642aa9.a0fd08","name":"","active":false,"console":"false","complete":"false","x":695,"y":304,"wires":[]},{"id":"72a6671e.4237a8","type":"function","z":"aa642aa9.a0fd08","name":"","func":"value = JSON.parse(msg.payload).value;\nif (value != 255) \n    return {payload: value};\nelse\n    return null;","outputs":1,"noerr":0,"x":542,"y":387,"wires":[["b27afe09.e7525","1087fe94.0a4ff1","870910a9.550da"]]},{"id":"1087fe94.0a4ff1","type":"ui_chart","z":"aa642aa9.a0fd08","name":"Pulse","group":"22e651a1.ab2d6e","order":1,"width":"6","height":"4","label":"Pulse","chartType":"line","legend":"false","xformat":"%H:%M:%S","interpolate":"linear","nodata":"","ymin":"","ymax":"","removeOlder":"30","removeOlderUnit":"1","x":694,"y":361,"wires":[[],[]]},{"id":"8de6ae5b.87b4","type":"debug","z":"aa642aa9.a0fd08","name":"","active":false,"console":"false","complete":"false","x":693.5,"y":452,"wires":[]},{"id":"3d91c687.a89eba","type":"ui_chart","z":"aa642aa9.a0fd08","name":"Perfusion Index (PI)","group":"22e651a1.ab2d6e","order":3,"width":"6","height":"4","label":"Perfusion Index (PI)","chartType":"line","legend":"false","xformat":"%H:%M:%S","interpolate":"linear","nodata":"","ymin":"","ymax":"","removeOlder":"30","removeOlderUnit":"1","x":753.5,"y":525,"wires":[[],[]]},{"id":"4a4e69c6.003aa8","type":"debug","z":"aa642aa9.a0fd08","name":"","active":false,"console":"false","complete":"false","x":694.5,"y":591,"wires":[]},{"id":"3e452060.3a9ba","type":"function","z":"aa642aa9.a0fd08","name":"","func":"value = JSON.parse(msg.payload).value;\nif (value != 255) \n    return {payload: value};\nelse\n    return null;","outputs":1,"noerr":0,"x":542.5,"y":665,"wires":[["4a4e69c6.003aa8","4257f15b.e7843"]]},{"id":"4257f15b.e7843","type":"ui_chart","z":"aa642aa9.a0fd08","name":"Oxygen Saturation (SpO2)","group":"22e651a1.ab2d6e","order":4,"width":"6","height":"4","label":"Oxygen Saturation (SpO2)","chartType":"line","legend":"false","xformat":"%H:%M:%S","interpolate":"linear","nodata":"","ymin":"","ymax":"100","removeOlder":"30","removeOlderUnit":"1","x":774.5,"y":664,"wires":[[],[]]},{"id":"c3bc5377.b266e","type":"websocket in","z":"aa642aa9.a0fd08","name":"Subscribe.PULSE","server":"","client":"d4987823.01a298","x":390,"y":332,"wires":[["72a6671e.4237a8","b27afe09.e7525"]]},{"id":"7eb6cdf8.c307c4","type":"websocket in","z":"aa642aa9.a0fd08","name":"Subscribe.PI","server":"","client":"7aae65cc.f42a9c","x":369.5,"y":461,"wires":[["f79a3499.efddc8"]]},{"id":"bdaa6600.018958","type":"websocket in","z":"aa642aa9.a0fd08","name":"Subscribe.SpO2","server":"","client":"23e18705.2196e8","x":380.5,"y":612,"wires":[["3e452060.3a9ba"]]},{"id":"f79a3499.efddc8","type":"function","z":"aa642aa9.a0fd08","name":"","func":"value = JSON.parse(msg.payload).value;\nif (value != 255) \n    return {payload: value};\nelse\n    return null;","outputs":1,"noerr":0,"x":541.5,"y":526,"wires":[["8de6ae5b.87b4","3d91c687.a89eba"]]},{"id":"870910a9.550da","type":"ui_gauge","z":"aa642aa9.a0fd08","name":"Pulse","group":"22e651a1.ab2d6e","order":2,"width":"6","height":"4","gtype":"gage","title":"Pulse","label":"units","format":"{{value}}","min":"30","max":"150","colors":["#00b500","#e6e600","#ca3838"],"x":697,"y":407,"wires":[]},{"id":"c29e532.0fb65b","type":"inject","z":"aa642aa9.a0fd08","name":"","topic":"","payload":"","payloadType":"date","repeat":"15","crontab":"","once":false,"x":369,"y":195,"wires":[["86dbc600.8d8fb8"]]},{"id":"86dbc600.8d8fb8","type":"exec","z":"aa642aa9.a0fd08","command":"curl -X GET --header 'Accept: application/json' 'http://agile-core:8080/api/device/bleF4B85E8D514A/status'","addpay":true,"append":"","useSpawn":"","timer":"15","name":"DeviceStatus","x":551,"y":192.5,"wires":[["104f0032.21e4d","5eb73645.1b2be8"],[],[]]},{"id":"5eb73645.1b2be8","type":"debug","z":"aa642aa9.a0fd08","name":"","active":true,"console":"false","complete":"false","x":884.5,"y":150,"wires":[]},{"id":"104f0032.21e4d","type":"function","z":"aa642aa9.a0fd08","name":"IsDisconnected","func":"if (JSON.parse(msg.payload).status == \"DISCONNECTED\")\n    return msg;\nelse\n    return null;","outputs":1,"noerr":0,"x":741,"y":195,"wires":[["5eb73645.1b2be8","7004b08c.806c9"]]},{"id":"7004b08c.806c9","type":"exec","z":"aa642aa9.a0fd08","command":"curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' 'http://agile-core:8080/api/device/bleF4B85E8D514A/connection'","addpay":false,"append":"","useSpawn":"","timer":"15","name":"DeviceConnect","x":950.5,"y":193,"wires":[[],[],[]]},{"id":"22e651a1.ab2d6e","type":"ui_group","z":"aa642aa9.a0fd08","name":"Oximeter","tab":"d49e9e37.6c99d","disp":true,"width":"12"},{"id":"d4987823.01a298","type":"websocket-client","z":"aa642aa9.a0fd08","path":"ws://agile-core:8080/ws/device/bleF4B85E8D514A/PULSE/subscribe","wholemsg":"false"},{"id":"7aae65cc.f42a9c","type":"websocket-client","z":"aa642aa9.a0fd08","path":"ws://agile-core:8080/ws/device/bleF4B85E8D514A/PI/subscribe","wholemsg":"false"},{"id":"23e18705.2196e8","type":"websocket-client","z":"aa642aa9.a0fd08","path":"ws://agile-core:8080/ws/device/bleF4B85E8D514A/SpO2/subscribe","wholemsg":"false"},{"id":"d49e9e37.6c99d","type":"ui_tab","z":"aa642aa9.a0fd08","name":"Home","icon":"dashboard"}]
doitdagi

Flow Info

created 4 months, 2 weeks ago

Node Types

Core
  • debug (x4)
  • exec (x2)
  • function (x4)
  • inject (x1)
  • websocket in (x3)
  • websocket-client (x3)
Other
  • ui_chart (x3)
  • ui_gauge (x1)
  • ui_group (x1)
  • ui_tab (x1)

Tags

  • AGILE
  • MEDICAL-DEVICE
  • AUTO-RECONNECT
  • AGILE-GATEWAY
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option