Digi XBee(R) ANSI C Host Library
|
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 FAR * | zdo_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... | |
#define | ZDO_REQUEST_TYPE_SINGLE 0x00 |
#define | ZDO_REQUEST_TYPE_EXTENDED 0x01 |
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 |
#define ZDO_DEVICE_ANNCE_CLUSTER | ( | handler, | |
context | |||
) |
Entry for Device Annce handler in cluster table of ZDO endpoint.
#define ZDO_ENDPOINT | ( | state | ) |
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.
Writes to *buffer, an 8-bit cluster count followed by the 16-bit cluster IDs in little-endian byte order.
[in,out] | buffer | location to store cluster list, updated to point to first byte after bytes written |
[in] | clust_read | list of 16-bit cluster IDs, terminated by WPAN_CLUSTER_END_OF_LIST |
[in] | max_count | maximum number of clusters to write to *buffer |
-ENOSPC | can't fit list of clusters into buffer |
>=0 | number 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.
[in,out] | buffer | location to store cluster list, updated to point to first byte after bytes written |
[in] | max_count | maximum number of clusters to write to *buffer |
[in] | mask | mask used to restrict entries |
[in] | entry | list of clusters, terminated by an entry with and ID of WPAN_CLUSTER_END_OF_LIST |
-ENOSPC | can't fit list of clusters into buffer |
>=0 | number 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.
[in] | envelope | envelope of request |
0 | successfully sent response |
-ENODATA | don't know network address of envelope->dev |
!0 | error 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.
[in] | dev | search the endpoint table of this device |
NULL | couldn't find the ZDO endpoint for dev |
!NULL | pointer 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
[out] | envelope | envelope to populate |
[in] | dev | device that will send this envelope |
[in] | address | send request to the given target, or NULL for a self-addressed request |
address
or a pointer to an all-zero IEEE addressReferences 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.
[in] | envelope | envelope of request |
0 | successfully sent response, or none of the endpoints matched the request |
-ENODATA | don't know network address of envelope->dev |
!0 | error 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.
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.
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.
[in] | envelope | envelope of request |
0 | successfully sent response |
-ENODATA | don't know network address of envelope->dev |
!0 | error 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.
[in] | dev | device to query |
NULL | dev does not have a ZDO endpoint |
!NULL | address 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).
[in] | envelope | envelope of received ZDO frame, contains address, endpoint, profile, and cluster info |
[in] | ep_state | pointer to endpoint's state structure (used for tracking transactions) |
0 | successfully processed |
!0 | error 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.
[out] | buffer | Buffer to hold generated request. |
[in] | buflen | Size of buffer used to hold generated request. |
[in] | addr_of_interest | See ZDO documentation for NWKAddrOfInterest. |
[in] | profile_id | Profile ID to match, must be an actual profile ID (cannot be WPAN_APS_PROFILE_ANY). |
[in] | inClust | List of input clusters, ending with WPAN_CLUSTER_END_OF_LIST. Can use NULL if there aren't any input clusters. |
[in] | outClust | List of output clusters, ending with WPAN_CLUSTER_END_OF_LIST. Can use NULL if there aren't any output clusters. |
-ENOSPC | buffer isn't large enough to hold request; need 7 bytes plus (2 * the number of clusters) |
>0 | number 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.
[in] | dev | device to send request on |
[in] | address | address to send request to, or NULL for self-addressed |
[in] | flags | one or more of the following flags:
|
0 | successfully sent request |
-EINVAL | bad parameter passed to function |
!0 | error 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.
[in] | envelope | addressing information used for the Bind Request |
[in] | type | ZDO_BIND_REQ for a Bind Request or ZDO_UNBIND_REQ for an Unbind Request; all other values are invalid |
[in] | callback | callback to receive Bind/Unbind (or Default) Response; NULL if you don't care about the response |
[in] | context | context passed to callback |
0 | successfully sent request |
-EINVAL | bad parameter passed to function |
!0 | error 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.
[in,out] | envelope | Envelope created by wpan_envelope_create; this function will fill in the cluster and reset the payload and length. |
[in] | cluster | Any ZDO request with a transaction and 16-bit network address as its only fields, including:
|
[in] | addr_of_interest | address to use in ZDO request |
[in] | callback | function to receive response |
[in] | context | context to pass to callback with response |
!0 | error sending request |
0 | request 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:
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.
[in] | dev | wpan_dev_t to send request |
[in] | net_addr | network address of device we're seeking an IEEE address for |
[out] | ieee_be | location to store the 64-bit IEEE address when the IEEE_addr response comes back. |
-EINVAL | invalid parameter passed to function |
-ENOSPC | conversation table is full, wait and try sending later |
0 | request sent |
!0 | error 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)).
[in] | dev | wpan_dev_t to send request |
[in] | ieee_be | IEEE address (in big-endian byte order) of device we're seeking a network address for |
[out] | net | location to store the 16-bit network address when the NWK_addr response comes back. |
-EINVAL | invalid parameter passed to function |
-ENOSPC | conversation table is full, wait and try sending later |
0 | request sent |
!0 | error 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.
[in] | request | envelope of original request |
[in] | response | frame to send in response |
[in] | length | length of response |
0 | sent response |
!0 | error 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.
[in] | envelope | Envelope 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_interest | Network address of the device for which the simple descriptor is required. |
[in] | endpoint | Endpoint of interest, a value from 1 to 254. |
[in] | callback | Function to receive the Simple Descriptor Response. See documentation for wpan_response_fn for this callback's API. |
[in] | context | Context pointer passed to the callback along with the response. |
0 | request sent |
!0 | error 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.