Backup and restore network
This adds a more complete backup and restore implementation. Previously managing the node XML files was problematic since the library manages these files, meaning the user application couldn’t easily modify or replace them while the network was running. Conversely, replacing them with the network offline was problematic since the user much call ZigBeeNetworkManager.startup(true) to initialise the network, and this will remove all nodes and their XML files.
With this PR, the backup information is now serialised as a single entity through the ZigBeeDataStore. New methods to backup and restore have been added to the ZigBeeNetworkManager that manage the removal of nodes, and initialisation of the system in the correct order.
Summary of Changes at user level
ZigBeeNetworkDataStore has the following new methods -:
-
boolean writeBackup(ZigBeeNetworkBackupDao backup)- the user MUST implement this method to store a backup. -
ZigBeeNetworkBackupDao readBackup(UUID uuid)- the user MUST implement this method to read a backup from the store. -
Set<ZigBeeNetworkBackupDao> listBackups()- the user MAY implement this method to read all the current backups. This is currently only used in the console so users implementing their own system may not require this.
ZigBeeNetworkManager has the following new methods -:
-
UUID createBackup()- creates a backup of the current network. This will store all data, including the network configuration (eg keys, channel, PANID etc) and the devices attached to the network, and returns aUUIDidentifying the backup. Serialisation of the data is through theZigBeeNetworkDataStore.writeBackupmethod. -
ZigBeeStatus restoreBackup(UUID uuid)- restores a backup given theUUID. This will read data from the data store using theZigBeeNetworkDataStore.readBackupmethod, and will restore all nodes, and reconfigure the coordinator. This has been tested when running with an existing network - calling at other times may require further updates.
Dongle changes
The following changes are made that do not directly impact users, but are added to lower level interfaces toward the coordinator -:
ZigBeeTransportTransmit
-
ZigBeeStatus setNetworkState(ZigBeeNetworkState networkState)- this method allows theZigBeeNetworkManagerto take the coordinator offline during the restoration of a backup. -
boolean setIeeeAddress(IeeeAddress ieeeAddress)- this method allows theZigBeeNetworkManagerto set theIeeeAddressof the coordinator. -
boolean setNwkAddress(int networkAddress)- this method allows theZigBeeNetworkManagerto set the network Address of the coordinator. Note that this is not used at this time, but was added to the interface for completeness.
Note that this PR only adds this support to the ZigBeeDongleEzsp implementation (ie Silabs Ember / Gecko chipset).
There is a limitation that the IEEE address can only be written to NVRAM once after which the token area needs erasing. Silabs introduced a function to do this in or around version 7.3 or 7.4. This is function ID 0x77, but in earlier versions of EZSP (prior to 7 I think) this ID was allocated to becomeTrustCenter. This PR removes the becomeTrustCenter function (it was not used in the library) and adds the tokenFactoryReset function as 0x77. Further work may be need for this to work on older firmware (if it’s even possible).
If the IEEE address doesn’t change (which should be the case if the network is backed up / restored using the same physical coordinator) then this will still work fine.
Console Application
The netback console command now has backup, restore UUID and list subcommands to manage backups. These are reasonably self explanatory and simply call the above methods in the ZigBeeNetworkManager.