Digi XBee(R) ANSI C Host Library
Files | Data Structures | Macros | Typedefs | Functions
Zigbee Data Object/Zigbee Device Profile

Files

file  zdo.h
 ZigBee Device Objects (ZDO) and ZigBee Device Profile (ZDP).
 
file  zigbee_zdo.c
 ZigBee Device Objects (ZDO) and ZigBee Device Profile (ZDP).
 

Data Structures

struct  zdo_nwk_addr_req_t
 frame format for ZDO NKW_addr request More...
 
struct  zdo_nwk_addr_rsp_header_t
 
struct  zdo_ieee_addr_req_t
 frame format for ZDO IEEE_addr request More...
 
struct  zdo_node_desc_req_t
 frame format for ZDO Node_Desc request More...
 
struct  zdo_node_desc_t
 frame format for ZDO Node_Desc response More...
 
struct  zdo_node_desc_resp_t
 < see ZDO_STATUS_* macros More...
 
struct  zdo_power_desc_req_t
 frame format for ZDO Power_Desc request More...
 
struct  zdo_power_desc_t
 format for ZDO PowerDescriptor More...
 
struct  zdo_power_desc_rsp_t
 frame format for ZDO Power_Desc response More...
 
struct  zdo_simple_desc_req_t
 frame format for ZDO Simple_Desc request More...
 
struct  zdo_simple_desc_resp_header_t
 header for ZDO Simple_Desc response, followed by a SimpleDescriptor More...
 
struct  zdo_simple_desc_header_t
 header for ZDO SimpleDescriptor (part of a Simple_Desc response), followed by uint8_t input cluster count, multiple uint16_t input cluster IDs, uint8_t output cluster count, multiple uint16_t output cluster IDs More...
 
struct  zdo_active_ep_req_t
 frame format for ZDO Active_EP request More...
 
struct  zdo_active_ep_rsp_header_t
 header for ZDO Active_EP response, followed by .ep_count uint8_t endpoints More...
 
struct  zdo_match_desc_req_t
 header for ZDO Match_Desc request More...
 
struct  zdo_match_desc_out_clust_t
 Second half of Match_Desc request. More...
 
struct  zdo_match_desc_rsp_header_t
 header for ZDO Match_Desc response, followed by .match_length uint8_t endpoints More...
 
struct  zdo_complex_desc_req_t
 frame format for ZDO Complex_Desc request More...
 
struct  zdo_user_desc_req_t
 frame format for ZDO Complex_Desc request More...
 
struct  zdo_device_annce_t
 frame format for a ZDO Device_annce announcement More...
 
struct  zdo_bind_req_header_t
 
struct  zdo_bind_group_req_t
 frame format for a ZDO Bind Request with a group address as the destination (header.dst_addr_mode == ZDO_BIND_DST_MODE_GROUP) More...
 
struct  zdo_bind_address_req_t
 frame format for a ZDO Bind Request with an IEEE address and endpoint as the destination (header.dst_addr_mode == ZDO_BIND_DST_MODE_ADDR) More...
 
union  zdo_bind_req_t
 
struct  zdo_mgmt_leave_req_t
 frame format for a ZDO Management Leave Request More...
 
struct  zdo_mgmt_leave_rsp_t
 

Macros

#define ZDO_CONVERSATION_TIMEOUT   15
 number of seconds to wait for ZDO responses before timing out
 
#define ZDO_ENDPOINT(state)
 Macro for ZDO endpoint table entry. More...
 
#define ZDO_CLUST_RESPONSE_MASK   0x8000
 Cluster IDs with the high bit set are responses.
 
#define ZDO_CLUST_IS_RESPONSE(c)   (c & ZDO_CLUST_RESPONSE_MASK)
 
#define ZDO_NWK_ADDR_REQ   0x0000
 cluster ID for ZDO NWK_addr request
 
#define ZDO_NWK_ADDR_RSP   0x8000
 cluster ID for ZDO NWK_addr response
 
#define ZDO_NET_ADDR_PENDING   0xFFFE
 
#define ZDO_NET_ADDR_TIMEOUT   0xFFFF
 
#define ZDO_NET_ADDR_ERROR   0xFFFD
 
#define ZDO_IEEE_ADDR_REQ   0x0001
 cluster ID for ZDO IEEE_addr request
 
#define ZDO_IEEE_ADDR_RSP   0x8001
 cluster ID for ZDO IEEE_addr response
 
#define ZDO_IEEE_ADDR_PENDING   WPAN_IEEE_ADDR_UNDEFINED
 
#define ZDO_IEEE_ADDR_TIMEOUT   WPAN_IEEE_ADDR_BROADCAST
 
#define ZDO_IEEE_ADDR_ERROR   WPAN_IEEE_ADDR_ALL_ZEROS
 
#define ZDO_NODE_DESC_REQ   0x0002
 cluster ID for ZDO Node_Desc request
 
#define ZDO_NODE_DESC_RSP   0x8002
 cluster ID for ZDO Node_Desc response
 
#define ZDO_NODE_DESC_FLAGS0_TYPE_MASK   0x07
 
#define ZDO_NODE_DESC_FLAGS0_TYPE_COORD   0x00
 
