Node.js lib for the TI SensorTag and TI CC2650 SensorTag
npm install sensortag
See test.js or sensorTag folder in Tom Igoe's BluetoothLE-Examples repo
var SensorTag = require('sensortag');
SensorTag.discover(callback(sensorTag));
function onDiscover(sensorTag) {
// ...
}
SensorTag.discoverAll(onDiscover);
SensorTag.stopDiscoverAll(onDiscover);
SensorTag.discoverById(id, callback(sensorTag));
SensorTag.discoverByAddress(address, callback(sensorTag));
sensorTag = {
id: "<peripheral id>",
type: "cc2540" | "cc2650"
}
sensorTag.connectAndSetUp(callback(error));
sensorTag.disconnect(callback);
sensorTag.readDeviceName(callback(error, deviceName));
sensorTag.readSystemId(callback(error, systemId));
sensorTag.readSerialNumber(callback(error, serialNumber));
sensorTag.readFirmwareRevision(callback(error, firmwareRevision));
sensorTag.readHardwareRevision(callback(error, hardwareRevision));
sensorTag.readSoftwareRevision(callback(error, softwareRevision));
sensorTag.readManufacturerName(callback(error, manufacturerName));
sensorTag.enableIrTemperature(callback(error));
sensorTag.disableIrTemperature(callback(error));
sensorTag.setIrTemperaturePeriod(period, callback(error)); // period min 300ms, default period is 1000 ms
sensorTag.readIrTemperature(callback(error, objectTemperature, ambientTemperature));
sensorTag.notifyIrTemperature(callback(error));
sensorTag.unnotifyIrTemperature(callback(error));
sensorTag.on('irTemperatureChange', callback(objectTemperature, ambientTemperature));
sensorTag.enableAccelerometer(callback(error));
sensorTag.disableAccelerometer(callback(error));
// CC2540: period 1 - 2550 ms, default period is 2000 ms
// CC2650: period 100 - 2550 ms, default period is 1000 ms
sensorTag.setAccelerometerPeriod(period, callback(error));
sensorTag.readAccelerometer(callback(error, x, y, z));
sensorTag.notifyAccelerometer(callback(error));
sensorTag.unnotifyAccelerometer(callback(error));
sensorTag.on('accelerometerChange', callback(x, y, z));
sensorTag.enableHumidity(callback(error));
sensorTag.disableHumidity(callback(error));
sensorTag.setHumidityPeriod(period, callback(error));
sensorTag.readHumidity(callback(error, temperature, humidity));
sensorTag.notifyHumidity(callback(error));
sensorTag.unnotifyHumidity(callback(error));
sensorTag.on('humidityChange', callback(temperature, humidity));
sensorTag.enableMagnetometer(callback(error));
sensorTag.disableMagnetometer(callback(error));
// CC2540: period 1 - 2550 ms, default period is 2000 ms
// CC2650: period 100 - 2550 ms, default period is 1000 ms
sensorTag.setMagnetometerPeriod(period, callback(error));
sensorTag.readMagnetometer(callback(error, x, y, z));
sensorTag.notifyMagnetometer(callback(error));
sensorTag.unnotifyMagnetometer(callback(error));
sensorTag.on('magnetometerChange', callback(x, y, z));
sensorTag.enableBarometricPressure(callback(error));
sensorTag.disableBarometricPressure(callback(error));
sensorTag.setBarometricPressurePeriod(period, callback(error)); // period 100 - 2550 ms
sensorTag.readBarometricPressure(callback(error, pressure));
sensorTag.notifyBarometricPressure(callback(error));
sensorTag.unnotifyBarometricPressure(callback(error));
sensorTag.on('barometricPressureChange', callback(pressure));
sensorTag.enableGyroscope(callback(error));
sensorTag.disableGyroscope(callback(error));
// period 100 - 2550 ms, default period is 1000 ms
sensorTag.setGyroscopePeriod(period, callback(error));
sensorTag.readGyroscope(callback(error, x, y, z));
sensorTag.notifyGyroscope(callback(error));
sensorTag.unnotifyGyroscope(callback(error));
sensorTag.on('gyroscopeChange', callback(x, y, z));
sensorTag.readIoData(callback(error, value));
sensorTag.writeIoData(value, callback(error));
sensorTag.readIoConfig(callback(error, value));
sensorTag.writeIoConfig(value, callback(error));
sensorTag.enableLuxometer(callback(error));
sensorTag.disableLuxometer(callback(error));
sensorTag.setLuxometerPeriod(period, callback(error));
sensorTag.readLuxometer(callback(error, lux));
sensorTag.notifyLuxometer(callback(error));
sensorTag.unnotifyLuxometer(callback(error));
sensorTag.on('luxometerChange', callback(lux));
sensorTag.notifySimpleKey(callback(error));
sensorTag.unnotifySimpleKey(callback(error));
CC2540:
sensorTag.on('simpleKeyChange', callback(left, right));
CC2650:
sensorTag.on('simpleKeyChange', callback(left, right, reedRelay));