High-level driver for the XBee S1 802.15.4 modem. More...

Detailed Description

High-level driver for the XBee S1 802.15.4 modem.

Files

file  xbee.h
 High-level driver for the XBee S1 802.15.4 modem.
 
file  xbee_params.h
 Default configuration for XBee devices.
 

Data Structures

struct  xbee_params_t
 Configuration parameters for XBee devices. More...
 
struct  xbee_t
 XBee device descriptor. More...
 
struct  xbee_l2hdr_t
 Data structure for extraction L2 information of received packets. More...
 

Macros

#define XBEE_MAX_PAYLOAD_LENGTH   (100U)
 Maximum payload length that can be send.
 
#define XBEE_MAX_PKT_LENGTH   (115U)
 Maximum packet length, including XBee API frame overhead.
 
#define XBEE_MAX_RESP_LENGTH   (16U)
 Maximum length of a command response.
 
#define XBEE_MAX_TXHDR_LENGTH   (14U)
 Maximal possible size of a TX header.
 
#define XBEE_DEFAULT_PROTOCOL   (GNRC_NETTYPE_SIXLOWPAN)
 Default protocol for data that is coming in.
 
#define XBEE_DEFAULT_PANID   (CONFIG_IEEE802154_DEFAULT_PANID)
 Default PAN ID used after initialization.
 
#define XBEE_DEFAULT_CHANNEL   (CONFIG_IEEE802154_DEFAULT_CHANNEL)
 Default channel used after initialization.
 

Enumerations

enum  xbee_rx_state_t {
  XBEE_INT_STATE_IDLE, XBEE_INT_STATE_SIZE1, XBEE_INT_STATE_SIZE2, XBEE_INT_STATE_TYPE,
  XBEE_INT_STATE_RESP, XBEE_INT_STATE_RX
}
 States of the internal FSM for handling incoming UART frames. More...
 

Functions

void xbee_setup (xbee_t *dev, const xbee_params_t *params)
 Prepare the given Xbee device. More...
 
int xbee_build_hdr (xbee_t *dev, uint8_t *xhdr, size_t payload_len, void *dst_addr, size_t addr_len)
 Put together the internal proprietary XBee header. More...
 
int xbee_parse_hdr (xbee_t *dev, const uint8_t *xhdr, xbee_l2hdr_t *l2hdr)
 Extract IEEE802.15.4 L2 header information from the XBee header. More...
 

Variables

const netdev_driver_t xbee_driver
 Reference to the XBee driver interface.
 

Address flags

#define XBEE_ADDR_FLAGS_LONG   (0x80)
 Use long addresses if not otherwise defined when set, use short addresses when unset.
 

Enumeration Type Documentation

◆ xbee_rx_state_t

States of the internal FSM for handling incoming UART frames.

Incoming data frames on the UART interfaces are handled using a finite state machine (FSM) in the UARTs RX interrupt handler. The FSM is needed to extract frame specific data as the frame size, frame type, and checksums.

Enumerator
XBEE_INT_STATE_IDLE 

waiting for the beginning of a new frame

XBEE_INT_STATE_SIZE1 

waiting for the first byte (MSB) of the frame size field

XBEE_INT_STATE_SIZE2 

waiting for the second byte (LSB) of the frame size field

XBEE_INT_STATE_TYPE 

waiting for the frame type field

XBEE_INT_STATE_RESP 

handling incoming data for AT command responses

XBEE_INT_STATE_RX 

handling incoming data when receiving radio packets

Definition at line 101 of file xbee.h.

Function Documentation

◆ xbee_build_hdr()

int xbee_build_hdr ( xbee_t dev,
uint8_t *  xhdr,
size_t  payload_len,
void *  dst_addr,
size_t  addr_len 
)

Put together the internal proprietary XBee header.

Parameters
[in]devXbee device to initialize
[out]xhdrbuffer to write the header into, MUST be at least of length XBEE_MAX_TXHDR_LENGTH
[in]payload_lenactual payload length (without the XBee header)
[in]dst_addrlink layer (L2) destination address
[in]addr_lenlength of dst_addr in byte (MUST be 2 or 8)
Returns
the length of the created header in byte
-EOVERFLOW if payload_len is greater than XBEE_MAX_PAYLOAD_LENGTH
-ENOMSG if the given destination address has an invalid length

◆ xbee_parse_hdr()

int xbee_parse_hdr ( xbee_t dev,
const uint8_t *  xhdr,
xbee_l2hdr_t l2hdr 
)

Extract IEEE802.15.4 L2 header information from the XBee header.

Parameters
[in]devXbee device to initialize
[in]xhdrXBee header, starting with the API identifier
[out]l2hdrthe L2 header information is written here
Returns
the length of the XBee header
-ENOMST if the given XBee header is invalid

◆ xbee_setup()

void xbee_setup ( xbee_t dev,
const xbee_params_t params 
)

Prepare the given Xbee device.

Parameters
[out]devXbee device to initialize
[in]paramsparameters for device initialization
Returns
0 on success
-ENODEV on invalid device descriptor
-ENXIO on invalid UART or GPIO pins