#define ZDO_NODE_DESC_FLAGS0_TYPE_ROUTER   0x01
 
#define ZDO_NODE_DESC_FLAGS0_TYPE_ENDDEV   0x02
 
#define ZDO_NODE_DESC_FLAGS0_COMPLEX_DESC_AVAIL   0x08
 
#define ZDO_NODE_DESC_FLAGS0_USER_DESC_AVAIL   0x10
 
#define ZDO_NODE_DESC_FLAGS0_RESERVED   0xE0
 
#define ZDO_NODE_DESC_FLAGS1_APS_FIELD   0x07
 
#define ZDO_NODE_DESC_FLAGS1_FREQUENCY_MASK   0xF8
 
#define ZDO_NODE_DESC_FLAGS1_FREQ_868   (1<<0)
 
#define ZDO_NODE_DESC_FLAGS1_FREQ_RESERVED_1   (1<<1)
 
#define ZDO_NODE_DESC_FLAGS1_FREQ_900   (1<<2)
 
#define ZDO_NODE_DESC_FLAGS1_FREQ_2400   (1<<3)
 
#define ZDO_NODE_DESC_FLAGS1_FREQ_RESERVED_4   (1<<4)
 
#define ZDO_POWER_DESC_REQ   0x0003
 cluster ID for ZDO Power_Desc request
 
#define ZDO_POWER_DESC_RSP   0x8003
 cluster ID for ZDO Power_Desc response
 
#define ZDO_SIMPLE_DESC_REQ   0x0004
 cluster ID for ZDO Simple_Desc request
 
#define ZDO_SIMPLE_DESC_RSP   0x8004
 cluster ID for ZDO Simple_Desc response
 
#define ZDO_ACTIVE_EP_REQ   0x0005
 cluster ID for ZDO Active_EP request
 
#define ZDO_ACTIVE_EP_RSP   0x8005
 cluster ID for ZDO Active_EP response
 
#define ZDO_MATCH_DESC_REQ   0x0006
 cluster ID for ZDO Match_Desc request
 
#define ZDO_MATCH_DESC_RSP   0x8006
 cluster ID for ZDO Match_Desc response
 
#define ZDO_COMPLEX_DESC_REQ   0x0007
 cluster ID for ZDO Complex_Desc request
 
#define ZDO_COMPLEX_DESC_RSP   0x8007
 cluster ID for ZDO Complex_Desc response
 
#define ZDO_USER_DESC_REQ   0x0011
 cluster ID for ZDO User_Desc request
 
#define ZDO_USER_DESC_RSP   0x8011
 cluster ID for ZDO User_Desc response
 
#define ZDO_DEVICE_ANNCE   0x0013
 cluster ID for ZDO Device_annce announcement
 
#define ZDO_DEVICE_ANNCE_CLUSTER(handler, context)
 Entry for Device Annce handler in cluster table of ZDO endpoint. More...
 
#define ZDO_BIND_REQ   0x0021
 cluster ID for ZDO Bind request
 
#define ZDO_BIND_RSP   0x8021
 cluster ID for ZDO Bind response
 
#define ZDO_UNBIND_REQ   0x0022
 cluster ID for ZDO Unbind request
 
#define ZDO_UNBIND_RSP   0x8022
 cluster ID for ZDO Unbind response
 
#define ZDO_BIND_DST_MODE_GROUP   0x01
 zdo_bind_req_t contains 16-bit group address
 
#define ZDO_BIND_DST_MODE_ADDR   0x03
 zdo_bind_req_t contains 64-bit destination address and endpoint
 
#define ZDO_MGMT_LEAVE_REQ   0x0034
 cluster ID for ZDO Management Leave Request
 
#define ZDO_MGMT_LEAVE_RSP   0x8034
 cluster ID for ZDO Management Leave Response
 
#define ZDO_MGMT_LEAVE_REQ_ENCRYPTED   0x0100
 extra sending option for zdo_mgmt_leave_req
 
#define zigbee_zdo_debug
 
#define ZDO_MAX_ENDPOINTS   20
 

Typedefs

typedef zdo_nwk_addr_rsp_header_t zdo_ieee_addr_rsp_header_t
 

Functions

wpan_ep_state_t FARzdo_endpoint_state (wpan_dev_t *dev)
 Returns the ZDO endpoint's state if a device has a ZDO endpoint. More...
 
int zdo_handler (const wpan_envelope_t FAR *envelope, wpan_ep_state_t FAR *ep_state)
 Process ZDO frames (received on endpoint 0 with Profile ID 0). More...
 
int zdo_send_response (const wpan_envelope_t FAR *request, const void FAR *response, uint16_t length)
 Send a response to a ZDO request. More...
 
int zdo_match_desc_request (void *buffer, int16_t buflen, uint16_t addr_of_interest, uint16_t profile_id, const uint16_t *inClust, const uint16_t *outClust)
 Generate a Match_Desc (Match Descriptor) request (ZigBee spec 2.4.3.1.7) to send on the network. More...
 
int zdo_send_nwk_addr_req (wpan_dev_t *dev, const addr64 FAR *ieee_be, uint16_t FAR *net)
 Given a device's IEEE (64-bit) address, get its 16-bit network address by unicasting a ZDO NWK_addr request to it. More...
 
