# af_zdo.h File Reference

public methods for af_zdo.c More...

`#include "application_configuration.h"`

## Defines
#define | SINGLE_DEVICE_RESPONSE 0
#define | INCLUDE_ASSOCIATED_DEVICES 1
#define | AF_INCOMING_MESSAGE_CLUSTER_LSB_FIELD (SRSP_PAYLOAD_START+2)
#define | AF_INCOMING_MESSAGE_CLUSTER_MSB_FIELD (SRSP_PAYLOAD_START+3)
#define | AF_INCOMING_MESSAGE_SHORT_ADDRESS_LSB_FIELD (SRSP_PAYLOAD_START+4)
#define | AF_INCOMING_MESSAGE_SHORT_ADDRESS_MSB_FIELD (SRSP_PAYLOAD_START+5)
#define | AF_INCOMING_MESSAGE_SHORT_ADDRESS() (CONVERT_TO_INT(znpBuf[AF_INCOMING_MESSAGE_SHORT_ADDRESS_LSB_FIELD], znpBuf[AF_INCOMING_MESSAGE_SHORT_ADDRESS_MSB_FIELD]))
#define | AF_INCOMING_MESSAGE_CLUSTER() (CONVERT_TO_INT(znpBuf[AF_INCOMING_MESSAGE_CLUSTER_LSB_FIELD], znpBuf[AF_INCOMING_MESSAGE_CLUSTER_MSB_FIELD]))
#define | AF_INCOMING_MESSAGE_PAYLOAD_LEN_FIELD (SRSP_PAYLOAD_START+16)
#define | AF_INCOMING_MESSAGE_PAYLOAD_START_FIELD (SRSP_PAYLOAD_START+17)
#define | IS_AF_INCOMING_MESSAGE() (CONVERT_TO_INT(znpBuf[SRSP_CMD_LSB_FIELD], znpBuf[SRSP_CMD_MSB_FIELD]) == AF_INCOMING_MSG)
## Functions
void | afRegisterApplication (struct applicationConfiguration ac)
void | afRegisterGenericApplication ()
void | zdoStartApplication ()
void | afSendData (unsigned char destinationEndpoint, unsigned char sourceEndpoint, unsigned int destinationShortAddress, unsigned int clusterId, unsigned char *data, unsigned char dataLength)
void | zdoRequestIeeeAddress (unsigned int shortAddress, unsigned char requestType, unsigned char startIndex)
unsigned char * | zdoNetworkAddressRequest (unsigned char *ieeeAddress, unsigned char requestType, unsigned char startIndex)
signed int | printAfIncomingMsgHeader (unsigned char *srsp)
void | printAfIncomingMsgHeaderNames ()
void | printZdoNetworkAddressResponse (unsigned char *rsp)

## Detailed Description

public methods for af_zdo.c

Rev
  622

Author
  dsmith

Date
  2010-07-02 10:55:33 -0700 (Fri, 02 Jul 2010)

YOU ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.

## Function Documentation

void afRegisterApplication | ( | struct applicationConfiguration | ac | ) |

Configures the ZNP for our application. Sets which profileId, etc. we're using as well as binding information FOR EACH ENDPOINT Using the AF/ZDO interface, you can have more than one endpoint. Recommended not to exceed 10 endpoints.

Parameters:

  | ac | the applicationConfiguration to register.

Precondition:
  znp was initialized and ZCD_NV_LOGICAL_TYPE has been set (COORDINATOR/ROUTER/END_DEVICE).

Postcondition:
  znpResult contains the error code, or ZNP_SUCCESS if success.
  can now use afStartApplication()

Note:
  this method does not check whether the endpoint being registered has already been registered - it is up to the application to manage that.

See also:
  applicationConfiguration

void afRegisterGenericApplication | ( |  | ) |

Configures the ZNP for a "generic" application: one endpoint, no binding or fancy stuff. Sets which endpoint, profileId, etc. we're using as well as binding information

Postcondition:
  znpResult contains the error code, or ZNP_SUCCESS if success.

See also:
  afRegisterApplication()

void afSendData | ( | unsigned char | destinationEndpoint,
|  | unsigned char | sourceEndpoint,
|  | unsigned int | destinationShortAddress,
|  | unsigned int | clusterId,
|  | unsigned char * | data,
|  | unsigned char | dataLength |
| ) |  |  |

Sends a message to another device over the Zigbee network using the AF command AF_DATA_REQUEST.

Parameters:

  | destinationEndpoint | which endpoint to send this to.
  | sourceEndpoint | which endpoint this message originated from on our device
  | destinationShortAddress | the short address of the destination, or ALL_DEVICES or ALL_ROUTERS_AND_COORDINATORS to broadcast the message.
  | clusterId | which cluster this message is for. User definable. Zigbee supports up to 2^16 clusters. A cluster is typically a particular command, e.g. "turn on lights" or "get temperature". If using a predefined Zigbee Alliance Application Profile then this cluster will follow the Zigbee Cluster Library.
  | data | is the data to send.
  | dataLength | is how many bytes of data to send. Must be less than MAXIMUM_PAYLOAD_LENGTH.

