digi.xbee.packets.cellular module

digi.xbee.packets.cellular.PATTERN_PHONE_NUMBER = '^\\+?\\d+$'

Pattern used to validate the phone number parameter of SMS packets.

class digi.xbee.packets.cellular.RXSMSPacket(phone_number, data, op_mode=<OperatingMode.API_MODE: (1, 'API mode')>)[source]

Bases: digi.xbee.packets.base.XBeeAPIPacket

This class represents an RX (Receive) SMS packet. Packet is built using the parameters of the constructor or providing a valid byte array.

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

Parameters:
  • phone_number (String) – Phone number of the device that sent the SMS.
  • data (String or bytearray) – Packet data (text of the SMS).
  • op_mode (OperatingMode, optional, default=`OperatingMode.API_MODE`) – The mode in which the frame was captured.
Raises:
  • ValueError – if length of phone_number is greater than 20.
  • ValueError – if phone_number is not a valid phone number.
static create_packet(raw, operating_mode)[source]

Override method.

Returns:

RXSMSPacket

Raises:
  • InvalidPacketException – if the bytearray length is less than 25. (start delim + length (2 bytes) + frame type + phone number (20 bytes) + checksum = 25 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. See SPECIAL_BYTE.
  • InvalidPacketException – if the calculated checksum is different from the checksum field value (last byte).
  • InvalidPacketException – if the frame type is different than ApiFrameType.RX_SMS.
  • InvalidOperatingModeException – if operating_mode is not supported.
needs_id()[source]

Override method.

get_phone_number_byte_array()[source]

Returns the phone number byte array.

Returns:phone number of the device that sent the SMS.
Return type:Bytearray
phone_number

Returns the phone number of the device that sent the SMS.

Returns:phone number of the device that sent the SMS.
Return type:String
data

Returns the data of the packet (SMS text).

Returns:the data of the packet.
Return type:String
effective_len

Returns the effective length of the packet.

Returns:Effective length of the packet.
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.

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.cellular.TXSMSPacket(frame_id, phone_number, data, op_mode=<OperatingMode.API_MODE: (1, 'API mode')>)[source]

Bases: digi.xbee.packets.base.XBeeAPIPacket

This class represents a TX (Transmit) SMS packet. Packet is built using the parameters of the constructor or providing a valid byte array.

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

Parameters:
  • frame_id (Integer) – the frame ID. Must be between 0 and 255.
  • phone_number (String) – the phone number.
  • data (String or bytearray) – this packet’s data.
  • op_mode (OperatingMode, optional, default=`OperatingMode.API_MODE`) – The mode in which the frame was captured.
Raises:
  • ValueError – if frame_id is not between 0 and 255.
  • ValueError – if length of phone_number is greater than 20.
  • ValueError – if phone_number is not a valid phone number.

See also

static create_packet(raw, operating_mode)[source]

Override method.

Returns:

TXSMSPacket

Raises:
  • InvalidPacketException – if the bytearray length is less than 27. (start delim, length (2 bytes), frame type, frame id, transmit options, phone number (20 bytes), checksum)
  • 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. See SPECIAL_BYTE.
  • InvalidPacketException – if the calculated checksum is different from the checksum field value (last byte).
  • InvalidPacketException – if the frame type is different than ApiFrameType.TX_SMS.
  • InvalidOperatingModeException – if operating_mode is not supported.
needs_id()[source]

Override method.

effective_len

Returns the effective length of the packet.

Returns:Effective length of the packet.
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.

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

get_phone_number_byte_array()[source]

Returns the phone number byte array.

Returns:phone number of the device that sent the SMS.
Return type:Bytearray
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
phone_number

Returns the phone number of the transmitter device.

Returns:the phone number of the transmitter device.
Return type:String
data

Returns the data of the packet (SMS text).

Returns:packet’s data.
Return type:Bytearray