int zdo_send_ieee_addr_req (wpan_dev_t *dev, uint16_t net_addr, addr64 FAR *ieee_be)
 Given a device's 16-bit network address, get its IEEE (64-bit) address by unicasting a ZDO IEEE_addr request to it. More...
 
int zdo_simple_desc_request (wpan_envelope_t *envelope, uint16_t addr_of_interest, uint_fast8_t endpoint, wpan_response_fn callback, const void FAR *context)
 Send a ZDO Simple Descriptor Request. More...
 
int zdo_send_bind_req (wpan_envelope_t *envelope, uint16_t type, wpan_response_fn callback, void FAR *context)
 Send a ZDO Bind (or Unbind) Request to the destination address in the envelope. More...
 
int zdo_mgmt_leave_req (wpan_dev_t *dev, const addr64 *address, uint16_t flags)
 Send a ZDO Management Leave Request. More...
 
int zdo_send_descriptor_req (wpan_envelope_t *envelope, uint16_t cluster, uint16_t addr_of_interest, wpan_response_fn callback, const void FAR *context)
 Send a ZDO Node, Power, Complex or User Descriptor request, or an Active Endpoint request. More...
 
const wpan_endpoint_table_entry_t_zdo_endpoint_of (wpan_dev_t *dev)
 Return the endpoint table entry for the ZDO endpoint. More...
 
const addr64_zdo_envelope_create (wpan_envelope_t *envelope, wpan_dev_t *dev, const addr64 *address)
 helper function for creating ZDO request envelopes More...
 
int _match_desc_cluster_list (uint8_t **buffer, const uint16_t *clust_read, int max_count)
 
int _zdo_match_desc_respond (const wpan_envelope_t FAR *envelope)
 Respond to a Match Descriptor (Match_Desc) request (ZigBee spec 2.4.3.1.7). More...
 
int _zdo_simple_desc_respond (const wpan_envelope_t FAR *envelope)
 Respond to a Simple Descriptor (Simple_Desc) request (ZigBee spec 2.4.3.1.5). More...
 
int _simple_desc_cluster_list (uint8_t **buffer, int max_count, uint8_t mask, const wpan_cluster_table_entry_t *entry)
 
int _zdo_active_ep_respond (const wpan_envelope_t FAR *envelope)
 Respond to an Active Endpoint (Active_EP) request (ZigBee spec 2.4.3.1.6). More...
 
int _zdo_process_nwk_addr_resp (wpan_conversation_t FAR *conversation, const wpan_envelope_t FAR *envelope)
 Callback function to process NWK_addr response frames. More...
 
int _zdo_process_ieee_addr_resp (wpan_conversation_t FAR *conversation, const wpan_envelope_t FAR *envelope)
 Callback function to process IEEE_addr response frames. More...
 

values for .request_type in NWK and IEEE address requests

#define ZDO_REQUEST_TYPE_SINGLE   0x00
 
#define ZDO_REQUEST_TYPE_EXTENDED   0x01
 

ZDO Mac Capability Flags

#define ZDO_CAPABILITY_ALTERNATE_PAN   0x01
 
#define ZDO_CAPABILITY_FULL_FUNCTION   0x02
 
#define ZDO_CAPABILITY_MAINS_POWER   0x04
 
#define ZDO_CAPABILITY_RX_ON_IDLE   0x08
 
#define ZDO_CAPABILITY_RESERVED_1   0x10
 
#define ZDO_CAPABILITY_RESERVED_2   0x20
 
#define ZDO_CAPABILITY_SECURITY   0x40
 
#define ZDO_CAPABILITY_ALLOCATE_ADDR   0x80
 

ZDO Status Values

#define ZDO_STATUS_SUCCESS   0x00
 
#define ZDO_STATUS_INV_REQUESTTYPE   0x80
 
#define ZDO_STATUS_DEVICE_NOT_FOUND   0x81
 
#define ZDO_STATUS_INVALID_EP   0x82
 
#define ZDO_STATUS_NOT_ACTIVE   0x83
 
#define ZDO_STATUS_NOT_SUPPORTED   0x84
 
#define ZDO_STATUS_TIMEOUT   0x85
 
#define ZDO_STATUS_NO_MATCH   0x86
 
#define ZDO_STATUS_NO_ENTRY   0x88
 
#define ZDO_STATUS_NO_DESCRIPTOR   0x89
 
#define ZDO_STATUS_INSUFFICIENT_SPACE   0x8A
 
#define ZDO_STATUS_NOT_PERMITTED   0x8B
 
#define ZDO_STATUS_TABLE_FULL   0x8C
 
#define ZDO_STATUS_NOT_AUTHORIZED   0x8D
 

ZDO Node Descriptor - MAC Capability Flags

#define ZDO_NODE_DESC_MAC_CAPABILITY_ALT_PAN_COORD   (1<<0)
 
#define ZDO_NODE_DESC_MAC_CAPABILITY_DEVICE_TYPE   (1<<1)
 
#define ZDO_NODE_DESC_MAC_CAPABILITY_POWER_SOURCE   (1<<2)
 
#define ZDO_NODE_DESC_MAC_CAPABILITY_RX_ON_IDLE   (1<<3)
 
#define ZDO_NODE_DESC_MAC_CAPABILITY_RESERVED_4   (1<<4)
 
#define ZDO_NODE_DESC_MAC_CAPABILITY_RESERVED_5   (1<<5)
 
#define ZDO_NODE_DESC_MAC_CAPABILITY_SECURITY   (1<<6)
 
#define ZDO_NODE_DESC_MAC_CAPABILITY_ALLOCATE_ADDR   (1<<7)
 

ZDO Node Descriptor - Server Mask Bit Assignments

#define ZDO_NODE_DESC_SERVER_MASK_PRIMARY_TRUST   (1<<0)
 
#define ZDO_NODE_DESC_SERVER_MASK_BACKUP_TRUST   (1<<1)
 
#define ZDO_NODE_DESC_SERVER_MASK_PRIMARY_BINDING   (1<<2)
 
#define ZDO_NODE_DESC_SERVER_MASK_BACKUP_BINDING   (1<<3)
 
#define ZDO_NODE_DESC_SERVER_MASK_PRIMARY_DISCOVERY   (1<<4)
 
#define ZDO_NODE_DESC_SERVER_MASK_BACKUP_DISCOVERY   (1<<5)
 
#define ZDO_NODE_DESC_SERVER_MASK_NETWORK_MANAGER   (1<<6)
 

PowerDescriptor macros

macros used in PowerDescriptor (zdo_power_desc_t)

#define ZDO_POWER_SOURCE_MAINS   0x01
 
#define ZDO_POWER_SOURCE_RECHARGABLE   0x02
 
#define ZDO_POWER_SOURCE_DISPOSABLE   0x04
 
#define ZDO_POWER_SOURCE_RESERVED   0x08
 
#define ZDO_POWER0_SYNC   0x00
 
#define ZDO_POWER0_PERIODIC   0x01
 
#define ZDO_POWER0_STIMULATED   0x02
 
#define ZDO_POWER0_AVAIL_MAINS   (ZDO_POWER_SOURCE_MAINS << 4)
 
#define ZDO_POWER0_AVAIL_RECHARGABLE   (ZDO_POWER_SOURCE_RECHARGABLE << 4)
 
#define ZDO_POWER0_AVAIL_DISPOSABLE   (ZDO_POWER_SOURCE_DISPOSABLE << 4)
 
#define ZDO_POWER0_AVAIL_RESERVED   (ZDO_POWER_SOURCE_RESERVED << 4)
 
#define ZDO_POWER1_LEVEL_CRITICAL   0x00
 
#define ZDO_POWER1_LEVEL_33   0x40
 
#define ZDO_POWER1_LEVEL_66   0x80
 
#define ZDO_POWER1_LEVEL_FULL   0xC0
 
#define ZDO_POWER1_CURRENT_MAINS   ZDO_POWER_SOURCE_MAINS
 
#define ZDO_POWER1_CURRENT_RECHARGABLE   ZDO_POWER_SOURCE_RECHARGABLE
 
#define ZDO_POWER1_CURRENT_DISPOSABLE   ZDO_POWER_SOURCE_DISPOSABLE
 
#define ZDO_POWER1_CURRENT_RESERVED   ZDO_POWER_SOURCE_RESERVED
 

Detailed Description

Macro Definition Documentation

#define ZDO_DEVICE_ANNCE_CLUSTER (   handler,
  context 
)
Value:
{ ZDO_DEVICE_ANNCE, handler, context, \
#define WPAN_CLUST_FLAG_OUTPUT
output/client cluster (typically receives responses)
Definition: aps.h:230
#define WPAN_CLUST_FLAG_NOT_ZCL
this cluster is NOT using the ZigBee Cluster Library (ZCL)
Definition: aps.h:248
#define ZDO_DEVICE_ANNCE
cluster ID for ZDO Device_annce announcement
Definition: zdo.h:548

Entry for Device Annce handler in cluster table of ZDO endpoint.

#define ZDO_ENDPOINT (   state)
Value:
&state, 0x0000, 0x00, NULL }
int zdo_handler(const wpan_envelope_t FAR *envelope, wpan_ep_state_t FAR *ep_state)
Process ZDO frames (received on endpoint 0 with Profile ID 0).
Definition: zigbee_zdo.c:731
#define WPAN_ENDPOINT_ZDO
ZigBee Device Object/Profile.
Definition: aps.h:113
#define WPAN_PROFILE_ZDO
ZigBee Device Object (aka ZigBee Device Profile)
Definition: aps.h:81

Macro for ZDO endpoint table entry.

state is the name of a wpan_ep_state_t global used to track the ZDO endpoint's state. Can't just have the state declared in zigbee_zdo.c since a device with multiple XBee modules, will need multiple ZDO wpan_ep_state_t globals.

Function Documentation

int _match_desc_cluster_list ( uint8_t **  buffer,
const uint16_t clust_read,
int  max_count 
)

Writes to *buffer, an 8-bit cluster count followed by the 16-bit cluster IDs in little-endian byte order.

