tlaukkan / zigbee4java

Zigbee API for Java provides simple Java interface to ZigBee network.
Apache License 2.0
144 stars 68 forks source link

Startup refactor #39

Closed cdjackson closed 9 years ago

cdjackson commented 9 years ago

This changes the startup methods to allow for the system to read the dongle configuration before the network starts. This allows the system to detect if the dongle configuration is different to that asked for, and then do a reset of the dongle - this is not possible in the current methods as the reset flag is included in the constructor...

You can still use the current startup method which works the same as normal. However, it also adds initializeHardware and initializeNetwork methods which effectively splits startup method in two.

After calling initializeHardware you can then call the getCurrentChannel and getCurrentPanId methods, and then the initializeNetwork method. The initializeHardware method takes parameter to specify if the network should be reset or not.

This also fixes a bug during the startup. If the startup sequence fails in the .open() method due to the reset timing out, then .close() doesn't get called.

I might merge my other dongle reset PR into this but it would be good if @tlaukkan and @chris-hatton can comment on this before it's merged. It shouldn't break anything as the existing methods are retained, but is a bit of a change all the same.

cdjackson commented 9 years ago

Merged the startup timer changes into this branch...

tlaukkan commented 9 years ago

Feel free to merge this yourself. Please ensure that the end result is in working order. I am fully tied with my day job so even I would like to review and test this I am not able to currently. :+1:

cdjackson commented 9 years ago

No probs - thanks Tommi. I’m using this daily, and so are a few others so I think it’s good :)