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.
See also
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: 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 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.DEVICE_REQUEST
. - InvalidOperatingModeException – if
operating_mode
is not supported.
See also
XBeeAPIPacket._check_api_packet()
-
request_id
¶ Integer. Request ID of the packet.
-
transport
¶ Integer. Transport (reserved).
-
flags
¶ Integer. Flags (reserved).
-
target
¶ String. Request target of the packet.
-
request_data
¶ Bytearray. Data of the device request.
-
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.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.See also
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: 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 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.DEVICE_RESPONSE
. - InvalidOperatingModeException – if
operating_mode
is not supported.
See also
XBeeAPIPacket._check_api_packet()
-
request_id
¶ Integer. Request ID of the packet.
-
request_data
¶ Bytearray. Data of the device response.
-
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.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
.See also
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.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 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.DEVICE_RESPONSE_STATUS
. - InvalidOperatingModeException – if
operating_mode
is not supported.
See also
XBeeAPIPacket._check_api_packet()
-
status
¶ DeviceCloudStatus
. Status of the device response.
-
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.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.
See also
Class constructor. Instantiates a new
FrameErrorPacket
object with the provided parameters.Parameters: frame_error ( FrameError
) – the frame error.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 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.FRAME_ERROR
. - InvalidOperatingModeException – if
operating_mode
is not supported.
See also
XBeeAPIPacket._check_api_packet()
-
error
¶ FrameError
. Frame error of the packet.
-
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.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.See also
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: 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 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.SEND_DATA_REQUEST
. - InvalidOperatingModeException – if
operating_mode
is not supported.
See also
XBeeAPIPacket._check_api_packet()
-
path
¶ String. Path of the file to upload to Device Cloud.
-
content_type
¶ String. The content type of the file to upload.
-
options
¶ SendDataRequestOptions
. File upload operation options.
-
file_data
¶ Bytearray. Data of the file to upload.
-
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.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.See also
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.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
-
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: 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 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.SEND_DATA_RESPONSE
. - InvalidOperatingModeException – if
operating_mode
is not supported.
See also
XBeeAPIPacket._check_api_packet()
-
status
¶ DeviceCloudStatus
. The file upload status.