digi.xbee.models.message module
- class digi.xbee.models.message.XBeeMessage(data, remote_node, timestamp, broadcast=False)[source]
Bases:
objectThis class represents a XBee message, which is formed by a
RemoteXBeeDevice(the sender) and some data (the data sent) as a bytearray.Class constructor.
- Parameters:
data (Bytearray) – the data sent.
remote_node (
RemoteXBeeDevice) – the sender.broadcast (Boolean, optional, default=`False`) – flag indicating whether the message is broadcast (True) or not (False). Optional.
timestamp – instant of time when the message was received.
- property data
Returns a bytearray containing the data of the message.
- Returns:
the data of the message.
- Return type:
Bytearray
- property remote_device
Returns the device which has sent the message.
- Returns:
the device which has sent the message.
- Return type:
- property is_broadcast
Returns whether the message is broadcast or not.
- Returns:
True if the message is broadcast, False otherwise.
- Return type:
Boolean
- property timestamp
Returns the moment when the message was received as a time.time() function returned value.
- Returns:
- the returned value of using
time.time()function when the message was received.
- the returned value of using
- Return type:
Float
- class digi.xbee.models.message.ExplicitXBeeMessage(data, remote_node, timestamp, src_endpoint, dest_endpoint, cluster_id, profile_id, broadcast=False)[source]
Bases:
XBeeMessageThis class represents an Explicit XBee message, which is formed by all parameters of a common XBee message and: Source endpoint, destination endpoint, cluster ID, profile ID.
Class constructor.
- Parameters:
data (Bytearray) – the data sent.
remote_node (
RemoteXBeeDevice) – the sender device.timestamp – instant of time when the message was received.
src_endpoint (Integer) – source endpoint of the message. 1 byte.
dest_endpoint (Integer) – destination endpoint of the message. 1 byte.
cluster_id (Integer) – cluster id of the message. 2 bytes.
profile_id (Integer) – profile id of the message. 2 bytes.
broadcast (Boolean, optional, default=`False`) – flag indicating whether the message is broadcast (True) or not (False). Optional.
- property source_endpoint
Returns the source endpoint of the message.
- Returns:
the source endpoint of the message. 1 byte.
- Return type:
Integer
- property dest_endpoint
Returns the destination endpoint of the message.
- Returns:
the destination endpoint of the message. 1 byte.
- Return type:
Integer
- property cluster_id
Returns the cluster ID of the message.
- Returns:
the cluster ID of the message. 2 bytes.
- Return type:
Integer
- property profile_id
Returns the profile ID of the message.
- Returns:
the profile ID of the message. 2 bytes.
- Return type:
Integer
- property data
Returns a bytearray containing the data of the message.
- Returns:
the data of the message.
- Return type:
Bytearray
- property is_broadcast
Returns whether the message is broadcast or not.
- Returns:
True if the message is broadcast, False otherwise.
- Return type:
Boolean
- property remote_device
Returns the device which has sent the message.
- Returns:
the device which has sent the message.
- Return type:
- property timestamp
Returns the moment when the message was received as a time.time() function returned value.
- Returns:
- the returned value of using
time.time()function when the message was received.
- the returned value of using
- Return type:
Float
- class digi.xbee.models.message.IPMessage(ip_addr, src_port, dest_port, protocol, data)[source]
Bases:
objectThis class represents an IP message containing the IP address the message belongs to, the source and destination ports, the IP protocol, and the content (data) of the message.
Class constructor.
- Parameters:
ip_addr (
ipaddress.IPv4Address) – The IP address the message comes from.src_port (Integer) – TCP or UDP source port of the transmission.
dest_port (Integer) – TCP or UDP destination port of the transmission.
protocol (
IPProtocol) – IP protocol used in the transmission.data (Bytearray) – the data sent.
- Raises:
ValueError – if ip_addr is None.
ValueError – if protocol is None.
ValueError – if data is None.
ValueError – if source_port is less than 0 or greater than 65535.
ValueError – if dest_port is less than 0 or greater than 65535.
- property ip_addr
Returns the IPv4 address this message is associated to.
- Returns:
The IPv4 address this message is associated to.
- Return type:
ipaddress.IPv4Address
- property source_port
Returns the source port of the transmission.
- Returns:
The source port of the transmission.
- Return type:
Integer
- property dest_port
Returns the destination port of the transmission.
- Returns:
The destination port of the transmission.
- Return type:
Integer
- property protocol
Returns the protocol used in the transmission.
- Returns:
The protocol used in the transmission.
- Return type:
- property data
Returns a bytearray containing the data of the message.
- Returns:
the data of the message.
- Return type:
Bytearray
- class digi.xbee.models.message.SMSMessage(phone_number, data)[source]
Bases:
objectThis class represents an SMS message containing the phone number that sent the message and the content (data) of the message.
This class is used within the library to read SMS sent to Cellular devices.
Class constructor. Instantiates a new
SMSMessageobject with the provided parameters.- Parameters:
phone_number (String) – The phone number that sent the message.
data (String) – The message text.
- Raises:
ValueError – if phone_number is None.
ValueError – if data is None.
ValueError – if phone_number is not a valid phone number.
- property phone_number
Returns the phone number that sent the message.
- Returns:
The phone number that sent the message.
- Return type:
String
- property data
Returns the data of the message.
- Returns:
The data of the message.
- Return type:
String
- class digi.xbee.models.message.UserDataRelayMessage(local_iface, data)[source]
Bases:
objectThis class represents a user data relay message containing the source interface and the content (data) of the message.
See also
Class constructor. Instantiates a new
UserDataRelayMessageobject with the provided parameters.- Parameters:
local_iface (
XBeeLocalInterface) – The source XBee local interface.data (Bytearray) – Byte array containing the data of the message.
- Raises:
ValueError – if relay_interface is None.
See also
- property local_interface
Returns the source interface that sent the message.
- Returns:
The source interface that sent the message.
- Return type:
- property data
Returns the data of the message.
- Returns:
The data of the message.
- Return type:
Bytearray
- class digi.xbee.models.message.BLEGAPScanLegacyAdvertisementMessage(address, address_type, advertisement_flags, rssi, payload)[source]
Bases:
_BLEGAPScanBaseAdvertisementMessageThis class represents a ‘Legacy’ BLE advertising message, that contains the address that the message was received from, the type of address it is, whether the device is connectable or not, the RSSI of the advertisement, and the payload that was sent.
Class constructor.
- Parameters:
address (
XBeeBLEAddress) – The BLE address the message comes from.address_type (Integer) – The type of BLE address.
advertisement_flags (Integer) – Flags. Includes whether connectable or not.
rssi (Float) – The received signal strength of the advertisement, in dBm.
payload (Bytearray) – The data payload of the advertisement.
- Raises:
ValueError – if address is None.
ValueError – if address_type is None.
ValueError – if advertisement_flags is None.
ValueError – if rssi is None.
ValueError – if payload is None.
- property address
Returns the BLE MAC address of the sender of the advertisement.
- Returns:
the BLE address of the sender.
- Return type:
- property address_type
Returns the type of BLE address of the sender.
- Returns:
The type of BLE address.
- Return type:
- property connectable
Returns if the advertising device indicates that BLE central-mode devices may connect to it.
- Returns:
True if connectable, False otherwise.
- Return type:
Boolean
- property name
Returns the Local/Short name, if the sender presented one.
- Returns:
The Local/Short name.
- Return type:
Str
- property payload
Returns a bytearray containing the data of the message.
- Returns:
the data of the message.
- Return type:
Bytearray
- property rssi
Returns the received signal strength of the advertisement, in dBm.
- Returns:
The RSSI value.
- Return type:
Integer
- to_dict()
Returns the message information as a dictionary.
- class digi.xbee.models.message.BLEGAPScanExtendedAdvertisementMessage(address, address_type, advertisement_flags, rssi, advertisement_set_id, primary_phy, secondary_phy, tx_power, periodic_interval, data_completeness, payload)[source]
Bases:
_BLEGAPScanBaseAdvertisementMessageThis class represents an ‘Extended’ BLE advertising message, that contains the address that the message was received from, the type of address it is, whether the device is connectable or not, the RSSI of the advertisement, and the payload that was sent.
Class constructor.
- Parameters:
address (
XBeeBLEAddress) – The BLE address the message comes from.address_type (Integer) – The type of BLE address.
advertisement_flags (Integer) – Flags. Includes whether connectable or not.
rssi (Float) – The received signal strength of the advertisement, in dBm.
advertisement_set_id (Integer) – A device can broadcast multiple advertisements at a time. The set identifier will help identify which advertisement you received.
primary_phy (Integer) – This is the preferred PHY for connecting with this device. Values are: 0x1: 1M PHY 0x2: 2M PHY 0x4: LE Coded PHY 125k 0x8: LE Coded PHY 500k 0xFF : Any PHY supported
secondary_phy (Integer) – This is the secondary PHY for connecting with this device. This has the same values as primary_phy.
tx_power (Integer) – Transmission power of received advertisement. This is a signed value.
periodic_interval (Integer) – Interval for periodic advertising. 0 indicates no periodic advertising. Interval value is in increments of 1.25 ms.
data_completeness (Integer) – Values are: 0x0: indicates all data of the advertisement has been reported. 0x1: Data is incomplete, but more data will follow. 0x2: Data is incomplete, but no more data is following. Data has be truncated.
payload (Bytearray) – The data payload of the advertisement.
- Raises:
ValueError – if address is None.
ValueError – if address_type is None.
ValueError – if advertisement_flags is None.
ValueError – if rssi is None.
ValueError – if advertisement_set_id is None.
ValueError – if primary_phy is None.
ValueError – if secondary_phy is None.
ValueError – if tx_power is None.
ValueError – if periodic_interval is None.
ValueError – if data_completeness is None.
ValueError – if payload is None.
- property advertisement_set_id
Returns the advertisement set identifier used to help identify which advertisement you received.
- Returns:
the advertisement set identifier.
- Return type:
Integer
- property primary_phy
Returns the preferred PHY for connecting this device.
- Returns:
the primary PHY
- Return type:
Integer
- property secondary_phy
Returns the secondary PHY for connecting this device.
- Returns:
the secondary PHY.
- Return type:
Integer
- property tx_power
Returns the transmission power of received advertisement. This is a signed value.
- Returns:
transmission power.
- Return type:
Integer
- property periodic_interval
Returns the interval for periodic advertising. 0 indicates no periodic advertising.
- Returns:
periodic interval.
- Return type:
Integer
- property data_completeness
Returns the data completeness field.
- Returns:
data completeness field.
- Return type:
Integer
- property address
Returns the BLE MAC address of the sender of the advertisement.
- Returns:
the BLE address of the sender.
- Return type:
- property address_type
Returns the type of BLE address of the sender.
- Returns:
The type of BLE address.
- Return type:
- property connectable
Returns if the advertising device indicates that BLE central-mode devices may connect to it.
- Returns:
True if connectable, False otherwise.
- Return type:
Boolean
- property name
Returns the Local/Short name, if the sender presented one.
- Returns:
The Local/Short name.
- Return type:
Str
- property payload
Returns a bytearray containing the data of the message.
- Returns:
the data of the message.
- Return type:
Bytearray
- property rssi
Returns the received signal strength of the advertisement, in dBm.
- Returns:
The RSSI value.
- Return type:
Integer
- class digi.xbee.models.message.BLEGAPScanStatusMessage(status)[source]
Bases:
objectThis class represents a BLE GAP scan status message. It will store the Status value received.
Class constructor.
- Parameters:
status (Integer) – The status of the GAP scan.
- Raises:
ValueError – if status is invalid.
- property status
Returns the status of the GAP scan.
- Returns:
The status of the GAP scan.
- Return type: