Zigbee stack API overview

1. Scope↑

This wiki describes the implementation of the Exegin ZSDK (Zigbee software design kit) API (application programming interface) for Zigbee on the STM32WBA Series based on V1.5 STM32Cube Firmware release supporting R23_FFD [1]. It describes all APIs used to control the stack. In particular, it covers APIs used to access to the following layers: BDB (base device behavior), APS (applications services), NWK (network layer services) and ZDO (Zigbee device object).

2. Zigbee stack handle↑

The stack is initialized by calling the function ZbInit(), which returns a stack instance handle of type ZigBeeT *. To the application this is an anonymous pointer, the contents of which are private to the stack. The application should only interact with ZigBeeT * to provide it back to the stack when calling most stack API functions. For this reason, stack API functions follow this format:

ZbFunc(struct ZigBeeT *zb, ...)

3. Status codes↑

Many functions in the Zigbee stack return a status code as an enumeration. The general status codes are the most common, and are included below as an example of their format.

3.1. General status codes↑

Value Status Code
0x00 ZB_STATUS_SUCCESS
0x70 ZB_STATUS_ALLOC_FAIL
0x71 ZB_STATUS_TIMEOUT

3.2. ZDP status codes↑

Status Value Status Code
0x00 ZB_ZDP_STATUS_SUCCESS
0x80 ZB_ZDP_STATUS_INV_REQTYPE
0x81 ZB_ZDP_STATUS_DEVNOTFOUND
0x82 ZB_ZDP_STATUS_INVALID_EP
0x83 ZB_ZDP_STATUS_NOT_ACTIVE
0x84 ZB_ZDP_STATUS_NOT_SUPPORTED
0x85 ZB_ZDP_STATUS_TIMEOUT
0x86 ZB_ZDP_STATUS_NO_MATCH
0x88 ZB_ZDP_STATUS_NO_ENTRY
0x89 ZB_ZDP_STATUS_NO_DESCRIPTOR
0x8a ZB_ZDP_STATUS_INSUFFICIENT_SPACE
0x8b ZB_ZDP_STATUS_NOT_PERMITTED
0x8c ZB_ZDP_STATUS_TABLE_FULL
0x8d ZB_ZDP_STATUS_NOT_AUTHORIZED
0x8e ZB_ZDP_STATUS_DEVICE_BINDING_TABLE_FULL
0x8f ZB_ZDP_STATUS_INVALID_INDEX


3.3. APS status codes↑

Status Value Status Code
0x00 ZB_APS_STATUS_SUCCESS
0xa0 ZB_APS_STATUS_ASDU_TOO_LONG
0xa1 ZB_APS_STATUS_DEFRAG_DEFERRED
0xa2 ZB_APS_STATUS_DEFRAG_UNSUPPORTED
0xa3 ZB_APS_STATUS_ILLEGAL_REQUEST
0xa4 ZB_APS_STATUS_INVALID_BINDING
0xa5 ZB_APS_STATUS_INVALID_GROUP
0xa6 ZB_APS_STATUS_INVALID_PARAMETER
0xa7 ZB_APS_STATUS_NO_ACK
0xa8 ZB_APS_STATUS_NO_BOUND_DEVICE
0xa9 ZB_APS_STATUS_NO_SHORT_ADDRESS
0xaa ZB_APS_STATUS_NOT_SUPPORTED
0xab ZB_APS_STATUS_SECURED_LINK_KEY
0xac ZB_APS_STATUS_SECURED_NWK_KEY
0xad ZB_APS_STATUS_SECURITY_FAIL
0xae ZB_APS_STATUS_TABLE_FULL
0xaf ZB_APS_STATUS_UNSECURED
0xb0 ZB_APS_STATUS_UNSUPPORTED_ATTRIBUTE

4. Timers↑

Timers are fundamental to the operation of the stack. The stack uses many different timers internally, and timer operation impacts events such as timeout. Some APIs have been exposed so applications may use the timer.

4.1. ZbTimerAlloc()↑

A timer is created by calling ZbTimerAlloc() along with a callback function (app_timer_callback). This callback will be invoked when the timer expires.

ZbTimerAlloc() Example

struct ZbTimerT *timer;
timer = ZbTimerAlloc(zb, app_timer_callback, NULL);

4.2. ZbTimerReset()↑

Once created, the timer must be reset to become active. The following example will reset and start the timer with a delay of 1000 ms or 1 sec, and includes the necessary application callback function.

ZbTimerReset() Prototype

ZbTimerReset(timer, 1000);
static void
app_timer callback(struct ZigBeeT *zb, void *arg)

4.3. ZbTimerStop()↑

Stop a timer before it expires.

ZbTimerStop() Prototype

ZbTimerStop(timer);

4.4. ZbTimerRemaining()↑

Returns the time remaining in milliseconds before the timer expires.

ZbTimerRemaining() Prototype

ZbTimerRemaining(timer);

Will return UINT_MAX if the timer is not running.

4.5. ZbTimerFree()↑

Frees a timer.

ZbTimerFree() Prototype

ZbTimerFree(timer);

4.6. ZbTimerChangeCallback()↑

Changes the callback function for the specified timer, without the need to free and allocate a new timer.

ZbTimerChangeCallback() Prototype

void ZbTimerChangeCallback(struct ZbTimerT *timer, void (*callback)(struct ZigBeeT
*zb, void *cb_arg), void *arg);

Parameters

  • timer – Zigbee timer structure
  • zb – Zigbee stack structure
  • arg – callback argument

4.7. ZbTimerRunning()↑

Returns true if the given timer is active.

ZbTimerRunning() Prototype

bool ZbTimerRunning(struct ZbTimerT *timer);

Parameters

  • timer – Zigbee timer structure

4.8. ZbUptime()↑

Retrieves the current uptime in milliseconds. This is typically only used internally by the stack for the timers.

ZbUptime() Prototype

ZbUptimeT ZbUptime(void);

Returns the current uptime in milliseconds. Note that this function will never return 0. Values are from 1 to ZB_UPTIME_MAX.

4.9. ZbTimeoutRemaining()↑

Used with ZbUptime. This function returns the time difference between expire_time and now, or 0 if the time has expired (now >= expire_time). This function handles the case where the time value has rolled over starting back from 0.

ZbTimeoutRemaining() Prototype

unsigned int ZbTimeoutRemaining(ZbUptimeT now, ZbUptimeT expire_time);

Parameters

  • now – current time
  • expire_time – The time when the timer was set to expire

5. Packet and message filters↑

Packet and message filters are primarily used internally by the stack. Typical applications will not need to use packet and message filters. Message filters are so central to stack operation that they afford a mechanism for applications to extend stack functionality. As messages traverse the stack, through the MAC, NWK, APS, ZDO or ZCL layers, filters are used to direct messages to the appropriate destination. A filter is defined with certain criteria. When a message is processed, the filters are checked and matching messages are directed to the requesting filter.

6. MAC initialization↑

The stack can operate on many different real and virtual MAC interfaces. Physical devices can be connected by SPI, UART, or USB. The MAC and stack can be coresident, or operate on separate MCUs. When on a separate MCU, Exegin SIO, MCP (MAC Control Protocol) or a proprietary protocol may be used.

Device options and configuration are highly variably. The specific API is device-dependent. However. The ultimate goal is for a WpanPublicT *device pointer to be created and passed to the stack, which has no knowledge of the device used.

6.1. Bare Metal device initialization↑

The device accesses the radio through the use of memory-mapped registers. On powerup, the radio hardware must be initialized. In this case, the PHY is local so that hardware specific PHY device is created, and a MAC instance created which uses this PHY interface.

Bare Metal device initialization example

#include "phy.h"
#include "wpan_mac_init.h"
WpanPublicT *device;
struct phyif phy;
uint64_t ext_addr;
/* initialize radio */
radio_init(&phy);
ext_addr = radio_get_ext_addr(); /* obtain from device */
/* optional callbacks not used for simplicity */
device = WpanMacInit(&phy, ext_addr, NULL, NULL);

7. Network management↑

ZbStartup executes the standard startup procedure. The startup function handles callbacks from the stack to maintain the network and security processes. For example, these include the handling of APSME-UPDATEDEVICE.indication messages when acting as a coordinator trust center, to handle the authentication procedure described in section 4.6.3.2 of the Zigbee specification document.

The message callback handlers can be overridden by the application by creating message filters using ZbMsgFilterRegister. This function and the entire startup code can be bypassed by the application, and the network layer APIs used directly, if so desired. If security is enabled (nwkSecurityLevel != 0), this function overloads the APSME callback functions and performs the authentication procedure.

This is purely a helper function, and if finer-grained control of startup and authentication is necessary then the application can perform these tasks manually.

8. Stack configuration↑

Most stack configuration parameters are controlled by the ZbStartupT structure passed to ZbStartup1.

ZbStartupT Structure

struct ZbStartupT config;

There are many configuration settings. Most applications want to first initialize the configuration with the default ZigBee PRO settings, or the default smart energy application settings:

Zigbee Pro startup default configuration

ZbStartupConfigGetProDefaults(&config);

Zigbee Smart Energy startup default configuration

ZbStartupConfigGetProSeDefaults(&config);

These functions do not set the channel list, which must be set manually by the application.

The following shows how to set the available channels (channel mask) to 11 and 15 on channel page 0 (2.4 GHz):

Setting the channel list

config.channelList.list[0].page = 0;
config.channelList.list[0].channelMask = (uint32_t)((1ul << 11) | (1ul << 15));
config.channelList.count = 1;

Each page must have its own mask. The list can contain a total of MAX_CHANNEL_LIST_ENTRIES.

A common configuration is the commissioning mode.

Commissioning mode configuration

config.bdbCommissioningMode |= BDB_COMMISSION_MODE_FIND_BIND;

The Touchlink commissioning mode is used frequently.

Touchlink commissioning mode configuration

config.bdbCommissioningMode |= BDB_COMMISSION_MODE_TOUCHLINK;
config.touchlink.flags = 0;
config.touchlink.zb_info = ZCL_TL_ZBINFO_TYPE_ROUTER;
config.touchlink.zb_info |= ZCL_TL_ZBINFO_RX_ON_IDLE;

9. APS layer↑

9.1. Functions↑

9.1.1. ZbApsAddrIsBcast↑

bool ZbApsAddrIsBcast(const struct ZbApsAddrT *addr);

Check if an address is set to broadcast.

Parameters

Return

  • Returns true if the address is set to broadcast, false otherwise

9.1.2. ZbApsAddrIsLocal↑

bool ZbApsAddrIsLocal(struct ZigBeeT *zb, const struct ZbApsAddrT *addr);

Check if an address is that of the provided Zigbee stack structure.

Parameters

Return

  • Returns true if the address is local, false otherwise.

9.1.3. ZbApsBindSrcExists↑

bool ZbApsBindSrcExists(struct ZigBeeT *zb, uint8_t endpoint, uint16_t clusterId);

Returns true if there is a binding entry in the Binding Table that matches the local device as the source address, and a matching source endpoint and cluster Id.

Parameters

Return

  • Returns true if binding exists, false otherwise.

9.1.4. ZbApsCommandSecurityCheck↑

bool ZbApsCommandSecurityCheck(struct ZigBeeT *zb, enum ZbApsCmdIdT cmdId, uint64_t srcExtAddr, enum ZbSecEncryptT encryptKeyType);

Check if an incoming command has the appropriate security level.

Parameters

Return

  • Returns true if the command is allowed, false otherwise

9.1.5. ZbApsEndpointExists↑

bool ZbApsEndpointExists(struct ZigBeeT *zb, uint8_t endpoint);

Determine if an endpoint currently exists.

Parameters

Return

  • Returns true if the endpoint is found, false otherwise

9.1.6. ZbApsEndpointProfile↑

uint16_t ZbApsEndpointProfile(struct ZigBeeT *zb, uint8_t endpoint);

Retrieve the profile ID of an endpoint.

Parameters

Return

  • Returns profile ID, or ZCL_PROFILE_WILDCARD (0xffff) on error

9.1.7. ZbApsFilterClusterAdd↑

struct ZbApsFilterT * ZbApsFilterClusterAdd(struct ZigBeeT *zb, uint8_t endpoint, uint16_t clusterId, uint16_t profileId, 
enum zb_msg_filter_rc (*callback) (struct ZbApsdeDataIndT *dataInd, void *cb_arg), void *arg);

Create an APSDE-DATA.indication filter for a specific endpoint and cluster Id. being filtered. For any incoming APS data packets that match this filter, the provided 'callback' function is called. The filter is freed by calling ZbApsFilterEndpointFree.

Parameters

Return

  • Filter pointer (handle)

9.1.8. ZbApsFilterEndpointAdd↑

struct ZbApsFilterT * ZbApsFilterEndpointAdd(struct ZigBeeT *zb, uint8_t endpoint, uint16_t profileId, 
enum zb_msg_filter_rc (*callback) (struct ZbApsdeDataIndT *dataInd, void *cb_arg), void *arg);

Create an APSDE-DATA.indication filter for a specific endpoint, with no specific cluster being filtered. For any incoming APS data packets that match this filter, the provided 'callback' function is called. The filter is freed by calling ZbApsFilterEndpointFree.

Parameters

Return

  • Filter pointer (handle)

9.1.9. ZbApsFilterEndpointFree↑

Remove and free an APS indication filter.

void ZbApsFilterEndpointFree(struct ZigBeeT *zb, struct ZbApsFilterT *filter);

Parameters

Return

  • Returns void

9.1.10. ZbApsFragDropTxAdd↑

bool ZbApsFragDropTxAdd(struct ZigBeeT *zb, uint8_t blockNum);

Used by the zbcli application as a DUT during ZCP certification testing (TP/PRO/BV-43 and TP/PRO/BV-44). It causes the stack to drop the next APS fragment to be transmitted matching the block number given by 'blockNum'.

Parameters

Return

  • True if the block number entry was created, false otherwise.

9.1.11. ZbApsFragDropTxClear↑

void ZbApsFragDropTxClear(struct ZigBeeT *zb);

Used by the zbcli application as a DUT during ZCP certification testing (TP/PRO/BV-43 and TP/PRO/BV-44). It clears all entries created by ZbApsFragDropTxAdd to drop APS fragments about to be transmitted. No fragments will be purposefully dropped after this point.

Parameters

Return

  • Returns void

9.1.12. ZbApsGetIndex↑

enum ZbStatusCodeT ZbApsGetIndex(struct ZigBeeT *zb, enum ZbApsmeIbAttrIdT attrId, void *attrPtr, 
unsigned int attrSz, unsigned int attrIndex);

Performs an APSME-GET.request. Retrieve the value of the attribute corresponding to the supplied index.

Parameters

Return

  • ZCL_STATUS_SUCCESS if successful, or other ZclStatusCodeT value on error

9.1.13. ZbApsGroupIsMember↑

bool ZbApsGroupIsMember(struct ZigBeeT *zb, uint16_t groupAddr, uint8_t endpoint);

Check if the local device is a member of a specified group.

Parameters

Return

  • Returns true if the device is a member, false otherwise

9.1.14. ZbApsGroupsGetCapacity↑

uint8_t ZbApsGroupsGetCapacity(struct ZigBeeT *zb);

Retrieve the number of free entries in the group table.

Parameters

Return

  • Returns the number of free entries in the group table

9.1.15. ZbApsGroupsGetMembership↑

uint8_t ZbApsGroupsGetMembership(struct ZigBeeT *zb, uint8_t endpoint, uint16_t *group_list, uint8_t max_len);

Retrieve all group addresses on this endpoint.

Parameters

Return

  • Returns a number of group addresses

9.1.16. ZbApsLinkKeyExists↑

bool ZbApsLinkKeyExists(struct ZigBeeT *zb, uint64_t partner);

Check if a link key exists in the AIB.

Parameters

Return

  • Returns true if the key exists, false otherwise

9.1.17. ZbApsLookupKey↑

struct ZbApsmeKeyPairT * ZbApsLookupKey(struct ZigBeeT *zb, struct ZbApsmeKeyPairT
*key, uint64_t addr, unsigned int *idx);

Look up an APS key pair descriptor from the apsDeviceKeyPairSet AIB attribute/key table.

Parameters

Return

  • Returns key pair on success, or NULL if no such entry was found

9.1.18. ZbApsSetIndex↑

enum ZbStatusCodeT ZbApsSetIndex(struct ZigBeeT *zb, enum ZbApsmeIbAttrIdT attrId,
const void *attrPtr, unsigned int attrSz, unsigned int attrIndex);

Performs an APSME-SET.request. Set the value of the attribute corresponding to the supplied index.

Parameters

Return

  • ZCL_STATUS_SUCCESS if successful, or other ZclStatusCodeT value on error

9.1.19. ZbApsUnbindAllReq↑

void ZbApsUnbindAllReq(struct ZigBeeT *zb);

Remove all entries from the binding table.

Parameters

Return

  • Returns void

9.1.20. ZbApsdeDataReqCallback↑

enum ZbStatusCodeT ZbApsdeDataReqCallback(struct ZigBeeT *zb, struct ZbApsdeDataReqT *req, 
void (*callback)(struct ZbApsdeDataConfT *conf, void *arg), void *arg);

Send an APSDE-DATA.request.

Parameters

Return

  • ZCL_STATUS_SUCCESS if the packet was queued, or other ZclStatusCodeT value on error

9.1.21. ZbApsmeAddEndpoint↑

void ZbApsmeAddEndpoint(struct ZigBeeT *zb, struct ZbApsmeAddEndpointReqT *r, struct ZbApsmeAddEndpointConfT *c);

Register an endpoint with the ZigBee stack. Typically called during initialization. Should be safe to call from an init function.

Parameters

Return

  • Returns void

9.1.22. ZbApsmeAddGroupReq↑

void ZbApsmeAddGroupReq(struct ZigBeeT *zb, struct ZbApsmeAddGroupReqT *r, struct ZbApsmeAddGroupConfT *c);

Add an entry to the group table.

Parameters

Return

  • Returns void

9.1.23. ZbApsmeAddKeyReq↑

void ZbApsmeAddKeyReq(struct ZigBeeT *zb, struct ZbApsmeAddKeyReqT *req, struct ZbApsmeAddKeyConfT *conf);

Perform an APSME-ADD-KEY.request.

Parameters

Return

  • Returns void

9.1.24. ZbApsmeBindReq↑

void ZbApsmeBindReq(struct ZigBeeT *zb, struct ZbApsmeBindReqT *bindReqPtr, struct ZbApsmeBindConfT *bindConfPtr);

Add an entry to the stack binding table. The size of the binding table is determined in the tableSizes parameter to ZbInit(). The binding table is maintained by the stack.

Parameters

Return

  • Returns void

9.1.25. ZbApsmeConfirmKeyReq↑

void ZbApsmeConfirmKeyReq(struct ZigBeeT *zb, struct ZbApsmeConfirmKeyReqT *req,
void (*callback)(struct ZbApsdeDataConfT *conf, void *arg), void *arg);

Perform an APSME-CONFIRM-KEY.request.

Parameters

Return

  • Returns void

9.1.26. ZbApsmeEndpointClusterListAppend↑

bool ZbApsmeEndpointClusterListAppend(struct ZigBeeT *zb, uint8_t endpoint, uint16_t cluster_id, bool is_input);

Add a cluster ID to the input cluster list of an existing endpoint.

Parameters

Return

  • Returns true on success, false otherwise

9.1.27. ZbApsmeEndpointClusterListRemove↑

bool ZbApsmeEndpointClusterListRemove(struct ZigBeeT *zb, uint8_t endpoint, uint16_t cluster_id, bool is_input);

Remove a cluster from an endpoint’s cluster list.

Parameters

Return

  • Returns true on success, false otherwise

9.1.28. ZbApsmeGetKeyReq↑

void ZbApsmeGetKeyReq(struct ZigBeeT *zb, struct ZbApsmeGetKeyReqT *req, struct ZbApsmeGetKeyConfT *conf);

Perform an APSME-GET-KEY.request.

Parameters

Return

  • Returns void

9.1.29. ZbApsmeRemoveAllGroupsReq↑

void ZbApsmeRemoveAllGroupsReq(struct ZigBeeT *zb, struct ZbApsmeRemoveAllGroupsReqT *r, struct ZbApsmeRemoveAllGroupsConfT *c);

Remove all entries from the group table.

Parameters

Return

  • Returns void

9.1.30. ZbApsmeRemoveDeviceReq↑

void ZbApsmeRemoveDeviceReq(struct ZigBeeT *zb, struct ZbApsmeRemoveDeviceReqT *req);

Perform an APSME-REMOVE-DEVICE.request.

Parameters

Return

  • Returns void

9.1.31. ZbApsmeRemoveEndpoint↑

void ZbApsmeRemoveEndpoint(struct ZigBeeT *zb, struct ZbApsmeRemoveEndpointReqT *r, struct ZbApsmeRemoveEndpointConfT *c);

Unregister and remove an endpoint from the APS endpoint table. Typically called when terminating an application.

Parameters

Return

  • Returns void

9.1.32. ZbApsmeRemoveGroupReq↑

void ZbApsmeRemoveGroupReq(struct ZigBeeT *zb, struct ZbApsmeRemoveGroupReqT *r, struct ZbApsmeRemoveGroupConfT *c);

Remove an entry from the group table

Parameters

Return

  • Returns void

9.1.33. ZbApsmeRemoveKeyReq↑

void ZbApsmeRemoveKeyReq(struct ZigBeeT *zb, struct ZbApsmeRemoveKeyReqT *req,
struct ZbApsmeRemoveKeyConfT *conf);

Perform an APSME-REMOVE-KEY.request.

Parameters

Return

  • Returns void

9.1.34. ZbApsmeRequestKeyReq↑

enum ZbStatusCodeT ZbApsmeRequestKeyReq(struct ZigBeeT *zb, struct ZbApsmeRequestKeyReqT *req);

Perform an APSME-REQUEST-KEY.request.

Parameters

Return

  • ZCL_STATUS_SUCCESS if successful, or other ZclStatusCodeT value on error

9.1.35. ZbApsmeSwitchKeyReq↑

void ZbApsmeSwitchKeyReq(struct ZigBeeT *zb, struct ZbApsmeSwitchKeyReqT *req);

Perform an APSME-SWITCH-KEY.request.

Parameters

Return

  • Returns void

9.1.36. ZbApsmeTransportKeyReq↑

void ZbApsmeTransportKeyReq(struct ZigBeeT *zb, struct ZbApsmeTransportKeyReqT *req);

Perform an APSME-TRANSPORT-KEY.request.

Parameters

Return

  • Returns void

9.1.37. ZbApsmeUnbindReq↑

void ZbApsmeUnbindReq(struct ZigBeeT *zb, struct ZbApsmeUnbindReqT *unbindReqPtr, struct ZbApsmeUnbindConfT *unbindConfPtr);

Remove an entry from the binding table.

Parameters

Return

  • Returns void

9.1.38. ZbApsmeUpdateDeviceReq↑

enum ZbSecHdrKeyIdT ZbApsmeUpdateDeviceReq(struct ZigBeeT *zb, struct ZbApsmeUpdateDeviceReqT *req);

Perform an APSME-UPDATE-DEVICE.request.

Parameters

Return

  • Returns security key used to send Update Device

9.1.39. ZbApsmeVerifyKeyReq↑

void ZbApsmeVerifyKeyReq(struct ZigBeeT *zb, struct ZbApsmeVerifyKeyReqT *req);

Perform an APSME-VERIFY-KEY.request.

Parameters

Return

  • Returns void

9.2. Enumerations↑

9.2.1. ZbApsAddrModeT↑

APSDE and interpan addressing modes

9.2.2. ZbApsCmdIdT↑

APS command frame IDs

9.2.3. ZbApsInitialJoinAuthMethodT↑

Initial join authentication method used with DLK.

9.2.4. ZbApsPostJoinKeyUpdateMethodT↑

Post join key update method.

9.2.5. ZbApsRequestKeyTypeT↑

RequestKeyType values

9.2.6. ZbApsmeDeviceStatusT↑

Device status values for APSME-UPDATE-DEVICE.request and indication

9.2.7. ZbApsmeIbAttrIdT↑

APS IB attributes

9.2.8. ZbApsmePolicyT↑

Trust center policy flags (ZB_APS_IB_ID_TRUST_CENTER_POLICY)

9.3. Structures↑

9.3.1. ZbApsAddrT↑

APS address information data structure

Parameters

9.3.2. ZbApsBufT↑

Buffer descriptor for vectored/scatter-gather API. Used when ZB_APSDE_DATAREQ_TXOPTIONS_VECTOR TX

Options bit is set.

Parameters

9.3.3. ZbApsRelayInfoT↑

APS relay information data structure

Parameters

9.3.4. ZbApsdeDataConfT↑

APSDE-DATA.confirm data structure

Parameters

9.3.5. ZbApsdeDataIndT↑

APSDE-DATA.indication data structure. These messages are received from the stack after setting up the proper message filter using ZbApsFilterEndpointAdd or ZbApsFilterClusterAdd.

Parameters

9.3.6. ZbApsdeDataReqT↑

APSDE-DATA.request data structure

Parameters

9.3.7. ZbApsmeAddEndpointConfT↑

APSME-ADD-ENDPOINT.confirm - Exegin Custom

Parameters

9.3.8. . ZbApsmeAddEndpointReqT↑

APSME-ADD-ENDPOINT.request - Exegin Custom

Parameters

9.3.9. ZbApsmeAddGroupConfT↑

APSME-ADD-GROUP.confirm Parameters

9.3.10. ZbApsmeAddGroupReqT↑

APSME-ADD-GROUP.request

Parameters

9.3.11. ZbApsmeAddKeyConfT↑

APSME-ADD-KEY.confirm - Exegin custom

Parameters

9.3.12. ZbApsmeAddKeyReqT↑

APSME-ADD-KEY.request - Exegin custom

Parameters

9.3.13. ZbApsmeBindConfT↑

APSME-BIND.confirm

Parameters

9.3.14. ZbApsmeBindReqT↑

APSME-BIND.request

Parameters

9.3.15. ZbApsmeBindT↑

APS binding table entry

Parameters

9.3.16. ZbApsmeConfirmKeyIndT↑

APSME-CONFIRM-KEY.indication

Parameters

9.3.17. ZbApsmeConfirmKeyReqT↑

APSME-CONFIRM-KEY.request

Parameters

9.3.18. ZbApsmeGetKeyReqT↑

APSME-GET-KEY.request - Exegin custom

Parameters

9.3.19. ZbApsmeGroupT↑

APS group ID table entry

Parameters

9.3.20. ZbApsmeKeyNegoConfirmT↑

APSME-KEY-NEGOTIATION.Confirm

Parameters

9.3.21. ZbApsmeKeyNegoIndT↑

APSME-KEY-NEGOTIATION.indication (R23)

Parameters

9.3.22. ZbApsmeRemoveAllGroupsConfT↑

APSME-REMOVE-ALL-GROUPS.confirm

Parameters

9.3.23. ZbApsmeRemoveAllGroupsReqT↑

APSME-REMOVE-ALL-GROUPS.request

Parameters

9.3.24. ZbApsmeRemoveDeviceIndT↑

APSME-REMOVE-DEVICE.indication

Parameters

9.3.25. ZbApsmeRemoveDeviceReqT↑

APSME-REMOVE-DEVICE.request

Parameters

9.3.26. ZbApsmeRemoveEndpointConfT↑

APSME-REMOVE-ENDPOINT.confirm - Exegin custom

Parameters

9.3.27. ZbApsmeRemoveEndpointReqT↑

APSME-REMOVE-ENDPOINT.request - Exegin custom

Parameters

9.3.28. ZbApsmeRemoveGroupConfT↑

APSME-REMOVE-GROUP.confirm

Parameters

9.3.29. ZbApsmeRemoveGroupReqT↑

APSME-REMOVE-GROUP.request

Parameters

9.3.30. ZbApsmeRemoveKeyConfT↑

APSME-REMOVE-KEY.confirm - Exegin custom

Parameters

9.3.31. ZbApsmeRemoveKeyReqT↑

APSME-REMOVE-KEY.request - Exegin custom

Parameters

9.3.32. ZbApsmeRequestKeyIndT↑

APSME-REQUEST-KEY.indication

Parameters

9.3.33. ZbApsmeRequestKeyReqT↑

APSME-REQUEST-KEY.request

Parameters

9.3.34. ZbApsmeSecChallengeIndT↑

APSME-SEC-CHALLENGE.indication (R23 - Exegin add-on)

Parameters

9.3.35. ZbApsmeSecChallengeReqT↑

APSME-SEC-CHALLENGE.request (R23 - Exegin add-on)

Parameters

9.3.36. ZbApsmeSwitchKeyIndT↑

APSME-SWITCH-KEY.indication

Parameters

9.3.37. ZbApsmeSwitchKeyReqT↑

APSME-SWITCH-KEY.request

Parameters

9.3.38. ZbApsmeTransKeyIndT↑

APSME-TRANSPORT-KEY.indication

Parameters

9.3.39. ZbApsmeTransportKeyReqT↑

APSME-TRANSPORT-KEY.request

Parameters

9.3.40. ZbApsmeUnbindConfT↑

APSME-UNBIND.confirm

Parameters

9.3.41. ZbApsmeUnbindReqT↑

APSME-UNBIND.request

Parameters

9.3.41.1. 14.3.42. ZbApsmeUpdateDeviceIndT↑

APSME-UPDATE-DEVICE.indication

Parameters

9.3.41.2. 14.3.43. ZbApsmeUpdateDeviceReqT↑

APSME-UPDATE-DEVICE.request

Parameters

9.3.41.3. 14.3.44. ZbApsmeVerifyKeyIndT↑

APSME-VERIFY-KEY.indication

Parameters

9.3.41.4. 14.3.45. ZbApsmeVerifyKeyReqT↑

APSME-VERIFY-KEY.request

Parameters

9.3.41.5. 14.3.46. ZbMsgApsCommandT↑

APS Command Indication struct. Used with the message filter Id 'ZB_MSG_FILTER_APS_COMMAND_IND'.

Parameters

10. BDB Layer↑

#include "zigbee.bdb.h"

10.1. Functions↑

10.1.1. ZbBdbGetEndpointStatus↑

enum ZbBdbCommissioningStatusT ZbBdbGetEndpointStatus(struct ZigBeeT *zb, uint8_t endpoint);

Get commissioning status for the given endpoint (same for all endpoints?). If endpoint = ZB_ENDPOINT_BCAST, returns the status for the first endpoint found.

Parameters

Return

  • Returns ZB_BDB_COMMISS_STATUS_SUCCESS on success, other BDB status code on failure

10.1.2. ZbBdbGetIndex↑

enum ZbStatusCodeT ZbBdbGetIndex(struct ZigBeeT *zb, enum ZbBdbAttrIdT attrId, void
*attrPtr, unsigned int attrSz, unsigned int attrIndex);

Read a BDB IB attribute.

Parameters

Return

  • ZCL_STATUS_SUCCESS if successful, or other ZclStatusCodeT value on error

10.1.3. ZbBdbSetIndex↑

enum ZbStatusCodeT ZbBdbSetIndex(struct ZigBeeT *zb, enum ZbBdbAttrIdT attrId,
const void *attrPtr, unsigned int attrSz, unsigned int attrIndex);

Write a BDB IB attribute.

Parameters

Return

  • ZCL_STATUS_SUCCESS if successful, or other ZclStatusCodeT value on error

10.2. Enumerations↑

10.2.1. ZbBdbAttrIdT↑

BDB IB attributes

10.2.2. ZbBdbCommissioningStatusT↑

bdbCommissioningStatus

10.2.3. ZbBdbLinkKeyExchMethodT↑

bdbTCLinkKeyExchangeMethod

10.2.4. ZbBdbTouchlinkKeyIndexT↑

ZbBdbTouchlinkKeyIndex

11. DLK utilities↑

#include "zigbee.dlk.h"

11.1. Description↑

This file defines all the public APIs used as part of ZigBee dynamic link key (DLK) implementation.

11.2. Functions↑

11.2.1. ZbDlkKeyNegoWithDevice↑

enum ZbStatusCodeT ZbDlkKeyNegoWithDevice(struct ZigBeeT *zb, uint64_t partnerAddr,
void (*callback)(enum ZbStatusCodeT status, void *arg), void *arg);

Perform dynamic link key negotiation (DLK) with a partner R23 device after the initiator has joined the network. The initiator and the responder devices can be TC or non-TC. In effect, this API can be used to negotiate both trust center and application link key.

Parameters

Return

  • ZB status code. If not ZB_STATUS_SUCCESS, then the callback will not be called.

11.3. Enumerations↑

11.3.1. ZbSelKeyNegoMethodT↑

Enumeration for selected key negotiation methods.

11.3.2. ZbSelPreSharedSecretT↑

Enumeration for selected PSK (Pre-shared) secret.

12. Zigbee message filters↑

#include "zigbee.filter.h"

12.1. Functions↑

12.1.1. ZbMsgFilterRegister↑

struct ZbMsgFilterT * ZbMsgFilterRegister(struct ZigBeeT *zb, uint32_t mask, uint8_t prio,
enum zb_msg_filter_rc (*callback)(struct ZigBeeT *zb, uint32_t id, void *msg, void *cbarg), void *arg);

Register message filter with the stack.

Parameters

Return

  • Undocumented

12.1.2. ZbMsgFilterRemove↑

void ZbMsgFilterRemove(struct ZigBeeT *zb, struct ZbMsgFilterT *filter);

Removes the given message filter from the stack.

Parameters

Return

  • Undocumented

12.2. Enumerations↑

12.2.1. zb_msg_filter_rc↑

Message filter callback return values. Used for the return codes with the callbacks for ZbMsgFilterRegister, ZbApsFilterEndpointAdd, etc.

12.3. Structures↑

12.3.1. ZbMsgStackEventT↑

A message that is sent if the device is an end-device and it has received an NLME-NETWORK-STATUS.indication with the PARENT_LINK_FAILURE status set. Outside of testing 18.4.* TP/R23/ZDO/APC-*, the application should attempt to rejoin the network using the ZbStartupRejoin() API call at its convenience.

Parameters

13. Zigbee utilities↑

#include "zigbee.h"

13.1. Description↑

This file groups global/external definitions from all the layer specific header files for example, aps, nwk, zdo etc… into a single place, so that one can just include zigbee.h for all the global definitions eliminating the header file inclusion clutter from source files.

13.2. Functions↑

13.2.1. ZbChangeExtAddr↑

 void ZbChangeExtAddr(struct ZigBeeT *zb, uint64_t extAddr);

Change extended address of the stack instance

Parameters

Return

  • Undocumented

13.2.2. ZbCheckTime↑

unsigned int ZbCheckTime(struct ZigBeeT *zb);

Returns the length of time (in milliseconds) until the next scheduled timer will elapse, or UINT_MAX if there are no scheduled timers.

Parameters

Return

  • Returns Length of time on success, 0 on failure

13.2.3. ZbDestroy↑

void ZbDestroy(struct ZigBeeT *zb);

Deallocates a Zigbee stack instance.

None Return

  • Undocumented

13.2.4. ZbDestroyWithCb↑

enum ZbStatusCodeT ZbDestroyWithCb(struct ZigBeeT *zb, void (*callback)(void *arg), void *arg);

Deallocates a Zigbee stack instance and save callback to application structure

Parameters

Return

  • Returns ZB_STATUS_SUCCESS on success, other status code on failure

13.2.5. ZbExtendedAddress↑

uint64_t ZbExtendedAddress(struct ZigBeeT *zb);

Returns the Extended address of the Zigbee stack.

Parameters

Return

  • Returns extended address

13.2.6. ZbHeapAvailable↑

unsigned long ZbHeapAvailable(struct ZigBeeT *zb);

Current size of memory available in the zigbee stack heap

Parameters

Return

  • Returns the amount of memory available in the zigbee stack heap, or 0 if unknown or unbounded

13.2.7. ZbHeapHighWaterMark↑

unsigned long ZbHeapHighWaterMark(struct ZigBeeT *zb);

Zigbee memory heap high-water mark. Useful during testing to determine maximum amount of memory consumed from total heap size.

Parameters

Return

  • Returns the worst-case heap usage (high-water mark)

13.2.8. ZbHeapUsed↑

unsigned long ZbHeapUsed(struct ZigBeeT *zb);

Current size of memory allocated from the zigbee stack heap

Parameters

Return

  • Returns the memory allocated from the zigbee stack heap

13.3. ZbIfAttach↑

bool ZbIfAttach(struct ZigBeeT *zb, struct WpanPublicT *dev);

Attaches an IEEE 802.15.4 device driver to the ZigBee stack. Uses the link pointers within the device structure for linking.

Return

  • Returns true on success, false otherwise

13.4. ZbIfDetach↑

void ZbIfDetach(struct ZigBeeT *zb, struct WpanPublicT *dev);

Detaches an IEEE 802.15.4 device driver from the ZigBee stack.

Parameters

Return

  • Undocumented

13.5. ZbInit↑

struct ZigBeeT * ZbInit(uint64_t extAddr, struct ZbInitTblSizesT *tblSizes, struct
ZbInitSetLoggingT *setLogging);

This is called to create a new Zigbee stack instance. One of the parameters provided is an optional pointer to a struct that defines the sizes of some of the tables within the stack (e.g. NNT, Routing Table, Security Keys Table). This lets the application developer tailor the memory usage depending on the type of device being developed.

Parameters

Return

  • Pointer to Zigbee stack instance, or NULL if there was a problem (for example, not enough memory)

13.6. ZbLeaveReq↑

enum ZbStatusCodeT ZbLeaveReq(struct ZigBeeT *zb, void (*callback)(struct ZbNlmeLeaveConfT *conf, void *arg), void *cbarg);

Send a leave request to the stack

Parameters

Return

  • Returns ZB_STATUS_SUCCESS on success, other status code on failure

13.7. ZbPersistGet↑

unsigned int ZbPersistGet(struct ZigBeeT *zb, uint8_t *buf, unsigned int maxlen);

Get the stack persistence data and write it to the buffer provided by buf. If buf is NULL and maxlen is zero, this function determines the buffer size required to save the persistence data. Use ZbStartupPersist to restore the persistence data to the stack and restart the zigbee stack.

Parameters

Return

  • Returns length of persistence data

13.8. ZbPersistNotifyRegister↑

bool ZbPersistNotifyRegister(struct ZigBeeT *zb, void (*callback)(struct ZigBeeT *zb, void *cbarg), void *cbarg);

Configure the persistence callback that tells the application when important stack parameters have changed and should be saved.

Return

  • True if callback was registered, false otherwise.

13.9. ZbPortStackEventFd↑

int ZbPortStackEventFd(struct ZigBeeT *zb);

Called to get the file descriptor to be used to wake-up the stack thread calling ZbTimerWork if a stack event needs to be processed. This is only required in multi-threaded environments. Without this event, it is possible for a user thread to initiate a stack function which does not activate the MAC layer, which in turn would wake up the stack thread.

Parameters

None Return

  • Undocumented

13.10. ZbReset↑

void ZbReset(struct ZigBeeT *zb);

Helper function to perform an APS and NWK reset

Parameters

None Return

  • Undocumented

13.11. ZbShortAddress↑

uint16_t ZbShortAddress(struct ZigBeeT *zb);

Returns the Short address of the Zigbee stack.

Return

  • Returns short address

13.12. ZbShutdown↑

void ZbShutdown(struct ZigBeeT *zb);

This API moves the stack to shutdown mode, used in case of a sleepy end device to conserve power.

Parameters

None Return

  • Undocumented

13.13. ZbStateGet↑

unsigned int ZbStateGet(struct ZigBeeT *zb, uint8_t *buf, unsigned int maxlen);

Same as ZbPersistGet, but saves additional more dynamic data such as routing tables. Use the same

ZbStartupPersist to restore the persistence data to the stack and to restart the zigbee stack.

Parameters

Return

  • Returns length of persistence and additional data

13.14. ZbTimeoutRemaining↑

unsigned int ZbTimeoutRemaining(ZbUptimeT now, ZbUptimeT expire_time);

Zigbee timeout remaining function.

Return

  • Returns 0 if now >= expire_time, difference in milliseconds between now and timeout if now < expire_time.

13.15. ZbTimerAlloc↑

struct ZbTimerT * ZbTimerAlloc(struct ZigBeeT *zb, void (*callback)(struct ZigBeeT *zb, void *cb_arg), void *arg);

Creates a ZigBee timer structure.

Parameters

Return

  • Zigbee timer structure

13.16. ZbTimerChangeCallback↑

void ZbTimerChangeCallback(struct ZbTimerT *timer, void (*callback)(struct ZigBeeT *zb, void *cb_arg), void *arg);

Changes callback function for the specified timer, without the need to free and allocate a new timer.

Parameters

Return

  • Undocumented

13.17. ZbTimerFree↑

void ZbTimerFree(struct ZbTimerT *timer);

Free a timer.

Parameters

None Return

  • Undocumented

13.18. ZbTimerRemaining↑

unsigned int ZbTimerRemaining(struct ZbTimerT *timer);

Returns time remaining in ms for a timer.

Parameters

Return

  • Time remaining in ms as an unsigned int

13.19. ZbTimerReset↑

void ZbTimerReset(struct ZbTimerT *timer, unsigned int timeout);

Reset and schedule a ZigBee timer.

Parameters

Return

  • Undocumented

13.20. ZbTimerRunning↑

bool ZbTimerRunning(struct ZbTimerT *timer);

Checks if the specified timer is active.

Return

  • True if the specified timer is active

13.21. ZbTimerStop↑

void ZbTimerStop(struct ZbTimerT *timer);

Stop a timer before it expires.

Parameters

None Return

  • Undocumented

13.22. ZbTimerWork↑

void ZbTimerWork(struct ZigBeeT *zb);

Called periodically to run the stack.

Parameters

None Return

  • Undocumented

13.23. ZbWakeupCallbackConfig↑

void ZbWakeupCallbackConfig(struct ZigBeeT *zb, void (*wakeup_cb)(void));

Configure a callback to activate the application if there is a stack event to process. Not required by all stack ports.

Parameters

Return

  • Undocumented

13.24. ZbZclBasicPostAlarm↑

bool ZbZclBasicPostAlarm(struct ZigBeeT *zb, uint8_t endpoint, uint8_t alarm_code);

Post an alarm code to the Basic Cluster.

Parameters

Return

  • Returns true on success, false otherwise

13.25. ZbZclBasicReadDirect↑

enum ZclStatusCodeT ZbZclBasicReadDirect(struct ZigBeeT *zb, uint16_t attrId, void *buf, unsigned int max_len);

Read a Basic Server attribute

Parameters

Return

  • ZCL status code

13.26. ZbZclBasicServerConfigDefaults↑

void ZbZclBasicServerConfigDefaults(struct ZigBeeT *zb, const struct ZbZclBasicServerDefaults *defaults);

Configure the default ZCL Basic Server attribute values. The Basic Server is integral to the stack in order for the attribute values to be made "global" and shared between all Basic Server instances on all endpoints. This should be

called after calling ZbInit and before creating any ZCL endpoints.

Parameters

Return

  • Undocumented

13.27. ZbZclBasicWriteDirect↑

enum ZclStatusCodeT ZbZclBasicWriteDirect(struct ZigBeeT *zb, uint16_t attrId, const void *buf, unsigned int max_len);

Write to a Basic Server attribute

Parameters

Return

  • ZCL status code

14. Structures↑

14.1. ZbChannelListEntryT↑

A single channel list entry. It includes the channel page and channel mask. It is used within struct ZbChannelListT when describing a list of channels masks, or on its own in some cases.

Parameters

14.2. ZbChannelListT↑

The Channel list structure. It includes a list of struct ZbChannelListEntryT entries; one for each channel page supported or to be used during commissioning.

Parameters

14.3. ZbInitSetLoggingT↑

Same parameters as ZbSetLogging takes. Allows debug log output as stack is being initialized.

Parameters

14.4. ZbInitTblSizesT↑

A pointer to this struct type is passed to ZbInit to define the various ZigBee tables used in the stack. If the pointer to ZbInit is NULL, the default sizes are used.

Parameters

14.5. ZbJoinerTLVsT↑

TLV structure the application can use to include TLVs in certain packet payloads during the commissioning process.

Parameters

14.6. ZbZclBasicServerDefaults↑

This data structure is used to configure the default attribute values for the basic server. All values are in ZCL data format (that is to say, strings are prefixed with the length byte)

Parameters

15. Hash Utilities↑

#include "zigbee.hash.h"

15.1. Description↑

This file defines the Exegin specific ZigBee AES Hash structure and also provides the declaration of Hashing APIs. Customers with their own hashing implementation can simply replace this file with their variant. In effect, it helps to plug customer specific hashing implementation into ZSDK stack.

16. NWK Layer

#include "zigbee.nwk.h"

16.1. Functions↑

16.1.1. ZbNlmeBcnSurveyReq↑

enum ZbStatusCodeT ZbNlmeBcnSurveyReq(struct ZigBeeT *zb, struct ZbNlmeBcnSurveyReqT *req, void (*callback)(struct ZbNlmeBcnSurveyConfT *conf,
void *cbarg), void *cbarg);

Starts the NLME beacon survey procedure and returns the survey results as part of the NLME-BEACONSURVEY.confirm primitive.

Parameters

Return

  • Undocumented

16.1.2. ZbNlmeDirectJoinReq↑

void ZbNlmeDirectJoinReq(struct ZigBeeT *zb, struct ZbNlmeDirectJoinReqT *directJoinReqPtr, struct ZbNlmeDirectJoinConfT *directJoinConfPtr);

