Digi XBee(R) ANSI C Host Library
Macros | Functions | Variables
xbee_atcmd.c File Reference

Code related to sending AT command requests and processing the responses. More...

#include <errno.h>
#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include "xbee/platform.h"
#include "xbee/byteorder.h"
#include "xbee/atcmd.h"

Macros

#define _xbee_atcmd_debug
 
#define XBEE_ATCMD_REG_REFRESH_IDX   7
 Offset into _xbee_atcmd_query_regs to use when refreshing the xbee_dev_t/ wpan_dev_t structure. More...
 

Functions

int xbee_cmd_tick (void)
 This function should be called periodically (at least every few seconds) to expire old entries from the AT Command Request table. More...
 
xbee_cmd_request_t FAR_xbee_cmd_handle_to_address (int16_t handle)
 
int _xbee_cmd_issue_list (xbee_dev_t *xbee, xbee_command_list_context_t FAR *clc, const xbee_cmd_response_t FAR *response)
 
int _xbee_cmd_list_callback (const xbee_cmd_response_t FAR *response)
 
int xbee_cmd_list_execute (xbee_dev_t *xbee, xbee_command_list_context_t FAR *clc, const xbee_atcmd_reg_t FAR *list, void FAR *base, const wpan_address_t FAR *address)
 Execute a list of AT commands. More...
 
enum xbee_command_list_status() xbee_cmd_list_status (xbee_command_list_context_t FAR *clc)
 Determine status of command list execution. More...
 
int xbee_cmd_init_device (xbee_dev_t *xbee)
 Initialize the AT Command layer for an XBee device. More...
 
void _xbee_cmd_query_handle_eo (const xbee_cmd_response_t FAR *response, const struct xbee_atcmd_reg_t FAR *reg, void FAR *base)
 
void _xbee_cmd_query_handle_ai (const xbee_cmd_response_t FAR *response, const struct xbee_atcmd_reg_t FAR *reg, void FAR *base)
 
void _xbee_cmd_query_handle_end (const xbee_cmd_response_t FAR *response, const struct xbee_atcmd_reg_t FAR *reg, void FAR *base)
 
int xbee_cmd_query_device (xbee_dev_t *xbee, uint_fast8_t refresh)
 Learn about the underlying device by sending a series of commands and storing the results in the xbee_dev_t. More...
 
int xbee_cmd_query_status (xbee_dev_t *xbee)
 Check the status of querying an XBee device, as initiated by xbee_cmd_query_device(). More...
 
int16_t xbee_cmd_create (xbee_dev_t *xbee, const char FAR command[3])
 Allocate an AT Command request. More...
 
int _xbee_cmd_release_request (xbee_cmd_request_t FAR *request)
 Release an entry from the request table by marking it as available. More...
 
int xbee_cmd_release_handle (int16_t handle)
 Release an entry from the request table by marking it as available. More...
 
int xbee_cmd_set_command (int16_t handle, const char FAR command[3])
 Change the command associated with a request. More...
 
int xbee_cmd_set_callback (int16_t handle, xbee_cmd_callback_fn callback, void FAR *context)
 Associate a callback with a given AT Command request. More...
 
int xbee_cmd_set_target (int16_t handle, const addr64 FAR *ieee, uint16_t network_address)
 Associate a remote XBee device with a given AT Command request. More...
 
uint8_t _xbee_cmd_encode_param (void FAR *buffer, uint32_t value)
 Store an unsigned integer in 1, 2 or 4 bytes as a parameter to an AT command. More...
 
int xbee_cmd_set_flags (int16_t handle, uint16_t flags)
 Set the flags for a given AT Command request. More...
 
int xbee_cmd_clear_flags (int16_t handle, uint16_t flags)
 Clear the flags for a given AT Command request. More...
 
int xbee_cmd_set_param (int16_t handle, uint32_t value)
 Set the parameter (up to 32-bits) for a given AT Command request. More...
 
int xbee_cmd_set_param_bytes (int16_t handle, const void FAR *data, uint8_t length)
 Set the parameter for a given AT Command request to a sequence of bytes. More...
 
int xbee_cmd_set_param_str (int16_t handle, const char FAR *str)
 Set a string parameter for a given AT Command request (e.g., the "NI" node identifier command). More...
 
int xbee_cmd_send (int16_t handle)
 Send an AT Command to a local or remote XBee device. More...
 
int _xbee_cmd_handle_response (xbee_dev_t *xbee, const void FAR *rawframe, uint16_t length, void FAR *context)
 Callback handler registered for frame types XBEE_FRAME_LOCAL_AT_RESPONSE (0x88) and XBEE_FRAME_REMOTE_AT_RESPONSE (0x97). More...
 
int _xbee_cmd_modem_status (xbee_dev_t *xbee, const void FAR *payload, uint16_t length, void FAR *context)
 Receive modem status frames and update our network address (and payload size) on state changes. More...
 
int xbee_cmd_simple (xbee_dev_t *xbee, const char FAR command[3], uint32_t value)
 Simple interface for sending a command with a parameter to the local XBee without checking for a response. More...
 
int xbee_cmd_execute (xbee_dev_t *xbee, const char FAR command[3], const void FAR *data, uint8_t length)
 Simple interface for sending a command with an optional parameter to the local XBee without checking for a response. More...
 
void xbee_identify (xbee_dev_t *xbee, bool_t identify)
 Programs with the ZCL Identify Server Cluster can call this function in their main loop to have the XBee module's association LED flash fast (100ms cycle) when in Identify Mode. More...
 

Variables

FAR xbee_cmd_request_t xbee_cmd_request_table [XBEE_CMD_REQUEST_TABLESIZE]
 Table used to keep track of outstanding requests.
 
const xbee_atcmd_reg_t _xbee_atcmd_query_regs []
 
xbee_command_list_context_t _xbee_atcmd_query_regs_head
 

Detailed Description

Code related to sending AT command requests and processing the responses.

Todo:
move xbee_cmd_simple and xbee_identify into xbee_device layer?
Todo:
Add code to return an error (and disable the stack) if the XBee responds with an IEEE address not in Digi's allocation?
Todo:
review todo list at the top of the file – lots to do