zigbee-bridge

How to use zigbee-bridge

1. Create a folder /zbserver and a server.js in it

$ mkdir zbserver && cd zbserver
/zbserver$ touch server.js

2. Install the zigbee-bridge module in /zbserver folder

/zbserver$ npm install zigbee-bridge

3. Edit server.js, Start ZigBee Server

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);
  }
});
$ npm install -g serialport
$ serialport-list
/dev/ttyACM0    usb-Texas_Instruments_TI_CC2531_USB_CDC___0X00124B000106B6C5-if00   Texas_Instruments
/dev/ttyS0
/dev/ttyS1
...

4. Test the Server

/zbserver$ node server.js

5. Permit ZigBee devices join the network

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