digi.xbee.packets.devicecloud module

class digi.xbee.packets.devicecloud.DeviceRequestPacket(request_id, target=None, request_data=None, op_mode=OperatingMode.API_MODE)[source]

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

See also

XBeeAPIPacket._check_api_packet()
needs_id()[source]

Override method.

property request_id

Returns the request ID of the packet.

Returns:

the request ID of the packet.

Return type:

Integer

property transport

Returns the transport of the packet.

Returns:

the transport of the packet.

Return type:

Integer

property flags

Returns the flags of the packet.

Returns:

the flags of the packet.

Return type:

Integer

property target

Returns the device request target of the packet.

Returns:

the device request target of the packet.

Return type:

String

property request_data

Returns the data of the device request.

Returns:

the data of the device request.

Return type:

Bytearray

property effective_len

Returns the effective length of the packet.

Returns:

Effective length of the packet.

Return type:

Integer

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

property 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)[source]

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

See also

XBeeAPIPacket._check_api_packet()
needs_id()[source]

Override method.

property request_id

Returns the request ID of the packet.

Returns:

the request ID of the packet.

Return type:

Integer

property request_data

Returns the data of the device response.

Returns:

the data of the device response.

Return type:

Bytearray

property effective_len

Returns the effective length of the packet.

Returns:

Effective length of the packet.

Return type:

Integer

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

property 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)[source]

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

Returns the status of the device response packet.

Returns:

the status of the device response packet.

Return type:

DeviceCloudStatus

property effective_len

Returns the effective length of the packet.

Returns:

Effective length of the packet.

Return type:

Integer

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

property 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)[source]

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

See also

XBeeAPIPacket._check_api_packet()
needs_id()[source]

Override method.

property error

Returns the frame error of the packet.

Returns:

the frame error of the packet.

Return type:

FrameError

See also

property effective_len

Returns the effective length of the packet.

Returns:

Effective length of the packet.

Return type:

Integer

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

property 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)[source]

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

See also

XBeeAPIPacket._check_api_packet()
needs_id()[source]

Override method.

property 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

property content_type

Returns the content type of the file to upload.

Returns:

the content type of the file to upload.

Return type:

String

property options

Returns the file upload operation options.

Returns:

the file upload operation options.

Return type:

SendDataRequestOptions

property effective_len

Returns the effective length of the packet.

Returns:

Effective length of the packet.

Return type:

Integer

property file_data

Returns the data of the file to upload.

Returns:

the data of the file to upload.

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

property 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)[source]

Bases: 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.

property effective_len

Returns the effective length of the packet.

Returns:

Effective length of the packet.

Return type:

Integer

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

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

See also

XBeeAPIPacket._check_api_packet()
needs_id()[source]

Override method.

property status

Returns the file upload status.

Returns:

the file upload status.

Return type:

DeviceCloudStatus