3.4.14. xbee — XBee

An XBee is a module for wireless communication.

../../../_images/xbee-s2c-zigbee.jpg

This driver implements reception and transmission of frames over a channel (normally a UART driver).

Known limitations:

  • Only AP=2 is supported. That is, API operation with escaped charaters. AP=1 could easily be implemented.

Manufacturer homepage: https://www.digi.com/


Source code: src/drivers/network/xbee.h, src/drivers/network/xbee.c

Test code: tst/drivers/software/network/xbee/main.c

Test coverage: src/drivers/network/xbee.c

Example code: examples/xbee/main.c


Defines

XBEE_DATA_MAX
XBEE_FRAME_ID_NO_ACK
XBEE_FRAME_TYPE_TX_REQUEST_64_BIT_ADDRESS
XBEE_FRAME_TYPE_TX_REQUEST_16_BIT_ADDRESS
XBEE_FRAME_TYPE_AT_COMMAND
XBEE_FRAME_TYPE_AT_COMMAND_QUEUE_PARAMETER_VALUE
XBEE_FRAME_TYPE_ZIGBEE_TRANSMIT_REQUEST
XBEE_FRAME_TYPE_EXPLICIT_ADDRESSING_ZIGBEE_COMMAND_FRAME
XBEE_FRAME_TYPE_REMOTE_COMMAND_REQUEST
XBEE_FRAME_TYPE_CREATE_SOURCE_ROUTE
XBEE_FRAME_TYPE_RX_PACKET_64_BIT_ADDRESS
XBEE_FRAME_TYPE_RX_PACKET_16_BIT_ADDRESS
XBEE_FRAME_TYPE_RX_PACKET_64_BIT_ADDRESS_IO
XBEE_FRAME_TYPE_RX_PACKET_16_BIT_ADDRESS_IO
XBEE_FRAME_TYPE_AT_COMMAND_RESPONSE
XBEE_FRAME_TYPE_TX_STATUS
XBEE_FRAME_TYPE_MODEM_STATUS
XBEE_FRAME_TYPE_ZIGBEE_TRANSMIT_STATUS
XBEE_FRAME_TYPE_ZIGBEE_RECEIVE_PACKET_AO_0
XBEE_FRAME_TYPE_ZIGBEE_EXPLICIT_RX_INDICATOR_AO_1
XBEE_FRAME_TYPE_ZIGBEE_IO_DATA_SAMPLE_RX_INDICATOR
XBEE_FRAME_TYPE_XBEE_SENSOR_READ_INDICATOR_AO_0
XBEE_FRAME_TYPE_NODE_IDENTIFICATION_INDICATOR_AO_0
XBEE_FRAME_TYPE_REMOTE_COMMAND_RESPONSE
XBEE_FRAME_TYPE_EXTENDED_MODEM_STATUS
XBEE_FRAME_TYPE_OVER_THE_AIR_FIRMWARE_UPDATE_STATUS
XBEE_FRAME_TYPE_ROUTE_RECORD_INDICATOR
XBEE_FRAME_TYPE_MANY_TO_ONE_ROUTE_REQUEST_INDICATOR
XBEE_PIN_DIO0
XBEE_PIN_DIO1
XBEE_PIN_DIO2
XBEE_PIN_DIO3
XBEE_PIN_DIO4
XBEE_PIN_DIO5
XBEE_PIN_DIO6
XBEE_PIN_DIO7
XBEE_PIN_DIO8
XBEE_PIN_AD0
XBEE_PIN_AD1
XBEE_PIN_AD2
XBEE_PIN_AD3
XBEE_PIN_MODE_DISABLED
XBEE_PIN_MODE_ADC
XBEE_PIN_MODE_INPUT
XBEE_PIN_MODE_OUTPUT_LOW
XBEE_PIN_MODE_OUTPUT_HIGH

Functions

int xbee_module_init(void)

Initialize the xbee module. This function must be called before calling any other function in this module.

The module will only be initialized once even if this function is called multiple times.

Return
zero(0) or negative error code.

int xbee_init(struct xbee_driver_t *self_p, void *chin_p, void *chout_p)

Initialize given driver object from given configuration.

Return
zero(0) or negative error code.
Parameters
  • self_p: Driver object to initialize.
  • chin_p: Input channel from the XBee module, often a UART driver.
  • chout_p: Output channel to the XBee module, often a UART driver output channel.

int xbee_read(struct xbee_driver_t *self_p, struct xbee_frame_t *frame_p)

Read a frame from the XBee module. Blocks until a frame is received or an error occurs.

Return
zero(0) or negative error code.
Parameters
  • self_p: Initialized driver object.
  • frame_p: Frame to read into.

int xbee_write(struct xbee_driver_t *self_p, const struct xbee_frame_t *frame_p)

Write given frame to the XBee module. Blocks until the frame have been transmitted or an error occurs.

Return
zero(0) or negative error code.
Parameters
  • self_p: Initialized driver object.
  • frame_p: Frame to write.

int xbee_print_frame(void *chan_p, struct xbee_frame_t *frame_p)

Decode given frame and write it as a human readable string to given channel.

Return
zero(0) or negative error code.
Parameters
  • chan_p: Channel to write the human readable string to.
  • frame_p: Frame to decode.

const char *xbee_frame_type_as_string(uint8_t frame_type)

Map given frame type to a human readable string.

Return
Human readable frame type string or NULL if given frame type is unknown.
Parameters
  • frame_type: Frame type.

const char *xbee_tx_status_as_string(uint8_t tx_status)

Map given TX status to a human readable string.

Return
Human readable TX status string or NULL if given TX status is unknown.
Parameters
  • tx_status: TX status.

const char *xbee_modem_status_as_string(uint8_t modem_status)

Map given modem status to a human readable string.

Return
Human readable modem status string or NULL if given modem status is unknown.
Parameters
  • modem_status: Modem status.

const char *xbee_at_command_response_status_as_string(uint8_t response_status)

Map given AT command response status to a human readable string.

Return
Human readable AT command response status string or NULL if given response status is unknown.
Parameters
  • response_status: AT command response status.

struct xbee_frame_t

Public Members

uint8_t type
uint8_t buf[XBEE_DATA_MAX]
size_t size
struct xbee_frame_t::@16 xbee_frame_t::data
struct xbee_driver_t

Public Members

struct chan_t *chin_p
struct chan_t *chout_p
struct xbee_driver_t::@17 xbee_driver_t::transport