digi.xbee.packets.socket module¶
-
class
digi.xbee.packets.socket.
SocketCreatePacket
(frame_id, protocol, op_mode=<OperatingMode.API_MODE: (1, 'API mode')>)[source]¶ Bases:
digi.xbee.packets.base.XBeeAPIPacket
This class represents a Socket Create packet. Packet is built using the parameters of the constructor.
Use this frame to create a new socket with the following protocols: TCP, UDP, or TLS.
See also
Class constructor. Instantiates a new
SocketCreatePacket
object with the provided parameters.Parameters: - frame_id (Integer) – the frame ID of the packet.
- protocol (
IPProtocol
) – the protocol used to create the socket. - op_mode (
OperatingMode
, optional, default=`OperatingMode.API_MODE`) – The mode in which the frame was captured.
See also
Raises: 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 + protocol + 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.SOCKET_CREATE
.InvalidOperatingModeException
– if operating_mode is not supported.
See also
XBeeAPIPacket._check_api_packet()
-
protocol
¶ Returns the communication protocol.
Returns: the communication protocol. Return type: IPProtocol
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.socket.
SocketCreateResponsePacket
(frame_id, socket_id, status, op_mode=<OperatingMode.API_MODE: (1, 'API mode')>)[source]¶ Bases:
digi.xbee.packets.base.XBeeAPIPacket
This class represents a Socket Create Response packet. Packet is built using the parameters of the constructor.
The device sends this frame in response to a Socket Create (0x40) frame. It contains a socket ID that should be used for future transactions with the socket and a status field.
If the status field is non-zero, which indicates an error, the socket ID will be set to 0xFF and the socket will not be opened.
See also
Class constructor. Instantiates a new
SocketCreateResponsePacket
object with the provided parameters.Parameters: - frame_id (Integer) – the frame ID of the packet.
- socket_id (Integer) – the unique socket ID to address the socket.
- status (
SocketStatus
) – the socket create status. - op_mode (
OperatingMode
, optional, default=`OperatingMode.API_MODE`) – The mode in which the frame was captured.
See also
Raises: ValueError
– if frame_id is less than 0 or greater than 255.ValueError
– if socket_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 8. (start delim. + length (2 bytes) + frame type + frame id + socket id + status + 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 notApiFrameType.SOCKET_CREATE_RESPONSE
.InvalidOperatingModeException
– if operating_mode is not supported.
See also
XBeeAPIPacket._check_api_packet()
-
socket_id
¶ Returns the the socket ID.
Returns: the socket ID. Return type: Integer
-
status
¶ Returns the socket create status.
Returns: the status. Return type: SocketStatus
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.socket.
SocketOptionRequestPacket
(frame_id, socket_id, option, option_data=None, op_mode=<OperatingMode.API_MODE: (1, 'API mode')>)[source]¶ Bases:
digi.xbee.packets.base.XBeeAPIPacket
This class represents a Socket Option Request packet. Packet is built using the parameters of the constructor.
Use this frame to modify the behavior of sockets to be different from the normal default behavior.
If the Option Data field is zero-length, the Socket Option Response Packet (0xC1) reports the current effective value.
See also
Class constructor. Instantiates a new
SocketOptionRequestPacket
object with the provided parameters.Parameters: - frame_id (Integer) – the frame ID of the packet.
- socket_id (Integer) – the socket ID to modify.
- option (
SocketOption
) – the socket option of the parameter to change. - option_data (Bytearray, optional) – the option data.
- op_mode (
OperatingMode
, optional, default=`OperatingMode.API_MODE`) – The mode in which the frame was captured.
See also
Raises: ValueError
– if frame_id is less than 0 or greater than 255.ValueError
– if socket_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 8. (start delim. + length (2 bytes) + frame type + frame id + socket id + option + checksum = 8 bytes).InvalidPacketException
– if the length field of ‘raw’ is different from its real length. (length field: byte 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.SOCKET_OPTION_REQUEST
.InvalidOperatingModeException
– if operating_mode is not supported.
See also
XBeeAPIPacket._check_api_packet()
-
socket_id
¶ Returns the the socket ID.
Returns: the socket ID. Return type: Integer
-
option
¶ Returns the socket option.
Returns: the socket option. Return type: SocketOption
See also
-
option_data
¶ Returns the socket option data.
Returns: the socket option data. 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: 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.socket.
SocketOptionResponsePacket
(frame_id, socket_id, option, status, option_data=None, op_mode=<OperatingMode.API_MODE: (1, 'API mode')>)[source]¶ Bases:
digi.xbee.packets.base.XBeeAPIPacket
This class represents a Socket Option Response packet. Packet is built using the parameters of the constructor.
Reports the status of requests made with the Socket Option Request (0x41) packet.
See also
Class constructor. Instantiates a new
SocketOptionResponsePacket
object with the provided parameters.Parameters: - frame_id (Integer) – the frame ID of the packet.
- socket_id (Integer) – the socket ID for which modification was requested.
- option (
SocketOption
) – the socket option of the parameter requested. - status (
SocketStatus
) – the socket option status of the parameter requested. - option_data (Bytearray, optional) – the option data.
- op_mode (
OperatingMode
, optional, default=`OperatingMode.API_MODE`) – The mode in which the frame was captured.
See also
Raises: ValueError
– if frame_id is less than 0 or greater than 255.ValueError
– if socket_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 9. (start delim. + length (2 bytes) + frame type + frame id + socket id + option + status + 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 notApiFrameType.SOCKET_OPTION_RESPONSE
.InvalidOperatingModeException
– if operating_mode is not supported.
See also
XBeeAPIPacket._check_api_packet()
-
socket_id
¶ Returns the the socket ID.
Returns: the socket ID. Return type: Integer
-
option
¶ Returns the socket option.
Returns: the socket option. Return type: SocketOption
See also
-
status
¶ Returns the socket option status.
Returns: the socket option status. Return type: SocketStatus
See also
-
option_data
¶ Returns the socket option data.
Returns: the socket option data. 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: 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.socket.
SocketConnectPacket
(frame_id, socket_id, dest_port, dest_address_type, dest_address, op_mode=<OperatingMode.API_MODE: (1, 'API mode')>)[source]¶ Bases:
digi.xbee.packets.base.XBeeAPIPacket
This class represents a Socket Connect packet. Packet is built using the parameters of the constructor.
Use this frame to create a socket connect message that causes the device to connect a socket to the given address and port.
For a UDP socket, this filters out any received responses that are not from the specified remote address and port.
Two frames occur in response:
- Socket Connect Response frame (
SocketConnectResponsePacket
): Arrives immediately and confirms the request. - Socket Status frame (
SocketStatePacket
): Indicates if the connection was successful.
Class constructor. Instantiates a new
SocketConnectPacket
object with the provided parameters.Parameters: - frame_id (Integer) – the frame ID of the packet.
- socket_id (Integer) – the ID of the socket to connect.
- dest_port (Integer) – the destination port number.
- dest_address_type (Integer) – the destination address type. One of
SocketConnectPacket.DEST_ADDRESS_BINARY
orSocketConnectPacket.DEST_ADDRESS_STRING
. - dest_address (Bytearray or String) – the destination address.
- op_mode (
OperatingMode
, optional, default=`OperatingMode.API_MODE`) – The mode in which the frame was captured.
See also
Raises: ValueError
– if frame_id is less than 0 or greater than 255.ValueError
– if socket_id is less than 0 or greater than 255.ValueError
– if dest_port is less than 0 or greater than 65535.ValueError
– if dest_address_type is different thanSocketConnectPacket.DEST_ADDRESS_BINARY
andSocketConnectPacket.DEST_ADDRESS_STRING
.ValueError
– if dest_address is None or does not follow the format specified in the configured type.
-
DEST_ADDRESS_BINARY
= 0¶ Indicates the destination address field is a binary IPv4 address in network byte order.
-
DEST_ADDRESS_STRING
= 1¶ Indicates the destination address field is a string containing either a dotted quad value or a domain name to be resolved.
-
static
create_packet
(raw, operating_mode)[source]¶ Override method.
Returns: Raises: InvalidPacketException
– if the bytearray length is less than 11. (start delim. + length (2 bytes) + frame type + frame id + socket id + dest port (2 bytes) + dest address type + dest_address + checksum = 11 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.SOCKET_CONNECT
.InvalidOperatingModeException
– if operating_mode is not supported.
See also
XBeeAPIPacket._check_api_packet()
-
socket_id
¶ Returns the the socket ID.
Returns: the socket ID. Return type: Integer
-
dest_port
¶ Returns the destination port.
Returns: the destination port. Return type: Integer
-
dest_address_type
¶ Returns the destination address type.
Returns: the destination address type. Return type: Integer
-
dest_address
¶ Returns the destination address.
Returns: the destination address. Return type: Bytearray or String
-
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
- Socket Connect Response frame (
-
class
digi.xbee.packets.socket.
SocketConnectResponsePacket
(frame_id, socket_id, status, op_mode=<OperatingMode.API_MODE: (1, 'API mode')>)[source]¶ Bases:
digi.xbee.packets.base.XBeeAPIPacket
This class represents a Socket Connect Response packet. Packet is built using the parameters of the constructor.
The device sends this frame in response to a Socket Connect (0x42) frame. The frame contains a status regarding the initiation of the connect.
See also
Class constructor. Instantiates a new
SocketConnectPacket
object with the provided parameters.Parameters: - frame_id (Integer) – the frame ID of the packet.
- socket_id (Integer) – the ID of the socket to connect.
- status (
SocketStatus
) – the socket connect status. - op_mode (
OperatingMode
, optional, default=`OperatingMode.API_MODE`) – The mode in which the frame was captured.
See also
Raises: ValueError
– if frame_id is less than 0 or greater than 255.ValueError
– if socket_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 8. (start delim. + length (2 bytes) + frame type + frame id + socket id + status + 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 notApiFrameType.SOCKET_CONNECT_RESPONSE
.InvalidOperatingModeException
– if operating_mode is not supported.
See also
XBeeAPIPacket._check_api_packet()
-
socket_id
¶ Returns the the socket ID.
Returns: the socket ID. Return type: Integer
-
status
¶ Returns the socket connect status.
Returns: the socket connect status. Return type: SocketStatus
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.socket.
SocketClosePacket
(frame_id, socket_id, op_mode=<OperatingMode.API_MODE: (1, 'API mode')>)[source]¶ Bases:
digi.xbee.packets.base.XBeeAPIPacket
This class represents a Socket Close packet. Packet is built using the parameters of the constructor.
Use this frame to close a socket when given an identifier.
See also
Class constructor. Instantiates a new
SocketClosePacket
object with the provided parameters.Parameters: - frame_id (Integer) – the frame ID of the packet.
- socket_id (Integer) – the ID of the socket to close.
- op_mode (
OperatingMode
, optional, default=`OperatingMode.API_MODE`) – The mode in which the frame was captured.
See also
Raises: ValueError
– if frame_id is less than 0 or greater than 255.ValueError
– if socket_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 + socket id + 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.SOCKET_CLOSE
.InvalidOperatingModeException
– if operating_mode is not supported.
See also
XBeeAPIPacket._check_api_packet()
-
socket_id
¶ Returns the socket ID.
Returns: the socket ID. Return type: Integer
-
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.socket.
SocketCloseResponsePacket
(frame_id, socket_id, status, op_mode=<OperatingMode.API_MODE: (1, 'API mode')>)[source]¶ Bases:
digi.xbee.packets.base.XBeeAPIPacket
This class represents a Socket Close Response packet. Packet is built using the parameters of the constructor.
The device sends this frame in response to a Socket Close (0x43) frame. Since a close will always succeed for a socket that exists, the status can be only one of two values:
- Success.
- Bad socket ID.
See also
Class constructor. Instantiates a new
SocketCloseResponsePacket
object with the provided parameters.Parameters: - frame_id (Integer) – the frame ID of the packet.
- socket_id (Integer) – the ID of the socket to close.
- status (
SocketStatus
) – the socket close status. - op_mode (
OperatingMode
, optional, default=`OperatingMode.API_MODE`) – The mode in which the frame was captured.
See also
Raises: ValueError
– if frame_id is less than 0 or greater than 255.ValueError
– if socket_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 8. (start delim. + length (2 bytes) + frame type + frame id + socket id + status + 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 notApiFrameType.SOCKET_CLOSE_RESPONSE
.InvalidOperatingModeException
– if operating_mode is not supported.
See also
XBeeAPIPacket._check_api_packet()
-
socket_id
¶ Returns the the socket ID.
Returns: the socket ID. Return type: Integer
-
status
¶ Returns the socket close status.
Returns: the socket close status. Return type: SocketStatus
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.socket.
SocketSendPacket
(frame_id, socket_id, payload=None, op_mode=<OperatingMode.API_MODE: (1, 'API mode')>)[source]¶ Bases:
digi.xbee.packets.base.XBeeAPIPacket
This class represents a Socket Send packet. Packet is built using the parameters of the constructor.
A Socket Send message causes the device to transmit data using the current connection. For a nonzero frame ID, this will elicit a Transmit (TX) Status - 0x89 frame (
TransmitStatusPacket
).This frame requires a successful Socket Connect - 0x42 frame first (
SocketConnectPacket
). For a socket that is not connected, the device responds with a Transmit (TX) Status - 0x89 frame with an error.See also
Class constructor. Instantiates a new
SocketSendPacket
object with the provided parameters.Parameters: - frame_id (Integer) – the frame ID of the packet.
- socket_id (Integer) – the socket identifier.
- payload (Bytearray, optional) – data that is sent.
- 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 socket_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 + socket ID + 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.SOCKET_SEND
.InvalidOperatingModeException
– if operating_mode is not supported.
See also
XBeeAPIPacket._check_api_packet()
-
socket_id
¶ Returns the socket ID.
Returns: the socket ID. Return type: Integer
-
payload
¶ Returns the payload to send.
Returns: the payload to send. 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: 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.socket.
SocketSendToPacket
(frame_id, socket_id, dest_address, dest_port, payload=None, op_mode=<OperatingMode.API_MODE: (1, 'API mode')>)[source]¶ Bases:
digi.xbee.packets.base.XBeeAPIPacket
This class represents a Socket Send packet. Packet is built using the parameters of the constructor.
A Socket SendTo (Transmit Explicit Data) message causes the device to transmit data using an IPv4 address and port. For a non-zero frame ID, this will elicit a Transmit (TX) Status - 0x89 frame (
TransmitStatusPacket
).If this frame is used with a TCP, SSL, or a connected UDP socket, the address and port fields are ignored.
See also
Class constructor. Instantiates a new
SocketSendToPacket
object with the provided parameters.Parameters: - frame_id (Integer) – the frame ID of the packet.
- socket_id (Integer) – the socket identifier.
- dest_address (
IPv4Address
) – IPv4 address of the destination device. - dest_port (Integer) – destination port number.
- payload (Bytearray, optional) – data that is sent.
- 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 socket_id is less than 0 or greater than 255.ValueError
– if dest_port is less than 0 or greater than 65535.
See also
-
static
create_packet
(raw, operating_mode)[source]¶ Override method.
Returns: Raises: InvalidPacketException
– if the bytearray length is less than 14. (start delim. + length (2 bytes) + frame type + frame id + socket ID + dest address (4 bytes) + dest port (2 bytes) + transmit options + checksum = 14 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.SOCKET_SENDTO
.InvalidOperatingModeException
– if operating_mode is not supported.
See also
XBeeAPIPacket._check_api_packet()
-
socket_id
¶ Returns the socket ID.
Returns: the socket ID. Return type: Integer
-
dest_address
¶ Returns the IPv4 address of the destination device.
Returns: the IPv4 address of the destination device. Return type: ipaddress.IPv4Address
-
dest_port
¶ Returns the destination port.
Returns: the destination port. Return type: Integer
-
payload
¶ Returns the payload to send.
Returns: the payload to send. 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: 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.socket.
SocketBindListenPacket
(frame_id, socket_id, src_port, op_mode=<OperatingMode.API_MODE: (1, 'API mode')>)[source]¶ Bases:
digi.xbee.packets.base.XBeeAPIPacket
This class represents a Socket Bind/Listen packet. Packet is built using the parameters of the constructor.
Opens a listener socket that listens for incoming connections.
When there is an incoming connection on the listener socket, a Socket New IPv4 Client - 0xCC frame (
SocketNewIPv4ClientPacket
) is sent, indicating the socket ID for the new connection along with the remote address information.For a UDP socket, this frame binds the socket to a given port. A bound UDP socket can receive data with a Socket Receive From: IPv4 - 0xCE frame (
SocketReceiveFromIPv4Packet
).See also
Class constructor. Instantiates a new
SocketBindListenPacket
object with the provided parameters.Parameters: - frame_id (Integer) – the frame ID of the packet.
- socket_id (Integer) – socket ID to listen on.
- src_port (Integer) – the port to listen on.
- 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 socket_id is less than 0 or greater than 255.ValueError
– if source_port is less than 0 or greater than 65535.
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 + frame id + socket ID + source port (2 bytes) + 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 notApiFrameType.SOCKET_BIND
.InvalidOperatingModeException
– if operating_mode is not supported.
See also
XBeeAPIPacket._check_api_packet()
-
socket_id
¶ Returns the socket ID.
Returns: the socket ID. Return type: Integer
-
source_port
¶ Returns the source port.
Returns: the source port. Return type: Integer
-
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.socket.
SocketListenResponsePacket
(frame_id, socket_id, status, op_mode=<OperatingMode.API_MODE: (1, 'API mode')>)[source]¶ Bases:
digi.xbee.packets.base.XBeeAPIPacket
This class represents a Socket Listen Response packet. Packet is built using the parameters of the constructor.
The device sends this frame in response to a Socket Bind/Listen (0x46) frame (
SocketBindListenPacket
).See also
Class constructor. Instantiates a new
SocketListenResponsePacket
object with the provided parameters.Parameters: - frame_id (Integer) – the frame ID of the packet.
- socket_id (Integer) – socket ID.
- status (
SocketStatus
) – socket listen 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.ValueError
– if socket_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 + socket ID + status + 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 notApiFrameType.SOCKET_LISTEN_RESPONSE
.InvalidOperatingModeException
– if operating_mode is not supported.
See also
XBeeAPIPacket._check_api_packet()
-
socket_id
¶ Returns the socket ID.
Returns: the socket ID. Return type: Integer
-
status
¶ Returns the socket listen status.
Returns: The socket listen status. Return type: SocketStatus
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.socket.
SocketNewIPv4ClientPacket
(socket_id, client_socket_id, remote_address, remote_port, op_mode=<OperatingMode.API_MODE: (1, 'API mode')>)[source]¶ Bases:
digi.xbee.packets.base.XBeeAPIPacket
This class represents a Socket New IPv4 Client packet. Packet is built using the parameters of the constructor.
XBee Cellular modem uses this frame when an incoming connection is accepted on a listener socket.
This frame contains the original listener’s socket ID and a new socket ID of the incoming connection, along with the connection’s remote address information.
See also
Class constructor. Instantiates a new
SocketNewIPv4ClientPacket
object with the provided parameters.Parameters: - socket_id (Integer) – the socket ID of the listener socket.
- client_socket_id (Integer) – the socket ID of the new connection.
- remote_address (
IPv4Address
) – the remote IPv4 address. - remote_port (Integer) – the remote port number.
- op_mode (
OperatingMode
, optional, default=`OperatingMode.API_MODE`) – The mode in which the frame was captured.
Raises: ValueError
– if socket_id is less than 0 or greater than 255.ValueError
– if client_socket_id is less than 0 or greater than 255.ValueError
– if remote_port is less than 0 or greater than 65535.
See also
-
static
create_packet
(raw, operating_mode)[source]¶ Override method.
Returns: Raises: InvalidPacketException
– if the bytearray length is less than 13. (start delim. + length (2 bytes) + frame type + socket ID + client socket ID + remote address (4 bytes) + remote port (2 bytes) + checksum = 13 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.SOCKET_NEW_IPV4_CLIENT
.InvalidOperatingModeException
– if operating_mode is not supported.
See also
XBeeAPIPacket._check_api_packet()
-
socket_id
¶ Returns the socket ID.
Returns: the socket ID. Return type: Integer
-
client_socket_id
¶ Returns the client socket ID.
Returns: the client socket ID. Return type: Integer
-
remote_address
¶ Returns the remote IPv4 address.
Returns: the remote IPv4 address. Return type: ipaddress.IPv4Address
-
remote_port
¶ Returns the remote port.
Returns: the remote port. Return type: Integer
-
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.socket.
SocketReceivePacket
(frame_id, socket_id, payload=None, op_mode=<OperatingMode.API_MODE: (1, 'API mode')>)[source]¶ Bases:
digi.xbee.packets.base.XBeeAPIPacket
This class represents a Socket Receive packet. Packet is built using the parameters of the constructor.
XBee Cellular modem uses this frame when it receives RF data on the specified socket.
See also
Class constructor. Instantiates a new
SocketReceivePacket
object with the provided parameters.Parameters: - frame_id (Integer) – the frame ID of the packet.
- socket_id (Integer) – the ID of the socket the data has been received on.
- payload (Bytearray, optional) – data that is received.
- 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 socket_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
-
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 7. (start delim. + length (2 bytes) + frame type + frame id + socket ID + 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.SOCKET_RECEIVE
.InvalidOperatingModeException
– if operating_mode is not supported.
See also
XBeeAPIPacket._check_api_packet()
-
socket_id
¶ Returns the socket ID.
Returns: the socket ID. Return type: Integer
-
payload
¶ Returns the payload that was received.
Returns: the payload that was received. Return type: Bytearray
-
class
digi.xbee.packets.socket.
SocketReceiveFromPacket
(frame_id, socket_id, src_address, src_port, payload=None, op_mode=<OperatingMode.API_MODE: (1, 'API mode')>)[source]¶ Bases:
digi.xbee.packets.base.XBeeAPIPacket
This class represents a Socket Receive From packet. Packet is built using the parameters of the constructor.
XBee Cellular modem uses this frame when it receives RF data on the specified socket. The frame also contains addressing information about the source.
See also
Class constructor. Instantiates a new
SocketReceiveFromPacket
object with the provided parameters.Parameters: - frame_id (Integer) – the frame ID of the packet.
- socket_id (Integer) – the ID of the socket the data has been received on.
- src_address (
IPv4Address
) – IPv4 address of the source device. - src_port (Integer) – source port number.
- payload (Bytearray, optional) – data that is received.
- 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 socket_id is less than 0 or greater than 255.ValueError
– if source_port is less than 0 or greater than 65535.
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
-
static
create_packet
(raw, operating_mode)[source]¶ Override method.
Returns: Raises: InvalidPacketException
– if the bytearray length is less than 13. (start delim. + length (2 bytes) + frame type + frame id + socket ID + source address (4 bytes) + source port (2 bytes) + status + Checksum = 14 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.SOCKET_RECEIVE_FROM
.InvalidOperatingModeException
– if operating_mode is not supported.
See also
XBeeAPIPacket._check_api_packet()
-
socket_id
¶ Returns the socket ID.
Returns: the socket ID. Return type: Integer
-
source_address
¶ Returns the IPv4 address of the source device.
Returns: the IPv4 address of the source device. Return type: ipaddress.IPv4Address
-
source_port
¶ Returns the source port.
Returns: the source port. Return type: Integer
-
payload
¶ Returns the payload to send.
Returns: the payload that has been received. Return type: Bytearray
-
class
digi.xbee.packets.socket.
SocketStatePacket
(socket_id, state, op_mode=<OperatingMode.API_MODE: (1, 'API mode')>)[source]¶ Bases:
digi.xbee.packets.base.XBeeAPIPacket
This class represents a Socket State packet. Packet is built using the parameters of the constructor.
This frame is sent out the device’s serial port to indicate the state related to the socket.
See also
Class constructor. Instantiates a new
SocketStatePacket
object with the provided parameters.Parameters: - socket_id (Integer) – the socket identifier.
- state (
SocketState
) – socket status. - op_mode (
OperatingMode
, optional, default=`OperatingMode.API_MODE`) – The mode in which the frame was captured.
Raises: ValueError
– if socket_id is less than 0 or greater than 255.See also
SockeState
-
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
-
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 + socket ID + state + 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.SOCKET_STATUS
.InvalidOperatingModeException
– if operating_mode is not supported.
See also
XBeeAPIPacket._check_api_packet()
-
socket_id
¶ Returns the socket ID.
Returns: the socket ID. Return type: Integer
-
state
¶ Returns the socket state.
Returns: The socket state. Return type: SocketState
See also