Giter VIP home page Giter VIP logo

node-sdk's Introduction

node-situscale

Node.js interface for reading data from SITU® Smart Food Nutrition Scale over bluetooth low energy connection.

Badges

bitHound Overall Score bitHound Dependencies bitHound Code

Description

This package allows you to set up asynchronous notifications for weight update notifications from SITU scale.

SITU Scale

Install

You can install this package either with npm.

npm

npm install situscale

Synopsis

var SituScale = require('situscale');

var scaleInstance = new SituScale(address);

Discovering Situscales in your vicinity

You can discover situscales in your vicinity using this module if you do not have the address for your situscale.

// discover.js
var SituScale = require('situscale');

var scale = new SituScale();
scale.searchScales(function(scale) {
  // Callback run for every new scale discovered in the vicinity till stopSearching is called()
  console.log("Discovered SITU scale with address: " + scale.address);
});

// Stop Searching after 3 seconds
setTimeout(
  scale.stopSearching(),
  3000
);

Receiving weight notifications from SITU scale

Once you know the address for your SITU scale you can receive weight notifications from it as and when they happen. Note that the weight is always received in grams and you must convert it to other unit of calculation if you need to.

var SituScale = require('situscale');

var address = "c6:e3:c7:5e:fd:fc";
var scaleInstance = new SituScale(address);

scale.getWeight(function(weight){
  console.log(weight);
});

Turning weight notifications on or off after connecting.

You can turn off weight notifications and turn them on as needed intermittently to save scale battery. The scale will still be connected on bluetooth but it will not send notifications while the notifications are turned off this way.

var SituScale = require('situscale');

var address = "c6:e3:c7:5e:fd:fc";
var scaleInstance = new SituScale(address);

scale.getWeight(function(weight){ // This function is called each time a weight notification is received.
  console.log(weight);
});

// Stop weight notifications after 3 seconds
setTimeout(function(){
  scale.stopNotifications();
  console.log('stopped notifications');

  // Start weight notifications after another 3 seconds
  setTimeout(function(){
    scale.startNotifications();
    console.log('started notifications');
  });
});

Disconnecting from the scale

You can disconnect from the SITU scale when you are done using it. Note that in disconnected state the scale will automatically power down after some time at the moment.

var SituScale = require('situscale');

var address = "c6:e3:c7:5e:fd:fc";
var scaleInstance = new SituScale(address);

scale.getWeight(function(weight){ // This function is called each time a weight notification is received.
  console.log(weight);
});

// Stop weight notifications after 3 seconds
setTimeout(function(){
  scale.stopNotifications();
  console.log('stopped notifications');
  setTimeout(function(){
    scale.disconnect();
    console.log('disconnected');
  }, 3000);
});

License

The MIT License

Copyright (c) Shantanu Bhadoria. https://www.shantanubhadoria.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

##Copyrights and Trademarks All labels including SITU® Smart Food Nutrition are trademarks of their respective owners. Please refer http://situscale.com/copyrights-trademarks/ for trademark information. Permission has been sought and received from SITU to release this module under the MIT license.

node-sdk's People

Contributors

shantanubhadoria avatar

Watchers

 avatar

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.