zigbeer / zigbee-shepherd

An open source ZigBee gateway solution with node.js.
MIT License
250 stars 89 forks source link

don't trigger 'ind' event #9

Closed amigomcu closed 7 years ago

amigomcu commented 7 years ago

hi all, when i start permitJoin device, i can see my device have been add PAN network. but it don't trigger 'ind' event and shepherd.list() return only Coordinator. could you give me some suggestion with this?

I'm a beginner at full-stack iot development. how to use the utilizes debug module on windows(win 7 64bit)

hw. cc2531 usb dongle. fw. cc-znp

splitice commented 7 years ago

We have seen similar issues, usually restarting the software, reseting the device or ZNP dongle does the job.

Often this happens when the software is restarted. Our current operating theory is that the ZNP dongle thinks the device is joined in the firmware. I have not been able to find a place where Zigbee Shepherd asks for a list of joined devices.

Perhaps executing a ZNP reset before start / init would solve the problem?

splitice commented 7 years ago

Internal discussion reveals:

Our proposed solution we are toying with at the moment is on-init to use assocFindDevice and assocCount to iterate the ZNP's status and mark devices as online/offline in devbox (the db).

Would love some feedback from the Zigbee Shepherd guys.

splitice commented 7 years ago

That would be limited to associations on the coordinator, it wouldn't pick up on associations on routers in the network.

Perhaps the approach described here: http://electronics.stackexchange.com/questions/199078/how-do-i-maintain-an-active-list-of-zigbee-devices-in-a-han

splitice commented 7 years ago

Initial implementation in our fork, cursory evaluation in our lab looks positive.

Still todo: creation of devices if database doesnt have them (query for simple desc etc to get eps etc)

splitice commented 7 years ago

Edit: False alarm, device was joining another network.

simenkid commented 7 years ago

Hi @amigomcu. you can try the node-env out to have the environment variable been set correctly in windows.

  1. Under your project folder, npm install cross-env --save-dev
  2. Run the server with cross-env: cross-env DEBUG=zigbee-shepherd* node server.js

Could you paste your code to us? Let's see if anything went wrong with the 'ind' issue. Thanks!

simenkid commented 7 years ago

Hi @splitice, I think your speculation on these two points is making sense:

My proposal is to have a handler to always disallow device joining when the server shutting down:

process.on('exit', function () {
     shepherd.permitJoin(0);
})`

But I wonder that this would not fully solve the problem, there is still a very little chance that a device comes into the network when ZS is not in the ready state and the ZNP dongle still opens for joining.

splitice commented 7 years ago

That still doesnt help as existing devices will stay joined during reboot, they will never re-join as they are in fact still joined. You could do a hardware reset instead. Still, it's not all that reliable and for some devices rejoining takes hours.

Our current method of doing an network scan is holding up reasonably well. Still a few kinks to be found though.

Further work is required as per the TODO though in case we loose the database, or a new device joins while the software isnt running.