NLME-DIRECT-JOIN.request

Parameters

Return

  • Undocumented

16.1.3. ZbNlmeEdScanReq↑

enum ZbStatusCodeT ZbNlmeEdScanReq(struct ZigBeeT *zb, struct ZbNlmeEdScanReqT *req, void (*callback)
(struct ZbNlmeEdScanConfT *scanConf, void *arg), void *cbarg);

NLME-ED-SCAN.request

Parameters

Return

  • Returns ZB_NWK_STATUS_SUCCESS on success, or other ZbStatusCodeT on failure

16.1.4. ZbNlmeGetInterface↑

void ZbNlmeGetInterface(struct ZigBeeT *zb, struct ZbNlmeGetInterfaceReqT *req, struct ZbNlmeGetInterfaceConfT *conf);

NLME-GET-INTERFACE.request

Parameters

Return

  • Undocumented

16.1.5. ZbNlmeGetReq↑

void ZbNlmeGetReq(struct ZigBeeT *zb, struct ZbNlmeGetReqT *getReqPtr, struct ZbNlmeGetConfT *getConfPtr);

NLME-GET.request

Parameters

Return

  • Undocumented

16.1.6. ZbNlmeIeeeJoiningListClear↑

void ZbNlmeIeeeJoiningListClear(struct ZigBeeT *zb);

Clear IEEE joining list

Parameters

None Return

  • Undocumented

16.1.7. ZbNlmeIeeeJoiningListRemove↑

bool ZbNlmeIeeeJoiningListRemove(struct ZigBeeT *zb, uint64_t extAddr);

Remove extended address from IEEE joining list

Parameters

Return

  • Returns true on success, or false otherwise

16.1.8. ZbNlmeJoinPolicyTimeoutRefresh↑

void ZbNlmeJoinPolicyTimeoutRefresh(struct ZigBeeT *zb);

Refresh join policy timer

Parameters

None Return

  • Undocumented

16.1.9. ZbNlmeJoinReq↑

enum ZbStatusCodeT ZbNlmeJoinReq(struct ZigBeeT *zb, struct ZbNlmeJoinReqT *joinReqPtr, void (*callback)(struct ZbNlmeJoinConfT *joinConf, void *arg),
void *cbarg);

NLME-JOIN.request

Parameters

Return

  • Returns ZB_NWK_STATUS_SUCCESS on success, or other ZbStatusCodeT on failure

16.1.10. ZbNlmeJoiningPolicyConfigure↑

bool ZbNlmeJoiningPolicyConfigure(struct ZigBeeT *zb, enum WpanJoinPolicyT policy, uint64_t *extAddrList, 
unsigned int numExtAddr, uint8_t *updateIdOverride);

External API to configure the joining policy and IEEE joining list. Should only be called by the Coordinator application. Router and End Devices applications should not be calling this, but rather obtain these parameters from the Coordinator through ZDP commands.

Parameters

Return

  • Returns true on success, or false otherwise

16.1.11. ZbNlmeJoiningPolicyGet↑

enum WpanJoinPolicyT ZbNlmeJoiningPolicyGet(struct ZigBeeT *zb);

Get the value of ZB_NWK_NIB_ID_JoiningPolicy

Parameters

Return

  • Returns joining policy enumeration value

16.1.12. ZbNlmeLeaveReq↑

enum ZbStatusCodeT ZbNlmeLeaveReq(struct ZigBeeT *zb, struct ZbNlmeLeaveReqT *leaveReqPtr, void (*callback)
(struct ZbNlmeLeaveConfT *leaveConfPtr, void *arg), void *cbarg);

NLME-LEAVE.request

Parameters

Return

  • Returns ZB_NWK_STATUS_SUCCESS on success, or other ZbStatusCodeT on failure

16.1.13. ZbNlmeNetDiscReq↑

enum ZbStatusCodeT ZbNlmeNetDiscReq(struct ZigBeeT *zb, struct ZbNlmeNetDiscReqT *req, void (*callback)
(struct ZbNlmeNetDiscConfT *conf, void *cbarg), void *cbarg);

NLME-NETWORK-DISCOVERY.request

Parameters

Return

  • Returns ZB_NWK_STATUS_SUCCESS on success, or other ZbStatusCodeT on failure

16.1.14. ZbNlmeNetFormReq↑

enum ZbStatusCodeT ZbNlmeNetFormReq(struct ZigBeeT *zb, struct ZbNlmeNetFormReqT *req, void (*callback) 
(struct ZbNlmeNetFormConfT *formConf, void *arg),   void *cbarg);

NLME-NETWORK-FORMATION.request

Parameters

Return

  • Returns ZB_NWK_STATUS_SUCCESS on success, or other ZbStatusCodeT on failure

16.1.15. ZbNlmePanIdUpdateReq↑

void ZbNlmePanIdUpdateReq(struct ZigBeeT *zb, struct ZbNlmePanIdUpdateReqT *req, struct ZbNlmePanIdUpdateConfT *conf);

Sends a NWK update command to switch the NWK PanId.

Parameters

Return

  • Undocumented

16.1.16. ZbNlmePermitJoinReq↑

void ZbNlmePermitJoinReq(struct ZigBeeT *zb, struct ZbNlmePermitJoinReqT *permitReq, struct ZbNlmePermitJoinConfT *permitConf);

NLME-PERMIT-JOIN.request

Parameters

Return

  • Undocumented

16.1.17. ZbNlmeResetReq↑

void ZbNlmeResetReq(struct ZigBeeT *zb, struct ZbNlmeResetReqT *resetReqPtr, struct ZbNlmeResetConfT *resetConfPtr);

NLME-RESET.request

Parameters

Return

  • Undocumented

16.1.18. ZbNlmeRouteDiscReq↑

enum ZbStatusCodeT ZbNlmeRouteDiscReq(struct ZigBeeT *zb, struct ZbNlmeRouteDiscReqT *routeDiscReqPtr, void (*callback)
(struct ZbNlmeRouteDiscConfT *discConf, void *cbarg), void *arg);

NLME-ROUTE-DISCOVERY.request

Parameters

Return

  • Returns ZB_NWK_STATUS_SUCCESS on success, or other ZbStatusCodeT on failure

16.1.19. ZbNlmeSetInterface↑

void ZbNlmeSetInterface(struct ZigBeeT *zb, struct ZbNlmeSetInterfaceReqT *req, struct ZbNlmeSetInterfaceConfT *conf);

NLME-SET-INTERFACE.request

Parameters

Return

  • Undocumented

16.1.20. ZbNlmeSetReq↑

void ZbNlmeSetReq(struct ZigBeeT *zb, struct ZbNlmeSetReqT *setReqPtr, struct ZbNlmeSetConfT *setConfPtr);

NLME-SET.request

Parameters

Return

  • Undocumented

16.1.21. ZbNlmeStartRouterReq↑

void ZbNlmeStartRouterReq(struct ZigBeeT *zb, struct ZbNlmeStartRouterReqT *req, struct ZbNlmeStartRouterConfT *conf);

NLME-START-ROUTER.request Parameters

Return

  • Undocumented

16.1.22. ZbNlmeSyncReq↑

enum ZbStatusCodeT ZbNlmeSyncReq(struct ZigBeeT *zb, struct ZbNlmeSyncReqT *syncReqPtr, void (*callback)
(struct ZbNlmeSyncConfT *syncConfPtr, void *arg), void *arg);

NLME-SYNC.request

Parameters

Return

  • Returns ZB_NWK_STATUS_SUCCESS on success, or other ZbStatusCodeT on failure

16.1.23. ZbNwkAddrLookupExt↑

uint64_t ZbNwkAddrLookupExt(struct ZigBeeT *zb, uint16_t nwkAddr);

Look up extended address from network address

Parameters

Return

  • Returns extended address that corresponds to the network address if known, otherwise returns 0.

16.1.24. ZbNwkAddrLookupNwk↑

uint16_t ZbNwkAddrLookupNwk(struct ZigBeeT *zb, uint64_t extAddr);

Look up network address from extended address

Parameters

Return

  • Returns network address that corresponds to the extended address if known, otherwise returns ZB_NWK_ADDR_UNDEFINED.

16.1.25. ZbNwkAddrSetNextChildAddr↑

void ZbNwkAddrSetNextChildAddr(struct ZigBeeT *zb, uint16_t nextChildAddr);

Set network address of next child to known value rather than stochastically assigned address.

Parameters

Return

  • Undocumented

16.1.26. ZbNwkAddrStoreMap↑

bool ZbNwkAddrStoreMap(struct ZigBeeT *zb, uint16_t nwkAddr, uint64_t extAddr, bool resolve_now);

Store new address mapping

Parameters

Return

  • Returns true on success, or false otherwise

16.1.27. ZbNwkClearActiveKey↑

bool ZbNwkClearActiveKey(struct ZigBeeT *zb);

Clear the active key sequence number

Parameters

Return

  • Returns true on success, or false otherwise

16.1.28. ZbNwkCommissioningConfig↑

bool ZbNwkCommissioningConfig(struct ZigBeeT *zb, struct ZbNwkCommissioningInfo *commission_info);

Configures the MAC interface to be able to send and receive commissioning InterPAN packets. This API is provided so the stack does not need to expose the MLME-SET API. This should be called before the stack has been started (that is to say ZbStartup).

Parameters

Return

  • True if configuration was successfully applied, false otherwise.

16.1.29. ZbNwkFastPollRelease↑

bool ZbNwkFastPollRelease(struct ZigBeeT *zb, struct nwk_fastpoll_entry_t *handle);

Release a fast polling request. If this is the last fast polling request, then fast polling is stopped.

Parameters

Return

  • True if found and removed, false otherwise.

16.1.30. ZbNwkFastPollRequestWithDesc↑

struct nwk_fastpoll_entry_t * ZbNwkFastPollRequestWithDesc(struct ZigBeeT *zb, unsigned int delay, unsigned int timeout, const char *desc);

Make the stack begin (or continue) fast polling. Fast polling period is defined by ZB_NWK_NIB_ID_FastPollPeriod.

Parameters

Return

  • Fast polling entry pointer, to be used as a handle to track this polling request.

16.1.31. ZbNwkFastPollResourceCount↑

unsigned int ZbNwkFastPollResourceCount(struct ZigBeeT *zb);

Get the current number of fast polling requests to the stack.

Parameters

Return

  • Number of outstanding fast polling requests.

16.1.32. ZbNwkGet↑

enum ZbStatusCodeT ZbNwkGet(struct ZigBeeT *zb, enum ZbNwkNibAttrIdT attrId, void *attrPtr, unsigned int attrSz);

Performs an NLME-GET.request for an attribute with fixed length data, usually uint8_t, uint16_t, uint32_t, or uint64_t data types.

Parameters

Return

  • Zigbee status code (e.g. ZB_STATUS_SUCCESS or ZB_NWK_STATUS_INVALID_PARAMETER)

16.1.33. ZbNwkGetActiveKey↑

bool ZbNwkGetActiveKey(struct ZigBeeT *zb, struct ZbNwkSecMaterialT *active_key);

Searches the nwkSecurityMaterialSet NIB attribute for a valid entry with a sequence number matching the active key sequence number. If found, the key will be copied into the out buffer and out will be returned.

Parameters

Return

  • Returns true on success, or false otherwise

16.1.34. ZbNwkGetArray↑

enum ZbStatusCodeT ZbNwkGetArray(struct ZigBeeT *zb, enum ZbNwkNibAttrIdT attrId, void *attrPtr, unsigned int *attrSz);

Performs an NLME-GET.request for an attribute with variable length data.

Parameters

Return

  • Zigbee status code (for example, ZB_STATUS_SUCCESS or ZB_NWK_STATUS_INVALID_PARAMETER)

16.1.35. ZbNwkGetIndex↑

enum ZbStatusCodeT ZbNwkGetIndex(struct ZigBeeT *zb, enum ZbNwkNibAttrIdT attrId, void *attrPtr, unsigned int attrSz, unsigned int attrIndex);

Performs an NLME-GET.request for an attribute containing an array of values using an index.

Parameters

Return

  • Zigbee status code (for example, ZB_STATUS_SUCCESS or ZB_NWK_STATUS_INVALID_PARAMETER)

16.1.36. ZbNwkGetSecMaterial↑

bool ZbNwkGetSecMaterial(struct ZigBeeT *zb, uint8_t keySeqno, struct ZbNwkSecMaterialT *material);

Gets a network key for a given sequence number. Will also return the frame counter if requested. If extAddr is 0, then the outgoing frame counter will be written to frameCounterPtr. Otherwise, if extAddr is non-zero, the incoming frame counter corresponding to extAddr will be written to frameCounterPtr;

Parameters

Return

  • Returns true on success, or false otherwise

16.1.37. ZbNwkIeeeJoiningListEnabled↑

bool ZbNwkIeeeJoiningListEnabled(struct ZigBeeT *zb);

Check if join policy is set to WPAN_JOIN_POLICY_IEEELIST

Parameters

Return

  • Returns true on success, or false otherwise

16.1.38. ZbNwkIfGetTxPower↑

bool ZbNwkIfGetTxPower(struct ZigBeeT *zb, const char *name, int8_t *tx_power);

Gets the transmit power of an interface.

Parameters

Return

  • Returns true on success, or false otherwise

16.1.39. ZbNwkIfSetTxPower↑

bool ZbNwkIfSetTxPower(struct ZigBeeT *zb, const char *name, int8_t tx_power);

Sets the transmit power of an interface.

Parameters

Return

  • Returns true on success, or false otherwise

16.1.40. ZbNwkNntGetZdExtAddr↑

uint64_t ZbNwkNntGetZdExtAddr(struct ZigBeeT *zb);

Get the EUI-64 of the connected remote Zigbee Direct device, if applicable and available.

Parameters

Return

  • EUI-64 of the connected remote Zigbee Direct device, or 0 if none found.

16.1.41. ZbNwkSendEdkaReq↑

bool ZbNwkSendEdkaReq(struct ZigBeeT *zb, void (*callback)(enum ZbStatusCodeT status, void *arg), void *arg);

Called by the application to manually send the End Device Timeout Request Command.

ZB_NWK_NIB_ID_DisablePeriodicTimers must be first set to 1, to disable the automatic sending of these commands. The application may want the periodic timers to be disabled, so it has more control of when packets are being transmit from the SED, in order to have fine control of battery power usage.

Parameters

Return

  • Undocumented

16.1.42. ZbNwkSendLinkPowerDeltaNotify↑

bool ZbNwkSendLinkPowerDeltaNotify(struct ZigBeeT *zb);

Network Link power delta notify.

Parameters

Return

  • Returns true on success, or false otherwise

16.1.43. ZbNwkSendLinkPowerDeltaReq↑

bool ZbNwkSendLinkPowerDeltaReq(struct ZigBeeT *zb);

Network Link power delta request.

Parameters

Return

  • Returns true on success, or false otherwise

16.1.44. ZbNwkSet↑

enum ZbStatusCodeT ZbNwkSet(struct ZigBeeT *zb, enum ZbNwkNibAttrIdT attrId, void *attrPtr, unsigned int attrSz);

Performs an NLME-SET.request for an attribute.

Parameters

Return

  • Zigbee Status Code (for example, ZB_STATUS_SUCCESS or ZB_NWK_STATUS_INVALID_PARAMETER)

