-
Notifications
You must be signed in to change notification settings - Fork 0
/
pseudoNetcore.js
72 lines (49 loc) · 1.17 KB
/
pseudoNetcore.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
var zb = require('zigbee');
var fbbs = require('freebird-base.js'),
Netcore = fbbs.Netcore;
var nc = new Netcore('zigbee', {
PHY: 'ieee802.15.4',
DLL: 'ieee802.15.4',
NWK: 'zigbee2007',
// TL: null,
// SL: null,
// PL: null,
APL: 'zcl'
}, zb);
// overrides
nc.cookDevice = function (raw, dev, callback) {
// fill up some fields
dev.role = raw.devType;
// dev.parent =
if (raw.devType === 'router' || raw.devType === 'coord')
dev.maySleep = false;
dev.address.permanent = raw.ieeeAddr;
dev.address.dynamic = raw.nwkAddr;
dev.extra = raw.info;
dev.attrs.manufacturer = raw.info.manufacturerId;
// dev.attrs.model = ;
callback(dev);
};
nc.cookGadget = function (dev, gad, callback) {
// fill up some fields
// classify this gadget
callback(gad);
};
nc.drivers.net = {
};
nc.drivers.dev = {
};
nc.drivers.gad = {
};
// (1) nc.devIncomingHandler()
// (2) nc.devLeavingHandler()
// (3) nc.attrReportHandler()
zb.on('evt1', function (x) {
// xxxx
nc.registerDevice(dev); // if fb there
});
zb.on('evt2', function (x) {
// xxxx
});
// ...
module.exports = nc;