digi.xbee.packets.common module

class digi.xbee.packets.common.ATCommPacket(frame_id, command, parameter=None)[source]

Bases: digi.xbee.packets.base.XBeeAPIPacket

This class represents an AT command packet.

Used to query or set module parameters on the local device. This API command applies changes after executing the command. (Changes made to module parameters take effect once changes are applied.).

Command response is received as an ATCommResponsePacket.

Class constructor. Instantiates a new ATCommPacket object with the provided parameters.

Parameters
  • frame_id (Integer) – the frame ID of the packet.

  • command (String) – the AT command of the packet. Must be a string.

  • parameter (Bytearray, optional) – the AT command parameter. Optional.

Raises
  • ValueError – if frame_id is less than 0 or greater than 255.

  • ValueError – if length of command is different from 2.

See also

static create_packet(raw, operating_mode)[source]

Override method.

Returns

ATCommPacket

Raises

See also

XBeeAPIPacket._check_api_packet()
needs_id()[source]

Override method.

property command

Returns the AT command of the packet.

Returns

the AT command of the packet.

Return type

String

property parameter

Returns the parameter of the packet.

Returns

the parameter of the packet.

Return type

Bytearray

property frame_id

Returns the frame ID of the packet.

Returns

the frame ID of the packet.

Return type

Integer

get_checksum()

Returns the checksum value of this XBeePacket. The checksum is the last 8 bits of the sum of the bytes between the length field and the checksum field.

Returns

checksum value of this XBeePacket.

Return type

Integer

See also

get_frame_spec_data()

Override method.

get_frame_type()

Returns the frame type of this packet.

Returns

the frame type of this packet.

Return type

ApiFrameType

See also

get_frame_type_value()

Returns the frame type integer value of this packet.

Returns

the frame type integer value of this packet.

Return type

Integer

See also

is_broadcast()

Returns whether this packet is broadcast or not.

Returns

True if this packet is broadcast, False otherwise.

Return type

Boolean

output(escaped=False)

Returns the raw bytearray of this XBeePacket, ready to be send by the serial port.

Parameters

escaped (Boolean) – indicates if the raw bytearray must be escaped.

Returns

raw bytearray of the XBeePacket.

Return type

Bytearray

to_dict()

Returns a dictionary with all information of the XBeePacket fields.

Returns

dictionary with all info of the XBeePacket fields.

Return type

Dictionary

static unescape_data(data)

Un-escapes the provided bytearray data.

Parameters

data (Bytearray) – the bytearray to unescape.

Returns

data unescaped.

Return type

Bytearray

class digi.xbee.packets.common.ATCommQueuePacket(frame_id, command, parameter=None)[source]

Bases: digi.xbee.packets.base.XBeeAPIPacket

This class represents an AT command Queue packet.

Used to query or set module parameters on the local device.

In contrast to the ATCommPacket API packet, new parameter values are queued and not applied until either an ATCommPacket is sent or the applyChanges() method of the XBeeDevice class is issued.

Command response is received as an ATCommResponsePacket.

Class constructor. Instantiates a new ATCommQueuePacket object with the provided parameters.

Parameters
  • frame_id (Integer) – the frame ID of the packet.

  • command (String) – the AT command of the packet. Must be a string.

  • parameter (Bytearray, optional) – the AT command parameter. Optional.

Raises
  • ValueError – if frame_id is less than 0 or greater than 255.

  • ValueError – if length of command is different from 2.

See also

static create_packet(raw, operating_mode)[source]

Override method.

Returns

ATCommQueuePacket

Raises

See also

XBeeAPIPacket._check_api_packet()
needs_id()[source]

Override method.

property command

Returns the AT command of the packet.

Returns

the AT command of the packet.

Return type

String

property parameter

Returns the parameter of the packet.

Returns

the parameter of the packet.

Return type

Bytearray

property frame_id

Returns the frame ID of the packet.

Returns

the frame ID of the packet.

Return type

Integer

get_checksum()

Returns the checksum value of this XBeePacket. The checksum is the last 8 bits of the sum of the bytes between the length field and the checksum field.

Returns

checksum value of this XBeePacket.

Return type

Integer

See also

get_frame_spec_data()

Override method.

get_frame_type()

Returns the frame type of this packet.

Returns

the frame type of this packet.

Return type

ApiFrameType

See also

get_frame_type_value()

Returns the frame type integer value of this packet.

Returns

the frame type integer value of this packet.

Return type

Integer

See also

is_broadcast()

Returns whether this packet is broadcast or not.

Returns

True if this packet is broadcast, False otherwise.

Return type

Boolean

output(escaped=False)

Returns the raw bytearray of this XBeePacket, ready to be send by the serial port.

Parameters

escaped (Boolean) – indicates if the raw bytearray must be escaped.

Returns

raw bytearray of the XBeePacket.

Return type

Bytearray

to_dict()

Returns a dictionary with all information of the XBeePacket fields.

Returns

dictionary with all info of the XBeePacket fields.

Return type

Dictionary

static unescape_data(data)

Un-escapes the provided bytearray data.

Parameters

data (Bytearray) – the bytearray to unescape.

Returns

data unescaped.

Return type

Bytearray

