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.XBeeAPIPacketThis 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.
See also
Class constructor. Instantiates a new
DeviceRequestPacketobject 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: 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. SeeSpecialByte.InvalidPacketException– if the calculated checksum is different from the checksum field value (last byte).InvalidPacketException– if the frame type is different fromApiFrameType.DEVICE_REQUEST.InvalidOperatingModeException– if operating_mode is not supported.
See also
XBeeAPIPacket._check_api_packet()
-
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.
See also
-
get_frame_type()¶ Returns the frame type of this packet.
Returns: the frame type of this packet. Return type: ApiFrameTypeSee 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.XBeeAPIPacketThis 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.See also
Class constructor. Instantiates a new
DeviceResponsePacketobject 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: 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. SeeSpecialByte.InvalidPacketException– if the calculated checksum is different from the checksum field value (last byte).InvalidPacketException– if the frame type is different fromApiFrameType.DEVICE_RESPONSE.InvalidOperatingModeException– if operating_mode is not supported.
See also
XBeeAPIPacket._check_api_packet()
-
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.
See also
-
get_frame_type()¶ Returns the frame type of this packet.
Returns: the frame type of this packet. Return type: ApiFrameTypeSee 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.XBeeAPIPacketThis 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.See also
Class constructor. Instantiates a new
DeviceResponseStatusPacketobject 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.See also
-
static
create_packet(raw, operating_mode)[source]¶ Override method.
Returns: 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. SeeSpecialByte.InvalidPacketException– if the calculated checksum is different from the checksum field value (last byte).InvalidPacketException– if the frame type is different fromApiFrameType.DEVICE_RESPONSE_STATUS.InvalidOperatingModeException– if operating_mode is not supported.
See also
XBeeAPIPacket._check_api_packet()
-
status¶ Returns the status of the device response packet.
Returns: the status of the device response packet. Return type: DeviceCloudStatusSee 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: ApiFrameTypeSee 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.XBeeAPIPacketThis 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.
See also
Class constructor. Instantiates a new
FrameErrorPacketobject 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.
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 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. SeeSpecialByte.InvalidPacketException– if the calculated checksum is different from the checksum field value (last byte).InvalidPacketException– if the frame type is different fromApiFrameType.FRAME_ERROR.InvalidOperatingModeException– if operating_mode is not supported.
See also
XBeeAPIPacket._check_api_packet()
-
error¶ Returns the frame error of the packet.
Returns: the frame error of the packet. Return type: FrameErrorSee 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: ApiFrameTypeSee 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
- frame_error (
-
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.XBeeAPIPacketThis 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
SendDataResponsePacketwill be received.See also
Class constructor. Instantiates a new
SendDataRequestPacketobject 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: 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. SeeSpecialByte.InvalidPacketException– if the calculated checksum is different from the checksum field value (last byte).InvalidPacketException– if the frame type is different fromApiFrameType.SEND_DATA_REQUEST.InvalidOperatingModeException– if operating_mode is not supported.
See also
XBeeAPIPacket._check_api_packet()
-
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: SendDataRequestOptionsSee also
-
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.
See also
-
get_frame_type()¶ Returns the frame type of this packet.
Returns: the frame type of this packet. Return type: ApiFrameTypeSee 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.XBeeAPIPacketThis 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.See also
Class constructor. Instantiates a new
SendDataResponsePacketobject 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.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: ApiFrameTypeSee 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: 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. SeeSpecialByte.InvalidPacketException– if the calculated checksum is different from the checksum field value (last byte).InvalidPacketException– if the frame type is different fromApiFrameType.SEND_DATA_RESPONSE.InvalidOperatingModeException– if operating_mode is not supported.
See also
XBeeAPIPacket._check_api_packet()
-
status¶ Returns the file upload status.
Returns: the file upload status. Return type: DeviceCloudStatusSee also