forked from sandeepmistry/node-sensortag
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-cc2650-io.js
59 lines (53 loc) · 1.48 KB
/
test-cc2650-io.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
51
52
53
54
55
56
57
58
59
var util = require('util');
var async = require('async');
var CC2650SensorTag = require('./index').CC2650;
var USE_READ = true;
CC2650SensorTag.discover(function(sensorTag) {
console.log('discovered: ' + sensorTag);
sensorTag.on('disconnect', function() {
console.log('disconnected!');
process.exit(0);
});
async.series([
function(callback) {
console.log('connectAndSetUp');
sensorTag.connectAndSetUp(callback);
},
// http://processors.wiki.ti.com/index.php/CC2650_SensorTag_User's_Guide#IO_Service
function(callback) {
console.log('IO off');
sensorTag.writeIoData(0, callback);
},
function(callback) {
console.log('writeIoConfig');
sensorTag.writeIoConfig(1, callback);
},
function(callback) {
console.log('LED red');
sensorTag.writeIoData(1, function() {
setTimeout(callback, 1000);
});
},
function(callback) {
console.log('LED green');
sensorTag.writeIoData(2, function() {
setTimeout(callback, 1000);
});
},
function(callback) {
console.log('buzzer');
sensorTag.writeIoData(4, function() {
setTimeout(callback, 1000);
});
},
function(callback) {
console.log('IO off');
sensorTag.writeIoData(0, callback);
},
function(callback) {
console.log('disconnect');
sensorTag.disconnect(callback);
}
]
);
});