-
Notifications
You must be signed in to change notification settings - Fork 47
Getting started
At first you have to reference the ZigBeeNet library. This is the core of the framework. You can do this by cloning this repository and build it by your own, or more easy use NuGet.org.
Core library NuGet link here: https://www.nuget.org/packages/ZigBeeNet/
Next step will be to reference the library for your hardware dongle. You can do this the same way as the core library. Then you need to create an IZigBeePort object.
We have already one for SerialPort here: https://www.nuget.org/packages/ZigBeeNet.Transport.SerialPort/
If all previous steps ar done you will start with the ZigBeeNetworkManager
class from the ZigBeeNet core library.
It is the main entrance point in every application which is working with ZigBeeNet.
ZigBeeNetworkManager implements functions for managing the ZigBee interfaces. The network manager is the central class of the framework. It provides the interface with the dongles to send and receive data, and application interfaces to provide listeners for system events (e.g. network status with the IZigBeeNetworkStateListener or changes to nodes with the IZigBeeNetworkNodeListener or to receive incoming commands with the IZigBeeCommandListener).
The ZigBeeNetworkManager maintains a list of all ZigBeeNodes that are known on the network. Depending on the system configuration, different discovery methods may be utilised to maintain this list. A Coordinator may actively look for all nodes on the network while a Router implementation may only need to know about specific nodes that it is communicating with.
The ZigBeeNetworkManager also maintains a list of ZigBeeNetworkExtensions which allow the functionality of the network to be extended. Extensions may provide different levels of functionality - an extension may be as simple as configuring the framework to work with a specific feature, or could provide a detailed application.
As constructor parameter it receives a dongle object, which is of type IZigBeeTransportTransmit
, that implements the hardware specific functionality.
Here an example with the Texas Instruments CC2531 dongle implementation:
ZigBeeSerialPort zigbeePort = new ZigBeeSerialPort("COM4");
IZigBeeTransportTransmit dongle = new ZigBeeDongleTiCc2531(zigbeePort);
ZigBeeNetworkManager networkManager = new ZigBeeNetworkManager(dongle);
// Initialise the network
networkManager.Initialize();
ZigBeeStatus startupSucceded = networkManager.Startup(false);
if (startupSucceded == ZigBeeStatus.SUCCESS)
{
Log.Logger.Information("ZigBee console starting up ... [OK]");
}
else
{
Log.Logger.Information("ZigBee console starting up ... [FAIL]");
return;
}
You also can take a look here for an example how to use the OnOffCluster to turn a light on or off https://github.com/zigbeenet/ZigbeeNet/wiki/Turn-light-on-off