Hi!I'm thinking a little bit about adding bluetooth support to use it for checking if I (or any other user) is at home. I tried a little bit in command line with hcitool and l2ping and I could find out the bluetooth address of my phone and also ping it. I'm wondering if there is any good node implementations for this? I noticed that l2ping is not runnable without root however, so I'm guessing there could be a problem doing this from node-red if I'm not running it under root?
--
http://nodered.org
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
http://nodered.org
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/HhTItZrXNkA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+u...@googlegroups.com.
--
dpkg --status bluez | grep '^Version:'
Version: 4.99-2
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
configure: error: GLib >= 2.28 is required
sudo apt-get install glib-2.6
functionGlobalContext: { noble:require('/home/pi/.node-red/node_modules/node-red-contrib-noble/node_modules/noble') // os:require('os'), // bonescript:require('bonescript'), // jfive:require("johnny-five"), // j5board:require("johnny-five").Board({repl:false}) },
var noble = context.global.noble;
Looks about right. Have you run the setcap command to allow non-root access ?
functionGlobalContext: { noble:require('/home/pi/.node-red/node_modules/node-red-contrib-noble/node_modules/noble') // os:require('os'), // bonescript:require('bonescript'), // jfive:require("johnny-five"), // j5board:require("johnny-five").Board({repl:false}) },
[{"id":"eb00084f.14fff8","type":"exec","z":"9703de.ff68fc2","command":"sudo hciconfig hci0 up","addpay":false,"append":"","useSpawn":"","name":"","x":559,"y":520,"wires":[[],[],[]]},{"id":"bb1be0fb.44e42","type":"inject","z":"9703de.ff68fc2","name":"","topic":"","payload":"","payloadType":"none","repeat":"","crontab":"","once":true,"x":130,"y":440,"wires":[["f1f8d3ce.0e073","e23458b3.1dcba8","1c4fa554.e3b05b","40e54401.bf1abc"]]},{"id":"6840f596.97bf0c","type":"comment","z":"9703de.ff68fc2","name":"Get the bluetooth adaptor running on startup","info":"","x":246.5,"y":360,"wires":[]},{"id":"1c4fa554.e3b05b","type":"exec","z":"9703de.ff68fc2","command":"sudo hciconfig hci0 down","addpay":false,"append":"","useSpawn":"","name":"","x":388,"y":440,"wires":[[],[],[]]},{"id":"549836fc.ab67c8","type":"function","z":"9703de.ff68fc2","name":"","func":"/*\n Continously scans for peripherals and prints out message when they enter/exit\n\n In range criteria: RSSI > RSSI_THRESHOLD_IN\n Out of range criteria: RSSI < RSSI_THRESHOLD_OUT\n\n*/\nvar noble = context.global.noble;\nvar RSSI_THRESHOLD_IN = -85;\nvar RSSI_THRESHOLD_OUT = -87;\nvar EXIT_CHECK_PERIOD = 2000; // milliseconds\nvar inRange = [];\n\nnoble.on('discover', function(peripheral) {\n if (peripheral.rssi < RSSI_THRESHOLD_IN) {\n // ignore\n return;\n }\n var id = peripheral.id;\n var entered = !inRange[id];\n if (entered) {\n inRange[id] = {\n peripheral: peripheral\n };\n msg.payload = ('\"' + peripheral.advertisement.localName + '\" entered (RSSI ' + peripheral.rssi + ') ' + new Date());\n node.send(msg);\n }\n inRange[id].lastSeen = Date.now();\n});\n\nsetInterval(function() {\n for (var id in inRange) {\n var peripheral = inRange[id].peripheral;\n if (peripheral.rssi < RSSI_THRESHOLD_IN) {\n msg.payload = peripheral.rssi;\n node.send(msg);\n }\n if (peripheral.rssi < RSSI_THRESHOLD_OUT) {\n msg.payload =('\"' + peripheral.advertisement.localName + '\" exited (RSSI ' + peripheral.rssi + ') ' + new Date());\n node.send(msg);\n delete inRange[id];\n }\n }\n}, EXIT_CHECK_PERIOD);\n\nnoble.on('stateChange', function(state) {\n if (state === 'poweredOn') {\n noble.startScanning([], true);\n } else {\n noble.stopScanning();\n }\n});\n","outputs":1,"noerr":0,"x":510,"y":680,"wires":[["3184b5bf.ce7b4a"]]},{"id":"3184b5bf.ce7b4a","type":"debug","z":"9703de.ff68fc2","name":"","active":true,"console":"false","complete":"payload","x":709,"y":680,"wires":[]},{"id":"813c8291.7ec38","type":"exec","z":"9703de.ff68fc2","command":"sudo setcap cap_net_raw+eip $(eval readlink -f `which node`)","addpay":false,"append":"","useSpawn":"","name":"","x":684,"y":580,"wires":[[],[],[]]},{"id":"f1f8d3ce.0e073","type":"delay","z":"9703de.ff68fc2","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":337,"y":520,"wires":[["eb00084f.14fff8"]]},{"id":"e23458b3.1dcba8","type":"delay","z":"9703de.ff68fc2","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":337,"y":580,"wires":[["813c8291.7ec38"]]},{"id":"40e54401.bf1abc","type":"delay","z":"9703de.ff68fc2","name":"","pauseType":"delay","timeout":"3","timeoutUnits":"seconds","rate":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":337,"y":680,"wires":[["549836fc.ab67c8"]]}]