Zigbee Module Examples

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions | Variables
zdo.c File Reference

Methods that implement the Zigbee Device Objects (ZDO) interface. More...

`#include "zdo.h"`
`#include "module.h"`
`#include "../HAL/hal.h"`
`#include "../Common/utilities.h"`
`#include "module_errors.h"`
`#include "zm_phy_spi.h"`
`#include <string.h>`
`#include <stdint.h>`

## Macros
#define | METHOD_ZDO_STARTUP_FROM_APP 0x31
#define | ZDO_STARTUP_FROM_APP_PAYLOAD_LEN 1
#define | NO_START_DELAY 0
#define | METHOD_ZDO_IEEE_ADDR_REQ 0x32
#define | METHOD_ZDO_IEEE_ADDR_RSP 0x33
#define | ZDO_IEEE_ADDR_REQ_PAYLOAD_LEN 4
#define | ZDO_IEEE_ADDR_RSP_TIMEOUT 10
#define | METHOD_ZDO_NWK_ADDR_REQ 0x34
#define | METHOD_ZDO_NWK_ADDR_RSP 0x35
#define | ZDO_NWK_ADDR_REQ_PAYLOAD_LEN 10
#define | ZDO_NWK_ADDR_RSP_TIMEOUT 10
#define | METHOD_ZDO_USER_DESC_REQ 0x36
#define | METHOD_ZDO_USER_DESC_RSP 0x37
#define | ZDO_USER_DESC_REQ_PAYLOAD_LEN 4
#define | ZDO_USER_DESC_RSP_TIMEOUT 10
#define | METHOD_ZDO_NODE_DESC_REQ 0x38
#define | METHOD_ZDO_NODE_DESC_RSP 0x39
#define | ZDO_NODE_DESC_REQ_PAYLOAD_LEN 4
#define | ZDO_NODE_DESC_RSP_TIMEOUT 10
#define | METHOD_ZDO_USER_DESC_SET 0x3A
#define | ZDO_USER_DESC_SET_PAYLOAD_LEN_HEADER 5

## Functions
moduleResult_t | zdoStartApplication ()
moduleResult_t | zdoRequestIeeeAddress (uint16_t shortAddress, uint8_t requestType, uint8_t startIndex)
moduleResult_t | zdoNetworkAddressRequest (uint8_t *ieeeAddress, uint8_t requestType, uint8_t startIndex)
void | displayZdoUserDescriptorResponse (uint8_t *rsp)
void | displayZdoNodeDescriptorResponse (uint8_t *rsp)
void | displayZdoAddressResponse (uint8_t *rsp)
void | displayZdoEndDeviceAnnounce (uint8_t *announce)
moduleResult_t | zdoUserDescriptorRequest (uint16_t destinationAddress, uint16_t networkAddressOfInterest)
moduleResult_t | zdoNodeDescriptorRequest (uint16_t destinationAddress, uint16_t networkAddressOfInterest)
moduleResult_t | zdoUserDescriptorSet (uint16_t destinationAddress, uint16_t networkAddressOfInterest, uint8_t *userDescriptor, uint8_t userDescriptorLength)

## Variables
uint8_t | zmBuf [ZIGBEE_MODULE_BUFFER_SIZE]

## Detailed Description

Methods that implement the Zigbee Device Objects (ZDO) interface.

The AF/ZDO interface is a more powerful version of the Simple API and allows you to configure, send, and receive Zigbee data. This file acts as an interface between the user's application and the Module physical interface. Module interface could be either SPI or UART. Refer to Interface Specification for more information.

Note:
  For more information, define ZDO_VERBOSE. It is recommended to define this on a per-project basis. In IAR, this can be done in Project Options : C/C++ compiler : Preprocessor In the defined symbols box, add: ZDO_VERBOSE

Rev:
  1642

Author:
  dsmith

Date:
  2012-10-31 11:17:04 -0700 (Wed, 31 Oct 2012)

# Support

Please refer to the wiki at www.anaren.com/air-wiki-zigbee for more information. Additional support is available via email at the following addresses:

