digi.xbee.packets.devicecloud module

class digi.xbee.packets.devicecloud.DeviceRequestPacket(request_id, target=None, request_data=None, op_mode=<OperatingMode.API_MODE: (1, 'API mode')>)[source]

Bases: digi.xbee.packets.base.XBeeAPIPacket

This class represents a device request packet. Packet is built using the parameters of the constructor or providing a valid API payload.

This frame type is sent out the serial port when the XBee module receives a valid device request from Device Cloud.

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

Parameters:
  • request_id (Integer) – number that identifies the device request. (0 has no special meaning)
  • target (String) – device request target.
  • request_data (Bytearray, optional) – data of the request.
  • op_mode (OperatingMode, optional, default=`OperatingMode.API_MODE`) – The mode in which the frame was captured.
Raises:
  • ValueError – if request_id is less than 0 or greater than 255.
  • ValueError – if length of target is greater than 255.

See also

static create_packet(raw, operating_mode)[source]

Override method.

Returns:

DeviceRequestPacket

Raises:
  • InvalidPacketException – if the bytearray length is less than 9. (start delim. + length (2 bytes) + frame type + request id + transport + flags + target length + checksum = 9 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.DEVICE_REQUEST.
  • InvalidOperatingModeException – if operating_mode is not supported.

See also

XBeeAPIPacket._check_api_packet()
needs_id()[source]

Override method.

request_id

Returns the request ID of the packet.

Returns:the request ID of the packet.
Return type:Integer
transport

Returns the transport of the packet.

Returns:the transport of the packet.
Return type:Integer
flags

Returns the flags of the packet.

Returns:the flags of the packet.
Return type:Integer
target

Returns the device request target of the packet.

Returns:the device request target of the packet.
Return type:String
request_data

Returns the data of the device request.

Returns:the data of the device request.
Return type:Bytearray
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
op_mode

Retrieves the operating mode in which this packet was read.

Returns:The operating mode.
Return type:OperatingMode
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.devicecloud.DeviceResponsePacket(frame_id, request_id, response_data=None, op_mode=<OperatingMode.API_MODE: (1, 'API mode')>)[source]

Bases: digi.xbee.packets.base.XBeeAPIPacket

This class represents a device response packet. Packet is built using the parameters of the constructor or providing a valid API payload.

This frame type is sent to the serial port by the host in response to the DeviceRequestPacket. It should be sent within five seconds to avoid a timeout error.

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

Parameters:
  • frame_id (Integer) – the frame ID of the packet.
  • request_id (Integer) – device Request ID. This number should match the device request ID in the device request. Otherwise, an error will occur. (0 has no special meaning)
  • response_data (Bytearray, optional) – data of the response.
  • op_mode (OperatingMode, optional, default=`OperatingMode.API_MODE`) – The mode in which the frame was captured.
Raises:
  • ValueError – if frame_id is less than 0 or greater than 255.
  • ValueError – if request_id is less than 0 or greater than 255.

See also

static create_packet(raw, operating_mode)[source]

Override method.

Returns:

DeviceResponsePacket

Raises:
  • InvalidPacketException – if the bytearray length is less than 8. (start delim. + length (2 bytes) + frame type + frame id + request id + reserved + checksum = 8 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.DEVICE_RESPONSE.
  • InvalidOperatingModeException – if operating_mode is not supported.

See also

XBeeAPIPacket._check_api_packet()
needs_id()[source]

Override method.

request_id

Returns the request ID of the packet.

Returns:the request ID of the packet.
Return type:Integer
request_data

Returns the data of the device response.

Returns:the data of the device response.
Return type:Bytearray
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
op_mode

Retrieves the operating mode in which this packet was read.

Returns:The operating mode.
Return type:OperatingMode
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.devicecloud.DeviceResponseStatusPacket(frame_id, status, op_mode=<OperatingMode.API_MODE: (1, 'API mode')>)[source]

Bases: digi.xbee.packets.base.XBeeAPIPacket

This class represents a device response status packet. Packet is built using the parameters of the constructor or providing a valid API payload.

This frame type is sent to the serial port after the serial port sends a DeviceResponsePacket.

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

Parameters:
  • frame_id (Integer) – the frame ID of the packet.
  • status (DeviceCloudStatus) – device response status.
Raises:

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

static create_packet(raw, operating_mode)[source]

Override method.

Returns:

DeviceResponseStatusPacket

Raises:
  • InvalidPacketException – if the bytearray length is less than 7. (start delim. + length (2 bytes) + frame type + frame id + device response status + checksum = 7 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.DEVICE_RESPONSE_STATUS.
  • InvalidOperatingModeException – if operating_mode is not supported.

See also

XBeeAPIPacket._check_api_packet()
needs_id()[source]

Override method.

status

Returns the status of the device response packet.

Returns:the status of the device response packet.
Return type:DeviceCloudStatus
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
op_mode

Retrieves the operating mode in which this packet was read.

Returns:The operating mode.
Return type:OperatingMode
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.devicecloud.FrameErrorPacket(frame_error, op_mode=<OperatingMode.API_MODE: (1, 'API mode')>)[source]

Bases: digi.xbee.packets.base.XBeeAPIPacket

This class represents a frame error packet. Packet is built using the parameters of the constructor or providing a valid API payload.

This frame type is sent to the serial port for any type of frame error.

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

Parameters:
  • frame_error (FrameError) – the frame error.
  • op_mode (OperatingMode, optional, default=`OperatingMode.API_MODE`) – The mode in which the frame was captured.
static create_packet(raw, operating_mode)[source]

Override method.

Returns:

FrameErrorPacket

Raises:
  • InvalidPacketException – if the bytearray length is less than 6. (start delim. + length (2 bytes) + frame type + frame error + checksum = 6 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.FRAME_ERROR.
  • InvalidOperatingModeException – if operating_mode is not supported.

See also

XBeeAPIPacket._check_api_packet()
needs_id()[source]

Override method.

error

Returns the frame error of the packet.

Returns:the frame error of the packet.
Return type:FrameError

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.

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
op_mode

Retrieves the operating mode in which this packet was read.

Returns:The operating mode.
Return type:OperatingMode
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.devicecloud.SendDataRequestPacket(frame_id, path, content_type, options, file_data=None, op_mode=<OperatingMode.API_MODE: (1, 'API mode')>)[source]

Bases: digi.xbee.packets.base.XBeeAPIPacket

This class represents a send data request packet. Packet is built using the parameters of the constructor or providing a valid API payload.

This frame type is used to send a file of the given name and type to Device Cloud.

If the frame ID is non-zero, a SendDataResponsePacket will be received.

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

Parameters:
  • frame_id (Integer) – the frame ID of the packet.
  • path (String) – path of the file to upload to Device Cloud.
  • content_type (String) – content type of the file to upload.
  • options (SendDataRequestOptions) – the action when uploading a file.
  • file_data (Bytearray, optional) – data of the file to upload.
  • op_mode (OperatingMode, optional, default=`OperatingMode.API_MODE`) – The mode in which the frame was captured.
Raises:

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

See also

static create_packet(raw, operating_mode)[source]

Override method.

Returns:

SendDataRequestPacket

Raises:
  • InvalidPacketException – if the bytearray length is less than 10. (start delim. + length (2 bytes) + frame type + frame id + path length + content type length + transport + options + checksum = 10 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.SEND_DATA_REQUEST.
  • InvalidOperatingModeException – if operating_mode is not supported.

See also

XBeeAPIPacket._check_api_packet()
needs_id()[source]

Override method.

path

Returns the path of the file to upload to Device Cloud.

Returns:the path of the file to upload to Device Cloud.
Return type:String
content_type

Returns the content type of the file to upload.

Returns:the content type of the file to upload.
Return type:String
options

Returns the file upload operation options.

Returns:the file upload operation options.
Return type:SendDataRequestOptions
file_data

Returns the data of the file to upload.

Returns:the data of the file to upload.
Return type:Bytearray
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
op_mode

Retrieves the operating mode in which this packet was read.

Returns:The operating mode.
Return type:OperatingMode
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.devicecloud.SendDataResponsePacket(frame_id, status, op_mode=<OperatingMode.API_MODE: (1, 'API mode')>)[source]

Bases: digi.xbee.packets.base.XBeeAPIPacket

This class represents a send data response packet. Packet is built using the parameters of the constructor or providing a valid API payload.

This frame type is sent out the serial port in response to the SendDataRequestPacket, providing its frame ID is non-zero.

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

Parameters:
  • frame_id (Integer) – the frame ID of the packet.
  • status (DeviceCloudStatus) – the file upload status.
  • op_mode (OperatingMode, optional, default=`OperatingMode.API_MODE`) – The mode in which the frame was captured.
Raises:

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

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
op_mode

Retrieves the operating mode in which this packet was read.

Returns:The operating mode.
Return type:OperatingMode
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:

SendDataResponsePacket

Raises:
  • InvalidPacketException – if the bytearray length is less than 10. (start delim. + length (2 bytes) + frame type + frame id + status + checksum = 7 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.SEND_DATA_RESPONSE.
  • InvalidOperatingModeException – if operating_mode is not supported.

See also

XBeeAPIPacket._check_api_packet()
needs_id()[source]

Override method.

status

Returns the file upload status.

Returns:the file upload status.
Return type:DeviceCloudStatus