IoT::XBee

class XBeeFrame

File Information

Library: IoT/XBee
Package: XBee
Header: IoT/XBee/XBeeFrame.h

Description

This class encapsulates a Digi XBee API frame.

Member Summary

Member Functions: checksum, data, dataSize, escape, frame, frameSize, init, operator =, read, swap, type, unescape

Enumerations

Anonymous

XBEE_MAX_FRAME_LENGTH = 1024

XBEE_MAX_DATA_LENGTH = XBEE_MAX_FRAME_LENGTH - 5

XBEE_FRAME_START_DELIM = 0x7E

FrameType

XBEE_FRAME_TRANSMIT_REQUEST_64BIT_ADDRESS = 0x00

XBEE_FRAME_TRANSMIT_REQUEST_16BIT_ADDRESS = 0x01

XBEE_FRAME_AT_COMMAND = 0x08

XBEE_FRAME_AT_COMMAND_QUEUE_PARAMETER_VALUE = 0x09

XBEE_FRAME_ZIGBEE_TRANSMIT_REQUEST = 0x10

XBEE_FRAME_EXPL_ADDR_ZIGBEE_COMMAND_FRAME = 0x11

XBEE_FRAME_REMOTE_AT_COMMAND_REQUEST = 0x17

XBEE_FRAME_CREATE_SOURCE_ROUTE = 0x21

XBEE_FRAME_RECEIVE_PACKET_64BIT_ADDRESS = 0x80

XBEE_FRAME_RECEIVE_PACKET_16BIT_ADDRESS = 0x81

XBEE_FRAME_RECEIVE_PACKET_64BIT_ADDRESS_IO = 0x82

XBEE_FRAME_RECEIVE_PACKET_16BIT_ADDRESS_IO = 0x83

XBEE_FRAME_AT_COMMAND_RESPONSE = 0x88

XBEE_FRAME_MODEM_STATUS = 0x8A

XBEE_FRAME_ZIGBEE_TRANSMIT_STATUS = 0x8B

XBEE_FRAME_TRANSMIT_STATUS = 0x89

XBEE_FRAME_ZIGBEE_RECEIVE_PACKET = 0x90

XBEE_FRAME_ZIGBEE_EXPLICIT_RX_INDICATOR = 0x91

XBEE_FRAME_ZIGBEE_IO_DATA_SAMPLE_RX_INDICATOR = 0x92

XBEE_FRAME_XBEE_SENSOR_READ_INDICATOR = 0x94

XBEE_FRAME_NODE_IDENTIFICATION_INDICATOR = 0x95

XBEE_FRAME_REMOTE_AT_COMMAND_RESPONSE = 0x97

XBEE_FRAME_OTA_FIRMWARE_UPDATE_STATUS = 0xA0

XBEE_FRAME_ROUTE_RECORD_INDICATOR = 0xA1

XBEE_FRAME_MANY_TO_ONE_ROUTE_REQUEST_INDICATOR = 0xA3

XBEE_FRAME_INVALID = 0xFF

ReadStatus

XBEE_FRAME_OK

XBEE_FRAME_NOT_ENOUGH_DATA

XBEE_FRAME_NOT_FOUND

Constructors

XBeeFrame

XBeeFrame();

Creates an empty XBeeFrame.

XBeeFrame

XBeeFrame(
    const XBeeFrame & other
);

Creates a XBeeFrame by copying another one.

XBeeFrame

XBeeFrame(
    FrameType frameType,
    const std::string & data
);

Creates a XBeeFrame of the given type, with the given frame data.

XBeeFrame

XBeeFrame(
    FrameType frameType,
    const char * data,
    std::size_t length
);

Creates a XBeeFrame of the given type, with the given frame data.

Destructor

~XBeeFrame

~XBeeFrame();

Destroys the XBeeFrame.

Member Functions

data inline

const char * data() const;

Returns a pointer to the frame data.

dataSize inline

std::size_t dataSize() const;

Returns the frame data size.

escape

void escape();

Escapes the frame, as required for AP=2 API mode.

When sending or receiving a UART data frame, specific data values must be escaped (flagged) so they do not interfere with the UART or UART data frame operation. To escape an interfering data byte, insert 0x7D and follow it with the byte to be escaped XOR’d with 0x20.

Data bytes that need to be escaped:

  • 0x7E – Frame Delimiter
  • 0x7D – Escape
  • 0x11 – XON
  • 0x13 – XOFF

frame inline

const char * frame() const;

Returns a pointer to the raw API frame.

frameSize inline

std::size_t frameSize() const;

Returns the raw frame size.

operator =

XBeeFrame & operator = (
    const XBeeFrame & other
);

Assignment operator.

read static

static ReadStatus read(
    XBeeFrame & frame,
    const char * buffer,
    std::size_t size
);

Attempts to read a frame from the given buffer.

Returns:

swap

void swap(
    XBeeFrame & other
);

Swaps the contents of the frame with another one.

type inline

FrameType type() const;

Returns the frame type.

unescape

void unescape();

Unescapes the frame, if AP=2 API mode is used.

See escape() for more information.

checksum protected inline

unsigned char checksum() const;

init protected

void init(
    FrameType frameType,
    const char * data,
    std::size_t length
);

Securely control IoT edge devices from anywhere   Connect a Device