Esempio n. 1
0
function disconnectCurrentPeripheral(){
	currentPeripheral.disconnect();
	console.log( currentPeripheral.advertisement.localName + ' disconnected');
	currentPeripheral = null;
	noble.startScanning([], true);
	state = 'scanning';
}
Esempio n. 2
0
noble.on('stateChange', function (state) {
    console.log('STATE: ' + state);
    if (state === 'poweredOn') {

        noble.startScanning(['a495ff10c5b14b44b5121370f02d74de'], false);
    }
});
Esempio n. 3
0
noble.on('stateChange', function(state) {
  console.log('Noble -> stateChange: ' + state);

  if(state==='poweredOn'){
  	noble.startScanning([], true);
  }
});
Esempio n. 4
0
noble.on('stateChange', function(state) {
  console.log('Noble -> stateChange: ' + state);
  if (state === 'poweredOn') {
    noble.startScanning([], true); // start scanning with repeated UUIDs
    setupSerial();
  }
});
Esempio n. 5
0
 BlueYeast.prototype._handleStatechanged = function() {
   if (noble.state == 'poweredOn') {
     noble.startScanning();
     noble.on('discover', this._handleDevicefound.bind(this));
     //noble.removeEventListener('stateChange', this._handleStatechanged);
   }
 };
Esempio n. 6
0
function startScanHelper() {
  if (shuttingDown || scanning)
    return;
  scanning = true;
  if (noble.state === 'poweredOn')
    noble.startScanning([], true);
}
	this.ddbstateChange = function( state ){
	  if (state === 'poweredOn') {
		  noble.startScanning();
	  } else {
		  noble.stopScanning();
	  }	
	}
 var startScanningOnPowerOn = function() {
   if (noble.state === 'poweredOn') {
     noble.startScanning([SERVICE_UUID], allowDuplicates);
   } else {
     noble.once('stateChange', startScanningOnPowerOn);
   }
 };
Esempio n. 9
0
 Device.prototype.handleDisconnect = function (peripheral) {
     var device = this;
     console.log('DISCONNECTING');
     device.disconnected = true;
     console.log('start scanning!');
     noble.startScanning([Device.Primary_Service_UUID]);
 }
Esempio n. 10
0
BlePeripherals.prototype._handleStateChanges = function(state){
	if(state === 'poweredOn'){
		noble.startScanning();
	}else{
		noble.stopScanning();
	}
};
Esempio n. 11
0
Proxy.prototype.acquireTarget = function(config) {
  console.log(('[status] Acquiring target ' + this.target).bold);

  /* Track BLE advertisement reports. */
  if (this.le_adv_handler != null)
      noble._bindings._gap._hci.removeListener(
        'leAdvertisingReport',
        this.le_adv_handler
      )
  this.le_adv_handler = function(status, type, address, addressType, report, rssi){
    this.discoverDeviceAdv(address, report, rssi);
  }.bind(this);
  noble._bindings._gap._hci.on(
    'leAdvertisingReport',
    this.le_adv_handler
  );
  /*
  noble._bindings._gap._hci.on(
    'leAdvertisingReport',
    function(status, type, address, addressType, report, rssi){
      this.discoverDeviceAdv(address, report, rssi);
    }.bind(this));
  */
  /* Track BLE advertisement reports. */
  noble.on('discover', function(peripheral){
      if (peripheral.address.toLowerCase() === this.target.toLowerCase()) {
        noble.stopScanning();
        this.connectDevice(peripheral, config);
      }
    }.bind(this)
  );

  /* Start scanning when ble device is ready. */
  noble.startScanning();
};
noble.on('stateChange', function(state){
  console.log('stateChange:', state);
  if(state === 'poweredOn'){
    console.log('scan: started');
    noble.startScanning();
  }
});
Esempio n. 13
0
module.exports = function (timeout, serviceUuid, peripherals, done) {
    noble.on('discover', discover.bind({peripherals:peripherals}));

    noble.startScanning([serviceUuid]);
    console.log('Scanning for BLE devices...');
    setTimeout(stopandreturn.bind({done:done, peripherals:peripherals}), timeout);
};
Esempio n. 14
0
noble.on('stateChange', function(state) {
  if (state === 'poweredOn') {
    noble.startScanning();
  } else {
    noble.stopScanning();
  }
});
Esempio n. 15
0
  EventEmitter.call(self);      // make a copy of EventEmitter so you can emit events

  // The scanning function:
  function scan(state) {
    if (state === 'poweredOn') {    // if the radio's on, scan for this service
      noble.startScanning([serviceUUID], false);
    }
    // emit a 'scanning' event:
    self.emit('scanning', state);
  }