Parameters
[in,out]bufferlocation to store cluster list, updated to point to first byte after bytes written
[in]clust_readlist of 16-bit cluster IDs, terminated by WPAN_CLUSTER_END_OF_LIST
[in]max_countmaximum number of clusters to write to *buffer
Return values
-ENOSPCcan't fit list of clusters into buffer
>=0number of clusters written to buffer

References ENOSPC, htole16, and WPAN_CLUSTER_END_OF_LIST.

Referenced by zdo_match_desc_request().

int _simple_desc_cluster_list ( uint8_t **  buffer,
int  max_count,
uint8_t  mask,
const wpan_cluster_table_entry_t entry 
)

Writes to *buffer, an 8-bit cluster count followed by the 16-bit IDs for entries in a cluster table matching a given mask.

Parameters
[in,out]bufferlocation to store cluster list, updated to point to first byte after bytes written
[in]max_countmaximum number of clusters to write to *buffer
[in]maskmask used to restrict entries
[in]entrylist of clusters, terminated by an entry with and ID of WPAN_CLUSTER_END_OF_LIST
Return values
-ENOSPCcan't fit list of clusters into buffer
>=0number of clusters written to buffer

References wpan_cluster_table_entry_t::cluster_id, ENOSPC, wpan_cluster_table_entry_t::flags, htole16, and WPAN_CLUSTER_END_OF_LIST.

Referenced by _zdo_simple_desc_respond().

int _zdo_active_ep_respond ( const wpan_envelope_t FAR envelope)

Respond to an Active Endpoint (Active_EP) request (ZigBee spec 2.4.3.1.6).

This ZDO request is used to get a list of active endoints on a device.

Parameters
[in]envelopeenvelope of request
Return values
0successfully sent response
-ENODATAdon't know network address of envelope->dev
!0error parsing request or sending response

References EINVAL, wpan_endpoint_table_entry_t::endpoint, ENODATA, FAR, hex_dump(), HEX_DUMP_FLAG_TAB, htole16, wpan_endpoint_get_next(), WPAN_ENDPOINT_ZDO, WPAN_NET_ADDR_UNDEFINED, and zdo_send_response().

Referenced by _zdo_simple_desc_respond(), and zdo_handler().

const wpan_endpoint_table_entry_t * _zdo_endpoint_of ( wpan_dev_t dev)

Return the endpoint table entry for the ZDO endpoint.

Parameters
[in]devsearch the endpoint table of this device
Return values
NULLcouldn't find the ZDO endpoint for dev
!NULLpointer to the ZDO endpoint of dev

References wpan_endpoint_match(), WPAN_ENDPOINT_ZDO, and WPAN_PROFILE_ZDO.

Referenced by zdo_endpoint_state(), and zdo_mgmt_leave_req().

const addr64 * _zdo_envelope_create ( wpan_envelope_t envelope,
wpan_dev_t dev,
const addr64 address 
)

helper function for creating ZDO request envelopes

Parameters
[out]envelopeenvelope to populate
[in]devdevice that will send this envelope
[in]addresssend request to the given target, or NULL for a self-addressed request
Returns
either address or a pointer to an all-zero IEEE address
Note
return value may change to something more useful in a future release

References wpan_dev_t::address, wpan_envelope_t::dest_endpoint, wpan_envelope_t::profile_id, wpan_envelope_t::source_endpoint, WPAN_ENDPOINT_ZDO, wpan_envelope_create(), WPAN_IEEE_ADDR_ALL_ZEROS, WPAN_NET_ADDR_UNDEFINED, and WPAN_PROFILE_ZDO.

Referenced by zdo_endpoint_state(), zdo_mgmt_leave_req(), zdo_send_bind_req(), and zdo_send_nwk_addr_req().

int _zdo_match_desc_respond ( const wpan_envelope_t FAR envelope)

Respond to a Match Descriptor (Match_Desc) request (ZigBee spec 2.4.3.1.7).

This ZDO request is used to find endpoints using a particular Profile ID and a cluster from a list of input and output clusters.

Parameters
[in]envelopeenvelope of request
Return values
0successfully sent response, or none of the endpoints matched the request
-ENODATAdon't know network address of envelope->dev
!0error parsing request or sending response

References wpan_endpoint_table_entry_t::cluster_table, EINVAL, wpan_endpoint_table_entry_t::endpoint, ENODATA, FAR, hex_dump(), HEX_DUMP_FLAG_TAB, htole16, le16toh, wpan_endpoint_table_entry_t::profile_id, WPAN_CLUST_FLAG_INPUT, WPAN_CLUST_FLAG_OUTPUT, wpan_cluster_match(), wpan_endpoint_get_next(), WPAN_ENDPOINT_ZDO, WPAN_NET_ADDR_UNDEFINED, and zdo_send_response().

Referenced by zdo_handler(), and zdo_match_desc_request().

int _zdo_process_ieee_addr_resp ( wpan_conversation_t FAR conversation,
const wpan_envelope_t FAR envelope 
)

Callback function to process IEEE_addr response frames.

The context field of the conversation is the location to store the 64-bit address returned in the response.

See also
zdo_send_ieee_addr_req()

