digi.xbee.reader module

class digi.xbee.reader.XBeeEvent(iterable=(), /)[source]

Bases: list

This 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.XBeeEvent

This 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:
  1. received_packet (XBeeAPIPacket): Received packet.

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.PacketReceivedFrom(iterable=(), /)[source]

Bases: digi.xbee.reader.XBeeEvent

This 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:
  1. received_packet (XBeeAPIPacket): Received packet.

  2. sender (RemoteXBeeDevice): Remote XBee who sent the packet.

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

This event is fired when an XBee receives data.

The callbacks for handle this events will receive the following arguments:
  1. message (XBeeMessage): Message containing the data received, the sender and the time.

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

This event is fired when a XBee receives a modem status packet.

The callbacks for handle this events will receive the following arguments:
  1. modem_status (ModemStatus): Modem status received.

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

This event is fired when a XBee receives an IO packet.

This includes:

  1. IO data sample RX indicator packet.

  2. RX IO 16 packet.

  3. RX IO 64 packet.

The callbacks that handle this event will receive the following arguments:
  1. io_sample (IOSample): Received IO sample.

  2. sender (RemoteXBeeDevice): Remote XBee who sent the packet.

  3. time (Integer): the time in which the packet was received.

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

This 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:
  1. event_type (digi.xbee.devices.NetworkEventType): Network event type.

  2. reason (digi.xbee.devices.NetworkEventReason): Reason of the event.

  3. node (digi.xbee.devices.XBeeDevice or digi.xbee.devices.RemoteXBeeDevice): Node added, updated or removed from the network.

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

This 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:
  1. discovered_device (RemoteXBeeDevice): Discovered remote XBee.

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

This 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:
  1. status (NetworkDiscoveryStatus): Network discovery status.

  2. description (String, optional): Description of the discovery status.

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

This event is fired when an XBee receives an explicit data packet.

The callbacks for handle this events will receive the following arguments:
  1. message (ExplicitXBeeMessage): Message containing the received data, the sender, the time, and explicit data message parameters.

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

This event is fired when an XBee receives IP data.

The callbacks for handle this events will receive the following arguments:
  1. message (IPMessage): Message containing containing the IP address the message belongs to, source and destination ports, IP protocol, and the content (data) of the 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.SMSReceived(iterable=(), /)[source]

Bases: digi.xbee.reader.XBeeEvent

This event is fired when an XBee receives an SMS.

The callbacks for handle this events will receive the following arguments:
  1. message (SMSMessage): Message containing the phone number that sent the message and the content (data) of the 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.RelayDataReceived(iterable=(), /)[source]

Bases: digi.xbee.reader.XBeeEvent

This event is fired when an XBee receives a user data relay output packet.

The callbacks to handle these events will receive the following arguments:
  1. message (UserDataRelayMessage): Message containing the source interface and the content (data) of the 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.BluetoothDataReceived(iterable=(), /)[source]

Bases: digi.xbee.reader.XBeeEvent

This event is fired when an XBee receives data from the Bluetooth interface.

The callbacks to handle these events will receive the following arguments:
  1. 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.XBeeEvent

This event is fired when an XBee receives data from the MicroPython interface.

The callbacks to handle these events will receive the following arguments:
  1. 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.XBeeEvent

This event is fired when an XBee receives a socket state packet.

The callbacks to handle these events will receive the following arguments:
  1. socket_id (Integer): Socket ID for state reported.

  2. 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.XBeeEvent

This event is fired when an XBee receives a socket receive data packet.

The callbacks to handle these events will receive the following arguments:
  1. socket_id (Integer): ID of the socket that received the data.

  2. 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.XBeeEvent

This event is fired when an XBee receives a socket receive from data packet.

The callbacks to handle these events will receive the following arguments:
  1. socket_id (Integer): ID of the socket that received the data.

  2. address (Tuple): 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.

  3. 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.RouteRecordIndicatorReceived(iterable=(), /)[source]

Bases: digi.xbee.reader.XBeeEvent

This event is fired when a route record packet is received.

