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
module_utilities.c File Reference

Simple utilities for interfacing with the Module. More...

`#include "../HAL/hal.h"`
`#include "module.h"`
`#include "af.h"`
`#include "zdo.h"`
`#include "module_errors.h"`
`#include "module_utilities.h"`
`#include "zm_phy.h"`
`#include "../Common/utilities.h"`
`#include <stddef.h>`

## Macros
#define | WFDS_POLL_INTERVAL_MS 100
#define | METHOD_WAIT_FOR_DEVICE_STATE 0x6000
#define | INVALID_DEVICETYPE 33
#define | MODULE_REGION_NORTH_AMERICA 0x0001
#define | MODULE_REGION_EUROPE 0x0002
#define | MINIMUM_BUILD_ID 0x10
#define | MODULE_TYPE_MASK 0x0F
#define | MAXIMUM_MODULE_TYPE 0x05
#define | MAX_OLD_BUILD_ID 0x1F
#define | IS_VALID_MODULE_TYPE(x) ((x>=0x20) && (x<=0x24))
#define | BUILD_ID_FW_2_4_0 0x7E
#define | METHOD_SET_MODULE_RF_POWER 0x6200
#define | METHOD_START_MODULE 0x6100
#define | TEN_SECONDS 10000
#define | FIFTEEN_SECONDS 15000
#define | START_TIMEOUT FIFTEEN_SECONDS

## Functions
moduleResult_t | waitForDeviceState (unsigned char expectedState, uint16_t timeoutMs)
uint8_t | getDeviceStateForDeviceType (uint8_t deviceType)
moduleResult_t | startModule (const struct moduleConfiguration *mc, const struct applicationConfiguration *ac)
void | displayMessages ()

## Variables
unsigned char | zmBuf [ZIGBEE_MODULE_BUFFER_SIZE]
struct moduleConfiguration | DEFAULT_MODULE_CONFIGURATION_COORDINATOR
struct moduleConfiguration | DEFAULT_MODULE_CONFIGURATION_ROUTER
struct moduleConfiguration | DEFAULT_MODULE_CONFIGURATION_END_DEVICE

## Detailed Description

Simple utilities for interfacing with the Module.

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.

## Macro Definition Documentation

#define INVALID_DEVICETYPE 33

Error value returned from getDeviceStateForDeviceType() if the deviceType is not recognized

#define WFDS_POLL_INTERVAL_MS 100

How often to poll the module in milliseconds to see if the desired deviceState has been received

## Function Documentation

void displayMessages | ( |  | ) |

Retrieves a pending message from the module and displays the type of message it is. Ignores the message if length = 0.

Precondition:
  moduleHasMessageWaiting() is true

uint8_t getDeviceStateForDeviceType | ( | uint8_t | deviceType | ) |

Private method to get the expected deviceState (in ZDO_STATE_CHANGE_IND) that corresponds to this deviceType.

Returns:
  the device state: DEV_ROUTER, DEV_END_DEVICE, or DEV_ZB_COORD accordingly, or INVALID_DEVICETYPE.

moduleResult_t startModule | ( | const struct moduleConfiguration * | mc,
|  | const struct applicationConfiguration * | ac
| ) |  |

Start the Module and join a network, using the AF/ZDO interface.

Parameters:

  moduleConfiguration | the settings to use to start the module
  applicationConfiguration | the settings to use to start the Zigbee Application

See also:
  struct moduleConfiguration in module_utilities.h for information about each field of the moduleConfiguration
  struct applicationConfiguration in application_configuration.h for information about each field of the applicationConfiguration
  module.c for more information about each of these steps.

moduleResult_t waitForDeviceState | ( | unsigned char | expectedState,
|  | uint16_t | timeoutMs
| ) |  |

Private method used to wait until a message is received indicating that we are on the network. Exits if received message is a ZDO_STATE_CHANGE_IND and the state matches what we want. Else loops until timeout.

Note:
  Since this is basically a blocking wait, you can also implement this in your application.

Parameters:

  expectedState | the deviceState we are expecting - DEV_ZB_COORD etc.
  timeoutMs | the amount of milliseconds to wait before returning an error. Should be an integer multiple of WFDS_POLL_INTERVAL_MS.

Todo:
  modify this if using UART.

## Variable Documentation

struct moduleConfiguration DEFAULT_MODULE_CONFIGURATION_COORDINATOR

Initial value:
{
COORDINATOR,
DEFAULT_CHANNEL_MASK,
ANY_PAN,
DEFAULT_POLL_RATE_MS,
DEFAULT_STARTUP_OPTIONS,
SECURITY_MODE_OFF,
NULL
}

Default configuration for a standard coordinator. Modify in application as needed.

struct moduleConfiguration DEFAULT_MODULE_CONFIGURATION_END_DEVICE

Initial value:
{
END_DEVICE,
DEFAULT_CHANNEL_MASK,
ANY_PAN,
DEFAULT_POLL_RATE_MS,
DEFAULT_STARTUP_OPTIONS,
SECURITY_MODE_OFF,
NULL
}

Default configuration for a standard end device. Modify in application as needed.

struct moduleConfiguration DEFAULT_MODULE_CONFIGURATION_ROUTER

Initial value:
{
ROUTER,
DEFAULT_CHANNEL_MASK,
ANY_PAN,
DEFAULT_POLL_RATE_MS,
DEFAULT_STARTUP_OPTIONS,
SECURITY_MODE_OFF,
NULL
}

Default configuration for a standard router. Modify in application as needed.

unsigned char 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.