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
example_network_explorer.c File Reference
Simple Applications

Allows the user to configure this device as either a Coordinator, Router, or End device and explore various features of the Zigbee Module, such as sending messages via short address or long address, finding devices, etc. Uses the AF/ZDO interface. Uses a command line interface (CLI). More...

`#include "../HAL/hal.h"`
`#include "../ZM/module.h"`
`#include "../ZM/application_configuration.h"`
`#include "../ZM/af.h"`
`#include "../ZM/zdo.h"`
`#include "../ZM/zm_phy_spi.h"`
`#include "../ZM/module_errors.h"`
`#include "../ZM/module_utilities.h"`
`#include "../Common/utilities.h"`
`#include "Messages/infoMessage.h"`
`#include "module_example_utils.h"`
`#include <stdint.h>`
`#include <stdlib.h>`
`#include <errno.h>`
`#include <string.h>`

## Macros
#define | MODULE_START_DELAY_IF_FAIL_MS 5000
#define | ESCAPE_KEY 0x1B
#define | NO_CHARACTER_RECEIVED 0xFF
#define | CLI_MODE_NORMAL 0
#define | CLI_MODE_ENTER_SHORT_ADDRESS 1
#define | CLI_MODE_ENTER_LONG_ADDRESS 2
#define | CLI_INPUT_BUFFER_SIZE 24
#define | NWK_OFFLINE 0
#define | NWK_ONLINE 1
#define | TEST_CLUSTER 0x77
enum | STATE { STATE_IDLE, STATE_INIT, STATE_MODULE_STARTUP, STATE_GET_DEVICE_TYPE, STATE_DISPLAY_NETWORK_INFORMATION, STATE_SEND_MESSAGE_VIA_LONG_ADDRESS, STATE_SEND_MESSAGE_VIA_SHORT_ADDRESS, STATE_VALID_SHORT_ADDRESS_ENTERED, STATE_VALID_LONG_ADDRESS_ENTERED, STATE_FIND_VIA_SHORT_ADDRESS, STATE_FIND_VIA_LONG_ADDRESS, STATE_IDLE, STATE_MODULE_STARTUP, STATE_DISPLAY_NETWORK_INFORMATION, STATE_IDLE, STATE_MODULE_STARTUP, STATE_SEND_INFO_MESSAGE, STATE_DISPLAY_NETWORK_INFORMATION, STATE_IDLE, STATE_MODULE_STARTUP, STATE_SEND_INFO_MESSAGE, STATE_DISPLAY_NETWORK_INFORMATION }
enum STATE | state = STATE_INIT
enum STATE | pendingState = STATE_IDLE
uint16_t | stateFlags = 0
uint8_t | zmBuf [ZIGBEE_MODULE_BUFFER_SIZE]
uint8_t | zigbeeDeviceType = ROUTER
uint8_t | zigbeeNetworkStatus = NWK_OFFLINE
uint16_t | shortAddressEntered
uint8_t | longAddressEntered [8]
unsigned char | testMessage [] = {0xE0,0xE1,0xE2,0xE3,0xE4}
void(* | debugConsoleIsr )(int8_t)
void | stateMachine ()
void | handleDebugConsoleInterrupt (int8_t rxByte)
enum STATE | processCommand (char cmd)
int | main (void)

## Detailed Description

Allows the user to configure this device as either a Coordinator, Router, or End device and explore various features of the Zigbee Module, such as sending messages via short address or long address, finding devices, etc. Uses the AF/ZDO interface. Uses a command line interface (CLI).

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 TEST_CLUSTER 0x77

Which cluster our test message uses

## Enumeration Type Documentation

enum STATE

STATES for state machine

## Function Documentation

void handleDebugConsoleInterrupt | ( | int8_t | rxByte | ) |

Process a serial ISR

    Method to handle bytes received on the debug console. Just stores it to the variable <code>command</code>.

This gets called by the ISR in the hal file since we set the debugConsoleIsr function pointer (defined in hal file) to point to this function.

    Method to handle bytes received on the debug console. Just stores it to the variable

`command`. This gets called by the ISR in the hal file since we set the debugConsoleIsr function pointer (in hal file) to point to this function.

Method to handle bytes received on the debug console. This gets called by the ISR in the hal file since we set the debugConsoleIsr function pointer (in hal file) to point to this function.

enum STATE processCommand | ( | char | cmd | ) |

Command Line Interface processor

    Process characters typed in by the user. Normally this will fire off a menu command, unless

we are awaiting the user to enter a two-byte (four ascii character) short address or eight byte (16 ascii character) long address.

Note:
  : processCommand modifies variables shortAddressEntered and longAddressEntered

Returns:
  the state to transition to next

void stateMachine | ( |  | ) |

This removes the blocking wait in afSendData() but this means that we have to process the AF_DATA_CONFIRM This bypasses the blocking wait in zdoRequestIeeeAddress() This bypasses the blocking wait in zdoRequestNwkAddress() The main application state machine

The main state machine for the application. Never exits.

## Variable Documentation

void(* debugConsoleIsr)(int8_t)

    This is a function pointer for the Interrupt Service Routine called when a debug console

character is received. To use it, declare it with `extern void (*debugConsoleIsr)(int8_t);` and then point it to a function you created, e.g. `debugConsoleIsr =` and your function handleDebugConsoleInterrupt() will be called when a byte is received on the debug serial port. Obviously your handleDebugConsoleInterrupt must have the same method signature as the function pointer. In other words, your function should be declared as: void handleDebugConsoleInterrupt(int8_t);

    This is a function pointer for the Interrupt Service Routine called when a debug console character is received.

To use it, declare it with `extern void (*debugConsoleIsr)(char);` and then point it to a function you created, e.g. `debugConsoleIsr =` and your function handleDebugConsoleInterrupt() will be called when a byte is received on the debug serial port.

This is a function pointer for the Interrupt Service Routine called when a debug console character is received. To use it, declare it with `extern void (*debugConsoleIsr)(char);` and then point it to a function you created, e.g. `debugConsoleIsr =` and your function handleDebugConsoleInterrupt() will be called when a byte is received on the debug serial port.

    This is a function pointer for the Interrupt Service Routine called when a debug console character is received.

To use it, declare it with `extern void (*debugConsoleIsr)(char);` and then point it to a function you created, e.g. `debugConsoleIsr =` and your function handleDebugConsoleInterrupt() will be called when a byte is received.

    This is a function pointer for the Interrupt Service Routine called when a debug console character is received.

To use it, declare it with `extern void (*debugConsoleIsr)(int8_t);` and then point it to a function you created, e.g. `debugConsoleIsr =` and your function handleDebugConsoleInterrupt() will be called when a byte is received on the debug serial port.

enum STATE pendingState = STATE_IDLE

    This stores what to do once a valid shortAddress or longAddress has been parsed by the command

line processor.

enum STATE state = STATE_INIT

    This is the current state of the application and is modified by other states, or based on the

contents of an incoming message.

uint16_t stateFlags = 0

Various flags between states

unsigned char testMessage[] = {0xE0,0xE1,0xE2,0xE3,0xE4}

The test message to send

uint8_t zigbeeDeviceType = ROUTER

Which device type to use to start the module. This can be changed via CLI.

uint8_t zigbeeNetworkStatus = NWK_OFFLINE

Whether the zigbee network has been started, etc.

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.