class digi.xbee.packets.common.ATCommResponsePacket(frame_id, command, response_status=<ATCommandStatus.OK: (0, 'Status OK')>, comm_value=None)[source]

Bases: digi.xbee.packets.base.XBeeAPIPacket

This class represents an AT command response packet.

In response to an AT command message, the module will send an AT command response message. Some commands will send back multiple frames (for example, the ND - Node Discover command).

This packet is received in response of an ATCommPacket.

Response also includes an ATCommandStatus object with the status of the AT command.

Class constructor. Instantiates a new ATCommResponsePacket object with the provided parameters.

Parameters
  • frame_id (Integer) – the frame ID of the packet. Must be between 0 and 255.

  • command (String) – the AT command of the packet. Must be a string.

  • response_status (ATCommandStatus or Integer) – the status of the AT command.

  • comm_value (Bytearray, optional) – the AT command response value. Optional.

Raises
  • ValueError – if frame_id is less than 0 or greater than 255.

  • ValueError – if length of command is different from 2.

static create_packet(raw, operating_mode)[source]

Override method.

Returns

ATCommResponsePacket

Raises

See also

XBeeAPIPacket._check_api_packet()
needs_id()[source]

Override method.

property command

Returns the AT command of the packet.

Returns

the AT command of the packet.

Return type

String

property command_value

Returns the AT command response value.

Returns

the AT command response value.

Return type

Bytearray

property real_status

Returns the AT command response status of the packet.

Returns

the AT command response status of the packet.

Return type

Integer

property status

Returns the AT command response status of the packet.

Returns

the AT command response status of the packet.

Return type

ATCommandStatus

See also

property frame_id

Returns the frame ID of the packet.

Returns

the frame ID of the packet.

Return type

Integer

get_checksum()

Returns the checksum value of this XBeePacket. The checksum is the last 8 bits of the sum of the bytes between the length field and the checksum field.

Returns

checksum value of this XBeePacket.

Return type

Integer

See also

get_frame_spec_data()

Override method.

get_frame_type()

Returns the frame type of this packet.

Returns

the frame type of this packet.

Return type

ApiFrameType

See also

get_frame_type_value()

Returns the frame type integer value of this packet.

Returns

the frame type integer value of this packet.

Return type

Integer

See also

is_broadcast()

Returns whether this packet is broadcast or not.

Returns

True if this packet is broadcast, False otherwise.

Return type

Boolean

output(escaped=False)

Returns the raw bytearray of this XBeePacket, ready to be send by the serial port.

Parameters

escaped (Boolean) – indicates if the raw bytearray must be escaped.

Returns

raw bytearray of the XBeePacket.

Return type

Bytearray

to_dict()

Returns a dictionary with all information of the XBeePacket fields.

Returns

dictionary with all info of the XBeePacket fields.

Return type

Dictionary

static unescape_data(data)

Un-escapes the provided bytearray data.

Parameters

data (Bytearray) – the bytearray to unescape.

Returns

data unescaped.

Return type

Bytearray

class digi.xbee.packets.common.ReceivePacket(x64bit_addr, x16bit_addr, receive_options, rf_data=None)[source]

Bases: digi.xbee.packets.base.XBeeAPIPacket

This class represents a receive packet. Packet is built using the parameters of the constructor or providing a valid byte array.

When the module receives an RF packet, it is sent out the UART using this message type.

This packet is received when external devices send transmit request packets to this module.

Among received data, some options can also be received indicating transmission parameters.

Class constructor. Instantiates a new ReceivePacket object with the provided parameters.

Parameters
  • x64bit_addr (XBee64BitAddress) – the 64-bit source address.

  • x16bit_addr (XBee16BitAddress) – the 16-bit source address.

  • receive_options (Integer) – bitfield indicating the receive options.

  • rf_data (Bytearray, optional) – received RF data. Optional.

static create_packet(raw, operating_mode)[source]

Override method.

Returns

ATCommResponsePacket

Raises

See also

XBeeAPIPacket._check_api_packet()
needs_id()[source]

Override method.

is_broadcast()[source]

Override method.

See also

XBeeAPIPacket.is_broadcast()
property x64bit_source_addr

Returns the 64-bit source address.

Returns

the 64-bit source address.

Return type

XBee64BitAddress

See also

property x16bit_source_addr

Returns the 16-bit source address.

Returns

the 16-bit source address.

Return type

XBee16BitAddress

See also

property receive_options

Returns the receive options bitfield.

Returns

the receive options bitfield.

Return type

Integer

See also

property rf_data

Returns the received RF data.

Returns

the received RF data.

Return type

Bytearray

property frame_id

Returns the frame ID of the packet.

Returns

the frame ID of the packet.

Return type

Integer

get_checksum()

Returns the checksum value of this XBeePacket. The checksum is the last 8 bits of the sum of the bytes between the length field and the checksum field.

Returns

checksum value of this XBeePacket.

Return type

Integer

See also

get_frame_spec_data()

Override method.

get_frame_type()

Returns the frame type of this packet.

Returns

the frame type of this packet.

Return type

ApiFrameType

See also

get_frame_type_value()

Returns the frame type integer value of this packet.

Returns

the frame type integer value of this packet.

Return type

Integer

See also

output(escaped=False)

Returns the raw bytearray of this XBeePacket, ready to be send by the serial port.