16.1.45. ZbNwkSetActiveKey↑

bool ZbNwkSetActiveKey(struct ZigBeeT *zb, struct ZbNwkSecMaterialT *active_key);

Perform an APSME-ADD-KEY.request and update the active key sequence number

Parameters

Return

  • Returns true on success, or false otherwise

16.1.46. ZbNwkSetFrameCounter↑

bool ZbNwkSetFrameCounter(struct ZigBeeT *zb, uint8_t keySeqno, uint64_t srcAddr, uint32_t newFrameCount);

Inserts or updates a frame counter in a given material set. If srcAddr is 0, or our local extended address then this call will update the outgoing frame counter. Otherwise this call will update (or create) an incoming frame counter. This function will compare the new frame counter against the existing one (if found). If the new value of the frame counter is stale then the update will be rejected and this function will return false. Otherwise, the update will always succeed (with a possible LRU eviction if the table is full). However, due to some known buggy devices, frame counter resets have been observed out in the wild. Therefore, stale frame counters will be accepted into the table subject to rate limiting and cooldown policies (controlled by the nwkFrameCounterCooldown NIB attribute).

Parameters

Return

  • Returns true on success, or false otherwise

16.1.47. ZbNwkSetIndex↑

enum ZbStatusCodeT ZbNwkSetIndex(struct ZigBeeT *zb, enum ZbNwkNibAttrIdT attrId, void *attrPtr, unsigned int attrSz, unsigned int attrIndex);

Performs an NLME-SET.request for an attribute containing an array of values using an index.

Parameters

Return

  • Zigbee status code (for example, ZB_STATUS_SUCCESS or ZB_NWK_STATUS_INVALID_PARAMETER)

16.1.48. ZbNwkToggleDutyCycle↑

bool ZbNwkToggleDutyCycle(struct ZigBeeT *zb, bool enable);

Enable or disable Duty Cycle management in the MAC. Disabling duty cycle will also clear the duty cycle history and set the status to MCP_DUTYCYCLE_STATUS_NORMAL. This function would typically be used in conjunction with ZB_NWK_NIB_ID_TxPowerMgmtSupported, which configures TX power control in the NWK and MAC.

Parameters

Return

  • Returns true on success, or false otherwise

16.1.49. ZbNwkZdGenerateBasicKey↑

bool ZbNwkZdGenerateBasicKey(struct ZigBeeT *zb, uint64_t zvd_eui, uint8_t key[ZB_SEC_KEYSIZE], uint8_t seqno);

Generate the basic key using network key with input seqnuence number and the ZVD EUI. This can used to generate basic key using old network keys as well.

Parameters

Return

  • true if basic key is generated successfully, false otherwise.

16.1.50. nwk_mac_filter_add↑

bool nwk_mac_filter_add(struct ZigBeeT *zb, uint64_t extAddr, uint16_t nwkAddr, uint8_t in_cost);

Add a new address filter. If the in_cost parameter is set to 0, then all matching frames are dropped.

Parameters

Return

  • True if the filter was added, false otherwise.

16.1.51. nwk_mac_filter_debug↑

void nwk_mac_filter_debug(struct ZigBeeT *zb);

When called, prints the address filtering table to the Zigbee debug log (level = ZB_LOG_MASK_INFO). Used for debugging only.

Parameters

Return

  • None

16.1.52. nwk_mac_filter_del↑

bool nwk_mac_filter_del(struct ZigBeeT *zb, uint64_t extAddr, uint16_t nwkAddr);

Removes an address filter matching either of the addresses provided.

Parameters

Return

  • True if the filter was removed, false otherwise.

16.2. Enumerations↑

16.2.1. ZbNwkNetworkStatusCodeT↑

NLME-NWK-STATUS.indication status codes

16.3. Structures↑

16.3.1. ZbNlmeBcnSurveyConfT↑

NLME-BEACON-SURVEY.confirm

Parameters

16.3.2. ZbNlmeBcnSurveyReqT↑

NLME-BEACON-SURVEY.request

Parameters

16.3.3. ZbNlmePanIdUpdateConfT↑

NLME-PANID-UPDATE.confirm

Parameters

16.3.4. ZbNlmePanIdUpdateReqT↑

NLME-PANID-UPDATE.request

Parameters

16.3.5. ZbNwkCommissioningInfo↑

Commissioning configuration.

Parameters

17. Security utilities

#include "zigbee.security.h"

17.1. Functions↑

17.1.1. ZbAesMmoHash↑

bool ZbAesMmoHash(uint8_t const *data, const unsigned int length, uint8_t *digest);

Performs an AES MMO hash on the selected data

Parameters

Return

  • Undocumented

17.1.2. ZbSecAddDeviceLinkKeyByInstallCode↑

enum ZbStatusCodeT ZbSecAddDeviceLinkKeyByInstallCode(struct ZigBeeT *zb, uint64_t extAddr, uint8_t *ic, unsigned int len);

ZbApsmeAddKeyReq helper function. Adds a device key-pair to the stack as a Trust Center Link Key type. This API is typically only used by a Trust Center to add link keys for devices that need to join the network. On the joiner side, the link key is set to the preconfiguredLinkKey parameter in the ZbStartupT configuration when calling ZbStartup to join the network.

Parameters

Return

  • Zigbee status code

17.1.3. ZbSecAddDeviceLinkKeyByKey↑

enum ZbStatusCodeT ZbSecAddDeviceLinkKeyByKey(struct ZigBeeT *zb, uint64_t extAddr, uint8_t *key);

ZbApsmeAddKeyReq helper function. Adds a device key-pair to the stack as a Trust Center Link Key type. This API is typically only used by a trust center to add link keys for devices that need to join the network. On the Joiner side, the link key is set to the preconfiguredLinkKey parameter in the ZbStartupT configuration when calling ZbStartup to join the network.

Parameters

Return

  • Zigbee status code

18. Startup

#include "zigbee.startup.h"

18.1. Functions↑

18.1.1. ZbStartup↑

enum ZbStatusCodeT ZbStartup(struct ZigBeeT *zb, struct ZbStartupT *configPtr, void
(*callback)(enum ZbStatusCodeT status, void *cb_arg), void *arg);

The startup code also handles callbacks from the stack to maintain the network and security processes. For example, these include the handling of APSME-UPDATE-DEVICE.indication messages when acting as a Coordinator Trust Center, to handle the authentication procedure described in section 4.6.3.2 of Zigbee R22.

The message callback handlers can be overridden by the application by creating message filters using ZbMsgFilterRegister.

This function and the entire startup code can be bypassed by the application, and the network layer APIs used directly, if so desired.

Parameters

Return

  • Zigbee status code whether the startup procedure has been started. If ZB_STATUS_SUCCESS, then the callback will be called with the final result.

18.1.2. ZbStartupConfigGetProDefaults↑

void ZbStartupConfigGetProDefaults(struct ZbStartupT *configPtr);

Get the default configuration for a PRO network.

Parameters

Return

  • None

18.1.3. ZbStartupConfigGetProSeDefaults↑

void ZbStartupConfigGetProSeDefaults(struct ZbStartupT *configPtr);

Same as ZbStartupConfigGetProDefaults, but clears the preconfigured global link keys.

Parameters

Return

  • None

18.1.4. ZbStartupDeviceInterviewComplete↑

bool ZbStartupDeviceInterviewComplete(struct ZigBeeT *zb, uint64_t joiner_eui64,
bool success);

The application calls this when it is done with the Device Interview process for a particular Joiner. The Device Interview process starts in the application when the stack calls the device_interview_cb() callback function defined in the 'struct ZbStartupT' startup configuration.

Parameters

Return

  • True if the request was processed successfully (that is to say the joiner is actively being tracked by the stack), or false otherwise.

18.1.5. ZbStartupFindBindStart↑

enum ZbStatusCodeT ZbStartupFindBindStart(struct ZigBeeT *zb, void (*callback)(enum
ZbStatusCodeT status, void *arg), void *arg);

Manually start Finding & Binding. F&B is also started automatically after joining the network.

Parameters

Return

  • Zigbee status code

18.1.6. ZbStartupFindBindStartEndpoint↑

enum ZbStatusCodeT ZbStartupFindBindStartEndpoint(struct ZigBeeT *zb, uint8_t endpoint, 
void (*callback)(enum ZbStatusCodeT status, void *arg), void *arg);

Same as ZbStartupFindBindStart, but only for a single endpoint.

Parameters

Return

  • Zigbee status code

18.1.7. ZbStartupPersist↑

enum ZbStatusCodeT ZbStartupPersist(struct ZigBeeT *zb, const void *pdata, unsigned
int plen, struct ZbStartupCbkeT *cbke_config, void (*callback)(enum ZbStatusCodeT
status, void *arg), void *arg);

Try starting stack using persistence data provided. NOTE: In case of a Zigbee virtual device (ZVD) this API only takes care of restoring the stack from persistence data and does not perform secure rejoin. So the ZVD application shall reestablish the secure session over BLE using basic or admin key and then perform the secure rejoin using ZbStartupRejoin() API.

Parameters

Return

  • Zigbee status code

18.1.8. ZbStartupRejoin↑

enum ZbStatusCodeT ZbStartupRejoin(struct ZigBeeT *zb, void (*callback)(struct
ZbNlmeJoinConfT *conf, void *arg), void *cbarg);

ZbStartupRejoin is a wrapper for ZbNlmeJoinReq(ZB_NWK_REJOIN_TYPE_NWKREJOIN). Use ZbStartupRejoin instead, because the internal startup handler will restart any timers we need to maintain our parent.

Must already be connected to a network. If not on a network and want to rejoin as way to connect, use ZbStartup with ZbStartTypeRejoin.

Parameters

Return

  • Zigbee status code
enum ZbStatusCodeT ZbStartupTclkStart(struct ZigBeeT *zb, void (*callback)(enum
ZbStatusCodeT status, void *arg), void *arg);

18.1.9. ZbStartupTclkStart↑

enum ZbStatusCodeT ZbStartupTclkStart(struct ZigBeeT *zb, void (*callback)(enum
ZbStatusCodeT status, void *arg), void *arg);

The application can call ZbStartupTclkStart if it wants to update the trust center link key post join using APS-Request Key method. This is usually done under following scenarios,

Note. In case of a Zigbee Direct (ZDD) updating a provisional link key, after it was commissioned via out-of-band commissioning mechanism. 2. To periodically generate a new APS Link Key with the Trust Center. Continual cycling of the TC Link Key is a 'Works With All Hubs (WWAHU)' security recommendation.

Parameters

Return

  • true if the tclk is completed successfuly, false otherwise.

18.1.10. ZbStartupTcsoAbort↑

bool ZbStartupTcsoAbort(struct ZigBeeT *zb);

Abort a TCSO, if it’s running. This function should not be necessary, but a Sleepy Device application may need it if it wants to go to sleep before ZbStartupTcsoStart has finished.

Parameters

Return

  • True if TCSO was aborted, false otherwise (i.e. wasn’t running).

18.1.11. ZbStartupTcsoStart↑

bool ZbStartupTcsoStart(struct ZigBeeT *zb, void (*callback)(enum ZbTcsoStatusT
status, void *arg), void *arg);

The Stack with the help of the ZCL Keep Alive cluster will automatically detect the loss of the Trust Center and start the TCSO process. Before the TCSO process starts and the 'tcso_callback' callback is provided in the startup configuration, it is called to check if the application wants to halt the TCSO process from starting or let it continue. Refer to the description for 'tcso_callback' in the startup configuration for more info.

The application can call ZbStartupTcsoStart at any time if it thinks it has lost communication with the Trust Center and to manually begin the TCSO process.

Parameters

Return

  • True if TCSO was started and to wait for callback to indicate completion. False if TCSO wasn’t started.

18.1.12. ZbStartupTouchlinkTargetStop↑

enum ZbStatusCodeT ZbStartupTouchlinkTargetStop(struct ZigBeeT *zb);

If Touchlink Target was started with ZbStartup, this API can be used to stop it.

Parameters

Return

  • Zigbee status code whether touchlink was successfully stopped or not.

18.1.13. ZbTrustCenterRejoin↑

enum ZbStatusCodeT ZbTrustCenterRejoin(struct ZigBeeT *zb, void (*callback)(enum
ZbStatusCodeT status, void *arg), void *cbarg);

Trust Center Rejoin - unsecured rejoin (already joined to network, but missed a NWK key update).

Parameters

Return

  • Zigbee status code

18.2. Enumerations↑

18.2.1. ZbStartType↑

Startup control-codes as per the ZCL Spec, Commissioning Cluster’s StartupControl attribute in the "Startup Parameters Attribute Set"

18.3. Structures↑

18.3.1. ZbStartupCbkeT↑

CBKE configuration parameters for ZbStartup. This configuration is only applicable if the 'suite_mask' is non-zero.

Parameters

18.3.2. ZbStartupT↑

The set of configuration parameters used to form or join a network using ZbStartup. Should be first initialized using ZbStartupConfigGetProDefaults or ZbStartupConfigGetProSeDefaults.

Parameters

19. TLV Utilities

#include "zigbee.tlv.h"

19.1. Description↑

This file defines all the ZigBee TLV APIs and macros.

19.2. Functions↑

19.2.1. zb_tlv_decode↑

int zb_tlv_decode(const uint8_t *buffer, unsigned int buffer_length, struct zb_tlv
*tlv_array, const unsigned int tlv_count);

Given a list of desired TLVs, examine all the TLVs as per the 'General TLV processing rules'. Update the desired TLV list with all matching TLVs found in the buffer. It is expected that the desired TLV list will have the length field populated with the 'minimum known length' for all the entries. Desired TLVs found in the buffer with length < than the 'minimum known length' are considered 'malformed TLVs'. All the unknown TLVs found in the buffer are locally stored to ensure no duplicate TLVs are present.

Parameters

Return

  • length of buffer decoded on success. ZB_TLV_STATUS_FAILURE, if any of the input parameters were invalid. ZB_TLV_STATUS_DUPLICATE_TLV, if a duplicate TLV is found. ZB_TLV_STATUS_BUFFER_TRUNCATED, if any TLV is found to be malformed.

19.2.2. zb_tlv_decode_check_mandatory↑

bool zb_tlv_decode_check_mandatory(const struct zb_tlv *tlv_array, const unsigned
int tlv_count);

Check all mandatory TLVs have non-NULL value fields.

Parameters

Return

  • true if all mandatory TLVs were found false otherwise

19.2.3. zb_tlv_encode↑

int zb_tlv_encode(uint8_t *buffer, unsigned int buffer_length, const struct zb_tlv
*tlv_array, const unsigned int tlv_count);

Given a list of TLVs, this API encodes TLV list into input buffer.

Parameters

Return

  • length encoded, negative on error

19.2.4. zb_tlv_encode_length↑

int zb_tlv_encode_length(struct zb_tlv *tlv_array, const unsigned int tlv_count);

Compute the size of buffer required, if the input TLVs were to be encoded.

Parameters

Return

  • size of buffer required to encode input TLVs.

19.2.5. zb_tlv_type_exists↑

bool zb_tlv_type_exists(uint8_t *buffer, unsigned int buffer_length, enum
zb_tlv_type type);

Check if the TLV type exists in the input buffer. This API will return failure if the TLV does not exist or is found to be truncated.

Parameters