The callbacks to handle these events will receive the following arguments:
  1. Source (RemoteXBeeDevice): Remote node that sent the

    route record.

  2. Hops (List): List of intermediate hops 16-bit addresses from closest

    to source (who sent the route record) to closest to destination (XBee16BitAddress).

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.RouteInformationReceived(iterable=(), /)[source]

Bases: digi.xbee.reader.XBeeEvent

This event is fired when a route information packet is received.

The callbacks to handle these events will receive the following arguments:
  1. Source event (Integer): Source event (0x11: NACK, 0x12: Trace route)

  2. Timestamp (Integer): System timer value on the node generating

    this package. The timestamp is in microseconds.

  3. ACK timeout count (Integer): Number of MAC ACK timeouts that occur.

  4. TX blocked count (Integer): Number of times the transmissions was

    blocked due to reception in progress.

  5. Destination address (XBee64BitAddress): 64-bit address of

    the final destination node.

  6. Source address (XBee64BitAddress): 64-bit address of

    the source node.

  7. Responder address (XBee64BitAddress): 64-bit address of

    of the node that generates this packet after it sends (or attempts to send) the packet to the next hop (successor node)

  8. Successor address (XBee64BitAddress): 64-bit address of

    of the next node after the responder in the route towards the destination.

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.RouteReceived(iterable=(), /)[source]

Bases: digi.xbee.reader.XBeeEvent

This event is fired when a route is received.

The callbacks to handle these events will receive the following arguments:
  1. source (XBeeDevice): Local node.

  2. destination (RemoteXBeeDevice): Remote node.

  3. hops (List): List of intermediate hops from source node to

    closest to destination (RemoteXBeeDevice).

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.InitDiscoveryScan(iterable=(), /)[source]

Bases: digi.xbee.reader.XBeeEvent

This event is fired when a new network discovery scan is about to start.

The callbacks to handle these events will receive the following arguments:
  1. Number of scan to start (starting with 1).

  2. Total number of scans.

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.EndDiscoveryScan(iterable=(), /)[source]

Bases: digi.xbee.reader.XBeeEvent

This event is fired when a network discovery scan has just finished.

The callbacks to handle these events will receive the following arguments:
  1. Number of scan that has finished (starting with 1).

  2. Total number of scans.

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.FileSystemFrameReceived(iterable=(), /)[source]

Bases: digi.xbee.reader.XBeeEvent

This event is fired when a file system packet is received.

The callbacks to handle these events will receive the following arguments:
  1. Source (AbstractXBeeDevice): Node that sent the file system frame.

  2. Frame id (Integer): Received frame id.

  3. Command (FSCmd): File system command.

  4. Status (:class: .FSCommandStatus): Status code.

  5. Receive options (Integer): Bitfield indicating receive options. See ReceiveOptions.

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

This 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:

  1. PacketReceived:

    1.1 received_packet (XBeeAPIPacket): Received packet.

  2. DataReceived
    2.1 message (XBeeMessage): Message containing the data

    received, the sender and the time.

  3. ModemStatusReceived

    3.1 modem_status (ModemStatus): Modem status received.

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

Parameters
  • comm_iface (XBeeCommunicationInterface) – Hardware interface to listen to.

  • xbee_device (XBeeDevice) – XBee that is the listener owner.

  • queue_max_size (Integer) – 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.

stop()[source]

Stops listening.

is_running()[source]

Returns whether this instance is running or not.

Returns

True if this instance is running, False otherwise.

Return type

Boolean

get_queue()[source]

Returns the packets queue.

Returns

Packets queue.

Return type

XBeeQueue

get_data_queue()[source]

Returns the data packets queue.

Returns

Data packets queue.

Return type

XBeeQueue

get_explicit_queue()[source]

Returns the explicit packets queue.

Returns

Explicit packets queue.

Return type

XBeeQueue

get_ip_queue()[source]

Returns the IP packets queue.

Returns

IP packets queue.

Return type

XBeeQueue

add_packet_received_callback(callback)[source]

Adds a callback for the event PacketReceived.

Parameters

callback (Function or List of functions) –

Callback. Receives one argument.

add_packet_received_from_callback(callback)[source]

