-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathindex.js
75 lines (63 loc) · 1.53 KB
/
index.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// TODO: we should use https://github.com/TooTallNate/node-bindings for this
// see https://github.com/arunoda/node-usage as an example
var _rf24 = require("./build/Release/rf24");
exports.radio = function (dev, speed, ce) {
dev = "/dev/spidev0.0";
speed = 8000000;
ce = 25;
// TODO: improve argument handling
var xcvr = new _rf24.Wrapper(dev,speed,ce),
radio = {};
radio.begin = function (cb) {
cb || (cb = function () {});
xcvr.begin(cb);
};
radio.listen = function (listen, cb) {
if (typeof listen === 'function') {
cb = listen;
listen = true;
}
cb || (cb = function () {});
xcvr.listen(listen, cb);
};
radio.write = function (data, cb) {
if (typeof data === 'string') {
data = new Buffer(data);
}
cb || (cb = function () {});
xcvr.write(data, cb);
};
radio.available = xcvr.available;
radio.read = xcvr.read;
return radio;
}
/*
ctor(s)
begin
reset
startListening
stopListening
[start]write
available[pipe]
read
openWritingPipe
openReadingPipe
writeAckPayload
isAckPayloadAvailable
setRetries
setChannel
get|setPayloadSize
getDynamicPayloadSize
enableAckPayload
enableDynamicPayloads
isPVariant
setAutoAck/per-pipe
get|setPALevel
get|setDataRate
get|setCRCLength
disableCRC
printDetails
powerDown|Up
whatHappened
testCarrier/testRPD
*/