Return

  • true if TLV exists, false otherwise

19.3. Enumerations↑

19.3.1. zb_tlv_type↑

ZigBee TLV type ID enumeration. TLV IDs have been split into local and global TLVs based on their usage. Local TLVs are specific to a single message and their tag IDs may overlap with the local TLV IDs of different messages. Range of local TLV tag IDs is 0-63. However, global TLVs have a single format across all messages and layers and are used in 2 or more different messages. Global TLV IDs represent a global state and is not completely ephemeral in nature. Range of global TLV tag IDs is 64-255.

19.4. Structures↑

19.4.1. zb_tlv↑

ZigBee TLV structure definition.

Parameters

20. ZDO Layer

#include "zigbee.zdo.h"

20.1. Description↑

This file provides the declaration of all the public APIs and macros used by the ZDO layer.

20.2. Functions↑

20.2.1. ZbZdoActiveEpReq ==↑

enum ZbStatusCodeT ZbZdoActiveEpReq(struct ZigBeeT *zb, struct ZbZdoActiveEpReqT *req, void (*callback)
(struct ZbZdoActiveEpRspT *rsp, void *cb_arg), void *arg);

Retrieve the active endpoint list for a device.

Parameters

Return

  • ZCL_STATUS_SUCCESS if successful, or other ZclStatusCodeT value on error

20.2.2. ZbZdoBcnSurveyReq↑

enum ZbStatusCodeT ZbZdoBcnSurveyReq(struct ZigBeeT *zb, struct ZbZdoBcnSurveyReqT *req, void (*callback)
(struct ZbZdoBcnSurveyRspT *rsp, void *cb_arg), void *arg); Sends ZDO Mgmt_Beacon_Survey_req command.

Parameters

Return

  • enum ZbStatusCodeT

20.2.3. ZbZdoBindReq↑

enum ZbStatusCodeT ZbZdoBindReq(struct ZigBeeT *zb, struct ZbZdoBindReqT *req, void
(*callback)(struct ZbZdoBindRspT *rsp, void *cb_arg), void *arg);

Perform a ZDO Bind operation.

Parameters

Return

  • ZCL_STATUS_SUCCESS if successful, or other ZclStatusCodeT value on error

20.2.4. ZbZdoClearAllBindingsReq↑

enum ZbStatusCodeT ZbZdoClearAllBindingsReq(struct ZigBeeT *zb, struct
ZbZdoClearAllBindingsReqT *req, void (*callback)(struct ZbZdoClearAllBindingsRspT
*rsp, void *cb_arg), void *arg);

Send a ZDO Security Clear all bindings request command.

Parameters

Return

  • ZCL_STATUS_SUCCESS if successful, or other ZclStatusCodeT value on error

20.2.5. ZbZdoDeviceAnnce↑

void ZbZdoDeviceAnnce(struct ZigBeeT *zb, struct ZbZdoDeviceAnnceT *deviceAnncePtr);

Send a Device_annce message to the network. Automatically called by the stack after joining.

Parameters

Return

  • Returns void

20.2.6. ZbZdoDeviceAnnceAlias↑

void ZbZdoDeviceAnnceAlias(struct ZigBeeT *zb, struct ZbZdoDeviceAnnceT
*deviceAnncePtr);

Send a Device_annce message to the network using aliasing.

Parameters

Return

  • Returns void

20.2.7. ZbZdoDeviceAnnceFilterRegister↑

struct ZbZdoFilterT * ZbZdoDeviceAnnceFilterRegister(struct ZigBeeT *zb, struct ZbZdoFilterT *filter, enum zb_msg_filter_rc 
(*callback)(struct ZigBeeT *zb, struct ZbZdoDeviceAnnceT *annce, uint8_t seqno, void *arg), void *arg);

Register a filter in the ZDO for the application to receive Device_Annce messages.

Parameters

Return

  • Pointer to filter structure

20.2.8. ZbZdoGetNextSeqNum↑

uint8_t ZbZdoGetNextSeqNum(struct ZigBeeT *zb);

Return and increment the next ZDO sequence number.

Parameters

Return

  • Returns ZDO sequence number.

20.2.9. ZbZdoIeeeAddrReq↑

enum ZbStatusCodeT ZbZdoIeeeAddrReq(struct ZigBeeT *zb, struct ZbZdoIeeeAddrReqT *req, void (*callback)
(struct ZbZdoIeeeAddrRspT *rsp, void *cb_arg), void *arg);

Retrive the 64-bit extended address for a device if given a short network address.

Parameters

Return

  • ZCL_STATUS_SUCCESS if successful, or other ZclStatusCodeT value on error

20.2.10. ZbZdoLeaveReq↑

enum ZbStatusCodeT ZbZdoLeaveReq(struct ZigBeeT *zb, struct ZbZdoLeaveReqT *req,
void (*callback)(struct ZbZdoLeaveRspT *rsp, void *cb_arg), void *arg);

Perform a Mgmt_leave_req command.

Parameters

Return

  • ZCL_STATUS_SUCCESS if successful, or other ZclStatusCodeT value on error

20.2.11. . ZbZdoLqiReq↑

Perform a Mgmt_Lqi_req command.

enum ZbStatusCodeT ZbZdoLqiReq(struct ZigBeeT *zb, struct ZbZdoLqiReqT *req, void
(*callback)(struct ZbZdoLqiRspT *rsp, void *cb_arg), void *arg);

Parameters

Return

  • ZCL_STATUS_SUCCESS if successful, or other ZclStatusCodeT value on error

20.2.12. ZbZdoMatchDescMulti↑

enum ZbStatusCodeT ZbZdoMatchDescMulti(struct ZigBeeT *zb, struct
ZbZdoMatchDescReqT *req, void (*callback)(struct ZbZdoMatchDescRspT *rsp, void
*cb_arg), void *arg);

Send a ZDO Match-Desc request and receive multiple responses. The responses, if any, are received by the callback. Each callback contains the result of a callback from a single device. The callback will be called each time a response is received. After a timeout period, the callback is called with a status of ZB_ZDP_STATUS_TIMEOUT to indicate the internal response filter is removed and any additional responses for this request are not processed.

Parameters

Return

  • ZB_ZDP_STATUS_SUCCESS for received responses, ZB_ZDP_STATUS_TABLE_FULL if there’s a problem starting the request, ZB_ZDP_STATUS_TIMEOUT when the stack decides to stop receiving responses, or other ZclStatusCodeT value on error

20.2.13. ZbZdoMatchDescReq↑

enum ZbStatusCodeT ZbZdoMatchDescReq(struct ZigBeeT *zb, struct ZbZdoMatchDescReqT *req, void (*callback)
(struct ZbZdoMatchDescRspT *rsp, void *cb_arg), void *arg);

Retrieve the mach descriptor for a device.

Parameters

Return

  • ZCL_STATUS_SUCCESS if successful, or other ZclStatusCodeT value on error

20.2.14. ZbZdoMgmtBindReq↑

enum ZbStatusCodeT ZbZdoMgmtBindReq(struct ZigBeeT *zb, struct ZbZdoMgmtBindReqT *req, void (*callback)
(struct ZbZdoMgmtBindRspT *rsp, void *cb_arg), void *arg); Perform a Mgmt_Bind_req command.

Parameters

Return

  • ZCL_STATUS_SUCCESS if successful, or other ZclStatusCodeT value on error

20.2.15. ZbZdoNodeDescReq↑

enum ZbStatusCodeT ZbZdoNodeDescReq(struct ZigBeeT *zb, struct ZbZdoNodeDescReqT *req, void (*callback)
(struct ZbZdoNodeDescRspT *rsp, void *cb_arg), void *arg);

Retrieve the node descriptor for a device.

Parameters

Return

  • ZCL_STATUS_SUCCESS if successful, or other ZclStatusCodeT value on error

20.2.16. ZbZdoNwkAddrReq↑

enum ZbStatusCodeT ZbZdoNwkAddrReq(struct ZigBeeT *zb, struct ZbZdoNwkAddrReqT *req, void (*callback)
(struct ZbZdoNwkAddrRspT *rsp, void *cb_arg), void *arg);

Retrieve the 16-bit short address for a device if given an extended address.

Parameters

Return

  • ZCL_STATUS_SUCCESS if successful, or other ZclStatusCodeT value on error

20.2.17. ZbZdoNwkEnhUpdateNotifyFilterRegister↑

struct ZbZdoFilterT * ZbZdoNwkEnhUpdateNotifyFilterRegister(struct ZigBeeT *zb, struct ZbZdoFilterT *filter, 
enum zb_msg_filter_rc (*callback)(struct ZigBeeT *zb, struct ZbZdoNwkUpdateNotifyT *msg, uint8_t seqno, void *arg), void *arg);

Register a filter in the ZDO for the application to receive Mgmt_Nwk_Enhanced_Update_notify messages.

Parameters

Return

  • Pointer to filter structure

20.2.18. ZbZdoNwkEnhUpdateReq↑

enum ZbStatusCodeT ZbZdoNwkEnhUpdateReq(struct ZigBeeT *zb, struct ZbZdoNwkEnhUpdateReqT *req, void (*callback)

(struct ZbZdoNwkUpdateNotifyT *reqPtr, void *cb_arg), void *arg); Perform a Mgmt_Nwk_Enhanced_Update_req command.

Parameters

Return

  • ZCL_STATUS_SUCCESS if successful, or other ZclStatusCodeT value on error

20.2.19. ZbZdoNwkIeeeJoinListBcastAll↑

unsigned int ZbZdoNwkIeeeJoinListBcastAll(struct ZigBeeT *zb);

Send an IEEE-Joining-List.response broadcast message for all entries in the IEEE Join List. Used primarily by GB868 applications.

Parameters

Return

  • Returns number of entries sent

20.2.20. ZbZdoNwkIeeeJoinListReq↑

enum ZbStatusCodeT ZbZdoNwkIeeeJoinListReq(struct ZigBeeT *zb, struct ZbZdoNwkIeeeJoinListReqT *req, 
void (*callback)(struct ZbZdoNwkIeeeJoinListRspT *rsp, void *cb_arg), void *arg);

Send an IEEE-Joining-List request.

Parameters

Return

  • ZCL_STATUS_SUCCESS if successful, or other ZclStatusCodeT value on error

20.2.21. ZbZdoNwkIeeeJoinListRsp↑

unsigned int ZbZdoNwkIeeeJoinListRsp(struct ZigBeeT *zb, uint16_t dstNwkAddr, uint8_t startIndex, 
uint8_t seqnum, bool fromRequest);

Send an IEEE-Joining-List.response. Used primarily by GB868 applications.

Parameters

Return

  • Number of entries sent in response

20.2.22. ZbZdoNwkUpdateNotify↑

enum ZbStatusCodeT ZbZdoNwkUpdateNotify(struct ZigBeeT *zb, struct
ZbZdoNwkUpdateNotifyT *reqPtr);

Send an unsolicited Mgmt_Nwk_Update_notify command to the network manager. Does not wait for any response.

Parameters

Return

  • ZCL_STATUS_SUCCESS if successful, or other ZclStatusCodeT value on error

20.2.23. ZbZdoNwkUpdateNotifyFilterRegister↑

struct ZbZdoFilterT * ZbZdoNwkUpdateNotifyFilterRegister(struct ZigBeeT *zb, struct ZbZdoFilterT *filter, 
enum zb_msg_filter_rc (*callback)(struct ZigBeeT *zb, struct ZbZdoNwkUpdateNotifyT *msg, uint8_t seqno, void *arg), void *arg);

Register a filter in the ZDO for the application to receive Mgmt_Nwk_Update_notify messages.

Parameters

Return

  • Pointer to filter structure

20.2.24. ZbZdoNwkUpdateReq↑

enum ZbStatusCodeT ZbZdoNwkUpdateReq(struct ZigBeeT *zb, struct ZbZdoNwkUpdateReqT
*req, void (*callback)(struct ZbZdoNwkUpdateNotifyT *reqPtr, void *cb_arg), void *arg);

Perform a Mgmt_Nwk_update_req command.

Parameters

Return

  • ZCL_STATUS_SUCCESS if successful, or other ZclStatusCodeT value on error

20.2.25. ZbZdoPermitJoinReq↑

enum ZbStatusCodeT ZbZdoPermitJoinReq(struct ZigBeeT *zb, struct ZbZdoPermitJoinReqT *req, 
void (*callback)(struct ZbZdoPermitJoinRspT *rsp, void *cb_arg), void *arg);

Sends a ZDO Mgmt_permit_join_req command.

With R23 and above, there are new fields added to the ZDO Mgmt_permit_join_req command e.g, 'Frame Control' & 'Global Beacon Appendix'

In case of centralized security networks only TC can send this command with TLV_UPDATE bit set to 1 in frame control field. And if a non-TC device invokes this API with TLV_UPDATE bit set, it will be treated as an invalid request.

Parameters

Return

  • ZCL_STATUS_SUCCESS if successful, or other ZclStatusCodeT value on error

20.2.26. ZbZdoPowerDescReq↑

enum ZbStatusCodeT ZbZdoPowerDescReq(struct ZigBeeT *zb, struct ZbZdoPowerDescReqT *req, void (*callback)
(struct ZbZdoPowerDescRspT *rsp, void *cb_arg), void *arg);

Retrieve the power descriptor for a device.

Parameters

Return

  • ZCL_STATUS_SUCCESS if successful, or other ZclStatusCodeT value on error

20.2.27. ZbZdoRtgReq↑

enum ZbStatusCodeT ZbZdoRtgReq(struct ZigBeeT *zb, struct ZbZdoRtgReqT *req, void
(*callback)(struct ZbZdoRtgRspT *rsp, void *cb_arg), void *arg);

Perform a Mgmt_Rtg_req command.

Parameters

Return

  • ZCL_STATUS_SUCCESS if successful, or other ZclStatusCodeT value on error

20.2.28. ZbZdoSecChallengeReq↑

enum ZbStatusCodeT ZbZdoSecChallengeReq(struct ZigBeeT *zb, struct ZbZdoSecChallengeReqT *req,
void (*callback)(struct ZbZdoSecChallengeRspT *rsp, void *cb_arg), void *arg);

Sends ZDO Security_Challenge_req command.

Parameters

Return

  • enum ZbStatusCodeT

20.2.29. ZbZdoSecDecommissionReq↑

enum ZbStatusCodeT ZbZdoSecDecommissionReq(struct ZigBeeT *zb, struct ZbZdoSecDecommissionReqT *req, void (*callback)
(struct ZbZdoSecDecommissionRspT *rsp, void *cb_arg), void *arg);

Sends ZDO Security_Decommission_req command.

Parameters

Return

  • enum ZbStatusCodeT

20.2.30. ZbZdoSecGetAuthLevelReq↑

enum ZbStatusCodeT ZbZdoSecGetAuthLevelReq(struct ZigBeeT *zb, struct ZbZdoSecGetAuthLevelReqT *req, 
void (*callback)(struct ZbZdoSecGetAuthLevelRspT *rsp, void *cb_arg), void *arg);

Send a ZDO Security get authentication level request command.

Parameters

Return

  • ZCL_STATUS_SUCCESS if successful, or other ZclStatusCodeT value on error

20.2.31. ZbZdoSecGetConfigReq↑

