Giter Club home page Giter Club logo

Comments (5)

nathankellenicki avatar nathankellenicki commented on May 17, 2024 1

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.

nathankellenicki avatar nathankellenicki commented on May 17, 2024

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.

mihazelnik avatar mihazelnik commented on May 17, 2024

thanks, now it makes more sense :) I had a feeling that it is something low level

from node-poweredup.

mihazelnik avatar mihazelnik commented on May 17, 2024

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.

nathankellenicki avatar nathankellenicki commented on May 17, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.