Note:
  On a coordinator in a trivial test setup, it takes approximately 10mSec from sending AF_DATA_REQUEST to when we receive AF_DATA_CONFIRM.
  `transactionSequenceNumber` is an optional user-definable reference number to match AF_DATA_REQUEST messages with AF_DATA_CONFIRM messages.
  The ZNP will automatically require an ACK from the next device on the route when sending data. To require an ACK from the final destination, change MAC_ACK to APS_ACK at the expense of increased network traffic.
  The `radius` is the maximum number of hops that this packet can travel through before it will be dropped. Should be set to the maximum number of hops expected in the network.
  adjust AF_DATA_CONFIRM_INTERVAL_MS and AF_DATA_CONFIRM_TIMEOUT_MS based on network size, number of hops, etc.

Precondition:
  the application was started successfully
  there is another device on the network with short address of `destinationShortAddress` and that device has successfully started its application.

Postcondition:
  srsp will contain a AF_DATA_REQUEST_SRSP. We will receive a AF_DATA_REQUEST_SRSP regardless of whether the message was successfully sent or not.
  we will receive a AF_DATA_CONFIRM if the message was successfully sent.
  znpResult contains the error code, or ZNP_SUCCESS if success.

signed int printAfIncomingMsgHeader | ( | unsigned char * | srsp | ) |

Displays the header information in an AF_INCOMING_MSG.

Parameters:

  | srsp | a pointer to the buffer containing the message

Returns:
  0 if success, -1 if not a AF_INCOMING_MSG.

void printAfIncomingMsgHeaderNames | ( |  | ) |

Displays the names that go with the above

void printZdoNetworkAddressResponse | ( | unsigned char * | rsp | ) |

Prints out the returned value of zdoNetworkAddressRequest()

unsigned char* zdoNetworkAddressRequest | ( | unsigned char * | ieeeAddress,
|  | unsigned char | requestType,
|  | unsigned char | startIndex |
| ) |  |  |

Requests a device's Short Address for a given long address.

Parameters:

  | ieeeAddress | the long address to locate
  | requestType | must be SINGLE_DEVICE_RESPONSE or INCLUDE_ASSOCIATED_DEVICES. If SINGLE_DEVICE_RESPONSE is selected, then only information about the requested device will be returned. If INCLUDE_ASSOCIATED_DEVICES is selected, then the short addresses of the selected device's children will be returned too.
  | startIndex | If INCLUDE_ASSOCIATED_DEVICES was selected, then there may be too many children to fit in one ZDO_NWK_ADDR_RSP message. So, use startIndex to get the next set of children's short addresses.

Note:
  DOES NOT WORK FOR SLEEPING END DEVICES

Postcondition:
  An ZDO_NWK_ADDR_RSP message will be received, with one or more entries.

Returns:
  a pointer to the beginning of the payload, or a pointer to indeterminate data if error.

Postcondition:
  znpResult contains the error code, or ZNP_SUCCESS if success.

void zdoRequestIeeeAddress | ( | unsigned int | shortAddress,
|  | unsigned char | requestType,
|  | unsigned char | startIndex |
| ) |  |  |

Requests a device's MAC Address (64-bit IEEE Address) given a short address.

Parameters:

  | shortAddress | the short address to locate
  | requestType | must be SINGLE_DEVICE_RESPONSE or INCLUDE_ASSOCIATED_DEVICES. If SINGLE_DEVICE_RESPONSE is selected, then only information about the requested device will be returned. If INCLUDE_ASSOCIATED_DEVICES is selected, then the short addresses of the selected device's children will be returned too.
  | startIndex | If INCLUDE_ASSOCIATED_DEVICES was selected, then there may be too many children to fit in one ZDO_IEEE_ADDR_RSP message. So, use startIndex to get the next set of children's short addresses.

Postcondition:
  An ZDO_IEEE_ADDR_RSP message will be received, with one or more entries.
  znpResult contains the error code, or ZNP_SUCCESS if success.

void zdoStartApplication | ( |  | ) |

Starts the Zigbee stack in the ZNP using the settings from a previous afRegisterApplication(). After this start request process completes, the device is ready to send, receive, and route network traffic.

Note:
  On a coordinator in a trivial test setup, it takes approximately 300mSec between sending START_REQUEST and receiving START_REQUEST_SRSP and then another 200-1000mSec from when we receive START_REQUEST_SRSP to when we receive START_CONFIRM. Set START_CONFIRM_TIMEOUT based on size of your network.
  ZDO_STARTUP_FROM_APP field StartDelay not used

Precondition:
  afRegisterApplication() was a success.

Postcondition:
  znpResult contains the error code, or ZNP_SUCCESS if success.
  We will see Device Status change to DEV_ROUTER, DEV_ZB_COORD, or DEV_END_DEVICE correspondingly if everything was ok.

All Data Structures Files Functions Variables Defines