enum ZbStatusCodeT ZbZdoSecGetConfigReq(struct ZigBeeT *zb, struct ZbZdoSecGetConfigReqT *req, 
void (*callback)(struct ZbZdoSecGetConfigRspT *rsp, void *cb_arg), void *arg);

Sends ZDO Security get configuration request command.

Parameters

Return

  • enum ZbStatusCodeT

20.2.32. ZbZdoSecKeyUpdateReq↑

enum ZbStatusCodeT ZbZdoSecKeyUpdateReq(struct ZigBeeT *zb, struct ZbZdoSecKeyUpdateReqT *req, 
void (*callback)(struct ZbZdoSecKeyUpdateRspT *rsp, void *cb_arg), void *arg);

Send a ZDO Security Key Update Request.

Parameters

Return

  • ZCL_STATUS_SUCCESS if successful, or other ZclStatusCodeT value on error

20.2.33. ZbZdoSecSetConfigReq↑

enum ZbStatusCodeT ZbZdoSecSetConfigReq(struct ZigBeeT *zb, struct ZbZdoSecSetConfigReqT *req,
void (*callback)(struct ZbZdoSecSetConfigRspT *rsp, void *cb_arg), void *arg);

Send a ZDO Security set configuration request command.

Parameters

Return

  • ZCL_STATUS_SUCCESS if successful, or other ZclStatusCodeT value on error

20.2.34. ZbZdoSimpleDescReq↑

enum ZbStatusCodeT ZbZdoSimpleDescReq(struct ZigBeeT *zb, struct ZbZdoSimpleDescReqT *req, void (*callback)
(struct ZbZdoSimpleDescRspT *rsp, void *cb_arg), void *arg);

Retrieve the simple descriptor for a device.

Parameters

Return

  • ZCL_STATUS_SUCCESS if successful, or other ZclStatusCodeT value on error

20.2.35. ZbZdoUnbindReq↑

enum ZbStatusCodeT ZbZdoUnbindReq(struct ZigBeeT *zb, struct ZbZdoBindReqT *req,
void (*callback)(struct ZbZdoBindRspT *rsp, void *cb_arg), void *arg);

Perform a ZDP Unbind Bind operation.

Return

  • ZCL_STATUS_SUCCESS if successful, or other ZclStatusCodeT value on error

20.3. Enumerations↑

20.3.1. ZbZdoAddrReqTypeT↑

NWK_addr_req / IEEE_addr_req definitions

20.4. Structures↑

20.4.1. ZbNodeDescriptorT↑

ZigBee Node Descriptor

Parameters

20.4.2. ZbPowerDescriptorT↑

ZigBee power descriptor

Parameters

20.4.3. ZbSimpleDescriptorT↑

ZigBee simple (application) descriptor.

Parameters

20.4.4. ZbZdoActiveEpReqT↑

Active_EP_req

20.4.5. ZbZdoActiveEpRspT↑

Active_EP_rsp

Parameters

20.4.6. ZbZdoBcnSurveyReqT↑

Mgmt_Beacon_Survey_Req.

Parameters

20.4.7. ZbZdoBcnSurveyRspT↑

Mgmt_Beacon_Survey_Rsp.

Parameters

20.4.8. ZbZdoBindReqT↑

Bind_req

Parameters

20.4.9. ZbZdoBindRspT↑

Bind_rsp

Parameters

20.4.10. ZbZdoBindingDescT↑

Binding descriptor

20.4.11. ZbZdoClearAllBindingsReqT↑

Clear_All_Bindings_req

Parameters

20.4.12. ZbZdoDeviceAnnceT↑

Device_annce (ZB_ZDO_DEVICE_ANNCE)

Parameters

20.4.13. ZbZdoIeeeAddrReqT↑

IEEE_addr_req

Parameters

20.4.14. ZbZdoLeaveReqT↑

Mgmt_Nwk_Leave_req

Parameters

20.4.15. ZbZdoLeaveRspT↑

Mgmt_Nwk_Leave_rsp

Parameters

20.4.16. ZbZdoLqiReqT↑

Mgmt_Lqi_req

Parameters

20.4.17. ZbZdoLqiRspT↑

Mgmt_Lqi_rsp

Parameters

20.4.18. ZbZdoMatchDescReqT↑

Match_Desc_req

Parameters

20.4.19. ZbZdoMatchDescRspT↑

Match_Desc_rsp

Parameters

20.4.20. ZbZdoMgmtBindReqT↑

Mgmt_Bind_req

Parameters

20.4.21. ZbZdoMgmtBindRspT↑

Mgmt_Bind_rsp

Parameters

20.4.22. ZbZdoNeighborDescT↑

Neighbor Descriptor

Parameters

20.4.23. ZbZdoNetworkDescT↑

Network descriptor

Parameters

20.4.24. ZbZdoNodeDescReqT↑

Node_Desc_req

Parameters

20.4.25. ZbZdoNodeDescRspT↑

Node_Desc_rsp

Parameters

20.4.26. ZbZdoNwkAddrReqT↑

NWK_addr_req

Parameters

20.4.27. ZbZdoNwkAddrRspT↑

NWK_addr_rsp

Parameters

20.4.28. ZbZdoNwkEnhUpdateReqT↑

Mgmt_Nwk_Enhanced_Update_req

Parameters

20.4.29. ZbZdoNwkIeeeJoinListReqT↑

Mgmt_Nwk_Ieee_Joining_List_req

Parameters

20.4.30. ZbZdoNwkIeeeJoinListRspT↑

Mgmt_Nwk_Ieee_Joining_List_rsp

Parameters

20.4.31. ZbZdoNwkUpdateNotifyT↑

Mgmt_Nwk_Update_notify

Parameters

20.4.32. ZbZdoNwkUpdateReqT↑

Mgmt_Nwk_Update_req

Parameters

20.4.33. ZbZdoPermitJoinReqT↑

ZDO Mgmt_Permit_Join_req

Parameters

20.4.34. ZbZdoPermitJoinRspT↑

ZDO Mgmt_Permit_Join_rsp

Parameters

20.4.35. ZbZdoPowerDescReqT↑

Power_Desc_req

Parameters

20.4.36. ZbZdoPowerDescRspT↑

Power_Desc_rsp

Parameters

20.4.37. ZbZdoRoutingDescT↑

Routing descriptor

Parameters

20.4.38. ZbZdoRtgReqT↑

Mgmt_Rtg_req

Parameters

20.4.39. ZbZdoRtgRspT↑

Mgmt_Rtg_rsp

Parameters

20.4.40. ZbZdoSecGetConfigReqT↑

Security_Get_Configuration_Req.

Parameters

20.4.41. ZbZdoSecGetConfigRspT↑

Security_Get_Configuration_Rsp.

Parameters

20.4.42. ZbZdoSecKeyUpdateReqT↑

Security_Key_Update_Req.

Parameters

20.4.43. ZbZdoSimpleDescReqT↑

Simple_Desc_req

Parameters

20.4.44. ZbZdoSimpleDescRspT↑

Simple_Desc_rsp

Parameters

21. Zigbee ZCL Core

#include "zcl/zcl.h"

21.1. Functions↑

21.1.1. ZbZclAppendHeader↑

int ZbZclAppendHeader(struct ZbZclHeaderT *zclHdrPtr, uint8_t *data, unsigned int max_len);

Builds and appends a ZCL Header to the end of a buffer. Returns length of data written, or negative value (-1) on error.

Parameters

None Return

  • Undocumented

21.1.2. ZbZclAttrEuiRead↑

uint64_t ZbZclAttrEuiRead(struct ZbZclClusterT *cluster, uint16_t attributeId, enum ZclStatusCodeT *statusPtr);

Helper to ZbZclAttrRead to read an EUI-64 attribute value.

Parameters

Return

  • The EUI-64 value

21.1.3. ZbZclAttrEuiWrite↑

enum ZclStatusCodeT ZbZclAttrEuiWrite(struct ZbZclClusterT *cluster, uint16_t attributeId, uint64_t eui);

Helper to ZbZclAttrWrite to write an EUI-64 attribute value.

Parameters

Return

  • ZCL Status Code

21.1.4. ZbZclAttrIntegerIncrement↑

enum ZclStatusCodeT ZbZclAttrIntegerIncrement(struct ZbZclClusterT *cluster,
uint16_t attributeId, long long value);

Helper to ZbZclAttrWrite to read, increment and write an integer attribute value.

Parameters

Return

  • ZCL status code

21.1.5. ZbZclAttrIntegerRead↑

long long ZbZclAttrIntegerRead(struct ZbZclClusterT *cluster, uint16_t attributeId,
enum ZclDataTypeT *typePtr, enum ZclStatusCodeT *statusPtr);

Helper to ZbZclAttrRead to read an integer attribute value.

Parameters

Return

  • Value of attribute

21.1.6. ZbZclAttrIntegerWrite↑

enum ZclStatusCodeT ZbZclAttrIntegerWrite(struct ZbZclClusterT *cluster, uint16_t attributeId, long long value);

Helper to ZbZclAttrWrite to write an integer attribute value.

Parameters

Return

  • ZCL status code

21.1.7. ZbZclAttrRead↑

enum ZclStatusCodeT ZbZclAttrRead(struct ZbZclClusterT *cluster, uint16_t attrId,
enum ZclDataTypeT *attrType, void *outputBuf, unsigned int max_len, bool isReporting);

Reads a local cluster attribute value. Returns the attribute type if provided as a pointer through 'attrType'.

Parameters

Return

  • ZCL status code

21.1.8. ZbZclAttrReportConfigDefault↑

enum ZclStatusCodeT ZbZclAttrReportConfigDefault(struct ZbZclClusterT *clusterPtr, uint16_t attrId, 
uint16_t default_min, uint16_t default_max, double *default_change);

Configure an attribute’s default reporting intervals. It will also set the active reporting intervals to these values and reset the reporting timer. The Reportable Change value will also be reset back to defaults (value = 1).

Parameters

Return

  • ZCL status code

21.1.9. ZbZclAttrReportConfigReq↑

enum ZclStatusCodeT ZbZclAttrReportConfigReq(struct ZbZclClusterT *cluster, struct ZbZclAttrReportConfigT *config,
void (*callback)(struct ZbZclCommandRspT *cmd_rsp, void *arg), void *arg);

Send a Configure Reporting Command. Response is returned in the 'callback' if provided by application.

Parameters

Return

  • ZCL status code

21.1.10. ZbZclAttrReportReadReq↑

enum ZclStatusCodeT ZbZclAttrReportReadReq(struct ZbZclClusterT *cluster, struct ZbZclAttrReportReadT *report,
void (*callback)(struct ZbZclCommandRspT *cmd_rsp, void *arg), void *arg);

Send a Read Reporting Configuration Command. Response is returned in the 'callback' if provided by application.

Parameters

Return

  • ZCL status code

21.1.11. ZbZclAttrStringWriteLong↑

enum ZclStatusCodeT ZbZclAttrStringWriteLong(struct ZbZclClusterT *cluster, uint16_t attributeId, const uint8_t *zcl_str);

Helper to ZbZclAttrWrite to write a string attribute value of type ZCL_DATATYPE_STRING_LONG_OCTET or ZCL_DATATYPE_STRING_LONG_CHARACTER.

Parameters

Return

  • ZCL status code

21.1.12. ZbZclAttrStringWriteShort↑

enum ZclStatusCodeT ZbZclAttrStringWriteShort(struct ZbZclClusterT *cluster, uint16_t attributeId, const uint8_t *zcl_str);

Helper to ZbZclAttrWrite to write a string attribute value of type ZCL_DATATYPE_STRING_OCTET or ZCL_DATATYPE_STRING_CHARACTER.

Parameters

Return

  • ZCL status code

21.1.13. ZbZclAttrWrite↑

enum ZclStatusCodeT ZbZclAttrWrite(struct ZbZclClusterT *cluster, const struct ZbApsAddrT *src, uint16_t attr_id, 
const uint8_t *attr_data, unsigned int max_len, ZclWriteModeT mode);

Writes a local cluster’s attribute value.

Parameters

Return

  • ZCL status code

21.1.14. ZbZclClusterCommandReqWithRspFilter↑

enum ZclStatusCodeT ZbZclClusterCommandReqWithRspFilter(struct ZbZclClusterT *cluster, struct ZbZclClusterCommandReqT *req, 
uint8_t rspCmd, unsigned int delay, void (*callback)(struct ZbZclCommandRspT *zcl_rsp, void *arg), void *arg);

ZbZclClusterCommandReq is a helper wrapper to ZbZclCommandReq. Information from the cluster is used when sending the command (source addressing, APS TX Options).

Parameters

Return

  • ZCL Status Code. If ZCL_STATUS_SUCCESS, the caller can expect the callback once the command is complete. If something other than ZCL_STATUS_SUCCESS, that indicates an error and the callback is never called in that case.

21.1.15. ZbZclClusterRegisterAlarmResetHandler↑

enum ZclStatusCodeT ZbZclClusterRegisterAlarmResetHandler(struct ZbZclClusterT *cluster, enum ZclStatusCodeT (*callback)
(struct ZbZclClusterT *cluster, uint8_t alarm_code, uint16_t cluster_id, struct ZbApsdeDataIndT *data_ind,
struct ZbZclHeaderT *hdr));

Register a callback handler for the given cluster to receive Alarm "Reset Alarm" and "Reset all alarms" commands.

Parameters

Return

  • ZCL status code

21.1.16. ZbZclClusterReportConfirmCallbackAttach↑

void ZbZclClusterReportConfirmCallbackAttach(struct ZbZclClusterT *cluster, void
(*callback)(struct ZbZclClusterT *cluster));

Attach a confirm callback function to be called on sending ZCL Attribute Report Commands.

Parameters

Return

  • None

21.1.17. ZbZclClusterReportsSend↑

enum ZclStatusCodeT ZbZclClusterReportsSend(struct ZbZclClusterT *cluster, bool send_all, void (*callback)
(struct ZbZclClusterT *cluster, unsigned int next_timeout, void *arg), void *arg);

If the application disables the automatic attribute reporting mechanism in the stack by setting the NIB 'ZB_NWK_NIB_ID_DisablePeriodicTimers' to 1, then the application will need to manually and periodically send reports by calling this function.

Parameters

Return

  • ZCL Status Code. If not ZCL_STATUS_SUCCESS, then callback will not be called.

21.1.18. ZbZclClusterReverseBind↑

struct ZbApsFilterT * ZbZclClusterReverseBind(struct ZbZclClusterT *cluster);

ZbZclClusterReverseBind is used by the Alarms Server so it can receive loopback messages sent in the direction of the client (i.e. reverse).

Parameters

Return

  • Filter pointer (handle)

21.1.19. ZbZclClusterReverseUnbind↑

void ZbZclClusterReverseUnbind(struct ZbZclClusterT *cluster, struct ZbApsFilterT *filter);

Remove the reverse (loopback) filter and free it.

Parameters

Return

  • None

21.1.20. ZbZclClusterSendAlarm↑

void ZbZclClusterSendAlarm(struct ZbZclClusterT *cluster, uint8_t src_endpoint, uint8_t alarm_code);

Send an alarm from a cluster as if it originated from the alarms cluster on the same endpoint. Typically, src_endpoint = cluster¬endpoint. If the cluster appears on multiple endpoints (e.g. Basic Cluster), the src_endpoint is required to know which one to actually send the Alarm Command from. The alarm message is sent via APS binding(s).

Parameters

Return

  • None

