forked from hcrohland/ble-cycling-power
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRSC-feature-characteristic.js
executable file
·35 lines (27 loc) · 1.08 KB
/
RSC-feature-characteristic.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
var util = require('util');
var os = require('os');
var exec = require('child_process').exec;
var bleno = require('bleno');
var Descriptor = bleno.Descriptor;
var Characteristic = bleno.Characteristic;
// Profile:
// https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.rsc_feature.xml
var FeatureCharacteristic = function() {
FeatureCharacteristic.super_.call(this, {
uuid: '2A54',
properties: ['read']
});
};
util.inherits(FeatureCharacteristic, Characteristic);
FeatureCharacteristic.prototype.onReadRequest = function(offset, callback) {
// return hardcoded value
// 000001 - 0x01 - Instantaneous Stride Length Measurement Supported
// 000010 - 0x02 - Total Distance Measurement Supported
// 000100 - 0x04 - Walking or Running Status Supported
// 001000 - 0x08 - Calibration Procedure Supported
// 010000 - 0x10 - Multiple Sensor Locations Supported
var value = new Buffer(4);
value.writeUInt32LE(0x02);
callback(this.RESULT_SUCCESS, value);
};
module.exports = FeatureCharacteristic;