Parameters

escaped (Boolean) – indicates if the raw bytearray must be escaped.

Returns

raw bytearray of the XBeePacket.

Return type

Bytearray

to_dict()

Returns a dictionary with all information of the XBeePacket fields.

Returns

dictionary with all info of the XBeePacket fields.

Return type

Dictionary

static unescape_data(data)

Un-escapes the provided bytearray data.

Parameters

data (Bytearray) – the bytearray to unescape.

Returns

data unescaped.

Return type

Bytearray

class digi.xbee.packets.common.RemoteATCommandPacket(frame_id, x64bit_addr, x16bit_addr, transmit_options, command, parameter=None)[source]

Bases: digi.xbee.packets.base.XBeeAPIPacket

This class represents a Remote AT command Request packet. Packet is built using the parameters of the constructor or providing a valid byte array.

Used to query or set module parameters on a remote device. For parameter changes on the remote device to take effect, changes must be applied, either by setting the apply changes options bit, or by sending an AC command to the remote node.

Remote command options are set as a bitfield.

If configured, command response is received as a RemoteATCommandResponsePacket.

Class constructor. Instantiates a new RemoteATCommandPacket object with the provided parameters.

Parameters
  • frame_id (integer) – the frame ID of the packet.

  • x64bit_addr (XBee64BitAddress) – the 64-bit destination address.

  • x16bit_addr (XBee16BitAddress) – the 16-bit destination address.

  • transmit_options (Integer) – bitfield of supported transmission options.

  • command (String) – AT command to send.

  • parameter (Bytearray, optional) – AT command parameter. Optional.

Raises
  • ValueError – if frame_id is less than 0 or greater than 255.

  • ValueError – if length of command is different from 2.

static create_packet(raw, operating_mode)[source]

Override method.

Returns

RemoteATCommandPacket

Raises

See also

XBeeAPIPacket._check_api_packet()
needs_id()[source]

Override method.

property x64bit_dest_addr

Returns the 64-bit destination address.

Returns

the 64-bit destination address.

Return type

XBee64BitAddress

See also

property x16bit_dest_addr

Returns the 16-bit destination address.

Returns

the 16-bit destination address.

Return type

XBee16BitAddress

See also

property transmit_options

Returns the transmit options bitfield.

Returns

the transmit options bitfield.

Return type

Integer

property parameter

Returns the AT command parameter.

Returns

the AT command parameter.

Return type

Bytearray

property command

Returns the AT command.

Returns

the AT command.

Return type

String

property frame_id

Returns the frame ID of the packet.

Returns

the frame ID of the packet.

Return type

Integer

get_checksum()

Returns the checksum value of this XBeePacket. The checksum is the last 8 bits of the sum of the bytes between the length field and the checksum field.

Returns

checksum value of this XBeePacket.

Return type

Integer

See also

get_frame_spec_data()

Override method.

get_frame_type()

Returns the frame type of this packet.

Returns

the frame type of this packet.

Return type

ApiFrameType

See also

get_frame_type_value()

Returns the frame type integer value of this packet.

Returns

the frame type integer value of this packet.

Return type

Integer

See also

is_broadcast()

Returns whether this packet is broadcast or not.

Returns

True if this packet is broadcast, False otherwise.

Return type

Boolean

output(escaped=False)

Returns the raw bytearray of this XBeePacket, ready to be send by the serial port.

Parameters

escaped (Boolean) – indicates if the raw bytearray must be escaped.

Returns

raw bytearray of the XBeePacket.

Return type

Bytearray

to_dict()

Returns a dictionary with all information of the XBeePacket fields.

Returns

dictionary with all info of the XBeePacket fields.

Return type

Dictionary

static unescape_data(data)

Un-escapes the provided bytearray data.

Parameters

data (Bytearray) – the bytearray to unescape.

Returns

data unescaped.

Return type

Bytearray

class digi.xbee.packets.common.RemoteATCommandResponsePacket(frame_id, x64bit_addr, x16bit_addr, command, response_status, comm_value=None)[source]

Bases: digi.xbee.packets.base.XBeeAPIPacket

This class represents a remote AT command response packet. Packet is built using the parameters of the constructor or providing a valid byte array.

If a module receives a remote command response RF data frame in response to a remote AT command request, the module will send a remote AT command response message out the UART. Some commands may send back multiple frames, for example, Node Discover (ND) command.

This packet is received in response of a RemoteATCommandPacket.

Response also includes an object with the status of the AT command.

Class constructor. Instantiates a new RemoteATCommandResponsePacket object with the provided parameters.

Parameters
  • frame_id (Integer) – the frame ID of the packet.

  • x64bit_addr (XBee64BitAddress) – the 64-bit source address

  • x16bit_addr (XBee16BitAddress) – the 16-bit source address.

  • command (String) – the AT command of the packet. Must be a string.

  • response_status (ATCommandStatus or Integer) – the status of the AT command.

  • comm_value (Bytearray, optional) – the AT command response value. Optional.

Raises
  • ValueError – if frame_id is less than 0 or greater than 255.

  • ValueError – if length of command is different from 2.

static create_packet(raw, operating_mode)[source]

Override method.

Returns

RemoteATCommandResponsePacket.

Raises

