Mr-Markus / ZigbeeNet

A .NET Standard library for working with ZigBee
Eclipse Public License 1.0
131 stars 47 forks source link

Add new Data Store serialisation concept #88

Closed spudwebb closed 4 years ago

spudwebb commented 4 years ago

This refactors the serialisation interface. It adds a new IZigBeeNetworkDataStore interface that is used to read/write/remove nodes. Users should implement this interface as they see appropriate for their system (eg SQL database, XML files, Json...).

This is different to the current serialisation interface which acts on the whole network. This causes problems with slower computers (eg RPi class) and larger networks where this can take in the order or 1 to 3 seconds to serialise. Additionally, multiple serialisations may occur at once (or close together) and this can cause blocking of the system for significant periods of time.

This implementation includes a ZigBeeDatabaseManager that manages the data store. It listens to the node update notifications, and will update the data store. The manager will defer writes for a short time to avoid multiple updates. This time is set to 250ms by default. If updates continue to be received for a device, then the manager will still store periodically (ie the hold-off will not act indefinitely in the case where many updates are received). This maximum period is set to 1 second by default.

Mr-Markus commented 4 years ago

Well done. Thanks 👍