var CONTROL_UUID = 'fff1'; var EFFECT_UUID = 'fffc'; var YeelightBlue = function(peripheral) { NobleDevice.call(this, peripheral); }; YeelightBlue.SCAN_UUIDS = [SERVICE_UUID]; YeelightBlue.is = function(peripheral) { var localName = peripheral.advertisement.localName; return ((localName === undefined) || (localName === 'Yeelight Blu')); }; NobleDevice.Util.inherits(YeelightBlue, NobleDevice); YeelightBlue.prototype.writeServiceStringCharacteristic = function(uuid, string, callback) { this.writeStringCharacteristic(SERVICE_UUID, uuid, string, callback); }; YeelightBlue.prototype.writeControlCharateristic = function(red, green, blue, brightness, callback) { var command = util.format('%d,%d,%d,%d', red, green, blue, brightness); for (var i = command.length; i < 18; i++) { command += ','; } this.writeServiceStringCharacteristic(CONTROL_UUID, command, callback); };
this.manufacturerData = (peripheral.advertisement.manufacturerData ? peripheral.advertisement.manufacturerData.toString('hex') : null); var serviceData = peripheral.advertisement.serviceData[0].data; this.address = serviceData.slice(0, 6).toString('hex').match(/.{1,2}/g).reverse().join(':'); this.addressData = new Buffer(this.address.split(':').join(''), 'hex'); this.measuredPower = serviceData.readInt8(6); this.major = serviceData.readUInt16LE(7); this.minor = serviceData.readUInt16LE(9); this._peripheral.on('disconnect', this.onDisconnect.bind(this)); this._onMotionDataBinded = this.onMotionData.bind(this); }; NobleDevice.Util.inherits(Estimote, NobleDevice); Estimote.SCAN_DUPLICATES = true; Estimote.is = function(peripheral) { var localName = peripheral.advertisement.localName; return ( (localName === 'estimote' || localName === 'EST') && // original || "new" name peripheral.advertisement.serviceData !== undefined && peripheral.advertisement.serviceData.length && peripheral.advertisement.serviceData[0].uuid === '180a'); }; Estimote.prototype.toString = function() { return JSON.stringify({ uuid: this.uuid,
this.type = 'cc2650'; this.mpu9250mask = 0; this.mpu9250notifyCount = 0; this.onMPU9250ChangeBinded = this.onMPU9250Change.bind(this); this.onLuxometerChangeBinded = this.onLuxometerChange.bind(this); }; CC2650SensorTag.is = function(peripheral) { var localName = peripheral.advertisement.localName; return (localName === 'CC2650 SensorTag') || (localName === 'SensorTag 2.0'); }; NobleDevice.Util.inherits(CC2650SensorTag, NobleDevice); NobleDevice.Util.mixin(CC2650SensorTag, NobleDevice.DeviceInformationService); NobleDevice.Util.mixin(CC2650SensorTag, Common); CC2650SensorTag.prototype.convertIrTemperatureData = function(data, callback) { var ambientTemperature = data.readInt16LE(2) / 128.0; var objectTemperature = data.readInt16LE(0) / 128.0; callback(objectTemperature, ambientTemperature); }; CC2650SensorTag.prototype.convertHumidityData = function(data, callback) { var temperature = -40 + ((165 * data.readUInt16LE(0)) / 65536.0); var humidity = data.readUInt16LE(2) * 100 / 65536.0; callback(temperature, humidity);
if (!idOrLocalName) { console.log("node hrm-device.js [ID or local name]"); process.exit(1); } var HRMDevice = function(device) { NobleDevice.call(this, device); }; HRMDevice.is = function(device) { var localName = device.advertisement.localName; return (device.id === idOrLocalName || localName === idOrLocalName); }; NobleDevice.Util.inherits(HRMDevice, NobleDevice); NobleDevice.Util.mixin(HRMDevice, NobleDevice.DeviceInformationService); NobleDevice.Util.mixin(HRMDevice, NobleDevice.HeartRateMeasumentService); var previous = 0; HRMDevice.discover(function(device) { console.log('discovered: ' + device); device.on('disconnect', function() { console.log('disconnected!'); process.exit(0); }); device.on('measumentChange', function(data) { console.log("update measument: " + data);
if (!(this instanceof Bean)) return new Bean(); NobleDevice.call(this, peripheral); EventEmitter.call(this); this.count = 0; this.gst = new Buffer(0); }; Bean.SCAN_UUIDS = [SERIAL_UUID]; util.inherits(Bean, EventEmitter); NobleDevice.Util.inherits(Bean, NobleDevice); Bean.prototype.connectAndSetup = function(callback) { var self = this; NobleDevice.prototype.connectAndSetup.call(self, function(){ self.notifyCharacteristic(SERIAL_UUID, BEAN_SERIAL_CHAR_UUID, true, self._onRead.bind(self), function(err){ if (err) throw err; self.emit('ready',err); callback(err); });
var AUTHORIZATION_UUID = '5ec0fffc3cf2a682e2112af96efdf667'; var FET_STATE_UUID = '5ec0fff23cf2a682e2112af96efdf667'; var VOLTAGE_UUID = '5ec0fff33cf2a682e2112af96efdf667'; var DEVICE_NAME_UUID = '5ec0fff93cf2a682e2112af96efdf667'; var Tethercell = function(peripheral) { NobleDevice.call(this, peripheral); }; Tethercell.SCAN_UUIDS = [SERVICE_UUID]; Tethercell.is = function(peripheral) { return (peripheral.advertisement.localName === undefined); }; NobleDevice.Util.inherits(Tethercell, NobleDevice); NobleDevice.Util.mixin(Tethercell, NobleDevice.DeviceInformationService); Tethercell.prototype.writeServiceDataCharacteristic = function(uuid, data, callback) { this.writeDataCharacteristic(SERVICE_UUID, uuid, data, callback); }; Tethercell.prototype.readServiceDataCharacteristic = function(uuid, callback) { this.readDataCharacteristic(SERVICE_UUID, uuid, callback); }; Tethercell.prototype.authorize = function(pin, callback) { this.writeServiceDataCharacteristic(AUTHORIZATION_UUID, new Buffer(pin, 'hex'), callback); }; Tethercell.prototype.readFetState = function(callback) {
NobleDevice.call(this, peripheral); var manufacturerData = peripheral.advertisement.manufacturerData; if (manufacturerData && manufacturerData.length === 8) { this.id = peripheral.advertisement.manufacturerData.toString('hex').match(/.{1,2}/g).reverse().join(':'); this.address = this.id.substring(0, 17); } this._keepAliveTimer = null; this.on('disconnect', this._onDisconnect.bind(this)); }; Lumen.SCAN_UUIDS = [SERVICE_UUID]; NobleDevice.Util.inherits(Lumen, NobleDevice); NobleDevice.Util.mixin(Lumen, NobleDevice.BatteryService); NobleDevice.Util.mixin(Lumen, NobleDevice.DeviceInformationService); Lumen.prototype._onDisconnect = function() { if (this._keepAliveTimer) { clearTimeout(this._keepAliveTimer); } }; Lumen.prototype.toString = function() { return JSON.stringify({ uuid: this.uuid, id: this.id, address: this.address });
var MOTION_RAW_CHARACTERISTIC_UUID = '1e374a21851e11e3b9e70002a5d5c51b'; var MOTION_POINTS_CHARACTERISTIC_UUID = '1e374a22851e11e3b9e70002a5d5c51b'; var RING_SERVICE_UUID = '1e374a30851e11e3b9e70002a5d5c51b'; var RING_EVENT_CHARACTERISTIC_UUID = '1e374a31851e11e3b9e70002a5d5c51b'; var RING_MODE_CHARACTERISTIC_UUID = '1e374a32851e11e3b9e70002a5d5c51b'; var RING_FEEDBACK_CHARACTERISTIC_UUID = '1e374a33851e11e3b9e70002a5d5c51b'; var Ring = function(peripheral) { NobleDevice.call(this, peripheral); EventEmitter.call(this); }; Ring.SCAN_UUIDS = [RING_SERVICE_UUID]; util.inherits(Ring, EventEmitter); NobleDevice.Util.inherits(Ring, NobleDevice); Ring.prototype.notifyEvent = function(done) { this.notifyCharacteristic(RING_SERVICE_UUID, RING_EVENT_CHARACTERISTIC_UUID, true, this._onReadEvent.bind(this), done); } Ring.prototype.unnotifyEvent = function(done) { this.notifyCharacteristic(RING_SERVICE_UUID, RING_EVENT_CHARACTERISTIC_UUID, false, this._onReadEvent.bind(this), done); }; Ring.prototype._onReadEvent = function(data) { if(data && data instanceof Buffer && data.length>0) { switch (data.readUInt8(0)) {
/*jslint node: true */ "use strict"; var NobleDevice = require('noble-device'); var Bean = require('./lib/Bean'); var ScratchOne = require('./lib/ScratchOne'); var ScratchTwo = require('./lib/ScratchTwo'); var ScratchThree = require('./lib/ScratchThree'); var ScratchFour = require('./lib/ScratchFour'); var ScratchFive = require('./lib/ScratchFive'); NobleDevice.Util.mixin(Bean, NobleDevice.BatteryService); NobleDevice.Util.mixin(Bean, NobleDevice.DeviceInformationService); NobleDevice.Util.mixin(Bean, ScratchOne); NobleDevice.Util.mixin(Bean, ScratchTwo); NobleDevice.Util.mixin(Bean, ScratchThree); NobleDevice.Util.mixin(Bean, ScratchFour); NobleDevice.Util.mixin(Bean, ScratchFive); module.exports = Bean;
'use strict'; var producer = require('godot-producer'); var SensorTag = require('sensortag').CC2540; var NobleDevice = require('noble-device'); NobleDevice.Util.mixin(SensorTag, NobleDevice.BatteryService); var debug = require('debug')('swg:device:sensortag'); SensorTag.SCAN_DUPLICATES = true; var series = require('run-series'); require('./discover')(SensorTag); var Producer = producer(function ctor (options) { var uuid = this.uuid = options.uuid; debug('initialized sensortag with %s', this.uuid || '<empty uuid>'); this.filter = function (device) { if (!uuid) { debug('filtering %s, but no filter', device.uuid); this.onDiscover(device); return; } debug('filtering device: "%s" <=> "%s"', device.uuid, uuid); if (device.uuid === uuid) { this.onDiscover(device); } }.bind(this); this.on('error', console.error.bind(console)); }, function produce () { debug('producing, stopping and restarting discovery'); SensorTag.stopDiscoverThis(this.filter); if (this.device) { this.device.disconnect();
/*jslint node: true */ "use strict"; var NobleDevice = require('noble-device'); var RingZero = require('./lib/ring'); NobleDevice.Util.mixin(RingZero, NobleDevice.DeviceInformationService); module.exports = RingZero;
var CURRENT_TEMPERATURE_CHARACTERISTIC_UUID = 'e0035609ec484ed09f3b5419c00a94fd'; var CURRENT_LIGHT_CHARACTERISTIC_UUID = 'e003560fec484ed09f3b5419c00a94fd'; var CURRENT_HUMIDITY_CHARACTERISTIC_UUID = 'e0035615ec484ed09f3b5419c00a94fd'; var WimotoClimate = function(peripheral) { NobleDevice.call(this, peripheral); this._onCurrentTemperatureChangeBinded = this._onCurrentTemperatureChange.bind(this); this._onCurrentLightChangeBinded = this._onCurrentLightChange.bind(this); this._onCurrentHumidityChangeBinded = this._onCurrentHumidityChange.bind(this); }; WimotoClimate.SCAN_UUIDS = ['5608', '5614', '560e']; NobleDevice.Util.inherits(WimotoClimate, NobleDevice); NobleDevice.Util.mixin(WimotoClimate, NobleDevice.DeviceInformationService, [ 'readManufacturerName', 'readModelNumber', 'readSystemId' ]); NobleDevice.Util.mixin(WimotoClimate, NobleDevice.BatteryService); WimotoClimate.prototype.readCurrentTemperature = function(callback) { this.readUInt16LECharacteristic(TEMPERATURE_SERVICE_UUID, CURRENT_TEMPERATURE_CHARACTERISTIC_UUID, function(error, value) { if (error) { return callback(error); }