ZigBee 3.0 Adding cluster on KW41Z

Document created by Shweta Chauhan Employee on Apr 18, 2018Last modified by Shweta Chauhan Employee on Apr 18, 2018
Version 7Show Document
  • View in full screen mode

This document describes how to add additional cluster to the router application in the AN12061-MKW41Z-AN-Zigbee-3-0-Base-Device Application Note.


The Router application's main endpoint contains Basic, Groups, Identify and OnOff server. The steps below describe how to add two clusters to Router: Temperature Measurement server and OnOff client.

Note that these changes only go as far as making the new clusters added and discoverable, no functionality has been added to these clusters.


The first step is to update the application ZCL Configuration file to add the new clusters (OnOff Client, Temperature Measurement Server) to the Router application endpoint.

The HA profile already contains few clusters but Temperature Measurement cluster was added:


/* Profile 'HA' */
#define HA_DEFAULT_CLUSTER_ID                (0xffff)
#define HA_OTA_CLUSTER_ID                    (0x0019)
#define HA_TEMPMEASUREMENT_CLUSTER_ID        (0x0402)


The OnOff client was already present in Router endpoint but made discoverable and the Temperature Measurement cluster was added and made discoverable into Router application endpoint.The clusters are added to the Input cluster list (Server side) and output cluster list (Client side) and made discoverable using DiscFlag only for the cluster list for which it is enabled. So, assuming you need to add OnOff cluster client, you would need to use add the cluster id (0x0006 for OnOff) into input cluster list (Server side of cluster) and output cluster list (Client side of the cluster) and make it discoverable for output cluster list as it is a client cluster. For temperature measurement, you need to make it discoverable for input Cluster list as below:

PRIVATE const uint16 s_au16Endpoint1InputClusterList[6] = { 0x0000, 0x0004, 0x0003, 0x0006, HA_TEMPMEASUREMENT_CLUSTER_ID , 0xffff, };
PRIVATE const PDUM_thAPdu s_ahEndpoint1InputClusterAPdus[6] = { apduZCL, apduZCL, apduZCL, apduZCL, apduZCL, apduZCL, };
PRIVATE uint8 s_au8Endpoint1InputClusterDiscFlags[1] = { 0x1f };

PRIVATE const uint16 s_au16Endpoint1OutputClusterList[5] = { 0x0000, 0x0004, 0x0003, 0x0006, HA_TEMPMEASUREMENT_CLUSTER_ID, };
PRIVATE uint8 s_au8Endpoint1OutputClusterDiscFlags[1] = { 0x08 };


Now update Simple Descriptor structure (see the declaration of zps_tsAplAfSimpleDescCont and ZPS_tsAplAfSimpleDescriptor structures to understand how to correctly fill the various parameters) to reflect the input cluster and output cluster list correctly as below :

PUBLIC zps_tsAplAfSimpleDescCont s_asSimpleDescConts[2] = {


This file is used to set the options used by the ZCL.

Enable Clusters

The cluster functionality for the router endpoint was enabled:

/*                             Enable Cluster                               */
/*                                                                          */
/* Add the following #define's to your zcl_options.h file to enable         */
/* cluster and their client or server instances                             */
#define CLD_BASIC



#define CLD_GROUPS


#define CLD_ONOFF


Enable any optional Attributes and Commands for the clusters

/* Temperature Measurement Cluster - Optional Attributes */
/* */
/* Add the following #define's to your zcl_options.h file to add optional */
/* attributes to the time cluster. */

/* Basic Cluster - Optional Commands */
/* */
/* Add the following #define's to your zcl_options.h file to add optional */
/* commands to the basic cluster. */

/* OnOff Cluster - Optional Commands */
/* */
/* Add the following #define's to your zcl_options.h file to add optional */
/* commands to the OnOff cluster. */

 Add the cluster creation and initialization into ZigBee Base device definitions

The cluster functionality for some of the clusters (like OnOff Client) is already present on ZigBee Base Device. For Temperature Measurement cluster the functionality was added into ZigBee Base Device.


The first step was including the Temperature Measurement header files into base device header file as shown below: 

#include "TemperatureMeasurement.h"

The second step was adding cluster instance (tsZHA_BaseDeviceClusterInstances) into base device Instance as shown below:

/* Temperature Measurement Instance */
tsZCL_ClusterInstance sTemperatureMeasurementServer;

The next step was to define the cluster into the base device structure (tsZHA_BaseDevice) as below:

tsCLD_TemperatureMeasurement sTemperatureMeasurementServerCluster;


The cluster create function for Temperature Measurement cluster for server was called in ZigBee base device registration function:


   /* Create an instance of a Temperature Measurement cluster as a server */
                                                   &au8TemperatureMeasurementAttributeControlBits[0]) != E_ZCL_SUCCESS)
      return E_ZCL_FAIL;


Temperature Measurement Server Cluster Data Initialization - APP_vZCL_DeviceSpecific_Init()

The default attribute values for the Temperature Measurement clusters are initialized:

PRIVATE void APP_vZCL_DeviceSpecific_Init(void)
   sBaseDevice.sOnOffServerCluster.bOnOff = FALSE;
   FLib_MemCpy(sBaseDevice.sBasicServerCluster.au8ManufacturerName, "NXP", CLD_BAS_MANUF_NAME_SIZE);
   FLib_MemCpy(sBaseDevice.sBasicServerCluster.au8ModelIdentifier, "BDB-Router", CLD_BAS_MODEL_ID_SIZE);
   FLib_MemCpy(sBaseDevice.sBasicServerCluster.au8DateCode, "20150212", CLD_BAS_DATE_SIZE);
   FLib_MemCpy(sBaseDevice.sBasicServerCluster.au8SWBuildID, "1000-0001", CLD_BAS_SW_BUILD_SIZE);

   sBaseDevice.sTemperatureMeasurementServerCluster.i16MeasuredValue = 0;
   sBaseDevice.sTemperatureMeasurementServerCluster.i16MinMeasuredValue = 0;
   sBaseDevice.sTemperatureMeasurementServerCluster.i16MaxMeasuredValue = 0;
2 people found this helpful