cmvee / bt-presence Goto Github PK
View Code? Open in Web Editor NEWnode.js module that uses linux l2ping to detect the presence of bluetooth devices
License: Apache License 2.0
node.js module that uses linux l2ping to detect the presence of bluetooth devices
License: Apache License 2.0
It seems that l2ping on my Linux system fails for the first ping but succeeds after that. As a test, I was scanning for my phone. I had to adjust the bt-presence index.js to send 2 pings.
$ sudo l2ping -c 3 -t 5 B0:C5:59:9C:9C:EE
Ping: B0:C5:59:9C:9C:EE from A4:34:D9:5A:45:77 (data size 44) ...
no response from B0:C5:59:9C:9C:EE: id 0
0 bytes from B0:C5:59:9C:9C:EE id 1 time 784.26ms
0 bytes from B0:C5:59:9C:9C:EE id 2 time 19.07ms
3 sent, 2 received, 33% loss
It'd be nice if you could set the type of combination you want to check for presence when there are several addresses. As far as I could test, if you use several comma separated addresses, true is return when ALL are present, false otherwise. I'd like the node to return true if ANY is present. Maybe you could add a new setting to set ANY or ALL, or maybe some type of notation for the Devices setting, like "(mac1 || mac2) && mac3"...
When a npm run build
is called with "strict": true
in tsconfig.json
the following error is generated;
src/index.ts:33:13 - error TS2564: Property 'timer' has no initializer and is not definitely assigned in the constructor.
33 private timer: NodeJS.Timer;
~~~~~
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! [email protected] build: `tsc`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2018-11-26T18_45_47_603Z-debug.log
# npm -v
6.4.1
# node -v
v8.12.0
Clearing to false build module.
In case I'm stopping and starting btPresence again, I get:
TypeError: Cannot read property 'bind' of undefined
2|node-red | 18 Dec 23:23:52 - [error] [bt-presence:41b0680f.ecda98] TypeError: Cannot read property 'bind' of undefined
2|node-red | at btPresence.start (/home/pi/nodes/node_modules/bt-presence/index.js:130:37)
It would be nice to be able to get separate events (present/not-present) for each device in the list. It is certainly easy for a developer to put in logic to manage devices in groups, so that doesn't seem really necessary (though I understand the use-case).
But without separate events per device there is really no way to implement presence for multiple entities...
Instead of only emitting the result on a change, could you offer a setting that enabled the result to be emitted every time please?
Lines 248 to 263 in 28a3ace
You might want to add some documentation to the README.md that l2ping needs to run as root.
Grant root privileges to run the l2ping scan by issuing this command:
$ sudo setcap 'cap_net_raw+eip' `which l2ping`
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.