20 #ifndef __XBEE_COMMAND 21 #define __XBEE_COMMAND 27 #ifndef XBEE_CMD_REQUEST_TABLESIZE 28 #define XBEE_CMD_REQUEST_TABLESIZE 2 36 #ifndef XBEE_CMD_MAX_PARAM_LENGTH 37 #if XBEE_CELLULAR_ENABLED 38 #define XBEE_CMD_MAX_PARAM_LENGTH 128 40 #define XBEE_CMD_MAX_PARAM_LENGTH 64 46 #define XBEE_CMD_REMOTE_TIMEOUT 180 49 #define XBEE_CMD_LOCAL_TIMEOUT 2 54 typedef union xbee_at_cmd {
60 #define XBEE_CMD_ATEO_INSECURE_JOIN (1<<0) 61 #define XBEE_CMD_ATEO_USE_TRUST_CENTER (1<<1) 62 #define XBEE_CMD_ATEO_USE_HASH_LINK_KEY (1<<2) 63 #define XBEE_CMD_ATEO_USE_AUTHENTICATION (1<<3) 74 typedef struct xbee_cmd_response {
115 #define XBEE_CMD_RESP_MASK_STATUS 0x000F 117 #define XBEE_CMD_RESP_ATND_RSSI_INVALID XBEE_AT_RESP_ATND_RSSI_INVALID 119 #define XBEE_CMD_RESP_FLAG_TIMEOUT 0x8000 144 #define XBEE_ATCMD_DONE 0 146 #define XBEE_ATCMD_REUSE 1 178 typedef struct xbee_cmd_request {
195 #define XBEE_CMD_FLAG_REMOTE 0x0001 200 #define XBEE_CMD_FLAG_QUEUE_CHANGE 0x0002 204 #define XBEE_CMD_FLAG_REUSE_HANDLE 0x0004 207 #define XBEE_CMD_FLAG_USER_MASK (XBEE_CMD_FLAG_QUEUE_CHANGE \ 208 |XBEE_CMD_FLAG_REUSE_HANDLE) 234 #ifndef XBEE_CMD_DISABLE_REMOTE 253 }) xbee_header_local_at_req_t;
273 }) xbee_header_remote_at_req_t;
279 #define XBEE_REMOTE_AT_OPT_QUEUE (0) 284 #define XBEE_REMOTE_AT_OPT_IMMEDIATE (1<<1) 287 #define XBEE_REMOTE_AT_OPT_SECURE (1<<4) 291 typedef union xbee_header_at_request {
324 #ifdef XBEE_DISABLE_DIGIMESH 325 #define XBEE_AT_RESP_STATUS(var) (var) 327 #define XBEE_AT_RESP_STATUS(var) ((var) & XBEE_AT_RESP_STATUS_MASK) 344 }) xbee_header_local_at_resp_t;
366 }) xbee_header_remote_at_resp_t;
372 xbee_header_local_at_resp_t header;
375 }) xbee_frame_local_at_resp_t;
379 xbee_header_remote_at_resp_t header;
383 }) xbee_frame_remote_at_resp_t;
386 typedef union xbee_frame_at_response {
435 XBEE_COMMAND_LIST_RUNNING = -
EBUSY,
436 XBEE_COMMAND_LIST_DONE = 0,
438 XBEE_COMMAND_LIST_ERROR = -
EIO,
540 #define XBEE_ATCMD_REG(c1,c2,type,obj,field) \ 541 { { { c1, c2 } }, 0, type, NULL, \ 542 (uint8_t) sizeof((*(obj *)NULL).field), \ 543 (uint8_t) offsetof( obj, field) } 557 #define XBEE_ATCMD_REG_CB(c1,c2,cb,flags) \ 558 { { { c1, c2 } }, flags, XBEE_CLT_NONE, cb, 0, 0 } 591 #define XBEE_ATCMD_REG_MOVE_THEN_CB(c1,c2,type,obj,field,cb,flags) \ 592 { { { c1, c2 } }, flags, type, cb, \ 593 (uint8_t) sizeof((*(obj *)NULL).field), \ 594 (uint8_t) offsetof( obj, field) } 611 #define XBEE_ATCMD_REG_SET_8(c1,c2,value) \ 612 { { { c1, c2 } }, 0, XBEE_CLT_SET_8, NULL, value, 0 } 619 #define XBEE_ATCMD_REG_END \ 620 { { { '\0', '\0' } } } 627 #define XBEE_ATCMD_REG_END_CMD(c1,c2) \ 628 { { { c1, c2 } }, 0, XBEE_CLT_LAST, NULL, 0, 0 } 640 #define XBEE_ATCMD_REG_END_CB(cb, flags) \ 641 { { { '\0', '\0' } }, flags, XBEE_CLT_NONE, cb, 0, 0 } 647 #define XBEE_ATCMD_REG_VALID(ptr) (ptr->command.w != 0) 660 #define xbee_cmd_list_status(clc) ((clc)->status) 665 #define XBEE_CMD_REQUEST_EMPTY(index) \ 666 (xbee_cmd_request_table[index].device == NULL) 670 #define XBEE_CMD_REQUEST_HANDLE(index) \ 671 ((index << 8) || xbee_cmd_request_table[index].sequence) 704 #define XBEE_FRAME_HANDLE_LOCAL_AT \ 705 { XBEE_FRAME_LOCAL_AT_RESPONSE, 0, _xbee_cmd_handle_response, NULL }, \ 706 { XBEE_FRAME_MODEM_STATUS, 0, _xbee_cmd_modem_status, NULL } 707 #define XBEE_FRAME_HANDLE_REMOTE_AT \ 708 { XBEE_FRAME_REMOTE_AT_RESPONSE, 0, _xbee_cmd_handle_response, NULL } 729 #define xbee_zcl_identify( xbee) \ 730 xbee_identify( xbee, zcl_identify_isactive() > 0) unsigned long uint32_t
32-bit unsigned integer
Definition: platform_config.h:43
Transmit failed.
Definition: atcmd.h:313
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.
Definition: xbee_atcmd.c:1117
uint8_t frame_type
First byte of header determines type (local or remote).
Definition: atcmd.h:388
FAR xbee_cmd_request_t xbee_cmd_request_table[XBEE_CMD_REQUEST_TABLESIZE]
Table used to keep track of outstanding requests.
Definition: xbee_atcmd.c:66
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.
Definition: xbee_atcmd.c:1312
xbee_command_list_status
Status codes for xbee_cmd_list_status()
Definition: atcmd.h:434
uint8_t frame_id
frame_id of last request sent
Definition: atcmd.h:232
#define FAR
On platforms with "far" pointers, define to the proper keyword; empty definition if not required...
Definition: platform.h:396
Copy response data byte-for-byte to base struct,.
Definition: atcmd.h:465
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...
Definition: xbee_atcmd.c:766
int xbee_cmd_tick(void)
This function should be called periodically (at least every few seconds) to expire old entries from t...
Definition: xbee_atcmd.c:80
uint16_t index
Where we are in the command list (index of last entry submitted).
Definition: atcmd.h:456
xbee_at_cmd_t command
command to send
Definition: atcmd.h:240
xbee_frame_local_at_resp_t local
Use if .frame_type is XBEE_FRAME_LOCAL_AT_RESPONSE.
Definition: atcmd.h:391
Datatype used for passing and storing XBee AT Commands.
Definition: atcmd.h:54
Set value to immediate 8-bit constant in .bytes field of the xbee_atcmd_reg_t entry.
Definition: atcmd.h:479
Copy response, changing expected big-endian to host byte order, and store in base struct...
Definition: atcmd.h:469
Success.
Definition: atcmd.h:309
#define XBEE_BEGIN_DECLS
Macro defined to.
Definition: platform.h:41
Entry for table of XBee registers to query at startup.
Definition: atcmd.h:493
xbee_frame_remote_at_resp_t remote
Use if .frame_type is XBEE_FRAME_REMOTE_AT_RESPONSE.
Definition: atcmd.h:394
This structure is used to keep track of outstanding local and remote AT requests. ...
Definition: atcmd.h:178
#define EIO
input/output error (POSIX.1)
Definition: platform.h:100
int(* xbee_cmd_callback_fn)(const xbee_cmd_response_t FAR *response)
Callback registered to an AT Command with xbee_cmd_set_callback().
Definition: atcmd.h:170
ATTO bit not set.
Definition: atcmd.h:316
int xbee_cmd_set_command(int16_t handle, const char FAR command[3])
Change the command associated with a request.
Definition: xbee_atcmd.c:1011
#define ETIMEDOUT
connection timed out (POSIX.1)
Definition: platform.h:124
uint32_t value
The value sent with the response, if any, in host byte order.
Definition: atcmd.h:134
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 X...
Definition: xbee_atcmd.c:1849
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 ...
Definition: xbee_atcmd.c:1827
enum xbee_command_list_status() xbee_cmd_list_status(xbee_command_list_context_t FAR *clc)
Determine status of command list execution.
Definition: xbee_atcmd.c:520
No default action. Often used for callbacks.
Definition: atcmd.h:461
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...
Definition: xbee_atcmd.c:1704
Use data in base struct as parameter for command, with null-terminated string data copied byte-for-by...
Definition: atcmd.h:474
xbee_cmd_request_t FAR * _xbee_cmd_handle_to_address(int16_t handle)
Definition: xbee_atcmd.c:169
int16_t xbee_cmd_create(xbee_dev_t *xbee, const char FAR command[3])
Allocate an AT Command request.
Definition: xbee_atcmd.c:870
int xbee_cmd_release_handle(int16_t handle)
Release an entry from the request table by marking it as available.
Definition: xbee_atcmd.c:986
uint16_t flags
combination of XBEE_CMD_FLAG_* macros
Definition: atcmd.h:191
The RSSI field of the ATND response is not valid [DigiMesh].
Definition: atcmd.h:319
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 resp...
Definition: xbee_atcmd.c:1769
xbee_command_list_fn callback
Callback function to be invoked when this command receives a response.
Definition: atcmd.h:502
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.
Definition: xbee_atcmd.c:475
xbee_command_list_type
Definition: atcmd.h:460
unsigned short uint16_t
16-bit unsigned integer
Definition: platform_config.h:41
const wpan_address_t FAR * source
Source of the response (NULL if a local AT command response)
Definition: atcmd.h:137
#define EBUSY
device or resource busy (POSIX.1)
Definition: platform.h:103
void(* xbee_command_list_fn)(const xbee_cmd_response_t FAR *response, const struct xbee_atcmd_reg_t FAR *reg, void FAR *base)
Callback registered for individual command list commands.
Definition: atcmd.h:423
unsigned char uint8_t
8-bit unsigned integer
Definition: platform_config.h:39
Single structure to hold an 802.15.4 device's 64-bit IEEE/MAC address and 16-bit network address...
Definition: types.h:98
int xbee_cmd_query_status(xbee_dev_t *xbee)
Check the status of querying an XBee device, as initiated by xbee_cmd_query_device().
Definition: xbee_atcmd.c:827
xbee_cmd_callback_fn callback
function to pass responses to
Definition: atcmd.h:226
Context data passed to command list processor.
Definition: atcmd.h:448
uint8_t flags
Option flags (meaningful to callback)
Definition: atcmd.h:495
#define XBEE_CMD_REQUEST_TABLESIZE
Maximum number of outstanding requests.
Definition: atcmd.h:30
int16_t handle
The handle to the request that generated this response.
Definition: atcmd.h:86
const uint8_t FAR * value_bytes
The value sent with the response; contains .value_length bytes.
Definition: atcmd.h:130
uint16_t timeout
expire entry if XBEE_CHECK_TIMEOUT_SEC(timeout) is true
Definition: atcmd.h:188
Mask to ignore extra bits used in the status response.
Definition: atcmd.h:307
Structure used to pass AT Command responses to registered callback handlers.
Definition: atcmd.h:74
int xbee_cmd_clear_flags(int16_t handle, uint16_t flags)
Clear the flags for a given AT Command request.
Definition: xbee_atcmd.c:1235
Use data in base struct as parameter for command, with binary data copied byte-for-byte.
Definition: atcmd.h:472
Last command, any response is discarded, no further command list entries are processed.
Definition: atcmd.h:481
int _xbee_cmd_release_request(xbee_cmd_request_t FAR *request)
Release an entry from the request table by marking it as available.
Definition: xbee_atcmd.c:958
Useful typedef for casting either a local or remote response frame.
Definition: atcmd.h:386
Response to an AT Command sent to a remote XBee.
Definition: atcmd.h:383
Bad Parameter.
Definition: atcmd.h:312
#define XBEE_CMD_MAX_PARAM_LENGTH
Maximum number of bytes in the parameter sent to a command.
Definition: atcmd.h:40
void FAR * context
Context registered with callback in call to xbee_cmd_set_callback().
Definition: atcmd.h:81
uint8_t bytes
number of bytes in response to copy or, for .type == XBEE_CLT_SET_8, is value to set.
Definition: atcmd.h:503
short int16_t
16-bit signed integer
Definition: platform_config.h:40
Typedef used to hold a 64-bit IEEE address, represented as 8 bytes, 4 16-bit values or 2 32-bit value...
Definition: types.h:34
Use data in base struct as parameter for command, changing host byte order to big-endian.
Definition: atcmd.h:476
Error.
Definition: atcmd.h:310
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)...
Definition: xbee_atcmd.c:1369
int xbee_cmd_init_device(xbee_dev_t *xbee)
Initialize the AT Command layer for an XBee device.
Definition: xbee_atcmd.c:550
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...
Definition: xbee_atcmd.c:1507
void FAR * base
Pointer to base address of data to populate with command responses.
Definition: atcmd.h:452
int xbee_cmd_send(int16_t handle)
Send an AT Command to a local or remote XBee device.
Definition: xbee_atcmd.c:1406
Copy response data byte-for-byte to base struct, starting at offset 0 and setting remaining bytes to ...
Definition: atcmd.h:462
uint8_t param_length
number of bytes stored in .param[]
Definition: atcmd.h:223
uint16_t flags
Additional information about the response.
Definition: atcmd.h:110
#define XBEE_END_DECLS
Macro defined to.
Definition: platform.h:42
xbee_at_resp_status
Possible values of status byte in xbee_header_local_at_resp_t and xbee_frame_local_at_resp_t.
Definition: atcmd.h:305
uint8_t sequence
Rolling identifier used to prevent use of stale request indicies.
Definition: atcmd.h:181
const struct xbee_atcmd_reg_t FAR * list
Pointer to start of command list.
Definition: atcmd.h:450
Encryption Error.
Definition: atcmd.h:315
Response to an AT Command sent to the local serially-connected XBee.
Definition: atcmd.h:375
int xbee_cmd_set_param(int16_t handle, uint32_t value)
Set the parameter (up to 32-bits) for a given AT Command request.
Definition: xbee_atcmd.c:1274
xbee_dev_t * device
Device that sent this request – if we have a table for each XBee, this element isn't necessary...
Definition: atcmd.h:185
Bad Command.
Definition: atcmd.h:311
int bool_t
Variable that can hold 0 or 1, may be an int for speed purporses or uint8_t for size optimization...
Definition: platform_config.h:51
xbee_dev_t * device
Local XBee device that sent the local (or received the remote) response.
Definition: atcmd.h:77
uint_fast8_t value_length
Number of bytes in .value_bytes or zero if there wasn't a value sent with the response.
Definition: atcmd.h:125
int xbee_cmd_set_flags(int16_t handle, uint16_t flags)
Set the flags for a given AT Command request.
Definition: xbee_atcmd.c:1201
xbee_at_cmd_t command
command to send to XBee device
Definition: atcmd.h:494
No Session.
Definition: atcmd.h:314
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.
Definition: xbee_atcmd.c:1059
void FAR * context
context to pass to callback function
Definition: atcmd.h:229
xbee_at_cmd_t command
The AT Command (e.g., VR, NI) sent in the request that generated this response.
Definition: atcmd.h:90