References addr64_format(), ADDR64_STRING_LENGTH, FAR, memcpy_letobe, PRIsFAR, and WPAN_CONVERSATION_END.

Referenced by zdo_send_ieee_addr_req().

int _zdo_process_nwk_addr_resp ( wpan_conversation_t FAR conversation,
const wpan_envelope_t FAR envelope 
)

Callback function to process NWK_addr response frames.

The context field of the conversation is the location to store the 16-bit address returned in the response.

See also
zdo_send_nwk_addr_req()

References FAR, le16toh, and WPAN_CONVERSATION_END.

Referenced by zdo_send_nwk_addr_req().

int _zdo_simple_desc_respond ( const wpan_envelope_t FAR envelope)

Respond to a Simple Descriptor (Simple_Desc) request (ZigBee spec 2.4.3.1.5).

This ZDO request is used to get information about a single endpoint.

Parameters
[in]envelopeenvelope of request
Return values
0successfully sent response
-ENODATAdon't know network address of envelope->dev
!0error parsing request or sending response

number of clusters that fit in cluster list, minus 2 count bytes

References _simple_desc_cluster_list(), _zdo_active_ep_respond(), wpan_endpoint_table_entry_t::cluster_table, wpan_endpoint_table_entry_t::device_id, wpan_endpoint_table_entry_t::device_version, EINVAL, ENODATA, FAR, htole16, wpan_endpoint_table_entry_t::profile_id, WPAN_CLUST_FLAG_INPUT, WPAN_CLUST_FLAG_OUTPUT, wpan_endpoint_match(), WPAN_NET_ADDR_UNDEFINED, and zdo_send_response().

Referenced by zdo_handler(), and zdo_simple_desc_request().

wpan_ep_state_t FAR * zdo_endpoint_state ( wpan_dev_t dev)

Returns the ZDO endpoint's state if a device has a ZDO endpoint.

Parameters
[in]devdevice to query
Return values
NULLdev does not have a ZDO endpoint
!NULLaddress of wpan_ep_state variable used for state tracking

References _zdo_endpoint_of(), _zdo_envelope_create(), and wpan_endpoint_table_entry_t::ep_state.

Referenced by zdo_send_bind_req(), zdo_send_descriptor_req(), zdo_send_ieee_addr_req(), zdo_send_match_desc(), zdo_send_nwk_addr_req(), and zdo_simple_desc_request().

int zdo_handler ( const wpan_envelope_t FAR envelope,
wpan_ep_state_t FAR ep_state 
)

Process ZDO frames (received on endpoint 0 with Profile ID 0).

Parameters
[in]envelopeenvelope of received ZDO frame, contains address, endpoint, profile, and cluster info
[in]ep_statepointer to endpoint's state structure (used for tracking transactions)
Return values
0successfully processed
!0error trying to process frame

References _zdo_active_ep_respond(), _zdo_match_desc_respond(), _zdo_simple_desc_respond(), addr64_format(), ADDR64_STRING_LENGTH, EINVAL, FAR, hex_dump(), HEX_DUMP_FLAG_TAB, le16toh, memcpy_letobe, PRIsFAR, PRIx16, wpan_conversation_response(), WPAN_ENVELOPE_BROADCAST_ADDR, ZDO_ACTIVE_EP_REQ, ZDO_DEVICE_ANNCE, ZDO_MATCH_DESC_REQ, zdo_send_response(), and ZDO_SIMPLE_DESC_REQ.

int zdo_match_desc_request ( void *  buffer,
int16_t  buflen,
uint16_t  addr_of_interest,
uint16_t  profile_id,
const uint16_t inClust,
const uint16_t outClust 
)

Generate a Match_Desc (Match Descriptor) request (ZigBee spec 2.4.3.1.7) to send on the network.

Note that the first byte of buffer is NOT set, and that the caller should set it to the next sequence number/transaction ID.

Parameters
[out]bufferBuffer to hold generated request.
[in]buflenSize of buffer used to hold generated request.
[in]addr_of_interestSee ZDO documentation for NWKAddrOfInterest.
[in]profile_idProfile ID to match, must be an actual profile ID (cannot be WPAN_APS_PROFILE_ANY).
[in]inClustList of input clusters, ending with WPAN_CLUSTER_END_OF_LIST. Can use NULL if there aren't any input clusters.
[in]outClustList of output clusters, ending with WPAN_CLUSTER_END_OF_LIST. Can use NULL if there aren't any output clusters.
Return values
-ENOSPCbuffer isn't large enough to hold request; need 7 bytes plus (2 * the number of clusters)
>0number of bytes written to buffer

References _match_desc_cluster_list(), _zdo_match_desc_respond(), EINVAL, ENOSPC, FAR, and htole16.

Referenced by zdo_send_match_desc().

int zdo_mgmt_leave_req ( wpan_dev_t dev,
const addr64 address,
uint16_t  flags 
)

Send a ZDO Management Leave Request.