See also

XBeeAPIPacket._check_api_packet()
needs_id()[source]

Override method.

property command

Returns the AT command of the packet.

Returns

the AT command of the packet.

Return type

String

property command_value

Returns the AT command response value.

Returns

the AT command response value.

Return type

Bytearray

property real_status

Returns the AT command response status of the packet.

Returns

the AT command response status of the packet.

Return type

Integer

property status

Returns the AT command response status of the packet.

Returns

the AT command response status of the packet.

Return type

ATCommandStatus

See also

property x64bit_source_addr

Returns the 64-bit source address.

Returns

the 64-bit source address.

Return type

XBee64BitAddress

See also

property x16bit_source_addr

Returns the 16-bit source address.

Returns

the 16-bit source address.

Return type

XBee16BitAddress

See also

property frame_id

Returns the frame ID of the packet.

Returns

the frame ID of the packet.

Return type

Integer

get_checksum()

Returns the checksum value of this XBeePacket. The checksum is the last 8 bits of the sum of the bytes between the length field and the checksum field.

Returns

checksum value of this XBeePacket.

Return type

Integer

See also

get_frame_spec_data()

Override method.

get_frame_type()

Returns the frame type of this packet.

Returns

the frame type of this packet.

Return type

ApiFrameType

See also

get_frame_type_value()

Returns the frame type integer value of this packet.

Returns

the frame type integer value of this packet.

Return type

Integer

See also

is_broadcast()

Returns whether this packet is broadcast or not.

Returns

True if this packet is broadcast, False otherwise.

Return type

Boolean

output(escaped=False)

Returns the raw bytearray of this XBeePacket, ready to be send by the serial port.

Parameters

escaped (Boolean) – indicates if the raw bytearray must be escaped.

Returns

raw bytearray of the XBeePacket.

Return type

Bytearray

to_dict()

Returns a dictionary with all information of the XBeePacket fields.

Returns

dictionary with all info of the XBeePacket fields.

Return type

Dictionary

static unescape_data(data)

Un-escapes the provided bytearray data.

Parameters

data (Bytearray) – the bytearray to unescape.

Returns

data unescaped.

Return type

Bytearray

class digi.xbee.packets.common.TransmitPacket(frame_id, x64bit_addr, x16bit_addr, broadcast_radius, transmit_options, rf_data=None)[source]

Bases: digi.xbee.packets.base.XBeeAPIPacket

This class represents a transmit request packet. Packet is built using the parameters of the constructor or providing a valid API byte array.

A transmit request API frame causes the module to send data as an RF packet to the specified destination.

The 64-bit destination address should be set to 0x000000000000FFFF for a broadcast transmission (to all devices).

The coordinator can be addressed by either setting the 64-bit address to 0x0000000000000000 and the 16-bit address to 0xFFFE, OR by setting the 64-bit address to the coordinator’s 64-bit address and the 16-bit address to 0x0000.

For all other transmissions, setting the 16-bit address to the correct 16-bit address can help improve performance when transmitting to multiple destinations.

If a 16-bit address is not known, this field should be set to 0xFFFE (unknown).

The transmit status frame ( ApiFrameType.TRANSMIT_STATUS) will indicate the discovered 16-bit address, if successful (see TransmitStatusPacket).

The broadcast radius can be set from 0 up to NH. If set to 0, the value of NH specifies the broadcast radius (recommended). This parameter is only used for broadcast transmissions.

The maximum number of payload bytes can be read with the NP command.

Several transmit options can be set using the transmit options bitfield.

Class constructor. Instantiates a new TransmitPacket object with the provided parameters.

Parameters
  • frame_id (integer) – the frame ID of the packet.

  • x64bit_addr (XBee64BitAddress) – the 64-bit destination address.

  • x16bit_addr (XBee16BitAddress) – the 16-bit destination address.

  • broadcast_radius (Integer) – maximum number of hops a broadcast transmission can occur.

  • transmit_options (Integer) – bitfield of supported transmission options.

  • rf_data (Bytearray, optional) – RF data that is sent to the destination device. Optional.

Raises

ValueError – if frame_id is less than 0 or greater than 255.

static create_packet(raw, operating_mode)[source]

Override method.

Returns

TransmitPacket.

Raises

See also

XBeeAPIPacket._check_api_packet()
needs_id()[source]

Override method.

property rf_data

Returns the RF data to send.

Returns

the RF data to send.

Return type

Bytearray

property transmit_options

Returns the transmit options bitfield.

Returns

the transmit options bitfield.

Return type

Integer

See also

property broadcast_radius

Returns the broadcast radius. Broadcast radius is the maximum number of hops a broadcast transmission.

Returns

the broadcast radius.

Return type

Integer

property x64bit_dest_addr

Returns the 64-bit destination address.

Returns

the 64-bit destination address.

Return type

XBee64BitAddress

See also

property x16bit_dest_addr

Returns the 16-bit destination address.

Returns

the 16-bit destination address.

Return type

XBee16BitAddress

See also

property frame_id

Returns the frame ID of the packet.

Returns

the frame ID of the packet.

Return type

Integer

get_checksum()

Returns the checksum value of this XBeePacket. The checksum is the last 8 bits of the sum of the bytes between the length field and the checksum field.

Returns