Adds a callback for the event PacketReceivedFrom.

Parameters

callback (Function or List of functions) –

Callback. Receives two arguments.

add_data_received_callback(callback)[source]

Adds a callback for the event DataReceived.

Parameters

callback (Function or List of functions) –

Callback. Receives one argument.

add_modem_status_received_callback(callback)[source]

Adds a callback for the event ModemStatusReceived.

Parameters

callback (Function or List of functions) –

Callback. Receives one argument.

add_io_sample_received_callback(callback)[source]

Adds a callback for the event IOSampleReceived.

Parameters

callback (Function or List of functions) –

Callback. Receives three arguments.

  • The received IO sample as an IOSample

  • The remote XBee device who has sent the packet as a RemoteXBeeDevice

  • The 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) –

Callback. Receives one argument.

add_ip_data_received_callback(callback)[source]

Adds a callback for the event IPDataReceived.

Parameters

callback (Function or List of functions) –

Callback. Receives one argument.

add_sms_received_callback(callback)[source]

Adds a callback for the event SMSReceived.

Parameters

callback (Function or List of functions) –

Callback. Receives one argument.

add_user_data_relay_received_callback(callback)[source]

Adds a callback for the event RelayDataReceived.

Parameters

callback (Function or List of functions) –

Callback. Receives one argument.

add_bluetooth_data_received_callback(callback)[source]

Adds a callback for the event BluetoothDataReceived.

Parameters

callback (Function or List of functions) –

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) –

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) –

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) –

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) –

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

add_route_record_received_callback(callback)[source]

Adds a callback for the event RouteRecordIndicatorReceived.

Parameters

callback (Function or List of functions) –

Callback. Receives two arguments.

  • Source (RemoteXBeeDevice): Remote node that sent

    the route record.

  • Hops (List): List of intermediate hops 16-bit addresses from

    closest to source (who sent the route record) to closest to destination.

add_route_info_received_callback(callback)[source]

Adds a callback for the event RouteInformationReceived.

Parameters

callback (Function or List of functions) –

Callback. Receives eight arguments.

  • Source event (Integer): Source event (0x11: NACK, 0x12: Trace route)

  • Timestamp (Integer): System timer value on the node generating this package. The timestamp is in microseconds.

  • ACK timeout count (Integer): Number of MAC ACK timeouts that occur.

  • TX blocked count (Integer): Number of times the transmissions was blocked due to reception in progress.

  • Destination address (XBee64BitAddress): 64-bit address of the final destination node.

  • Source address (XBee64BitAddress): 64-bit address of the source node.

  • Responder address (XBee64BitAddress): 64-bit address of the node that generated this packet after it sent (or attempted to send) the packet to the next hop (successor node)

  • Successor address (XBee64BitAddress): 64-bit address of the next node after the responder in the route towards the destination.

add_fs_frame_received_callback(callback)[source]

Adds a callback for the event FileSystemFrameReceived.

Parameters

callback (Function or List of functions) –

Callback. Receives four arguments.

  • Source (AbstractXBeeDevice): Node that sent the

    file system frame.

  • Frame id (Integer): Received frame id.

  • Command (FSCmd): File system command.

  • Receive options (Integer): Bitfield indicating receive options. See ReceiveOptions.

del_packet_received_callback(callback)[source]

Deletes a callback for the callback list of PacketReceived event.

Parameters

callback (Function) – Callback to delete.

Raises

ValueError – If callback is not in the callback list of PacketReceived event.

del_packet_received_from_callback(callback)[source]

Deletes a callback for the callback list of PacketReceivedFrom event.

Parameters

callback (Function) – Callback to delete.

Raises

ValueError – If callback is not in the callback list of PacketReceivedFrom event.

del_data_received_callback(callback)[source]

Deletes a callback for the callback list of DataReceived event.

Parameters

callback (Function) – Callback to delete.

Raises

ValueError – If callback is not in the callback list of DataReceived event.

del_modem_status_received_callback(callback)[source]

Deletes a callback for the callback list of ModemStatusReceived event.

Parameters

callback (Function) – Callback to delete.

Raises