- Questions on how to use the product: AIR@a.nosp@m.nare.nosp@m.n.com
- Feature requests, comments, and improvements: featu.nosp@m.rere.nosp@m.quest.nosp@m.s@te.nosp@m.slaco.nosp@m.ntro.nosp@m.ls.co.nosp@m.m
- Consulting engagements: sales.nosp@m.@tes.nosp@m.lacon.nosp@m.trol.nosp@m.s.com

# License

Copyright (c) 2012 Tesla Controls. All rights reserved. This Software may only be used with an Anaren A2530E24AZ1, A2530E24CZ1, A2530R24AZ1, or A2530R24CZ1 module. Redistribution and use in source and binary forms, with or without modification, are subject to the Software License Agreement in the file "anaren_eula.txt"

YOU FURTHER 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 ANAREN MICROWAVE OR TESLA CONTROLS BE LIABLE OR OBLIGATED UNDER CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSE 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 displayZdoAddressResponse | ( | uint8_t * | rsp | ) |

    Displays the returned value of zdoNetworkAddressRequest() or zdoRequestIeeeAddress()

Both response messages use the same format.

Parameters:

  rsp | points to the beginning of the response

Precondition:
  rsp holds a valid response

void displayZdoEndDeviceAnnounce | ( | uint8_t * | announce | ) |

    Displays the parsed fields in a ZDO_END_DEVICE_ANNCE_IND message

Parameters:

  announce | points to the start of a ZDO_END_DEVICE_ANNCE_IND: (zmBuf)

void displayZdoNodeDescriptorResponse | ( | uint8_t * | rsp | ) |

    Displays the returned value of ZdoNodeDescriptorRequest()

Parameters:

  rsp | points to the beginning of the response

Precondition:
  rsp holds a valid response

void displayZdoUserDescriptorResponse | ( | uint8_t * | rsp | ) |

    Displays the returned value of ZdoUserDescriptorRequest()

Parameters:

  rsp | points to the beginning of the response

Precondition:
  rsp holds a valid response

moduleResult_t zdoNetworkAddressRequest | ( | uint8_t * | ieeeAddress,
|  | uint8_t | requestType,
|  | uint8_t | startIndex
| ) |  |

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

Parameters:

  ieeeAddress | the long address to locate, LSB first!
  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
  may not work correctly when using UART interface

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.

moduleResult_t zdoNodeDescriptorRequest | ( | uint16_t | destinationAddress,
|  | uint16_t | networkAddressOfInterest
| ) |  |

    Requests a remote device's node descriptor.

Parameters:

  destinationAddress | the short address of the destination
  networkAddressOfInterest | the short address of the device the query is intended for

Postcondition:
  zmBuf contains the ZDO_NODE_DESC_RSP message.

moduleResult_t zdoRequestIeeeAddress | ( | uint16_t | shortAddress,
|  | uint8_t | requestType,
|  | uint8_t | startIndex
| ) |  |

    Requests a remote 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:
  zmBuf contains the ZDO_IEEE_ADDR_RSP message.

moduleResult_t zdoStartApplication | ( |  | ) |

    Starts the Zigbee stack in the Module 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:
  We will see Device Status change to DEV_ROUTER, DEV_ZB_COORD, or DEV_END_DEVICE correspondingly if everything was ok.

moduleResult_t zdoUserDescriptorRequest | ( | uint16_t | destinationAddress,
|  | uint16_t | networkAddressOfInterest
| ) |  |

    Requests a remote device's user descriptor. This is a 16 byte text field that may be used for

anything and may be read/written remotely.

Parameters:

  destinationAddress | the short address of the destination
  networkAddressOfInterest | the short address of the device the query is intended for

Postcondition:
  zmBuf contains the ZDO_USER_DESC_RSP message.

moduleResult_t zdoUserDescriptorSet | ( | uint16_t | destinationAddress,
|  | uint16_t | networkAddressOfInterest,
|  | uint8_t * | userDescriptor,
|  | uint8_t | userDescriptorLength
| ) |  |

    Sets a remote device's user descriptor.

Parameters:

  destinationAddress | the short address of the destination
  networkAddressOfInterest | the short address of the device

## Variable Documentation

uint8_t zmBuf[ZIGBEE_MODULE_BUFFER_SIZE]

    This buffer will hold the transmitted messages and received SRSP Payload after sendMessage() was

called. If fragmentation support is not required then this can be smaller, e.g. 100B.