Parameters
[in]devdevice to send request on
[in]addressaddress to send request to, or NULL for self-addressed
[in]flagsone or more of the following flags:
  • ZDO_MGMT_LEAVE_REQ_FLAG_NONE
  • ZDO_MGMT_LEAVE_REQ_FLAG_REMOVE_CHILDREN - set the Remove Children flag in the ZDO request
  • ZDO_MGMT_LEAVE_REQ_FLAG_REJOIN - set the Rejoin flag in the ZDO request
  • ZDO_MGMT_LEAVE_REQ_ENCRYPTED - send the request with APS encryption
Return values
0successfully sent request
-EINVALbad parameter passed to function
!0error sending request

References _zdo_endpoint_of(), _zdo_envelope_create(), wpan_envelope_t::cluster_id, EINVAL, wpan_envelope_t::length, wpan_envelope_t::payload, WPAN_CLUST_FLAG_ENCRYPT, wpan_endpoint_next_trans(), wpan_envelope_send(), ZDO_MGMT_LEAVE_REQ, and ZDO_MGMT_LEAVE_REQ_ENCRYPTED.

int zdo_send_bind_req ( wpan_envelope_t envelope,
uint16_t  type,
wpan_response_fn  callback,
void FAR context 
)

Send a ZDO Bind (or Unbind) Request to the destination address in the envelope.

Binds .dest_endpoint on .ieee_address to .source_endpoint on .dev using .cluster_id.

Ignores the .options, .payload, and .length members of the envelope.

Parameters
[in]envelopeaddressing information used for the Bind Request
[in]typeZDO_BIND_REQ for a Bind Request or ZDO_UNBIND_REQ for an Unbind Request; all other values are invalid
[in]callbackcallback to receive Bind/Unbind (or Default) Response; NULL if you don't care about the response
[in]contextcontext passed to callback
Return values
0successfully sent request
-EINVALbad parameter passed to function
!0error sending request

References _zdo_envelope_create(), wpan_dev_t::address, wpan_envelope_t::cluster_id, wpan_envelope_t::dest_endpoint, wpan_envelope_t::dev, EINVAL, htole16, wpan_envelope_t::ieee_address, wpan_envelope_t::length, memcpy_betole, wpan_envelope_t::network_address, wpan_envelope_t::payload, wpan_envelope_t::source_endpoint, wpan_conversation_register(), wpan_envelope_send(), ZDO_BIND_DST_MODE_ADDR, ZDO_BIND_REQ, ZDO_CONVERSATION_TIMEOUT, zdo_endpoint_state(), and ZDO_UNBIND_REQ.

int zdo_send_descriptor_req ( wpan_envelope_t envelope,
uint16_t  cluster,
uint16_t  addr_of_interest,
wpan_response_fn  callback,
const void FAR context 
)

Send a ZDO Node, Power, Complex or User Descriptor request, or an Active Endpoint request.

Parameters
[in,out]envelopeEnvelope created by wpan_envelope_create; this function will fill in the cluster and reset the payload and length.
[in]clusterAny ZDO request with a transaction and 16-bit network address as its only fields, including:
  • ZDO_NODE_DESC_REQ
  • ZDO_POWER_DESC_REQ
  • ZDO_ACTIVE_EP_REQ
  • ZDO_COMPLEX_DESC_REQ
  • ZDO_USER_DESC_REQ
[in]addr_of_interestaddress to use in ZDO request
[in]callbackfunction to receive response
[in]contextcontext to pass to callback with response
Return values
!0error sending request
0request sent

References wpan_envelope_t::cluster_id, wpan_envelope_t::dest_endpoint, wpan_envelope_t::dev, EINVAL, htole16, wpan_envelope_t::length, wpan_envelope_t::payload, wpan_envelope_t::profile_id, wpan_envelope_t::source_endpoint, wpan_conversation_register(), WPAN_ENDPOINT_ZDO, wpan_envelope_send(), WPAN_PROFILE_ZDO, ZDO_CONVERSATION_TIMEOUT, and zdo_endpoint_state().

int zdo_send_ieee_addr_req ( wpan_dev_t dev,
uint16_t  net_addr,
addr64 FAR ieee_be 
)

Given a device's 16-bit network address, get its IEEE (64-bit) address by unicasting a ZDO IEEE_addr request to it.

This function only works with the following XBee firmware versions:

  • S2C: 401F and later (ZigBee), 5123 and later (Smart Energy)
  • S2[B]: not supported

After calling this function, *ieee_be is set to *ZDO_IEEE_ADDR_PENDING.

When a SUCCESS response comes back, *ieee_be is set to the 64-bit IEEE address in the response.

If an ERROR response comes back, *ieee_be is set to all zeros (*ZDO_IEEE_ADDR_ERROR).

If a timeout occurs waiting for a response, *ieee_be is set to ZDO_IEEE_ADDR_TIMEOUT.

