digi.xbee.reader module¶
-
class
digi.xbee.reader.XBeeEvent(iterable=(), /)[source]¶ Bases:
listThis class represents a generic XBee event.
New event callbacks can be added here following this prototype:
def callback_prototype(*args, **kwargs): #do something...
All of them will be executed when the event is fired.
See also
list (Python standard class)-
append(object, /)¶ Append object to the end of the list.
-
clear()¶ Remove all items from list.
-
copy()¶ Return a shallow copy of the list.
-
count(value, /)¶ Return number of occurrences of value.
-
extend(iterable, /)¶ Extend list by appending elements from the iterable.
-
index(value, start=0, stop=9223372036854775807, /)¶ Return first index of value.
Raises ValueError if the value is not present.
-
insert(index, object, /)¶ Insert object before index.
-
pop(index=-1, /)¶ Remove and return item at index (default last).
Raises IndexError if list is empty or index is out of range.
-
remove(value, /)¶ Remove first occurrence of value.
Raises ValueError if the value is not present.
-
reverse()¶ Reverse IN PLACE.
-
sort(*, key=None, reverse=False)¶ Stable sort IN PLACE.
-
-
class
digi.xbee.reader.PacketReceived(iterable=(), /)[source]¶ Bases:
digi.xbee.reader.XBeeEventThis event is fired when an XBee receives any packet, independent of its frame type.
- The callbacks for handle this events will receive the following arguments:
received_packet (
XBeeAPIPacket): the received packet.
See also
-
append(object, /)¶ Append object to the end of the list.
-
clear()¶ Remove all items from list.
-
copy()¶ Return a shallow copy of the list.
-
count(value, /)¶ Return number of occurrences of value.
-
extend(iterable, /)¶ Extend list by appending elements from the iterable.
-
index(value, start=0, stop=9223372036854775807, /)¶ Return first index of value.
Raises ValueError if the value is not present.
-
insert(index, object, /)¶ Insert object before index.
-
pop(index=-1, /)¶ Remove and return item at index (default last).
Raises IndexError if list is empty or index is out of range.
-
remove(value, /)¶ Remove first occurrence of value.
Raises ValueError if the value is not present.
-
reverse()¶ Reverse IN PLACE.
-
sort(*, key=None, reverse=False)¶ Stable sort IN PLACE.
-
class
digi.xbee.reader.DataReceived(iterable=(), /)[source]¶ Bases:
digi.xbee.reader.XBeeEventThis event is fired when an XBee receives data.
- The callbacks for handle this events will receive the following arguments:
message (
XBeeMessage): message containing the data received, the sender and the time.
See also
-
append(object, /)¶ Append object to the end of the list.
-
clear()¶ Remove all items from list.
-
copy()¶ Return a shallow copy of the list.
-
count(value, /)¶ Return number of occurrences of value.
-
extend(iterable, /)¶ Extend list by appending elements from the iterable.
-
index(value, start=0, stop=9223372036854775807, /)¶ Return first index of value.
Raises ValueError if the value is not present.
-
insert(index, object, /)¶ Insert object before index.
-
pop(index=-1, /)¶ Remove and return item at index (default last).
Raises IndexError if list is empty or index is out of range.
-
remove(value, /)¶ Remove first occurrence of value.
Raises ValueError if the value is not present.
-
reverse()¶ Reverse IN PLACE.
-
sort(*, key=None, reverse=False)¶ Stable sort IN PLACE.
-
class
digi.xbee.reader.ModemStatusReceived(iterable=(), /)[source]¶ Bases:
digi.xbee.reader.XBeeEventThis event is fired when a XBee receives a modem status packet.
- The callbacks for handle this events will receive the following arguments:
modem_status (
ModemStatus): the modem status received.
See also
-
append(object, /)¶ Append object to the end of the list.
-
clear()¶ Remove all items from list.
-
copy()¶ Return a shallow copy of the list.
-
count(value, /)¶ Return number of occurrences of value.
-
extend(iterable, /)¶ Extend list by appending elements from the iterable.
-
index(value, start=0, stop=9223372036854775807, /)¶ Return first index of value.
Raises ValueError if the value is not present.
-
insert(index, object, /)¶ Insert object before index.
-
pop(index=-1, /)¶ Remove and return item at index (default last).
Raises IndexError if list is empty or index is out of range.
-
remove(value, /)¶ Remove first occurrence of value.
Raises ValueError if the value is not present.
-
reverse()¶ Reverse IN PLACE.
-
sort(*, key=None, reverse=False)¶ Stable sort IN PLACE.
-
class
digi.xbee.reader.IOSampleReceived(iterable=(), /)[source]¶ Bases:
digi.xbee.reader.XBeeEventThis event is fired when a XBee receives an IO packet.
This includes:
IO data sample RX indicator packet.
RX IO 16 packet.
RX IO 64 packet.
- The callbacks that handle this event will receive the following arguments:
io_sample (
IOSample): the received IO sample.sender (
RemoteXBeeDevice): the remote XBee device who has sent the packet.time (Integer): the time in which the packet was received.
See also
-
append(object, /)¶ Append object to the end of the list.
-
clear()¶ Remove all items from list.
-
copy()¶ Return a shallow copy of the list.
-
count(value, /)¶ Return number of occurrences of value.
-
extend(iterable, /)¶ Extend list by appending elements from the iterable.
-
index(value, start=0, stop=9223372036854775807, /)¶ Return first index of value.
Raises ValueError if the value is not present.
-
insert(index, object, /)¶ Insert object before index.
-
pop(index=-1, /)¶ Remove and return item at index (default last).
Raises IndexError if list is empty or index is out of range.
-
remove(value, /)¶ Remove first occurrence of value.
Raises ValueError if the value is not present.
-
reverse()¶ Reverse IN PLACE.
-
sort(*, key=None, reverse=False)¶ Stable sort IN PLACE.
-
class
digi.xbee.reader.NetworkModified(iterable=(), /)[source]¶ Bases:
digi.xbee.reader.XBeeEventThis event is fired when the network is being modified by the addition of a new node, an existing node information is updated, a node removal, or when the network items are cleared.
- The callbacks that handle this event will receive the following arguments:
event_type (
digi.xbee.devices.NetworkEventType): the network event type.reason (
digi.xbee.devices.NetworkEventReason): The reason of the event.node (
digi.xbee.devices.XBeeDeviceordigi.xbee.devices.RemoteXBeeDevice): The node added, updated or removed from the network.
See also
-
append(object, /)¶ Append object to the end of the list.
-
clear()¶ Remove all items from list.
-
copy()¶ Return a shallow copy of the list.
-
count(value, /)¶ Return number of occurrences of value.
-
extend(iterable, /)¶ Extend list by appending elements from the iterable.
-
index(value, start=0, stop=9223372036854775807, /)¶ Return first index of value.
Raises ValueError if the value is not present.
-
insert(index, object, /)¶ Insert object before index.
-
pop(index=-1, /)¶ Remove and return item at index (default last).
Raises IndexError if list is empty or index is out of range.
-
remove(value, /)¶ Remove first occurrence of value.
Raises ValueError if the value is not present.
-
reverse()¶ Reverse IN PLACE.
-
sort(*, key=None, reverse=False)¶ Stable sort IN PLACE.
-
class
digi.xbee.reader.DeviceDiscovered(iterable=(), /)[source]¶ Bases:
digi.xbee.reader.XBeeEventThis event is fired when an XBee discovers another remote XBee during a discovering operation.
- The callbacks that handle this event will receive the following arguments:
discovered_device (
RemoteXBeeDevice): the discovered remote XBee device.
See also
-
append(object, /)¶ Append object to the end of the list.
-
clear()¶ Remove all items from list.
-
copy()¶ Return a shallow copy of the list.
-
count(value, /)¶ Return number of occurrences of value.
-
extend(iterable, /)¶ Extend list by appending elements from the iterable.
-
index(value, start=0, stop=9223372036854775807, /)¶ Return first index of value.
Raises ValueError if the value is not present.
-
insert(index, object, /)¶ Insert object before index.
-
pop(index=-1, /)¶ Remove and return item at index (default last).
Raises IndexError if list is empty or index is out of range.
-
remove(value, /)¶ Remove first occurrence of value.
Raises ValueError if the value is not present.
-
reverse()¶ Reverse IN PLACE.
-
sort(*, key=None, reverse=False)¶ Stable sort IN PLACE.
-
class
digi.xbee.reader.DiscoveryProcessFinished(iterable=(), /)[source]¶ Bases:
digi.xbee.reader.XBeeEventThis event is fired when the discovery process finishes, either successfully or due to an error.
- The callbacks that handle this event will receive the following arguments:
status (
NetworkDiscoveryStatus): the network discovery status.
See also
-
append(object, /)¶ Append object to the end of the list.
-
clear()¶ Remove all items from list.
-
copy()¶ Return a shallow copy of the list.
-
count(value, /)¶ Return number of occurrences of value.
-
extend(iterable, /)¶ Extend list by appending elements from the iterable.
-
index(value, start=0, stop=9223372036854775807, /)¶ Return first index of value.
Raises ValueError if the value is not present.
-
insert(index, object, /)¶ Insert object before index.
-
pop(index=-1, /)¶ Remove and return item at index (default last).
Raises IndexError if list is empty or index is out of range.
-
remove(value, /)¶ Remove first occurrence of value.
Raises ValueError if the value is not present.
-
reverse()¶ Reverse IN PLACE.
-
sort(*, key=None, reverse=False)¶ Stable sort IN PLACE.
-
class
digi.xbee.reader.ExplicitDataReceived(iterable=(), /)[source]¶ Bases:
digi.xbee.reader.XBeeEventThis event is fired when an XBee receives an explicit data packet.
- The callbacks for handle this events will receive the following arguments:
- message (
ExplicitXBeeMessage): message containing the data received, the sender, the time and explicit data message parameters.
- message (
See also
-
append(object, /)¶ Append object to the end of the list.
-
clear()¶ Remove all items from list.
-
copy()¶ Return a shallow copy of the list.
-
count(value, /)¶ Return number of occurrences of value.
-
extend(iterable, /)¶ Extend list by appending elements from the iterable.
-
index(value, start=0, stop=9223372036854775807, /)¶ Return first index of value.
Raises ValueError if the value is not present.
-
insert(index, object, /)¶ Insert object before index.
-
pop(index=-1, /)¶ Remove and return item at index (default last).
Raises IndexError if list is empty or index is out of range.
-
remove(value, /)¶ Remove first occurrence of value.
Raises ValueError if the value is not present.
-
reverse()¶ Reverse IN PLACE.
-
sort(*, key=None, reverse=False)¶ Stable sort IN PLACE.
-
class
digi.xbee.reader.IPDataReceived(iterable=(), /)[source]¶ Bases:
digi.xbee.reader.XBeeEventThis event is fired when an XBee receives IP data.
- The callbacks for handle this events will receive the following arguments:
- message (
IPMessage): message containing containing the IP address the message belongs to, the source and destination ports, the IP protocol, and the content (data) of the message.
- message (
-
append(object, /)¶ Append object to the end of the list.
-
clear()¶ Remove all items from list.
-
copy()¶ Return a shallow copy of the list.
-
count(value, /)¶ Return number of occurrences of value.
-
extend(iterable, /)¶ Extend list by appending elements from the iterable.
-
index(value, start=0, stop=9223372036854775807, /)¶ Return first index of value.
Raises ValueError if the value is not present.
-
insert(index, object, /)¶ Insert object before index.
-
pop(index=-1, /)¶ Remove and return item at index (default last).
Raises IndexError if list is empty or index is out of range.
-
remove(value, /)¶ Remove first occurrence of value.
Raises ValueError if the value is not present.
-
reverse()¶ Reverse IN PLACE.
-
sort(*, key=None, reverse=False)¶ Stable sort IN PLACE.
-
class
digi.xbee.reader.SMSReceived(iterable=(), /)[source]¶ Bases:
digi.xbee.reader.XBeeEventThis event is fired when an XBee receives an SMS.
- The callbacks for handle this events will receive the following arguments:
- message (
SMSMessage): message containing the phone number that sent the message and the content (data) of the message.
- message (
See also
-
append(object, /)¶ Append object to the end of the list.
-
clear()¶ Remove all items from list.
-
copy()¶ Return a shallow copy of the list.
-
count(value, /)¶ Return number of occurrences of value.
-
extend(iterable, /)¶ Extend list by appending elements from the iterable.
-
index(value, start=0, stop=9223372036854775807, /)¶ Return first index of value.
Raises ValueError if the value is not present.
-
insert(index, object, /)¶ Insert object before index.
-
pop(index=-1, /)¶ Remove and return item at index (default last).
Raises IndexError if list is empty or index is out of range.
-
remove(value, /)¶ Remove first occurrence of value.
Raises ValueError if the value is not present.
-
reverse()¶ Reverse IN PLACE.
-
sort(*, key=None, reverse=False)¶ Stable sort IN PLACE.
-
class
digi.xbee.reader.RelayDataReceived(iterable=(), /)[source]¶ Bases:
digi.xbee.reader.XBeeEventThis event is fired when an XBee receives a user data relay output packet.
- The callbacks to handle these events will receive the following arguments:
- message (
UserDataRelayMessage): message containing the source interface and the content (data) of the message.
- message (
See also
-
append(object, /)¶ Append object to the end of the list.
-
clear()¶ Remove all items from list.
-
copy()¶ Return a shallow copy of the list.
-
count(value, /)¶ Return number of occurrences of value.
-
extend(iterable, /)¶ Extend list by appending elements from the iterable.
-
index(value, start=0, stop=9223372036854775807, /)¶ Return first index of value.
Raises ValueError if the value is not present.
-
insert(index, object, /)¶ Insert object before index.
-
pop(index=-1, /)¶ Remove and return item at index (default last).
Raises IndexError if list is empty or index is out of range.
-
remove(value, /)¶ Remove first occurrence of value.
Raises ValueError if the value is not present.
-
reverse()¶ Reverse IN PLACE.
-
sort(*, key=None, reverse=False)¶ Stable sort IN PLACE.
-
class
digi.xbee.reader.BluetoothDataReceived(iterable=(), /)[source]¶ Bases:
digi.xbee.reader.XBeeEventThis event is fired when an XBee receives data from the Bluetooth interface.
- The callbacks to handle these events will receive the following arguments:
data (Bytearray): received Bluetooth data.
See also
-
append(object, /)¶ Append object to the end of the list.
-
clear()¶ Remove all items from list.
-
copy()¶ Return a shallow copy of the list.
-
count(value, /)¶ Return number of occurrences of value.
-
extend(iterable, /)¶ Extend list by appending elements from the iterable.
-
index(value, start=0, stop=9223372036854775807, /)¶ Return first index of value.
Raises ValueError if the value is not present.
-
insert(index, object, /)¶ Insert object before index.
-
pop(index=-1, /)¶ Remove and return item at index (default last).
Raises IndexError if list is empty or index is out of range.
-
remove(value, /)¶ Remove first occurrence of value.
Raises ValueError if the value is not present.
-
reverse()¶ Reverse IN PLACE.
-
sort(*, key=None, reverse=False)¶ Stable sort IN PLACE.
-
class
digi.xbee.reader.MicroPythonDataReceived(iterable=(), /)[source]¶ Bases:
digi.xbee.reader.XBeeEventThis event is fired when an XBee receives data from the MicroPython interface.
- The callbacks to handle these events will receive the following arguments:
data (Bytearray): received MicroPython data.
See also
-
append(object, /)¶ Append object to the end of the list.
-
clear()¶ Remove all items from list.
-
copy()¶ Return a shallow copy of the list.
-
count(value, /)¶ Return number of occurrences of value.
-
extend(iterable, /)¶ Extend list by appending elements from the iterable.
-
index(value, start=0, stop=9223372036854775807, /)¶ Return first index of value.
Raises ValueError if the value is not present.
-
insert(index, object, /)¶ Insert object before index.
-
pop(index=-1, /)¶ Remove and return item at index (default last).
Raises IndexError if list is empty or index is out of range.
-
remove(value, /)¶ Remove first occurrence of value.
Raises ValueError if the value is not present.
-
reverse()¶ Reverse IN PLACE.
-
sort(*, key=None, reverse=False)¶ Stable sort IN PLACE.
-
class
digi.xbee.reader.SocketStateReceived(iterable=(), /)[source]¶ Bases:
digi.xbee.reader.XBeeEventThis event is fired when an XBee receives a socket state packet.
- The callbacks to handle these events will receive the following arguments:
socket_id (Integer): socket ID for state reported.
state (
SocketState): received state.
See also
-
append(object, /)¶ Append object to the end of the list.
-
clear()¶ Remove all items from list.
-
copy()¶ Return a shallow copy of the list.
-
count(value, /)¶ Return number of occurrences of value.
-
extend(iterable, /)¶ Extend list by appending elements from the iterable.
-
index(value, start=0, stop=9223372036854775807, /)¶ Return first index of value.
Raises ValueError if the value is not present.
-
insert(index, object, /)¶ Insert object before index.
-
pop(index=-1, /)¶ Remove and return item at index (default last).
Raises IndexError if list is empty or index is out of range.
-
remove(value, /)¶ Remove first occurrence of value.
Raises ValueError if the value is not present.
-
reverse()¶ Reverse IN PLACE.
-
sort(*, key=None, reverse=False)¶ Stable sort IN PLACE.
-
class
digi.xbee.reader.SocketDataReceived(iterable=(), /)[source]¶ Bases:
digi.xbee.reader.XBeeEventThis event is fired when an XBee receives a socket receive data packet.
- The callbacks to handle these events will receive the following arguments:
socket_id (Integer): ID of the socket that received the data.
payload (Bytearray): received data.
See also
-
append(object, /)¶ Append object to the end of the list.
-
clear()¶ Remove all items from list.
-
copy()¶ Return a shallow copy of the list.
-
count(value, /)¶ Return number of occurrences of value.
-
extend(iterable, /)¶ Extend list by appending elements from the iterable.
-
index(value, start=0, stop=9223372036854775807, /)¶ Return first index of value.
Raises ValueError if the value is not present.
-
insert(index, object, /)¶ Insert object before index.
-
pop(index=-1, /)¶ Remove and return item at index (default last).
Raises IndexError if list is empty or index is out of range.
-
remove(value, /)¶ Remove first occurrence of value.
Raises ValueError if the value is not present.
-
reverse()¶ Reverse IN PLACE.
-
sort(*, key=None, reverse=False)¶ Stable sort IN PLACE.
-
class
digi.xbee.reader.SocketDataReceivedFrom(iterable=(), /)[source]¶ Bases:
digi.xbee.reader.XBeeEventThis event is fired when an XBee receives a socket receive from data packet.
- The callbacks to handle these events will receive the following arguments:
socket_id (Integer): ID of the socket that received the data.
- address (Tuple): a pair (host, port) of the source address where
host is a string representing an IPv4 address like ‘100.50.200.5’, and port is an integer.
payload (Bytearray): received data.
See also
-
append(object, /)¶ Append object to the end of the list.
-
clear()¶ Remove all items from list.
-
copy()¶ Return a shallow copy of the list.
-
count(value, /)¶ Return number of occurrences of value.
-
extend(iterable, /)¶ Extend list by appending elements from the iterable.
-
index(value, start=0, stop=9223372036854775807, /)¶ Return first index of value.
Raises ValueError if the value is not present.
-
insert(index, object, /)¶ Insert object before index.
-
pop(index=-1, /)¶ Remove and return item at index (default last).
Raises IndexError if list is empty or index is out of range.
-
remove(value, /)¶ Remove first occurrence of value.
Raises ValueError if the value is not present.
-
reverse()¶ Reverse IN PLACE.
-
sort(*, key=None, reverse=False)¶ Stable sort IN PLACE.
-
class
digi.xbee.reader.PacketListener(comm_iface, xbee_device, queue_max_size=None)[source]¶ Bases:
threading.ThreadThis class represents a packet listener, which is a thread that’s always listening for incoming packets to the XBee.
When it receives a packet, this class throws an event depending on which packet it is. You can add your own callbacks for this events via certain class methods. This callbacks must have a certain header, see each event documentation.
This class has fields that are events. Its recommended to use only the append() and remove() method on them, or -= and += operators. If you do something more with them, it’s for your own risk.
Here are the parameters which will be received by the event callbacks, depending on which event it is in each case:
The following parameters are passed via **kwargs to event callbacks of:
- PacketReceived:
1.1 received_packet (
XBeeAPIPacket): the received packet.
- DataReceived
2.1 message (
XBeeMessage): message containing the data received, the sender and the time.
- ModemStatusReceived
3.1 modem_status (
ModemStatus): the modem status received.
Class constructor. Instantiates a new
PacketListenerobject with the provided parameters.- Parameters
comm_iface (
XBeeCommunicationInterface) – the hardware interface to listen to.xbee_device (
XBeeDevice) – the XBee that is the listener owner.queue_max_size (Integer) – the maximum size of the XBee queue.
-
property
daemon¶ A boolean value indicating whether this thread is a daemon thread.
This must be set before start() is called, otherwise RuntimeError is raised. Its initial value is inherited from the creating thread; the main thread is not a daemon thread and therefore all threads created in the main thread default to daemon = False.
The entire Python program exits when only daemon threads are left.
-
wait_until_started(timeout=None)[source]¶ Blocks until the thread has fully started. If already started, returns immediately.
- Parameters
timeout (Float) – timeout for the operation in seconds.
-
run()[source]¶ This is the method that will be executing for listening packets.
For each packet, it will execute the proper callbacks.
-
is_running()[source]¶ Returns whether this instance is running or not.
- Returns
Trueif this instance is running,Falseotherwise.- Return type
Boolean
-
get_data_queue()[source]¶ Returns the data packets queue.
- Returns
the data packets queue.
- Return type
-
get_explicit_queue()[source]¶ Returns the explicit packets queue.
- Returns
the explicit packets queue.
- Return type
-
add_packet_received_callback(callback)[source]¶ Adds a callback for the event
PacketReceived.- Parameters
callback (Function or List of functions) –
the callback. Receives two arguments.
The received packet as a
XBeeAPIPacket
-
add_data_received_callback(callback)[source]¶ Adds a callback for the event
DataReceived.- Parameters
callback (Function or List of functions) –
the callback. Receives one argument.
The data received as an
XBeeMessage
-
add_modem_status_received_callback(callback)[source]¶ Adds a callback for the event
ModemStatusReceived.- Parameters
callback (Function or List of functions) –
the callback. Receives one argument.
The modem status as a
ModemStatus
-
add_io_sample_received_callback(callback)[source]¶ Adds a callback for the event
IOSampleReceived.- Parameters
callback (Function or List of functions) –
the callback. Receives three arguments.
The received IO sample as an
IOSampleThe remote XBee device who has sent the packet as a
RemoteXBeeDeviceThe time in which the packet was received as an Integer
-
add_explicit_data_received_callback(callback)[source]¶ Adds a callback for the event
ExplicitDataReceived.- Parameters
callback (Function or List of functions) –
the callback. Receives one argument.
The explicit data received as an
ExplicitXBeeMessage
-
add_ip_data_received_callback(callback)[source]¶ Adds a callback for the event
IPDataReceived.- Parameters
callback (Function or List of functions) –
the callback. Receives one argument.
The data received as an
IPMessage
-
add_sms_received_callback(callback)[source]¶ Adds a callback for the event
SMSReceived.- Parameters
callback (Function or List of functions) –
the callback. Receives one argument.
The data received as an
SMSMessage
-
add_user_data_relay_received_callback(callback)[source]¶ Adds a callback for the event
RelayDataReceived.- Parameters
callback (Function or List of functions) –
the callback. Receives one argument.
The data received as a
UserDataRelayMessage
-
add_bluetooth_data_received_callback(callback)[source]¶ Adds a callback for the event
BluetoothDataReceived.- Parameters
callback (Function or List of functions) –
the callback. Receives one argument.
The data received as a Bytearray
-
add_micropython_data_received_callback(callback)[source]¶ Adds a callback for the event
MicroPythonDataReceived.- Parameters
callback (Function or List of functions) –
the callback. Receives one argument.
The data received as a Bytearray
-
add_socket_state_received_callback(callback)[source]¶ Adds a callback for the event
SocketStateReceived.- Parameters
callback (Function or List of functions) –
the callback. Receives two arguments.
The socket ID as an Integer.
The state received as a
SocketState
-
add_socket_data_received_callback(callback)[source]¶ Adds a callback for the event
SocketDataReceived.- Parameters
callback (Function or List of functions) –
the callback. Receives two arguments.
The socket ID as an Integer.
The status received as a
SocketStatus
-
add_socket_data_received_from_callback(callback)[source]¶ Adds a callback for the event
SocketDataReceivedFrom.- Parameters
callback (Function or List of functions) –
the callback. Receives three arguments.
The socket ID as an Integer.
- A pair (host, port) of the source address where host is a string representing an IPv4 address
like ‘100.50.200.5’, and port is an integer.
The status received as a
SocketStatus
-
del_packet_received_callback(callback)[source]¶ Deletes a callback for the callback list of
PacketReceivedevent.- Parameters
callback (Function) – the callback to delete.
- Raises
ValueError – if
callbackis not in the callback list ofPacketReceivedevent.
-
del_data_received_callback(callback)[source]¶ Deletes a callback for the callback list of
DataReceivedevent.- Parameters
callback (Function) – the callback to delete.
- Raises
ValueError – if
callbackis not in the callback list ofDataReceivedevent.
-
del_modem_status_received_callback(callback)[source]¶ Deletes a callback for the callback list of
ModemStatusReceivedevent.- Parameters
callback (Function) – the callback to delete.
- Raises
ValueError – if
callbackis not in the callback list ofModemStatusReceivedevent.
-
del_io_sample_received_callback(callback)[source]¶ Deletes a callback for the callback list of
IOSampleReceivedevent.- Parameters
callback (Function) – the callback to delete.
- Raises
ValueError – if
callbackis not in the callback list ofIOSampleReceivedevent.
-
del_explicit_data_received_callback(callback)[source]¶ Deletes a callback for the callback list of
ExplicitDataReceivedevent.- Parameters
callback (Function) – the callback to delete.
- Raises
ValueError – if
callbackis not in the callback list ofExplicitDataReceivedevent.
-
del_ip_data_received_callback(callback)[source]¶ Deletes a callback for the callback list of
IPDataReceivedevent.- Parameters
callback (Function) – the callback to delete.
- Raises
ValueError – if
callbackis not in the callback list ofIPDataReceivedevent.
-
del_sms_received_callback(callback)[source]¶ Deletes a callback for the callback list of
SMSReceivedevent.- Parameters
callback (Function) – the callback to delete.
- Raises
ValueError – if
callbackis not in the callback list ofSMSReceivedevent.
-
del_user_data_relay_received_callback(callback)[source]¶ Deletes a callback for the callback list of
RelayDataReceivedevent.- Parameters
callback (Function) – the callback to delete.
- Raises
ValueError – if
callbackis not in the callback list ofRelayDataReceivedevent.
-
del_bluetooth_data_received_callback(callback)[source]¶ Deletes a callback for the callback list of
BluetoothDataReceivedevent.- Parameters
callback (Function) – the callback to delete.
- Raises
ValueError – if
callbackis not in the callback list ofBluetoothDataReceivedevent.
-
del_micropython_data_received_callback(callback)[source]¶ Deletes a callback for the callback list of
MicroPythonDataReceivedevent.- Parameters
callback (Function) – the callback to delete.
- Raises
ValueError – if
callbackis not in the callback list ofMicroPythonDataReceivedevent.
-
del_socket_state_received_callback(callback)[source]¶ Deletes a callback for the callback list of
SocketStateReceivedevent.- Parameters
callback (Function) – the callback to delete.
- Raises
ValueError – if
callbackis not in the callback list ofSocketStateReceivedevent.
-
del_socket_data_received_callback(callback)[source]¶ Deletes a callback for the callback list of
SocketDataReceivedevent.- Parameters
callback (Function) – the callback to delete.
- Raises
ValueError – if
callbackis not in the callback list ofSocketDataReceivedevent.
-
del_socket_data_received_from_callback(callback)[source]¶ Deletes a callback for the callback list of
SocketDataReceivedFromevent.- Parameters
callback (Function) – the callback to delete.
- Raises
ValueError – if
callbackis not in the callback list ofSocketDataReceivedFromevent.
-
get_packet_received_callbacks()[source]¶ Returns the list of registered callbacks for received packets.
- Returns
List of
PacketReceivedevents.- Return type
List
-
get_data_received_callbacks()[source]¶ Returns the list of registered callbacks for received data.
- Returns
List of
DataReceivedevents.- Return type
List
-
get_modem_status_received_callbacks()[source]¶ Returns the list of registered callbacks for received modem status.
- Returns
List of
ModemStatusReceivedevents.- Return type
List
-
get_io_sample_received_callbacks()[source]¶ Returns the list of registered callbacks for received IO samples.
- Returns
List of
IOSampleReceivedevents.- Return type
List
-
get_explicit_data_received_callbacks()[source]¶ Returns the list of registered callbacks for received explicit data.
- Returns
List of
ExplicitDataReceivedevents.- Return type
List
-
get_ip_data_received_callbacks()[source]¶ Returns the list of registered callbacks for received IP data.
- Returns
List of
IPDataReceivedevents.- Return type
List
-
get_sms_received_callbacks()[source]¶ Returns the list of registered callbacks for received SMS.
- Returns
List of
SMSReceivedevents.- Return type
List
-
get_user_data_relay_received_callbacks()[source]¶ Returns the list of registered callbacks for received user data relay.
- Returns
List of
RelayDataReceivedevents.- Return type
List
-
get_bluetooth_data_received_callbacks()[source]¶ Returns the list of registered callbacks for received Bluetooth data.
- Returns
List of
BluetoothDataReceivedevents.- Return type
List
-
get_micropython_data_received_callbacks()[source]¶ Returns the list of registered callbacks for received micropython data.
- Returns
List of
MicroPythonDataReceivedevents.- Return type
List
-
property
ident¶ Thread identifier of this thread or None if it has not been started.
This is a nonzero integer. See the get_ident() function. Thread identifiers may be recycled when a thread exits and another thread is created. The identifier is available even after the thread has exited.
-
isAlive()¶ Return whether the thread is alive.
This method is deprecated, use is_alive() instead.
-
is_alive()¶ Return whether the thread is alive.
This method returns True just before the run() method starts until just after the run() method terminates. The module function enumerate() returns a list of all alive threads.
-
join(timeout=None)¶ Wait until the thread terminates.
This blocks the calling thread until the thread whose join() method is called terminates – either normally or through an unhandled exception or until the optional timeout occurs.
When the timeout argument is present and not None, it should be a floating point number specifying a timeout for the operation in seconds (or fractions thereof). As join() always returns None, you must call is_alive() after join() to decide whether a timeout happened – if the thread is still alive, the join() call timed out.
When the timeout argument is not present or None, the operation will block until the thread terminates.
A thread can be join()ed many times.
join() raises a RuntimeError if an attempt is made to join the current thread as that would cause a deadlock. It is also an error to join() a thread before it has been started and attempts to do so raises the same exception.
-
property
name¶ A string used for identification purposes only.
It has no semantics. Multiple threads may be given the same name. The initial name is set by the constructor.
-
start()¶ Start the thread’s activity.
It must be called at most once per thread object. It arranges for the object’s run() method to be invoked in a separate thread of control.
This method will raise a RuntimeError if called more than once on the same thread object.
-
class
digi.xbee.reader.XBeeQueue(maxsize=10)[source]¶ Bases:
queue.QueueThis class represents an XBee queue.
Class constructor. Instantiates a new
XBeeQueuewith the provided parameters.- Parameters
(Integer, default (maxsize) –
the maximum size of the queue.
-
get(block=True, timeout=None)[source]¶ Returns the first element of the queue if there is some element ready before timeout expires, in case of the timeout is not
None.If timeout is
None, this method is non-blocking. In this case, if there isn’t any element available, it returnsNone, otherwise it returns anXBeeAPIPacket.- Parameters
block (Boolean) –
Trueto block duringtimeoutwaiting for a packet,Falseto not block.timeout (Integer, optional) – timeout in seconds.
- Returns
- a packet if there is any packet available before
timeoutexpires. If
timeoutisNone, the returned value may beNone.
- a packet if there is any packet available before
- Return type
- Raises
TimeoutException – if
timeoutis notNoneand there isn’t any packet available before the timeout expires.
-
get_by_remote(remote_xbee_device, timeout=None)[source]¶ Returns the first element of the queue that had been sent by
remote_xbee_device, if there is some in the specified timeout.If timeout is
None, this method is non-blocking. In this case, if there isn’t any packet sent byremote_xbee_devicein the queue, it returnsNone, otherwise it returns anXBeeAPIPacket.- Parameters
remote_xbee_device (
RemoteXBeeDevice) – the remote XBee device to get its firs element from queue.timeout (Integer, optional) – timeout in seconds.
- Returns
- if there is any packet available before the timeout expires. If timeout is
None, the returned value may beNone.
- Return type
- Raises
TimeoutException – if timeout is not
Noneand there isn’t any packet available that has been sent byremote_xbee_devicebefore the timeout expires.
-
get_by_ip(ip_addr, timeout=None)[source]¶ Returns the first IP data packet from the queue whose IP address matches the provided address.
If timeout is
None, this method is non-blocking. In this case, if there isn’t any packet sent byremote_xbee_devicein the queue, it returnsNone, otherwise it returns anXBeeAPIPacket.- Parameters
ip_addr (
ipaddress.IPv4Address) – The IP address to look for in the list of packets.timeout (Integer, optional) – Timeout in seconds.
- Returns
- if there is any packet available before the timeout expires. If timeout is
None, the returned value may beNone.
- Return type
- Raises
TimeoutException – if timeout is not
Noneand there isn’t any packet available that has been sent byremote_xbee_devicebefore the timeout expires.
-
get_by_id(frame_id, timeout=None)[source]¶ Returns the first packet from the queue whose frame ID matches the provided one.
If timeout is
None, this method is non-blocking. In this case, if there isn’t any received packet with the provided frame ID in the queue, it returnsNone, otherwise it returns anXBeeAPIPacket.- Parameters
frame_id (Integer) – The frame ID to look for in the list of packets.
timeout (Integer, optional) – Timeout in seconds.
- Returns
- if there is any packet available before the timeout expires. If timeout is
None, the returned value may beNone.
- Return type
- Raises
TimeoutException – if timeout is not
Noneand there isn’t any packet available that matchesthe provided frame ID before the timeout expires. –
-
empty()¶ Return True if the queue is empty, False otherwise (not reliable!).
This method is likely to be removed at some point. Use qsize() == 0 as a direct substitute, but be aware that either approach risks a race condition where a queue can grow before the result of empty() or qsize() can be used.
To create code that needs to wait for all queued tasks to be completed, the preferred technique is to use the join() method.
-
full()¶ Return True if the queue is full, False otherwise (not reliable!).
This method is likely to be removed at some point. Use qsize() >= n as a direct substitute, but be aware that either approach risks a race condition where a queue can shrink before the result of full() or qsize() can be used.
-
get_nowait()¶ Remove and return an item from the queue without blocking.
Only get an item if one is immediately available. Otherwise raise the Empty exception.
-
join()¶ Blocks until all items in the Queue have been gotten and processed.
The count of unfinished tasks goes up whenever an item is added to the queue. The count goes down whenever a consumer thread calls task_done() to indicate the item was retrieved and all work on it is complete.
When the count of unfinished tasks drops to zero, join() unblocks.
-
put(item, block=True, timeout=None)¶ Put an item into the queue.
If optional args ‘block’ is true and ‘timeout’ is None (the default), block if necessary until a free slot is available. If ‘timeout’ is a non-negative number, it blocks at most ‘timeout’ seconds and raises the Full exception if no free slot was available within that time. Otherwise (‘block’ is false), put an item on the queue if a free slot is immediately available, else raise the Full exception (‘timeout’ is ignored in that case).
-
put_nowait(item)¶ Put an item into the queue without blocking.
Only enqueue the item if a free slot is immediately available. Otherwise raise the Full exception.
-
qsize()¶ Return the approximate size of the queue (not reliable!).
-
task_done()¶ Indicate that a formerly enqueued task is complete.
Used by Queue consumer threads. For each get() used to fetch a task, a subsequent call to task_done() tells the queue that the processing on the task is complete.
If a join() is currently blocking, it will resume when all items have been processed (meaning that a task_done() call was received for every item that had been put() into the queue).
Raises a ValueError if called more times than there were items placed in the queue.