ValueError – If callback is not in the callback list of ModemStatusReceived event.

del_io_sample_received_callback(callback)[source]

Deletes a callback for the callback list of IOSampleReceived event.

Parameters

callback (Function) – Callback to delete.

Raises

ValueError – If callback is not in the callback list of IOSampleReceived event.

del_explicit_data_received_callback(callback)[source]

Deletes a callback for the callback list of ExplicitDataReceived event.

Parameters

callback (Function) – Callback to delete.

Raises

ValueError – If callback is not in the callback list of ExplicitDataReceived event.

del_ip_data_received_callback(callback)[source]

Deletes a callback for the callback list of IPDataReceived event.

Parameters

callback (Function) – Callback to delete.

Raises

ValueError – If callback is not in the callback list of IPDataReceived event.

del_sms_received_callback(callback)[source]

Deletes a callback for the callback list of SMSReceived event.

Parameters

callback (Function) – Callback to delete.

Raises

ValueError – If callback is not in the callback list of SMSReceived event.

del_user_data_relay_received_callback(callback)[source]

Deletes a callback for the callback list of RelayDataReceived event.

Parameters

callback (Function) – Callback to delete.

Raises

ValueError – If callback is not in the callback list of RelayDataReceived event.

del_bluetooth_data_received_callback(callback)[source]

Deletes a callback for the callback list of BluetoothDataReceived event.

Parameters

callback (Function) – Callback to delete.

Raises

ValueError – If callback is not in the callback list of BluetoothDataReceived event.

del_micropython_data_received_callback(callback)[source]

Deletes a callback for the callback list of MicroPythonDataReceived event.

Parameters

callback (Function) – Callback to delete.

Raises

ValueError – If callback is not in the callback list of MicroPythonDataReceived event.

del_socket_state_received_callback(callback)[source]

Deletes a callback for the callback list of SocketStateReceived event.

Parameters

callback (Function) – Callback to delete.

Raises

ValueError – If callback is not in the callback list of SocketStateReceived event.

del_socket_data_received_callback(callback)[source]

Deletes a callback for the callback list of SocketDataReceived event.

Parameters

callback (Function) – Callback to delete.

Raises

ValueError – If callback is not in the callback list of SocketDataReceived event.

del_socket_data_received_from_callback(callback)[source]

Deletes a callback for the callback list of SocketDataReceivedFrom event.

Parameters

callback (Function) – Callback to delete.

Raises

ValueError – If callback is not in the callback list of SocketDataReceivedFrom event.

del_route_record_received_callback(callback)[source]

Deletes a callback for the callback list of RouteRecordIndicatorReceived event.

Parameters

callback (Function) – Callback to delete.

Raises

ValueError – If callback is not in the callback list of RouteRecordIndicatorReceived event.

del_route_info_callback(callback)[source]

Deletes a callback for the callback list of RouteInformationReceived event.

Parameters

callback (Function) – Callback to delete.

Raises

ValueError – If callback is not in the callback list of RouteInformationReceived event.

del_fs_frame_received_callback(callback)[source]

Deletes a callback for the callback list of FileSystemFrameReceived event.

Parameters

callback (Function) – Callback to delete.

Raises

ValueError – If callback is not in the callback list of FileSystemFrameReceived event.

get_packet_received_callbacks()[source]

Returns the list of registered callbacks for received packets.

Returns

List of PacketReceived events.

Return type

List

get_packet_received_from_callbacks()[source]

Returns the list of registered callbacks for received packets.

Returns

List of PacketReceivedFrom events.

Return type

List

get_data_received_callbacks()[source]

Returns the list of registered callbacks for received data.

Returns

List of DataReceived events.

Return type

List

get_modem_status_received_callbacks()[source]

Returns the list of registered callbacks for received modem status.

Returns

List of ModemStatusReceived events.

Return type

List

get_io_sample_received_callbacks()[source]

Returns the list of registered callbacks for received IO samples.

Returns

List of IOSampleReceived events.

Return type

List

get_explicit_data_received_callbacks()[source]

Returns the list of registered callbacks for received explicit data.

Returns

List of ExplicitDataReceived events.

Return type