checksum value of this XBeePacket.

Return type

Integer

See also

get_frame_spec_data()

Override method.

get_frame_type()

Returns the frame type of this packet.

Returns

the frame type of this packet.

Return type

ApiFrameType

See also

get_frame_type_value()

Returns the frame type integer value of this packet.

Returns

the frame type integer value of this packet.

Return type

Integer

See also

is_broadcast()

Returns whether this packet is broadcast or not.

Returns

True if this packet is broadcast, False otherwise.

Return type

Boolean

output(escaped=False)

Returns the raw bytearray of this XBeePacket, ready to be send by the serial port.

Parameters

escaped (Boolean) – indicates if the raw bytearray must be escaped.

Returns

raw bytearray of the XBeePacket.

Return type

Bytearray

to_dict()

Returns a dictionary with all information of the XBeePacket fields.

Returns

dictionary with all info of the XBeePacket fields.

Return type

Dictionary

static unescape_data(data)

Un-escapes the provided bytearray data.

Parameters

data (Bytearray) – the bytearray to unescape.

Returns

data unescaped.

Return type

Bytearray

class digi.xbee.packets.common.TransmitStatusPacket(frame_id, x16bit_addr, transmit_retry_count, transmit_status=<TransmitStatus.SUCCESS: (0, 'Success')>, discovery_status=<DiscoveryStatus.NO_DISCOVERY_OVERHEAD: (0, 'No discovery overhead')>)[source]

Bases: digi.xbee.packets.base.XBeeAPIPacket

This class represents a transmit status packet. Packet is built using the parameters of the constructor or providing a valid raw byte array.

When a Transmit Request is completed, the module sends a transmit status message. This message will indicate if the packet was transmitted successfully or if there was a failure.

This packet is the response to standard and explicit transmit requests.

See also

Class constructor. Instantiates a new TransmitStatusPacket object with the provided parameters.

Parameters
  • frame_id (Integer) – the frame ID of the packet.

  • x16bit_addr (XBee16BitAddress) – 16-bit network address the packet was delivered to.

  • transmit_retry_count (Integer) – the number of application transmission retries that took place.

  • transmit_status (TransmitStatus, optional) – transmit status. Default: SUCCESS. Optional.

  • discovery_status (DiscoveryStatus, optional) – discovery status. Default: NO_DISCOVERY_OVERHEAD. Optional.

Raises

ValueError – if frame_id is less than 0 or greater than 255.

static create_packet(raw, operating_mode)[source]

Override method.

Returns

TransmitStatusPacket

Raises

See also

XBeeAPIPacket._check_api_packet()
needs_id()[source]

Override method.

property x16bit_dest_addr

Returns the 16-bit destination address.

Returns

the 16-bit destination address.

Return type

XBee16BitAddress

See also

property transmit_status

Returns the transmit status.

Returns

the transmit status.

Return type

TransmitStatus

See also

property transmit_retry_count

Returns the transmit retry count.

Returns

the transmit retry count.

Return type

Integer

property discovery_status

Returns the discovery status.

Returns

the discovery status.

Return type

DiscoveryStatus

See also

property frame_id

Returns the frame ID of the packet.

Returns

the frame ID of the packet.

Return type

Integer

get_checksum()

Returns the checksum value of this XBeePacket. The checksum is the last 8 bits of the sum of the bytes between the length field and the checksum field.

Returns

checksum value of this XBeePacket.

Return type

Integer

See also

get_frame_spec_data()

Override method.

get_frame_type()

Returns the frame type of this packet.

Returns

the frame type of this packet.

Return type

ApiFrameType

See also

get_frame_type_value()

Returns the frame type integer value of this packet.

Returns

the frame type integer value of this packet.

Return type

Integer

See also

is_broadcast()

Returns whether this packet is broadcast or not.

Returns

True if this packet is broadcast, False otherwise.

Return type

Boolean

output(escaped=False)

Returns the raw bytearray of this XBeePacket, ready to be send by the serial port.

Parameters

escaped (Boolean) – indicates if the raw bytearray must be escaped.

Returns

raw bytearray of the XBeePacket.

Return type

Bytearray

to_dict()

Returns a dictionary with all information of the XBeePacket fields.

Returns

dictionary with all info of the XBeePacket fields.

Return type

Dictionary

static unescape_data(data)

Un-escapes the provided bytearray data.

Parameters

data (Bytearray) – the bytearray to unescape.

Returns

data unescaped.

Return type

Bytearray

class digi.xbee.packets.common.ModemStatusPacket(modem_status)[source]

Bases: digi.xbee.packets.base.XBeeAPIPacket

This class represents a modem status packet. Packet is built using the parameters of the constructor or providing a valid API raw byte array.

RF module status messages are sent from the module in response to specific conditions and indicates the state of the modem in that moment.

See also

Class constructor. Instantiates a new ModemStatusPacket object with the provided parameters.

Parameters

modem_status (ModemStatus) – the modem status event.

static create_packet(raw, operating_mode)[source]

Override method.

Returns

ModemStatusPacket.

Raises

See also

XBeeAPIPacket._check_api_packet()
needs_id()[source]

Override method.

property modem_status

Returns the modem status event.

Returns

The modem status event.

Return type

ModemStatus