1 addr64 ieee_be; // IEEE address in big-endian byte order
2 uint16_t net_addr;
3 
4 printf( "Sending IEEE_addr request for 0x%04X\n", net_addr);
5 zdo_send_ieee_addr_req( dev, net_addr, &ieee_be);
6 do {
7  wpan_tick( dev);
8 } while (addr64_equal( &ieee_be, ZDO_IEEE_ADDR_PENDING));
9 
10 if (addr64_equal( &ieee_be, ZDO_IEEE_ADDR_TIMEOUT))
11 {
12  printf( "IEEE_addr request for 0x%04X timed out\n", net_addr);
13 }
14 else if (addr64_is_zero( &ieee_be))
15 {
16  printf( "Error retrieving IEEE_addr for 0x%04X\n", net_addr);
17 }
18 else
19 {
20  printf( "IEEE address of 0x%04X is %" PRIsFAR "\n", net_addr,
21  addr64_format( buffer, &ieee_be));
22 }
Parameters
[in]devwpan_dev_t to send request
[in]net_addrnetwork address of device we're seeking an IEEE address for
[out]ieee_belocation to store the 64-bit IEEE address when the IEEE_addr response comes back.
Return values
-EINVALinvalid parameter passed to function
-ENOSPCconversation table is full, wait and try sending later
0request sent
!0error trying to send request

References _zdo_process_ieee_addr_resp(), wpan_envelope_t::cluster_id, EINVAL, htole16, wpan_envelope_t::length, wpan_envelope_t::payload, wpan_conversation_register(), wpan_envelope_create(), wpan_envelope_send(), WPAN_IEEE_ADDR_UNDEFINED, ZDO_CONVERSATION_TIMEOUT, zdo_endpoint_state(), and ZDO_IEEE_ADDR_REQ.

int zdo_send_nwk_addr_req ( wpan_dev_t dev,
const addr64 FAR ieee_be,
uint16_t FAR net 
)

Given a device's IEEE (64-bit) address, get its 16-bit network address by unicasting a ZDO NWK_addr request to it.

After calling this function, *net is set to ZDO_NET_ADDR_PENDING.

When a SUCCESS response comes back, *net is set to the 16-bit network address in the response.

When an ERROR response comes back, *net is set to ZDO_NET_ADDR_ERROR.

If a timeout occurs waiting for a response, *net is set to ZDO_NET_ADDR_TIMEOUT.

(So the caller needs to wait until (*net != ZDO_NET_ADDR_PENDING)).

Parameters
[in]devwpan_dev_t to send request
[in]ieee_beIEEE address (in big-endian byte order) of device we're seeking a network address for
[out]netlocation to store the 16-bit network address when the NWK_addr response comes back.
Return values
-EINVALinvalid parameter passed to function
-ENOSPCconversation table is full, wait and try sending later
0request sent
!0error trying to send request

References _zdo_envelope_create(), _zdo_process_nwk_addr_resp(), addr64_format(), ADDR64_STRING_LENGTH, wpan_envelope_t::cluster_id, EINVAL, wpan_envelope_t::length, memcpy_betole, wpan_envelope_t::payload, PRIsFAR, wpan_conversation_register(), wpan_envelope_send(), ZDO_CONVERSATION_TIMEOUT, zdo_endpoint_state(), and ZDO_NWK_ADDR_REQ.

int zdo_send_response ( const wpan_envelope_t FAR request,
const void FAR response,
uint16_t  length 
)

Send a response to a ZDO request.

Automatically builds the response envelope and sets its cluster ID (to the request's cluster ID with the high bit set) before sending.

Parameters
[in]requestenvelope of original request
[in]responseframe to send in response
[in]lengthlength of response
Return values
0sent response
!0error sending response

References wpan_envelope_t::cluster_id, hex_dump(), HEX_DUMP_FLAG_TAB, wpan_envelope_t::length, wpan_envelope_t::payload, wpan_envelope_reply(), wpan_envelope_send(), and ZDO_CLUST_RESPONSE_MASK.

Referenced by _zdo_active_ep_respond(), _zdo_match_desc_respond(), _zdo_simple_desc_respond(), and zdo_handler().

int zdo_simple_desc_request ( wpan_envelope_t envelope,
uint16_t  addr_of_interest,
uint_fast8_t  endpoint,
wpan_response_fn  callback,
const void FAR context 
)

Send a ZDO Simple Descriptor Request.

The simple descriptor contains information specific to each of a node's endpoints. Use the ZDO Simple Descriptor Request to get a descriptor for an endpoint on a remote node.

Parameters
[in]envelopeEnvelope created with wpan_envelope_create(). Only dev, ieee_address and network_address should be set, all other structure elements should be zero. Address may match addr_of_interest or an alternative device that contains the discovery information of that device (like an end device's parent).
[in]addr_of_interestNetwork address of the device for which the simple descriptor is required.
[in]endpointEndpoint of interest, a value from 1 to 254.
[in]callbackFunction to receive the Simple Descriptor Response. See documentation for wpan_response_fn for this callback's API.
[in]contextContext pointer passed to the callback along with the response.
Return values
0request sent
!0error sending request

References _zdo_simple_desc_respond(), wpan_envelope_t::cluster_id, wpan_envelope_t::dest_endpoint, wpan_envelope_t::dev, EINVAL, FAR, htole16, wpan_envelope_t::length, wpan_envelope_t::payload, wpan_envelope_t::profile_id, wpan_envelope_t::source_endpoint, wpan_conversation_register(), WPAN_ENDPOINT_ZDO, wpan_envelope_send(), WPAN_PROFILE_ZDO, ZDO_CONVERSATION_TIMEOUT, zdo_endpoint_state(), and ZDO_SIMPLE_DESC_REQ.