List

get_ip_data_received_callbacks()[source]

Returns the list of registered callbacks for received IP data.

Returns

List of IPDataReceived events.

Return type

List

get_sms_received_callbacks()[source]

Returns the list of registered callbacks for received SMS.

Returns

List of SMSReceived events.

Return type

List

get_user_data_relay_received_callbacks()[source]

Returns the list of registered callbacks for received user data relay.

Returns

List of RelayDataReceived events.

Return type

List

get_bluetooth_data_received_callbacks()[source]

Returns the list of registered callbacks for received Bluetooth data.

Returns

List of BluetoothDataReceived events.

Return type

List

get_micropython_data_received_callbacks()[source]

Returns the list of registered callbacks for received MicroPython data.

Returns

List of MicroPythonDataReceived events.

Return type

List

get_socket_state_received_callbacks()[source]

Returns the list of registered callbacks for received socket state.

Returns

List of SocketStateReceived events.

Return type

List

get_socket_data_received_callbacks()[source]

Returns the list of registered callbacks for received socket data.

Returns

List of SocketDataReceived events.

Return type

List

get_socket_data_received_from_callbacks()[source]

Returns the list of registered callbacks for received socket data from.

Returns

List of SocketDataReceivedFrom events.

Return type

List

get_route_record_received_callbacks()[source]

Returns the list of registered callbacks for received route records.

Returns

List of RouteRecordIndicatorReceived events.

Return type

List

get_route_info_callbacks()[source]

Returns the list of registered callbacks for received route information packets.

Returns

List of RouteInformationReceived events.

Return type

List

get_fs_frame_received_callbacks()[source]

Returns the list of registered callbacks for received file system packets.

Returns

List of FileSystemFrameReceived events.

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

This class represents an XBee queue.

Class constructor. Instantiates a new XBeeQueue with the provided parameters.

Parameters

maxsize (Integer, optional, default=10) – 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 is not any element available, it returns None, otherwise it returns an XBeeAPIPacket.

Parameters
  • block (Boolean) – True to block during timeout waiting for a packet, False to not block.

  • timeout (Integer, optional) – timeout in seconds.

Returns

Packet if there is any packet available

before timeout expires. If timeout is None, the returned value may be None.

Return type

XBeeAPIPacket

Raises

TimeoutException – If timeout is not None and there is not any packet available before the timeout expires.

get_by_remote(remote, timeout=None)[source]

Returns the first element of the queue that had been sent by remote, if there is some in the specified timeout.

If timeout is None, this method is non-blocking. In this case, if there is not any packet sent by remote in the queue, it returns None, otherwise it returns an XBeeAPIPacket.

Parameters
  • remote (RemoteXBeeDevice) – Remote XBee to get its first element from queue.

  • timeout (Integer, optional, default=`None`) – Timeout in seconds.

Returns

If there is any packet available before

the timeout expires. If timeout is None, the returned value may be None.

Return type

XBeeAPIPacket

Raises

TimeoutException – If timeout is not None and there is not any packet available that was sent by remote before 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 is not any packet sent by ip_addr in the queue, it returns None, otherwise it returns an XBeeAPIPacket.

Parameters
  • ip_addr (ipaddress.IPv4Address) – IP address to look for in the list of packets.

  • timeout (Integer, optional, default=`None`) – Timeout in seconds.

Returns

If there is any packet available before the

timeout expires. If timeout is None, the returned value may be None.

Return type

XBeeAPIPacket

Raises

TimeoutException – If timeout is not None and there is not any packet available that was sent by ip_addr 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_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 is not any received packet with the provided frame ID in the queue, it returns None, otherwise it returns an XBeeAPIPacket.

Parameters
  • frame_id (Integer) – Frame ID to look for in the list of packets.

  • timeout (Integer, optional, default=`None`) – Timeout in seconds.

Returns

If there is any packet available before

the timeout expires. If timeout is None, the returned value may be None.

Return type

XBeeAPIPacket

Raises

TimeoutException – If timeout is not None and there is not any packet available that matches the provided frame ID before the timeout expires.

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.

flush()[source]

Clears the queue.