-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathapp.js
More file actions
37 lines (30 loc) · 849 Bytes
/
app.js
File metadata and controls
37 lines (30 loc) · 849 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
35
36
37
var bleno = require('bleno');
var BlenoPrimaryService = bleno.PrimaryService;
var IpCharacteristic = require('./ip_characteristic');
bleno.on('servicesSet', function() {
console.log('on -> servicesSet');
});
bleno.on('accept', function() {
console.log('on -> accept');
});
bleno.on('stateChange', function(state) {
console.log('on -> stateChange: ' + state);
if (state === 'poweredOn') {
bleno.startAdvertising('ardrobot', ['ec00']);
} else {
bleno.stopAdvertising();
}
});
bleno.on('advertisingStart', function(error) {
console.log('on -> advertisingStart: ' + (error ? 'error ' + error : 'success'));
if (!error) {
bleno.setServices([
new BlenoPrimaryService({
uuid: '01010101010101010101010101010101',
characteristics: [
new IpCharacteristic()
]
})
]);
}
});