digi.xbee.packets.socket module

class digi.xbee.packets.socket.SocketCreatePacket(frame_id, protocol)[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.

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.

Raises

ValueError – if frame_id is less than 0 or greater than 255.

static create_packet(raw, operating_mode)[source]

Override method.

Returns

SocketCreatePacket.

Raises

See also

XBeeAPIPacket._check_api_packet()
needs_id()[source]

Override method.

property protocol

IPProtocol. Communication protocol.

property frame_id

Returns the frame ID of the packet.

Returns

the frame ID of the packet.

Return type

Integer

get_checksum()

Returns the checksum value of this XBeePacket.

The checksum is the last 8 bits of the sum of the bytes between the length field and the checksum field.

Returns

checksum value of this XBeePacket.

Return type

Integer

See also

get_frame_spec_data()

Override method.

get_frame_type()

Returns the frame type of this packet.

Returns

the frame type of this packet.

Return type

ApiFrameType

See also

get_frame_type_value()

Returns the frame type integer value of this packet.

Returns

the frame type integer value of this packet.

Return type

Integer

See also

is_broadcast()

Returns whether this packet is broadcast or not.

Returns

True if this packet is broadcast, False otherwise.

Return type

Boolean

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.socket.SocketCreateResponsePacket(frame_id, socket_id, status)[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.

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.

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

SocketCreateResponsePacket.

Raises

See also

XBeeAPIPacket._check_api_packet()
needs_id()[source]

Override method.

property socket_id

Integer. Socket ID.

property status

SocketStatus. Socket create status.

property frame_id

Returns the frame ID of the packet.

Returns

the frame ID of the packet.

Return type

Integer

get_checksum()

Returns the checksum value of this XBeePacket.

The checksum is the last 8 bits of the sum of the bytes between the length field and the checksum field.

Returns

checksum value of this XBeePacket.

Return type

Integer

See also

get_frame_spec_data()

Override method.

get_frame_type()

Returns the frame type of this packet.

Returns

the frame type of this packet.

Return type

ApiFrameType

See also

get_frame_type_value()

Returns the frame type integer value of this packet.

Returns

the frame type integer value of this packet.

Return type

Integer

See also

is_broadcast()

Returns whether this packet is broadcast or not.

Returns

True if this packet is broadcast, False otherwise.

Return type

Boolean

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.socket.SocketOptionRequestPacket(frame_id, socket_id, option, option_data=None)[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.

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. Optional.

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

SocketOptionRequestPacket.

Raises

See also

XBeeAPIPacket._check_api_packet()
needs_id()[source]

Override method.

property socket_id

Integer. Socket ID.

property option

SocketOption. Socket option.

property option_data

Bytearray. Socket option data.

property frame_id

Returns the frame ID of the packet.

Returns

the frame ID of the packet.

Return type

Integer

get_checksum()

Returns the checksum value of this XBeePacket.

The checksum is the last 8 bits of the sum of the bytes between the length field and the checksum field.

Returns

checksum value of this XBeePacket.

Return type

Integer

See also

get_frame_spec_data()

Override method.

get_frame_type()

Returns the frame type of this packet.

Returns

the frame type of this packet.

Return type

ApiFrameType

See also

get_frame_type_value()

Returns the frame type integer value of this packet.

Returns

the frame type integer value of this packet.

Return type

Integer

See also

is_broadcast()

Returns whether this packet is broadcast or not.

Returns

True if this packet is broadcast, False otherwise.

Return type

Boolean

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.socket.SocketOptionResponsePacket(frame_id, socket_id, option, status, option_data=None)[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.

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. Optional.

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

SocketOptionResponsePacket.

Raises

See also

XBeeAPIPacket._check_api_packet()
needs_id()[source]

Override method.

property socket_id

Integer. Socket ID.

property option

SocketOption. Socket option.

property status

SocketStatus. Socket option status

property option_data

Bytearray. Socket option data.

property frame_id

Returns the frame ID of the packet.

Returns

the frame ID of the packet.

Return type

Integer

get_checksum()

Returns the checksum value of this XBeePacket.

The checksum is the last 8 bits of the sum of the bytes between the length field and the checksum field.

Returns

checksum value of this XBeePacket.

Return type

Integer

See also

get_frame_spec_data()

Override method.

get_frame_type()

Returns the frame type of this packet.

Returns

the frame type of this packet.

Return type

ApiFrameType

See also

get_frame_type_value()

Returns the frame type integer value of this packet.

Returns

the frame type integer value of this packet.

Return type

Integer

See also

is_broadcast()

Returns whether this packet is broadcast or not.

Returns

True if this packet is broadcast, False otherwise.

Return type

Boolean

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.socket.SocketConnectPacket(frame_id, socket_id, dest_port, dest_address_type, dest_address)[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:

Class constructor. Instantiates a new SocketConnectPacket object with the provided parameters.

Parameters
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 than SocketConnectPacket.DEST_ADDRESS_BINARY and SocketConnectPacket.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

SocketConnectPacket.

Raises

See also

XBeeAPIPacket._check_api_packet()
needs_id()[source]

Override method.

property socket_id

Integer. Socket ID.

property dest_port

Integer. Destination port.

property dest_address_type

Integer. Destination address type.

property dest_address

Bytearray. Destination address.

property frame_id

Returns the frame ID of the packet.

Returns

the frame ID of the packet.

Return type

Integer

get_checksum()

Returns the checksum value of this XBeePacket.

The checksum is the last 8 bits of the sum of the bytes between the length field and the checksum field.

Returns

checksum value of this XBeePacket.

Return type

Integer

See also

get_frame_spec_data()

Override method.

get_frame_type()

Returns the frame type of this packet.

Returns

the frame type of this packet.

Return type

ApiFrameType

See also

get_frame_type_value()

Returns the frame type integer value of this packet.

Returns

the frame type integer value of this packet.

Return type

Integer

See also

is_broadcast()

Returns whether this packet is broadcast or not.

Returns

True if this packet is broadcast, False otherwise.

Return type

Boolean

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.socket.SocketConnectResponsePacket(frame_id, socket_id, status)[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.

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.

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

SocketConnectResponsePacket.

Raises

See also

XBeeAPIPacket._check_api_packet()
needs_id()[source]

Override method.

property socket_id

Integer. Socket ID.

property status

SocketStatus. Socket connect status.

property frame_id

Returns the frame ID of the packet.

Returns

the frame ID of the packet.

Return type

Integer

get_checksum()

Returns the checksum value of this XBeePacket.

The checksum is the last 8 bits of the sum of the bytes between the length field and the checksum field.

Returns

checksum value of this XBeePacket.

Return type

Integer

See also

get_frame_spec_data()

Override method.

get_frame_type()

Returns the frame type of this packet.

Returns

the frame type of this packet.

Return type

ApiFrameType

See also

get_frame_type_value()

Returns the frame type integer value of this packet.

Returns

the frame type integer value of this packet.

Return type

Integer

See also

is_broadcast()

Returns whether this packet is broadcast or not.

Returns

True if this packet is broadcast, False otherwise.

Return type

Boolean

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.socket.SocketClosePacket(frame_id, socket_id)[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.

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.

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

SocketClosePacket.

Raises

See also

XBeeAPIPacket._check_api_packet()
needs_id()[source]

Override method.

property socket_id

Integer. Socket ID.

property frame_id

Returns the frame ID of the packet.

Returns

the frame ID of the packet.

Return type

Integer

get_checksum()

Returns the checksum value of this XBeePacket.

The checksum is the last 8 bits of the sum of the bytes between the length field and the checksum field.

Returns

checksum value of this XBeePacket.

Return type

Integer

See also

get_frame_spec_data()

Override method.

get_frame_type()

Returns the frame type of this packet.

Returns

the frame type of this packet.

Return type

ApiFrameType

See also

get_frame_type_value()

Returns the frame type integer value of this packet.

Returns

the frame type integer value of this packet.

Return type

Integer

See also

is_broadcast()

Returns whether this packet is broadcast or not.

Returns

True if this packet is broadcast, False otherwise.

Return type

Boolean

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.socket.SocketCloseResponsePacket(frame_id, socket_id, status)[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.

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.

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

SocketCloseResponsePacket.

Raises

See also

XBeeAPIPacket._check_api_packet()
needs_id()[source]

Override method.

property socket_id

Integer. Socket ID.

property status

SocketStatus. Socket close status.

property frame_id

Returns the frame ID of the packet.

Returns

the frame ID of the packet.

Return type

Integer

get_checksum()

Returns the checksum value of this XBeePacket.

The checksum is the last 8 bits of the sum of the bytes between the length field and the checksum field.

Returns

checksum value of this XBeePacket.

Return type

Integer

See also

get_frame_spec_data()

Override method.

get_frame_type()

Returns the frame type of this packet.

Returns

the frame type of this packet.

Return type

ApiFrameType

See also

get_frame_type_value()

Returns the frame type integer value of this packet.

Returns

the frame type integer value of this packet.

Return type

Integer

See also

is_broadcast()

Returns whether this packet is broadcast or not.

Returns

True if this packet is broadcast, False otherwise.

Return type

Boolean

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.socket.SocketSendPacket(frame_id, socket_id, payload=None)[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.

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.

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

SocketSendPacket.

Raises

See also

XBeeAPIPacket._check_api_packet()
needs_id()[source]

Override method.

property socket_id

Integer. Socket ID.

property payload

Bytearray. Payload to send.

property frame_id

Returns the frame ID of the packet.

Returns

the frame ID of the packet.

Return type

Integer

get_checksum()

Returns the checksum value of this XBeePacket.

The checksum is the last 8 bits of the sum of the bytes between the length field and the checksum field.

Returns

checksum value of this XBeePacket.

Return type

Integer

See also

get_frame_spec_data()

Override method.

get_frame_type()

Returns the frame type of this packet.

Returns

the frame type of this packet.

Return type

ApiFrameType

See also

get_frame_type_value()

Returns the frame type integer value of this packet.

Returns

the frame type integer value of this packet.

Return type

Integer

See also

is_broadcast()

Returns whether this packet is broadcast or not.

Returns

True if this packet is broadcast, False otherwise.

Return type

Boolean

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.socket.SocketSendToPacket(frame_id, socket_id, dest_address, dest_port, payload=None)[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.

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.

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

SocketSendToPacket.

Raises

See also

XBeeAPIPacket._check_api_packet()
needs_id()[source]

Override method.

property socket_id

Integer. Socket ID.

property dest_address

ipaddress.IPv4Address. IPv4 address of the destination device.

property dest_port

Integer. Destination port.

property payload

Bytearray. Payload to send.

property frame_id

Returns the frame ID of the packet.

Returns

the frame ID of the packet.

Return type

Integer

get_checksum()

Returns the checksum value of this XBeePacket.

The checksum is the last 8 bits of the sum of the bytes between the length field and the checksum field.

Returns

checksum value of this XBeePacket.

Return type

Integer

See also

get_frame_spec_data()

Override method.

get_frame_type()

Returns the frame type of this packet.

Returns

the frame type of this packet.

Return type

ApiFrameType

See also

get_frame_type_value()

Returns the frame type integer value of this packet.

Returns

the frame type integer value of this packet.

Return type

Integer

See also

is_broadcast()

Returns whether this packet is broadcast or not.

Returns

True if this packet is broadcast, False otherwise.

Return type

Boolean

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.socket.SocketBindListenPacket(frame_id, socket_id, source_port)[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

SocketReceiveFromIPv4Packet

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.

  • source_port (Integer) – the port to listen on.

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

SocketBindListenPacket.

Raises

See also

XBeeAPIPacket._check_api_packet()
needs_id()[source]

Override method.

property socket_id

Integer. Socket ID.

property source_port

Integer. Source port.

property frame_id

Returns the frame ID of the packet.

Returns

the frame ID of the packet.

Return type

Integer

get_checksum()

Returns the checksum value of this XBeePacket.

The checksum is the last 8 bits of the sum of the bytes between the length field and the checksum field.

Returns

checksum value of this XBeePacket.

Return type

Integer

See also

get_frame_spec_data()

Override method.

get_frame_type()

Returns the frame type of this packet.

Returns

the frame type of this packet.

Return type

ApiFrameType

See also

get_frame_type_value()

Returns the frame type integer value of this packet.

Returns

the frame type integer value of this packet.

Return type

Integer

See also

is_broadcast()

Returns whether this packet is broadcast or not.

Returns

True if this packet is broadcast, False otherwise.

Return type

Boolean

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.socket.SocketListenResponsePacket(frame_id, socket_id, status)[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).

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.

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

SocketListenResponsePacket.

Raises

See also

XBeeAPIPacket._check_api_packet()
needs_id()[source]

Override method.

property socket_id

Integer. Socket ID.

property status

SocketStatus. Socket listen status.

property frame_id

Returns the frame ID of the packet.

Returns

the frame ID of the packet.

Return type

Integer

get_checksum()

Returns the checksum value of this XBeePacket.

The checksum is the last 8 bits of the sum of the bytes between the length field and the checksum field.

Returns

checksum value of this XBeePacket.

Return type

Integer

See also

get_frame_spec_data()

Override method.

get_frame_type()

Returns the frame type of this packet.

Returns

the frame type of this packet.

Return type

ApiFrameType

See also

get_frame_type_value()

Returns the frame type integer value of this packet.

Returns

the frame type integer value of this packet.

Return type

Integer

See also

is_broadcast()

Returns whether this packet is broadcast or not.

Returns

True if this packet is broadcast, False otherwise.

Return type

Boolean

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.socket.SocketNewIPv4ClientPacket(socket_id, client_socket_id, remote_address, remote_port)[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.

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

SocketNewIPv4ClientPacket.

Raises

See also

XBeeAPIPacket._check_api_packet()
needs_id()[source]

Override method.

property socket_id

Integer. Socket ID.

property client_socket_id

Integer. Client socket ID.

property remote_address

ipaddress.IPv4Address. Remote IPv4 address.

property remote_port

Integer. Remote port.

property frame_id

Returns the frame ID of the packet.

Returns

the frame ID of the packet.

Return type

Integer

get_checksum()

Returns the checksum value of this XBeePacket.

The checksum is the last 8 bits of the sum of the bytes between the length field and the checksum field.

Returns

checksum value of this XBeePacket.

Return type

Integer

See also

get_frame_spec_data()

Override method.

get_frame_type()

Returns the frame type of this packet.

Returns

the frame type of this packet.

Return type

ApiFrameType

See also

get_frame_type_value()

Returns the frame type integer value of this packet.

Returns

the frame type integer value of this packet.

Return type

Integer

See also

is_broadcast()

Returns whether this packet is broadcast or not.

Returns

True if this packet is broadcast, False otherwise.

Return type

Boolean

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.socket.SocketReceivePacket(frame_id, socket_id, payload=None)[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.

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

SocketReceivePacket.

Raises

See also

XBeeAPIPacket._check_api_packet()
needs_id()[source]

Override method.

property socket_id

Integer. Socket ID.

property payload

Bytearray. Payload that was received.

property frame_id

Returns the frame ID of the packet.

Returns

the frame ID of the packet.

Return type

Integer

get_checksum()

Returns the checksum value of this XBeePacket.

The checksum is the last 8 bits of the sum of the bytes between the length field and the checksum field.

Returns

checksum value of this XBeePacket.

Return type

Integer

See also

get_frame_spec_data()

Override method.

get_frame_type()

Returns the frame type of this packet.

Returns

the frame type of this packet.

Return type

ApiFrameType

See also

get_frame_type_value()

Returns the frame type integer value of this packet.

Returns

the frame type integer value of this packet.

Return type

Integer

See also

is_broadcast()

Returns whether this packet is broadcast or not.

Returns

True if this packet is broadcast, False otherwise.

Return type

Boolean

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.socket.SocketReceiveFromPacket(frame_id, socket_id, source_address, source_port, payload=None)[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.

  • source_address (IPv4Address) – IPv4 address of the source device.

  • source_port (Integer) – source port number.

  • payload (Bytearray, optional) – data that is received.

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

property frame_id

Returns the frame ID of the packet.

Returns

the frame ID of the packet.

Return type

Integer

get_checksum()

Returns the checksum value of this XBeePacket.

The checksum is the last 8 bits of the sum of the bytes between the length field and the checksum field.

Returns

checksum value of this XBeePacket.

Return type

Integer

See also

get_frame_spec_data()

Override method.

get_frame_type()

Returns the frame type of this packet.

Returns

the frame type of this packet.

Return type

ApiFrameType

See also

get_frame_type_value()

Returns the frame type integer value of this packet.

Returns

the frame type integer value of this packet.

Return type

Integer

See also

is_broadcast()

Returns whether this packet is broadcast or not.

Returns

True if this packet is broadcast, False otherwise.

Return type

Boolean

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

SocketReceiveFromPacket.

Raises

See also

XBeeAPIPacket._check_api_packet()
needs_id()[source]

Override method.

property socket_id

Integer. Socket ID.

property source_address

ipaddress.IPv4Address. IPv4 address of the source device.

property source_port

Integer. Source port.

property payload

Bytearray. Payload that has been received.

class digi.xbee.packets.socket.SocketStatePacket(socket_id, state)[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.

Raises

ValueError – if socket_id is less than 0 or greater than 255.

See also

SockeState
property frame_id

Returns the frame ID of the packet.

Returns

the frame ID of the packet.

Return type

Integer

get_checksum()

Returns the checksum value of this XBeePacket.

The checksum is the last 8 bits of the sum of the bytes between the length field and the checksum field.

Returns

checksum value of this XBeePacket.

Return type

Integer

See also

get_frame_spec_data()

Override method.

get_frame_type()

Returns the frame type of this packet.

Returns

the frame type of this packet.

Return type

ApiFrameType

See also

get_frame_type_value()

Returns the frame type integer value of this packet.

Returns

the frame type integer value of this packet.

Return type

Integer

See also

is_broadcast()

Returns whether this packet is broadcast or not.

Returns

True if this packet is broadcast, False otherwise.

Return type

Boolean

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

SocketStatePacket.

Raises

See also

XBeeAPIPacket._check_api_packet()
needs_id()[source]

Override method.

property socket_id

Integer. Socket ID.

property state

SocketState. Socket state.