digi.xbee.packets.devicecloud module

class digi.xbee.packets.devicecloud.DeviceRequestPacket(request_id, target=None, request_data=None)[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. Optional.

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

See also

XBeeAPIPacket._check_api_packet()
needs_id()[source]

Override method.

property request_id

Integer. Request ID of the packet.

property transport

Integer. Transport (reserved).

property flags

Integer. Flags (reserved).

property target

String. Request target of the packet.

property request_data

Bytearray. Data of the device request.

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 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.devicecloud.DeviceResponsePacket(frame_id, request_id, response_data=None)[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. Optional.

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

See also

XBeeAPIPacket._check_api_packet()
needs_id()[source]

Override method.

property request_id

Integer. Request ID of the packet.

property request_data

Bytearray. Data of the device response.

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 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.devicecloud.DeviceResponseStatusPacket(frame_id, status)[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

See also

XBeeAPIPacket._check_api_packet()
needs_id()[source]

Override method.

property status

DeviceCloudStatus. Status of the device response.

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 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.devicecloud.FrameErrorPacket(frame_error)[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.

static create_packet(raw, operating_mode)[source]

Override method.

Returns

FrameErrorPacket

Raises

See also

XBeeAPIPacket._check_api_packet()
needs_id()[source]

Override method.

property error

FrameError. Frame error of the packet.

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 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.devicecloud.SendDataRequestPacket(frame_id, path, content_type, options, file_data=None)[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. Optional.

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

See also

XBeeAPIPacket._check_api_packet()
needs_id()[source]

Override method.

property path

String. Path of the file to upload to Device Cloud.

property content_type

String. The content type of the file to upload.

property options

SendDataRequestOptions. File upload operation options.

property file_data

Bytearray. Data of the file to upload.

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 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.devicecloud.SendDataResponsePacket(frame_id, status)[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.

Raises

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

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 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

SendDataResponsePacket

Raises

See also

XBeeAPIPacket._check_api_packet()
needs_id()[source]

Override method.

property status

DeviceCloudStatus. The file upload status.