Previous Topic

Next Topic

Book Contents

Book Index

Adding Support for Custom Coordinators

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.

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();
}