-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcharacteristic_aroma.js
50 lines (44 loc) · 1.24 KB
/
characteristic_aroma.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/**
* Dependencies
**/
var bleno = require('/usr/local/lib/node_modules/bleno');
var util = require('util');
/**
* Types
**/
var Characteristic = bleno.Characteristic;
var Descriptor = bleno.Descriptor;
/**
* Constructor
**/
var Characteristic_Aroma = function(toilet)
{
Characteristic_Aroma.super_.call(this, {
uuid : '0000000000000000000000000000fff2',
properties: [ 'write' ],
value: null,
descriptors: [
new Descriptor({
uuid: '2901',
value: 'Set aroma: 0,1'
})
]
});
this.toilet = toilet;
}
util.inherits(Characteristic_Aroma, Characteristic);
Characteristic_Aroma.prototype.onWriteRequest = function(data, offset, withoutResponse, callback)
{
if (offset) {
console.log('Received WRITE for \'ATTR_LONG\', offset:' + offset);
callback(this.RESULT_ATTR_NOT_LONG);
} else if (data.length !== 1) {
console.log('Received WRITE with \'INVALID_ATTRIBUTE_LENGTH\', length:' + data.length);
callback(this.RESULT_INVALID_ATTRIBUTE_LENGTH);
} else {
var value = data.readUInt8(0);
this.toilet.setAroma(value);
callback(this.RESULT_SUCCESS);
}
}
module.exports = Characteristic_Aroma;