Comments (5)
Aaannd it does. A single blink and the device goes off. No attempt to connect to anything else. :)
I'll look to publishing a new version with this functionality a bit later today.
from node-poweredup.
The subscribe/unsubscribe methods are used at connection time of a new device (color sensor, tilt sensor, etc) to tell the sensor what mode to put itself in. They are automatically called by this library when it detects a new device/sensor.
For example, the "color and distance sensor" shipped with the Boost tookit has several modes - one where it only reports color values, one where it only reports distance values, one where it reports both, etc. There are a couple more.
The reason they exist is that by only reporting the values the receiver cares about, it can save BLE bandwidth by not sending out the rest of the data that the receiver has indicated it doesn't care about.
For simplicity's sake, this library automatically puts the Boost sensor into "color and distance" mode, as you can just ignore the values you don't care about, and I've yet to run into any issues (or hear of anyone running into issues) with BLE bandwidth limits.
This is the function that sets the default modes: https://github.com/nathankellenicki/node-poweredup/blob/master/src/hub.ts#L415-L432
If you want (and the reason these methods are public rather than private), you can set the sensors into different modes - but, WARNING! :) I have not tested the sensor message parsing code with other modes other than the defaults I've set, and as they currently don't check, it may break!
Regarding your second question - you will only reconnect if you are still scanning. So you should call stop() on your PoweredUP instance before you disconnect your Hub instance.
However I believe the power off talked about in that thread is a hard power off - immediate shutdown, no blinking lights, no attempt to reconnect. Almost like flicking a switch. But I haven't tested it yet.
from node-poweredup.
thanks, now it makes more sense :) I had a feeling that it is something low level
from node-poweredup.
Yes, you can stop scanning, but if you have hub and remote control and you want to disconnect them, they will then find each other and connect, so hard shut down would be good to have
from node-poweredup.
Well that would only happen if a) both devices were disconnected at the same time, and b) both the remote and the hub had been paired together at some point in the past, but agreed, a hard shutdown would be good, as it would stop other devices/people who are scanning from connecting to it.
Hopefully it works as advertised. :)
from node-poweredup.
Related Issues (20)
- Cannot Be Used In JS Frameworks (React/Vue/etc) HOT 5
- RSSI Always -60 HOT 1
- osx monterey m1 not working HOT 10
- Problem running examples on Mac OS Monteray HOT 1
- Duplo Train Base does not connect (most times) HOT 1
- any way to run on iphone
- missing Mario case in _determineLPF2HubType
- Tachomotor & Absolutemotor
- Running into build error when installing HOT 1
- Cannot connect to Hub HOT 5
- Race in _determineLPF2HubType HOT 1
- wechat miniprogram environment support
- Installation Failed
- Question: how is this._mode determined? HOT 3
- Documentation for migrating versions?
- add RGB and HSV to Technic Color Sensor HOT 1
- RemoteHub "button" event doesn't work! HOT 2
- Error: Cannot find module '@abandonware/bluetooth-hci-socket' HOT 3
- Feature request: Mario volume support
- question/feature request : micro:bit compatibility
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-poweredup.