$ mkdir zbserver && cd zbserver
/zbserver$ touch server.js
zigbee-bridge
module in /zbserver folder/zbserver$ npm install zigbee-bridge
const Bridge = require('zigbee-bridge');
const zserver = new Bridge('/dev/ttyACM0');
// see [1]
zserver.on('ready', () => {
console.log('Server is ready.');
});
zserver.start(function (err) {
if (err) {
console.log(err);
}
});
serialport-list
to list all available serial ports.$ npm install -g serialport
$ serialport-list
/dev/ttyACM0 usb-Texas_Instruments_TI_CC2531_USB_CDC___0X00124B000106B6C5-if00 Texas_Instruments
/dev/ttyS0
/dev/ttyS1
...
/zbserver$ node server.js
var Bridge = require('zigbee-bridge');
var zserver = new Bridge('/dev/ttyACM0');
// see [1]
zserver.on('ready', () => {
console.log('Server is ready. Allow devices to join the network within 180 secs.');
console.log('Waiting for incoming clients or messages...');
zserver.permitJoin(180);
});
zserver.on('permitJoining', (joinTimeLeft) => {
console.log(joinTimeLeft);
});
// see [2]
zserver.on('ind', (msg) => {
switch (msg.type) {
case 'devIncoming':
console.log(`Device: ${msg.data} joining the network!`);
msg.endpoints.forEach((ep) => {
console.log(ep.dump()); // endpoint information
});
break;
default:
// Not deal with other msg.type in this example
break;
}
});
zserver.start((err) => {
if (err) {
console.log(err);
}
});
Run server.js and Let your ZigBee device join the network.
/zbserver$ node server.js