digi.xbee.packets.relay module¶
-
class
digi.xbee.packets.relay.
UserDataRelayPacket
(frame_id, local_iface, data=None, op_mode=<OperatingMode.API_MODE: (1, 'API mode')>)[source]¶ Bases:
digi.xbee.packets.base.XBeeAPIPacket
This class represents a User Data Relay packet. Packet is built using the parameters of the constructor.
The User Data Relay packet allows for data to come in on an interface with a designation of the target interface for the data to be output on.
The destination interface must be one of the interfaces found in the corresponding enumerator (see
XBeeLocalInterface
).Class constructor. Instantiates a new
UserDataRelayPacket
object with the provided parameters.Parameters: - frame_id (integer) – the frame ID of the packet.
- local_iface (
XBeeLocalInterface
) – the destination interface. - data (Bytearray, optional) – Data to send to the destination interface.
- op_mode (
OperatingMode
, optional, default=`OperatingMode.API_MODE`) – The mode in which the frame was captured.
See also
Raises: ValueError
– if local_interface is None.ValueError
– if frame_id is less than 0 or greater than 255.
-
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 + relay interface + 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 notApiFrameType.USER_DATA_RELAY_REQUEST
.InvalidOperatingModeException
– if operating_mode is not supported.
See also
XBeeAPIPacket._check_api_packet()
-
data
¶ Returns the data to send.
Returns: the data to send. Return type: Bytearray
-
dest_interface
¶ Returns the the destination interface.
Returns: the destination interface. Return type: XBeeLocalInterface
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
-
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.relay.
UserDataRelayOutputPacket
(local_iface, data=None, op_mode=<OperatingMode.API_MODE: (1, 'API mode')>)[source]¶ Bases:
digi.xbee.packets.base.XBeeAPIPacket
This class represents a User Data Relay Output packet. Packet is built using the parameters of the constructor.
The User Data Relay Output packet can be received from any relay interface.
The source interface must be one of the interfaces found in the corresponding enumerator (see
XBeeLocalInterface
).Class constructor. Instantiates a new
UserDataRelayOutputPacket
object with the provided parameters.Parameters: - local_iface (
XBeeLocalInterface
) – the source interface. - data (Bytearray, optional) – Data received from the source interface.
- op_mode (
OperatingMode
, optional, default=`OperatingMode.API_MODE`) – The mode in which the frame was captured.
Raises: ValueError
– if local_interface is None.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 + relay interface + 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 notApiFrameType.USER_DATA_RELAY_OUTPUT
.InvalidOperatingModeException
– if operating_mode is not supported.
See also
XBeeAPIPacket._check_api_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
-
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
-
data
¶ Returns the received data.
Returns: the received data. Return type: Bytearray
-
src_interface
¶ Returns the the source interface.
Returns: the source interface. Return type: XBeeLocalInterface
See also
- local_iface (