21.1.21. ZbZclCommandReqWithRspFilter↑

enum ZclStatusCodeT ZbZclCommandReqWithRspFilter(struct ZigBeeT *zb, struct ZbZclCommandReqT *zclReq, 
uint8_t rspCmd, void (*callback)(struct ZbZclCommandRspT *rsp, void *arg), void *arg);

Send a ZCL command. The callback function is called when the associated ZCL response is received, or there’s an error.

Parameters

Return

  • ZCL Status Code. ZCL_STATUS_SUCCESS if command was sent and caller can wait for the callback to be called. Otherwise, there was a problem sending the command and the callback is never called in this case.

21.1.22. ZbZclIsDefaultRsp↑

bool ZbZclIsDefaultRsp(struct ZbZclHeaderT *hdr);

This is a helper function that inspects a ZCL header struct and returns true if it’s for a ZCL Default Response command, or false otherwise.

Parameters

Return

  • True if ZCL header indicates it’s for a ZCL Default Response command, or false otherwise.

21.1.23. ZbZclParseHeader↑

int ZbZclParseHeader(struct ZbZclHeaderT *zclHdrPtr, const uint8_t *buf, unsigned int len);

Parses a ZCL Header from a received frame. Returns Length of the ZCL header, or negative value (-1) on error.

Parameters

None Return

  • Undocumented

21.1.24. ZbZclParseInteger↑

long long ZbZclParseInteger(enum ZclDataTypeT dataType, const uint8_t *data, enum ZclStatusCodeT *statusPtr);

Parses a integer number from a buffer starting at the given pointer and returns it as a long long integer. Note that the length of the buffer isn’t checked. The caller is assumed to have sanity-checked the buffer length already by a call to ZbZclAttrParseLength or ZbZclAttrTypeLength

Parameters

Return

  • The parsed value, if *statusPtr == SUCCESS

21.1.25. ZbZclPrependHeader↑

int ZbZclPrependHeader(struct ZbZclHeaderT *zclHdrPtr, uint8_t *data, unsigned int len);

Builds and appends a ZCL Header to the start of a buffer. Returns length of data written, or negative value (-1) on error.

Parameters

None Return

  • Undocumented

21.1.26. zcl_get_bomd_req_queue_timeout_abs↑

ZbUptimeT zcl_get_bomd_req_queue_timeout_abs(struct ZigBeeT *zb);

Helper function to return the timeout value, based on the BDB parameter 'ZB_BDB_ZclBomdReqQueueTimeoutMs'

Parameters

Return

  • ZbZclUptime() plus the ZB_BDB_ZclBomdReqQueueTimeoutMs value.

21.1.27. zcl_get_bomd_req_wait_timeout_ms↑

uint32_t zcl_get_bomd_req_wait_timeout_ms(struct ZigBeeT *zb);

Helper function to return value from BDB parameter 'ZB_BDB_ZclBomdReqWaitTimeoutMs'

Parameters

Return

  • Timeout value in milliseconds

21.1.28. zcl_hexstr_to_bin↑

int zcl_hexstr_to_bin(const char *str, uint8_t *out, unsigned int maxlen);

This is a helper function to convert an ascii string of hexidecimal characters to an array of binary octets. The input string can have upper or lower case hex characters, and must not contain any delimiters. Since this is a helper function, it may change or be removed in the future.

Parameters

Return

  • Number of bytes written to 'out' or -1 on error.

21.2. Enumerations↑

21.2.1. ZbZclAttrCbTypeT↑

Attribute Callback Types

21.3. Structures↑

21.3.1. ZbZclAttrCbInfoT↑

Attribute callback information

Parameters

21.3.2. ZbZclAttrT↑

The structure used to initialize a ZCL attribute when calling ZbZclAttrAppendList.

Parameters

22. Touchlink

#include "zcl/zcl.touchlink.h"

22.1. Functions↑

22.1.1. ZbZclTouchlinkInitiatorGetEpListReq↑

enum ZclStatusCodeT ZbZclTouchlinkInitiatorGetEpListReq(struct ZigBeeT *zb, struct ZbTlGetEpListReqCmd *cmd, const struct ZbApsAddrT *dst,
void (*callback)(struct ZbTlGetEpListRspCmd *rsp, void *arg), void *arg);

Sends a Touchlink Utility Get Endpoint List Request Command

Parameters

Return

  • ZCL_STATUS_SUCCESS if successful, or other ZclStatusCodeT value on error

22.1.2. ZbZclTouchlinkInitiatorGetGrpIdReq↑

enum ZclStatusCodeT ZbZclTouchlinkInitiatorGetGrpIdReq(struct ZigBeeT *zb, struct ZbTlGetGroupIdsReqCmd *cmd, const struct ZbApsAddrT *dst,
void (*callback)(struct ZbTlGetGroupIdsRspCmd *rsp, void *arg), void *arg);

Sends a Touchlink Utility Get Group Identifiers Request Command

Parameters

Return

  • ZCL_STATUS_SUCCESS if successful, or other ZclStatusCodeT value on error

22.1.3. ZbZclTouchlinkTargetSendEpInfoCmd↑

enum ZclStatusCodeT ZbZclTouchlinkTargetSendEpInfoCmd(struct ZigBeeT *zb, uint8_t endpoint, const struct ZbApsAddrT *dst,
void (*callback)(struct ZbZclCommandRspT *zcl_rsp, void *arg), void *arg);

Sends a Touchlink Utility Endpoint Information Command

Parameters

Return

  • ZCL_STATUS_SUCCESS if successful, or other ZclStatusCodeT value on error

22.2. Structures↑

22.2.1. ZbTlEndpointList↑

Endpoint Information Record entry

Parameters

22.2.2. ZbTlEpInfoCmd↑

Endpoint Information command

Parameters

22.2.3. ZbTlGetEpListReqCmd↑

Get Endpoint List Request command

Parameters

22.2.4. ZbTlGetEpListRspCmd↑

Get Endpoint List Response command

Parameters

22.2.5. ZbTlGetGroupIdsReqCmd↑

Get Group Identifiers Request command

Parameters

22.2.6. ZbTlGetGroupIdsRspCmd↑

Get Group Identifiers Response command

Parameters

22.2.7. ZbTlGroupRecordList↑

Group Information Record list

Parameters

22.2.8. ZbTouchlinkCallbacks↑

Zigbee Touchlink callback functions for Touchlink Controller Device Utility commands. These are configured by "struct ZbStartupT" with ZbStartup().

Parameters

23. Key Exchange (CBKE)

#include "zcl/key/zcl.key.h"

23.1. Description↑

The Certificate-based Key Establishment (CBKE) cluster is handled internally by the stack. When CBKE is enabled, the stack creates an instance of the CBKE cluster. There is no exposed public API to the CBKE cluster itself. CBKE is configured in the security.cbke (struct ZbStartupCbkeT) section of the ZbStartupT startup config. The basic setup procedure is to enable the supported suites in suite_mask and load the corresponding suite configuration and certificates for the enabled suites into the startup config before starting the stack.

CBKE configuration struct for ZbStartup. This is only applicable if the 'suite_mask' is non-zero.

ZbStartupCbkeT

24. Appendix A: Zigbee status codes

24.1. NWK status codes↑

Status Value Status Code
0x00 ZB_NWK_STATUS_SUCCESS
0xc1 ZB_NWK_STATUS_INVALID_PARAMETER
0xc2 ZB_NWK_STATUS_INVALID_REQUEST
0xc3 ZB_NWK_STATUS_NOT_PERMITTED
0xc4 ZB_NWK_STATUS_STARTUP_FAILURE
0xc5 ZB_NWK_STATUS_ALREADY_PRESENT
0xc6 ZB_NWK_STATUS_SYNC_FAILURE
0xc7 ZB_NWK_STATUS_TABLE_FULL
0xc8 ZB_NWK_STATUS_UNKNOWN_DEVICE
0xc9 ZB_NWK_STATUS_UNSUPPORTED_ATTRIBUTE
0xca ZB_NWK_STATUS_NO_NETWORKS
0xcb ZB_NWK_STATUS_LEAVE_UNCONFIRMED
0xcc ZB_NWK_STATUS_MAX_FRM_CNTR
0xcd ZB_NWK_STATUS_NO_KEY
0xce ZB_NWK_STATUS_BAD_CCM_OUTPUT
0xcf ZB_NWK_STATUS_NO_ROUTING_CAPACITY
0xd0 ZB_NWK_STATUS_ROUTE_DISCOVERY_FAILED
0xd1 ZB_NWK_STATUS_ROUTE_ERROR
0xd2 ZB_NWK_STATUS_BT_TABLE_FULL
0xd3 ZB_NWK_STATUS_FRAME_NOT_BUFFERED
0xd4 ZB_NWK_STATUS_INVALID_INDEX
0xd5 ZB_NWK_STATUS_INTERNAL_ERR


24.1.1. WPAN Status Codes↑

Status Value Status Code
0x00 ZB_WPAN_STATUS_SUCCESS
0xdb ZB_WPAN_STATUS_COUNTER_ERROR
0xdc ZB_WPAN_STATUS_IMPROPER_KEY_TYPE
0xdd ZB_WPAN_STATUS_IMPROPER_SECURITY_LEVEL
0xde ZB_WPAN_STATUS_UNSUPPORTED_LEGACY
0xdf ZB_WPAN_STATUS_UNSUPPORTED_SECURITY
0xe0 ZB_WPAN_STATUS_BEACON_LOSS
0xe1 ZB_WPAN_STATUS_CHANNEL_ACCESS_FAILURE
0xe2 ZB_WPAN_STATUS_DENIED
0xe3 ZB_WPAN_STATUS_DISABLE_TRX_FAILURE
0xe4 ZB_WPAN_STATUS_SECURITY_ERROR
0xe5 ZB_WPAN_STATUS_FRAME_TOO_LONG
0xe6 ZB_WPAN_STATUS_INVALID_GTS
0xe7 ZB_WPAN_STATUS_INVALID_HANDLE
0xe8 ZB_WPAN_STATUS_INVALID_PARAMETER
0xe9 ZB_WPAN_STATUS_NO_ACK
0xea ZB_WPAN_STATUS_NO_BEACON
0xeb ZB_WPAN_STATUS_NO_DATA
0xec ZB_WPAN_STATUS_NO_SHORT_ADDRESS
0xed ZB_WPAN_STATUS_OUT_OF_CAP
0xee ZB_WPAN_STATUS_PAN_ID_CONFLICT
0xef ZB_WPAN_STATUS_REALIGNMENT
0xf0 ZB_WPAN_STATUS_TRANSACTION_EXPIRED
0xf1 ZB_WPAN_STATUS_TRANSACTION_OVERFLOW
0xf2 ZB_WPAN_STATUS_TX_ACTIVE
0xf3 ZB_WPAN_STATUS_UNAVAILABLE_KEY
0xf4 ZB_WPAN_STATUS_UNSUPPORTED_ATTRIBUTE
0xf5 ZB_WPAN_STATUS_INVALID_ADDRESS
0xf6 ZB_WPAN_STATUS_ON_TIME_TOO_LONG
0xf7 ZB_WPAN_STATUS_PAST_TIME
0xf8 ZB_WPAN_STATUS_TRACKING_OFF
0xf9 ZB_WPAN_STATUS_INVALID_INDEX
0xfa ZB_WPAN_STATUS_LIMIT_REACHED
0xfb ZB_WPAN_STATUS_READ_ONLY
0xfc ZB_WPAN_STATUS_SCAN_IN_PROGRESS
0xfd ZB_WPAN_STATUS_SUPERFRAME_OVERLAP
0xfe ZB_WPAN_STATUS_DRIVER_ERROR
0xff ZB_WPAN_STATUS_DEVICE_ERROR

24.1.2. ZCL status codes↑

Status Value Status Code
0z00 ZCL_STATUS_SUCCESS
0x01 ZCL_STATUS_FAILURE
0x70 ZCL_STATUS_ALLOC_FAIL
0x7e ZCL_STATUS_NOT_AUTHORIZED
0x80 ZCL_STATUS_MALFORMED_COMMAND
0x81 ZCL_STATUS_UNSUPP_CLUSTER_COMMAND
0x82 ZCL_STATUS_UNSUPP_GENERAL_COMMAND
0x83 ZCL_STATUS_UNSUPP_MFR_CLUSTER_COMMAND
0x84 ZCL_STATUS_UNSUPP_MFR_GENERAL_COMMAND
0x85 ZCL_STATUS_INVALID_FIELD
0x86 ZCL_STATUS_UNSUPP_ATTRIBUTE
0x87 ZCL_STATUS_INVALID_VALUE
0x88 ZCL_STATUS_READ_ONLY
0x89 ZCL_STATUS_INSUFFICIENT_SPACE
0x8a ZCL_STATUS_DUPLICATE_EXISTS
0x8b ZCL_STATUS_NOT_FOUND
0x8c ZCL_STATUS_UNREPORTABLE_ATTRIBUTE
0x8d ZCL_STATUS_INVALID_DATA_TYPE
0x8e ZCL_STATUS_INVALID_SELECTOR
0x8f ZCL_STATUS_WRITE_ONLY
0x90 ZCL_STATUS_INCONSISTENT_STARTUP_STATE
0x91 ZCL_STATUS_DEFINED_OUT_OF_BAND
0x92 ZCL_STATUS_INCONSISTENT
0x93 ZCL_STATUS_ACTION_DENIED
0x94 ZCL_STATUS_TIMEOUT
0x95 ZCL_STATUS_ABORT
0x96 ZCL_STATUS_INVALID_IMAGE
0x97 ZCL_STATUS_WAIT_FOR_DATA
0x98 ZCL_STATUS_NO_IMAGE_AVAILABLE
0x99 ZCL_STATUS_REQUIRE_MORE_IMAGE
0x9A ZCL_STATUS_NOTIFICATION_PENDING
0xc0 ZCL_STATUS_HARDWARE_FAILURE
0xc1 ZCL_STATUS_SOFTWARE_FAILURE
0xc2 ZCL_STATUS_CALIBRATION_ERROR
0xc3 ZCL_STATUS_UNSUPP_CLUSTER
0xc4 ZCL_STATUS_LIMIT_REACHED


24.1.3. Trust Center Swap Out status codes↑

Status Value Status Code
0x00 ZB_TCSO_STATUS_SUCCESS
0x01 ZB_TCSO_STATUS_DISCOVERY_UNDERWAY
0x02 ZB_TCSO_STATUS_REJOIN_PREV
0x03 ZB_TCSO_STATUS_NOT_FOUND
0x04 ZB_TCSO_STATUS_FATAL


24.1.4. Key Establishment status codes↑

Status Value Status Code
0x00 ZCL_KEY_STATUS_SUCCESS
0x01 ZCL_KEY_STATUS_UNKNOWN_ISSUER
0x02 ZCL_KEY_STATUS_BAD_KEY_CONFIRM
0x03 ZCL_KEY_STATUS_BAD_MESSAGE
0x04 ZCL_KEY_STATUS_NO_RESOURCES
0x05 ZCL_KEY_STATUS_UNSUPPORTED_SUITE
0x06 ZCL_KEY_STATUS_INVALID_CERTIFICATE
0x07 ZCL_KEY_STATUS_TIMEOUT
0x08 ZCL_KEY_STATUS_MATCH_DESC_FAILED


25. References