This network stack was designed for use with XBee modules in API mode, but it is sometimes necessary to work with a module in AT mode (for example, performing DigiMesh firmware updates).
_xbee_atmode_debug int xbee_atmode_enter |
( |
xbee_dev_t * |
xbee | ) |
|
Attempt to enter AT command mode (delay 1 second, send +++, delay 1 second).
After calling xbee_atmode_enter(), you must continue to call xbee_atmode_tick() until it returns XBEE_MODE_COMMAND (successfully entered command mode) or XBEE_MODE_IDLE (failed to enter command mode).
- Parameters
-
- Return values
-
0 | Initiated sequence to enter command mode. |
-EINVAL | Invalid XBee device passed to function. |
- See also
- xbee_atmode_exit, xbee_atmode_tick
_xbee_atmode_debug int xbee_atmode_exit |
( |
xbee_dev_t * |
xbee | ) |
|
Leave AT command mode and return to idle mode.
XBee driver doesn't consider the XBee module to be in idle mode until xbee_atmode_tick() returns XBEE_MODE_IDLE.
- Parameters
-
- Return values
-
0 | Already in idle mode, or sent command to return to it. Call xbee_atmode_tick() until it returns XBEE_MODE_IDLE. |
-EINVAL | Invalid XBee device passed to function. |
-EBUSY | Can't exit until receipt of response from previous command. Call function again later. |
- See also
- xbee_atmode_enter, xbee_atmode_tick
_xbee_atmode_debug int xbee_atmode_read_response |
( |
xbee_dev_t * |
xbee, |
|
|
char FAR * |
response, |
|
|
int |
resp_size, |
|
|
int FAR * |
bytesread |
|
) |
| |
Non-blocking function reads response to request sent with xbee_atmode_send_request to an XBee device in AT Command Mode.
Reads up to trailing return () before returning success (0). Does not include trailing return in response.
Sample code for using this function:
4 *response = '\0'; // start with empty response
8 retval = xbee_atmode_read_response( xbee, response,
9 sizeof( response), &bytesread);
10 } while (retval == -EAGAIN);
13 printf( "error %d reading response\n", retval);
15 printf( "response is %s\n", response);
@param[in] xbee XBee device
@param[out] response Buffer to hold the response. Since this function
is non-blocking, and may require multiple calls to read the
entire response, the buffer is used to hold the partial
response until the XBee sends a return (\r).
@param[in] resp_size Size of response buffer passed in parameter 2.
@param[in,out] bytesread Pointer to an integer that is tracking the number
of bytes already read. Function will read new bytes starting at
\a &response[*bytesread] and will increment \a *bytesread for
every byte added to \a response.
If NULL, function will append new bytes to the end of
\a response.
@retval 0 received complete line
@retval -EINVAL Invalid parameter passed to function.
@retval -EPERM XBee isn't waiting for a response
@retval -ENOSPC buffer filled before "\r" received
@retval -EAGAIN haven't read entire response yet, call function again
@retval -ETIMEDOUT timed out waiting for response
@sa xbee_atmode_send_request
_xbee_atmode_debug int xbee_atmode_send_request |
( |
xbee_dev_t * |
xbee, |
|
|
const char FAR * |
command |
|
) |
| |
Send an AT request and wait for a response.
Automatically prepends the request with "AT" and adds the trailing carriage-return.
- Parameters
-
[in] | xbee | XBee device |
[in] | command | Command to send (without leading AT or trailing ) |
- Return values
-
0 | Command sent |
-EINVAL | Invalid parameter passed to function. |
-ENOSPC | Not enough room in transmit buffer to send request. |
- See also
- xbee_atmode_read_response
_xbee_atmode_debug int xbee_atmode_tick |
( |
xbee_dev_t * |
xbee | ) |
|
Advance the XBee device state machine when entering or exiting AT Command Mode or waiting for a response to a command.
- Parameters
-
- Return values
-
>=0 | Current state of XBee device. See the function help for xbee_mode for a list of modes. |
-EINVAL | Invalid XBee device passed to function. |
< | 0 Undocumented error. |
- See also
- xbee_atmode_enter, xbee_atmode_tick