Overview
Extending the ZigBee Abstract driver to add support for new types of ZigBee coordinators is possible following the steps provided below.
Implementing the CoordinatorConnectionFactory Interface
Implement the CoordinatorConnectionFactory interface to provide means for creating new CoordinatorConnection instances which are used by the CoordinatorConenctionManager.
Example of implementing CoordinatorConnectionFactory.createCoordinatorConnection method.
public void setManager(CoordinatorConnectionManager ccMan) {
this.ccMan = ccMan;
}
public CoordinatorConnectionAccess createCoordinatorConnection(Dictionary properties) throws ZigBeeException {
return new FreescaleCoordinatorConnection(properties, bc, log, sTracker, ccMan, driverEventsDispatcher, "ZigBee Freescale");
}
Defining Factory Configuration
Define factory configuration to configure needed PAN/communication settings of a physical ZigBee coordinator device.
Communicating with the Physical ZigBee Coordinator Device
Add a class that extends Communicator class to handle communication with the physical ZigBee coordinator device. In order to do so follow the steps:
If the coordinator uses serial communication then CommCommunicator can be used instead of Communicator. In this case the above methods are implemented using the gnu.io bundle.
Transmitting ZigBee Messages and Configurations
Analyse the communication interface of the coordinator device and decide which commands shall be used to implement transmission of ZigBee messages and configurations:
You can extend MessageHendler in order to implement PacketListener.
Managing Coordinator Connections
Add a class that extends the CoordinatorConnectionAccess class to manage the coordinator connections and handle connection properties:
If the coordinator uses serial communication then the CommCoordinatorConnection can be used instead of the CoordinatorConnectionAccess. In this case the two methods are implemented by the gnu.io bundle.
Example
See the example of the FreescaleCoordinatorConnection constructor (FreescaleCoordinatorConnection extends CommCoordinatorConnection) provided below.
public FreescaleCoordinatorConnection(Dictionary props, BundleContext bc, Log log, BasicTracker tracker, CoordinatorConnectionManager ccManager,
ZigBeeEventsDispatcher zigbeeEventsDispatcher, String name) throws ZigBeeException {
this.properties = props;
this.log = log;
this.zigbeeEventsDispatcher = zigbeeEventsDispatcher;
this.communicator = new FreescaleCommunicator( this, ccManager, tracker, zigbeeEventsDispatcher, bc, log, name);
this.nodeDiscoveryService = new NodeDiscoveryServiceAccess( this, tracker, zigbeeEventsDispatcher, Activator.backup, bc, log);
this.transmitService = new TransmitServiceAccess( this, tracker, zigbeeEventsDispatcher, log, bc, true,
Constants.TRANSMISSION_MODE_BROADCAST | Constants.TRANSMISSION_MODE_MULTICAST | Constants.TRANSMISSION_MODE_UNICAST);
this.utilFrameHandler = new UtilMessageHandler(communicator, tracker, log); //
UtilMessageHandler extends MessageHendler this.apsdeDataFrameHandler = new APSDEMessageHandler(transmitService, communicator, tracker, log); // APSDEMessageHandler extends
TransmitServiceHelper this.zdoStateManager = new ZDOStateManager(log);
this.zdpFrameHandler = new ZDPMessageHandler(transmitService, communicator, tracker, zdoStateManager, log); // ZDPMessageHandler extends
TransmitServiceHelper this.coordinatorInterface = new FreescaleCoordinatorInterface( this, ccManager, tracker, log); //
FreescaleCoordinatorInterface extend AbstractCoordinatorInterface
communicator.addPacketListener(utilFrameHandler); //add
PackerListener communicator.addPacketListener(zdpFrameHandler); //add PackerListener
communicator.addPacketListener(apsdeDataFrameHandler); //add PackerListener
transmitService.addTransmitServiceHelper(zdpFrameHandler); //add TransmitServiceHelper
transmitService.addTransmitServiceHelper(apsdeDataFrameHandler); //add TransmitServiceHelper }
Implementing the startup
Add the bundle activator and implement the startup:
Example
An example of Activator.start method follows:
public void start(BundleContext bc) throws Exception {
this.bc = bc;
log = new Log(bc);
logConfiguration = new ZigBeeLogConfiguration(bc, log, LOG_CONFIGURATION_PID);
boolean starting = bc.getBundle().getState() == Bundle.STARTING;
if (starting) {
backup = new ZigBeeBackupProvider(bc, log, this, "mbs.zb.freescale");
backupReg = bc.registerService(BackupProvider.class.getName(), backup, null);
backup.init();
}
driverEventsDispatcher = new ZigBeeEventsDispatcher(bc, log);
driverEventsDispatcher.open();
sTracker = new BasicTracker(bc);
ccFactory = new FreescaleCoordinatorConnectionFactory(bc, log, driverEventsDispatcher, sTracker);
ccManager = new CoordinatorConnectionManager(CONFIGURATION_COMM_FPID, CONFIGURATION_PAN_FPID,
"ZigBee FreeScale Coordinator Connection Factory", ccFactory, driverEventsDispatcher, sTracker, backup, bc, log);
ccFactory.setManager(ccManager);
sTracker.setManager(ccManager);
sTracker.open();
}