See also

property frame_id

Returns the frame ID of the packet.

Returns

the frame ID of the packet.

Return type

Integer

get_checksum()

Returns the checksum value of this XBeePacket. The checksum is the last 8 bits of the sum of the bytes between the length field and the checksum field.

Returns

checksum value of this XBeePacket.

Return type

Integer

See also

get_frame_spec_data()

Override method.

get_frame_type()

Returns the frame type of this packet.

Returns

the frame type of this packet.

Return type

ApiFrameType

See also

get_frame_type_value()

Returns the frame type integer value of this packet.

Returns

the frame type integer value of this packet.

Return type

Integer

See also

is_broadcast()

Returns whether this packet is broadcast or not.

Returns

True if this packet is broadcast, False otherwise.

Return type

Boolean

output(escaped=False)

Returns the raw bytearray of this XBeePacket, ready to be send by the serial port.

Parameters

escaped (Boolean) – indicates if the raw bytearray must be escaped.

Returns

raw bytearray of the XBeePacket.

Return type

Bytearray

to_dict()

Returns a dictionary with all information of the XBeePacket fields.

Returns

dictionary with all info of the XBeePacket fields.

Return type

Dictionary

static unescape_data(data)

Un-escapes the provided bytearray data.

Parameters

data (Bytearray) – the bytearray to unescape.

Returns

data unescaped.

Return type

Bytearray

class digi.xbee.packets.common.IODataSampleRxIndicatorPacket(x64bit_addr, x16bit_addr, receive_options, rf_data=None)[source]

Bases: digi.xbee.packets.base.XBeeAPIPacket

This class represents an IO data sample RX indicator packet. Packet is built using the parameters of the constructor or providing a valid API byte array.

When the module receives an IO sample frame from a remote device, it sends the sample out the UART using this frame type (when AO=0). Only modules running API firmware will send IO samples out the UART.

Among received data, some options can also be received indicating transmission parameters.

Class constructor. Instantiates a new IODataSampleRxIndicatorPacket object with the provided parameters.

Parameters
  • x64bit_addr (XBee64BitAddress) – the 64-bit source address.

  • x16bit_addr (XBee16BitAddress) – the 16-bit source address.

  • receive_options (Integer) – bitfield indicating the receive options.

  • rf_data (Bytearray, optional) – received RF data. Optional.

Raises

ValueError – if rf_data is not None and it’s not valid for create an IOSample.

static create_packet(raw, operating_mode)[source]

Override method.

Returns

IODataSampleRxIndicatorPacket.

Raises

See also

XBeeAPIPacket._check_api_packet()
needs_id()[source]

Override method.

is_broadcast()[source]

Override method.

See also

XBeeAPIPacket.is_broadcast()
property x64bit_source_addr

Returns the 64-bit source address.

Returns

the 64-bit source address.

Return type

XBee64BitAddress

See also

property x16bit_source_addr

Returns the 16-bit source address.

Returns

the 16-bit source address.

Return type

XBee16BitAddress

See also

property receive_options

Returns the receive options bitfield.

Returns

the receive options bitfield.

Return type

Integer

See also

property rf_data

Returns the received RF data.

Returns

the received RF data.

Return type

Bytearray

property io_sample

Returns the IO sample corresponding to the data contained in the packet.

Returns

the IO sample of the packet, None if the

packet has not any data or if the sample could not be generated correctly.

Return type

IOSample

See also

property frame_id

Returns the frame ID of the packet.

Returns

the frame ID of the packet.

Return type

Integer

get_checksum()

Returns the checksum value of this XBeePacket. The checksum is the last 8 bits of the sum of the bytes between the length field and the checksum field.

Returns

checksum value of this XBeePacket.

Return type

Integer

See also

get_frame_spec_data()

Override method.

get_frame_type()

Returns the frame type of this packet.

Returns

the frame type of this packet.

Return type

ApiFrameType

See also

get_frame_type_value()

Returns the frame type integer value of this packet.

Returns

the frame type integer value of this packet.

Return type

Integer

See also

output(escaped=False)

Returns the raw bytearray of this XBeePacket, ready to be send by the serial port.

Parameters

escaped (Boolean) – indicates if the raw bytearray must be escaped.

Returns

raw bytearray of the XBeePacket.

Return type

Bytearray

to_dict()

Returns a dictionary with all information of the XBeePacket fields.

Returns

dictionary with all info of the XBeePacket fields.

Return type

Dictionary

static unescape_data(data)

Un-escapes the provided bytearray data.

Parameters

data (Bytearray) – the bytearray to unescape.

Returns

data unescaped.

Return type

Bytearray

class digi.xbee.packets.common.ExplicitAddressingPacket(frame_id, x64bit_addr, x16bit_addr, source_endpoint, dest_endpoint, cluster_id, profile_id, broadcast_radius=0, transmit_options=0, rf_data=None)[source]

Bases: digi.xbee.packets.base.XBeeAPIPacket

This class represents an explicit addressing command packet. Packet is built using the parameters of the constructor or providing a valid API payload.

Allows application layer fields (endpoint and cluster ID) to be specified for a data transmission. Similar to the transmit request, but also requires application layer addressing fields to be specified (endpoints, cluster ID, profile ID). An explicit addressing request API frame causes the module to send data as an RF packet to the specified destination, using the specified source and destination endpoints, cluster ID, and profile ID.