Esempio n. 16
0
 var startScanningOnPowerOn = function() {
   if (noble.state === 'poweredOn') {
     noble.startScanning(['39e1fa0084a811e2afba0002a5d5c51b'], true);
   } else {
     noble.once('stateChange', startScanningOnPowerOn);
   }
 };
Esempio n. 17
0
noble.on('stateChange', function (state) {
    console.log('stateChange >>> Device went to ' + state);
    if (state === 'poweredOn') {
        console.log('stateChange >>> Device is powered on, starting scanning...')
        noble.startScanning();
    }
})
Esempio n. 18
0
 _onStateChange: function(state) {
   if (state === 'poweredOn') {
     noble.startScanning(["180d"]);
   } else {
     noble.stopScanning();
   }
 },
Esempio n. 19
0
 noble.on('stateChange', function(state) {
   if (state === 'poweredOn'){
     noble.startScanning([self.serviceId], false);
   }else{
     noble.stopScanning();
   }
 });
Esempio n. 20
0
BTProximity.prototype.init = function() {
  console.log("Initing...");
  noble.startScanning([], true);
  if (!this.lastSeen) {
    this.lastSeen = new Date().getTime(); // Pretend we're here.
    this.present = true;
  }
};
 noble.on('stateChange', function(state) {
   if (state === 'poweredOn') {
     noble.startScanning(SCAN_UUIDS, false);
   } else {
     noble.stopScanning();
     reject('bluetooth fff?');
   }
 });
 noble.on('stateChange', function(state) {
   if (state === 'poweredOn') {
     noble.startScanning(deviceClass.SCAN_UUIDS | [], this.SCAN_DUPLICATES);
   } else {
     noble.stopScanning();
     reject('bluetooth off?');
   }
 });
Esempio n. 23
0
BrickBLE_server.prototype.startScanning	= function(continuousScan) {
	console.log( "BrickBLE_server::startScanning", continuousScan );
	this.BLE_server.continuousScan = continuousScan?true:false;
	if( !this.BLE_server.scanning && noble.state === "poweredOn") {
		noble.startScanning();
	}
	this.emit( "update_BrickBLE_sever", {continuousScan: this.BLE_server.continuousScan} );
}
Esempio n. 24
0
	noble.on('scanStop', function() {
		if(server.BLE_server.continuousScan && server.BLE_server.scanning) {
			noble.startScanning();
		} else {
			server.BLE_server.scanning = false;
			server.emit("update_BrickBLE_sever", {scanning: server.BLE_server.scanning} );
		}
	});
Esempio n. 25
0
noble.on('stateChange', function(state) {
    if (state === 'poweredOn') {
        console.log("Starting scan...");
        noble.startScanning([], true);
    } else {
        noble.stopScanning();
    }
});
Esempio n. 26
0
noble.on('stateChange', function (state) {
  console.log('state change', state);
  if (state === 'poweredOn') {
    noble.startScanning();
  } else {
    noble.stopScanning();
  }
});
noble.on('stateChange',function(state){
	if(state == 'poweredOn'){
		console.log("Bluetooth stateChange, start scanning...");
		noble.startScanning([],true);
	}else{
		noble.stopScanning();
	}
});
Esempio n. 28
0
noble.on('stateChange', function(state) {
    if (state === 'poweredOn') {
        noble.startScanning(['bbb0']);
    } else {
        noble.stopScanning();
        alert('Please enable Bluetooth');
    }
});
Esempio n. 29
0
function onDisconnect()
{
  beacon.removeListener('disconnect', onDisconnect);
  console.log('disconnected!');

  noble.on('discover', onDiscover);
  noble.startScanning();
}
Esempio n. 30
0
noble.on('stateChange', function(state) {
  if (state === 'poweredOn') {
    noble.startScanning();
    console.log('Searching for Angel Sensor')
  } else {
    noble.stopScanning();
  }
});