How to use noble - 10 common examples

To help you get started, we’ve selected a few noble examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jmaxxz / keymaker / node_tools / src / lib / lock_scanner.js View on Github external
this.start = function start(){
    noble.on('stateChange', function(state) {
      if (state === 'poweredOn') {
        noble.startScanning(["bd4ac6100b4511e38ffd0800200c9a66"], false);
        this.emit('start');
      } else {
        noble.stopScanning();
        this.emit('stop');
      }
    }.bind(this));

    noble.on('discover', async peripheral => {
      // things seem pretty unstable if one starts looking
      // at the peripheral immediately.
      await delay(500);
      if(!peripheral.advertisement.manufacturerData || peripheral.advertisement.manufacturerData.length < 20) {
        return;
      }
github lab11 / polypoint / phone / tritag.js View on Github external
noble.on('stateChange', function (state) {
	if (state === 'poweredOn') {
		// Note, tritag *does not* advertise it's service uuid, only eddystone/summon
		noble.startScanning(SUMMON_SERVICE_UUIDS, true);

		console.log('Started scanning.');
	}
});
github demirhanaydin / node-mi-flora / index.js View on Github external
startScanning() {
    if (noble.state === 'poweredOn') {
      noble.startScanning([], true);
    } else {
      // bind event to start scanning
      noble.on('stateChange', function (state) {
        if (state === 'poweredOn') {
          noble.startScanning([], true);
        }
      });
    }
  }
github peterlee0127 / YeeLight-Blue-2 / ble.js View on Github external
function startDiscover(devices){
    noble.on('stateChange', function(state) {
        if (state === 'poweredOn'){
            if(!Array.isArray(devices)) {
                console.log("please set startDiscover([])");
                process.exit();
            }
            discover(devices);
        }
        else{
            noble.stopScanning();
        }
    });
}
exports.startDiscover = startDiscover;
github jacopotagliabue / anki-drive-python-sdk / node_app / node_socket_app / node_server.js View on Github external
noble.on('stateChange', function(state) {
    if (state === 'poweredOn')
    {
        console.log("powered on!");
        noble.on('discover', function(device) {
            console.log(util.format("SCAN|%s|%s", device.id, device.address));
        });
        noble.startScanning(ANKI_DRIVE_SERVICE_UUIDS);
        setTimeout(function() {
           noble.stopScanning();
           console.log("SCAN|COMPLETED");
        }, 2500);
    }
});
github saphero / sphero-hack / setup / setup-bb8.js View on Github external
module.exports = exports = (callback) => {
  console.log('Beginning setup');
  noble.startScanning();
  noble.on('discover', (peripheral) => {
    if (_.includes(peripheral.advertisement.localName, 'BB-')) {
      var deviceUUID = peripheral.uuid;
      var localName = peripheral.advertisement.localName;
      console.log('Writing to config file');
      console.log('BB8 UUID - "' + deviceUUID + '"');
      console.log('Local Name: ' + localName);
      var config = require('home-config').load('.bb8config', {
        BB8_UUID: deviceUUID,
        BB8_LOCAL_NAME: localName
      });
      config.save();
      noble.stopScanning();
      console.log('Connected to ' + config.BB8_LOCAL_NAME);
      console.log('Saved config file to ~/.bb8config');
      callback();
    } else {
github new-davinci / node-flexbot / lib / flexbot.js View on Github external
that.connect = function (callback) {
    noble.on('discover',function (p) {
      if (FLEX_SIGNATURES.indexOf(p.advertisement.localName) >= 0  || p.advertisement.serviceUuids.indexOf('ffe0') >= 0) {
        console.log('Discovered a Flexbot.')
        that.copter = p;
        that.copter.connect(function () {
          console.log('Connected to Flexbot.');
          noble.stopScanning();
          that.copter.discoverServices(['ffe0'], function (error, services) {

            if(error){
              callback(error);
            } else {
              services[0].discoverCharacteristics(['ffe1'], function (error, characteristics) {
                if(error){
                  callback(error);
                } else {
                  that.BLECharacteristic = characteristics[0];
github ChrisScheffler / miflora / lib / miflora2.js View on Github external
await new Promise((resolve, reject) => {
					noble.startScanning([ROOT_SERVICE_UUID], true, error => {
						if (error) {
							return reject(error);
						}
						return resolve();
					});
				});
				await wait(timeout);
github tigoe / BluetoothLE-Examples / noble / updateRSSI / updateRSSI.js View on Github external
function scan(state){
  if (state === 'poweredOn') {
    noble.startScanning();
    console.log("Started scanning");   
  } else {
    noble.stopScanning();
    console.log("Is Bluetooth on?");
  }
}
github tigoe / BluetoothLE-Examples / stickNfindExample / stickNfindExample.js View on Github external
function scan(state){
  if (state === 'poweredOn') {
    noble.startScanning();
    console.log("Started scanning");   
  } else {
    noble.stopScanning();
    console.log("Is Bluetooth on?");
  }
}

noble

A Node.js BLE (Bluetooth Low Energy) central library.

MIT
Latest version published 7 years ago

Package Health Score

30 / 100
Full package analysis

Popular noble functions