The 64-bit destination address should be set to 0x000000000000FFF for a broadcast transmission (to all devices).

The coordinator can be addressed by either setting the 64-bit address to 0x000000000000000 and the 16-bit address to 0xFFFE, OR by setting the 64-bit address to the coordinator’s 64-bit address and the 16-bit address to 0x0000.

For all other transmissions, setting the 16-bit address to the right 16-bit address can help improve performance when transmitting to multiple destinations.

If a 16-bit address is not known, this field should be set to 0xFFFE (unknown).

The transmit status frame (ApiFrameType.TRANSMIT_STATUS) will indicate the discovered 16-bit address, if successful (see TransmitStatusPacket)).

The broadcast radius can be set from 0 up to NH. If set to 0, the value of NH specifies the broadcast radius (recommended). This parameter is only used for broadcast transmissions.

The maximum number of payload bytes can be read with the NP command. Note: if source routing is used, the RF payload will be reduced by two bytes per intermediate hop in the source route.

Several transmit options can be set using the transmit options bitfield.

Class constructor. . Instantiates a new ExplicitAddressingPacket object with the provided parameters.

Parameters
  • frame_id (Integer) – the frame ID of the packet.

  • x64bit_addr (XBee64BitAddress) – the 64-bit address.

  • x16bit_addr (XBee16BitAddress) – the 16-bit address.

  • source_endpoint (Integer) – source endpoint. 1 byte.

  • dest_endpoint (Integer) – destination endpoint. 1 byte.

  • cluster_id (Integer) – cluster id. Must be between 0 and 0xFFFF.

  • profile_id (Integer) – profile id. Must be between 0 and 0xFFFF.

  • broadcast_radius (Integer) – maximum number of hops a broadcast transmission can occur.

  • transmit_options (Integer) – bitfield of supported transmission options.

  • rf_data (Bytearray, optional) – RF data that is sent to the destination device. Optional.

Raises
  • ValueError – if frame_id, src_endpoint or dst_endpoint are less than 0 or greater than 255.

  • ValueError – if lengths of cluster_id or profile_id (respectively) are less than 0 or greater than 0xFFFF.

property frame_id

Returns the frame ID of the packet.

Returns

the frame ID of the packet.

Return type

Integer

get_checksum()

Returns the checksum value of this XBeePacket. The checksum is the last 8 bits of the sum of the bytes between the length field and the checksum field.

Returns

checksum value of this XBeePacket.

Return type

Integer

See also

get_frame_spec_data()

Override method.

get_frame_type()

Returns the frame type of this packet.

Returns

the frame type of this packet.

Return type

ApiFrameType

See also

get_frame_type_value()

Returns the frame type integer value of this packet.

Returns

the frame type integer value of this packet.

Return type

Integer

See also

is_broadcast()

Returns whether this packet is broadcast or not.

Returns

True if this packet is broadcast, False otherwise.

Return type

Boolean

output(escaped=False)

Returns the raw bytearray of this XBeePacket, ready to be send by the serial port.

Parameters

escaped (Boolean) – indicates if the raw bytearray must be escaped.

Returns

raw bytearray of the XBeePacket.

Return type

Bytearray

to_dict()

Returns a dictionary with all information of the XBeePacket fields.

Returns

dictionary with all info of the XBeePacket fields.

Return type

Dictionary

static unescape_data(data)

Un-escapes the provided bytearray data.

Parameters

data (Bytearray) – the bytearray to unescape.

Returns

data unescaped.

Return type

Bytearray

static create_packet(raw, operating_mode)[source]

Override method.

Returns

ExplicitAddressingPacket.

Raises
  • InvalidPacketException – if the bytearray length is less than 24. (start delim. + length (2 bytes) + frame type + frame ID + 64bit addr. + 16bit addr. + source endpoint + dest. endpoint + cluster ID (2 bytes) + profile ID (2 bytes) + broadcast radius + transmit options + checksum = 24 bytes).

  • InvalidPacketException – if the length field of ‘raw’ is different from its real length. (length field: bytes 2 and 3)

  • InvalidPacketException – if the first byte of ‘raw’ is not the header byte. See SpecialByte.

  • InvalidPacketException – if the calculated checksum is different from the checksum field value (last byte).

  • InvalidPacketException – if the frame type is different from ApiFrameType.EXPLICIT_ADDRESSING.

  • InvalidOperatingModeException – if operating_mode is not supported.

See also

XBeeAPIPacket._check_api_packet()
needs_id()[source]

Override method.

property source_endpoint

Returns the source endpoint of the transmission.

Returns

the source endpoint of the transmission.

Return type

Integer

property dest_endpoint

Returns the destination endpoint of the transmission.

Returns

the destination endpoint of the transmission.

Return type

Integer

property cluster_id

Returns the cluster ID of the transmission.

Returns

the cluster ID of the transmission.

Return type

Integer

property profile_id

Returns the profile ID of the transmission.

Returns

Integer: the profile ID of the transmission.

property rf_data

Returns the RF data to send.

Returns

the RF data to send.

Return type

Bytearray

property transmit_options

Returns the transmit options bitfield.

Returns

