Coder Social home page Coder Social logo

node-flic-buttons's Introduction

##node-flic-buttons

A NodeJS node to interact with the flic.io BLE buttons.

This node requires the fliclib-linux-dist daemon to handle the low level comunication with the buttons. You will need to install this (and the correct version of bluez) before you start.

The node supports all method that can be accesses by the C++ library made available in the fliclib-linux-dist package.

  • startScan
  • stopScan
  • connectButton
  • disconnectButton

connectButton and disconnectButton take the button MAC address of the button

var flic = require('node-flic-buttons');

var buttons = new flic();
// defaults to localhost:5000 else
//var buttons = new flic(host, port);

The buttons object will emit the following events

  • online - when connected to the daemon
  • offline - when disconnected from the daemon
  • discovered - when a button is discoverd (as part of a scan)
  • connected - when a button is connected
  • disconnected - when a button is disconnected
  • click - when a button is clicked, double clicked or long clicked

The discovered, connected, disconnected, and click all pass objects along with the event

flic.on('click', function(clickEvt){
  //{"deviceId":"80:E4:DA:70:XX:XX","queued":false,"timeDiff":0,"isSingleClick":true,"isDoubleClick":false,"isHold":false}
  if (clickEvt.isSingleClick) {
    ...
  } else if (clickEvt.isDoubleClick) {
    ...
  } else if (clickEvt.isHold) {
    ...
  }
});

I'm not 100% confident the startScan, stopScan, connect all work 100% of the time. You can pair buttons manually with the flic command that ships with the fliclib-linux package using the following actions:

  • Ensure that bluetoothd and the daemon are running
  • run flic
  • type the command startScan
  • press the flic button (you may have to press and hold for 7 seconds to unlock if it has been previously paired)
  • type the command stopScan
  • type the command list, this will show all known flic.io buttons
80:E4:DA:70:XX:XX [Disconnected]
  • type connect [80:E4:DA:70:XX:XX] where [mac address is the button you want to pair]
  • you should now see something that looks like
Connected to: 80:E4:DA:70:XX:XX
Verified: 80:E4:DA:70:XX:XX
  • the button should now be paired

node-flic-buttons's People

Contributors

hardillb avatar

Stargazers

 avatar Sabin Tudor avatar Jesús Darío avatar Kristofer Hjelmtorp avatar Richard James avatar Timon Reinhard avatar Yannick avatar Andy avatar Matjaž Lipuš avatar Thomas Grinderslev avatar  avatar Kiko Marrs avatar Matt avatar Umar Hansa avatar nauwep avatar Nate W avatar  avatar Connor Knabe avatar Julien Breux avatar sweet pi - sweet home avatar Mike Boehm avatar

Watchers

Thomas Grinderslev avatar Alex avatar Andy avatar  avatar Gui Lima avatar  avatar

Forkers

chrismaz11

node-flic-buttons's Issues

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.