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
.See also
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 than 2.
See also
-
static
create_packet
(raw, operating_mode)[source]¶ Override method.
Returns: Raises: - InvalidPacketException – if the bytearray length is less than 6. (start delim. + length (2 bytes) + frame type + frame id + checksum = 6 bytes).
- InvalidPacketException – if the length field of ‘raw’ is different than 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 than the checksum field value (last byte).
- InvalidPacketException – if the frame type is different than
ApiFrameType.AT_COMMAND
. - InvalidOperatingModeException – if
operating_mode
is not supported.
See also
XBeeAPIPacket._check_api_packet()
-
command
¶ String. AT command.
-
parameter
¶ Bytearray. AT command parameter.
-
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.
See also
-
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 will be escaped or not. 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 information 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 anATCommPacket
is sent or theapplyChanges()
method of theXBeeDevice
class is issued.Command response is received as an
ATCommResponsePacket
.See also
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 than 2.
See also
-
static
create_packet
(raw, operating_mode)[source]¶ Override method.
Returns: Raises: - InvalidPacketException – if the bytearray length is less than 6. (start delim. + length (2 bytes) + frame type + frame id + checksum = 6 bytes).
- InvalidPacketException – if the length field of ‘raw’ is different than 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 than the checksum field value (last byte).
- InvalidPacketException – if the frame type is different than
ApiFrameType.AT_COMMAND_QUEUE
. - InvalidOperatingModeException – if
operating_mode
is not supported.
See also
XBeeAPIPacket._check_api_packet()
-
command
¶ String. AT command.
-
parameter
¶ Bytearray. AT command parameter.
-
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.
See also
-
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 will be escaped or not. 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 information 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.See also
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
) – 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 than 2.
See also
-
static
create_packet
(raw, operating_mode)[source]¶ Override method.
Returns: Raises: - InvalidPacketException – if the bytearray length is less than 9. (start delim. + length (2 bytes) + frame type + frame id + at command (2 bytes) + command status + checksum = 9 bytes).
- InvalidPacketException – if the length field of ‘raw’ is different than 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 than the checksum field value (last byte).
- InvalidPacketException – if the frame type is different than
ApiFrameType.AT_COMMAND_RESPONSE
. - InvalidPacketException – if the command status field is not a valid value. See
ATCommandStatus
. - InvalidOperatingModeException – if
operating_mode
is not supported.
See also
XBeeAPIPacket._check_api_packet()
-
command
¶ String. AT command.
-
command_value
¶ Bytearray. AT command value.
-
status
¶ ATCommandStatus
. AT command response status.
-
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.
See also
-
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 will be escaped or not. 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 information 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.
See also
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: Raises: - InvalidPacketException – if the bytearray length is less than 16. (start delim. + length (2 bytes) + frame type + frame id + 64bit addr. + 16bit addr. + Receive options + checksum = 16 bytes).
- InvalidPacketException – if the length field of ‘raw’ is different than 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 than the checksum field value (last byte).
- InvalidPacketException – if the frame type is not
ApiFrameType.RECEIVE_PACKET
. - InvalidOperatingModeException – if
operating_mode
is not supported.
See also
XBeeAPIPacket._check_api_packet()
-
x64bit_source_addr
¶ XBee64BitAddress
. 64-bit source address.
-
x16bit_source_addr
¶ XBee16BitAddress
. 16-bit source address.
-
receive_options
¶ Integer. Receive options bitfield.
-
rf_data
¶ Bytearray. Received RF data.
-
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.
See also
-
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 will be escaped or not. 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 information 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
- x64bit_addr (
-
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 than 2.
-
static
create_packet
(raw, operating_mode)[source]¶ Override method.
Returns: Raises: - InvalidPacketException – if the Bytearray length is less than 19. (start delim. + length (2 bytes) + frame type + frame id + 64bit addr. + 16bit addr. + transmit options + command (2 bytes) + checksum = 19 bytes).
- InvalidPacketException – if the length field of ‘raw’ is different than 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 than the checksum field value (last byte).
- InvalidPacketException – if the frame type is not
ApiFrameType.REMOTE_AT_COMMAND_REQUEST
. - InvalidOperatingModeException – if
operating_mode
is not supported.
See also
XBeeAPIPacket._check_api_packet()
-
x64bit_dest_addr
¶ XBee64BitAddress
. 64-bit destination address.
-
x16bit_dest_addr
¶ XBee16BitAddress
. 16-bit destination address.
-
transmit_options
¶ Integer. Transmit options bitfield.
-
command
¶ String. AT command.
-
parameter
¶ Bytearray. AT command parameter.
-
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.
See also
-
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 will be escaped or not. 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 information 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
) – 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 than 2.
-
static
create_packet
(raw, operating_mode)[source]¶ Override method.
Returns: Raises: - InvalidPacketException – if the bytearray length is less than 19. (start delim. + length (2 bytes) + frame type + frame id + 64bit addr. + 16bit addr. + receive options + command (2 bytes) + checksum = 19 bytes).
- InvalidPacketException – if the length field of ‘raw’ is different than 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 than the checksum field value (last byte).
- InvalidPacketException – if the frame type is not
ApiFrameType.REMOTE_AT_COMMAND_RESPONSE
. - InvalidOperatingModeException – if
operating_mode
is not supported.
See also
XBeeAPIPacket._check_api_packet()
-
x64bit_source_addr
¶ XBee64BitAddress
. 64-bit source address.
-
x16bit_source_addr
¶ XBee16BitAddress
. 16-bit source address.
-
command
¶ String. AT command.
-
command_value
¶ Bytearray. AT command value.
-
status
¶ ATCommandStatus
. AT command response status.
-
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.
See also
-
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 will be escaped or not. 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 information 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 all
0x00
} and the 16-bit address to0xFFFE
, OR by setting the 64-bit address to the coordinator’s 64-bit address and the 16-bit address to0x0000
.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 (seeTransmitStatusPacket
).The broadcast radius can be set from
0
up toNH
. If set to0
, the value ofNH
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.
See also
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: Raises: - InvalidPacketException – if the bytearray length is less than 18. (start delim. + length (2 bytes) + frame type + frame id + 64bit addr. + 16bit addr. + Receive options + checksum = 16 bytes).
- InvalidPacketException – if the length field of ‘raw’ is different than 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 than the checksum field value (last byte).
- InvalidPacketException – if the frame type is not
ApiFrameType.TRANSMIT_REQUEST
. - InvalidOperatingModeException – if
operating_mode
is not supported.
See also
XBeeAPIPacket._check_api_packet()
-
x64bit_dest_addr
¶ XBee64BitAddress
. 64-bit destination address.
-
x16bit_dest_addr
¶ XBee16BitAddress
. 16-bit destination address.
-
transmit_options
¶ Integer. Transmit options bitfield.
-
broadcast_radius
¶ Integer. Broadcast radius.
-
rf_data
¶ Bytearray. RF data to send.
-
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.
See also
-
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 will be escaped or not. 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 information 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: Raises: - InvalidPacketException – if the bytearray length is less than 11. (start delim. + length (2 bytes) + frame type + frame id + 16bit addr. + transmit retry count + delivery status + discovery status + checksum = 11 bytes).
- InvalidPacketException – if the length field of ‘raw’ is different than 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 than the checksum field value (last byte).
- InvalidPacketException – if the frame type is not
ApiFrameType.TRANSMIT_STATUS
. - InvalidOperatingModeException – if
operating_mode
is not supported.
See also
XBeeAPIPacket._check_api_packet()
-
x16bit_dest_addr
¶ XBee16BitAddress
. 16-bit destination address.
-
transmit_retry_count
¶ Integer. Transmit retry count value.
-
transmit_status
¶ TransmitStatus
. Transmit status.
-
discovery_status
¶ DiscoveryStatus
. Discovery status.
-
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.
See also
-
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 will be escaped or not. 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 information 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.See also
-
static
create_packet
(raw, operating_mode)[source]¶ Override method.
Returns: Raises: - InvalidPacketException – if the bytearray length is less than 6. (start delim. + length (2 bytes) + frame type + modem status + checksum = 6 bytes).
- InvalidPacketException – if the length field of ‘raw’ is different than 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 than the checksum field value (last byte).
- InvalidPacketException – if the frame type is not
ApiFrameType.MODEM_STATUS
. - InvalidOperatingModeException – if
operating_mode
is not supported.
See also
XBeeAPIPacket._check_api_packet()
-
modem_status
¶ ModemStatus
. Modem status event.
-
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.
See also
-
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 will be escaped or not. 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 information 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
-
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.
See also
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 notNone
and it’s not valid for create anIOSample
.-
static
create_packet
(raw, operating_mode)[source]¶ Override method.
Returns: Raises: - InvalidPacketException – if the bytearray length is less than 20. (start delim. + length (2 bytes) + frame type + 64bit addr. + 16bit addr. + rf data (5 bytes) + checksum = 20 bytes).
- InvalidPacketException – if the length field of ‘raw’ is different than 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 than the checksum field value (last byte).
- InvalidPacketException – if the frame type is not
ApiFrameType.IO_DATA_SAMPLE_RX_INDICATOR
. - InvalidOperatingModeException – if
operating_mode
is not supported.
See also
XBeeAPIPacket._check_api_packet()
-
x64bit_source_addr
¶ XBee64BitAddress
. 64-bit source address.
-
x16bit_source_addr
¶ XBee16BitAddress
. 16-bit source address.
-
receive_options
¶ Integer. Receive options bitfield.
-
rf_data
¶ Bytearray. Received RF data.
-
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.
See also
-
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 will be escaped or not. 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 information 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
- x64bit_addr (
-
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
0x000000000000FFFF
for a broadcast transmission (to all devices).The coordinator can be addressed by either setting the 64-bit address to all
0x00
and the 16-bit address to0xFFFE
, OR by setting the 64-bit address to the coordinator’s 64-bit address and the 16-bit address to0x0000
.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 (seeTransmitStatusPacket
)).The broadcast radius can be set from
0
up toNH
. If set to0
, the value ofNH
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.
See also
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
ordst_endpoint
are less than 0 or greater than 255. - ValueError – if lengths of
cluster_id
orprofile_id
(respectively) are less than 0 or greater than 0xFFFF.
-
static
create_packet
(raw, operating_mode)[source]¶ Override method.
Returns: 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 than 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 than the checksum field value (last byte).
- InvalidPacketException – if the frame type is different than
ApiFrameType.EXPLICIT_ADDRESSING
. - InvalidOperatingModeException – if
operating_mode
is not supported.
See also
XBeeAPIPacket._check_api_packet()
-
x64bit_dest_addr
¶ XBee64BitAddress
. 64-bit destination address.
-
x16bit_dest_addr
¶ XBee16BitAddress
. 16-bit destination address.
-
transmit_options
¶ Integer. Transmit options bitfield.
-
broadcast_radius
¶ Integer. Broadcast radius.
-
source_endpoint
¶ Integer. Source endpoint of the transmission.
-
dest_endpoint
¶ Integer. Destination endpoint of the transmission.
-
cluster_id
¶ Integer. Cluster ID of the transmission.
-
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.
See also
-
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 will be escaped or not. 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 information 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
-
profile_id
¶ Integer. Profile ID of the transmission.
-
rf_data
¶ Bytearray. RF data to send.
-
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.
See also
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
ordst_endpoint
are less than 0 or greater than 255. - ValueError – if lengths of
cluster_id
orprofile_id
(respectively) are different than 2.
See also
-
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.
See also
-
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 will be escaped or not. 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 information 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: 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 than 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 than the checksum field value (last byte).
- InvalidPacketException – if the frame type is different than
ApiFrameType.EXPLICIT_RX_INDICATOR
. - InvalidOperatingModeException – if
operating_mode
is not supported.
See also
XBeeAPIPacket._check_api_packet()
-
x64bit_source_addr
¶ XBee64BitAddress
. 64-bit source address.
-
x16bit_source_addr
¶ XBee16BitAddress
. 16-bit source address.
-
receive_options
¶ Integer. Receive options bitfield.
-
source_endpoint
¶ Integer. Source endpoint of the transmission.
-
dest_endpoint
¶ Integer. Destination endpoint of the transmission.
-
cluster_id
¶ Integer. Cluster ID of the transmission.
-
profile_id
¶ Integer. Profile ID of the transmission.
-
rf_data
¶ Bytearray. Received RF data.
- x64bit_addr (