the transmit options bitfield.

Return type

Integer

See also

property broadcast_radius

Returns the broadcast radius. Broadcast radius is the maximum number of hops a broadcast transmission.

Returns

the broadcast radius.

Return type

Integer

property x64bit_dest_addr

Returns the 64-bit destination address.

Returns

the 64-bit destination address.

Return type

XBee64BitAddress

See also

property x16bit_dest_addr

Returns the 16-bit destination address.

Returns

the 16-bit destination address.

Return type

XBee16BitAddress

See also

class digi.xbee.packets.common.ExplicitRXIndicatorPacket(x64bit_addr, x16bit_addr, source_endpoint, dest_endpoint, cluster_id, profile_id, receive_options, rf_data=None)[source]

Bases: digi.xbee.packets.base.XBeeAPIPacket

This class represents an explicit RX indicator packet. Packet is built using the parameters of the constructor or providing a valid API payload.

When the modem receives an RF packet it is sent out the UART using this message type (when AO=1).

This packet is received when external devices send explicit addressing packets to this module.

Among received data, some options can also be received indicating transmission parameters.

Class constructor. Instantiates a new ExplicitRXIndicatorPacket object with the provided parameters.

Parameters
  • x64bit_addr (XBee64BitAddress) – the 64-bit source address.

  • x16bit_addr (XBee16BitAddress) – the 16-bit source address.

  • source_endpoint (Integer) – source endpoint. 1 byte.

  • dest_endpoint (Integer) – destination endpoint. 1 byte.

  • cluster_id (Integer) – cluster ID. Must be between 0 and 0xFFFF.

  • profile_id (Integer) – profile ID. Must be between 0 and 0xFFFF.

  • receive_options (Integer) – bitfield indicating the receive options.

  • rf_data (Bytearray, optional) – received RF data. Optional.

Raises
  • ValueError – if src_endpoint or dst_endpoint are less than 0 or greater than 255.

  • ValueError – if lengths of cluster_id or profile_id (respectively) are different from 2.

property frame_id

Returns the frame ID of the packet.

Returns

the frame ID of the packet.

Return type

Integer

get_checksum()

Returns the checksum value of this XBeePacket. The checksum is the last 8 bits of the sum of the bytes between the length field and the checksum field.

Returns

checksum value of this XBeePacket.

Return type

Integer

See also

get_frame_spec_data()

Override method.

get_frame_type()

Returns the frame type of this packet.

Returns

the frame type of this packet.

Return type

ApiFrameType

See also

get_frame_type_value()

Returns the frame type integer value of this packet.

Returns

the frame type integer value of this packet.

Return type

Integer

See also

output(escaped=False)

Returns the raw bytearray of this XBeePacket, ready to be send by the serial port.

Parameters

escaped (Boolean) – indicates if the raw bytearray must be escaped.

Returns

raw bytearray of the XBeePacket.

Return type

Bytearray

to_dict()

Returns a dictionary with all information of the XBeePacket fields.

Returns

dictionary with all info of the XBeePacket fields.

Return type

Dictionary

static unescape_data(data)

Un-escapes the provided bytearray data.

Parameters

data (Bytearray) – the bytearray to unescape.

Returns

data unescaped.

Return type

Bytearray

static create_packet(raw, operating_mode)[source]

Override method.

Returns

ExplicitRXIndicatorPacket.

Raises
  • InvalidPacketException – if the bytearray length is less than 22. (start delim. + length (2 bytes) + frame type + 64bit addr. + 16bit addr. + source endpoint + dest. endpoint + cluster ID (2 bytes) + profile ID (2 bytes) + receive options + checksum = 22 bytes).

  • InvalidPacketException – if the length field of ‘raw’ is different from its real length. (length field: bytes 2 and 3)

  • InvalidPacketException – if the first byte of ‘raw’ is not the header byte. See SpecialByte.

  • InvalidPacketException – if the calculated checksum is different from the checksum field value (last byte).

  • InvalidPacketException – if the frame type is different from ApiFrameType.EXPLICIT_RX_INDICATOR.

  • InvalidOperatingModeException – if operating_mode is not supported.

See also

XBeeAPIPacket._check_api_packet()
needs_id()[source]

Override method.

is_broadcast()[source]

Override method.

See also

XBeeAPIPacket.is_broadcast()
property x64bit_source_addr

Returns the 64-bit source address.

Returns

the 64-bit source address.

Return type

XBee64BitAddress

See also

property x16bit_source_addr

Returns the 16-bit source address.

Returns

the 16-bit source address.

Return type

XBee16BitAddress

See also

property source_endpoint

Returns the source endpoint of the transmission.

Returns

the source endpoint of the transmission.

Return type

Integer

property dest_endpoint

Returns the destination endpoint of the transmission.

Returns

the destination endpoint of the transmission.

Return type

Integer

property cluster_id

Returns the cluster ID of the transmission.

Returns

the cluster ID of the transmission.

Return type

Integer

property profile_id

Returns the profile ID of the transmission.

Returns

Integer: the profile ID of the transmission.

property receive_options

Returns the receive options bitfield.

Returns

the receive options bitfield.

Return type

Integer

See also

property rf_data

Returns the received RF data.

Returns

the received RF data.

Return type

Bytearray