-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLocationLatitudeCharacteristic.js
More file actions
34 lines (29 loc) · 978 Bytes
/
Copy pathLocationLatitudeCharacteristic.js
File metadata and controls
34 lines (29 loc) · 978 Bytes
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
var util = require('util');
var bleno = require('bleno');
var locationStation = require('./LocationStation');
function LocationLatitudeCharacteristic(locationStation) {
bleno.Characteristic.call(this, {
uuid: '13333333333333333333333333330001',
properties: ['read'],
descriptors: [
new bleno.Descriptor({
uuid: '2901',
value: 'Get the current latitude of the device.'
})
]
});
this.locationStation = locationStation
}
util.inherits(LocationLatitudeCharacteristic, bleno.Characteristic);
LocationLatitudeCharacteristic.prototype.onReadRequest = function(offset, callback) {
if (offset) {
callback(this.RESULT_ATTR_NOT_LONG, null);
}
else {
console.log("Sending latitude - " + JSON.stringify(this.locationStation.latitude));
var data = new Buffer(8);
data.writeDoubleBE(this.locationStation.latitude, 0);
callback(this.RESULT_SUCCESS, data);
}
};
module.exports = LocationLatitudeCharacteristic;