digi.xbee.devices module

class digi.xbee.devices.AbstractXBeeDevice(local_xbee_device=None, serial_port=None, sync_ops_timeout=4, comm_iface=None)[source]

Bases: object

This class provides common functionality for all XBee devices.

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

Parameters:
  • local_xbee_device (XBeeDevice, optional) – only necessary if XBee device is remote. The local XBee device that will behave as connection interface to communicate with the remote XBee one.
  • serial_port (XBeeSerialPort, optional) – only necessary if the XBee device is local. The serial port that will be used to communicate with this XBee.
  • (Integer, default (sync_ops_timeout) – AbstractXBeeDevice._DEFAULT_TIMEOUT_SYNC_OPERATIONS): the timeout (in seconds) that will be applied for all synchronous operations.
  • comm_iface (XBeeCommunicationInterface, optional) – only necessary if the XBee device is local. The hardware interface that will be used to communicate with this XBee.
LOG_PATTERN = '{comm_iface:s} - {event:s} - {opmode:s}: {content:s}'

Pattern used to log packet events.

update_device_data_from(device)[source]

Updates the current device reference with the data provided for the given device.

This is only for internal use.

Parameters:device (AbstractXBeeDevice) – the XBee device to get the data from.
Returns:True if the device data has been updated, False otherwise.
Return type:Boolean
get_parameter(parameter, parameter_value=None)[source]

Returns the value of the provided parameter via an AT Command.

Parameters:
  • parameter (String) – parameter to get.
  • parameter_value (Bytearray, optional) – The value of the parameter to execute (if any).
Returns:

the parameter value.

Return type:

Bytearray

Raises:
set_parameter(parameter, value)[source]

Sets the value of a parameter via an AT Command.

If you send parameter to a local XBee device, all changes will be applied automatically, except for non-volatile memory, in which case you will need to execute the parameter “WR” via AbstractXBeeDevice.execute_command() method, or AbstractXBeeDevice.apply_changes() method.

If you are sending parameters to a remote XBee device, the changes will be not applied automatically, unless the “apply_changes” flag is activated.

You can set this flag via the method AbstractXBeeDevice.enable_apply_changes().

This flag only works for volatile memory, if you want to save changed parameters in non-volatile memory, even for remote devices, you must execute “WR” command by one of the 2 ways mentioned above.

Parameters:
  • parameter (String) – parameter to set.
  • value (Bytearray) – value of the parameter.
Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – if the response is not as expected.
  • ValueError – if parameter is None or value is None.
execute_command(parameter)[source]

Executes the provided command.

Parameters:

parameter (String) – The name of the AT command to be executed.

Raises:
apply_changes()[source]

Applies changes via AC command.

Raises:
write_changes()[source]

Writes configurable parameter values to the non-volatile memory of the XBee device so that parameter modifications persist through subsequent resets.

Parameters values remain in this device’s memory until overwritten by subsequent use of this method.

If changes are made without writing them to non-volatile memory, the module reverts back to previously saved parameters the next time the module is powered-on.

Writing the parameter modifications does not mean those values are immediately applied, this depends on the status of the ‘apply configuration changes’ option. Use method is_apply_configuration_changes_enabled() to get its status and enable_apply_configuration_changes() to enable/disable the option. If it is disabled, method apply_changes() can be used in order to manually apply the changes.

Raises:
reset()[source]

Performs a software reset on this XBee device and blocks until the process is completed.

Raises:
read_device_info(init=True)[source]

Updates all instance parameters reading them from the XBee device.

Parameters:

init (Boolean, optional, default=`True`) – If False only not initialized parameters are read, all if True.

Raises:
get_node_id()[source]

Returns the Node Identifier (NI) value of the XBee device.

Returns:the Node Identifier (NI) of the XBee device.
Return type:String
set_node_id(node_id)[source]

Sets the Node Identifier (NI) value of the XBee device..

Parameters:

node_id (String) – the new Node Identifier (NI) of the XBee device.

Raises:
  • ValueError – if node_id is None or its length is greater than 20.
  • TimeoutException – if the response is not received before the read timeout expires.
get_hardware_version()[source]

Returns the hardware version of the XBee device.

Returns:the hardware version of the XBee device.
Return type:HardwareVersion

See also

get_firmware_version()[source]

Returns the firmware version of the XBee device.

Returns:the hardware version of the XBee device.
Return type:Bytearray
get_protocol()[source]

Returns the current protocol of the XBee device.

Returns:the current protocol of the XBee device.
Return type:XBeeProtocol

See also

get_16bit_addr()[source]

Returns the 16-bit address of the XBee device.

Returns:the 16-bit address of the XBee device.
Return type:XBee16BitAddress

See also

set_16bit_addr(value)[source]

Sets the 16-bit address of the XBee device.

Parameters:

value (XBee16BitAddress) – the new 16-bit address of the XBee device.

Raises:
get_64bit_addr()[source]

Returns the 64-bit address of the XBee device.

Returns:the 64-bit address of the XBee device.
Return type:XBee64BitAddress

See also

get_role()[source]

Gets the XBee role.

Returns:the role of the XBee.
Return type:digi.xbee.models.protocol.Role
get_current_frame_id()[source]

Returns the last used frame ID.

Returns:the last used frame ID.
Return type:Integer
enable_apply_changes(value)[source]

Sets the apply_changes flag.

Parameters:value (Boolean) – True to enable the apply changes flag, False to disable it.
is_apply_changes_enabled()[source]

Returns whether the apply_changes flag is enabled or not.

Returns:True if the apply_changes flag is enabled, False otherwise.
Return type:Boolean
is_remote()[source]

Determines whether the XBee device is remote or not.

Returns:True if the XBee device is remote, False otherwise.
Return type:Boolean
set_sync_ops_timeout(sync_ops_timeout)[source]

Sets the serial port read timeout.

Parameters:sync_ops_timeout (Integer) – the read timeout, expressed in seconds.
get_sync_ops_timeout()[source]

Returns the serial port read timeout.

Returns:the serial port read timeout in seconds.
Return type:Integer
get_dest_address()[source]

Returns the 64-bit address of the XBee device that data will be reported to.

Returns:the address.
Return type:XBee64BitAddress
Raises:TimeoutException – if the response is not received before the read timeout expires.

See also

set_dest_address(addr)[source]

Sets the 64-bit address of the XBee device that data will be reported to.

Parameters:

addr (XBee64BitAddress or RemoteXBeeDevice) – the address itself or the remote XBee device that you want to set up its address as destination address.

Raises:
  • TimeoutException – If the response is not received before the read timeout expires.
  • XBeeException – If the XBee device’s serial port is closed.
  • InvalidOperatingModeException – If the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If the response is not as expected.
  • ValueError – If addr is None.
get_pan_id()[source]

Returns the operating PAN ID of the XBee device.

Returns:operating PAN ID of the XBee device.
Return type:Bytearray
Raises:TimeoutException – if the response is not received before the read timeout expires.
set_pan_id(value)[source]

Sets the operating PAN ID of the XBee device.

Parameters:value (Bytearray) – the new operating PAN ID of the XBee device.. Must have only 1 or 2 bytes.
Raises:TimeoutException – if the response is not received before the read timeout expires.
get_power_level()[source]

Returns the power level of the XBee device.

Returns:the power level of the XBee device.
Return type:PowerLevel
Raises:TimeoutException – if the response is not received before the read timeout expires.

See also

set_power_level(power_level)[source]

Sets the power level of the XBee device.

Parameters:power_level (PowerLevel) – the new power level of the XBee device.
Raises:TimeoutException – if the response is not received before the read timeout expires.

See also

set_io_configuration(io_line, io_mode)[source]

Sets the configuration of the provided IO line.

Parameters:
  • io_line (IOLine) – the IO line to configure.
  • io_mode (IOMode) – the IO mode to set to the IO line.
Raises:

See also

get_io_configuration(io_line)[source]

Returns the configuration of the provided IO line.

Parameters:

io_line (IOLine) – the io line to configure.

Returns:

the IO mode of the IO line provided.

Return type:

IOMode

Raises:
get_io_sampling_rate()[source]

Returns the IO sampling rate of the XBee device.

Returns:

the IO sampling rate of XBee device.

Return type:

Integer

Raises:
set_io_sampling_rate(rate)[source]

Sets the IO sampling rate of the XBee device in seconds. A sample rate of 0 means the IO sampling feature is disabled.

Parameters:

rate (Integer) – the new IO sampling rate of the XBee device in seconds.

Raises:
read_io_sample()[source]

Returns an IO sample from the XBee device containing the value of all enabled digital IO and analog input channels.

Returns:

the IO sample read from the XBee device.

Return type:

IOSample

Raises:

See also

get_adc_value(io_line)[source]

Returns the analog value of the provided IO line.

The provided IO line must be previously configured as ADC. To do so, use AbstractXBeeDevice.set_io_configuration() and IOMode.ADC.

Parameters:

io_line (IOLine) – the IO line to get its ADC value.

Returns:

the analog value corresponding to the provided IO line.

Return type:

Integer

Raises:

See also

set_pwm_duty_cycle(io_line, cycle)[source]

Sets the duty cycle in % of the provided IO line.

The provided IO line must be PWM-capable, previously configured as PWM output.

Parameters:
  • io_line (IOLine) – the IO Line to be assigned.
  • cycle (Integer) – duty cycle in % to be assigned. Must be between 0 and 100.
Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – if the response is not as expected.
  • ValueError – if the given IO line does not have PWM capability or cycle is not between 0 and 100.

See also

get_pwm_duty_cycle(io_line)[source]

Returns the PWM duty cycle in % corresponding to the provided IO line.

Parameters:

io_line (IOLine) – the IO line to get its PWM duty cycle.

Returns:

the PWM duty cycle of the given IO line or None if the response is empty.

Return type:

Integer

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – if the response is not as expected.
  • ValueError – if the passed IO_LINE has no PWM capability.

See also

get_dio_value(io_line)[source]

Returns the digital value of the provided IO line.

The provided IO line must be previously configured as digital I/O. To do so, use AbstractXBeeDevice.set_io_configuration().

Parameters:

io_line (IOLine) – the DIO line to gets its digital value.

Returns:

current value of the provided IO line.

Return type:

IOValue

Raises:

See also

set_dio_value(io_line, io_value)[source]

Sets the digital value (high or low) to the provided IO line.

Parameters:
  • io_line (IOLine) – the digital IO line to sets its value.
  • io_value (IOValue) – the IO value to set to the IO line.
Raises:

See also

set_dio_change_detection(io_lines_set)[source]

Sets the digital IO lines to be monitored and sampled whenever their status changes.

A None set of lines disables this feature.

Parameters:

io_lines_set – set of IOLine.

Raises:

See also

get_api_output_mode()[source]

Deprecated since version 1.3: Use get_api_output_mode_value()

Returns the API output mode of the XBee device.

The API output mode determines the format that the received data is output through the serial interface of the XBee device.

Returns:

the API output mode of the XBee device.

Return type:

APIOutputMode

Raises:

See also

get_api_output_mode_value()[source]

Returns the API output mode of the XBee.

The API output mode determines the format that the received data is output through the serial interface of the XBee.

Returns:

the parameter value.

Return type:

Bytearray

Raises:
set_api_output_mode(api_output_mode)[source]

Deprecated since version 1.3: Use set_api_output_mode_value()

Sets the API output mode of the XBee device.

Parameters:

api_output_mode (APIOutputMode) – the new API output mode of the XBee device.

Raises:

See also

set_api_output_mode_value(api_output_mode)[source]

Sets the API output mode of the XBee.

Parameters:

api_output_mode (Integer) – new API output mode options. Calculate this value using the method digi.xbee.models.mode.APIOutputModeBit.calculate_api_output_mode_value() with a set of digi.xbee.models.mode.APIOutputModeBit.

Raises:
enable_bluetooth()[source]

Enables the Bluetooth interface of this XBee device.

To work with this interface, you must also configure the Bluetooth password if not done previously. You can use the AbstractXBeeDevice.update_bluetooth_password() method for that purpose.

Note that your device must have Bluetooth Low Energy support to use this method.

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
disable_bluetooth()[source]

Disables the Bluetooth interface of this XBee device.

Note that your device must have Bluetooth Low Energy support to use this method.

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
get_bluetooth_mac_addr()[source]

Reads and returns the EUI-48 Bluetooth MAC address of this XBee device in a format such as 00112233AABB.

Note that your device must have Bluetooth Low Energy support to use this method.

Returns:

The Bluetooth MAC address.

Return type:

String

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
update_bluetooth_password(new_password)[source]

Changes the password of this Bluetooth device with the new one provided.

Note that your device must have Bluetooth Low Energy support to use this method.

Parameters:

new_password (String) – New Bluetooth password.

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
update_firmware(xml_firmware_file, xbee_firmware_file=None, bootloader_firmware_file=None, timeout=None, progress_callback=None)[source]

Performs a firmware update operation of the device.

Parameters:
  • xml_firmware_file (String) – path of the XML file that describes the firmware to upload.
  • xbee_firmware_file (String, optional) – location of the XBee binary firmware file.
  • bootloader_firmware_file (String, optional) – location of the bootloader binary firmware file.
  • timeout (Integer, optional) – the maximum time to wait for target read operations during the update process.
  • progress_callback (Function, optional) –
    function to execute to receive progress information. Receives two
    arguments:
    • The current update task as a String
    • The current update task percentage as an Integer
Raises:
apply_profile(profile_path, progress_callback=None)[source]

Applies the given XBee profile to the XBee device.

Parameters:
  • profile_path (String) – path of the XBee profile file to apply.
  • progress_callback (Function, optional) –
    function to execute to receive progress information. Receives two
    arguments:
    • The current apply profile task as a String
    • The current apply profile task percentage as an Integer
Raises:
log

Logger. The XBee device logger.

class digi.xbee.devices.XBeeDevice(port=None, baud_rate=None, data_bits=<sphinx.ext.autodoc.importer._MockObject object>, stop_bits=<sphinx.ext.autodoc.importer._MockObject object>, parity=<sphinx.ext.autodoc.importer._MockObject object>, flow_control=<FlowControl.NONE: None>, _sync_ops_timeout=4, comm_iface=None)[source]

Bases: digi.xbee.devices.AbstractXBeeDevice

This class represents a non-remote generic XBee device.

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.

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

Parameters:
  • port (Integer or String) – serial port identifier. Integer: number of XBee device, numbering starts at zero. Device name: depending on operating system. e.g. ‘/dev/ttyUSB0’ on ‘GNU/Linux’ or ‘COM3’ on Windows.
  • baud_rate (Integer) – the serial port baud rate.
  • (Integer, default (_sync_ops_timeout) – serial.EIGHTBITS): comm port bitsize.
  • (Integer, defaultserial.STOPBITS_ONE): comm port stop bits.
  • (Character, default (parity) – serial.PARITY_NONE): comm port parity.
  • (Integer, defaultFlowControl.NONE): comm port flow control.
  • (Integer, default – 3): the read timeout (in seconds).
  • comm_iface (XBeeCommunicationInterface) – the communication interface.
Raises:

All exceptions raised by PySerial's Serial class constructor.

See also

PySerial documentation: http://pyserial.sourceforge.net
TIMEOUT_READ_PACKET = 3

Timeout to read packets.

classmethod create_xbee_device(comm_port_data)[source]

Creates and returns an XBeeDevice from data of the port to which is connected.

Parameters:
  • comm_port_data (Dictionary) – dictionary with all comm port data needed.
  • dictionary keys are (The) –
    “baudRate” –> Baud rate.
    ”port” –> Port number.
    ”bitSize” –> Bit size.
    ”stopBits” –> Stop bits.
    ”parity” –> Parity.
    ”flowControl” –> Flow control.
    ”timeout” for –> Timeout for synchronous operations (in seconds).
Returns:

the XBee device created.

Return type:

XBeeDevice

Raises:

SerialException – if the port you want to open does not exist or is already opened.

See also

open(force_settings=False)[source]

Opens the communication with the XBee device and loads some information about it.

Parameters:

force_settings (Boolean, optional) – True to open the device ensuring/forcing that the specified serial settings are applied even if the current configuration is different, False to open the device with the current configuration. Default to False.

Raises:
close()[source]

Closes the communication with the XBee device.

This method guarantees that all threads running are stopped and the serial port is closed.

get_parameter(param, parameter_value=None)[source]

Override.

set_parameter(param, value)[source]

Override.

See:
AbstractXBeeDevice.set_parameter()
send_data(remote_xbee_device, data, transmit_options=0)[source]

Blocking method. This method sends data to a remote XBee device synchronously.

This method will wait for the packet response.

The default timeout for this method is XBeeDevice._DEFAULT_TIMEOUT_SYNC_OPERATIONS.

Parameters:
  • remote_xbee_device (RemoteXBeeDevice) – the remote XBee device to send data to.
  • data (String or Bytearray) – the raw data to send.
  • transmit_options (Integer, optional) – transmit options, bitfield of TransmitOptions. Default to TransmitOptions.NONE.value.
Returns:

XBeePacket the response.

Raises:
  • ValueError – if remote_xbee_device is None.
  • TimeoutException – if this method can’t read a response packet in XBeeDevice._DEFAULT_TIMEOUT_SYNC_OPERATIONS seconds.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • TransmitException – if the status of the response received is not OK.
  • XBeeException – if the XBee device’s serial port is closed.
send_data_async(remote_xbee_device, data, transmit_options=0)[source]

Non-blocking method. This method sends data to a remote XBee device.

This method won’t wait for the response.

Parameters:
  • remote_xbee_device (RemoteXBeeDevice) – the remote XBee device to send data to.
  • data (String or Bytearray) – the raw data to send.
  • transmit_options (Integer, optional) – transmit options, bitfield of TransmitOptions. Default to TransmitOptions.NONE.value.
Raises:
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – if the XBee device’s serial port is closed.

See also

send_data_broadcast(data, transmit_options=0)[source]

Sends the provided data to all the XBee nodes of the network (broadcast).

This method blocks till a success or error transmit status arrives or the configured receive timeout expires.

The received timeout is configured using the AbstractXBeeDevice.set_sync_ops_timeout() method and can be consulted with AbstractXBeeDevice.get_sync_ops_timeout() method.

Parameters:
  • data (String or Bytearray) – data to send.
  • transmit_options (Integer, optional) – transmit options, bitfield of TransmitOptions. Default to TransmitOptions.NONE.value.
Raises:
  • TimeoutException – if this method can’t read a response packet in XBeeDevice._DEFAULT_TIMEOUT_SYNC_OPERATIONS seconds.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • TransmitException – if the status of the response received is not OK.
  • XBeeException – if the XBee device’s serial port is closed.
send_user_data_relay(local_interface, data)[source]

Sends the given data to the given XBee local interface.

Parameters:
  • local_interface (XBeeLocalInterface) – Destination XBee local interface.
  • data (Bytearray) – Data to send.
Raises:
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ValueError – if local_interface is None.
  • XBeeException – if there is any problem sending the User Data Relay.
send_bluetooth_data(data)[source]

Sends the given data to the Bluetooth interface using a User Data Relay frame.

Parameters:

data (Bytearray) – Data to send.

Raises:
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – if there is any problem sending the data.
send_micropython_data(data)[source]

Sends the given data to the MicroPython interface using a User Data Relay frame.

Parameters:

data (Bytearray) – Data to send.

Raises:
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – if there is any problem sending the data.
read_data(timeout=None)[source]

Reads new data received by this XBee device.

If a timeout is specified, this method blocks until new data is received or the timeout expires, throwing in that case a TimeoutException.

Parameters:

timeout (Integer, optional) – read timeout in seconds. If it’s None, this method is non-blocking and will return None if there is no data available.

Returns:

the read message or None if this XBee did not receive new data.

Return type:

XBeeMessage

Raises:
  • ValueError – if a timeout is specified and is less than 0.
  • TimeoutException – if a timeout is specified and no data was received during that time.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – if the XBee device’s serial port is closed.

See also

read_data_from(remote_xbee_device, timeout=None)[source]

Reads new data received from the given remote XBee device.

If a timeout is specified, this method blocks until new data is received or the timeout expires, throwing in that case a TimeoutException.

Parameters:
  • remote_xbee_device (RemoteXBeeDevice) – the remote XBee device that sent the data.
  • timeout (Integer, optional) – read timeout in seconds. If it’s None, this method is non-blocking and will return None if there is no data available.
Returns:

the read message sent by remote_xbee_device or None if this XBee did

not receive new data.

Return type:

XBeeMessage

Raises:
  • ValueError – if a timeout is specified and is less than 0.
  • TimeoutException – if a timeout is specified and no data was received during that time.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – if the XBee device’s serial port is closed.
has_packets()[source]

Returns whether the XBee device’s queue has packets or not. This do not include explicit packets.

Returns:True if this XBee device’s queue has packets, False otherwise.
Return type:Boolean
has_explicit_packets()[source]

Returns whether the XBee device’s queue has explicit packets or not. This do not include non-explicit packets.

Returns:True if this XBee device’s queue has explicit packets, False otherwise.
Return type:Boolean
flush_queues()[source]

Flushes the packets queue.

reset()[source]

Override method.

add_packet_received_callback(callback)[source]

Adds a callback for the event digi.xbee.reader.PacketReceived.

Parameters:callback (Function) –

the callback. Receives two arguments.

add_data_received_callback(callback)[source]

Adds a callback for the event digi.xbee.reader.DataReceived.

Parameters:callback (Function) –

the callback. Receives one argument.

add_modem_status_received_callback(callback)[source]

Adds a callback for the event digi.xbee.reader.ModemStatusReceived.

Parameters:callback (Function) –

the callback. Receives one argument.

add_io_sample_received_callback(callback)[source]

Adds a callback for the event digi.xbee.reader.IOSampleReceived.

Parameters:callback (Function) –

the callback. Receives three arguments.

add_expl_data_received_callback(callback)[source]

Adds a callback for the event digi.xbee.reader.ExplicitDataReceived.

Parameters:callback (Function) –

the callback. Receives one argument.

add_user_data_relay_received_callback(callback)[source]

Adds a callback for the event digi.xbee.reader.RelayDataReceived.

Parameters:callback (Function) –

the callback. Receives one argument.

add_bluetooth_data_received_callback(callback)[source]

Adds a callback for the event digi.xbee.reader.BluetoothDataReceived.

Parameters:callback (Function) –

the callback. Receives one argument.

  • The Bluetooth data as a Bytearray
add_micropython_data_received_callback(callback)[source]

Adds a callback for the event digi.xbee.reader.MicroPythonDataReceived.

Parameters:callback (Function) –

the callback. Receives one argument.

  • The MicroPython data as a Bytearray
add_socket_state_received_callback(callback)[source]

Adds a callback for the event digi.xbee.reader.SocketStateReceived.

Parameters:callback (Function) –

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 digi.xbee.reader.SocketDataReceived.

Parameters:callback (Function) –

the callback. Receives two arguments.

  • The socket ID as an Integer.
  • The data received as Bytearray
add_socket_data_received_from_callback(callback)[source]

Adds a callback for the event digi.xbee.reader.SocketDataReceivedFrom.

Parameters:callback (Function) –

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 data received as Bytearray
del_packet_received_callback(callback)[source]

Deletes a callback for the callback list of digi.xbee.reader.PacketReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.PacketReceived event.
del_data_received_callback(callback)[source]

Deletes a callback for the callback list of digi.xbee.reader.DataReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.DataReceived event.
del_modem_status_received_callback(callback)[source]

Deletes a callback for the callback list of digi.xbee.reader.ModemStatusReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.ModemStatusReceived event.
del_io_sample_received_callback(callback)[source]

Deletes a callback for the callback list of digi.xbee.reader.IOSampleReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.IOSampleReceived event.
del_expl_data_received_callback(callback)[source]

Deletes a callback for the callback list of digi.xbee.reader.ExplicitDataReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.ExplicitDataReceived event.
del_user_data_relay_received_callback(callback)[source]

Deletes a callback for the callback list of digi.xbee.reader.RelayDataReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.RelayDataReceived event.
del_bluetooth_data_received_callback(callback)[source]

Deletes a callback for the callback list of digi.xbee.reader.BluetoothDataReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.BluetoothDataReceived event.
del_micropython_data_received_callback(callback)[source]

Deletes a callback for the callback list of digi.xbee.reader.MicroPythonDataReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.MicroPythonDataReceived event.
del_socket_state_received_callback(callback)[source]

Deletes a callback for the callback list of digi.xbee.reader.SocketStateReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.SocketStateReceived event.
del_socket_data_received_callback(callback)[source]

Deletes a callback for the callback list of digi.xbee.reader.SocketDataReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.SocketDataReceived event.
del_socket_data_received_from_callback(callback)[source]

Deletes a callback for the callback list of digi.xbee.reader.SocketDataReceivedFrom event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.SocketDataReceivedFrom event.
get_xbee_device_callbacks()[source]

Returns this XBee internal callbacks for process received packets.

This method is called by the PacketListener associated with this XBee to get its callbacks. These callbacks will be executed before user callbacks.

Returns:PacketReceived
is_open()[source]

Returns whether this XBee device is open or not.

Returns:Boolean. True if this XBee device is open, False otherwise.
is_remote()[source]

Override method.

get_network()[source]

Returns this XBee device’s current network.

Returns:XBeeDevice.XBeeNetwork
send_packet_sync_and_get_response(packet_to_send, timeout=None)[source]

Override method.

See also

AbstractXBeeDevice._send_packet_sync_and_get_response()
send_packet(packet, sync=False)[source]

Override method.

See also

AbstractXBeeDevice._send_packet()
get_next_frame_id()[source]

Returns the next frame ID of the XBee device.

Returns:The next frame ID of the XBee device.
Return type:Integer
comm_iface

XBeeCommunicationInterface. The hardware interface associated to the XBee device.

serial_port

XBeeSerialPort. The serial port associated to the XBee device.

operating_mode

OperatingMode. The operating mode of the XBee device.

apply_changes()

Applies changes via AC command.

Raises:
apply_profile(profile_path, progress_callback=None)

Applies the given XBee profile to the XBee device.

Parameters:
  • profile_path (String) – path of the XBee profile file to apply.
  • progress_callback (Function, optional) –
    function to execute to receive progress information. Receives two
    arguments:
    • The current apply profile task as a String
    • The current apply profile task percentage as an Integer
Raises:
disable_bluetooth()

Disables the Bluetooth interface of this XBee device.

Note that your device must have Bluetooth Low Energy support to use this method.

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
enable_apply_changes(value)

Sets the apply_changes flag.

Parameters:value (Boolean) – True to enable the apply changes flag, False to disable it.
enable_bluetooth()

Enables the Bluetooth interface of this XBee device.

To work with this interface, you must also configure the Bluetooth password if not done previously. You can use the AbstractXBeeDevice.update_bluetooth_password() method for that purpose.

Note that your device must have Bluetooth Low Energy support to use this method.

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
execute_command(parameter)

Executes the provided command.

Parameters:

parameter (String) – The name of the AT command to be executed.

Raises:
get_16bit_addr()

Returns the 16-bit address of the XBee device.

Returns:the 16-bit address of the XBee device.
Return type:XBee16BitAddress

See also

get_64bit_addr()

Returns the 64-bit address of the XBee device.

Returns:the 64-bit address of the XBee device.
Return type:XBee64BitAddress

See also

get_adc_value(io_line)

Returns the analog value of the provided IO line.

The provided IO line must be previously configured as ADC. To do so, use AbstractXBeeDevice.set_io_configuration() and IOMode.ADC.

Parameters:

io_line (IOLine) – the IO line to get its ADC value.

Returns:

the analog value corresponding to the provided IO line.

Return type:

Integer

Raises:

See also

get_api_output_mode()

Deprecated since version 1.3: Use get_api_output_mode_value()

Returns the API output mode of the XBee device.

The API output mode determines the format that the received data is output through the serial interface of the XBee device.

Returns:

the API output mode of the XBee device.

Return type:

APIOutputMode

Raises:

See also

get_api_output_mode_value()

Returns the API output mode of the XBee.

The API output mode determines the format that the received data is output through the serial interface of the XBee.

Returns:

the parameter value.

Return type:

Bytearray

Raises:
get_bluetooth_mac_addr()

Reads and returns the EUI-48 Bluetooth MAC address of this XBee device in a format such as 00112233AABB.

Note that your device must have Bluetooth Low Energy support to use this method.

Returns:

The Bluetooth MAC address.

Return type:

String

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
get_current_frame_id()

Returns the last used frame ID.

Returns:the last used frame ID.
Return type:Integer
get_dest_address()

Returns the 64-bit address of the XBee device that data will be reported to.

Returns:the address.
Return type:XBee64BitAddress
Raises:TimeoutException – if the response is not received before the read timeout expires.

See also

get_dio_value(io_line)

Returns the digital value of the provided IO line.

The provided IO line must be previously configured as digital I/O. To do so, use AbstractXBeeDevice.set_io_configuration().

Parameters:

io_line (IOLine) – the DIO line to gets its digital value.

Returns:

current value of the provided IO line.

Return type:

IOValue

Raises:

See also

get_firmware_version()

Returns the firmware version of the XBee device.

Returns:the hardware version of the XBee device.
Return type:Bytearray
get_hardware_version()

Returns the hardware version of the XBee device.

Returns:the hardware version of the XBee device.
Return type:HardwareVersion

See also

get_io_configuration(io_line)

Returns the configuration of the provided IO line.

Parameters:

io_line (IOLine) – the io line to configure.

Returns:

the IO mode of the IO line provided.

Return type:

IOMode

Raises:
get_io_sampling_rate()

Returns the IO sampling rate of the XBee device.

Returns:

the IO sampling rate of XBee device.

Return type:

Integer

Raises:
get_node_id()

Returns the Node Identifier (NI) value of the XBee device.

Returns:the Node Identifier (NI) of the XBee device.
Return type:String
get_pan_id()

Returns the operating PAN ID of the XBee device.

Returns:operating PAN ID of the XBee device.
Return type:Bytearray
Raises:TimeoutException – if the response is not received before the read timeout expires.
get_power_level()

Returns the power level of the XBee device.

Returns:the power level of the XBee device.
Return type:PowerLevel
Raises:TimeoutException – if the response is not received before the read timeout expires.

See also

get_protocol()

Returns the current protocol of the XBee device.

Returns:the current protocol of the XBee device.
Return type:XBeeProtocol

See also

get_pwm_duty_cycle(io_line)

Returns the PWM duty cycle in % corresponding to the provided IO line.

Parameters:

io_line (IOLine) – the IO line to get its PWM duty cycle.

Returns:

the PWM duty cycle of the given IO line or None if the response is empty.

Return type:

Integer

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – if the response is not as expected.
  • ValueError – if the passed IO_LINE has no PWM capability.

See also

get_role()

Gets the XBee role.

Returns:the role of the XBee.
Return type:digi.xbee.models.protocol.Role
get_sync_ops_timeout()

Returns the serial port read timeout.

Returns:the serial port read timeout in seconds.
Return type:Integer
is_apply_changes_enabled()

Returns whether the apply_changes flag is enabled or not.

Returns:True if the apply_changes flag is enabled, False otherwise.
Return type:Boolean
log

Returns the XBee device log.

Returns:the XBee device logger.
Return type:Logger
read_device_info(init=True)

Updates all instance parameters reading them from the XBee device.

Parameters:

init (Boolean, optional, default=`True`) – If False only not initialized parameters are read, all if True.

Raises:
read_io_sample()

Returns an IO sample from the XBee device containing the value of all enabled digital IO and analog input channels.

Returns:

the IO sample read from the XBee device.

Return type:

IOSample

Raises:

See also

set_16bit_addr(value)

Sets the 16-bit address of the XBee device.

Parameters:

value (XBee16BitAddress) – the new 16-bit address of the XBee device.

Raises:
set_api_output_mode(api_output_mode)

Deprecated since version 1.3: Use set_api_output_mode_value()

Sets the API output mode of the XBee device.

Parameters:

api_output_mode (APIOutputMode) – the new API output mode of the XBee device.

Raises:

See also

set_api_output_mode_value(api_output_mode)

Sets the API output mode of the XBee.

Parameters:

api_output_mode (Integer) – new API output mode options. Calculate this value using the method digi.xbee.models.mode.APIOutputModeBit.calculate_api_output_mode_value() with a set of digi.xbee.models.mode.APIOutputModeBit.

Raises:
set_dest_address(addr)

Sets the 64-bit address of the XBee device that data will be reported to.

Parameters:

addr (XBee64BitAddress or RemoteXBeeDevice) – the address itself or the remote XBee device that you want to set up its address as destination address.

Raises:
  • TimeoutException – If the response is not received before the read timeout expires.
  • XBeeException – If the XBee device’s serial port is closed.
  • InvalidOperatingModeException – If the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If the response is not as expected.
  • ValueError – If addr is None.
set_dio_change_detection(io_lines_set)

Sets the digital IO lines to be monitored and sampled whenever their status changes.

A None set of lines disables this feature.

Parameters:

io_lines_set – set of IOLine.

Raises:

See also

set_dio_value(io_line, io_value)

Sets the digital value (high or low) to the provided IO line.

Parameters:
  • io_line (IOLine) – the digital IO line to sets its value.
  • io_value (IOValue) – the IO value to set to the IO line.
Raises:

See also

set_io_configuration(io_line, io_mode)

Sets the configuration of the provided IO line.

Parameters:
  • io_line (IOLine) – the IO line to configure.
  • io_mode (IOMode) – the IO mode to set to the IO line.
Raises:

See also

set_io_sampling_rate(rate)

Sets the IO sampling rate of the XBee device in seconds. A sample rate of 0 means the IO sampling feature is disabled.

Parameters:

rate (Integer) – the new IO sampling rate of the XBee device in seconds.

Raises:
set_node_id(node_id)

Sets the Node Identifier (NI) value of the XBee device..

Parameters:

node_id (String) – the new Node Identifier (NI) of the XBee device.

Raises:
  • ValueError – if node_id is None or its length is greater than 20.
  • TimeoutException – if the response is not received before the read timeout expires.
set_pan_id(value)

Sets the operating PAN ID of the XBee device.

Parameters:value (Bytearray) – the new operating PAN ID of the XBee device.. Must have only 1 or 2 bytes.
Raises:TimeoutException – if the response is not received before the read timeout expires.
set_power_level(power_level)

Sets the power level of the XBee device.

Parameters:power_level (PowerLevel) – the new power level of the XBee device.
Raises:TimeoutException – if the response is not received before the read timeout expires.

See also

set_pwm_duty_cycle(io_line, cycle)

Sets the duty cycle in % of the provided IO line.

The provided IO line must be PWM-capable, previously configured as PWM output.

Parameters:
  • io_line (IOLine) – the IO Line to be assigned.
  • cycle (Integer) – duty cycle in % to be assigned. Must be between 0 and 100.
Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – if the response is not as expected.
  • ValueError – if the given IO line does not have PWM capability or cycle is not between 0 and 100.

See also

set_sync_ops_timeout(sync_ops_timeout)

Sets the serial port read timeout.

Parameters:sync_ops_timeout (Integer) – the read timeout, expressed in seconds.
update_bluetooth_password(new_password)

Changes the password of this Bluetooth device with the new one provided.

Note that your device must have Bluetooth Low Energy support to use this method.

Parameters:

new_password (String) – New Bluetooth password.

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
update_device_data_from(device)

Updates the current device reference with the data provided for the given device.

This is only for internal use.

Parameters:device (AbstractXBeeDevice) – the XBee device to get the data from.
Returns:True if the device data has been updated, False otherwise.
Return type:Boolean
update_firmware(xml_firmware_file, xbee_firmware_file=None, bootloader_firmware_file=None, timeout=None, progress_callback=None)

Performs a firmware update operation of the device.

Parameters:
  • xml_firmware_file (String) – path of the XML file that describes the firmware to upload.
  • xbee_firmware_file (String, optional) – location of the XBee binary firmware file.
  • bootloader_firmware_file (String, optional) – location of the bootloader binary firmware file.
  • timeout (Integer, optional) – the maximum time to wait for target read operations during the update process.
  • progress_callback (Function, optional) –
    function to execute to receive progress information. Receives two
    arguments:
    • The current update task as a String
    • The current update task percentage as an Integer
Raises:
write_changes()

Writes configurable parameter values to the non-volatile memory of the XBee device so that parameter modifications persist through subsequent resets.

Parameters values remain in this device’s memory until overwritten by subsequent use of this method.

If changes are made without writing them to non-volatile memory, the module reverts back to previously saved parameters the next time the module is powered-on.

Writing the parameter modifications does not mean those values are immediately applied, this depends on the status of the ‘apply configuration changes’ option. Use method is_apply_configuration_changes_enabled() to get its status and enable_apply_configuration_changes() to enable/disable the option. If it is disabled, method apply_changes() can be used in order to manually apply the changes.

Raises:
class digi.xbee.devices.Raw802Device(port=None, baud_rate=None, data_bits=<sphinx.ext.autodoc.importer._MockObject object>, stop_bits=<sphinx.ext.autodoc.importer._MockObject object>, parity=<sphinx.ext.autodoc.importer._MockObject object>, flow_control=<FlowControl.NONE: None>, _sync_ops_timeout=4, comm_iface=None)[source]

Bases: digi.xbee.devices.XBeeDevice

This class represents a local 802.15.4 XBee device.

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

Parameters:
  • port (Integer or String) – serial port identifier. Integer: number of XBee device, numbering starts at zero. Device name: depending on operating system. e.g. ‘/dev/ttyUSB0’ on ‘GNU/Linux’ or ‘COM3’ on Windows.
  • baud_rate (Integer) – the serial port baud rate.
  • (Integer, default (flow_control) – serial.EIGHTBITS): comm port bitsize.
  • (Integer, defaultserial.STOPBITS_ONE): comm port stop bits.
  • (Character, default (parity) – serial.PARITY_NONE): comm port parity.
  • (Integer, default

    FlowControl.NONE): comm port flow control.

    _sync_ops_timeout (Integer, default: 3): the read timeout (in seconds).
    comm_iface (XBeeCommunicationInterface): the communication interface.

:raises All exceptions raised by XBeeDevice.__init__() constructor.:

See also

XBeeDevice.__init__()
open(force_settings=False)[source]

Override.

Raises:
  • TimeoutException – If there is any problem with the communication.
  • InvalidOperatingModeException – If the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – If the protocol is invalid or if the XBee device is already open.
get_protocol()[source]

Override.

get_ai_status()[source]

Override.

See also

AbstractXBeeDevice._get_ai_status()
send_data_64(x64addr, data, transmit_options=0)[source]

Override.

See also

XBeeDevice.send_data_64()
send_data_async_64(x64addr, data, transmit_options=0)[source]

Override.

See also

XBeeDevice.send_data_async_64()
send_data_16(x16addr, data, transmit_options=0)[source]

Override.

See also

XBeeDevice._send_data_16()
send_data_async_16(x16addr, data, transmit_options=0)[source]

Override.

See also

XBeeDevice._send_data_async_16()
add_bluetooth_data_received_callback(callback)

Adds a callback for the event digi.xbee.reader.BluetoothDataReceived.

Parameters:callback (Function) –

the callback. Receives one argument.

  • The Bluetooth data as a Bytearray
add_data_received_callback(callback)

Adds a callback for the event digi.xbee.reader.DataReceived.

Parameters:callback (Function) –

the callback. Receives one argument.

add_expl_data_received_callback(callback)

Adds a callback for the event digi.xbee.reader.ExplicitDataReceived.

Parameters:callback (Function) –

the callback. Receives one argument.

add_io_sample_received_callback(callback)

Adds a callback for the event digi.xbee.reader.IOSampleReceived.

Parameters:callback (Function) –

the callback. Receives three arguments.

add_micropython_data_received_callback(callback)

Adds a callback for the event digi.xbee.reader.MicroPythonDataReceived.

Parameters:callback (Function) –

the callback. Receives one argument.

  • The MicroPython data as a Bytearray
add_modem_status_received_callback(callback)

Adds a callback for the event digi.xbee.reader.ModemStatusReceived.

Parameters:callback (Function) –

the callback. Receives one argument.

add_packet_received_callback(callback)

Adds a callback for the event digi.xbee.reader.PacketReceived.

Parameters:callback (Function) –

the callback. Receives two arguments.

add_socket_data_received_callback(callback)

Adds a callback for the event digi.xbee.reader.SocketDataReceived.

Parameters:callback (Function) –

the callback. Receives two arguments.

  • The socket ID as an Integer.
  • The data received as Bytearray
add_socket_data_received_from_callback(callback)

Adds a callback for the event digi.xbee.reader.SocketDataReceivedFrom.

Parameters:callback (Function) –

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 data received as Bytearray
add_socket_state_received_callback(callback)

Adds a callback for the event digi.xbee.reader.SocketStateReceived.

Parameters:callback (Function) –

the callback. Receives two arguments.

  • The socket ID as an Integer.
  • The state received as a SocketState
add_user_data_relay_received_callback(callback)

Adds a callback for the event digi.xbee.reader.RelayDataReceived.

Parameters:callback (Function) –

the callback. Receives one argument.

apply_changes()

Applies changes via AC command.

Raises:
apply_profile(profile_path, progress_callback=None)

Applies the given XBee profile to the XBee device.

Parameters:
  • profile_path (String) – path of the XBee profile file to apply.
  • progress_callback (Function, optional) –
    function to execute to receive progress information. Receives two
    arguments:
    • The current apply profile task as a String
    • The current apply profile task percentage as an Integer
Raises:
close()

Closes the communication with the XBee device.

This method guarantees that all threads running are stopped and the serial port is closed.

comm_iface

Returns the hardware interface associated to the XBee device.

Returns:the hardware interface associated to the XBee device.
Return type:XBeeCommunicationInterface

See also

classmethod create_xbee_device(comm_port_data)

Creates and returns an XBeeDevice from data of the port to which is connected.

Parameters:
  • comm_port_data (Dictionary) – dictionary with all comm port data needed.
  • dictionary keys are (The) –
    “baudRate” –> Baud rate.
    ”port” –> Port number.
    ”bitSize” –> Bit size.
    ”stopBits” –> Stop bits.
    ”parity” –> Parity.
    ”flowControl” –> Flow control.
    ”timeout” for –> Timeout for synchronous operations (in seconds).
Returns:

the XBee device created.

Return type:

XBeeDevice

Raises:

SerialException – if the port you want to open does not exist or is already opened.

See also

del_bluetooth_data_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.BluetoothDataReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.BluetoothDataReceived event.
del_data_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.DataReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.DataReceived event.
del_expl_data_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.ExplicitDataReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.ExplicitDataReceived event.
del_io_sample_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.IOSampleReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.IOSampleReceived event.
del_micropython_data_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.MicroPythonDataReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.MicroPythonDataReceived event.
del_modem_status_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.ModemStatusReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.ModemStatusReceived event.
del_packet_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.PacketReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.PacketReceived event.
del_socket_data_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.SocketDataReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.SocketDataReceived event.
del_socket_data_received_from_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.SocketDataReceivedFrom event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.SocketDataReceivedFrom event.
del_socket_state_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.SocketStateReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.SocketStateReceived event.
del_user_data_relay_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.RelayDataReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.RelayDataReceived event.
disable_bluetooth()

Disables the Bluetooth interface of this XBee device.

Note that your device must have Bluetooth Low Energy support to use this method.

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
enable_apply_changes(value)

Sets the apply_changes flag.

Parameters:value (Boolean) – True to enable the apply changes flag, False to disable it.
enable_bluetooth()

Enables the Bluetooth interface of this XBee device.

To work with this interface, you must also configure the Bluetooth password if not done previously. You can use the AbstractXBeeDevice.update_bluetooth_password() method for that purpose.

Note that your device must have Bluetooth Low Energy support to use this method.

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
execute_command(parameter)

Executes the provided command.

Parameters:

parameter (String) – The name of the AT command to be executed.

Raises:
flush_queues()

Flushes the packets queue.

get_16bit_addr()

Returns the 16-bit address of the XBee device.

Returns:the 16-bit address of the XBee device.
Return type:XBee16BitAddress

See also

get_64bit_addr()

Returns the 64-bit address of the XBee device.

Returns:the 64-bit address of the XBee device.
Return type:XBee64BitAddress

See also

get_adc_value(io_line)

Returns the analog value of the provided IO line.

The provided IO line must be previously configured as ADC. To do so, use AbstractXBeeDevice.set_io_configuration() and IOMode.ADC.

Parameters:

io_line (IOLine) – the IO line to get its ADC value.

Returns:

the analog value corresponding to the provided IO line.

Return type:

Integer

Raises:

See also

get_api_output_mode()

Deprecated since version 1.3: Use get_api_output_mode_value()

Returns the API output mode of the XBee device.

The API output mode determines the format that the received data is output through the serial interface of the XBee device.

Returns:

the API output mode of the XBee device.

Return type:

APIOutputMode

Raises:

See also

get_api_output_mode_value()

Returns the API output mode of the XBee.

The API output mode determines the format that the received data is output through the serial interface of the XBee.

Returns:

the parameter value.

Return type:

Bytearray

Raises:
get_bluetooth_mac_addr()

Reads and returns the EUI-48 Bluetooth MAC address of this XBee device in a format such as 00112233AABB.

Note that your device must have Bluetooth Low Energy support to use this method.

Returns:

The Bluetooth MAC address.

Return type:

String

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
get_current_frame_id()

Returns the last used frame ID.

Returns:the last used frame ID.
Return type:Integer
get_dest_address()

Returns the 64-bit address of the XBee device that data will be reported to.

Returns:the address.
Return type:XBee64BitAddress
Raises:TimeoutException – if the response is not received before the read timeout expires.

See also

get_dio_value(io_line)

Returns the digital value of the provided IO line.

The provided IO line must be previously configured as digital I/O. To do so, use AbstractXBeeDevice.set_io_configuration().

Parameters:

io_line (IOLine) – the DIO line to gets its digital value.

Returns:

current value of the provided IO line.

Return type:

IOValue

Raises:

See also

get_firmware_version()

Returns the firmware version of the XBee device.

Returns:the hardware version of the XBee device.
Return type:Bytearray
get_hardware_version()

Returns the hardware version of the XBee device.

Returns:the hardware version of the XBee device.
Return type:HardwareVersion

See also

get_io_configuration(io_line)

Returns the configuration of the provided IO line.

Parameters:

io_line (IOLine) – the io line to configure.

Returns:

the IO mode of the IO line provided.

Return type:

IOMode

Raises:
get_io_sampling_rate()

Returns the IO sampling rate of the XBee device.

Returns:

the IO sampling rate of XBee device.

Return type:

Integer

Raises:
get_network()

Returns this XBee device’s current network.

Returns:XBeeDevice.XBeeNetwork
get_next_frame_id()

Returns the next frame ID of the XBee device.

Returns:The next frame ID of the XBee device.
Return type:Integer
get_node_id()

Returns the Node Identifier (NI) value of the XBee device.

Returns:the Node Identifier (NI) of the XBee device.
Return type:String
get_pan_id()

Returns the operating PAN ID of the XBee device.

Returns:operating PAN ID of the XBee device.
Return type:Bytearray
Raises:TimeoutException – if the response is not received before the read timeout expires.
get_parameter(param, parameter_value=None)

Override.

get_power_level()

Returns the power level of the XBee device.

Returns:the power level of the XBee device.
Return type:PowerLevel
Raises:TimeoutException – if the response is not received before the read timeout expires.

See also

get_pwm_duty_cycle(io_line)

Returns the PWM duty cycle in % corresponding to the provided IO line.

Parameters:

io_line (IOLine) – the IO line to get its PWM duty cycle.

Returns:

the PWM duty cycle of the given IO line or None if the response is empty.

Return type:

Integer

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – if the response is not as expected.
  • ValueError – if the passed IO_LINE has no PWM capability.

See also

get_role()

Gets the XBee role.

Returns:the role of the XBee.
Return type:digi.xbee.models.protocol.Role
get_sync_ops_timeout()

Returns the serial port read timeout.

Returns:the serial port read timeout in seconds.
Return type:Integer
get_xbee_device_callbacks()

Returns this XBee internal callbacks for process received packets.

This method is called by the PacketListener associated with this XBee to get its callbacks. These callbacks will be executed before user callbacks.

Returns:PacketReceived
has_explicit_packets()

Returns whether the XBee device’s queue has explicit packets or not. This do not include non-explicit packets.

Returns:True if this XBee device’s queue has explicit packets, False otherwise.
Return type:Boolean
has_packets()

Returns whether the XBee device’s queue has packets or not. This do not include explicit packets.

Returns:True if this XBee device’s queue has packets, False otherwise.
Return type:Boolean
is_apply_changes_enabled()

Returns whether the apply_changes flag is enabled or not.

Returns:True if the apply_changes flag is enabled, False otherwise.
Return type:Boolean
is_open()

Returns whether this XBee device is open or not.

Returns:Boolean. True if this XBee device is open, False otherwise.
is_remote()

Override method.

log

Returns the XBee device log.

Returns:the XBee device logger.
Return type:Logger
operating_mode

Returns this XBee device’s operating mode.

Returns:OperatingMode. This XBee device’s operating mode.
read_data(timeout=None)

Reads new data received by this XBee device.

If a timeout is specified, this method blocks until new data is received or the timeout expires, throwing in that case a TimeoutException.

Parameters:

timeout (Integer, optional) – read timeout in seconds. If it’s None, this method is non-blocking and will return None if there is no data available.

Returns:

the read message or None if this XBee did not receive new data.

Return type:

XBeeMessage

Raises:
  • ValueError – if a timeout is specified and is less than 0.
  • TimeoutException – if a timeout is specified and no data was received during that time.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – if the XBee device’s serial port is closed.

See also

read_data_from(remote_xbee_device, timeout=None)

Reads new data received from the given remote XBee device.

If a timeout is specified, this method blocks until new data is received or the timeout expires, throwing in that case a TimeoutException.

Parameters:
  • remote_xbee_device (RemoteXBeeDevice) – the remote XBee device that sent the data.
  • timeout (Integer, optional) – read timeout in seconds. If it’s None, this method is non-blocking and will return None if there is no data available.
Returns:

the read message sent by remote_xbee_device or None if this XBee did

not receive new data.

Return type:

XBeeMessage

Raises:
  • ValueError – if a timeout is specified and is less than 0.
  • TimeoutException – if a timeout is specified and no data was received during that time.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – if the XBee device’s serial port is closed.
read_device_info(init=True)

Updates all instance parameters reading them from the XBee device.

Parameters:

init (Boolean, optional, default=`True`) – If False only not initialized parameters are read, all if True.

Raises:
read_io_sample()

Returns an IO sample from the XBee device containing the value of all enabled digital IO and analog input channels.

Returns:

the IO sample read from the XBee device.

Return type:

IOSample

Raises:

See also

reset()

Override method.

send_bluetooth_data(data)

Sends the given data to the Bluetooth interface using a User Data Relay frame.

Parameters:

data (Bytearray) – Data to send.

Raises:
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – if there is any problem sending the data.
send_data(remote_xbee_device, data, transmit_options=0)

Blocking method. This method sends data to a remote XBee device synchronously.

This method will wait for the packet response.

The default timeout for this method is XBeeDevice._DEFAULT_TIMEOUT_SYNC_OPERATIONS.

Parameters:
  • remote_xbee_device (RemoteXBeeDevice) – the remote XBee device to send data to.
  • data (String or Bytearray) – the raw data to send.
  • transmit_options (Integer, optional) – transmit options, bitfield of TransmitOptions. Default to TransmitOptions.NONE.value.
Returns:

XBeePacket the response.

Raises:
  • ValueError – if remote_xbee_device is None.
  • TimeoutException – if this method can’t read a response packet in XBeeDevice._DEFAULT_TIMEOUT_SYNC_OPERATIONS seconds.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • TransmitException – if the status of the response received is not OK.
  • XBeeException – if the XBee device’s serial port is closed.
send_data_async(remote_xbee_device, data, transmit_options=0)

Non-blocking method. This method sends data to a remote XBee device.

This method won’t wait for the response.

Parameters:
  • remote_xbee_device (RemoteXBeeDevice) – the remote XBee device to send data to.
  • data (String or Bytearray) – the raw data to send.
  • transmit_options (Integer, optional) – transmit options, bitfield of TransmitOptions. Default to TransmitOptions.NONE.value.
Raises:
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – if the XBee device’s serial port is closed.

See also

send_data_broadcast(data, transmit_options=0)

Sends the provided data to all the XBee nodes of the network (broadcast).

This method blocks till a success or error transmit status arrives or the configured receive timeout expires.

The received timeout is configured using the AbstractXBeeDevice.set_sync_ops_timeout() method and can be consulted with AbstractXBeeDevice.get_sync_ops_timeout() method.

Parameters:
  • data (String or Bytearray) – data to send.
  • transmit_options (Integer, optional) – transmit options, bitfield of TransmitOptions. Default to TransmitOptions.NONE.value.
Raises:
  • TimeoutException – if this method can’t read a response packet in XBeeDevice._DEFAULT_TIMEOUT_SYNC_OPERATIONS seconds.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • TransmitException – if the status of the response received is not OK.
  • XBeeException – if the XBee device’s serial port is closed.
send_micropython_data(data)

Sends the given data to the MicroPython interface using a User Data Relay frame.

Parameters:

data (Bytearray) – Data to send.

Raises:
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – if there is any problem sending the data.
send_packet(packet, sync=False)

Override method.

See also

AbstractXBeeDevice._send_packet()
send_packet_sync_and_get_response(packet_to_send, timeout=None)

Override method.

See also

AbstractXBeeDevice._send_packet_sync_and_get_response()
send_user_data_relay(local_interface, data)

Sends the given data to the given XBee local interface.

Parameters:
  • local_interface (XBeeLocalInterface) – Destination XBee local interface.
  • data (Bytearray) – Data to send.
Raises:
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ValueError – if local_interface is None.
  • XBeeException – if there is any problem sending the User Data Relay.
serial_port

Returns the serial port associated to the XBee device, if any.

Returns:
the serial port associated to the XBee device. Returns None if the local XBee
does not use serial communication.
Return type:XBeeSerialPort

See also

set_16bit_addr(value)

Sets the 16-bit address of the XBee device.

Parameters:

value (XBee16BitAddress) – the new 16-bit address of the XBee device.

Raises:
set_api_output_mode(api_output_mode)

Deprecated since version 1.3: Use set_api_output_mode_value()

Sets the API output mode of the XBee device.

Parameters:

api_output_mode (APIOutputMode) – the new API output mode of the XBee device.

Raises:

See also

set_api_output_mode_value(api_output_mode)

Sets the API output mode of the XBee.

Parameters:

api_output_mode (Integer) – new API output mode options. Calculate this value using the method digi.xbee.models.mode.APIOutputModeBit.calculate_api_output_mode_value() with a set of digi.xbee.models.mode.APIOutputModeBit.

Raises:
set_dest_address(addr)

Sets the 64-bit address of the XBee device that data will be reported to.

Parameters:

addr (XBee64BitAddress or RemoteXBeeDevice) – the address itself or the remote XBee device that you want to set up its address as destination address.

Raises:
  • TimeoutException – If the response is not received before the read timeout expires.
  • XBeeException – If the XBee device’s serial port is closed.
  • InvalidOperatingModeException – If the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If the response is not as expected.
  • ValueError – If addr is None.
set_dio_change_detection(io_lines_set)

Sets the digital IO lines to be monitored and sampled whenever their status changes.

A None set of lines disables this feature.

Parameters:

io_lines_set – set of IOLine.

Raises:

See also

set_dio_value(io_line, io_value)

Sets the digital value (high or low) to the provided IO line.

Parameters:
  • io_line (IOLine) – the digital IO line to sets its value.
  • io_value (IOValue) – the IO value to set to the IO line.
Raises:

See also

set_io_configuration(io_line, io_mode)

Sets the configuration of the provided IO line.

Parameters:
  • io_line (IOLine) – the IO line to configure.
  • io_mode (IOMode) – the IO mode to set to the IO line.
Raises:

See also

set_io_sampling_rate(rate)

Sets the IO sampling rate of the XBee device in seconds. A sample rate of 0 means the IO sampling feature is disabled.

Parameters:

rate (Integer) – the new IO sampling rate of the XBee device in seconds.

Raises:
set_node_id(node_id)

Sets the Node Identifier (NI) value of the XBee device..

Parameters:

node_id (String) – the new Node Identifier (NI) of the XBee device.

Raises:
  • ValueError – if node_id is None or its length is greater than 20.
  • TimeoutException – if the response is not received before the read timeout expires.
set_pan_id(value)

Sets the operating PAN ID of the XBee device.

Parameters:value (Bytearray) – the new operating PAN ID of the XBee device.. Must have only 1 or 2 bytes.
Raises:TimeoutException – if the response is not received before the read timeout expires.
set_parameter(param, value)

Override.

See:
AbstractXBeeDevice.set_parameter()
set_power_level(power_level)

Sets the power level of the XBee device.

Parameters:power_level (PowerLevel) – the new power level of the XBee device.
Raises:TimeoutException – if the response is not received before the read timeout expires.

See also

set_pwm_duty_cycle(io_line, cycle)

Sets the duty cycle in % of the provided IO line.

The provided IO line must be PWM-capable, previously configured as PWM output.

Parameters:
  • io_line (IOLine) – the IO Line to be assigned.
  • cycle (Integer) – duty cycle in % to be assigned. Must be between 0 and 100.
Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – if the response is not as expected.
  • ValueError – if the given IO line does not have PWM capability or cycle is not between 0 and 100.

See also

set_sync_ops_timeout(sync_ops_timeout)

Sets the serial port read timeout.

Parameters:sync_ops_timeout (Integer) – the read timeout, expressed in seconds.
update_bluetooth_password(new_password)

Changes the password of this Bluetooth device with the new one provided.

Note that your device must have Bluetooth Low Energy support to use this method.

Parameters:

new_password (String) – New Bluetooth password.

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
update_device_data_from(device)

Updates the current device reference with the data provided for the given device.

This is only for internal use.

Parameters:device (AbstractXBeeDevice) – the XBee device to get the data from.
Returns:True if the device data has been updated, False otherwise.
Return type:Boolean
update_firmware(xml_firmware_file, xbee_firmware_file=None, bootloader_firmware_file=None, timeout=None, progress_callback=None)

Performs a firmware update operation of the device.

Parameters:
  • xml_firmware_file (String) – path of the XML file that describes the firmware to upload.
  • xbee_firmware_file (String, optional) – location of the XBee binary firmware file.
  • bootloader_firmware_file (String, optional) – location of the bootloader binary firmware file.
  • timeout (Integer, optional) – the maximum time to wait for target read operations during the update process.
  • progress_callback (Function, optional) –
    function to execute to receive progress information. Receives two
    arguments:
    • The current update task as a String
    • The current update task percentage as an Integer
Raises:
write_changes()

Writes configurable parameter values to the non-volatile memory of the XBee device so that parameter modifications persist through subsequent resets.

Parameters values remain in this device’s memory until overwritten by subsequent use of this method.

If changes are made without writing them to non-volatile memory, the module reverts back to previously saved parameters the next time the module is powered-on.

Writing the parameter modifications does not mean those values are immediately applied, this depends on the status of the ‘apply configuration changes’ option. Use method is_apply_configuration_changes_enabled() to get its status and enable_apply_configuration_changes() to enable/disable the option. If it is disabled, method apply_changes() can be used in order to manually apply the changes.

Raises:
class digi.xbee.devices.DigiMeshDevice(port=None, baud_rate=None, data_bits=<sphinx.ext.autodoc.importer._MockObject object>, stop_bits=<sphinx.ext.autodoc.importer._MockObject object>, parity=<sphinx.ext.autodoc.importer._MockObject object>, flow_control=<FlowControl.NONE: None>, _sync_ops_timeout=4, comm_iface=None)[source]

Bases: digi.xbee.devices.XBeeDevice

This class represents a local DigiMesh XBee device.

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

Parameters:
  • port (Integer or String) – serial port identifier. Integer: number of XBee device, numbering starts at zero. Device name: depending on operating system. e.g. ‘/dev/ttyUSB0’ on ‘GNU/Linux’ or ‘COM3’ on Windows.
  • baud_rate (Integer) – the serial port baud rate.
  • (Integer, default (flow_control) – serial.EIGHTBITS): comm port bitsize.
  • (Integer, defaultserial.STOPBITS_ONE): comm port stop bits.
  • (Character, default (parity) – serial.PARITY_NONE): comm port parity.
  • (Integer, default

    FlowControl.NONE): comm port flow control.

    _sync_ops_timeout (Integer, default: 3): the read timeout (in seconds).
    comm_iface (XBeeCommunicationInterface): the communication interface.

:raises All exceptions raised by XBeeDevice.__init__() constructor.:

See also

XBeeDevice.__init__()
open(force_settings=False)[source]

Override.

Raises:
  • TimeoutException – If there is any problem with the communication.
  • InvalidOperatingModeException – If the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – If the protocol is invalid or if the XBee device is already open.
get_protocol()[source]

Override.

send_data_64(x64addr, data, transmit_options=0)[source]

Override.

See also

XBeeDevice.send_data_64()
send_data_async_64(x64addr, data, transmit_options=0)[source]

Override.

See also

XBeeDevice.send_data_async_64()
read_expl_data(timeout=None)[source]

Override.

See also

XBeeDevice.read_expl_data()
read_expl_data_from(remote_xbee_device, timeout=None)[source]

Override.

See also

XBeeDevice.read_expl_data_from()
send_expl_data(remote_xbee_device, data, src_endpoint, dest_endpoint, cluster_id, profile_id, transmit_options=0)[source]

Override.

See also

XBeeDevice.send_expl_data()
send_expl_data_broadcast(data, src_endpoint, dest_endpoint, cluster_id, profile_id, transmit_options=0)[source]

Override.

See also

XBeeDevice._send_expl_data_broadcast()
send_expl_data_async(remote_xbee_device, data, src_endpoint, dest_endpoint, cluster_id, profile_id, transmit_options=0)[source]

Override.

See also

XBeeDevice.send_expl_data_async()
add_bluetooth_data_received_callback(callback)

Adds a callback for the event digi.xbee.reader.BluetoothDataReceived.

Parameters:callback (Function) –

the callback. Receives one argument.

  • The Bluetooth data as a Bytearray
add_data_received_callback(callback)

Adds a callback for the event digi.xbee.reader.DataReceived.

Parameters:callback (Function) –

the callback. Receives one argument.

add_expl_data_received_callback(callback)

Adds a callback for the event digi.xbee.reader.ExplicitDataReceived.

Parameters:callback (Function) –

the callback. Receives one argument.

add_io_sample_received_callback(callback)

Adds a callback for the event digi.xbee.reader.IOSampleReceived.

Parameters:callback (Function) –

the callback. Receives three arguments.

add_micropython_data_received_callback(callback)

Adds a callback for the event digi.xbee.reader.MicroPythonDataReceived.

Parameters:callback (Function) –

the callback. Receives one argument.

  • The MicroPython data as a Bytearray
add_modem_status_received_callback(callback)

Adds a callback for the event digi.xbee.reader.ModemStatusReceived.

Parameters:callback (Function) –

the callback. Receives one argument.

add_packet_received_callback(callback)

Adds a callback for the event digi.xbee.reader.PacketReceived.

Parameters:callback (Function) –

the callback. Receives two arguments.

add_socket_data_received_callback(callback)

Adds a callback for the event digi.xbee.reader.SocketDataReceived.

Parameters:callback (Function) –

the callback. Receives two arguments.

  • The socket ID as an Integer.
  • The data received as Bytearray
add_socket_data_received_from_callback(callback)

Adds a callback for the event digi.xbee.reader.SocketDataReceivedFrom.

Parameters:callback (Function) –

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 data received as Bytearray
add_socket_state_received_callback(callback)

Adds a callback for the event digi.xbee.reader.SocketStateReceived.

Parameters:callback (Function) –

the callback. Receives two arguments.

  • The socket ID as an Integer.
  • The state received as a SocketState
add_user_data_relay_received_callback(callback)

Adds a callback for the event digi.xbee.reader.RelayDataReceived.

Parameters:callback (Function) –

the callback. Receives one argument.

apply_changes()

Applies changes via AC command.

Raises:
apply_profile(profile_path, progress_callback=None)

Applies the given XBee profile to the XBee device.

Parameters:
  • profile_path (String) – path of the XBee profile file to apply.
  • progress_callback (Function, optional) –
    function to execute to receive progress information. Receives two
    arguments:
    • The current apply profile task as a String
    • The current apply profile task percentage as an Integer
Raises:
close()

Closes the communication with the XBee device.

This method guarantees that all threads running are stopped and the serial port is closed.

comm_iface

Returns the hardware interface associated to the XBee device.

Returns:the hardware interface associated to the XBee device.
Return type:XBeeCommunicationInterface

See also

classmethod create_xbee_device(comm_port_data)

Creates and returns an XBeeDevice from data of the port to which is connected.

Parameters:
  • comm_port_data (Dictionary) – dictionary with all comm port data needed.
  • dictionary keys are (The) –
    “baudRate” –> Baud rate.
    ”port” –> Port number.
    ”bitSize” –> Bit size.
    ”stopBits” –> Stop bits.
    ”parity” –> Parity.
    ”flowControl” –> Flow control.
    ”timeout” for –> Timeout for synchronous operations (in seconds).
Returns:

the XBee device created.

Return type:

XBeeDevice

Raises:

SerialException – if the port you want to open does not exist or is already opened.

See also

del_bluetooth_data_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.BluetoothDataReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.BluetoothDataReceived event.
del_data_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.DataReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.DataReceived event.
del_expl_data_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.ExplicitDataReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.ExplicitDataReceived event.
del_io_sample_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.IOSampleReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.IOSampleReceived event.
del_micropython_data_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.MicroPythonDataReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.MicroPythonDataReceived event.
del_modem_status_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.ModemStatusReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.ModemStatusReceived event.
del_packet_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.PacketReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.PacketReceived event.
del_socket_data_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.SocketDataReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.SocketDataReceived event.
del_socket_data_received_from_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.SocketDataReceivedFrom event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.SocketDataReceivedFrom event.
del_socket_state_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.SocketStateReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.SocketStateReceived event.
del_user_data_relay_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.RelayDataReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.RelayDataReceived event.
disable_bluetooth()

Disables the Bluetooth interface of this XBee device.

Note that your device must have Bluetooth Low Energy support to use this method.

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
enable_apply_changes(value)

Sets the apply_changes flag.

Parameters:value (Boolean) – True to enable the apply changes flag, False to disable it.
enable_bluetooth()

Enables the Bluetooth interface of this XBee device.

To work with this interface, you must also configure the Bluetooth password if not done previously. You can use the AbstractXBeeDevice.update_bluetooth_password() method for that purpose.

Note that your device must have Bluetooth Low Energy support to use this method.

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
execute_command(parameter)

Executes the provided command.

Parameters:

parameter (String) – The name of the AT command to be executed.

Raises:
flush_queues()

Flushes the packets queue.

get_16bit_addr()

Returns the 16-bit address of the XBee device.

Returns:the 16-bit address of the XBee device.
Return type:XBee16BitAddress

See also

get_64bit_addr()

Returns the 64-bit address of the XBee device.

Returns:the 64-bit address of the XBee device.
Return type:XBee64BitAddress

See also

get_adc_value(io_line)

Returns the analog value of the provided IO line.

The provided IO line must be previously configured as ADC. To do so, use AbstractXBeeDevice.set_io_configuration() and IOMode.ADC.

Parameters:

io_line (IOLine) – the IO line to get its ADC value.

Returns:

the analog value corresponding to the provided IO line.

Return type:

Integer

Raises:

See also

get_api_output_mode()

Deprecated since version 1.3: Use get_api_output_mode_value()

Returns the API output mode of the XBee device.

The API output mode determines the format that the received data is output through the serial interface of the XBee device.

Returns:

the API output mode of the XBee device.

Return type:

APIOutputMode

Raises:

See also

get_api_output_mode_value()

Returns the API output mode of the XBee.

The API output mode determines the format that the received data is output through the serial interface of the XBee.

Returns:

the parameter value.

Return type:

Bytearray

Raises:
get_bluetooth_mac_addr()

Reads and returns the EUI-48 Bluetooth MAC address of this XBee device in a format such as 00112233AABB.

Note that your device must have Bluetooth Low Energy support to use this method.

Returns:

The Bluetooth MAC address.

Return type:

String

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
get_current_frame_id()

Returns the last used frame ID.

Returns:the last used frame ID.
Return type:Integer
get_dest_address()

Returns the 64-bit address of the XBee device that data will be reported to.

Returns:the address.
Return type:XBee64BitAddress
Raises:TimeoutException – if the response is not received before the read timeout expires.

See also

get_dio_value(io_line)

Returns the digital value of the provided IO line.

The provided IO line must be previously configured as digital I/O. To do so, use AbstractXBeeDevice.set_io_configuration().

Parameters:

io_line (IOLine) – the DIO line to gets its digital value.

Returns:

current value of the provided IO line.

Return type:

IOValue

Raises:

See also

get_firmware_version()

Returns the firmware version of the XBee device.

Returns:the hardware version of the XBee device.
Return type:Bytearray
get_hardware_version()

Returns the hardware version of the XBee device.

Returns:the hardware version of the XBee device.
Return type:HardwareVersion

See also

get_io_configuration(io_line)

Returns the configuration of the provided IO line.

Parameters:

io_line (IOLine) – the io line to configure.

Returns:

the IO mode of the IO line provided.

Return type:

IOMode

Raises:
get_io_sampling_rate()

Returns the IO sampling rate of the XBee device.

Returns:

the IO sampling rate of XBee device.

Return type:

Integer

Raises:
get_network()

Returns this XBee device’s current network.

Returns:XBeeDevice.XBeeNetwork
get_next_frame_id()

Returns the next frame ID of the XBee device.

Returns:The next frame ID of the XBee device.
Return type:Integer
get_node_id()

Returns the Node Identifier (NI) value of the XBee device.

Returns:the Node Identifier (NI) of the XBee device.
Return type:String
get_pan_id()

Returns the operating PAN ID of the XBee device.

Returns:operating PAN ID of the XBee device.
Return type:Bytearray
Raises:TimeoutException – if the response is not received before the read timeout expires.
get_parameter(param, parameter_value=None)

Override.

get_power_level()

Returns the power level of the XBee device.

Returns:the power level of the XBee device.
Return type:PowerLevel
Raises:TimeoutException – if the response is not received before the read timeout expires.

See also

get_pwm_duty_cycle(io_line)

Returns the PWM duty cycle in % corresponding to the provided IO line.

Parameters:

io_line (IOLine) – the IO line to get its PWM duty cycle.

Returns:

the PWM duty cycle of the given IO line or None if the response is empty.

Return type:

Integer

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – if the response is not as expected.
  • ValueError – if the passed IO_LINE has no PWM capability.

See also

get_role()

Gets the XBee role.

Returns:the role of the XBee.
Return type:digi.xbee.models.protocol.Role
get_sync_ops_timeout()

Returns the serial port read timeout.

Returns:the serial port read timeout in seconds.
Return type:Integer
get_xbee_device_callbacks()

Returns this XBee internal callbacks for process received packets.

This method is called by the PacketListener associated with this XBee to get its callbacks. These callbacks will be executed before user callbacks.

Returns:PacketReceived
has_explicit_packets()

Returns whether the XBee device’s queue has explicit packets or not. This do not include non-explicit packets.

Returns:True if this XBee device’s queue has explicit packets, False otherwise.
Return type:Boolean
has_packets()

Returns whether the XBee device’s queue has packets or not. This do not include explicit packets.

Returns:True if this XBee device’s queue has packets, False otherwise.
Return type:Boolean
is_apply_changes_enabled()

Returns whether the apply_changes flag is enabled or not.

Returns:True if the apply_changes flag is enabled, False otherwise.
Return type:Boolean
is_open()

Returns whether this XBee device is open or not.

Returns:Boolean. True if this XBee device is open, False otherwise.
is_remote()

Override method.

log

Returns the XBee device log.

Returns:the XBee device logger.
Return type:Logger
operating_mode

Returns this XBee device’s operating mode.

Returns:OperatingMode. This XBee device’s operating mode.
read_data(timeout=None)

Reads new data received by this XBee device.

If a timeout is specified, this method blocks until new data is received or the timeout expires, throwing in that case a TimeoutException.

Parameters:

timeout (Integer, optional) – read timeout in seconds. If it’s None, this method is non-blocking and will return None if there is no data available.

Returns:

the read message or None if this XBee did not receive new data.

Return type:

XBeeMessage

Raises:
  • ValueError – if a timeout is specified and is less than 0.
  • TimeoutException – if a timeout is specified and no data was received during that time.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – if the XBee device’s serial port is closed.

See also

read_data_from(remote_xbee_device, timeout=None)

Reads new data received from the given remote XBee device.

If a timeout is specified, this method blocks until new data is received or the timeout expires, throwing in that case a TimeoutException.

Parameters:
  • remote_xbee_device (RemoteXBeeDevice) – the remote XBee device that sent the data.
  • timeout (Integer, optional) – read timeout in seconds. If it’s None, this method is non-blocking and will return None if there is no data available.
Returns:

the read message sent by remote_xbee_device or None if this XBee did

not receive new data.

Return type:

XBeeMessage

Raises:
  • ValueError – if a timeout is specified and is less than 0.
  • TimeoutException – if a timeout is specified and no data was received during that time.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – if the XBee device’s serial port is closed.
read_device_info(init=True)

Updates all instance parameters reading them from the XBee device.

Parameters:

init (Boolean, optional, default=`True`) – If False only not initialized parameters are read, all if True.

Raises:
read_io_sample()

Returns an IO sample from the XBee device containing the value of all enabled digital IO and analog input channels.

Returns:

the IO sample read from the XBee device.

Return type:

IOSample

Raises:

See also

reset()

Override method.

send_bluetooth_data(data)

Sends the given data to the Bluetooth interface using a User Data Relay frame.

Parameters:

data (Bytearray) – Data to send.

Raises:
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – if there is any problem sending the data.
send_data(remote_xbee_device, data, transmit_options=0)

Blocking method. This method sends data to a remote XBee device synchronously.

This method will wait for the packet response.

The default timeout for this method is XBeeDevice._DEFAULT_TIMEOUT_SYNC_OPERATIONS.

Parameters:
  • remote_xbee_device (RemoteXBeeDevice) – the remote XBee device to send data to.
  • data (String or Bytearray) – the raw data to send.
  • transmit_options (Integer, optional) – transmit options, bitfield of TransmitOptions. Default to TransmitOptions.NONE.value.
Returns:

XBeePacket the response.

Raises:
  • ValueError – if remote_xbee_device is None.
  • TimeoutException – if this method can’t read a response packet in XBeeDevice._DEFAULT_TIMEOUT_SYNC_OPERATIONS seconds.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • TransmitException – if the status of the response received is not OK.
  • XBeeException – if the XBee device’s serial port is closed.
send_data_async(remote_xbee_device, data, transmit_options=0)

Non-blocking method. This method sends data to a remote XBee device.

This method won’t wait for the response.

Parameters:
  • remote_xbee_device (RemoteXBeeDevice) – the remote XBee device to send data to.
  • data (String or Bytearray) – the raw data to send.
  • transmit_options (Integer, optional) – transmit options, bitfield of TransmitOptions. Default to TransmitOptions.NONE.value.
Raises:
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – if the XBee device’s serial port is closed.

See also

send_data_broadcast(data, transmit_options=0)

Sends the provided data to all the XBee nodes of the network (broadcast).

This method blocks till a success or error transmit status arrives or the configured receive timeout expires.

The received timeout is configured using the AbstractXBeeDevice.set_sync_ops_timeout() method and can be consulted with AbstractXBeeDevice.get_sync_ops_timeout() method.

Parameters:
  • data (String or Bytearray) – data to send.
  • transmit_options (Integer, optional) – transmit options, bitfield of TransmitOptions. Default to TransmitOptions.NONE.value.
Raises:
  • TimeoutException – if this method can’t read a response packet in XBeeDevice._DEFAULT_TIMEOUT_SYNC_OPERATIONS seconds.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • TransmitException – if the status of the response received is not OK.
  • XBeeException – if the XBee device’s serial port is closed.
send_micropython_data(data)

Sends the given data to the MicroPython interface using a User Data Relay frame.

Parameters:

data (Bytearray) – Data to send.

Raises:
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – if there is any problem sending the data.
send_packet(packet, sync=False)

Override method.

See also

AbstractXBeeDevice._send_packet()
send_packet_sync_and_get_response(packet_to_send, timeout=None)

Override method.

See also

AbstractXBeeDevice._send_packet_sync_and_get_response()
send_user_data_relay(local_interface, data)

Sends the given data to the given XBee local interface.

Parameters:
  • local_interface (XBeeLocalInterface) – Destination XBee local interface.
  • data (Bytearray) – Data to send.
Raises:
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ValueError – if local_interface is None.
  • XBeeException – if there is any problem sending the User Data Relay.
serial_port

Returns the serial port associated to the XBee device, if any.

Returns:
the serial port associated to the XBee device. Returns None if the local XBee
does not use serial communication.
Return type:XBeeSerialPort

See also

set_16bit_addr(value)

Sets the 16-bit address of the XBee device.

Parameters:

value (XBee16BitAddress) – the new 16-bit address of the XBee device.

Raises:
set_api_output_mode(api_output_mode)

Deprecated since version 1.3: Use set_api_output_mode_value()

Sets the API output mode of the XBee device.

Parameters:

api_output_mode (APIOutputMode) – the new API output mode of the XBee device.

Raises:

See also

set_api_output_mode_value(api_output_mode)

Sets the API output mode of the XBee.

Parameters:

api_output_mode (Integer) – new API output mode options. Calculate this value using the method digi.xbee.models.mode.APIOutputModeBit.calculate_api_output_mode_value() with a set of digi.xbee.models.mode.APIOutputModeBit.

Raises:
set_dest_address(addr)

Sets the 64-bit address of the XBee device that data will be reported to.

Parameters:

addr (XBee64BitAddress or RemoteXBeeDevice) – the address itself or the remote XBee device that you want to set up its address as destination address.

Raises:
  • TimeoutException – If the response is not received before the read timeout expires.
  • XBeeException – If the XBee device’s serial port is closed.
  • InvalidOperatingModeException – If the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If the response is not as expected.
  • ValueError – If addr is None.
set_dio_change_detection(io_lines_set)

Sets the digital IO lines to be monitored and sampled whenever their status changes.

A None set of lines disables this feature.

Parameters:

io_lines_set – set of IOLine.

Raises:

See also

set_dio_value(io_line, io_value)

Sets the digital value (high or low) to the provided IO line.

Parameters:
  • io_line (IOLine) – the digital IO line to sets its value.
  • io_value (IOValue) – the IO value to set to the IO line.
Raises:

See also

set_io_configuration(io_line, io_mode)

Sets the configuration of the provided IO line.

Parameters:
  • io_line (IOLine) – the IO line to configure.
  • io_mode (IOMode) – the IO mode to set to the IO line.
Raises:

See also

set_io_sampling_rate(rate)

Sets the IO sampling rate of the XBee device in seconds. A sample rate of 0 means the IO sampling feature is disabled.

Parameters:

rate (Integer) – the new IO sampling rate of the XBee device in seconds.

Raises:
set_node_id(node_id)

Sets the Node Identifier (NI) value of the XBee device..

Parameters:

node_id (String) – the new Node Identifier (NI) of the XBee device.

Raises:
  • ValueError – if node_id is None or its length is greater than 20.
  • TimeoutException – if the response is not received before the read timeout expires.
set_pan_id(value)

Sets the operating PAN ID of the XBee device.

Parameters:value (Bytearray) – the new operating PAN ID of the XBee device.. Must have only 1 or 2 bytes.
Raises:TimeoutException – if the response is not received before the read timeout expires.
set_parameter(param, value)

Override.

See:
AbstractXBeeDevice.set_parameter()
set_power_level(power_level)

Sets the power level of the XBee device.

Parameters:power_level (PowerLevel) – the new power level of the XBee device.
Raises:TimeoutException – if the response is not received before the read timeout expires.

See also

set_pwm_duty_cycle(io_line, cycle)

Sets the duty cycle in % of the provided IO line.

The provided IO line must be PWM-capable, previously configured as PWM output.

Parameters:
  • io_line (IOLine) – the IO Line to be assigned.
  • cycle (Integer) – duty cycle in % to be assigned. Must be between 0 and 100.
Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – if the response is not as expected.
  • ValueError – if the given IO line does not have PWM capability or cycle is not between 0 and 100.

See also

set_sync_ops_timeout(sync_ops_timeout)

Sets the serial port read timeout.

Parameters:sync_ops_timeout (Integer) – the read timeout, expressed in seconds.
update_bluetooth_password(new_password)

Changes the password of this Bluetooth device with the new one provided.

Note that your device must have Bluetooth Low Energy support to use this method.

Parameters:

new_password (String) – New Bluetooth password.

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
update_device_data_from(device)

Updates the current device reference with the data provided for the given device.

This is only for internal use.

Parameters:device (AbstractXBeeDevice) – the XBee device to get the data from.
Returns:True if the device data has been updated, False otherwise.
Return type:Boolean
update_firmware(xml_firmware_file, xbee_firmware_file=None, bootloader_firmware_file=None, timeout=None, progress_callback=None)

Performs a firmware update operation of the device.

Parameters:
  • xml_firmware_file (String) – path of the XML file that describes the firmware to upload.
  • xbee_firmware_file (String, optional) – location of the XBee binary firmware file.
  • bootloader_firmware_file (String, optional) – location of the bootloader binary firmware file.
  • timeout (Integer, optional) – the maximum time to wait for target read operations during the update process.
  • progress_callback (Function, optional) –
    function to execute to receive progress information. Receives two
    arguments:
    • The current update task as a String
    • The current update task percentage as an Integer
Raises:
write_changes()

Writes configurable parameter values to the non-volatile memory of the XBee device so that parameter modifications persist through subsequent resets.

Parameters values remain in this device’s memory until overwritten by subsequent use of this method.

If changes are made without writing them to non-volatile memory, the module reverts back to previously saved parameters the next time the module is powered-on.

Writing the parameter modifications does not mean those values are immediately applied, this depends on the status of the ‘apply configuration changes’ option. Use method is_apply_configuration_changes_enabled() to get its status and enable_apply_configuration_changes() to enable/disable the option. If it is disabled, method apply_changes() can be used in order to manually apply the changes.

Raises:
class digi.xbee.devices.DigiPointDevice(port=None, baud_rate=None, data_bits=<sphinx.ext.autodoc.importer._MockObject object>, stop_bits=<sphinx.ext.autodoc.importer._MockObject object>, parity=<sphinx.ext.autodoc.importer._MockObject object>, flow_control=<FlowControl.NONE: None>, _sync_ops_timeout=4, comm_iface=None)[source]

Bases: digi.xbee.devices.XBeeDevice

This class represents a local DigiPoint XBee device.

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

Parameters:
  • port (Integer or String) – serial port identifier. Integer: number of XBee device, numbering starts at zero. Device name: depending on operating system. e.g. ‘/dev/ttyUSB0’ on ‘GNU/Linux’ or ‘COM3’ on Windows.
  • baud_rate (Integer) – the serial port baud rate.
  • (Integer, default (_sync_ops_timeout) – serial.EIGHTBITS): comm port bitsize.
  • (Integer, defaultserial.STOPBITS_ONE): comm port stop bits.
  • (Character, default (parity) – serial.PARITY_NONE): comm port parity.
  • (Integer, defaultFlowControl.NONE): comm port flow control.
  • (Integer, default – 3): the read timeout (in seconds).
  • comm_iface (XBeeCommunicationInterface) – the communication interface.

:raises All exceptions raised by XBeeDevice.__init__() constructor.:

See also

XBeeDevice.__init__()
open(force_settings=False)[source]

Override.

Raises:
  • TimeoutException – If there is any problem with the communication.
  • InvalidOperatingModeException – If the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – If the protocol is invalid or if the XBee device is already open.
get_protocol()[source]

Override.

send_data_64_16(x64addr, x16addr, data, transmit_options=0)[source]

Override.

See also

XBeeDevice.send_data_64_16()
send_data_async_64_16(x64addr, x16addr, data, transmit_options=0)[source]

Override.

See also

XBeeDevice.send_data_async_64_16()
read_expl_data(timeout=None)[source]

Override.

See also

XBeeDevice.read_expl_data()
read_expl_data_from(remote_xbee_device, timeout=None)[source]

Override.

See also

XBeeDevice.read_expl_data_from()
send_expl_data(remote_xbee_device, data, src_endpoint, dest_endpoint, cluster_id, profile_id, transmit_options=0)[source]

Override.

See also

XBeeDevice.send_expl_data()
send_expl_data_broadcast(data, src_endpoint, dest_endpoint, cluster_id, profile_id, transmit_options=0)[source]

Override.

See also

XBeeDevice._send_expl_data_broadcast()
send_expl_data_async(remote_xbee_device, data, src_endpoint, dest_endpoint, cluster_id, profile_id, transmit_options=0)[source]

Override.

See also

XBeeDevice.send_expl_data_async()
add_bluetooth_data_received_callback(callback)

Adds a callback for the event digi.xbee.reader.BluetoothDataReceived.

Parameters:callback (Function) –

the callback. Receives one argument.

  • The Bluetooth data as a Bytearray
add_data_received_callback(callback)

Adds a callback for the event digi.xbee.reader.DataReceived.

Parameters:callback (Function) –

the callback. Receives one argument.

add_expl_data_received_callback(callback)

Adds a callback for the event digi.xbee.reader.ExplicitDataReceived.

Parameters:callback (Function) –

the callback. Receives one argument.

add_io_sample_received_callback(callback)

Adds a callback for the event digi.xbee.reader.IOSampleReceived.

Parameters:callback (Function) –

the callback. Receives three arguments.

add_micropython_data_received_callback(callback)

Adds a callback for the event digi.xbee.reader.MicroPythonDataReceived.

Parameters:callback (Function) –

the callback. Receives one argument.

  • The MicroPython data as a Bytearray
add_modem_status_received_callback(callback)

Adds a callback for the event digi.xbee.reader.ModemStatusReceived.

Parameters:callback (Function) –

the callback. Receives one argument.

add_packet_received_callback(callback)

Adds a callback for the event digi.xbee.reader.PacketReceived.

Parameters:callback (Function) –

the callback. Receives two arguments.

add_socket_data_received_callback(callback)

Adds a callback for the event digi.xbee.reader.SocketDataReceived.

Parameters:callback (Function) –

the callback. Receives two arguments.

  • The socket ID as an Integer.
  • The data received as Bytearray
add_socket_data_received_from_callback(callback)

Adds a callback for the event digi.xbee.reader.SocketDataReceivedFrom.

Parameters:callback (Function) –

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 data received as Bytearray
add_socket_state_received_callback(callback)

Adds a callback for the event digi.xbee.reader.SocketStateReceived.

Parameters:callback (Function) –

the callback. Receives two arguments.

  • The socket ID as an Integer.
  • The state received as a SocketState
add_user_data_relay_received_callback(callback)

Adds a callback for the event digi.xbee.reader.RelayDataReceived.

Parameters:callback (Function) –

the callback. Receives one argument.

apply_changes()

Applies changes via AC command.

Raises:
apply_profile(profile_path, progress_callback=None)

Applies the given XBee profile to the XBee device.

Parameters:
  • profile_path (String) – path of the XBee profile file to apply.
  • progress_callback (Function, optional) –
    function to execute to receive progress information. Receives two
    arguments:
    • The current apply profile task as a String
    • The current apply profile task percentage as an Integer
Raises:
close()

Closes the communication with the XBee device.

This method guarantees that all threads running are stopped and the serial port is closed.

comm_iface

Returns the hardware interface associated to the XBee device.

Returns:the hardware interface associated to the XBee device.
Return type:XBeeCommunicationInterface

See also

classmethod create_xbee_device(comm_port_data)

Creates and returns an XBeeDevice from data of the port to which is connected.

Parameters:
  • comm_port_data (Dictionary) – dictionary with all comm port data needed.
  • dictionary keys are (The) –
    “baudRate” –> Baud rate.
    ”port” –> Port number.
    ”bitSize” –> Bit size.
    ”stopBits” –> Stop bits.
    ”parity” –> Parity.
    ”flowControl” –> Flow control.
    ”timeout” for –> Timeout for synchronous operations (in seconds).
Returns:

the XBee device created.

Return type:

XBeeDevice

Raises:

SerialException – if the port you want to open does not exist or is already opened.

See also

del_bluetooth_data_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.BluetoothDataReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.BluetoothDataReceived event.
del_data_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.DataReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.DataReceived event.
del_expl_data_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.ExplicitDataReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.ExplicitDataReceived event.
del_io_sample_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.IOSampleReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.IOSampleReceived event.
del_micropython_data_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.MicroPythonDataReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.MicroPythonDataReceived event.
del_modem_status_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.ModemStatusReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.ModemStatusReceived event.
del_packet_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.PacketReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.PacketReceived event.
del_socket_data_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.SocketDataReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.SocketDataReceived event.
del_socket_data_received_from_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.SocketDataReceivedFrom event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.SocketDataReceivedFrom event.
del_socket_state_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.SocketStateReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.SocketStateReceived event.
del_user_data_relay_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.RelayDataReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.RelayDataReceived event.
disable_bluetooth()

Disables the Bluetooth interface of this XBee device.

Note that your device must have Bluetooth Low Energy support to use this method.

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
enable_apply_changes(value)

Sets the apply_changes flag.

Parameters:value (Boolean) – True to enable the apply changes flag, False to disable it.
enable_bluetooth()

Enables the Bluetooth interface of this XBee device.

To work with this interface, you must also configure the Bluetooth password if not done previously. You can use the AbstractXBeeDevice.update_bluetooth_password() method for that purpose.

Note that your device must have Bluetooth Low Energy support to use this method.

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
execute_command(parameter)

Executes the provided command.

Parameters:

parameter (String) – The name of the AT command to be executed.

Raises:
flush_queues()

Flushes the packets queue.

get_16bit_addr()

Returns the 16-bit address of the XBee device.

Returns:the 16-bit address of the XBee device.
Return type:XBee16BitAddress

See also

get_64bit_addr()

Returns the 64-bit address of the XBee device.

Returns:the 64-bit address of the XBee device.
Return type:XBee64BitAddress

See also

get_adc_value(io_line)

Returns the analog value of the provided IO line.

The provided IO line must be previously configured as ADC. To do so, use AbstractXBeeDevice.set_io_configuration() and IOMode.ADC.

Parameters:

io_line (IOLine) – the IO line to get its ADC value.

Returns:

the analog value corresponding to the provided IO line.

Return type:

Integer

Raises:

See also

get_api_output_mode()

Deprecated since version 1.3: Use get_api_output_mode_value()

Returns the API output mode of the XBee device.

The API output mode determines the format that the received data is output through the serial interface of the XBee device.

Returns:

the API output mode of the XBee device.

Return type:

APIOutputMode

Raises:

See also

get_api_output_mode_value()

Returns the API output mode of the XBee.

The API output mode determines the format that the received data is output through the serial interface of the XBee.

Returns:

the parameter value.

Return type:

Bytearray

Raises:
get_bluetooth_mac_addr()

Reads and returns the EUI-48 Bluetooth MAC address of this XBee device in a format such as 00112233AABB.

Note that your device must have Bluetooth Low Energy support to use this method.

Returns:

The Bluetooth MAC address.

Return type:

String

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
get_current_frame_id()

Returns the last used frame ID.

Returns:the last used frame ID.
Return type:Integer
get_dest_address()

Returns the 64-bit address of the XBee device that data will be reported to.

Returns:the address.
Return type:XBee64BitAddress
Raises:TimeoutException – if the response is not received before the read timeout expires.

See also

get_dio_value(io_line)

Returns the digital value of the provided IO line.

The provided IO line must be previously configured as digital I/O. To do so, use AbstractXBeeDevice.set_io_configuration().

Parameters:

io_line (IOLine) – the DIO line to gets its digital value.

Returns:

current value of the provided IO line.

Return type:

IOValue

Raises:

See also

get_firmware_version()

Returns the firmware version of the XBee device.

Returns:the hardware version of the XBee device.
Return type:Bytearray
get_hardware_version()

Returns the hardware version of the XBee device.

Returns:the hardware version of the XBee device.
Return type:HardwareVersion

See also

get_io_configuration(io_line)

Returns the configuration of the provided IO line.

Parameters:

io_line (IOLine) – the io line to configure.

Returns:

the IO mode of the IO line provided.

Return type:

IOMode

Raises:
get_io_sampling_rate()

Returns the IO sampling rate of the XBee device.

Returns:

the IO sampling rate of XBee device.

Return type:

Integer

Raises:
get_network()

Returns this XBee device’s current network.

Returns:XBeeDevice.XBeeNetwork
get_next_frame_id()

Returns the next frame ID of the XBee device.

Returns:The next frame ID of the XBee device.
Return type:Integer
get_node_id()

Returns the Node Identifier (NI) value of the XBee device.

Returns:the Node Identifier (NI) of the XBee device.
Return type:String
get_pan_id()

Returns the operating PAN ID of the XBee device.

Returns:operating PAN ID of the XBee device.
Return type:Bytearray
Raises:TimeoutException – if the response is not received before the read timeout expires.
get_parameter(param, parameter_value=None)

Override.

get_power_level()

Returns the power level of the XBee device.

Returns:the power level of the XBee device.
Return type:PowerLevel
Raises:TimeoutException – if the response is not received before the read timeout expires.

See also

get_pwm_duty_cycle(io_line)

Returns the PWM duty cycle in % corresponding to the provided IO line.

Parameters:

io_line (IOLine) – the IO line to get its PWM duty cycle.

Returns:

the PWM duty cycle of the given IO line or None if the response is empty.

Return type:

Integer

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – if the response is not as expected.
  • ValueError – if the passed IO_LINE has no PWM capability.

See also

get_role()

Gets the XBee role.

Returns:the role of the XBee.
Return type:digi.xbee.models.protocol.Role
get_sync_ops_timeout()

Returns the serial port read timeout.

Returns:the serial port read timeout in seconds.
Return type:Integer
get_xbee_device_callbacks()

Returns this XBee internal callbacks for process received packets.

This method is called by the PacketListener associated with this XBee to get its callbacks. These callbacks will be executed before user callbacks.

Returns:PacketReceived
has_explicit_packets()

Returns whether the XBee device’s queue has explicit packets or not. This do not include non-explicit packets.

Returns:True if this XBee device’s queue has explicit packets, False otherwise.
Return type:Boolean
has_packets()

Returns whether the XBee device’s queue has packets or not. This do not include explicit packets.

Returns:True if this XBee device’s queue has packets, False otherwise.
Return type:Boolean
is_apply_changes_enabled()

Returns whether the apply_changes flag is enabled or not.

Returns:True if the apply_changes flag is enabled, False otherwise.
Return type:Boolean
is_open()

Returns whether this XBee device is open or not.

Returns:Boolean. True if this XBee device is open, False otherwise.
is_remote()

Override method.

log

Returns the XBee device log.

Returns:the XBee device logger.
Return type:Logger
operating_mode

Returns this XBee device’s operating mode.

Returns:OperatingMode. This XBee device’s operating mode.
read_data(timeout=None)

Reads new data received by this XBee device.

If a timeout is specified, this method blocks until new data is received or the timeout expires, throwing in that case a TimeoutException.

Parameters:

timeout (Integer, optional) – read timeout in seconds. If it’s None, this method is non-blocking and will return None if there is no data available.

Returns:

the read message or None if this XBee did not receive new data.

Return type:

XBeeMessage

Raises:
  • ValueError – if a timeout is specified and is less than 0.
  • TimeoutException – if a timeout is specified and no data was received during that time.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – if the XBee device’s serial port is closed.

See also

read_data_from(remote_xbee_device, timeout=None)

Reads new data received from the given remote XBee device.

If a timeout is specified, this method blocks until new data is received or the timeout expires, throwing in that case a TimeoutException.

Parameters:
  • remote_xbee_device (RemoteXBeeDevice) – the remote XBee device that sent the data.
  • timeout (Integer, optional) – read timeout in seconds. If it’s None, this method is non-blocking and will return None if there is no data available.
Returns:

the read message sent by remote_xbee_device or None if this XBee did

not receive new data.

Return type:

XBeeMessage

Raises:
  • ValueError – if a timeout is specified and is less than 0.
  • TimeoutException – if a timeout is specified and no data was received during that time.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – if the XBee device’s serial port is closed.
read_device_info(init=True)

Updates all instance parameters reading them from the XBee device.

Parameters:

init (Boolean, optional, default=`True`) – If False only not initialized parameters are read, all if True.

Raises:
read_io_sample()

Returns an IO sample from the XBee device containing the value of all enabled digital IO and analog input channels.

Returns:

the IO sample read from the XBee device.

Return type:

IOSample

Raises:

See also

reset()

Override method.

send_bluetooth_data(data)

Sends the given data to the Bluetooth interface using a User Data Relay frame.

Parameters:

data (Bytearray) – Data to send.

Raises:
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – if there is any problem sending the data.
send_data(remote_xbee_device, data, transmit_options=0)

Blocking method. This method sends data to a remote XBee device synchronously.

This method will wait for the packet response.

The default timeout for this method is XBeeDevice._DEFAULT_TIMEOUT_SYNC_OPERATIONS.

Parameters:
  • remote_xbee_device (RemoteXBeeDevice) – the remote XBee device to send data to.
  • data (String or Bytearray) – the raw data to send.
  • transmit_options (Integer, optional) – transmit options, bitfield of TransmitOptions. Default to TransmitOptions.NONE.value.
Returns:

XBeePacket the response.

Raises:
  • ValueError – if remote_xbee_device is None.
  • TimeoutException – if this method can’t read a response packet in XBeeDevice._DEFAULT_TIMEOUT_SYNC_OPERATIONS seconds.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • TransmitException – if the status of the response received is not OK.
  • XBeeException – if the XBee device’s serial port is closed.
send_data_async(remote_xbee_device, data, transmit_options=0)

Non-blocking method. This method sends data to a remote XBee device.

This method won’t wait for the response.

Parameters:
  • remote_xbee_device (RemoteXBeeDevice) – the remote XBee device to send data to.
  • data (String or Bytearray) – the raw data to send.
  • transmit_options (Integer, optional) – transmit options, bitfield of TransmitOptions. Default to TransmitOptions.NONE.value.
Raises:
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – if the XBee device’s serial port is closed.

See also

send_data_broadcast(data, transmit_options=0)

Sends the provided data to all the XBee nodes of the network (broadcast).

This method blocks till a success or error transmit status arrives or the configured receive timeout expires.

The received timeout is configured using the AbstractXBeeDevice.set_sync_ops_timeout() method and can be consulted with AbstractXBeeDevice.get_sync_ops_timeout() method.

Parameters:
  • data (String or Bytearray) – data to send.
  • transmit_options (Integer, optional) – transmit options, bitfield of TransmitOptions. Default to TransmitOptions.NONE.value.
Raises:
  • TimeoutException – if this method can’t read a response packet in XBeeDevice._DEFAULT_TIMEOUT_SYNC_OPERATIONS seconds.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • TransmitException – if the status of the response received is not OK.
  • XBeeException – if the XBee device’s serial port is closed.
send_micropython_data(data)

Sends the given data to the MicroPython interface using a User Data Relay frame.

Parameters:

data (Bytearray) – Data to send.

Raises:
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – if there is any problem sending the data.
send_packet(packet, sync=False)

Override method.

See also

AbstractXBeeDevice._send_packet()
send_packet_sync_and_get_response(packet_to_send, timeout=None)

Override method.

See also

AbstractXBeeDevice._send_packet_sync_and_get_response()
send_user_data_relay(local_interface, data)

Sends the given data to the given XBee local interface.

Parameters:
  • local_interface (XBeeLocalInterface) – Destination XBee local interface.
  • data (Bytearray) – Data to send.
Raises:
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ValueError – if local_interface is None.
  • XBeeException – if there is any problem sending the User Data Relay.
serial_port

Returns the serial port associated to the XBee device, if any.

Returns:
the serial port associated to the XBee device. Returns None if the local XBee
does not use serial communication.
Return type:XBeeSerialPort

See also

set_16bit_addr(value)

Sets the 16-bit address of the XBee device.

Parameters:

value (XBee16BitAddress) – the new 16-bit address of the XBee device.

Raises:
set_api_output_mode(api_output_mode)

Deprecated since version 1.3: Use set_api_output_mode_value()

Sets the API output mode of the XBee device.

Parameters:

api_output_mode (APIOutputMode) – the new API output mode of the XBee device.

Raises:

See also

set_api_output_mode_value(api_output_mode)

Sets the API output mode of the XBee.

Parameters:

api_output_mode (Integer) – new API output mode options. Calculate this value using the method digi.xbee.models.mode.APIOutputModeBit.calculate_api_output_mode_value() with a set of digi.xbee.models.mode.APIOutputModeBit.

Raises:
set_dest_address(addr)

Sets the 64-bit address of the XBee device that data will be reported to.

Parameters:

addr (XBee64BitAddress or RemoteXBeeDevice) – the address itself or the remote XBee device that you want to set up its address as destination address.

Raises:
  • TimeoutException – If the response is not received before the read timeout expires.
  • XBeeException – If the XBee device’s serial port is closed.
  • InvalidOperatingModeException – If the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If the response is not as expected.
  • ValueError – If addr is None.
set_dio_change_detection(io_lines_set)

Sets the digital IO lines to be monitored and sampled whenever their status changes.

A None set of lines disables this feature.

Parameters:

io_lines_set – set of IOLine.

Raises:

See also

set_dio_value(io_line, io_value)

Sets the digital value (high or low) to the provided IO line.

Parameters:
  • io_line (IOLine) – the digital IO line to sets its value.
  • io_value (IOValue) – the IO value to set to the IO line.
Raises:

See also

set_io_configuration(io_line, io_mode)

Sets the configuration of the provided IO line.

Parameters:
  • io_line (IOLine) – the IO line to configure.
  • io_mode (IOMode) – the IO mode to set to the IO line.
Raises:

See also

set_io_sampling_rate(rate)

Sets the IO sampling rate of the XBee device in seconds. A sample rate of 0 means the IO sampling feature is disabled.

Parameters:

rate (Integer) – the new IO sampling rate of the XBee device in seconds.

Raises:
set_node_id(node_id)

Sets the Node Identifier (NI) value of the XBee device..

Parameters:

node_id (String) – the new Node Identifier (NI) of the XBee device.

Raises:
  • ValueError – if node_id is None or its length is greater than 20.
  • TimeoutException – if the response is not received before the read timeout expires.
set_pan_id(value)

Sets the operating PAN ID of the XBee device.

Parameters:value (Bytearray) – the new operating PAN ID of the XBee device.. Must have only 1 or 2 bytes.
Raises:TimeoutException – if the response is not received before the read timeout expires.
set_parameter(param, value)

Override.

See:
AbstractXBeeDevice.set_parameter()
set_power_level(power_level)

Sets the power level of the XBee device.

Parameters:power_level (PowerLevel) – the new power level of the XBee device.
Raises:TimeoutException – if the response is not received before the read timeout expires.

See also

set_pwm_duty_cycle(io_line, cycle)

Sets the duty cycle in % of the provided IO line.

The provided IO line must be PWM-capable, previously configured as PWM output.

Parameters:
  • io_line (IOLine) – the IO Line to be assigned.
  • cycle (Integer) – duty cycle in % to be assigned. Must be between 0 and 100.
Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – if the response is not as expected.
  • ValueError – if the given IO line does not have PWM capability or cycle is not between 0 and 100.

See also

set_sync_ops_timeout(sync_ops_timeout)

Sets the serial port read timeout.

Parameters:sync_ops_timeout (Integer) – the read timeout, expressed in seconds.
update_bluetooth_password(new_password)

Changes the password of this Bluetooth device with the new one provided.

Note that your device must have Bluetooth Low Energy support to use this method.

Parameters:

new_password (String) – New Bluetooth password.

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
update_device_data_from(device)

Updates the current device reference with the data provided for the given device.

This is only for internal use.

Parameters:device (AbstractXBeeDevice) – the XBee device to get the data from.
Returns:True if the device data has been updated, False otherwise.
Return type:Boolean
update_firmware(xml_firmware_file, xbee_firmware_file=None, bootloader_firmware_file=None, timeout=None, progress_callback=None)

Performs a firmware update operation of the device.

Parameters:
  • xml_firmware_file (String) – path of the XML file that describes the firmware to upload.
  • xbee_firmware_file (String, optional) – location of the XBee binary firmware file.
  • bootloader_firmware_file (String, optional) – location of the bootloader binary firmware file.
  • timeout (Integer, optional) – the maximum time to wait for target read operations during the update process.
  • progress_callback (Function, optional) –
    function to execute to receive progress information. Receives two
    arguments:
    • The current update task as a String
    • The current update task percentage as an Integer
Raises:
write_changes()

Writes configurable parameter values to the non-volatile memory of the XBee device so that parameter modifications persist through subsequent resets.

Parameters values remain in this device’s memory until overwritten by subsequent use of this method.

If changes are made without writing them to non-volatile memory, the module reverts back to previously saved parameters the next time the module is powered-on.

Writing the parameter modifications does not mean those values are immediately applied, this depends on the status of the ‘apply configuration changes’ option. Use method is_apply_configuration_changes_enabled() to get its status and enable_apply_configuration_changes() to enable/disable the option. If it is disabled, method apply_changes() can be used in order to manually apply the changes.

Raises:
class digi.xbee.devices.ZigBeeDevice(port=None, baud_rate=None, data_bits=<sphinx.ext.autodoc.importer._MockObject object>, stop_bits=<sphinx.ext.autodoc.importer._MockObject object>, parity=<sphinx.ext.autodoc.importer._MockObject object>, flow_control=<FlowControl.NONE: None>, _sync_ops_timeout=4, comm_iface=None)[source]

Bases: digi.xbee.devices.XBeeDevice

This class represents a local ZigBee XBee device.

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

Parameters:
  • port (Integer or String) – serial port identifier. Integer: number of XBee device, numbering starts at zero. Device name: depending on operating system. e.g. ‘/dev/ttyUSB0’ on ‘GNU/Linux’ or ‘COM3’ on Windows.
  • baud_rate (Integer) – the serial port baud rate.
  • (Integer, default (flow_control) – serial.EIGHTBITS): comm port bitsize.
  • (Integer, defaultserial.STOPBITS_ONE): comm port stop bits.
  • (Character, default (parity) – serial.PARITY_NONE): comm port parity.
  • (Integer, default

    FlowControl.NONE): comm port flow control.

    _sync_ops_timeout (Integer, default: 3): the read timeout (in seconds).
    comm_iface (XBeeCommunicationInterface): the communication interface.

:raises All exceptions raised by XBeeDevice.__init__() constructor.:

See also

XBeeDevice.__init__()
open(force_settings=False)[source]

Override.

Raises:
  • TimeoutException – If there is any problem with the communication.
  • InvalidOperatingModeException – If the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – If the protocol is invalid or if the XBee device is already open.
get_protocol()[source]

Override.

get_ai_status()[source]

Override.

See also

AbstractXBeeDevice._get_ai_status()
force_disassociate()[source]

Override.

See also

AbstractXBeeDevice._force_disassociate()
send_data_64_16(x64addr, x16addr, data, transmit_options=0)[source]

Override.

See also

XBeeDevice.send_data_64_16()
send_data_async_64_16(x64addr, x16addr, data, transmit_options=0)[source]

Override.

See also

XBeeDevice.send_data_async_64_16()
read_expl_data(timeout=None)[source]

Override.

See also

XBeeDevice._read_expl_data()
read_expl_data_from(remote_xbee_device, timeout=None)[source]

Override.

See also

XBeeDevice._read_expl_data_from()
send_expl_data(remote_xbee_device, data, src_endpoint, dest_endpoint, cluster_id, profile_id, transmit_options=0)[source]

Override.

See also

XBeeDevice._send_expl_data()
send_expl_data_broadcast(data, src_endpoint, dest_endpoint, cluster_id, profile_id, transmit_options=0)[source]

Override.

See also

XBeeDevice._send_expl_data_broadcast()
send_expl_data_async(remote_xbee_device, data, src_endpoint, dest_endpoint, cluster_id, profile_id, transmit_options=0)[source]

Override.

See also

XBeeDevice.send_expl_data_async()
send_multicast_data(group_id, data, src_endpoint, dest_endpoint, cluster_id, profile_id)[source]

Blocking method. This method sends multicast data to the provided group ID synchronously.

This method will wait for the packet response.

The default timeout for this method is XBeeDevice._DEFAULT_TIMEOUT_SYNC_OPERATIONS.

Parameters:
  • group_id (XBee16BitAddress) – the 16 bit address of the multicast group.
  • data (Bytearray) – the raw data to send.
  • src_endpoint (Integer) – source endpoint of the transmission. 1 byte.
  • dest_endpoint (Integer) – destination endpoint of the transmission. 1 byte.
  • cluster_id (Integer) – Cluster ID of the transmission. Must be between 0x0 and 0xFFFF.
  • profile_id (Integer) – Profile ID of the transmission. Must be between 0x0 and 0xFFFF.
Returns:

the response packet.

Return type:

XBeePacket

Raises:
  • TimeoutException – if this method can’t read a response packet in XBeeDevice._DEFAULT_TIMEOUT_SYNC_OPERATIONS seconds.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – if the XBee device’s serial port is closed.
  • XBeeException – if the status of the response received is not OK.

See also

XBee16BitAddress
XBeePacket
send_multicast_data_async(group_id, data, src_endpoint, dest_endpoint, cluster_id, profile_id)[source]

Non-blocking method. This method sends multicast data to the provided group ID.

This method won’t wait for the response.

Parameters:
  • group_id (XBee16BitAddress) – the 16 bit address of the multicast group.
  • data (Bytearray) – the raw data to send.
  • src_endpoint (Integer) – source endpoint of the transmission. 1 byte.
  • dest_endpoint (Integer) – destination endpoint of the transmission. 1 byte.
  • cluster_id (Integer) – Cluster ID of the transmission. Must be between 0x0 and 0xFFFF.
  • profile_id (Integer) – Profile ID of the transmission. Must be between 0x0 and 0xFFFF.
Raises:
  • TimeoutException – if this method can’t read a response packet in XBeeDevice._DEFAULT_TIMEOUT_SYNC_OPERATIONS seconds.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – if the XBee device’s serial port is closed.

See also

XBee16BitAddress
register_joining_device(registrant_address, options, key)[source]

Securely registers a joining device to a trust center. Registration is the process by which a node is authorized to join the network using a preconfigured link key or installation code that is conveyed to the trust center out-of-band (using a physical interface and not over-the-air).

This method is synchronous, it sends the register joining device packet and waits for the answer of the operation. Then, returns the corresponding status.

Parameters:
  • registrant_address (XBee64BitAddress) – the 64-bit address of the device to register.
  • options (RegisterKeyOptions) – the register options indicating the key source.
  • key (Bytearray) – key of the device to register.
Returns:

the register device operation status or None if the answer

received is not a RegisterDeviceStatusPacket.

Return type:

ZigbeeRegisterStatus

Raises:
  • TimeoutException – if the answer is not received in the configured timeout.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – if the XBee device’s serial port is closed.
  • ValueError – if registrant_address is None or if options is None.

See also

RegisterKeyOptions
XBee64BitAddress
ZigbeeRegisterStatus
register_joining_device_async(registrant_address, options, key)[source]

Securely registers a joining device to a trust center. Registration is the process by which a node is authorized to join the network using a preconfigured link key or installation code that is conveyed to the trust center out-of-band (using a physical interface and not over-the-air).

This method is asynchronous, which means that it will not wait for an answer after sending the register frame.

Parameters:
  • registrant_address (XBee64BitAddress) – the 64-bit address of the device to register.
  • options (RegisterKeyOptions) – the register options indicating the key source.
  • key (Bytearray) – key of the device to register.
Raises:
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – if the XBee device’s serial port is closed.
  • ValueError – if registrant_address is None or if options is None.

See also

RegisterKeyOptions
XBee64BitAddress
unregister_joining_device(unregistrant_address)[source]

Unregisters a joining device from a trust center.

This method is synchronous, it sends the unregister joining device packet and waits for the answer of the operation. Then, returns the corresponding status.

Parameters:

unregistrant_address (XBee64BitAddress) – the 64-bit address of the device to unregister.

Returns:

the unregister device operation status or None if the answer

received is not a RegisterDeviceStatusPacket.

Return type:

ZigbeeRegisterStatus

Raises:
  • TimeoutException – if the answer is not received in the configured timeout.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – if the XBee device’s serial port is closed.
  • ValueError – if registrant_address is None.

See also

XBee64BitAddress
ZigbeeRegisterStatus
unregister_joining_device_async(unregistrant_address)[source]

Unregisters a joining device from a trust center.

This method is asynchronous, which means that it will not wait for an answer after sending the uregister frame.

Parameters:

unregistrant_address (XBee64BitAddress) – the 64-bit address of the device to unregister.

Raises:
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – if the XBee device’s serial port is closed.
  • ValueError – if registrant_address is None.

See also

XBee64BitAddress
add_bluetooth_data_received_callback(callback)

Adds a callback for the event digi.xbee.reader.BluetoothDataReceived.

Parameters:callback (Function) –

the callback. Receives one argument.

  • The Bluetooth data as a Bytearray
add_data_received_callback(callback)

Adds a callback for the event digi.xbee.reader.DataReceived.

Parameters:callback (Function) –

the callback. Receives one argument.

add_expl_data_received_callback(callback)

Adds a callback for the event digi.xbee.reader.ExplicitDataReceived.

Parameters:callback (Function) –

the callback. Receives one argument.

add_io_sample_received_callback(callback)

Adds a callback for the event digi.xbee.reader.IOSampleReceived.

Parameters:callback (Function) –

the callback. Receives three arguments.

add_micropython_data_received_callback(callback)

Adds a callback for the event digi.xbee.reader.MicroPythonDataReceived.

Parameters:callback (Function) –

the callback. Receives one argument.

  • The MicroPython data as a Bytearray
add_modem_status_received_callback(callback)

Adds a callback for the event digi.xbee.reader.ModemStatusReceived.

Parameters:callback (Function) –

the callback. Receives one argument.

add_packet_received_callback(callback)

Adds a callback for the event digi.xbee.reader.PacketReceived.

Parameters:callback (Function) –

the callback. Receives two arguments.

add_socket_data_received_callback(callback)

Adds a callback for the event digi.xbee.reader.SocketDataReceived.

Parameters:callback (Function) –

the callback. Receives two arguments.

  • The socket ID as an Integer.
  • The data received as Bytearray
add_socket_data_received_from_callback(callback)

Adds a callback for the event digi.xbee.reader.SocketDataReceivedFrom.

Parameters:callback (Function) –

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 data received as Bytearray
add_socket_state_received_callback(callback)

Adds a callback for the event digi.xbee.reader.SocketStateReceived.

Parameters:callback (Function) –

the callback. Receives two arguments.

  • The socket ID as an Integer.
  • The state received as a SocketState
add_user_data_relay_received_callback(callback)

Adds a callback for the event digi.xbee.reader.RelayDataReceived.

Parameters:callback (Function) –

the callback. Receives one argument.

apply_changes()

Applies changes via AC command.

Raises:
apply_profile(profile_path, progress_callback=None)

Applies the given XBee profile to the XBee device.

Parameters:
  • profile_path (String) – path of the XBee profile file to apply.
  • progress_callback (Function, optional) –
    function to execute to receive progress information. Receives two
    arguments:
    • The current apply profile task as a String
    • The current apply profile task percentage as an Integer
Raises:
close()

Closes the communication with the XBee device.

This method guarantees that all threads running are stopped and the serial port is closed.

comm_iface

Returns the hardware interface associated to the XBee device.

Returns:the hardware interface associated to the XBee device.
Return type:XBeeCommunicationInterface

See also

classmethod create_xbee_device(comm_port_data)

Creates and returns an XBeeDevice from data of the port to which is connected.

Parameters:
  • comm_port_data (Dictionary) – dictionary with all comm port data needed.
  • dictionary keys are (The) –
    “baudRate” –> Baud rate.
    ”port” –> Port number.
    ”bitSize” –> Bit size.
    ”stopBits” –> Stop bits.
    ”parity” –> Parity.
    ”flowControl” –> Flow control.
    ”timeout” for –> Timeout for synchronous operations (in seconds).
Returns:

the XBee device created.

Return type:

XBeeDevice

Raises:

SerialException – if the port you want to open does not exist or is already opened.

See also

del_bluetooth_data_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.BluetoothDataReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.BluetoothDataReceived event.
del_data_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.DataReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.DataReceived event.
del_expl_data_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.ExplicitDataReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.ExplicitDataReceived event.
del_io_sample_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.IOSampleReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.IOSampleReceived event.
del_micropython_data_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.MicroPythonDataReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.MicroPythonDataReceived event.
del_modem_status_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.ModemStatusReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.ModemStatusReceived event.
del_packet_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.PacketReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.PacketReceived event.
del_socket_data_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.SocketDataReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.SocketDataReceived event.
del_socket_data_received_from_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.SocketDataReceivedFrom event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.SocketDataReceivedFrom event.
del_socket_state_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.SocketStateReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.SocketStateReceived event.
del_user_data_relay_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.RelayDataReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.RelayDataReceived event.
disable_bluetooth()

Disables the Bluetooth interface of this XBee device.

Note that your device must have Bluetooth Low Energy support to use this method.

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
enable_apply_changes(value)

Sets the apply_changes flag.

Parameters:value (Boolean) – True to enable the apply changes flag, False to disable it.
enable_bluetooth()

Enables the Bluetooth interface of this XBee device.

To work with this interface, you must also configure the Bluetooth password if not done previously. You can use the AbstractXBeeDevice.update_bluetooth_password() method for that purpose.

Note that your device must have Bluetooth Low Energy support to use this method.

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
execute_command(parameter)

Executes the provided command.

Parameters:

parameter (String) – The name of the AT command to be executed.

Raises:
flush_queues()

Flushes the packets queue.

get_16bit_addr()

Returns the 16-bit address of the XBee device.

Returns:the 16-bit address of the XBee device.
Return type:XBee16BitAddress

See also

get_64bit_addr()

Returns the 64-bit address of the XBee device.

Returns:the 64-bit address of the XBee device.
Return type:XBee64BitAddress

See also

get_adc_value(io_line)

Returns the analog value of the provided IO line.

The provided IO line must be previously configured as ADC. To do so, use AbstractXBeeDevice.set_io_configuration() and IOMode.ADC.

Parameters:

io_line (IOLine) – the IO line to get its ADC value.

Returns:

the analog value corresponding to the provided IO line.

Return type:

Integer

Raises:

See also

get_api_output_mode()

Deprecated since version 1.3: Use get_api_output_mode_value()

Returns the API output mode of the XBee device.

The API output mode determines the format that the received data is output through the serial interface of the XBee device.

Returns:

the API output mode of the XBee device.

Return type:

APIOutputMode

Raises:

See also

get_api_output_mode_value()

Returns the API output mode of the XBee.

The API output mode determines the format that the received data is output through the serial interface of the XBee.

Returns:

the parameter value.

Return type:

Bytearray

Raises:
get_bluetooth_mac_addr()

Reads and returns the EUI-48 Bluetooth MAC address of this XBee device in a format such as 00112233AABB.

Note that your device must have Bluetooth Low Energy support to use this method.

Returns:

The Bluetooth MAC address.

Return type:

String

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
get_current_frame_id()

Returns the last used frame ID.

Returns:the last used frame ID.
Return type:Integer
get_dest_address()

Returns the 64-bit address of the XBee device that data will be reported to.

Returns:the address.
Return type:XBee64BitAddress
Raises:TimeoutException – if the response is not received before the read timeout expires.

See also

get_dio_value(io_line)

Returns the digital value of the provided IO line.

The provided IO line must be previously configured as digital I/O. To do so, use AbstractXBeeDevice.set_io_configuration().

Parameters:

io_line (IOLine) – the DIO line to gets its digital value.

Returns:

current value of the provided IO line.

Return type:

IOValue

Raises:

See also

get_firmware_version()

Returns the firmware version of the XBee device.

Returns:the hardware version of the XBee device.
Return type:Bytearray
get_hardware_version()

Returns the hardware version of the XBee device.

Returns:the hardware version of the XBee device.
Return type:HardwareVersion

See also

get_io_configuration(io_line)

Returns the configuration of the provided IO line.

Parameters:

io_line (IOLine) – the io line to configure.

Returns:

the IO mode of the IO line provided.

Return type:

IOMode

Raises:
get_io_sampling_rate()

Returns the IO sampling rate of the XBee device.

Returns:

the IO sampling rate of XBee device.

Return type:

Integer

Raises:
get_network()

Returns this XBee device’s current network.

Returns:XBeeDevice.XBeeNetwork
get_next_frame_id()

Returns the next frame ID of the XBee device.

Returns:The next frame ID of the XBee device.
Return type:Integer
get_node_id()

Returns the Node Identifier (NI) value of the XBee device.

Returns:the Node Identifier (NI) of the XBee device.
Return type:String
get_pan_id()

Returns the operating PAN ID of the XBee device.

Returns:operating PAN ID of the XBee device.
Return type:Bytearray
Raises:TimeoutException – if the response is not received before the read timeout expires.
get_parameter(param, parameter_value=None)

Override.

get_power_level()

Returns the power level of the XBee device.

Returns:the power level of the XBee device.
Return type:PowerLevel
Raises:TimeoutException – if the response is not received before the read timeout expires.

See also

get_pwm_duty_cycle(io_line)

Returns the PWM duty cycle in % corresponding to the provided IO line.

Parameters:

io_line (IOLine) – the IO line to get its PWM duty cycle.

Returns:

the PWM duty cycle of the given IO line or None if the response is empty.

Return type:

Integer

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – if the response is not as expected.
  • ValueError – if the passed IO_LINE has no PWM capability.

See also

get_role()

Gets the XBee role.

Returns:the role of the XBee.
Return type:digi.xbee.models.protocol.Role
get_sync_ops_timeout()

Returns the serial port read timeout.

Returns:the serial port read timeout in seconds.
Return type:Integer
get_xbee_device_callbacks()

Returns this XBee internal callbacks for process received packets.

This method is called by the PacketListener associated with this XBee to get its callbacks. These callbacks will be executed before user callbacks.

Returns:PacketReceived
has_explicit_packets()

Returns whether the XBee device’s queue has explicit packets or not. This do not include non-explicit packets.

Returns:True if this XBee device’s queue has explicit packets, False otherwise.
Return type:Boolean
has_packets()

Returns whether the XBee device’s queue has packets or not. This do not include explicit packets.

Returns:True if this XBee device’s queue has packets, False otherwise.
Return type:Boolean
is_apply_changes_enabled()

Returns whether the apply_changes flag is enabled or not.

Returns:True if the apply_changes flag is enabled, False otherwise.
Return type:Boolean
is_open()

Returns whether this XBee device is open or not.

Returns:Boolean. True if this XBee device is open, False otherwise.
is_remote()

Override method.

log

Returns the XBee device log.

Returns:the XBee device logger.
Return type:Logger
operating_mode

Returns this XBee device’s operating mode.

Returns:OperatingMode. This XBee device’s operating mode.
read_data(timeout=None)

Reads new data received by this XBee device.

If a timeout is specified, this method blocks until new data is received or the timeout expires, throwing in that case a TimeoutException.

Parameters:

timeout (Integer, optional) – read timeout in seconds. If it’s None, this method is non-blocking and will return None if there is no data available.

Returns:

the read message or None if this XBee did not receive new data.

Return type:

XBeeMessage

Raises:
  • ValueError – if a timeout is specified and is less than 0.
  • TimeoutException – if a timeout is specified and no data was received during that time.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – if the XBee device’s serial port is closed.

See also

read_data_from(remote_xbee_device, timeout=None)

Reads new data received from the given remote XBee device.

If a timeout is specified, this method blocks until new data is received or the timeout expires, throwing in that case a TimeoutException.

Parameters:
  • remote_xbee_device (RemoteXBeeDevice) – the remote XBee device that sent the data.
  • timeout (Integer, optional) – read timeout in seconds. If it’s None, this method is non-blocking and will return None if there is no data available.
Returns:

the read message sent by remote_xbee_device or None if this XBee did

not receive new data.

Return type:

XBeeMessage

Raises:
  • ValueError – if a timeout is specified and is less than 0.
  • TimeoutException – if a timeout is specified and no data was received during that time.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – if the XBee device’s serial port is closed.
read_device_info(init=True)

Updates all instance parameters reading them from the XBee device.

Parameters:

init (Boolean, optional, default=`True`) – If False only not initialized parameters are read, all if True.

Raises:
read_io_sample()

Returns an IO sample from the XBee device containing the value of all enabled digital IO and analog input channels.

Returns:

the IO sample read from the XBee device.

Return type:

IOSample

Raises:

See also

reset()

Override method.

send_bluetooth_data(data)

Sends the given data to the Bluetooth interface using a User Data Relay frame.

Parameters:

data (Bytearray) – Data to send.

Raises:
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – if there is any problem sending the data.
send_data(remote_xbee_device, data, transmit_options=0)

Blocking method. This method sends data to a remote XBee device synchronously.

This method will wait for the packet response.

The default timeout for this method is XBeeDevice._DEFAULT_TIMEOUT_SYNC_OPERATIONS.

Parameters:
  • remote_xbee_device (RemoteXBeeDevice) – the remote XBee device to send data to.
  • data (String or Bytearray) – the raw data to send.
  • transmit_options (Integer, optional) – transmit options, bitfield of TransmitOptions. Default to TransmitOptions.NONE.value.
Returns:

XBeePacket the response.

Raises:
  • ValueError – if remote_xbee_device is None.
  • TimeoutException – if this method can’t read a response packet in XBeeDevice._DEFAULT_TIMEOUT_SYNC_OPERATIONS seconds.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • TransmitException – if the status of the response received is not OK.
  • XBeeException – if the XBee device’s serial port is closed.
send_data_async(remote_xbee_device, data, transmit_options=0)

Non-blocking method. This method sends data to a remote XBee device.

This method won’t wait for the response.

Parameters:
  • remote_xbee_device (RemoteXBeeDevice) – the remote XBee device to send data to.
  • data (String or Bytearray) – the raw data to send.
  • transmit_options (Integer, optional) – transmit options, bitfield of TransmitOptions. Default to TransmitOptions.NONE.value.
Raises:
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – if the XBee device’s serial port is closed.

See also

send_data_broadcast(data, transmit_options=0)

Sends the provided data to all the XBee nodes of the network (broadcast).

This method blocks till a success or error transmit status arrives or the configured receive timeout expires.

The received timeout is configured using the AbstractXBeeDevice.set_sync_ops_timeout() method and can be consulted with AbstractXBeeDevice.get_sync_ops_timeout() method.

Parameters:
  • data (String or Bytearray) – data to send.
  • transmit_options (Integer, optional) – transmit options, bitfield of TransmitOptions. Default to TransmitOptions.NONE.value.
Raises:
  • TimeoutException – if this method can’t read a response packet in XBeeDevice._DEFAULT_TIMEOUT_SYNC_OPERATIONS seconds.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • TransmitException – if the status of the response received is not OK.
  • XBeeException – if the XBee device’s serial port is closed.
send_micropython_data(data)

Sends the given data to the MicroPython interface using a User Data Relay frame.

Parameters:

data (Bytearray) – Data to send.

Raises:
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – if there is any problem sending the data.
send_packet(packet, sync=False)

Override method.

See also

AbstractXBeeDevice._send_packet()
send_packet_sync_and_get_response(packet_to_send, timeout=None)

Override method.

See also

AbstractXBeeDevice._send_packet_sync_and_get_response()
send_user_data_relay(local_interface, data)

Sends the given data to the given XBee local interface.

Parameters:
  • local_interface (XBeeLocalInterface) – Destination XBee local interface.
  • data (Bytearray) – Data to send.
Raises:
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ValueError – if local_interface is None.
  • XBeeException – if there is any problem sending the User Data Relay.
serial_port

Returns the serial port associated to the XBee device, if any.

Returns:
the serial port associated to the XBee device. Returns None if the local XBee
does not use serial communication.
Return type:XBeeSerialPort

See also

set_16bit_addr(value)

Sets the 16-bit address of the XBee device.

Parameters:

value (XBee16BitAddress) – the new 16-bit address of the XBee device.

Raises:
set_api_output_mode(api_output_mode)

Deprecated since version 1.3: Use set_api_output_mode_value()

Sets the API output mode of the XBee device.

Parameters:

api_output_mode (APIOutputMode) – the new API output mode of the XBee device.

Raises:

See also

set_api_output_mode_value(api_output_mode)

Sets the API output mode of the XBee.

Parameters:

api_output_mode (Integer) – new API output mode options. Calculate this value using the method digi.xbee.models.mode.APIOutputModeBit.calculate_api_output_mode_value() with a set of digi.xbee.models.mode.APIOutputModeBit.

Raises:
set_dest_address(addr)

Sets the 64-bit address of the XBee device that data will be reported to.

Parameters:

addr (XBee64BitAddress or RemoteXBeeDevice) – the address itself or the remote XBee device that you want to set up its address as destination address.

Raises:
  • TimeoutException – If the response is not received before the read timeout expires.
  • XBeeException – If the XBee device’s serial port is closed.
  • InvalidOperatingModeException – If the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If the response is not as expected.
  • ValueError – If addr is None.
set_dio_change_detection(io_lines_set)

Sets the digital IO lines to be monitored and sampled whenever their status changes.

A None set of lines disables this feature.

Parameters:

io_lines_set – set of IOLine.

Raises:

See also

set_dio_value(io_line, io_value)

Sets the digital value (high or low) to the provided IO line.

Parameters:
  • io_line (IOLine) – the digital IO line to sets its value.
  • io_value (IOValue) – the IO value to set to the IO line.
Raises:

See also

set_io_configuration(io_line, io_mode)

Sets the configuration of the provided IO line.

Parameters:
  • io_line (IOLine) – the IO line to configure.
  • io_mode (IOMode) – the IO mode to set to the IO line.
Raises:

See also

set_io_sampling_rate(rate)

Sets the IO sampling rate of the XBee device in seconds. A sample rate of 0 means the IO sampling feature is disabled.

Parameters:

rate (Integer) – the new IO sampling rate of the XBee device in seconds.

Raises:
set_node_id(node_id)

Sets the Node Identifier (NI) value of the XBee device..

Parameters:

node_id (String) – the new Node Identifier (NI) of the XBee device.

Raises:
  • ValueError – if node_id is None or its length is greater than 20.
  • TimeoutException – if the response is not received before the read timeout expires.
set_pan_id(value)

Sets the operating PAN ID of the XBee device.

Parameters:value (Bytearray) – the new operating PAN ID of the XBee device.. Must have only 1 or 2 bytes.
Raises:TimeoutException – if the response is not received before the read timeout expires.
set_parameter(param, value)

Override.

See:
AbstractXBeeDevice.set_parameter()
set_power_level(power_level)

Sets the power level of the XBee device.

Parameters:power_level (PowerLevel) – the new power level of the XBee device.
Raises:TimeoutException – if the response is not received before the read timeout expires.

See also

set_pwm_duty_cycle(io_line, cycle)

Sets the duty cycle in % of the provided IO line.

The provided IO line must be PWM-capable, previously configured as PWM output.

Parameters:
  • io_line (IOLine) – the IO Line to be assigned.
  • cycle (Integer) – duty cycle in % to be assigned. Must be between 0 and 100.
Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – if the response is not as expected.
  • ValueError – if the given IO line does not have PWM capability or cycle is not between 0 and 100.

See also

set_sync_ops_timeout(sync_ops_timeout)

Sets the serial port read timeout.

Parameters:sync_ops_timeout (Integer) – the read timeout, expressed in seconds.
update_bluetooth_password(new_password)

Changes the password of this Bluetooth device with the new one provided.

Note that your device must have Bluetooth Low Energy support to use this method.

Parameters:

new_password (String) – New Bluetooth password.

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
update_device_data_from(device)

Updates the current device reference with the data provided for the given device.

This is only for internal use.

Parameters:device (AbstractXBeeDevice) – the XBee device to get the data from.
Returns:True if the device data has been updated, False otherwise.
Return type:Boolean
update_firmware(xml_firmware_file, xbee_firmware_file=None, bootloader_firmware_file=None, timeout=None, progress_callback=None)

Performs a firmware update operation of the device.

Parameters:
  • xml_firmware_file (String) – path of the XML file that describes the firmware to upload.
  • xbee_firmware_file (String, optional) – location of the XBee binary firmware file.
  • bootloader_firmware_file (String, optional) – location of the bootloader binary firmware file.
  • timeout (Integer, optional) – the maximum time to wait for target read operations during the update process.
  • progress_callback (Function, optional) –
    function to execute to receive progress information. Receives two
    arguments:
    • The current update task as a String
    • The current update task percentage as an Integer
Raises:
write_changes()

Writes configurable parameter values to the non-volatile memory of the XBee device so that parameter modifications persist through subsequent resets.

Parameters values remain in this device’s memory until overwritten by subsequent use of this method.

If changes are made without writing them to non-volatile memory, the module reverts back to previously saved parameters the next time the module is powered-on.

Writing the parameter modifications does not mean those values are immediately applied, this depends on the status of the ‘apply configuration changes’ option. Use method is_apply_configuration_changes_enabled() to get its status and enable_apply_configuration_changes() to enable/disable the option. If it is disabled, method apply_changes() can be used in order to manually apply the changes.

Raises:
class digi.xbee.devices.IPDevice(port=None, baud_rate=None, data_bits=<sphinx.ext.autodoc.importer._MockObject object>, stop_bits=<sphinx.ext.autodoc.importer._MockObject object>, parity=<sphinx.ext.autodoc.importer._MockObject object>, flow_control=<FlowControl.NONE: None>, _sync_ops_timeout=4, comm_iface=None)[source]

Bases: digi.xbee.devices.XBeeDevice

This class provides common functionality for XBee IP devices.

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

Parameters:
  • port (Integer or String) – serial port identifier. Integer: number of XBee device, numbering starts at zero. Device name: depending on operating system. e.g. ‘/dev/ttyUSB0’ on ‘GNU/Linux’ or ‘COM3’ on Windows.
  • baud_rate (Integer) – the serial port baud rate.
  • (Integer, default (_sync_ops_timeout) – serial.EIGHTBITS): comm port bitsize.
  • (Integer, defaultserial.STOPBITS_ONE): comm port stop bits.
  • (Character, default (parity) – serial.PARITY_NONE): comm port parity.
  • (Integer, defaultFlowControl.NONE): comm port flow control.
  • (Integer, default – 3): the read timeout (in seconds).
  • comm_iface (XBeeCommunicationInterface) – the communication interface.

:raises All exceptions raised by XBeeDevice.__init__() constructor.:

See also

XBeeDevice.__init__()
read_device_info(init=True)[source]

Override.

get_ip_addr()[source]

Returns the IP address of this IP device.

To refresh this value use the method IPDevice.read_device_info().

Returns:The IP address of this IP device.
Return type:ipaddress.IPv4Address

See also

ipaddress.IPv4Address
set_dest_ip_addr(address)[source]

Sets the destination IP address.

Parameters:

address (ipaddress.IPv4Address) – Destination IP address.

Raises:
  • ValueError – if address is None.
  • TimeoutException – if there is a timeout setting the destination IP address.
  • XBeeException – if there is any other XBee related exception.

See also

ipaddress.IPv4Address
get_dest_ip_addr()[source]

Returns the destination IP address.

Returns:

The configured destination IP address.

Return type:

ipaddress.IPv4Address

Raises:

See also

ipaddress.IPv4Address
add_ip_data_received_callback(callback)[source]

Adds a callback for the event digi.xbee.reader.IPDataReceived.

Parameters:callback (Function) –

the callback. Receives one argument.

del_ip_data_received_callback(callback)[source]

Deletes a callback for the callback list of digi.xbee.reader.IPDataReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.IPDataReceived event.
start_listening(source_port)[source]

Starts listening for incoming IP transmissions in the provided port.

Parameters:

source_port (Integer) – Port to listen for incoming transmissions.

Raises:
  • ValueError – if source_port is less than 0 or greater than 65535.
  • TimeoutException – if there is a timeout setting the source port.
  • XBeeException – if there is any other XBee related exception.
stop_listening()[source]

Stops listening for incoming IP transmissions.

Raises:
send_ip_data(ip_addr, dest_port, protocol, data, close_socket=False)[source]

Sends the provided IP data to the given IP address and port using the specified IP protocol. For TCP and TCP SSL protocols, you can also indicate if the socket should be closed when data is sent.

This method blocks till a success or error response arrives or the configured receive timeout expires.

Parameters:
  • ip_addr (ipaddress.IPv4Address) – The IP address to send IP data to.
  • dest_port (Integer) – The destination port of the transmission.
  • protocol (IPProtocol) – The IP protocol used for the transmission.
  • data (String or Bytearray) – The IP data to be sent.
  • close_socket (Boolean, optional) – True to close the socket just after the transmission. False to keep it open. Default to False.
Raises:
  • ValueError – if ip_addr is None.
  • ValueError – if protocol is None.
  • ValueError – if data is None.
  • ValueError – if dest_port is less than 0 or greater than 65535.
  • OperationNotSupportedException – if the device is remote.
  • TimeoutException – if there is a timeout sending the data.
  • XBeeException – if there is any other XBee related exception.
send_ip_data_async(ip_addr, dest_port, protocol, data, close_socket=False)[source]

Sends the provided IP data to the given IP address and port asynchronously using the specified IP protocol. For TCP and TCP SSL protocols, you can also indicate if the socket should be closed when data is sent.

Asynchronous transmissions do not wait for answer from the remote device or for transmit status packet.

Parameters:
  • ip_addr (ipaddress.IPv4Address) – The IP address to send IP data to.
  • dest_port (Integer) – The destination port of the transmission.
  • protocol (IPProtocol) – The IP protocol used for the transmission.
  • data (String or Bytearray) – The IP data to be sent.
  • close_socket (Boolean, optional) – True to close the socket just after the transmission. False to keep it open. Default to False.
Raises:
  • ValueError – if ip_addr is None.
  • ValueError – if protocol is None.
  • ValueError – if data is None.
  • ValueError – if dest_port is less than 0 or greater than 65535.
  • OperationNotSupportedException – if the device is remote.
  • XBeeException – if there is any other XBee related exception.
send_ip_data_broadcast(dest_port, data)[source]

Sends the provided IP data to all clients.

This method blocks till a success or error transmit status arrives or the configured receive timeout expires.

Parameters:
  • dest_port (Integer) – The destination port of the transmission.
  • data (String or Bytearray) – The IP data to be sent.
Raises:
  • ValueError – if data is None.
  • ValueError – if dest_port is less than 0 or greater than 65535.
  • TimeoutException – if there is a timeout sending the data.
  • XBeeException – if there is any other XBee related exception.
read_ip_data(timeout=3)[source]

Reads new IP data received by this XBee device during the provided timeout.

This method blocks until new IP data is received or the provided timeout expires.

For non-blocking operations, register a callback and use the method IPDevice.add_ip_data_received_callback().

Before reading IP data you need to start listening for incoming IP data at a specific port. Use the method IPDevice.start_listening() for that purpose. When finished, you can use the method IPDevice.stop_listening() to stop listening for incoming IP data.

Parameters:timeout (Integer, optional) – The time to wait for new IP data in seconds.
Returns:IP message, None if this device did not receive new data.
Return type:IPMessage
Raises:ValueError – if timeout is less than 0.
read_ip_data_from(ip_addr, timeout=3)[source]

Reads new IP data received from the given IP address during the provided timeout.

This method blocks until new IP data from the provided IP address is received or the given timeout expires.

For non-blocking operations, register a callback and use the method IPDevice.add_ip_data_received_callback().

Before reading IP data you need to start listening for incoming IP data at a specific port. Use the method IPDevice.start_listening() for that purpose. When finished, you can use the method IPDevice.stop_listening() to stop listening for incoming IP data.

Parameters:
  • ip_addr (ipaddress.IPv4Address) – The IP address to read data from.
  • timeout (Integer, optional) – The time to wait for new IP data in seconds.
Returns:

IP message, None if this device did not

receive new data from the provided IP address.

Return type:

IPMessage

Raises:

ValueError – if timeout is less than 0.

get_network()[source]

Deprecated.

This protocol does not support the network functionality.

get_16bit_addr()[source]

Deprecated.

This protocol does not have an associated 16-bit address.

get_dest_address()[source]

Deprecated.

Operation not supported in this protocol. Use IPDevice.get_dest_ip_addr() instead. This method will raise an AttributeError.

set_dest_address(addr)[source]

Deprecated.

Operation not supported in this protocol. Use IPDevice.set_dest_ip_addr() instead. This method will raise an AttributeError.

get_pan_id()[source]

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

set_pan_id(value)[source]

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

add_data_received_callback(callback)[source]

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

del_data_received_callback(callback)[source]

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

add_expl_data_received_callback(callback)[source]

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

del_expl_data_received_callback(callback)[source]

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

read_data(timeout=None, explicit=False)[source]

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

read_data_from(remote_xbee_device, timeout=None, explicit=False)[source]

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

send_data_broadcast(data, transmit_options=0)[source]

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

send_data(remote_xbee_device, data, transmit_options=0)[source]

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

send_data_async(remote_xbee_device, data, transmit_options=0)[source]

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

add_bluetooth_data_received_callback(callback)

Adds a callback for the event digi.xbee.reader.BluetoothDataReceived.

Parameters:callback (Function) –

the callback. Receives one argument.

  • The Bluetooth data as a Bytearray
add_io_sample_received_callback(callback)

Adds a callback for the event digi.xbee.reader.IOSampleReceived.

Parameters:callback (Function) –

the callback. Receives three arguments.

add_micropython_data_received_callback(callback)

Adds a callback for the event digi.xbee.reader.MicroPythonDataReceived.

Parameters:callback (Function) –

the callback. Receives one argument.

  • The MicroPython data as a Bytearray
add_modem_status_received_callback(callback)

Adds a callback for the event digi.xbee.reader.ModemStatusReceived.

Parameters:callback (Function) –

the callback. Receives one argument.

add_packet_received_callback(callback)

Adds a callback for the event digi.xbee.reader.PacketReceived.

Parameters:callback (Function) –

the callback. Receives two arguments.

add_socket_data_received_callback(callback)

Adds a callback for the event digi.xbee.reader.SocketDataReceived.

Parameters:callback (Function) –

the callback. Receives two arguments.

  • The socket ID as an Integer.
  • The data received as Bytearray
add_socket_data_received_from_callback(callback)

Adds a callback for the event digi.xbee.reader.SocketDataReceivedFrom.

Parameters:callback (Function) –

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 data received as Bytearray
add_socket_state_received_callback(callback)

Adds a callback for the event digi.xbee.reader.SocketStateReceived.

Parameters:callback (Function) –

the callback. Receives two arguments.

  • The socket ID as an Integer.
  • The state received as a SocketState
add_user_data_relay_received_callback(callback)

Adds a callback for the event digi.xbee.reader.RelayDataReceived.

Parameters:callback (Function) –

the callback. Receives one argument.

apply_changes()

Applies changes via AC command.

Raises:
apply_profile(profile_path, progress_callback=None)

Applies the given XBee profile to the XBee device.

Parameters:
  • profile_path (String) – path of the XBee profile file to apply.
  • progress_callback (Function, optional) –
    function to execute to receive progress information. Receives two
    arguments:
    • The current apply profile task as a String
    • The current apply profile task percentage as an Integer
Raises:
close()

Closes the communication with the XBee device.

This method guarantees that all threads running are stopped and the serial port is closed.

comm_iface

Returns the hardware interface associated to the XBee device.

Returns:the hardware interface associated to the XBee device.
Return type:XBeeCommunicationInterface

See also

classmethod create_xbee_device(comm_port_data)

Creates and returns an XBeeDevice from data of the port to which is connected.

Parameters:
  • comm_port_data (Dictionary) – dictionary with all comm port data needed.
  • dictionary keys are (The) –
    “baudRate” –> Baud rate.
    ”port” –> Port number.
    ”bitSize” –> Bit size.
    ”stopBits” –> Stop bits.
    ”parity” –> Parity.
    ”flowControl” –> Flow control.
    ”timeout” for –> Timeout for synchronous operations (in seconds).
Returns:

the XBee device created.

Return type:

XBeeDevice

Raises:

SerialException – if the port you want to open does not exist or is already opened.

See also

del_bluetooth_data_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.BluetoothDataReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.BluetoothDataReceived event.
del_io_sample_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.IOSampleReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.IOSampleReceived event.
del_micropython_data_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.MicroPythonDataReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.MicroPythonDataReceived event.
del_modem_status_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.ModemStatusReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.ModemStatusReceived event.
del_packet_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.PacketReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.PacketReceived event.
del_socket_data_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.SocketDataReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.SocketDataReceived event.
del_socket_data_received_from_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.SocketDataReceivedFrom event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.SocketDataReceivedFrom event.
del_socket_state_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.SocketStateReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.SocketStateReceived event.
del_user_data_relay_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.RelayDataReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.RelayDataReceived event.
disable_bluetooth()

Disables the Bluetooth interface of this XBee device.

Note that your device must have Bluetooth Low Energy support to use this method.

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
enable_apply_changes(value)

Sets the apply_changes flag.

Parameters:value (Boolean) – True to enable the apply changes flag, False to disable it.
enable_bluetooth()

Enables the Bluetooth interface of this XBee device.

To work with this interface, you must also configure the Bluetooth password if not done previously. You can use the AbstractXBeeDevice.update_bluetooth_password() method for that purpose.

Note that your device must have Bluetooth Low Energy support to use this method.

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
execute_command(parameter)

Executes the provided command.

Parameters:

parameter (String) – The name of the AT command to be executed.

Raises:
flush_queues()

Flushes the packets queue.

get_64bit_addr()

Returns the 64-bit address of the XBee device.

Returns:the 64-bit address of the XBee device.
Return type:XBee64BitAddress

See also

get_adc_value(io_line)

Returns the analog value of the provided IO line.

The provided IO line must be previously configured as ADC. To do so, use AbstractXBeeDevice.set_io_configuration() and IOMode.ADC.

Parameters:

io_line (IOLine) – the IO line to get its ADC value.

Returns:

the analog value corresponding to the provided IO line.

Return type:

Integer

Raises:

See also

get_api_output_mode()

Deprecated since version 1.3: Use get_api_output_mode_value()

Returns the API output mode of the XBee device.

The API output mode determines the format that the received data is output through the serial interface of the XBee device.

Returns:

the API output mode of the XBee device.

Return type:

APIOutputMode

Raises:

See also

get_api_output_mode_value()

Returns the API output mode of the XBee.

The API output mode determines the format that the received data is output through the serial interface of the XBee.

Returns:

the parameter value.

Return type:

Bytearray

Raises:
get_bluetooth_mac_addr()

Reads and returns the EUI-48 Bluetooth MAC address of this XBee device in a format such as 00112233AABB.

Note that your device must have Bluetooth Low Energy support to use this method.

Returns:

The Bluetooth MAC address.

Return type:

String

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
get_current_frame_id()

Returns the last used frame ID.

Returns:the last used frame ID.
Return type:Integer
get_dio_value(io_line)

Returns the digital value of the provided IO line.

The provided IO line must be previously configured as digital I/O. To do so, use AbstractXBeeDevice.set_io_configuration().

Parameters:

io_line (IOLine) – the DIO line to gets its digital value.

Returns:

current value of the provided IO line.

Return type:

IOValue

Raises:

See also

get_firmware_version()

Returns the firmware version of the XBee device.

Returns:the hardware version of the XBee device.
Return type:Bytearray
get_hardware_version()

Returns the hardware version of the XBee device.

Returns:the hardware version of the XBee device.
Return type:HardwareVersion

See also

get_io_configuration(io_line)

Returns the configuration of the provided IO line.

Parameters:

io_line (IOLine) – the io line to configure.

Returns:

the IO mode of the IO line provided.

Return type:

IOMode

Raises:
get_io_sampling_rate()

Returns the IO sampling rate of the XBee device.

Returns:

the IO sampling rate of XBee device.

Return type:

Integer

Raises:
get_next_frame_id()

Returns the next frame ID of the XBee device.

Returns:The next frame ID of the XBee device.
Return type:Integer
get_node_id()

Returns the Node Identifier (NI) value of the XBee device.

Returns:the Node Identifier (NI) of the XBee device.
Return type:String
get_parameter(param, parameter_value=None)

Override.

get_power_level()

Returns the power level of the XBee device.

Returns:the power level of the XBee device.
Return type:PowerLevel
Raises:TimeoutException – if the response is not received before the read timeout expires.

See also

get_protocol()

Returns the current protocol of the XBee device.

Returns:the current protocol of the XBee device.
Return type:XBeeProtocol

See also

get_pwm_duty_cycle(io_line)

Returns the PWM duty cycle in % corresponding to the provided IO line.

Parameters:

io_line (IOLine) – the IO line to get its PWM duty cycle.

Returns:

the PWM duty cycle of the given IO line or None if the response is empty.

Return type:

Integer

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – if the response is not as expected.
  • ValueError – if the passed IO_LINE has no PWM capability.

See also

get_role()

Gets the XBee role.

Returns:the role of the XBee.
Return type:digi.xbee.models.protocol.Role
get_sync_ops_timeout()

Returns the serial port read timeout.

Returns:the serial port read timeout in seconds.
Return type:Integer
get_xbee_device_callbacks()

Returns this XBee internal callbacks for process received packets.

This method is called by the PacketListener associated with this XBee to get its callbacks. These callbacks will be executed before user callbacks.

Returns:PacketReceived
has_explicit_packets()

Returns whether the XBee device’s queue has explicit packets or not. This do not include non-explicit packets.

Returns:True if this XBee device’s queue has explicit packets, False otherwise.
Return type:Boolean
has_packets()

Returns whether the XBee device’s queue has packets or not. This do not include explicit packets.

Returns:True if this XBee device’s queue has packets, False otherwise.
Return type:Boolean
is_apply_changes_enabled()

Returns whether the apply_changes flag is enabled or not.

Returns:True if the apply_changes flag is enabled, False otherwise.
Return type:Boolean
is_open()

Returns whether this XBee device is open or not.

Returns:Boolean. True if this XBee device is open, False otherwise.
is_remote()

Override method.

log

Returns the XBee device log.

Returns:the XBee device logger.
Return type:Logger
open(force_settings=False)

Opens the communication with the XBee device and loads some information about it.

Parameters:

force_settings (Boolean, optional) – True to open the device ensuring/forcing that the specified serial settings are applied even if the current configuration is different, False to open the device with the current configuration. Default to False.

Raises:
operating_mode

Returns this XBee device’s operating mode.

Returns:OperatingMode. This XBee device’s operating mode.
read_io_sample()

Returns an IO sample from the XBee device containing the value of all enabled digital IO and analog input channels.

Returns:

the IO sample read from the XBee device.

Return type:

IOSample

Raises:

See also

reset()

Override method.

send_bluetooth_data(data)

Sends the given data to the Bluetooth interface using a User Data Relay frame.

Parameters:

data (Bytearray) – Data to send.

Raises:
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – if there is any problem sending the data.
send_micropython_data(data)

Sends the given data to the MicroPython interface using a User Data Relay frame.

Parameters:

data (Bytearray) – Data to send.

Raises:
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – if there is any problem sending the data.
send_packet(packet, sync=False)

Override method.

See also

AbstractXBeeDevice._send_packet()
send_packet_sync_and_get_response(packet_to_send, timeout=None)

Override method.

See also

AbstractXBeeDevice._send_packet_sync_and_get_response()
send_user_data_relay(local_interface, data)

Sends the given data to the given XBee local interface.

Parameters:
  • local_interface (XBeeLocalInterface) – Destination XBee local interface.
  • data (Bytearray) – Data to send.
Raises:
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ValueError – if local_interface is None.
  • XBeeException – if there is any problem sending the User Data Relay.
serial_port

Returns the serial port associated to the XBee device, if any.

Returns:
the serial port associated to the XBee device. Returns None if the local XBee
does not use serial communication.
Return type:XBeeSerialPort

See also

set_16bit_addr(value)

Sets the 16-bit address of the XBee device.

Parameters:

value (XBee16BitAddress) – the new 16-bit address of the XBee device.

Raises:
set_api_output_mode(api_output_mode)

Deprecated since version 1.3: Use set_api_output_mode_value()

Sets the API output mode of the XBee device.

Parameters:

api_output_mode (APIOutputMode) – the new API output mode of the XBee device.

Raises:

See also

set_api_output_mode_value(api_output_mode)

Sets the API output mode of the XBee.

Parameters:

api_output_mode (Integer) – new API output mode options. Calculate this value using the method digi.xbee.models.mode.APIOutputModeBit.calculate_api_output_mode_value() with a set of digi.xbee.models.mode.APIOutputModeBit.

Raises:
set_dio_change_detection(io_lines_set)

Sets the digital IO lines to be monitored and sampled whenever their status changes.

A None set of lines disables this feature.

Parameters:

io_lines_set – set of IOLine.

Raises:

See also

set_dio_value(io_line, io_value)

Sets the digital value (high or low) to the provided IO line.

Parameters:
  • io_line (IOLine) – the digital IO line to sets its value.
  • io_value (IOValue) – the IO value to set to the IO line.
Raises:

See also

set_io_configuration(io_line, io_mode)

Sets the configuration of the provided IO line.

Parameters:
  • io_line (IOLine) – the IO line to configure.
  • io_mode (IOMode) – the IO mode to set to the IO line.
Raises:

See also

set_io_sampling_rate(rate)

Sets the IO sampling rate of the XBee device in seconds. A sample rate of 0 means the IO sampling feature is disabled.

Parameters:

rate (Integer) – the new IO sampling rate of the XBee device in seconds.

Raises:
set_node_id(node_id)

Sets the Node Identifier (NI) value of the XBee device..

Parameters:

node_id (String) – the new Node Identifier (NI) of the XBee device.

Raises:
  • ValueError – if node_id is None or its length is greater than 20.
  • TimeoutException – if the response is not received before the read timeout expires.
set_parameter(param, value)

Override.

See:
AbstractXBeeDevice.set_parameter()
set_power_level(power_level)

Sets the power level of the XBee device.

Parameters:power_level (PowerLevel) – the new power level of the XBee device.
Raises:TimeoutException – if the response is not received before the read timeout expires.

See also

set_pwm_duty_cycle(io_line, cycle)

Sets the duty cycle in % of the provided IO line.

The provided IO line must be PWM-capable, previously configured as PWM output.

Parameters:
  • io_line (IOLine) – the IO Line to be assigned.
  • cycle (Integer) – duty cycle in % to be assigned. Must be between 0 and 100.
Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – if the response is not as expected.
  • ValueError – if the given IO line does not have PWM capability or cycle is not between 0 and 100.

See also

set_sync_ops_timeout(sync_ops_timeout)

Sets the serial port read timeout.

Parameters:sync_ops_timeout (Integer) – the read timeout, expressed in seconds.
update_bluetooth_password(new_password)

Changes the password of this Bluetooth device with the new one provided.

Note that your device must have Bluetooth Low Energy support to use this method.

Parameters:

new_password (String) – New Bluetooth password.

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
update_device_data_from(device)

Updates the current device reference with the data provided for the given device.

This is only for internal use.

Parameters:device (AbstractXBeeDevice) – the XBee device to get the data from.
Returns:True if the device data has been updated, False otherwise.
Return type:Boolean
update_firmware(xml_firmware_file, xbee_firmware_file=None, bootloader_firmware_file=None, timeout=None, progress_callback=None)

Performs a firmware update operation of the device.

Parameters:
  • xml_firmware_file (String) – path of the XML file that describes the firmware to upload.
  • xbee_firmware_file (String, optional) – location of the XBee binary firmware file.
  • bootloader_firmware_file (String, optional) – location of the bootloader binary firmware file.
  • timeout (Integer, optional) – the maximum time to wait for target read operations during the update process.
  • progress_callback (Function, optional) –
    function to execute to receive progress information. Receives two
    arguments:
    • The current update task as a String
    • The current update task percentage as an Integer
Raises:
write_changes()

Writes configurable parameter values to the non-volatile memory of the XBee device so that parameter modifications persist through subsequent resets.

Parameters values remain in this device’s memory until overwritten by subsequent use of this method.

If changes are made without writing them to non-volatile memory, the module reverts back to previously saved parameters the next time the module is powered-on.

Writing the parameter modifications does not mean those values are immediately applied, this depends on the status of the ‘apply configuration changes’ option. Use method is_apply_configuration_changes_enabled() to get its status and enable_apply_configuration_changes() to enable/disable the option. If it is disabled, method apply_changes() can be used in order to manually apply the changes.

Raises:
class digi.xbee.devices.CellularDevice(port=None, baud_rate=None, data_bits=<sphinx.ext.autodoc.importer._MockObject object>, stop_bits=<sphinx.ext.autodoc.importer._MockObject object>, parity=<sphinx.ext.autodoc.importer._MockObject object>, flow_control=<FlowControl.NONE: None>, _sync_ops_timeout=4, comm_iface=None)[source]

Bases: digi.xbee.devices.IPDevice

This class represents a local Cellular device.

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

Parameters:
  • port (Integer or String) – serial port identifier. Integer: number of XBee device, numbering starts at zero. Device name: depending on operating system. e.g. ‘/dev/ttyUSB0’ on ‘GNU/Linux’ or ‘COM3’ on Windows.
  • baud_rate (Integer) – the serial port baud rate.
  • (Integer, default (_sync_ops_timeout) – serial.EIGHTBITS): comm port bitsize.
  • (Integer, defaultserial.STOPBITS_ONE): comm port stop bits.
  • (Character, default (parity) – serial.PARITY_NONE): comm port parity.
  • (Integer, defaultFlowControl.NONE): comm port flow control.
  • (Integer, default – 3): the read timeout (in seconds).
  • comm_iface (XBeeCommunicationInterface) – the communication interface.

:raises All exceptions raised by XBeeDevice.__init__() constructor.:

See also

XBeeDevice.__init__()
open(force_settings=False)[source]

Override.

Raises:
  • TimeoutException – If there is any problem with the communication.
  • InvalidOperatingModeException – If the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – If the protocol is invalid or if the XBee device is already open.
get_protocol()[source]

Override.

read_device_info(init=True)[source]

Override.

See also

XBeeDevice.read_device _info()
is_connected()[source]

Returns whether the device is connected to the Internet or not.

Returns:

True if the device is connected to the Internet, False otherwise.

Return type:

Boolean

Raises:
  • TimeoutException – if there is a timeout getting the association indication status.
  • XBeeException – if there is any other XBee related exception.
get_cellular_ai_status()[source]

Returns the current association status of this Cellular device.

It indicates occurrences of errors during the modem initialization and connection.

Returns:

The association indication status of the Cellular device.

Return type:

CellularAssociationIndicationStatus

Raises:
  • TimeoutException – if there is a timeout getting the association indication status.
  • XBeeException – if there is any other XBee related exception.
add_sms_callback(callback)[source]

Adds a callback for the event digi.xbee.reader.SMSReceived.

Parameters:callback (Function) –

the callback. Receives one argument.

del_sms_callback(callback)[source]

Deletes a callback for the callback list of digi.xbee.reader.SMSReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.SMSReceived event.
get_imei_addr()[source]

Returns the IMEI address of this Cellular device.

To refresh this value use the method CellularDevice.read_device_info().

Returns:The IMEI address of this Cellular device.
Return type:XBeeIMEIAddress
send_sms(phone_number, data)[source]

Sends the provided SMS message to the given phone number.

This method blocks till a success or error response arrives or the configured receive timeout expires.

For non-blocking operations use the method CellularDevice.send_sms_async().

Parameters:
  • phone_number (String) – The phone number to send the SMS to.
  • data (String) – Text of the SMS.
Raises:
send_sms_async(phone_number, data)[source]

Sends asynchronously the provided SMS to the given phone number.

Asynchronous transmissions do not wait for answer or for transmit status packet.

Parameters:
  • phone_number (String) – The phone number to send the SMS to.
  • data (String) – Text of the SMS.
Raises:
get_sockets_list()[source]

Returns a list with the IDs of all active (open) sockets.

Returns:

list with the IDs of all active (open) sockets, or empty list if there is not any active socket.

Return type:

List

Raises:
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
get_socket_info(socket_id)[source]

Returns the information of the socket with the given socket ID.

Parameters:

socket_id (Integer) – ID of the socket.

Returns:

The socket information, or None if the socket with that ID does not exist.

Return type:

SocketInfo

Raises:
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.

See also

SocketInfo
get_64bit_addr()[source]

Deprecated.

Cellular protocol does not have an associated 64-bit address.

add_io_sample_received_callback(callback)[source]

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

del_io_sample_received_callback(callback)[source]

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

set_dio_change_detection(io_lines_set)[source]

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

get_io_sampling_rate()[source]

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

set_io_sampling_rate(rate)[source]

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

get_node_id()[source]

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

set_node_id(node_id)[source]

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

get_power_level()[source]

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

set_power_level(power_level)[source]

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

add_bluetooth_data_received_callback(callback)

Adds a callback for the event digi.xbee.reader.BluetoothDataReceived.

Parameters:callback (Function) –

the callback. Receives one argument.

  • The Bluetooth data as a Bytearray
add_data_received_callback(callback)

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

add_expl_data_received_callback(callback)

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

add_ip_data_received_callback(callback)

Adds a callback for the event digi.xbee.reader.IPDataReceived.

Parameters:callback (Function) –

the callback. Receives one argument.

add_micropython_data_received_callback(callback)

Adds a callback for the event digi.xbee.reader.MicroPythonDataReceived.

Parameters:callback (Function) –

the callback. Receives one argument.

  • The MicroPython data as a Bytearray
add_modem_status_received_callback(callback)

Adds a callback for the event digi.xbee.reader.ModemStatusReceived.

Parameters:callback (Function) –

the callback. Receives one argument.

add_packet_received_callback(callback)

Adds a callback for the event digi.xbee.reader.PacketReceived.

Parameters:callback (Function) –

the callback. Receives two arguments.

add_socket_data_received_callback(callback)

Adds a callback for the event digi.xbee.reader.SocketDataReceived.

Parameters:callback (Function) –

the callback. Receives two arguments.

  • The socket ID as an Integer.
  • The data received as Bytearray
add_socket_data_received_from_callback(callback)

Adds a callback for the event digi.xbee.reader.SocketDataReceivedFrom.

Parameters:callback (Function) –

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 data received as Bytearray
add_socket_state_received_callback(callback)

Adds a callback for the event digi.xbee.reader.SocketStateReceived.

Parameters:callback (Function) –

the callback. Receives two arguments.

  • The socket ID as an Integer.
  • The state received as a SocketState
add_user_data_relay_received_callback(callback)

Adds a callback for the event digi.xbee.reader.RelayDataReceived.

Parameters:callback (Function) –

the callback. Receives one argument.

apply_changes()

Applies changes via AC command.

Raises:
apply_profile(profile_path, progress_callback=None)

Applies the given XBee profile to the XBee device.

Parameters:
  • profile_path (String) – path of the XBee profile file to apply.
  • progress_callback (Function, optional) –
    function to execute to receive progress information. Receives two
    arguments:
    • The current apply profile task as a String
    • The current apply profile task percentage as an Integer
Raises:
close()

Closes the communication with the XBee device.

This method guarantees that all threads running are stopped and the serial port is closed.

comm_iface

Returns the hardware interface associated to the XBee device.

Returns:the hardware interface associated to the XBee device.
Return type:XBeeCommunicationInterface

See also

classmethod create_xbee_device(comm_port_data)

Creates and returns an XBeeDevice from data of the port to which is connected.

Parameters:
  • comm_port_data (Dictionary) – dictionary with all comm port data needed.
  • dictionary keys are (The) –
    “baudRate” –> Baud rate.
    ”port” –> Port number.
    ”bitSize” –> Bit size.
    ”stopBits” –> Stop bits.
    ”parity” –> Parity.
    ”flowControl” –> Flow control.
    ”timeout” for –> Timeout for synchronous operations (in seconds).
Returns:

the XBee device created.

Return type:

XBeeDevice

Raises:

SerialException – if the port you want to open does not exist or is already opened.

See also

del_bluetooth_data_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.BluetoothDataReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.BluetoothDataReceived event.
del_data_received_callback(callback)

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

del_expl_data_received_callback(callback)

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

del_ip_data_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.IPDataReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.IPDataReceived event.
del_micropython_data_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.MicroPythonDataReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.MicroPythonDataReceived event.
del_modem_status_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.ModemStatusReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.ModemStatusReceived event.
del_packet_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.PacketReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.PacketReceived event.
del_socket_data_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.SocketDataReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.SocketDataReceived event.
del_socket_data_received_from_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.SocketDataReceivedFrom event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.SocketDataReceivedFrom event.
del_socket_state_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.SocketStateReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.SocketStateReceived event.
del_user_data_relay_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.RelayDataReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.RelayDataReceived event.
disable_bluetooth()

Disables the Bluetooth interface of this XBee device.

Note that your device must have Bluetooth Low Energy support to use this method.

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
enable_apply_changes(value)

Sets the apply_changes flag.

Parameters:value (Boolean) – True to enable the apply changes flag, False to disable it.
enable_bluetooth()

Enables the Bluetooth interface of this XBee device.

To work with this interface, you must also configure the Bluetooth password if not done previously. You can use the AbstractXBeeDevice.update_bluetooth_password() method for that purpose.

Note that your device must have Bluetooth Low Energy support to use this method.

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
execute_command(parameter)

Executes the provided command.

Parameters:

parameter (String) – The name of the AT command to be executed.

Raises:
flush_queues()

Flushes the packets queue.

get_16bit_addr()

Deprecated.

This protocol does not have an associated 16-bit address.

get_adc_value(io_line)

Returns the analog value of the provided IO line.

The provided IO line must be previously configured as ADC. To do so, use AbstractXBeeDevice.set_io_configuration() and IOMode.ADC.

Parameters:

io_line (IOLine) – the IO line to get its ADC value.

Returns:

the analog value corresponding to the provided IO line.

Return type:

Integer

Raises:

See also

get_api_output_mode()

Deprecated since version 1.3: Use get_api_output_mode_value()

Returns the API output mode of the XBee device.

The API output mode determines the format that the received data is output through the serial interface of the XBee device.

Returns:

the API output mode of the XBee device.

Return type:

APIOutputMode

Raises:

See also

get_api_output_mode_value()

Returns the API output mode of the XBee.

The API output mode determines the format that the received data is output through the serial interface of the XBee.

Returns:

the parameter value.

Return type:

Bytearray

Raises:
get_bluetooth_mac_addr()

Reads and returns the EUI-48 Bluetooth MAC address of this XBee device in a format such as 00112233AABB.

Note that your device must have Bluetooth Low Energy support to use this method.

Returns:

The Bluetooth MAC address.

Return type:

String

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
get_current_frame_id()

Returns the last used frame ID.

Returns:the last used frame ID.
Return type:Integer
get_dest_address()

Deprecated.

Operation not supported in this protocol. Use IPDevice.get_dest_ip_addr() instead. This method will raise an AttributeError.

get_dest_ip_addr()

Returns the destination IP address.

Returns:

The configured destination IP address.

Return type:

ipaddress.IPv4Address

Raises:

See also

ipaddress.IPv4Address
get_dio_value(io_line)

Returns the digital value of the provided IO line.

The provided IO line must be previously configured as digital I/O. To do so, use AbstractXBeeDevice.set_io_configuration().

Parameters:

io_line (IOLine) – the DIO line to gets its digital value.

Returns:

current value of the provided IO line.

Return type:

IOValue

Raises:

See also

get_firmware_version()

Returns the firmware version of the XBee device.

Returns:the hardware version of the XBee device.
Return type:Bytearray
get_hardware_version()

Returns the hardware version of the XBee device.

Returns:the hardware version of the XBee device.
Return type:HardwareVersion

See also

get_io_configuration(io_line)

Returns the configuration of the provided IO line.

Parameters:

io_line (IOLine) – the io line to configure.

Returns:

the IO mode of the IO line provided.

Return type:

IOMode

Raises:
get_ip_addr()

Returns the IP address of this IP device.

To refresh this value use the method IPDevice.read_device_info().

Returns:The IP address of this IP device.
Return type:ipaddress.IPv4Address

See also

ipaddress.IPv4Address
get_network()

Deprecated.

This protocol does not support the network functionality.

get_next_frame_id()

Returns the next frame ID of the XBee device.

Returns:The next frame ID of the XBee device.
Return type:Integer
get_pan_id()

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

get_parameter(param, parameter_value=None)

Override.

get_pwm_duty_cycle(io_line)

Returns the PWM duty cycle in % corresponding to the provided IO line.

Parameters:

io_line (IOLine) – the IO line to get its PWM duty cycle.

Returns:

the PWM duty cycle of the given IO line or None if the response is empty.

Return type:

Integer

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – if the response is not as expected.
  • ValueError – if the passed IO_LINE has no PWM capability.

See also

get_role()

Gets the XBee role.

Returns:the role of the XBee.
Return type:digi.xbee.models.protocol.Role
get_sync_ops_timeout()

Returns the serial port read timeout.

Returns:the serial port read timeout in seconds.
Return type:Integer
get_xbee_device_callbacks()

Returns this XBee internal callbacks for process received packets.

This method is called by the PacketListener associated with this XBee to get its callbacks. These callbacks will be executed before user callbacks.

Returns:PacketReceived
has_explicit_packets()

Returns whether the XBee device’s queue has explicit packets or not. This do not include non-explicit packets.

Returns:True if this XBee device’s queue has explicit packets, False otherwise.
Return type:Boolean
has_packets()

Returns whether the XBee device’s queue has packets or not. This do not include explicit packets.

Returns:True if this XBee device’s queue has packets, False otherwise.
Return type:Boolean
is_apply_changes_enabled()

Returns whether the apply_changes flag is enabled or not.

Returns:True if the apply_changes flag is enabled, False otherwise.
Return type:Boolean
is_open()

Returns whether this XBee device is open or not.

Returns:Boolean. True if this XBee device is open, False otherwise.
is_remote()

Override method.

log

Returns the XBee device log.

Returns:the XBee device logger.
Return type:Logger
operating_mode

Returns this XBee device’s operating mode.

Returns:OperatingMode. This XBee device’s operating mode.
read_data(timeout=None, explicit=False)

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

read_data_from(remote_xbee_device, timeout=None, explicit=False)

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

read_io_sample()

Returns an IO sample from the XBee device containing the value of all enabled digital IO and analog input channels.

Returns:

the IO sample read from the XBee device.

Return type:

IOSample

Raises:

See also

read_ip_data(timeout=3)

Reads new IP data received by this XBee device during the provided timeout.

This method blocks until new IP data is received or the provided timeout expires.

For non-blocking operations, register a callback and use the method IPDevice.add_ip_data_received_callback().

Before reading IP data you need to start listening for incoming IP data at a specific port. Use the method IPDevice.start_listening() for that purpose. When finished, you can use the method IPDevice.stop_listening() to stop listening for incoming IP data.

Parameters:timeout (Integer, optional) – The time to wait for new IP data in seconds.
Returns:IP message, None if this device did not receive new data.
Return type:IPMessage
Raises:ValueError – if timeout is less than 0.
read_ip_data_from(ip_addr, timeout=3)

Reads new IP data received from the given IP address during the provided timeout.

This method blocks until new IP data from the provided IP address is received or the given timeout expires.

For non-blocking operations, register a callback and use the method IPDevice.add_ip_data_received_callback().

Before reading IP data you need to start listening for incoming IP data at a specific port. Use the method IPDevice.start_listening() for that purpose. When finished, you can use the method IPDevice.stop_listening() to stop listening for incoming IP data.

Parameters:
  • ip_addr (ipaddress.IPv4Address) – The IP address to read data from.
  • timeout (Integer, optional) – The time to wait for new IP data in seconds.
Returns:

IP message, None if this device did not

receive new data from the provided IP address.

Return type:

IPMessage

Raises:

ValueError – if timeout is less than 0.

reset()

Override method.

send_bluetooth_data(data)

Sends the given data to the Bluetooth interface using a User Data Relay frame.

Parameters:

data (Bytearray) – Data to send.

Raises:
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – if there is any problem sending the data.
send_data(remote_xbee_device, data, transmit_options=0)

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

send_data_async(remote_xbee_device, data, transmit_options=0)

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

send_data_broadcast(data, transmit_options=0)

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

send_ip_data(ip_addr, dest_port, protocol, data, close_socket=False)

Sends the provided IP data to the given IP address and port using the specified IP protocol. For TCP and TCP SSL protocols, you can also indicate if the socket should be closed when data is sent.

This method blocks till a success or error response arrives or the configured receive timeout expires.

Parameters:
  • ip_addr (ipaddress.IPv4Address) – The IP address to send IP data to.
  • dest_port (Integer) – The destination port of the transmission.
  • protocol (IPProtocol) – The IP protocol used for the transmission.
  • data (String or Bytearray) – The IP data to be sent.
  • close_socket (Boolean, optional) – True to close the socket just after the transmission. False to keep it open. Default to False.
Raises:
  • ValueError – if ip_addr is None.
  • ValueError – if protocol is None.
  • ValueError – if data is None.
  • ValueError – if dest_port is less than 0 or greater than 65535.
  • OperationNotSupportedException – if the device is remote.
  • TimeoutException – if there is a timeout sending the data.
  • XBeeException – if there is any other XBee related exception.
send_ip_data_async(ip_addr, dest_port, protocol, data, close_socket=False)

Sends the provided IP data to the given IP address and port asynchronously using the specified IP protocol. For TCP and TCP SSL protocols, you can also indicate if the socket should be closed when data is sent.

Asynchronous transmissions do not wait for answer from the remote device or for transmit status packet.

Parameters:
  • ip_addr (ipaddress.IPv4Address) – The IP address to send IP data to.
  • dest_port (Integer) – The destination port of the transmission.
  • protocol (IPProtocol) – The IP protocol used for the transmission.
  • data (String or Bytearray) – The IP data to be sent.
  • close_socket (Boolean, optional) – True to close the socket just after the transmission. False to keep it open. Default to False.
Raises:
  • ValueError – if ip_addr is None.
  • ValueError – if protocol is None.
  • ValueError – if data is None.
  • ValueError – if dest_port is less than 0 or greater than 65535.
  • OperationNotSupportedException – if the device is remote.
  • XBeeException – if there is any other XBee related exception.
send_ip_data_broadcast(dest_port, data)

Sends the provided IP data to all clients.

This method blocks till a success or error transmit status arrives or the configured receive timeout expires.

Parameters:
  • dest_port (Integer) – The destination port of the transmission.
  • data (String or Bytearray) – The IP data to be sent.
Raises:
  • ValueError – if data is None.
  • ValueError – if dest_port is less than 0 or greater than 65535.
  • TimeoutException – if there is a timeout sending the data.
  • XBeeException – if there is any other XBee related exception.
send_micropython_data(data)

Sends the given data to the MicroPython interface using a User Data Relay frame.

Parameters:

data (Bytearray) – Data to send.

Raises:
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – if there is any problem sending the data.
send_packet(packet, sync=False)

Override method.

See also

AbstractXBeeDevice._send_packet()
send_packet_sync_and_get_response(packet_to_send, timeout=None)

Override method.

See also

AbstractXBeeDevice._send_packet_sync_and_get_response()
send_user_data_relay(local_interface, data)

Sends the given data to the given XBee local interface.

Parameters:
  • local_interface (XBeeLocalInterface) – Destination XBee local interface.
  • data (Bytearray) – Data to send.
Raises:
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ValueError – if local_interface is None.
  • XBeeException – if there is any problem sending the User Data Relay.
serial_port

Returns the serial port associated to the XBee device, if any.

Returns:
the serial port associated to the XBee device. Returns None if the local XBee
does not use serial communication.
Return type:XBeeSerialPort

See also

set_16bit_addr(value)

Sets the 16-bit address of the XBee device.

Parameters:

value (XBee16BitAddress) – the new 16-bit address of the XBee device.

Raises:
set_api_output_mode(api_output_mode)

Deprecated since version 1.3: Use set_api_output_mode_value()

Sets the API output mode of the XBee device.

Parameters:

api_output_mode (APIOutputMode) – the new API output mode of the XBee device.

Raises:

See also

set_api_output_mode_value(api_output_mode)

Sets the API output mode of the XBee.

Parameters:

api_output_mode (Integer) – new API output mode options. Calculate this value using the method digi.xbee.models.mode.APIOutputModeBit.calculate_api_output_mode_value() with a set of digi.xbee.models.mode.APIOutputModeBit.

Raises:
set_dest_address(addr)

Deprecated.

Operation not supported in this protocol. Use IPDevice.set_dest_ip_addr() instead. This method will raise an AttributeError.

set_dest_ip_addr(address)

Sets the destination IP address.

Parameters:

address (ipaddress.IPv4Address) – Destination IP address.

Raises:
  • ValueError – if address is None.
  • TimeoutException – if there is a timeout setting the destination IP address.
  • XBeeException – if there is any other XBee related exception.

See also

ipaddress.IPv4Address
set_dio_value(io_line, io_value)

Sets the digital value (high or low) to the provided IO line.

Parameters:
  • io_line (IOLine) – the digital IO line to sets its value.
  • io_value (IOValue) – the IO value to set to the IO line.
Raises:

See also

set_io_configuration(io_line, io_mode)

Sets the configuration of the provided IO line.

Parameters:
  • io_line (IOLine) – the IO line to configure.
  • io_mode (IOMode) – the IO mode to set to the IO line.
Raises:

See also

set_pan_id(value)

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

set_parameter(param, value)

Override.

See:
AbstractXBeeDevice.set_parameter()
set_pwm_duty_cycle(io_line, cycle)

Sets the duty cycle in % of the provided IO line.

The provided IO line must be PWM-capable, previously configured as PWM output.

Parameters:
  • io_line (IOLine) – the IO Line to be assigned.
  • cycle (Integer) – duty cycle in % to be assigned. Must be between 0 and 100.
Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – if the response is not as expected.
  • ValueError – if the given IO line does not have PWM capability or cycle is not between 0 and 100.

See also

set_sync_ops_timeout(sync_ops_timeout)

Sets the serial port read timeout.

Parameters:sync_ops_timeout (Integer) – the read timeout, expressed in seconds.
start_listening(source_port)

Starts listening for incoming IP transmissions in the provided port.

Parameters:

source_port (Integer) – Port to listen for incoming transmissions.

Raises:
  • ValueError – if source_port is less than 0 or greater than 65535.
  • TimeoutException – if there is a timeout setting the source port.
  • XBeeException – if there is any other XBee related exception.
stop_listening()

Stops listening for incoming IP transmissions.

Raises:
update_bluetooth_password(new_password)

Changes the password of this Bluetooth device with the new one provided.

Note that your device must have Bluetooth Low Energy support to use this method.

Parameters:

new_password (String) – New Bluetooth password.

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
update_device_data_from(device)

Updates the current device reference with the data provided for the given device.

This is only for internal use.

Parameters:device (AbstractXBeeDevice) – the XBee device to get the data from.
Returns:True if the device data has been updated, False otherwise.
Return type:Boolean
update_firmware(xml_firmware_file, xbee_firmware_file=None, bootloader_firmware_file=None, timeout=None, progress_callback=None)

Performs a firmware update operation of the device.

Parameters:
  • xml_firmware_file (String) – path of the XML file that describes the firmware to upload.
  • xbee_firmware_file (String, optional) – location of the XBee binary firmware file.
  • bootloader_firmware_file (String, optional) – location of the bootloader binary firmware file.
  • timeout (Integer, optional) – the maximum time to wait for target read operations during the update process.
  • progress_callback (Function, optional) –
    function to execute to receive progress information. Receives two
    arguments:
    • The current update task as a String
    • The current update task percentage as an Integer
Raises:
write_changes()

Writes configurable parameter values to the non-volatile memory of the XBee device so that parameter modifications persist through subsequent resets.

Parameters values remain in this device’s memory until overwritten by subsequent use of this method.

If changes are made without writing them to non-volatile memory, the module reverts back to previously saved parameters the next time the module is powered-on.

Writing the parameter modifications does not mean those values are immediately applied, this depends on the status of the ‘apply configuration changes’ option. Use method is_apply_configuration_changes_enabled() to get its status and enable_apply_configuration_changes() to enable/disable the option. If it is disabled, method apply_changes() can be used in order to manually apply the changes.

Raises:
class digi.xbee.devices.LPWANDevice(port=None, baud_rate=None, data_bits=<sphinx.ext.autodoc.importer._MockObject object>, stop_bits=<sphinx.ext.autodoc.importer._MockObject object>, parity=<sphinx.ext.autodoc.importer._MockObject object>, flow_control=<FlowControl.NONE: None>, _sync_ops_timeout=4, comm_iface=None)[source]

Bases: digi.xbee.devices.CellularDevice

This class provides common functionality for XBee Low-Power Wide-Area Network devices.

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

Parameters:
  • port (Integer or String) – serial port identifier. Integer: number of XBee device, numbering starts at zero. Device name: depending on operating system. e.g. ‘/dev/ttyUSB0’ on ‘GNU/Linux’ or ‘COM3’ on Windows.
  • baud_rate (Integer) – the serial port baud rate.
  • (Integer, default (_sync_ops_timeout) – serial.EIGHTBITS): comm port bitsize.
  • (Integer, defaultserial.STOPBITS_ONE): comm port stop bits.
  • (Character, default (parity) – serial.PARITY_NONE): comm port parity.
  • (Integer, defaultFlowControl.NONE): comm port flow control.
  • (Integer, default – 3): the read timeout (in seconds).
  • comm_iface (XBeeCommunicationInterface) – the communication interface.

:raises All exceptions raised by XBeeDevice.__init__() constructor.:

See also

CellularDevice.__init__()
send_ip_data(ip_addr, dest_port, protocol, data, close_socket=False)[source]

Sends the provided IP data to the given IP address and port using the specified IP protocol.

This method blocks till a success or error response arrives or the configured receive timeout expires.

Parameters:
  • ip_addr (ipaddress.IPv4Address) – The IP address to send IP data to.
  • dest_port (Integer) – The destination port of the transmission.
  • protocol (IPProtocol) – The IP protocol used for the transmission.
  • data (String or Bytearray) – The IP data to be sent.
  • close_socket (Boolean, optional) – Must be False.
Raises:

ValueError – if protocol is not UDP.

send_ip_data_async(ip_addr, dest_port, protocol, data, close_socket=False)[source]

Sends the provided IP data to the given IP address and port asynchronously using the specified IP protocol.

Asynchronous transmissions do not wait for answer from the remote device or for transmit status packet.

Parameters:
  • ip_addr (ipaddress.IPv4Address) – The IP address to send IP data to.
  • dest_port (Integer) – The destination port of the transmission.
  • protocol (IPProtocol) – The IP protocol used for the transmission.
  • data (String or Bytearray) – The IP data to be sent.
  • close_socket (Boolean, optional) – Must be False.
Raises:

ValueError – if protocol is not UDP.

add_sms_callback(callback)[source]

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

del_sms_callback(callback)[source]

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

send_sms(phone_number, data)[source]

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

send_sms_async(phone_number, data)[source]

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

add_bluetooth_data_received_callback(callback)

Adds a callback for the event digi.xbee.reader.BluetoothDataReceived.

Parameters:callback (Function) –

the callback. Receives one argument.

  • The Bluetooth data as a Bytearray
add_data_received_callback(callback)

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

add_expl_data_received_callback(callback)

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

add_io_sample_received_callback(callback)

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

add_ip_data_received_callback(callback)

Adds a callback for the event digi.xbee.reader.IPDataReceived.

Parameters:callback (Function) –

the callback. Receives one argument.

add_micropython_data_received_callback(callback)

Adds a callback for the event digi.xbee.reader.MicroPythonDataReceived.

Parameters:callback (Function) –

the callback. Receives one argument.

  • The MicroPython data as a Bytearray
add_modem_status_received_callback(callback)

Adds a callback for the event digi.xbee.reader.ModemStatusReceived.

Parameters:callback (Function) –

the callback. Receives one argument.

add_packet_received_callback(callback)

Adds a callback for the event digi.xbee.reader.PacketReceived.

Parameters:callback (Function) –

the callback. Receives two arguments.

add_socket_data_received_callback(callback)

Adds a callback for the event digi.xbee.reader.SocketDataReceived.

Parameters:callback (Function) –

the callback. Receives two arguments.

  • The socket ID as an Integer.
  • The data received as Bytearray
add_socket_data_received_from_callback(callback)

Adds a callback for the event digi.xbee.reader.SocketDataReceivedFrom.

Parameters:callback (Function) –

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 data received as Bytearray
add_socket_state_received_callback(callback)

Adds a callback for the event digi.xbee.reader.SocketStateReceived.

Parameters:callback (Function) –

the callback. Receives two arguments.

  • The socket ID as an Integer.
  • The state received as a SocketState
add_user_data_relay_received_callback(callback)

Adds a callback for the event digi.xbee.reader.RelayDataReceived.

Parameters:callback (Function) –

the callback. Receives one argument.

apply_changes()

Applies changes via AC command.

Raises:
apply_profile(profile_path, progress_callback=None)

Applies the given XBee profile to the XBee device.

Parameters:
  • profile_path (String) – path of the XBee profile file to apply.
  • progress_callback (Function, optional) –
    function to execute to receive progress information. Receives two
    arguments:
    • The current apply profile task as a String
    • The current apply profile task percentage as an Integer
Raises:
close()

Closes the communication with the XBee device.

This method guarantees that all threads running are stopped and the serial port is closed.

comm_iface

Returns the hardware interface associated to the XBee device.

Returns:the hardware interface associated to the XBee device.
Return type:XBeeCommunicationInterface

See also

classmethod create_xbee_device(comm_port_data)

Creates and returns an XBeeDevice from data of the port to which is connected.

Parameters:
  • comm_port_data (Dictionary) – dictionary with all comm port data needed.
  • dictionary keys are (The) –
    “baudRate” –> Baud rate.
    ”port” –> Port number.
    ”bitSize” –> Bit size.
    ”stopBits” –> Stop bits.
    ”parity” –> Parity.
    ”flowControl” –> Flow control.
    ”timeout” for –> Timeout for synchronous operations (in seconds).
Returns:

the XBee device created.

Return type:

XBeeDevice

Raises:

SerialException – if the port you want to open does not exist or is already opened.

See also

del_bluetooth_data_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.BluetoothDataReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.BluetoothDataReceived event.
del_data_received_callback(callback)

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

del_expl_data_received_callback(callback)

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

del_io_sample_received_callback(callback)

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

del_ip_data_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.IPDataReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.IPDataReceived event.
del_micropython_data_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.MicroPythonDataReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.MicroPythonDataReceived event.
del_modem_status_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.ModemStatusReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.ModemStatusReceived event.
del_packet_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.PacketReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.PacketReceived event.
del_socket_data_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.SocketDataReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.SocketDataReceived event.
del_socket_data_received_from_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.SocketDataReceivedFrom event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.SocketDataReceivedFrom event.
del_socket_state_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.SocketStateReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.SocketStateReceived event.
del_user_data_relay_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.RelayDataReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.RelayDataReceived event.
disable_bluetooth()

Disables the Bluetooth interface of this XBee device.

Note that your device must have Bluetooth Low Energy support to use this method.

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
enable_apply_changes(value)

Sets the apply_changes flag.

Parameters:value (Boolean) – True to enable the apply changes flag, False to disable it.
enable_bluetooth()

Enables the Bluetooth interface of this XBee device.

To work with this interface, you must also configure the Bluetooth password if not done previously. You can use the AbstractXBeeDevice.update_bluetooth_password() method for that purpose.

Note that your device must have Bluetooth Low Energy support to use this method.

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
execute_command(parameter)

Executes the provided command.

Parameters:

parameter (String) – The name of the AT command to be executed.

Raises:
flush_queues()

Flushes the packets queue.

get_16bit_addr()

Deprecated.

This protocol does not have an associated 16-bit address.

get_64bit_addr()

Deprecated.

Cellular protocol does not have an associated 64-bit address.

get_adc_value(io_line)

Returns the analog value of the provided IO line.

The provided IO line must be previously configured as ADC. To do so, use AbstractXBeeDevice.set_io_configuration() and IOMode.ADC.

Parameters:

io_line (IOLine) – the IO line to get its ADC value.

Returns:

the analog value corresponding to the provided IO line.

Return type:

Integer

Raises:

See also

get_api_output_mode()

Deprecated since version 1.3: Use get_api_output_mode_value()

Returns the API output mode of the XBee device.

The API output mode determines the format that the received data is output through the serial interface of the XBee device.

Returns:

the API output mode of the XBee device.

Return type:

APIOutputMode

Raises:

See also

get_api_output_mode_value()

Returns the API output mode of the XBee.

The API output mode determines the format that the received data is output through the serial interface of the XBee.

Returns:

the parameter value.

Return type:

Bytearray

Raises:
get_bluetooth_mac_addr()

Reads and returns the EUI-48 Bluetooth MAC address of this XBee device in a format such as 00112233AABB.

Note that your device must have Bluetooth Low Energy support to use this method.

Returns:

The Bluetooth MAC address.

Return type:

String

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
get_cellular_ai_status()

Returns the current association status of this Cellular device.

It indicates occurrences of errors during the modem initialization and connection.

Returns:

The association indication status of the Cellular device.

Return type:

CellularAssociationIndicationStatus

Raises:
  • TimeoutException – if there is a timeout getting the association indication status.
  • XBeeException – if there is any other XBee related exception.
get_current_frame_id()

Returns the last used frame ID.

Returns:the last used frame ID.
Return type:Integer
get_dest_address()

Deprecated.

Operation not supported in this protocol. Use IPDevice.get_dest_ip_addr() instead. This method will raise an AttributeError.

get_dest_ip_addr()

Returns the destination IP address.

Returns:

The configured destination IP address.

Return type:

ipaddress.IPv4Address

Raises:

See also

ipaddress.IPv4Address
get_dio_value(io_line)

Returns the digital value of the provided IO line.

The provided IO line must be previously configured as digital I/O. To do so, use AbstractXBeeDevice.set_io_configuration().

Parameters:

io_line (IOLine) – the DIO line to gets its digital value.

Returns:

current value of the provided IO line.

Return type:

IOValue

Raises:

See also

get_firmware_version()

Returns the firmware version of the XBee device.

Returns:the hardware version of the XBee device.
Return type:Bytearray
get_hardware_version()

Returns the hardware version of the XBee device.

Returns:the hardware version of the XBee device.
Return type:HardwareVersion

See also

get_imei_addr()

Returns the IMEI address of this Cellular device.

To refresh this value use the method CellularDevice.read_device_info().

Returns:The IMEI address of this Cellular device.
Return type:XBeeIMEIAddress
get_io_configuration(io_line)

Returns the configuration of the provided IO line.

Parameters:

io_line (IOLine) – the io line to configure.

Returns:

the IO mode of the IO line provided.

Return type:

IOMode

Raises:
get_io_sampling_rate()

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

get_ip_addr()

Returns the IP address of this IP device.

To refresh this value use the method IPDevice.read_device_info().

Returns:The IP address of this IP device.
Return type:ipaddress.IPv4Address

See also

ipaddress.IPv4Address
get_network()

Deprecated.

This protocol does not support the network functionality.

get_next_frame_id()

Returns the next frame ID of the XBee device.

Returns:The next frame ID of the XBee device.
Return type:Integer
get_node_id()

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

get_pan_id()

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

get_parameter(param, parameter_value=None)

Override.

get_power_level()

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

get_protocol()

Override.

get_pwm_duty_cycle(io_line)

Returns the PWM duty cycle in % corresponding to the provided IO line.

Parameters:

io_line (IOLine) – the IO line to get its PWM duty cycle.

Returns:

the PWM duty cycle of the given IO line or None if the response is empty.

Return type:

Integer

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – if the response is not as expected.
  • ValueError – if the passed IO_LINE has no PWM capability.

See also

get_role()

Gets the XBee role.

Returns:the role of the XBee.
Return type:digi.xbee.models.protocol.Role
get_socket_info(socket_id)

Returns the information of the socket with the given socket ID.

Parameters:

socket_id (Integer) – ID of the socket.

Returns:

The socket information, or None if the socket with that ID does not exist.

Return type:

SocketInfo

Raises:
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.

See also

SocketInfo
get_sockets_list()

Returns a list with the IDs of all active (open) sockets.

Returns:

list with the IDs of all active (open) sockets, or empty list if there is not any active socket.

Return type:

List

Raises:
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
get_sync_ops_timeout()

Returns the serial port read timeout.

Returns:the serial port read timeout in seconds.
Return type:Integer
get_xbee_device_callbacks()

Returns this XBee internal callbacks for process received packets.

This method is called by the PacketListener associated with this XBee to get its callbacks. These callbacks will be executed before user callbacks.

Returns:PacketReceived
has_explicit_packets()

Returns whether the XBee device’s queue has explicit packets or not. This do not include non-explicit packets.

Returns:True if this XBee device’s queue has explicit packets, False otherwise.
Return type:Boolean
has_packets()

Returns whether the XBee device’s queue has packets or not. This do not include explicit packets.

Returns:True if this XBee device’s queue has packets, False otherwise.
Return type:Boolean
is_apply_changes_enabled()

Returns whether the apply_changes flag is enabled or not.

Returns:True if the apply_changes flag is enabled, False otherwise.
Return type:Boolean
is_connected()

Returns whether the device is connected to the Internet or not.

Returns:

True if the device is connected to the Internet, False otherwise.

Return type:

Boolean

Raises:
  • TimeoutException – if there is a timeout getting the association indication status.
  • XBeeException – if there is any other XBee related exception.
is_open()

Returns whether this XBee device is open or not.

Returns:Boolean. True if this XBee device is open, False otherwise.
is_remote()

Override method.

log

Returns the XBee device log.

Returns:the XBee device logger.
Return type:Logger
open(force_settings=False)

Override.

Raises:
  • TimeoutException – If there is any problem with the communication.
  • InvalidOperatingModeException – If the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – If the protocol is invalid or if the XBee device is already open.
operating_mode

Returns this XBee device’s operating mode.

Returns:OperatingMode. This XBee device’s operating mode.
read_data(timeout=None, explicit=False)

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

read_data_from(remote_xbee_device, timeout=None, explicit=False)

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

read_device_info(init=True)

Override.

See also

XBeeDevice.read_device _info()
read_io_sample()

Returns an IO sample from the XBee device containing the value of all enabled digital IO and analog input channels.

Returns:

the IO sample read from the XBee device.

Return type:

IOSample

Raises:

See also

read_ip_data(timeout=3)

Reads new IP data received by this XBee device during the provided timeout.

This method blocks until new IP data is received or the provided timeout expires.

For non-blocking operations, register a callback and use the method IPDevice.add_ip_data_received_callback().

Before reading IP data you need to start listening for incoming IP data at a specific port. Use the method IPDevice.start_listening() for that purpose. When finished, you can use the method IPDevice.stop_listening() to stop listening for incoming IP data.

Parameters:timeout (Integer, optional) – The time to wait for new IP data in seconds.
Returns:IP message, None if this device did not receive new data.
Return type:IPMessage
Raises:ValueError – if timeout is less than 0.
read_ip_data_from(ip_addr, timeout=3)

Reads new IP data received from the given IP address during the provided timeout.

This method blocks until new IP data from the provided IP address is received or the given timeout expires.

For non-blocking operations, register a callback and use the method IPDevice.add_ip_data_received_callback().

Before reading IP data you need to start listening for incoming IP data at a specific port. Use the method IPDevice.start_listening() for that purpose. When finished, you can use the method IPDevice.stop_listening() to stop listening for incoming IP data.

Parameters:
  • ip_addr (ipaddress.IPv4Address) – The IP address to read data from.
  • timeout (Integer, optional) – The time to wait for new IP data in seconds.
Returns:

IP message, None if this device did not

receive new data from the provided IP address.

Return type:

IPMessage

Raises:

ValueError – if timeout is less than 0.

reset()

Override method.

send_bluetooth_data(data)

Sends the given data to the Bluetooth interface using a User Data Relay frame.

Parameters:

data (Bytearray) – Data to send.

Raises:
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – if there is any problem sending the data.
send_data(remote_xbee_device, data, transmit_options=0)

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

send_data_async(remote_xbee_device, data, transmit_options=0)

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

send_data_broadcast(data, transmit_options=0)

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

send_ip_data_broadcast(dest_port, data)

Sends the provided IP data to all clients.

This method blocks till a success or error transmit status arrives or the configured receive timeout expires.

Parameters:
  • dest_port (Integer) – The destination port of the transmission.
  • data (String or Bytearray) – The IP data to be sent.
Raises:
  • ValueError – if data is None.
  • ValueError – if dest_port is less than 0 or greater than 65535.
  • TimeoutException – if there is a timeout sending the data.
  • XBeeException – if there is any other XBee related exception.
send_micropython_data(data)

Sends the given data to the MicroPython interface using a User Data Relay frame.

Parameters:

data (Bytearray) – Data to send.

Raises:
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – if there is any problem sending the data.
send_packet(packet, sync=False)

Override method.

See also

AbstractXBeeDevice._send_packet()
send_packet_sync_and_get_response(packet_to_send, timeout=None)

Override method.

See also

AbstractXBeeDevice._send_packet_sync_and_get_response()
send_user_data_relay(local_interface, data)

Sends the given data to the given XBee local interface.

Parameters:
  • local_interface (XBeeLocalInterface) – Destination XBee local interface.
  • data (Bytearray) – Data to send.
Raises:
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ValueError – if local_interface is None.
  • XBeeException – if there is any problem sending the User Data Relay.
serial_port

Returns the serial port associated to the XBee device, if any.

Returns:
the serial port associated to the XBee device. Returns None if the local XBee
does not use serial communication.
Return type:XBeeSerialPort

See also

set_16bit_addr(value)

Sets the 16-bit address of the XBee device.

Parameters:

value (XBee16BitAddress) – the new 16-bit address of the XBee device.

Raises:
set_api_output_mode(api_output_mode)

Deprecated since version 1.3: Use set_api_output_mode_value()

Sets the API output mode of the XBee device.

Parameters:

api_output_mode (APIOutputMode) – the new API output mode of the XBee device.

Raises:

See also

set_api_output_mode_value(api_output_mode)

Sets the API output mode of the XBee.

Parameters:

api_output_mode (Integer) – new API output mode options. Calculate this value using the method digi.xbee.models.mode.APIOutputModeBit.calculate_api_output_mode_value() with a set of digi.xbee.models.mode.APIOutputModeBit.

Raises:
set_dest_address(addr)

Deprecated.

Operation not supported in this protocol. Use IPDevice.set_dest_ip_addr() instead. This method will raise an AttributeError.

set_dest_ip_addr(address)

Sets the destination IP address.

Parameters:

address (ipaddress.IPv4Address) – Destination IP address.

Raises:
  • ValueError – if address is None.
  • TimeoutException – if there is a timeout setting the destination IP address.
  • XBeeException – if there is any other XBee related exception.

See also

ipaddress.IPv4Address
set_dio_change_detection(io_lines_set)

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

set_dio_value(io_line, io_value)

Sets the digital value (high or low) to the provided IO line.

Parameters:
  • io_line (IOLine) – the digital IO line to sets its value.
  • io_value (IOValue) – the IO value to set to the IO line.
Raises:

See also

set_io_configuration(io_line, io_mode)

Sets the configuration of the provided IO line.

Parameters:
  • io_line (IOLine) – the IO line to configure.
  • io_mode (IOMode) – the IO mode to set to the IO line.
Raises:

See also

set_io_sampling_rate(rate)

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

set_node_id(node_id)

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

set_pan_id(value)

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

set_parameter(param, value)

Override.

See:
AbstractXBeeDevice.set_parameter()
set_power_level(power_level)

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

set_pwm_duty_cycle(io_line, cycle)

Sets the duty cycle in % of the provided IO line.

The provided IO line must be PWM-capable, previously configured as PWM output.

Parameters:
  • io_line (IOLine) – the IO Line to be assigned.
  • cycle (Integer) – duty cycle in % to be assigned. Must be between 0 and 100.
Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – if the response is not as expected.
  • ValueError – if the given IO line does not have PWM capability or cycle is not between 0 and 100.

See also

set_sync_ops_timeout(sync_ops_timeout)

Sets the serial port read timeout.

Parameters:sync_ops_timeout (Integer) – the read timeout, expressed in seconds.
start_listening(source_port)

Starts listening for incoming IP transmissions in the provided port.

Parameters:

source_port (Integer) – Port to listen for incoming transmissions.

Raises:
  • ValueError – if source_port is less than 0 or greater than 65535.
  • TimeoutException – if there is a timeout setting the source port.
  • XBeeException – if there is any other XBee related exception.
stop_listening()

Stops listening for incoming IP transmissions.

Raises:
update_bluetooth_password(new_password)

Changes the password of this Bluetooth device with the new one provided.

Note that your device must have Bluetooth Low Energy support to use this method.

Parameters:

new_password (String) – New Bluetooth password.

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
update_device_data_from(device)

Updates the current device reference with the data provided for the given device.

This is only for internal use.

Parameters:device (AbstractXBeeDevice) – the XBee device to get the data from.
Returns:True if the device data has been updated, False otherwise.
Return type:Boolean
update_firmware(xml_firmware_file, xbee_firmware_file=None, bootloader_firmware_file=None, timeout=None, progress_callback=None)

Performs a firmware update operation of the device.

Parameters:
  • xml_firmware_file (String) – path of the XML file that describes the firmware to upload.
  • xbee_firmware_file (String, optional) – location of the XBee binary firmware file.
  • bootloader_firmware_file (String, optional) – location of the bootloader binary firmware file.
  • timeout (Integer, optional) – the maximum time to wait for target read operations during the update process.
  • progress_callback (Function, optional) –
    function to execute to receive progress information. Receives two
    arguments:
    • The current update task as a String
    • The current update task percentage as an Integer
Raises:
write_changes()

Writes configurable parameter values to the non-volatile memory of the XBee device so that parameter modifications persist through subsequent resets.

Parameters values remain in this device’s memory until overwritten by subsequent use of this method.

If changes are made without writing them to non-volatile memory, the module reverts back to previously saved parameters the next time the module is powered-on.

Writing the parameter modifications does not mean those values are immediately applied, this depends on the status of the ‘apply configuration changes’ option. Use method is_apply_configuration_changes_enabled() to get its status and enable_apply_configuration_changes() to enable/disable the option. If it is disabled, method apply_changes() can be used in order to manually apply the changes.

Raises:
class digi.xbee.devices.NBIoTDevice(port=None, baud_rate=None, data_bits=<sphinx.ext.autodoc.importer._MockObject object>, stop_bits=<sphinx.ext.autodoc.importer._MockObject object>, parity=<sphinx.ext.autodoc.importer._MockObject object>, flow_control=<FlowControl.NONE: None>, _sync_ops_timeout=4, comm_iface=None)[source]

Bases: digi.xbee.devices.LPWANDevice

This class represents a local NB-IoT device.

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

Parameters:
  • port (Integer or String) – serial port identifier. Integer: number of XBee device, numbering starts at zero. Device name: depending on operating system. e.g. ‘/dev/ttyUSB0’ on ‘GNU/Linux’ or ‘COM3’ on Windows.
  • baud_rate (Integer) – the serial port baud rate.
  • (Integer, default (_sync_ops_timeout) – serial.EIGHTBITS): comm port bitsize.
  • (Integer, defaultserial.STOPBITS_ONE): comm port stop bits.
  • (Character, default (parity) – serial.PARITY_NONE): comm port parity.
  • (Integer, defaultFlowControl.NONE): comm port flow control.
  • (Integer, default – 3): the read timeout (in seconds).
  • comm_iface (XBeeCommunicationInterface) – the communication interface.

:raises All exceptions raised by XBeeDevice.__init__() constructor.:

See also

LPWANDevice.__init__()
open(force_settings=False)[source]

Override.

Raises:
  • TimeoutException – If there is any problem with the communication.
  • InvalidOperatingModeException – If the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – If the protocol is invalid or if the XBee device is already open.
get_protocol()[source]

Override.

add_bluetooth_data_received_callback(callback)

Adds a callback for the event digi.xbee.reader.BluetoothDataReceived.

Parameters:callback (Function) –

the callback. Receives one argument.

  • The Bluetooth data as a Bytearray
add_data_received_callback(callback)

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

add_expl_data_received_callback(callback)

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

add_io_sample_received_callback(callback)

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

add_ip_data_received_callback(callback)

Adds a callback for the event digi.xbee.reader.IPDataReceived.

Parameters:callback (Function) –

the callback. Receives one argument.

add_micropython_data_received_callback(callback)

Adds a callback for the event digi.xbee.reader.MicroPythonDataReceived.

Parameters:callback (Function) –

the callback. Receives one argument.

  • The MicroPython data as a Bytearray
add_modem_status_received_callback(callback)

Adds a callback for the event digi.xbee.reader.ModemStatusReceived.

Parameters:callback (Function) –

the callback. Receives one argument.

add_packet_received_callback(callback)

Adds a callback for the event digi.xbee.reader.PacketReceived.

Parameters:callback (Function) –

the callback. Receives two arguments.

add_sms_callback(callback)

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

add_socket_data_received_callback(callback)

Adds a callback for the event digi.xbee.reader.SocketDataReceived.

Parameters:callback (Function) –

the callback. Receives two arguments.

  • The socket ID as an Integer.
  • The data received as Bytearray
add_socket_data_received_from_callback(callback)

Adds a callback for the event digi.xbee.reader.SocketDataReceivedFrom.

Parameters:callback (Function) –

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 data received as Bytearray
add_socket_state_received_callback(callback)

Adds a callback for the event digi.xbee.reader.SocketStateReceived.

Parameters:callback (Function) –

the callback. Receives two arguments.

  • The socket ID as an Integer.
  • The state received as a SocketState
add_user_data_relay_received_callback(callback)

Adds a callback for the event digi.xbee.reader.RelayDataReceived.

Parameters:callback (Function) –

the callback. Receives one argument.

apply_changes()

Applies changes via AC command.

Raises:
apply_profile(profile_path, progress_callback=None)

Applies the given XBee profile to the XBee device.

Parameters:
  • profile_path (String) – path of the XBee profile file to apply.
  • progress_callback (Function, optional) –
    function to execute to receive progress information. Receives two
    arguments:
    • The current apply profile task as a String
    • The current apply profile task percentage as an Integer
Raises:
close()

Closes the communication with the XBee device.

This method guarantees that all threads running are stopped and the serial port is closed.

comm_iface

Returns the hardware interface associated to the XBee device.

Returns:the hardware interface associated to the XBee device.
Return type:XBeeCommunicationInterface

See also

classmethod create_xbee_device(comm_port_data)

Creates and returns an XBeeDevice from data of the port to which is connected.

Parameters:
  • comm_port_data (Dictionary) – dictionary with all comm port data needed.
  • dictionary keys are (The) –
    “baudRate” –> Baud rate.
    ”port” –> Port number.
    ”bitSize” –> Bit size.
    ”stopBits” –> Stop bits.
    ”parity” –> Parity.
    ”flowControl” –> Flow control.
    ”timeout” for –> Timeout for synchronous operations (in seconds).
Returns:

the XBee device created.

Return type:

XBeeDevice

Raises:

SerialException – if the port you want to open does not exist or is already opened.

See also

del_bluetooth_data_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.BluetoothDataReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.BluetoothDataReceived event.
del_data_received_callback(callback)

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

del_expl_data_received_callback(callback)

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

del_io_sample_received_callback(callback)

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

del_ip_data_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.IPDataReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.IPDataReceived event.
del_micropython_data_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.MicroPythonDataReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.MicroPythonDataReceived event.
del_modem_status_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.ModemStatusReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.ModemStatusReceived event.
del_packet_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.PacketReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.PacketReceived event.
del_sms_callback(callback)

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

del_socket_data_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.SocketDataReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.SocketDataReceived event.
del_socket_data_received_from_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.SocketDataReceivedFrom event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.SocketDataReceivedFrom event.
del_socket_state_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.SocketStateReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.SocketStateReceived event.
del_user_data_relay_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.RelayDataReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.RelayDataReceived event.
disable_bluetooth()

Disables the Bluetooth interface of this XBee device.

Note that your device must have Bluetooth Low Energy support to use this method.

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
enable_apply_changes(value)

Sets the apply_changes flag.

Parameters:value (Boolean) – True to enable the apply changes flag, False to disable it.
enable_bluetooth()

Enables the Bluetooth interface of this XBee device.

To work with this interface, you must also configure the Bluetooth password if not done previously. You can use the AbstractXBeeDevice.update_bluetooth_password() method for that purpose.

Note that your device must have Bluetooth Low Energy support to use this method.

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
execute_command(parameter)

Executes the provided command.

Parameters:

parameter (String) – The name of the AT command to be executed.

Raises:
flush_queues()

Flushes the packets queue.

get_16bit_addr()

Deprecated.

This protocol does not have an associated 16-bit address.

get_64bit_addr()

Deprecated.

Cellular protocol does not have an associated 64-bit address.

get_adc_value(io_line)

Returns the analog value of the provided IO line.

The provided IO line must be previously configured as ADC. To do so, use AbstractXBeeDevice.set_io_configuration() and IOMode.ADC.

Parameters:

io_line (IOLine) – the IO line to get its ADC value.

Returns:

the analog value corresponding to the provided IO line.

Return type:

Integer

Raises:

See also

get_api_output_mode()

Deprecated since version 1.3: Use get_api_output_mode_value()

Returns the API output mode of the XBee device.

The API output mode determines the format that the received data is output through the serial interface of the XBee device.

Returns:

the API output mode of the XBee device.

Return type:

APIOutputMode

Raises:

See also

get_api_output_mode_value()

Returns the API output mode of the XBee.

The API output mode determines the format that the received data is output through the serial interface of the XBee.

Returns:

the parameter value.

Return type:

Bytearray

Raises:
get_bluetooth_mac_addr()

Reads and returns the EUI-48 Bluetooth MAC address of this XBee device in a format such as 00112233AABB.

Note that your device must have Bluetooth Low Energy support to use this method.

Returns:

The Bluetooth MAC address.

Return type:

String

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
get_cellular_ai_status()

Returns the current association status of this Cellular device.

It indicates occurrences of errors during the modem initialization and connection.

Returns:

The association indication status of the Cellular device.

Return type:

CellularAssociationIndicationStatus

Raises:
  • TimeoutException – if there is a timeout getting the association indication status.
  • XBeeException – if there is any other XBee related exception.
get_current_frame_id()

Returns the last used frame ID.

Returns:the last used frame ID.
Return type:Integer
get_dest_address()

Deprecated.

Operation not supported in this protocol. Use IPDevice.get_dest_ip_addr() instead. This method will raise an AttributeError.

get_dest_ip_addr()

Returns the destination IP address.

Returns:

The configured destination IP address.

Return type:

ipaddress.IPv4Address

Raises:

See also

ipaddress.IPv4Address
get_dio_value(io_line)

Returns the digital value of the provided IO line.

The provided IO line must be previously configured as digital I/O. To do so, use AbstractXBeeDevice.set_io_configuration().

Parameters:

io_line (IOLine) – the DIO line to gets its digital value.

Returns:

current value of the provided IO line.

Return type:

IOValue

Raises:

See also

get_firmware_version()

Returns the firmware version of the XBee device.

Returns:the hardware version of the XBee device.
Return type:Bytearray
get_hardware_version()

Returns the hardware version of the XBee device.

Returns:the hardware version of the XBee device.
Return type:HardwareVersion

See also

get_imei_addr()

Returns the IMEI address of this Cellular device.

To refresh this value use the method CellularDevice.read_device_info().

Returns:The IMEI address of this Cellular device.
Return type:XBeeIMEIAddress
get_io_configuration(io_line)

Returns the configuration of the provided IO line.

Parameters:

io_line (IOLine) – the io line to configure.

Returns:

the IO mode of the IO line provided.

Return type:

IOMode

Raises:
get_io_sampling_rate()

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

get_ip_addr()

Returns the IP address of this IP device.

To refresh this value use the method IPDevice.read_device_info().

Returns:The IP address of this IP device.
Return type:ipaddress.IPv4Address

See also

ipaddress.IPv4Address
get_network()

Deprecated.

This protocol does not support the network functionality.

get_next_frame_id()

Returns the next frame ID of the XBee device.

Returns:The next frame ID of the XBee device.
Return type:Integer
get_node_id()

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

get_pan_id()

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

get_parameter(param, parameter_value=None)

Override.

get_power_level()

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

get_pwm_duty_cycle(io_line)

Returns the PWM duty cycle in % corresponding to the provided IO line.

Parameters:

io_line (IOLine) – the IO line to get its PWM duty cycle.

Returns:

the PWM duty cycle of the given IO line or None if the response is empty.

Return type:

Integer

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – if the response is not as expected.
  • ValueError – if the passed IO_LINE has no PWM capability.

See also

get_role()

Gets the XBee role.

Returns:the role of the XBee.
Return type:digi.xbee.models.protocol.Role
get_socket_info(socket_id)

Returns the information of the socket with the given socket ID.

Parameters:

socket_id (Integer) – ID of the socket.

Returns:

The socket information, or None if the socket with that ID does not exist.

Return type:

SocketInfo

Raises:
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.

See also

SocketInfo
get_sockets_list()

Returns a list with the IDs of all active (open) sockets.

Returns:

list with the IDs of all active (open) sockets, or empty list if there is not any active socket.

Return type:

List

Raises:
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
get_sync_ops_timeout()

Returns the serial port read timeout.

Returns:the serial port read timeout in seconds.
Return type:Integer
get_xbee_device_callbacks()

Returns this XBee internal callbacks for process received packets.

This method is called by the PacketListener associated with this XBee to get its callbacks. These callbacks will be executed before user callbacks.

Returns:PacketReceived
has_explicit_packets()

Returns whether the XBee device’s queue has explicit packets or not. This do not include non-explicit packets.

Returns:True if this XBee device’s queue has explicit packets, False otherwise.
Return type:Boolean
has_packets()

Returns whether the XBee device’s queue has packets or not. This do not include explicit packets.

Returns:True if this XBee device’s queue has packets, False otherwise.
Return type:Boolean
is_apply_changes_enabled()

Returns whether the apply_changes flag is enabled or not.

Returns:True if the apply_changes flag is enabled, False otherwise.
Return type:Boolean
is_connected()

Returns whether the device is connected to the Internet or not.

Returns:

True if the device is connected to the Internet, False otherwise.

Return type:

Boolean

Raises:
  • TimeoutException – if there is a timeout getting the association indication status.
  • XBeeException – if there is any other XBee related exception.
is_open()

Returns whether this XBee device is open or not.

Returns:Boolean. True if this XBee device is open, False otherwise.
is_remote()

Override method.

log

Returns the XBee device log.

Returns:the XBee device logger.
Return type:Logger
operating_mode

Returns this XBee device’s operating mode.

Returns:OperatingMode. This XBee device’s operating mode.
read_data(timeout=None, explicit=False)

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

read_data_from(remote_xbee_device, timeout=None, explicit=False)

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

read_device_info(init=True)

Override.

See also

XBeeDevice.read_device _info()
read_io_sample()

Returns an IO sample from the XBee device containing the value of all enabled digital IO and analog input channels.

Returns:

the IO sample read from the XBee device.

Return type:

IOSample

Raises:

See also

read_ip_data(timeout=3)

Reads new IP data received by this XBee device during the provided timeout.

This method blocks until new IP data is received or the provided timeout expires.

For non-blocking operations, register a callback and use the method IPDevice.add_ip_data_received_callback().

Before reading IP data you need to start listening for incoming IP data at a specific port. Use the method IPDevice.start_listening() for that purpose. When finished, you can use the method IPDevice.stop_listening() to stop listening for incoming IP data.

Parameters:timeout (Integer, optional) – The time to wait for new IP data in seconds.
Returns:IP message, None if this device did not receive new data.
Return type:IPMessage
Raises:ValueError – if timeout is less than 0.
read_ip_data_from(ip_addr, timeout=3)

Reads new IP data received from the given IP address during the provided timeout.

This method blocks until new IP data from the provided IP address is received or the given timeout expires.

For non-blocking operations, register a callback and use the method IPDevice.add_ip_data_received_callback().

Before reading IP data you need to start listening for incoming IP data at a specific port. Use the method IPDevice.start_listening() for that purpose. When finished, you can use the method IPDevice.stop_listening() to stop listening for incoming IP data.

Parameters:
  • ip_addr (ipaddress.IPv4Address) – The IP address to read data from.
  • timeout (Integer, optional) – The time to wait for new IP data in seconds.
Returns:

IP message, None if this device did not

receive new data from the provided IP address.

Return type:

IPMessage

Raises:

ValueError – if timeout is less than 0.

reset()

Override method.

send_bluetooth_data(data)

Sends the given data to the Bluetooth interface using a User Data Relay frame.

Parameters:

data (Bytearray) – Data to send.

Raises:
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – if there is any problem sending the data.
send_data(remote_xbee_device, data, transmit_options=0)

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

send_data_async(remote_xbee_device, data, transmit_options=0)

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

send_data_broadcast(data, transmit_options=0)

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

send_ip_data(ip_addr, dest_port, protocol, data, close_socket=False)

Sends the provided IP data to the given IP address and port using the specified IP protocol.

This method blocks till a success or error response arrives or the configured receive timeout expires.

Parameters:
  • ip_addr (ipaddress.IPv4Address) – The IP address to send IP data to.
  • dest_port (Integer) – The destination port of the transmission.
  • protocol (IPProtocol) – The IP protocol used for the transmission.
  • data (String or Bytearray) – The IP data to be sent.
  • close_socket (Boolean, optional) – Must be False.
Raises:

ValueError – if protocol is not UDP.

send_ip_data_async(ip_addr, dest_port, protocol, data, close_socket=False)

Sends the provided IP data to the given IP address and port asynchronously using the specified IP protocol.

Asynchronous transmissions do not wait for answer from the remote device or for transmit status packet.

Parameters:
  • ip_addr (ipaddress.IPv4Address) – The IP address to send IP data to.
  • dest_port (Integer) – The destination port of the transmission.
  • protocol (IPProtocol) – The IP protocol used for the transmission.
  • data (String or Bytearray) – The IP data to be sent.
  • close_socket (Boolean, optional) – Must be False.
Raises:

ValueError – if protocol is not UDP.

send_ip_data_broadcast(dest_port, data)

Sends the provided IP data to all clients.

This method blocks till a success or error transmit status arrives or the configured receive timeout expires.

Parameters:
  • dest_port (Integer) – The destination port of the transmission.
  • data (String or Bytearray) – The IP data to be sent.
Raises:
  • ValueError – if data is None.
  • ValueError – if dest_port is less than 0 or greater than 65535.
  • TimeoutException – if there is a timeout sending the data.
  • XBeeException – if there is any other XBee related exception.
send_micropython_data(data)

Sends the given data to the MicroPython interface using a User Data Relay frame.

Parameters:

data (Bytearray) – Data to send.

Raises:
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – if there is any problem sending the data.
send_packet(packet, sync=False)

Override method.

See also

AbstractXBeeDevice._send_packet()
send_packet_sync_and_get_response(packet_to_send, timeout=None)

Override method.

See also

AbstractXBeeDevice._send_packet_sync_and_get_response()
send_sms(phone_number, data)

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

send_sms_async(phone_number, data)

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

send_user_data_relay(local_interface, data)

Sends the given data to the given XBee local interface.

Parameters:
  • local_interface (XBeeLocalInterface) – Destination XBee local interface.
  • data (Bytearray) – Data to send.
Raises:
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ValueError – if local_interface is None.
  • XBeeException – if there is any problem sending the User Data Relay.
serial_port

Returns the serial port associated to the XBee device, if any.

Returns:
the serial port associated to the XBee device. Returns None if the local XBee
does not use serial communication.
Return type:XBeeSerialPort

See also

set_16bit_addr(value)

Sets the 16-bit address of the XBee device.

Parameters:

value (XBee16BitAddress) – the new 16-bit address of the XBee device.

Raises:
set_api_output_mode(api_output_mode)

Deprecated since version 1.3: Use set_api_output_mode_value()

Sets the API output mode of the XBee device.

Parameters:

api_output_mode (APIOutputMode) – the new API output mode of the XBee device.

Raises:

See also

set_api_output_mode_value(api_output_mode)

Sets the API output mode of the XBee.

Parameters:

api_output_mode (Integer) – new API output mode options. Calculate this value using the method digi.xbee.models.mode.APIOutputModeBit.calculate_api_output_mode_value() with a set of digi.xbee.models.mode.APIOutputModeBit.

Raises:
set_dest_address(addr)

Deprecated.

Operation not supported in this protocol. Use IPDevice.set_dest_ip_addr() instead. This method will raise an AttributeError.

set_dest_ip_addr(address)

Sets the destination IP address.

Parameters:

address (ipaddress.IPv4Address) – Destination IP address.

Raises:
  • ValueError – if address is None.
  • TimeoutException – if there is a timeout setting the destination IP address.
  • XBeeException – if there is any other XBee related exception.

See also

ipaddress.IPv4Address
set_dio_change_detection(io_lines_set)

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

set_dio_value(io_line, io_value)

Sets the digital value (high or low) to the provided IO line.

Parameters:
  • io_line (IOLine) – the digital IO line to sets its value.
  • io_value (IOValue) – the IO value to set to the IO line.
Raises:

See also

set_io_configuration(io_line, io_mode)

Sets the configuration of the provided IO line.

Parameters:
  • io_line (IOLine) – the IO line to configure.
  • io_mode (IOMode) – the IO mode to set to the IO line.
Raises:

See also

set_io_sampling_rate(rate)

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

set_node_id(node_id)

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

set_pan_id(value)

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

set_parameter(param, value)

Override.

See:
AbstractXBeeDevice.set_parameter()
set_power_level(power_level)

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

set_pwm_duty_cycle(io_line, cycle)

Sets the duty cycle in % of the provided IO line.

The provided IO line must be PWM-capable, previously configured as PWM output.

Parameters:
  • io_line (IOLine) – the IO Line to be assigned.
  • cycle (Integer) – duty cycle in % to be assigned. Must be between 0 and 100.
Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – if the response is not as expected.
  • ValueError – if the given IO line does not have PWM capability or cycle is not between 0 and 100.

See also

set_sync_ops_timeout(sync_ops_timeout)

Sets the serial port read timeout.

Parameters:sync_ops_timeout (Integer) – the read timeout, expressed in seconds.
start_listening(source_port)

Starts listening for incoming IP transmissions in the provided port.

Parameters:

source_port (Integer) – Port to listen for incoming transmissions.

Raises:
  • ValueError – if source_port is less than 0 or greater than 65535.
  • TimeoutException – if there is a timeout setting the source port.
  • XBeeException – if there is any other XBee related exception.
stop_listening()

Stops listening for incoming IP transmissions.

Raises:
update_bluetooth_password(new_password)

Changes the password of this Bluetooth device with the new one provided.

Note that your device must have Bluetooth Low Energy support to use this method.

Parameters:

new_password (String) – New Bluetooth password.

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
update_device_data_from(device)

Updates the current device reference with the data provided for the given device.

This is only for internal use.

Parameters:device (AbstractXBeeDevice) – the XBee device to get the data from.
Returns:True if the device data has been updated, False otherwise.
Return type:Boolean
update_firmware(xml_firmware_file, xbee_firmware_file=None, bootloader_firmware_file=None, timeout=None, progress_callback=None)

Performs a firmware update operation of the device.

Parameters:
  • xml_firmware_file (String) – path of the XML file that describes the firmware to upload.
  • xbee_firmware_file (String, optional) – location of the XBee binary firmware file.
  • bootloader_firmware_file (String, optional) – location of the bootloader binary firmware file.
  • timeout (Integer, optional) – the maximum time to wait for target read operations during the update process.
  • progress_callback (Function, optional) –
    function to execute to receive progress information. Receives two
    arguments:
    • The current update task as a String
    • The current update task percentage as an Integer
Raises:
write_changes()

Writes configurable parameter values to the non-volatile memory of the XBee device so that parameter modifications persist through subsequent resets.

Parameters values remain in this device’s memory until overwritten by subsequent use of this method.

If changes are made without writing them to non-volatile memory, the module reverts back to previously saved parameters the next time the module is powered-on.

Writing the parameter modifications does not mean those values are immediately applied, this depends on the status of the ‘apply configuration changes’ option. Use method is_apply_configuration_changes_enabled() to get its status and enable_apply_configuration_changes() to enable/disable the option. If it is disabled, method apply_changes() can be used in order to manually apply the changes.

Raises:
class digi.xbee.devices.WiFiDevice(port=None, baud_rate=None, data_bits=<sphinx.ext.autodoc.importer._MockObject object>, stop_bits=<sphinx.ext.autodoc.importer._MockObject object>, parity=<sphinx.ext.autodoc.importer._MockObject object>, flow_control=<FlowControl.NONE: None>, _sync_ops_timeout=4, comm_iface=None)[source]

Bases: digi.xbee.devices.IPDevice

This class represents a local Wi-Fi XBee device.

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

Parameters:
  • port (Integer or String) – serial port identifier. Integer: number of XBee device, numbering starts at zero. Device name: depending on operating system. e.g. ‘/dev/ttyUSB0’ on ‘GNU/Linux’ or ‘COM3’ on Windows.
  • baud_rate (Integer) – the serial port baud rate.
  • (Integer, default (_sync_ops_timeout) – serial.EIGHTBITS): comm port bitsize.
  • (Integer, defaultserial.STOPBITS_ONE): comm port stop bits.
  • (Character, default (parity) – serial.PARITY_NONE): comm port parity.
  • (Integer, defaultFlowControl.NONE): comm port flow control.
  • (Integer, default – 3): the read timeout (in seconds).
  • comm_iface (XBeeCommunicationInterface) – the communication interface.

:raises All exceptions raised by XBeeDevice.__init__() constructor.:

See also

v.__init__()
open(force_settings=False)[source]

Override.

Raises:
  • TimeoutException – If there is any problem with the communication.
  • InvalidOperatingModeException – If the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – If the protocol is invalid or if the XBee device is already open.
get_protocol()[source]

Override.

get_wifi_ai_status()[source]

Returns the current association status of the device.

Returns:

the current association status of the device.

Return type:

WiFiAssociationIndicationStatus

Raises:
  • TimeoutException – if there is a timeout getting the association indication status.
  • XBeeException – if there is any other XBee related exception.
get_access_point(ssid)[source]

Finds and returns the access point that matches the supplied SSID.

Parameters:

ssid (String) – the SSID of the access point to get.

Returns:

the discovered access point with the provided SSID, or None

if the timeout expires and the access point was not found.

Return type:

AccessPoint

Raises:

See also

scan_access_points()[source]

Performs a scan to search for access points in the vicinity.

This method blocks until all the access points are discovered or the configured access point timeout expires.

The access point timeout is configured using the WiFiDevice.set_access_point_timeout() method and can be consulted with WiFiDevice.get_access_point_timeout() method.

Returns:

the list of AccessPoint objects discovered.

Return type:

List

Raises:

See also

connect_by_ap(access_point, password=None)[source]

Connects to the provided access point.

This method blocks until the connection with the access point is established or the configured access point timeout expires.

The access point timeout is configured using the WiFiDevice.set_access_point_timeout() method and can be consulted with WiFiDevice.get_access_point_timeout() method.

Once the module is connected to the access point, you can issue the WiFiDevice.write_changes() method to save the connection settings. This way the module will try to connect to the access point every time it is powered on.

Parameters:
  • access_point (AccessPoint) – The access point to connect to.
  • password (String, optional) – The password for the access point, None if it does not have any encryption enabled. Optional.
Returns:

True if the module connected to the access point successfully, False otherwise.

Return type:

Boolean

Raises:
  • ValueError – if access_point is None.
  • TimeoutException – if there is a timeout sending the connect commands.
  • XBeeException – if there is any other XBee related exception.
connect_by_ssid(ssid, password=None)[source]

Connects to the access point with provided SSID.

This method blocks until the connection with the access point is established or the configured access point timeout expires.

The access point timeout is configured using the WiFiDevice.set_access_point_timeout() method and can be consulted with WiFiDevice.get_access_point_timeout() method.

Once the module is connected to the access point, you can issue the WiFiDevice.write_changes() method to save the connection settings. This way the module will try to connect to the access point every time it is powered on.

Parameters:
  • ssid (String) – the SSID of the access point to connect to.
  • password (String, optional) – The password for the access point, None if it does not have any encryption enabled. Optional.
Returns:

True if the module connected to the access point successfully, False otherwise.

Return type:

Boolean

Raises:
  • ValueError – if ssid is None.
  • TimeoutException – if there is a timeout sending the connect commands.
  • XBeeException – if the access point with the provided SSID cannot be found.
  • XBeeException – if there is any other XBee related exception.
disconnect()[source]

Disconnects from the access point that the device is connected to.

This method blocks until the device disconnects totally from the access point or the configured access point timeout expires.

The access point timeout is configured using the WiFiDevice.set_access_point_timeout() method and can be consulted with WiFiDevice.get_access_point_timeout() method.

Returns:

True if the module disconnected from the access point successfully, False otherwise.

Return type:

Boolean

Raises:
is_connected()[source]

Returns whether the device is connected to an access point or not.

Returns:True if the device is connected to an access point, False otherwise.
Return type:Boolean
Raises:TimeoutException – if there is a timeout getting the association indication status.
get_access_point_timeout()[source]

Returns the configured access point timeout for connecting, disconnecting and scanning access points.

Returns:the current access point timeout in milliseconds.
Return type:Integer
set_access_point_timeout(ap_timeout)[source]

Configures the access point timeout in milliseconds for connecting, disconnecting and scanning access points.

Parameters:ap_timeout (Integer) – the new access point timeout in milliseconds.
Raises:ValueError – if ap_timeout is less than 0.
get_ip_addressing_mode()[source]

Returns the IP addressing mode of the device.

Returns:the IP addressing mode.
Return type:IPAddressingMode
Raises:TimeoutException – if there is a timeout reading the IP addressing mode.
set_ip_addressing_mode(mode)[source]

Sets the IP addressing mode of the device.

Parameters:mode (IPAddressingMode) – the new IP addressing mode to set.
Raises:TimeoutException – if there is a timeout setting the IP addressing mode.
set_ip_address(ip_address)[source]

Sets the IP address of the module.

This method can only be called if the module is configured in IPAddressingMode.STATIC mode. Otherwise an XBeeException will be thrown.

Parameters:ip_address (ipaddress.IPv4Address) – the new IP address to set.
Raises:TimeoutException – if there is a timeout setting the IP address.

See also

ipaddress.IPv4Address
get_mask_address()[source]

Returns the subnet mask IP address.

Returns:the subnet mask IP address.
Return type:ipaddress.IPv4Address
Raises:TimeoutException – if there is a timeout reading the subnet mask address.

See also

ipaddress.IPv4Address
set_mask_address(mask_address)[source]

Sets the subnet mask IP address.

This method can only be called if the module is configured in IPAddressingMode.STATIC mode. Otherwise an XBeeException will be thrown.

Parameters:mask_address (ipaddress.IPv4Address) – the new subnet mask address to set.
Raises:TimeoutException – if there is a timeout setting the subnet mask address.

See also

ipaddress.IPv4Address
get_gateway_address()[source]

Returns the IP address of the gateway.

Returns:the IP address of the gateway.
Return type:ipaddress.IPv4Address
Raises:TimeoutException – if there is a timeout reading the gateway address.

See also

ipaddress.IPv4Address
set_gateway_address(gateway_address)[source]

Sets the IP address of the gateway.

This method can only be called if the module is configured in IPAddressingMode.STATIC mode. Otherwise an XBeeException will be thrown.

Parameters:gateway_address (ipaddress.IPv4Address) – the new gateway address to set.
Raises:TimeoutException – if there is a timeout setting the gateway address.

See also

ipaddress.IPv4Address
get_dns_address()[source]

Returns the IP address of Domain Name Server (DNS).

Returns:the DNS address configured.
Return type:ipaddress.IPv4Address
Raises:TimeoutException – if there is a timeout reading the DNS address.

See also

ipaddress.IPv4Address
set_dns_address(dns_address)[source]

Sets the IP address of Domain Name Server (DNS).

Parameters:dns_address (ipaddress.IPv4Address) – the new DNS address to set.
Raises:TimeoutException – if there is a timeout setting the DNS address.

See also

ipaddress.IPv4Address
add_bluetooth_data_received_callback(callback)

Adds a callback for the event digi.xbee.reader.BluetoothDataReceived.

Parameters:callback (Function) –

the callback. Receives one argument.

  • The Bluetooth data as a Bytearray
add_data_received_callback(callback)

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

add_expl_data_received_callback(callback)

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

add_io_sample_received_callback(callback)

Adds a callback for the event digi.xbee.reader.IOSampleReceived.

Parameters:callback (Function) –

the callback. Receives three arguments.

add_ip_data_received_callback(callback)

Adds a callback for the event digi.xbee.reader.IPDataReceived.

Parameters:callback (Function) –

the callback. Receives one argument.

add_micropython_data_received_callback(callback)

Adds a callback for the event digi.xbee.reader.MicroPythonDataReceived.

Parameters:callback (Function) –

the callback. Receives one argument.

  • The MicroPython data as a Bytearray
add_modem_status_received_callback(callback)

Adds a callback for the event digi.xbee.reader.ModemStatusReceived.

Parameters:callback (Function) –

the callback. Receives one argument.

add_packet_received_callback(callback)

Adds a callback for the event digi.xbee.reader.PacketReceived.

Parameters:callback (Function) –

the callback. Receives two arguments.

add_socket_data_received_callback(callback)

Adds a callback for the event digi.xbee.reader.SocketDataReceived.

Parameters:callback (Function) –

the callback. Receives two arguments.

  • The socket ID as an Integer.
  • The data received as Bytearray
add_socket_data_received_from_callback(callback)

Adds a callback for the event digi.xbee.reader.SocketDataReceivedFrom.

Parameters:callback (Function) –

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 data received as Bytearray
add_socket_state_received_callback(callback)

Adds a callback for the event digi.xbee.reader.SocketStateReceived.

Parameters:callback (Function) –

the callback. Receives two arguments.

  • The socket ID as an Integer.
  • The state received as a SocketState
add_user_data_relay_received_callback(callback)

Adds a callback for the event digi.xbee.reader.RelayDataReceived.

Parameters:callback (Function) –

the callback. Receives one argument.

apply_changes()

Applies changes via AC command.

Raises:
apply_profile(profile_path, progress_callback=None)

Applies the given XBee profile to the XBee device.

Parameters:
  • profile_path (String) – path of the XBee profile file to apply.
  • progress_callback (Function, optional) –
    function to execute to receive progress information. Receives two
    arguments:
    • The current apply profile task as a String
    • The current apply profile task percentage as an Integer
Raises:
close()

Closes the communication with the XBee device.

This method guarantees that all threads running are stopped and the serial port is closed.

comm_iface

Returns the hardware interface associated to the XBee device.

Returns:the hardware interface associated to the XBee device.
Return type:XBeeCommunicationInterface

See also

classmethod create_xbee_device(comm_port_data)

Creates and returns an XBeeDevice from data of the port to which is connected.

Parameters:
  • comm_port_data (Dictionary) – dictionary with all comm port data needed.
  • dictionary keys are (The) –
    “baudRate” –> Baud rate.
    ”port” –> Port number.
    ”bitSize” –> Bit size.
    ”stopBits” –> Stop bits.
    ”parity” –> Parity.
    ”flowControl” –> Flow control.
    ”timeout” for –> Timeout for synchronous operations (in seconds).
Returns:

the XBee device created.

Return type:

XBeeDevice

Raises:

SerialException – if the port you want to open does not exist or is already opened.

See also

del_bluetooth_data_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.BluetoothDataReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.BluetoothDataReceived event.
del_data_received_callback(callback)

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

del_expl_data_received_callback(callback)

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

del_io_sample_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.IOSampleReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.IOSampleReceived event.
del_ip_data_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.IPDataReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.IPDataReceived event.
del_micropython_data_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.MicroPythonDataReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.MicroPythonDataReceived event.
del_modem_status_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.ModemStatusReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.ModemStatusReceived event.
del_packet_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.PacketReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.PacketReceived event.
del_socket_data_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.SocketDataReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.SocketDataReceived event.
del_socket_data_received_from_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.SocketDataReceivedFrom event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.SocketDataReceivedFrom event.
del_socket_state_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.SocketStateReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.SocketStateReceived event.
del_user_data_relay_received_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.RelayDataReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of digi.xbee.reader.RelayDataReceived event.
disable_bluetooth()

Disables the Bluetooth interface of this XBee device.

Note that your device must have Bluetooth Low Energy support to use this method.

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
enable_apply_changes(value)

Sets the apply_changes flag.

Parameters:value (Boolean) – True to enable the apply changes flag, False to disable it.
enable_bluetooth()

Enables the Bluetooth interface of this XBee device.

To work with this interface, you must also configure the Bluetooth password if not done previously. You can use the AbstractXBeeDevice.update_bluetooth_password() method for that purpose.

Note that your device must have Bluetooth Low Energy support to use this method.

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
execute_command(parameter)

Executes the provided command.

Parameters:

parameter (String) – The name of the AT command to be executed.

Raises:
flush_queues()

Flushes the packets queue.

get_16bit_addr()

Deprecated.

This protocol does not have an associated 16-bit address.

get_64bit_addr()

Returns the 64-bit address of the XBee device.

Returns:the 64-bit address of the XBee device.
Return type:XBee64BitAddress

See also

get_adc_value(io_line)

Returns the analog value of the provided IO line.

The provided IO line must be previously configured as ADC. To do so, use AbstractXBeeDevice.set_io_configuration() and IOMode.ADC.

Parameters:

io_line (IOLine) – the IO line to get its ADC value.

Returns:

the analog value corresponding to the provided IO line.

Return type:

Integer

Raises:

See also

get_api_output_mode()

Deprecated since version 1.3: Use get_api_output_mode_value()

Returns the API output mode of the XBee device.

The API output mode determines the format that the received data is output through the serial interface of the XBee device.

Returns:

the API output mode of the XBee device.

Return type:

APIOutputMode

Raises:

See also

get_api_output_mode_value()

Returns the API output mode of the XBee.

The API output mode determines the format that the received data is output through the serial interface of the XBee.

Returns:

the parameter value.

Return type:

Bytearray

Raises:
get_bluetooth_mac_addr()

Reads and returns the EUI-48 Bluetooth MAC address of this XBee device in a format such as 00112233AABB.

Note that your device must have Bluetooth Low Energy support to use this method.

Returns:

The Bluetooth MAC address.

Return type:

String

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
get_current_frame_id()

Returns the last used frame ID.

Returns:the last used frame ID.
Return type:Integer
get_dest_address()

Deprecated.

Operation not supported in this protocol. Use IPDevice.get_dest_ip_addr() instead. This method will raise an AttributeError.

get_dest_ip_addr()

Returns the destination IP address.

Returns:

The configured destination IP address.

Return type:

ipaddress.IPv4Address

Raises:

See also

ipaddress.IPv4Address
get_dio_value(io_line)

Returns the digital value of the provided IO line.

The provided IO line must be previously configured as digital I/O. To do so, use AbstractXBeeDevice.set_io_configuration().

Parameters:

io_line (IOLine) – the DIO line to gets its digital value.

Returns:

current value of the provided IO line.

Return type:

IOValue

Raises:

See also

get_firmware_version()

Returns the firmware version of the XBee device.

Returns:the hardware version of the XBee device.
Return type:Bytearray
get_hardware_version()

Returns the hardware version of the XBee device.

Returns:the hardware version of the XBee device.
Return type:HardwareVersion

See also

get_io_configuration(io_line)

Returns the configuration of the provided IO line.

Parameters:

io_line (IOLine) – the io line to configure.

Returns:

the IO mode of the IO line provided.

Return type:

IOMode

Raises:
get_io_sampling_rate()

Returns the IO sampling rate of the XBee device.

Returns:

the IO sampling rate of XBee device.

Return type:

Integer

Raises:
get_ip_addr()

Returns the IP address of this IP device.

To refresh this value use the method IPDevice.read_device_info().

Returns:The IP address of this IP device.
Return type:ipaddress.IPv4Address

See also

ipaddress.IPv4Address
get_network()

Deprecated.

This protocol does not support the network functionality.

get_next_frame_id()

Returns the next frame ID of the XBee device.

Returns:The next frame ID of the XBee device.
Return type:Integer
get_node_id()

Returns the Node Identifier (NI) value of the XBee device.

Returns:the Node Identifier (NI) of the XBee device.
Return type:String
get_pan_id()

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

get_parameter(param, parameter_value=None)

Override.

get_power_level()

Returns the power level of the XBee device.

Returns:the power level of the XBee device.
Return type:PowerLevel
Raises:TimeoutException – if the response is not received before the read timeout expires.

See also

get_pwm_duty_cycle(io_line)

Returns the PWM duty cycle in % corresponding to the provided IO line.

Parameters:

io_line (IOLine) – the IO line to get its PWM duty cycle.

Returns:

the PWM duty cycle of the given IO line or None if the response is empty.

Return type:

Integer

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – if the response is not as expected.
  • ValueError – if the passed IO_LINE has no PWM capability.

See also

get_role()

Gets the XBee role.

Returns:the role of the XBee.
Return type:digi.xbee.models.protocol.Role
get_sync_ops_timeout()

Returns the serial port read timeout.

Returns:the serial port read timeout in seconds.
Return type:Integer
get_xbee_device_callbacks()

Returns this XBee internal callbacks for process received packets.

This method is called by the PacketListener associated with this XBee to get its callbacks. These callbacks will be executed before user callbacks.

Returns:PacketReceived
has_explicit_packets()

Returns whether the XBee device’s queue has explicit packets or not. This do not include non-explicit packets.

Returns:True if this XBee device’s queue has explicit packets, False otherwise.
Return type:Boolean
has_packets()

Returns whether the XBee device’s queue has packets or not. This do not include explicit packets.

Returns:True if this XBee device’s queue has packets, False otherwise.
Return type:Boolean
is_apply_changes_enabled()

Returns whether the apply_changes flag is enabled or not.

Returns:True if the apply_changes flag is enabled, False otherwise.
Return type:Boolean
is_open()

Returns whether this XBee device is open or not.

Returns:Boolean. True if this XBee device is open, False otherwise.
is_remote()

Override method.

log

Returns the XBee device log.

Returns:the XBee device logger.
Return type:Logger
operating_mode

Returns this XBee device’s operating mode.

Returns:OperatingMode. This XBee device’s operating mode.
read_data(timeout=None, explicit=False)

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

read_data_from(remote_xbee_device, timeout=None, explicit=False)

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

read_device_info(init=True)

Override.

read_io_sample()

Returns an IO sample from the XBee device containing the value of all enabled digital IO and analog input channels.

Returns:

the IO sample read from the XBee device.

Return type:

IOSample

Raises:

See also

read_ip_data(timeout=3)

Reads new IP data received by this XBee device during the provided timeout.

This method blocks until new IP data is received or the provided timeout expires.

For non-blocking operations, register a callback and use the method IPDevice.add_ip_data_received_callback().

Before reading IP data you need to start listening for incoming IP data at a specific port. Use the method IPDevice.start_listening() for that purpose. When finished, you can use the method IPDevice.stop_listening() to stop listening for incoming IP data.

Parameters:timeout (Integer, optional) – The time to wait for new IP data in seconds.
Returns:IP message, None if this device did not receive new data.
Return type:IPMessage
Raises:ValueError – if timeout is less than 0.
read_ip_data_from(ip_addr, timeout=3)

Reads new IP data received from the given IP address during the provided timeout.

This method blocks until new IP data from the provided IP address is received or the given timeout expires.

For non-blocking operations, register a callback and use the method IPDevice.add_ip_data_received_callback().

Before reading IP data you need to start listening for incoming IP data at a specific port. Use the method IPDevice.start_listening() for that purpose. When finished, you can use the method IPDevice.stop_listening() to stop listening for incoming IP data.

Parameters:
  • ip_addr (ipaddress.IPv4Address) – The IP address to read data from.
  • timeout (Integer, optional) – The time to wait for new IP data in seconds.
Returns:

IP message, None if this device did not

receive new data from the provided IP address.

Return type:

IPMessage

Raises:

ValueError – if timeout is less than 0.

reset()

Override method.

send_bluetooth_data(data)

Sends the given data to the Bluetooth interface using a User Data Relay frame.

Parameters:

data (Bytearray) – Data to send.

Raises:
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – if there is any problem sending the data.
send_data(remote_xbee_device, data, transmit_options=0)

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

send_data_async(remote_xbee_device, data, transmit_options=0)

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

send_data_broadcast(data, transmit_options=0)

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

send_ip_data(ip_addr, dest_port, protocol, data, close_socket=False)

Sends the provided IP data to the given IP address and port using the specified IP protocol. For TCP and TCP SSL protocols, you can also indicate if the socket should be closed when data is sent.

This method blocks till a success or error response arrives or the configured receive timeout expires.

Parameters:
  • ip_addr (ipaddress.IPv4Address) – The IP address to send IP data to.
  • dest_port (Integer) – The destination port of the transmission.
  • protocol (IPProtocol) – The IP protocol used for the transmission.
  • data (String or Bytearray) – The IP data to be sent.
  • close_socket (Boolean, optional) – True to close the socket just after the transmission. False to keep it open. Default to False.
Raises:
  • ValueError – if ip_addr is None.
  • ValueError – if protocol is None.
  • ValueError – if data is None.
  • ValueError – if dest_port is less than 0 or greater than 65535.
  • OperationNotSupportedException – if the device is remote.
  • TimeoutException – if there is a timeout sending the data.
  • XBeeException – if there is any other XBee related exception.
send_ip_data_async(ip_addr, dest_port, protocol, data, close_socket=False)

Sends the provided IP data to the given IP address and port asynchronously using the specified IP protocol. For TCP and TCP SSL protocols, you can also indicate if the socket should be closed when data is sent.

Asynchronous transmissions do not wait for answer from the remote device or for transmit status packet.

Parameters:
  • ip_addr (ipaddress.IPv4Address) – The IP address to send IP data to.
  • dest_port (Integer) – The destination port of the transmission.
  • protocol (IPProtocol) – The IP protocol used for the transmission.
  • data (String or Bytearray) – The IP data to be sent.
  • close_socket (Boolean, optional) – True to close the socket just after the transmission. False to keep it open. Default to False.
Raises:
  • ValueError – if ip_addr is None.
  • ValueError – if protocol is None.
  • ValueError – if data is None.
  • ValueError – if dest_port is less than 0 or greater than 65535.
  • OperationNotSupportedException – if the device is remote.
  • XBeeException – if there is any other XBee related exception.
send_ip_data_broadcast(dest_port, data)

Sends the provided IP data to all clients.

This method blocks till a success or error transmit status arrives or the configured receive timeout expires.

Parameters:
  • dest_port (Integer) – The destination port of the transmission.
  • data (String or Bytearray) – The IP data to be sent.
Raises:
  • ValueError – if data is None.
  • ValueError – if dest_port is less than 0 or greater than 65535.
  • TimeoutException – if there is a timeout sending the data.
  • XBeeException – if there is any other XBee related exception.
send_micropython_data(data)

Sends the given data to the MicroPython interface using a User Data Relay frame.

Parameters:

data (Bytearray) – Data to send.

Raises:
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – if there is any problem sending the data.
send_packet(packet, sync=False)

Override method.

See also

AbstractXBeeDevice._send_packet()
send_packet_sync_and_get_response(packet_to_send, timeout=None)

Override method.

See also

AbstractXBeeDevice._send_packet_sync_and_get_response()
send_user_data_relay(local_interface, data)

Sends the given data to the given XBee local interface.

Parameters:
  • local_interface (XBeeLocalInterface) – Destination XBee local interface.
  • data (Bytearray) – Data to send.
Raises:
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ValueError – if local_interface is None.
  • XBeeException – if there is any problem sending the User Data Relay.
serial_port

Returns the serial port associated to the XBee device, if any.

Returns:
the serial port associated to the XBee device. Returns None if the local XBee
does not use serial communication.
Return type:XBeeSerialPort

See also

set_16bit_addr(value)

Sets the 16-bit address of the XBee device.

Parameters:

value (XBee16BitAddress) – the new 16-bit address of the XBee device.

Raises:
set_api_output_mode(api_output_mode)

Deprecated since version 1.3: Use set_api_output_mode_value()

Sets the API output mode of the XBee device.

Parameters:

api_output_mode (APIOutputMode) – the new API output mode of the XBee device.

Raises:

See also

set_api_output_mode_value(api_output_mode)

Sets the API output mode of the XBee.

Parameters:

api_output_mode (Integer) – new API output mode options. Calculate this value using the method digi.xbee.models.mode.APIOutputModeBit.calculate_api_output_mode_value() with a set of digi.xbee.models.mode.APIOutputModeBit.

Raises:
set_dest_address(addr)

Deprecated.

Operation not supported in this protocol. Use IPDevice.set_dest_ip_addr() instead. This method will raise an AttributeError.

set_dest_ip_addr(address)

Sets the destination IP address.

Parameters:

address (ipaddress.IPv4Address) – Destination IP address.

Raises:
  • ValueError – if address is None.
  • TimeoutException – if there is a timeout setting the destination IP address.
  • XBeeException – if there is any other XBee related exception.

See also

ipaddress.IPv4Address
set_dio_change_detection(io_lines_set)

Sets the digital IO lines to be monitored and sampled whenever their status changes.

A None set of lines disables this feature.

Parameters:

io_lines_set – set of IOLine.

Raises:

See also

set_dio_value(io_line, io_value)

Sets the digital value (high or low) to the provided IO line.

Parameters:
  • io_line (IOLine) – the digital IO line to sets its value.
  • io_value (IOValue) – the IO value to set to the IO line.
Raises:

See also

set_io_configuration(io_line, io_mode)

Sets the configuration of the provided IO line.

Parameters:
  • io_line (IOLine) – the IO line to configure.
  • io_mode (IOMode) – the IO mode to set to the IO line.
Raises:

See also

set_io_sampling_rate(rate)

Sets the IO sampling rate of the XBee device in seconds. A sample rate of 0 means the IO sampling feature is disabled.

Parameters:

rate (Integer) – the new IO sampling rate of the XBee device in seconds.

Raises:
set_node_id(node_id)

Sets the Node Identifier (NI) value of the XBee device..

Parameters:

node_id (String) – the new Node Identifier (NI) of the XBee device.

Raises:
  • ValueError – if node_id is None or its length is greater than 20.
  • TimeoutException – if the response is not received before the read timeout expires.
set_pan_id(value)

Deprecated.

Operation not supported in this protocol. This method will raise an AttributeError.

set_parameter(param, value)

Override.

See:
AbstractXBeeDevice.set_parameter()
set_power_level(power_level)

Sets the power level of the XBee device.

Parameters:power_level (PowerLevel) – the new power level of the XBee device.
Raises:TimeoutException – if the response is not received before the read timeout expires.

See also

set_pwm_duty_cycle(io_line, cycle)

Sets the duty cycle in % of the provided IO line.

The provided IO line must be PWM-capable, previously configured as PWM output.

Parameters:
  • io_line (IOLine) – the IO Line to be assigned.
  • cycle (Integer) – duty cycle in % to be assigned. Must be between 0 and 100.
Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – if the response is not as expected.
  • ValueError – if the given IO line does not have PWM capability or cycle is not between 0 and 100.

See also

set_sync_ops_timeout(sync_ops_timeout)

Sets the serial port read timeout.

Parameters:sync_ops_timeout (Integer) – the read timeout, expressed in seconds.
start_listening(source_port)

Starts listening for incoming IP transmissions in the provided port.

Parameters:

source_port (Integer) – Port to listen for incoming transmissions.

Raises:
  • ValueError – if source_port is less than 0 or greater than 65535.
  • TimeoutException – if there is a timeout setting the source port.
  • XBeeException – if there is any other XBee related exception.
stop_listening()

Stops listening for incoming IP transmissions.

Raises:
update_bluetooth_password(new_password)

Changes the password of this Bluetooth device with the new one provided.

Note that your device must have Bluetooth Low Energy support to use this method.

Parameters:

new_password (String) – New Bluetooth password.

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
update_device_data_from(device)

Updates the current device reference with the data provided for the given device.

This is only for internal use.

Parameters:device (AbstractXBeeDevice) – the XBee device to get the data from.
Returns:True if the device data has been updated, False otherwise.
Return type:Boolean
update_firmware(xml_firmware_file, xbee_firmware_file=None, bootloader_firmware_file=None, timeout=None, progress_callback=None)

Performs a firmware update operation of the device.

Parameters:
  • xml_firmware_file (String) – path of the XML file that describes the firmware to upload.
  • xbee_firmware_file (String, optional) – location of the XBee binary firmware file.
  • bootloader_firmware_file (String, optional) – location of the bootloader binary firmware file.
  • timeout (Integer, optional) – the maximum time to wait for target read operations during the update process.
  • progress_callback (Function, optional) –
    function to execute to receive progress information. Receives two
    arguments:
    • The current update task as a String
    • The current update task percentage as an Integer
Raises:
write_changes()

Writes configurable parameter values to the non-volatile memory of the XBee device so that parameter modifications persist through subsequent resets.

Parameters values remain in this device’s memory until overwritten by subsequent use of this method.

If changes are made without writing them to non-volatile memory, the module reverts back to previously saved parameters the next time the module is powered-on.

Writing the parameter modifications does not mean those values are immediately applied, this depends on the status of the ‘apply configuration changes’ option. Use method is_apply_configuration_changes_enabled() to get its status and enable_apply_configuration_changes() to enable/disable the option. If it is disabled, method apply_changes() can be used in order to manually apply the changes.

Raises:
class digi.xbee.devices.RemoteXBeeDevice(local_xbee_device, x64bit_addr=<digi.xbee.models.address.XBee64BitAddress object>, x16bit_addr=<digi.xbee.models.address.XBee16BitAddress object>, node_id=None)[source]

Bases: digi.xbee.devices.AbstractXBeeDevice

This class represents a remote XBee device.

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

Parameters:
  • local_xbee_device (XBeeDevice) – the local XBee device associated with the remote one.
  • x64bit_addr (XBee64BitAddress) – the 64-bit address of the remote XBee device.
  • x16bit_addr (XBee16BitAddress) – the 16-bit address of the remote XBee device.
  • node_id (String, optional) – the node identifier of the remote XBee device. Optional.

See also

XBee16BitAddress
XBee64BitAddress
get_parameter(parameter, parameter_value=None)[source]

Override.

set_parameter(parameter, value)[source]

Override.

is_remote()[source]

Override method.

reset()[source]

Override method.

get_local_xbee_device()[source]

Returns the local XBee device associated to the remote one.

Returns:XBeeDevice
set_local_xbee_device(local_xbee_device)[source]

This methods associates a XBeeDevice to the remote XBee device.

Parameters:local_xbee_device (XBeeDevice) – the new local XBee device associated to the remote one.

See also

get_serial_port()[source]

Returns the serial port of the local XBee device associated to the remote one.

Returns:the serial port of the local XBee device associated to the remote one.
Return type:XBeeSerialPort

See also

XBeeSerialPort
get_comm_iface()[source]

Returns the communication interface of the local XBee device associated to the remote one.

Returns:
the communication interface of the local XBee device associated to
the remote one.
Return type:XBeeCommunicationInterface

See also

XBeeCommunicationInterface
apply_changes()

Applies changes via AC command.

Raises:
apply_profile(profile_path, progress_callback=None)

Applies the given XBee profile to the XBee device.

Parameters:
  • profile_path (String) – path of the XBee profile file to apply.
  • progress_callback (Function, optional) –
    function to execute to receive progress information. Receives two
    arguments:
    • The current apply profile task as a String
    • The current apply profile task percentage as an Integer
Raises:
disable_bluetooth()

Disables the Bluetooth interface of this XBee device.

Note that your device must have Bluetooth Low Energy support to use this method.

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
enable_apply_changes(value)

Sets the apply_changes flag.

Parameters:value (Boolean) – True to enable the apply changes flag, False to disable it.
enable_bluetooth()

Enables the Bluetooth interface of this XBee device.

To work with this interface, you must also configure the Bluetooth password if not done previously. You can use the AbstractXBeeDevice.update_bluetooth_password() method for that purpose.

Note that your device must have Bluetooth Low Energy support to use this method.

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
execute_command(parameter)

Executes the provided command.

Parameters:

parameter (String) – The name of the AT command to be executed.

Raises:
get_16bit_addr()

Returns the 16-bit address of the XBee device.

Returns:the 16-bit address of the XBee device.
Return type:XBee16BitAddress

See also

get_64bit_addr()

Returns the 64-bit address of the XBee device.

Returns:the 64-bit address of the XBee device.
Return type:XBee64BitAddress

See also

get_adc_value(io_line)

Returns the analog value of the provided IO line.

The provided IO line must be previously configured as ADC. To do so, use AbstractXBeeDevice.set_io_configuration() and IOMode.ADC.

Parameters:

io_line (IOLine) – the IO line to get its ADC value.

Returns:

the analog value corresponding to the provided IO line.

Return type:

Integer

Raises:

See also

get_api_output_mode()

Deprecated since version 1.3: Use get_api_output_mode_value()

Returns the API output mode of the XBee device.

The API output mode determines the format that the received data is output through the serial interface of the XBee device.

Returns:

the API output mode of the XBee device.

Return type:

APIOutputMode

Raises:

See also

get_api_output_mode_value()

Returns the API output mode of the XBee.

The API output mode determines the format that the received data is output through the serial interface of the XBee.

Returns:

the parameter value.

Return type:

Bytearray

Raises:
get_bluetooth_mac_addr()

Reads and returns the EUI-48 Bluetooth MAC address of this XBee device in a format such as 00112233AABB.

Note that your device must have Bluetooth Low Energy support to use this method.

Returns:

The Bluetooth MAC address.

Return type:

String

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
get_current_frame_id()

Returns the last used frame ID.

Returns:the last used frame ID.
Return type:Integer
get_dest_address()

Returns the 64-bit address of the XBee device that data will be reported to.

Returns:the address.
Return type:XBee64BitAddress
Raises:TimeoutException – if the response is not received before the read timeout expires.

See also

get_dio_value(io_line)

Returns the digital value of the provided IO line.

The provided IO line must be previously configured as digital I/O. To do so, use AbstractXBeeDevice.set_io_configuration().

Parameters:

io_line (IOLine) – the DIO line to gets its digital value.

Returns:

current value of the provided IO line.

Return type:

IOValue

Raises:

See also

get_firmware_version()

Returns the firmware version of the XBee device.

Returns:the hardware version of the XBee device.
Return type:Bytearray
get_hardware_version()

Returns the hardware version of the XBee device.

Returns:the hardware version of the XBee device.
Return type:HardwareVersion

See also

get_io_configuration(io_line)

Returns the configuration of the provided IO line.

Parameters:

io_line (IOLine) – the io line to configure.

Returns:

the IO mode of the IO line provided.

Return type:

IOMode

Raises:
get_io_sampling_rate()

Returns the IO sampling rate of the XBee device.

Returns:

the IO sampling rate of XBee device.

Return type:

Integer

Raises:
get_node_id()

Returns the Node Identifier (NI) value of the XBee device.

Returns:the Node Identifier (NI) of the XBee device.
Return type:String
get_pan_id()

Returns the operating PAN ID of the XBee device.

Returns:operating PAN ID of the XBee device.
Return type:Bytearray
Raises:TimeoutException – if the response is not received before the read timeout expires.
get_power_level()

Returns the power level of the XBee device.

Returns:the power level of the XBee device.
Return type:PowerLevel
Raises:TimeoutException – if the response is not received before the read timeout expires.

See also

get_protocol()

Returns the current protocol of the XBee device.

Returns:the current protocol of the XBee device.
Return type:XBeeProtocol

See also

get_pwm_duty_cycle(io_line)

Returns the PWM duty cycle in % corresponding to the provided IO line.

Parameters:

io_line (IOLine) – the IO line to get its PWM duty cycle.

Returns:

the PWM duty cycle of the given IO line or None if the response is empty.

Return type:

Integer

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – if the response is not as expected.
  • ValueError – if the passed IO_LINE has no PWM capability.

See also

get_role()

Gets the XBee role.

Returns:the role of the XBee.
Return type:digi.xbee.models.protocol.Role
get_sync_ops_timeout()

Returns the serial port read timeout.

Returns:the serial port read timeout in seconds.
Return type:Integer
is_apply_changes_enabled()

Returns whether the apply_changes flag is enabled or not.

Returns:True if the apply_changes flag is enabled, False otherwise.
Return type:Boolean
log

Returns the XBee device log.

Returns:the XBee device logger.
Return type:Logger
read_device_info(init=True)

Updates all instance parameters reading them from the XBee device.

Parameters:

init (Boolean, optional, default=`True`) – If False only not initialized parameters are read, all if True.

Raises:
read_io_sample()

Returns an IO sample from the XBee device containing the value of all enabled digital IO and analog input channels.

Returns:

the IO sample read from the XBee device.

Return type:

IOSample

Raises:

See also

set_16bit_addr(value)

Sets the 16-bit address of the XBee device.

Parameters:

value (XBee16BitAddress) – the new 16-bit address of the XBee device.

Raises:
set_api_output_mode(api_output_mode)

Deprecated since version 1.3: Use set_api_output_mode_value()

Sets the API output mode of the XBee device.

Parameters:

api_output_mode (APIOutputMode) – the new API output mode of the XBee device.

Raises:

See also

set_api_output_mode_value(api_output_mode)

Sets the API output mode of the XBee.

Parameters:

api_output_mode (Integer) – new API output mode options. Calculate this value using the method digi.xbee.models.mode.APIOutputModeBit.calculate_api_output_mode_value() with a set of digi.xbee.models.mode.APIOutputModeBit.

Raises:
set_dest_address(addr)

Sets the 64-bit address of the XBee device that data will be reported to.

Parameters:

addr (XBee64BitAddress or RemoteXBeeDevice) – the address itself or the remote XBee device that you want to set up its address as destination address.

Raises:
  • TimeoutException – If the response is not received before the read timeout expires.
  • XBeeException – If the XBee device’s serial port is closed.
  • InvalidOperatingModeException – If the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If the response is not as expected.
  • ValueError – If addr is None.
set_dio_change_detection(io_lines_set)

Sets the digital IO lines to be monitored and sampled whenever their status changes.

A None set of lines disables this feature.

Parameters:

io_lines_set – set of IOLine.

Raises:

See also

set_dio_value(io_line, io_value)

Sets the digital value (high or low) to the provided IO line.

Parameters:
  • io_line (IOLine) – the digital IO line to sets its value.
  • io_value (IOValue) – the IO value to set to the IO line.
Raises:

See also

set_io_configuration(io_line, io_mode)

Sets the configuration of the provided IO line.

Parameters:
  • io_line (IOLine) – the IO line to configure.
  • io_mode (IOMode) – the IO mode to set to the IO line.
Raises:

See also

set_io_sampling_rate(rate)

Sets the IO sampling rate of the XBee device in seconds. A sample rate of 0 means the IO sampling feature is disabled.

Parameters:

rate (Integer) – the new IO sampling rate of the XBee device in seconds.

Raises:
set_node_id(node_id)

Sets the Node Identifier (NI) value of the XBee device..

Parameters:

node_id (String) – the new Node Identifier (NI) of the XBee device.

Raises:
  • ValueError – if node_id is None or its length is greater than 20.
  • TimeoutException – if the response is not received before the read timeout expires.
set_pan_id(value)

Sets the operating PAN ID of the XBee device.

Parameters:value (Bytearray) – the new operating PAN ID of the XBee device.. Must have only 1 or 2 bytes.
Raises:TimeoutException – if the response is not received before the read timeout expires.
set_power_level(power_level)

Sets the power level of the XBee device.

Parameters:power_level (PowerLevel) – the new power level of the XBee device.
Raises:TimeoutException – if the response is not received before the read timeout expires.

See also

set_pwm_duty_cycle(io_line, cycle)

Sets the duty cycle in % of the provided IO line.

The provided IO line must be PWM-capable, previously configured as PWM output.

Parameters:
  • io_line (IOLine) – the IO Line to be assigned.
  • cycle (Integer) – duty cycle in % to be assigned. Must be between 0 and 100.
Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – if the response is not as expected.
  • ValueError – if the given IO line does not have PWM capability or cycle is not between 0 and 100.

See also

set_sync_ops_timeout(sync_ops_timeout)

Sets the serial port read timeout.

Parameters:sync_ops_timeout (Integer) – the read timeout, expressed in seconds.
update_bluetooth_password(new_password)

Changes the password of this Bluetooth device with the new one provided.

Note that your device must have Bluetooth Low Energy support to use this method.

Parameters:

new_password (String) – New Bluetooth password.

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
update_device_data_from(device)

Updates the current device reference with the data provided for the given device.

This is only for internal use.

Parameters:device (AbstractXBeeDevice) – the XBee device to get the data from.
Returns:True if the device data has been updated, False otherwise.
Return type:Boolean
update_firmware(xml_firmware_file, xbee_firmware_file=None, bootloader_firmware_file=None, timeout=None, progress_callback=None)

Performs a firmware update operation of the device.

Parameters:
  • xml_firmware_file (String) – path of the XML file that describes the firmware to upload.
  • xbee_firmware_file (String, optional) – location of the XBee binary firmware file.
  • bootloader_firmware_file (String, optional) – location of the bootloader binary firmware file.
  • timeout (Integer, optional) – the maximum time to wait for target read operations during the update process.
  • progress_callback (Function, optional) –
    function to execute to receive progress information. Receives two
    arguments:
    • The current update task as a String
    • The current update task percentage as an Integer
Raises:
write_changes()

Writes configurable parameter values to the non-volatile memory of the XBee device so that parameter modifications persist through subsequent resets.

Parameters values remain in this device’s memory until overwritten by subsequent use of this method.

If changes are made without writing them to non-volatile memory, the module reverts back to previously saved parameters the next time the module is powered-on.

Writing the parameter modifications does not mean those values are immediately applied, this depends on the status of the ‘apply configuration changes’ option. Use method is_apply_configuration_changes_enabled() to get its status and enable_apply_configuration_changes() to enable/disable the option. If it is disabled, method apply_changes() can be used in order to manually apply the changes.

Raises:
class digi.xbee.devices.RemoteRaw802Device(local_xbee_device, x64bit_addr=None, x16bit_addr=None, node_id=None)[source]

Bases: digi.xbee.devices.RemoteXBeeDevice

This class represents a remote 802.15.4 XBee device.

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

Parameters:
  • local_xbee_device (XBeeDevice) – the local XBee device associated with the remote one.
  • x64bit_addr (XBee64BitAddress) – the 64-bit address of the remote XBee device.
  • x16bit_addr (XBee16BitAddress) – the 16-bit address of the remote XBee device.
  • node_id (String, optional) – the node identifier of the remote XBee device. Optional.
Raises:

XBeeException – if the protocol of local_xbee_device is invalid.

See also

XBee16BitAddress
XBee64BitAddress
get_protocol()[source]

Override.

set_64bit_addr(address)[source]

Sets the 64-bit address of this remote 802.15.4 device.

Parameters:address (XBee64BitAddress) – The 64-bit address to be set to the device.
Raises:ValueError – if address is None.
get_ai_status()[source]

Override.

See also

AbstractXBeeDevice._get_ai_status()
apply_changes()

Applies changes via AC command.

Raises:
apply_profile(profile_path, progress_callback=None)

Applies the given XBee profile to the XBee device.

Parameters:
  • profile_path (String) – path of the XBee profile file to apply.
  • progress_callback (Function, optional) –
    function to execute to receive progress information. Receives two
    arguments:
    • The current apply profile task as a String
    • The current apply profile task percentage as an Integer
Raises:
disable_bluetooth()

Disables the Bluetooth interface of this XBee device.

Note that your device must have Bluetooth Low Energy support to use this method.

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
enable_apply_changes(value)

Sets the apply_changes flag.

Parameters:value (Boolean) – True to enable the apply changes flag, False to disable it.
enable_bluetooth()

Enables the Bluetooth interface of this XBee device.

To work with this interface, you must also configure the Bluetooth password if not done previously. You can use the AbstractXBeeDevice.update_bluetooth_password() method for that purpose.

Note that your device must have Bluetooth Low Energy support to use this method.

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
execute_command(parameter)

Executes the provided command.

Parameters:

parameter (String) – The name of the AT command to be executed.

Raises:
get_16bit_addr()

Returns the 16-bit address of the XBee device.

Returns:the 16-bit address of the XBee device.
Return type:XBee16BitAddress

See also

get_64bit_addr()

Returns the 64-bit address of the XBee device.

Returns:the 64-bit address of the XBee device.
Return type:XBee64BitAddress

See also

get_adc_value(io_line)

Returns the analog value of the provided IO line.

The provided IO line must be previously configured as ADC. To do so, use AbstractXBeeDevice.set_io_configuration() and IOMode.ADC.

Parameters:

io_line (IOLine) – the IO line to get its ADC value.

Returns:

the analog value corresponding to the provided IO line.

Return type:

Integer

Raises:

See also

get_api_output_mode()

Deprecated since version 1.3: Use get_api_output_mode_value()

Returns the API output mode of the XBee device.

The API output mode determines the format that the received data is output through the serial interface of the XBee device.

Returns:

the API output mode of the XBee device.

Return type:

APIOutputMode

Raises:

See also

get_api_output_mode_value()

Returns the API output mode of the XBee.

The API output mode determines the format that the received data is output through the serial interface of the XBee.

Returns:

the parameter value.

Return type:

Bytearray

Raises:
get_bluetooth_mac_addr()

Reads and returns the EUI-48 Bluetooth MAC address of this XBee device in a format such as 00112233AABB.

Note that your device must have Bluetooth Low Energy support to use this method.

Returns:

The Bluetooth MAC address.

Return type:

String

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
get_comm_iface()

Returns the communication interface of the local XBee device associated to the remote one.

Returns:
the communication interface of the local XBee device associated to
the remote one.
Return type:XBeeCommunicationInterface

See also

XBeeCommunicationInterface
get_current_frame_id()

Returns the last used frame ID.

Returns:the last used frame ID.
Return type:Integer
get_dest_address()

Returns the 64-bit address of the XBee device that data will be reported to.

Returns:the address.
Return type:XBee64BitAddress
Raises:TimeoutException – if the response is not received before the read timeout expires.

See also

get_dio_value(io_line)

Returns the digital value of the provided IO line.

The provided IO line must be previously configured as digital I/O. To do so, use AbstractXBeeDevice.set_io_configuration().

Parameters:

io_line (IOLine) – the DIO line to gets its digital value.

Returns:

current value of the provided IO line.

Return type:

IOValue

Raises:

See also

get_firmware_version()

Returns the firmware version of the XBee device.

Returns:the hardware version of the XBee device.
Return type:Bytearray
get_hardware_version()

Returns the hardware version of the XBee device.

Returns:the hardware version of the XBee device.
Return type:HardwareVersion

See also

get_io_configuration(io_line)

Returns the configuration of the provided IO line.

Parameters:

io_line (IOLine) – the io line to configure.

Returns:

the IO mode of the IO line provided.

Return type:

IOMode

Raises:
get_io_sampling_rate()

Returns the IO sampling rate of the XBee device.

Returns:

the IO sampling rate of XBee device.

Return type:

Integer

Raises:
get_local_xbee_device()

Returns the local XBee device associated to the remote one.

Returns:XBeeDevice
get_node_id()

Returns the Node Identifier (NI) value of the XBee device.

Returns:the Node Identifier (NI) of the XBee device.
Return type:String
get_pan_id()

Returns the operating PAN ID of the XBee device.

Returns:operating PAN ID of the XBee device.
Return type:Bytearray
Raises:TimeoutException – if the response is not received before the read timeout expires.
get_parameter(parameter, parameter_value=None)

Override.

get_power_level()

Returns the power level of the XBee device.

Returns:the power level of the XBee device.
Return type:PowerLevel
Raises:TimeoutException – if the response is not received before the read timeout expires.

See also

get_pwm_duty_cycle(io_line)

Returns the PWM duty cycle in % corresponding to the provided IO line.

Parameters:

io_line (IOLine) – the IO line to get its PWM duty cycle.

Returns:

the PWM duty cycle of the given IO line or None if the response is empty.

Return type:

Integer

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – if the response is not as expected.
  • ValueError – if the passed IO_LINE has no PWM capability.

See also

get_role()

Gets the XBee role.

Returns:the role of the XBee.
Return type:digi.xbee.models.protocol.Role
get_serial_port()

Returns the serial port of the local XBee device associated to the remote one.

Returns:the serial port of the local XBee device associated to the remote one.
Return type:XBeeSerialPort

See also

XBeeSerialPort
get_sync_ops_timeout()

Returns the serial port read timeout.

Returns:the serial port read timeout in seconds.
Return type:Integer
is_apply_changes_enabled()

Returns whether the apply_changes flag is enabled or not.

Returns:True if the apply_changes flag is enabled, False otherwise.
Return type:Boolean
is_remote()

Override method.

log

Returns the XBee device log.

Returns:the XBee device logger.
Return type:Logger
read_device_info(init=True)

Updates all instance parameters reading them from the XBee device.

Parameters:

init (Boolean, optional, default=`True`) – If False only not initialized parameters are read, all if True.

Raises:
read_io_sample()

Returns an IO sample from the XBee device containing the value of all enabled digital IO and analog input channels.

Returns:

the IO sample read from the XBee device.

Return type:

IOSample

Raises:

See also

reset()

Override method.

set_16bit_addr(value)

Sets the 16-bit address of the XBee device.

Parameters:

value (XBee16BitAddress) – the new 16-bit address of the XBee device.

Raises:
set_api_output_mode(api_output_mode)

Deprecated since version 1.3: Use set_api_output_mode_value()

Sets the API output mode of the XBee device.

Parameters:

api_output_mode (APIOutputMode) – the new API output mode of the XBee device.

Raises:

See also

set_api_output_mode_value(api_output_mode)

Sets the API output mode of the XBee.

Parameters:

api_output_mode (Integer) – new API output mode options. Calculate this value using the method digi.xbee.models.mode.APIOutputModeBit.calculate_api_output_mode_value() with a set of digi.xbee.models.mode.APIOutputModeBit.

Raises:
set_dest_address(addr)

Sets the 64-bit address of the XBee device that data will be reported to.

Parameters:

addr (XBee64BitAddress or RemoteXBeeDevice) – the address itself or the remote XBee device that you want to set up its address as destination address.

Raises:
  • TimeoutException – If the response is not received before the read timeout expires.
  • XBeeException – If the XBee device’s serial port is closed.
  • InvalidOperatingModeException – If the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If the response is not as expected.
  • ValueError – If addr is None.
set_dio_change_detection(io_lines_set)

Sets the digital IO lines to be monitored and sampled whenever their status changes.

A None set of lines disables this feature.

Parameters:

io_lines_set – set of IOLine.

Raises:

See also

set_dio_value(io_line, io_value)

Sets the digital value (high or low) to the provided IO line.

Parameters:
  • io_line (IOLine) – the digital IO line to sets its value.
  • io_value (IOValue) – the IO value to set to the IO line.
Raises:

See also

set_io_configuration(io_line, io_mode)

Sets the configuration of the provided IO line.

Parameters:
  • io_line (IOLine) – the IO line to configure.
  • io_mode (IOMode) – the IO mode to set to the IO line.
Raises:

See also

set_io_sampling_rate(rate)

Sets the IO sampling rate of the XBee device in seconds. A sample rate of 0 means the IO sampling feature is disabled.

Parameters:

rate (Integer) – the new IO sampling rate of the XBee device in seconds.

Raises:
set_local_xbee_device(local_xbee_device)

This methods associates a XBeeDevice to the remote XBee device.

Parameters:local_xbee_device (XBeeDevice) – the new local XBee device associated to the remote one.

See also

set_node_id(node_id)

Sets the Node Identifier (NI) value of the XBee device..

Parameters:

node_id (String) – the new Node Identifier (NI) of the XBee device.

Raises:
  • ValueError – if node_id is None or its length is greater than 20.
  • TimeoutException – if the response is not received before the read timeout expires.
set_pan_id(value)

Sets the operating PAN ID of the XBee device.

Parameters:value (Bytearray) – the new operating PAN ID of the XBee device.. Must have only 1 or 2 bytes.
Raises:TimeoutException – if the response is not received before the read timeout expires.
set_parameter(parameter, value)

Override.

set_power_level(power_level)

Sets the power level of the XBee device.

Parameters:power_level (PowerLevel) – the new power level of the XBee device.
Raises:TimeoutException – if the response is not received before the read timeout expires.

See also

set_pwm_duty_cycle(io_line, cycle)

Sets the duty cycle in % of the provided IO line.

The provided IO line must be PWM-capable, previously configured as PWM output.

Parameters:
  • io_line (IOLine) – the IO Line to be assigned.
  • cycle (Integer) – duty cycle in % to be assigned. Must be between 0 and 100.
Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – if the response is not as expected.
  • ValueError – if the given IO line does not have PWM capability or cycle is not between 0 and 100.

See also

set_sync_ops_timeout(sync_ops_timeout)

Sets the serial port read timeout.

Parameters:sync_ops_timeout (Integer) – the read timeout, expressed in seconds.
update_bluetooth_password(new_password)

Changes the password of this Bluetooth device with the new one provided.

Note that your device must have Bluetooth Low Energy support to use this method.

Parameters:

new_password (String) – New Bluetooth password.

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
update_device_data_from(device)

Updates the current device reference with the data provided for the given device.

This is only for internal use.

Parameters:device (AbstractXBeeDevice) – the XBee device to get the data from.
Returns:True if the device data has been updated, False otherwise.
Return type:Boolean
update_firmware(xml_firmware_file, xbee_firmware_file=None, bootloader_firmware_file=None, timeout=None, progress_callback=None)

Performs a firmware update operation of the device.

Parameters:
  • xml_firmware_file (String) – path of the XML file that describes the firmware to upload.
  • xbee_firmware_file (String, optional) – location of the XBee binary firmware file.
  • bootloader_firmware_file (String, optional) – location of the bootloader binary firmware file.
  • timeout (Integer, optional) – the maximum time to wait for target read operations during the update process.
  • progress_callback (Function, optional) –
    function to execute to receive progress information. Receives two
    arguments:
    • The current update task as a String
    • The current update task percentage as an Integer
Raises:
write_changes()

Writes configurable parameter values to the non-volatile memory of the XBee device so that parameter modifications persist through subsequent resets.

Parameters values remain in this device’s memory until overwritten by subsequent use of this method.

If changes are made without writing them to non-volatile memory, the module reverts back to previously saved parameters the next time the module is powered-on.

Writing the parameter modifications does not mean those values are immediately applied, this depends on the status of the ‘apply configuration changes’ option. Use method is_apply_configuration_changes_enabled() to get its status and enable_apply_configuration_changes() to enable/disable the option. If it is disabled, method apply_changes() can be used in order to manually apply the changes.

Raises:
class digi.xbee.devices.RemoteDigiMeshDevice(local_xbee_device, x64bit_addr=None, node_id=None)[source]

Bases: digi.xbee.devices.RemoteXBeeDevice

This class represents a remote DigiMesh XBee device.

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

Parameters:
  • local_xbee_device (XBeeDevice) – the local XBee device associated with the remote one.
  • x64bit_addr (XBee64BitAddress) – the 64-bit address of the remote XBee device.
  • node_id (String, optional) – the node identifier of the remote XBee device. Optional.
Raises:

XBeeException – if the protocol of local_xbee_device is invalid.

See also

XBee64BitAddress
get_protocol()[source]

Override.

apply_changes()

Applies changes via AC command.

Raises:
apply_profile(profile_path, progress_callback=None)

Applies the given XBee profile to the XBee device.

Parameters:
  • profile_path (String) – path of the XBee profile file to apply.
  • progress_callback (Function, optional) –
    function to execute to receive progress information. Receives two
    arguments:
    • The current apply profile task as a String
    • The current apply profile task percentage as an Integer
Raises:
disable_bluetooth()

Disables the Bluetooth interface of this XBee device.

Note that your device must have Bluetooth Low Energy support to use this method.

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
enable_apply_changes(value)

Sets the apply_changes flag.

Parameters:value (Boolean) – True to enable the apply changes flag, False to disable it.
enable_bluetooth()

Enables the Bluetooth interface of this XBee device.

To work with this interface, you must also configure the Bluetooth password if not done previously. You can use the AbstractXBeeDevice.update_bluetooth_password() method for that purpose.

Note that your device must have Bluetooth Low Energy support to use this method.

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
execute_command(parameter)

Executes the provided command.

Parameters:

parameter (String) – The name of the AT command to be executed.

Raises:
get_16bit_addr()

Returns the 16-bit address of the XBee device.

Returns:the 16-bit address of the XBee device.
Return type:XBee16BitAddress

See also

get_64bit_addr()

Returns the 64-bit address of the XBee device.

Returns:the 64-bit address of the XBee device.
Return type:XBee64BitAddress

See also

get_adc_value(io_line)

Returns the analog value of the provided IO line.

The provided IO line must be previously configured as ADC. To do so, use AbstractXBeeDevice.set_io_configuration() and IOMode.ADC.

Parameters:

io_line (IOLine) – the IO line to get its ADC value.

Returns:

the analog value corresponding to the provided IO line.

Return type:

Integer

Raises:

See also

get_api_output_mode()

Deprecated since version 1.3: Use get_api_output_mode_value()

Returns the API output mode of the XBee device.

The API output mode determines the format that the received data is output through the serial interface of the XBee device.

Returns:

the API output mode of the XBee device.

Return type:

APIOutputMode

Raises:

See also

get_api_output_mode_value()

Returns the API output mode of the XBee.

The API output mode determines the format that the received data is output through the serial interface of the XBee.

Returns:

the parameter value.

Return type:

Bytearray

Raises:
get_bluetooth_mac_addr()

Reads and returns the EUI-48 Bluetooth MAC address of this XBee device in a format such as 00112233AABB.

Note that your device must have Bluetooth Low Energy support to use this method.

Returns:

The Bluetooth MAC address.

Return type:

String

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
get_comm_iface()

Returns the communication interface of the local XBee device associated to the remote one.

Returns:
the communication interface of the local XBee device associated to
the remote one.
Return type:XBeeCommunicationInterface

See also

XBeeCommunicationInterface
get_current_frame_id()

Returns the last used frame ID.

Returns:the last used frame ID.
Return type:Integer
get_dest_address()

Returns the 64-bit address of the XBee device that data will be reported to.

Returns:the address.
Return type:XBee64BitAddress
Raises:TimeoutException – if the response is not received before the read timeout expires.

See also

get_dio_value(io_line)

Returns the digital value of the provided IO line.

The provided IO line must be previously configured as digital I/O. To do so, use AbstractXBeeDevice.set_io_configuration().

Parameters:

io_line (IOLine) – the DIO line to gets its digital value.

Returns:

current value of the provided IO line.

Return type:

IOValue

Raises:

See also

get_firmware_version()

Returns the firmware version of the XBee device.

Returns:the hardware version of the XBee device.
Return type:Bytearray
get_hardware_version()

Returns the hardware version of the XBee device.

Returns:the hardware version of the XBee device.
Return type:HardwareVersion

See also

get_io_configuration(io_line)

Returns the configuration of the provided IO line.

Parameters:

io_line (IOLine) – the io line to configure.

Returns:

the IO mode of the IO line provided.

Return type:

IOMode

Raises:
get_io_sampling_rate()

Returns the IO sampling rate of the XBee device.

Returns:

the IO sampling rate of XBee device.

Return type:

Integer

Raises:
get_local_xbee_device()

Returns the local XBee device associated to the remote one.

Returns:XBeeDevice
get_node_id()

Returns the Node Identifier (NI) value of the XBee device.

Returns:the Node Identifier (NI) of the XBee device.
Return type:String
get_pan_id()

Returns the operating PAN ID of the XBee device.

Returns:operating PAN ID of the XBee device.
Return type:Bytearray
Raises:TimeoutException – if the response is not received before the read timeout expires.
get_parameter(parameter, parameter_value=None)

Override.

get_power_level()

Returns the power level of the XBee device.

Returns:the power level of the XBee device.
Return type:PowerLevel
Raises:TimeoutException – if the response is not received before the read timeout expires.

See also

get_pwm_duty_cycle(io_line)

Returns the PWM duty cycle in % corresponding to the provided IO line.

Parameters:

io_line (IOLine) – the IO line to get its PWM duty cycle.

Returns:

the PWM duty cycle of the given IO line or None if the response is empty.

Return type:

Integer

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – if the response is not as expected.
  • ValueError – if the passed IO_LINE has no PWM capability.

See also

get_role()

Gets the XBee role.

Returns:the role of the XBee.
Return type:digi.xbee.models.protocol.Role
get_serial_port()

Returns the serial port of the local XBee device associated to the remote one.

Returns:the serial port of the local XBee device associated to the remote one.
Return type:XBeeSerialPort

See also

XBeeSerialPort
get_sync_ops_timeout()

Returns the serial port read timeout.

Returns:the serial port read timeout in seconds.
Return type:Integer
is_apply_changes_enabled()

Returns whether the apply_changes flag is enabled or not.

Returns:True if the apply_changes flag is enabled, False otherwise.
Return type:Boolean
is_remote()

Override method.

log

Returns the XBee device log.

Returns:the XBee device logger.
Return type:Logger
read_device_info(init=True)

Updates all instance parameters reading them from the XBee device.

Parameters:

init (Boolean, optional, default=`True`) – If False only not initialized parameters are read, all if True.

Raises:
read_io_sample()

Returns an IO sample from the XBee device containing the value of all enabled digital IO and analog input channels.

Returns:

the IO sample read from the XBee device.

Return type:

IOSample

Raises:

See also

reset()

Override method.

set_16bit_addr(value)

Sets the 16-bit address of the XBee device.

Parameters:

value (XBee16BitAddress) – the new 16-bit address of the XBee device.

Raises:
set_api_output_mode(api_output_mode)

Deprecated since version 1.3: Use set_api_output_mode_value()

Sets the API output mode of the XBee device.

Parameters:

api_output_mode (APIOutputMode) – the new API output mode of the XBee device.

Raises:

See also

set_api_output_mode_value(api_output_mode)

Sets the API output mode of the XBee.

Parameters:

api_output_mode (Integer) – new API output mode options. Calculate this value using the method digi.xbee.models.mode.APIOutputModeBit.calculate_api_output_mode_value() with a set of digi.xbee.models.mode.APIOutputModeBit.

Raises:
set_dest_address(addr)

Sets the 64-bit address of the XBee device that data will be reported to.

Parameters:

addr (XBee64BitAddress or RemoteXBeeDevice) – the address itself or the remote XBee device that you want to set up its address as destination address.

Raises:
  • TimeoutException – If the response is not received before the read timeout expires.
  • XBeeException – If the XBee device’s serial port is closed.
  • InvalidOperatingModeException – If the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If the response is not as expected.
  • ValueError – If addr is None.
set_dio_change_detection(io_lines_set)

Sets the digital IO lines to be monitored and sampled whenever their status changes.

A None set of lines disables this feature.

Parameters:

io_lines_set – set of IOLine.

Raises:

See also

set_dio_value(io_line, io_value)

Sets the digital value (high or low) to the provided IO line.

Parameters:
  • io_line (IOLine) – the digital IO line to sets its value.
  • io_value (IOValue) – the IO value to set to the IO line.
Raises:

See also

set_io_configuration(io_line, io_mode)

Sets the configuration of the provided IO line.

Parameters:
  • io_line (IOLine) – the IO line to configure.
  • io_mode (IOMode) – the IO mode to set to the IO line.
Raises:

See also

set_io_sampling_rate(rate)

Sets the IO sampling rate of the XBee device in seconds. A sample rate of 0 means the IO sampling feature is disabled.

Parameters:

rate (Integer) – the new IO sampling rate of the XBee device in seconds.

Raises:
set_local_xbee_device(local_xbee_device)

This methods associates a XBeeDevice to the remote XBee device.

Parameters:local_xbee_device (XBeeDevice) – the new local XBee device associated to the remote one.

See also

set_node_id(node_id)

Sets the Node Identifier (NI) value of the XBee device..

Parameters:

node_id (String) – the new Node Identifier (NI) of the XBee device.

Raises:
  • ValueError – if node_id is None or its length is greater than 20.
  • TimeoutException – if the response is not received before the read timeout expires.
set_pan_id(value)

Sets the operating PAN ID of the XBee device.

Parameters:value (Bytearray) – the new operating PAN ID of the XBee device.. Must have only 1 or 2 bytes.
Raises:TimeoutException – if the response is not received before the read timeout expires.
set_parameter(parameter, value)

Override.

set_power_level(power_level)

Sets the power level of the XBee device.

Parameters:power_level (PowerLevel) – the new power level of the XBee device.
Raises:TimeoutException – if the response is not received before the read timeout expires.

See also

set_pwm_duty_cycle(io_line, cycle)

Sets the duty cycle in % of the provided IO line.

The provided IO line must be PWM-capable, previously configured as PWM output.

Parameters:
  • io_line (IOLine) – the IO Line to be assigned.
  • cycle (Integer) – duty cycle in % to be assigned. Must be between 0 and 100.
Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – if the response is not as expected.
  • ValueError – if the given IO line does not have PWM capability or cycle is not between 0 and 100.

See also

set_sync_ops_timeout(sync_ops_timeout)

Sets the serial port read timeout.

Parameters:sync_ops_timeout (Integer) – the read timeout, expressed in seconds.
update_bluetooth_password(new_password)

Changes the password of this Bluetooth device with the new one provided.

Note that your device must have Bluetooth Low Energy support to use this method.

Parameters:

new_password (String) – New Bluetooth password.

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
update_device_data_from(device)

Updates the current device reference with the data provided for the given device.

This is only for internal use.

Parameters:device (AbstractXBeeDevice) – the XBee device to get the data from.
Returns:True if the device data has been updated, False otherwise.
Return type:Boolean
update_firmware(xml_firmware_file, xbee_firmware_file=None, bootloader_firmware_file=None, timeout=None, progress_callback=None)

Performs a firmware update operation of the device.

Parameters:
  • xml_firmware_file (String) – path of the XML file that describes the firmware to upload.
  • xbee_firmware_file (String, optional) – location of the XBee binary firmware file.
  • bootloader_firmware_file (String, optional) – location of the bootloader binary firmware file.
  • timeout (Integer, optional) – the maximum time to wait for target read operations during the update process.
  • progress_callback (Function, optional) –
    function to execute to receive progress information. Receives two
    arguments:
    • The current update task as a String
    • The current update task percentage as an Integer
Raises:
write_changes()

Writes configurable parameter values to the non-volatile memory of the XBee device so that parameter modifications persist through subsequent resets.

Parameters values remain in this device’s memory until overwritten by subsequent use of this method.

If changes are made without writing them to non-volatile memory, the module reverts back to previously saved parameters the next time the module is powered-on.

Writing the parameter modifications does not mean those values are immediately applied, this depends on the status of the ‘apply configuration changes’ option. Use method is_apply_configuration_changes_enabled() to get its status and enable_apply_configuration_changes() to enable/disable the option. If it is disabled, method apply_changes() can be used in order to manually apply the changes.

Raises:
class digi.xbee.devices.RemoteDigiPointDevice(local_xbee_device, x64bit_addr=None, node_id=None)[source]

Bases: digi.xbee.devices.RemoteXBeeDevice

This class represents a remote DigiPoint XBee device.

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

Parameters:
  • local_xbee_device (XBeeDevice) – the local XBee device associated with the remote one.
  • x64bit_addr (XBee64BitAddress) – the 64-bit address of the remote XBee device.
  • node_id (String, optional) – the node identifier of the remote XBee device. Optional.
Raises:

XBeeException – if the protocol of local_xbee_device is invalid.

See also

XBee64BitAddress
get_protocol()[source]

Override.

apply_changes()

Applies changes via AC command.

Raises:
apply_profile(profile_path, progress_callback=None)

Applies the given XBee profile to the XBee device.

Parameters:
  • profile_path (String) – path of the XBee profile file to apply.
  • progress_callback (Function, optional) –
    function to execute to receive progress information. Receives two
    arguments:
    • The current apply profile task as a String
    • The current apply profile task percentage as an Integer
Raises:
disable_bluetooth()

Disables the Bluetooth interface of this XBee device.

Note that your device must have Bluetooth Low Energy support to use this method.

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
enable_apply_changes(value)

Sets the apply_changes flag.

Parameters:value (Boolean) – True to enable the apply changes flag, False to disable it.
enable_bluetooth()

Enables the Bluetooth interface of this XBee device.

To work with this interface, you must also configure the Bluetooth password if not done previously. You can use the AbstractXBeeDevice.update_bluetooth_password() method for that purpose.

Note that your device must have Bluetooth Low Energy support to use this method.

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
execute_command(parameter)

Executes the provided command.

Parameters:

parameter (String) – The name of the AT command to be executed.

Raises:
get_16bit_addr()

Returns the 16-bit address of the XBee device.

Returns:the 16-bit address of the XBee device.
Return type:XBee16BitAddress

See also

get_64bit_addr()

Returns the 64-bit address of the XBee device.

Returns:the 64-bit address of the XBee device.
Return type:XBee64BitAddress

See also

get_adc_value(io_line)

Returns the analog value of the provided IO line.

The provided IO line must be previously configured as ADC. To do so, use AbstractXBeeDevice.set_io_configuration() and IOMode.ADC.

Parameters:

io_line (IOLine) – the IO line to get its ADC value.

Returns:

the analog value corresponding to the provided IO line.

Return type:

Integer

Raises:

See also

get_api_output_mode()

Deprecated since version 1.3: Use get_api_output_mode_value()

Returns the API output mode of the XBee device.

The API output mode determines the format that the received data is output through the serial interface of the XBee device.

Returns:

the API output mode of the XBee device.

Return type:

APIOutputMode

Raises:

See also

get_api_output_mode_value()

Returns the API output mode of the XBee.

The API output mode determines the format that the received data is output through the serial interface of the XBee.

Returns:

the parameter value.

Return type:

Bytearray

Raises:
get_bluetooth_mac_addr()

Reads and returns the EUI-48 Bluetooth MAC address of this XBee device in a format such as 00112233AABB.

Note that your device must have Bluetooth Low Energy support to use this method.

Returns:

The Bluetooth MAC address.

Return type:

String

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
get_comm_iface()

Returns the communication interface of the local XBee device associated to the remote one.

Returns:
the communication interface of the local XBee device associated to
the remote one.
Return type:XBeeCommunicationInterface

See also

XBeeCommunicationInterface
get_current_frame_id()

Returns the last used frame ID.

Returns:the last used frame ID.
Return type:Integer
get_dest_address()

Returns the 64-bit address of the XBee device that data will be reported to.

Returns:the address.
Return type:XBee64BitAddress
Raises:TimeoutException – if the response is not received before the read timeout expires.

See also

get_dio_value(io_line)

Returns the digital value of the provided IO line.

The provided IO line must be previously configured as digital I/O. To do so, use AbstractXBeeDevice.set_io_configuration().

Parameters:

io_line (IOLine) – the DIO line to gets its digital value.

Returns:

current value of the provided IO line.

Return type:

IOValue

Raises:

See also

get_firmware_version()

Returns the firmware version of the XBee device.

Returns:the hardware version of the XBee device.
Return type:Bytearray
get_hardware_version()

Returns the hardware version of the XBee device.

Returns:the hardware version of the XBee device.
Return type:HardwareVersion

See also

get_io_configuration(io_line)

Returns the configuration of the provided IO line.

Parameters:

io_line (IOLine) – the io line to configure.

Returns:

the IO mode of the IO line provided.

Return type:

IOMode

Raises:
get_io_sampling_rate()

Returns the IO sampling rate of the XBee device.

Returns:

the IO sampling rate of XBee device.

Return type:

Integer

Raises:
get_local_xbee_device()

Returns the local XBee device associated to the remote one.

Returns:XBeeDevice
get_node_id()

Returns the Node Identifier (NI) value of the XBee device.

Returns:the Node Identifier (NI) of the XBee device.
Return type:String
get_pan_id()

Returns the operating PAN ID of the XBee device.

Returns:operating PAN ID of the XBee device.
Return type:Bytearray
Raises:TimeoutException – if the response is not received before the read timeout expires.
get_parameter(parameter, parameter_value=None)

Override.

get_power_level()

Returns the power level of the XBee device.

Returns:the power level of the XBee device.
Return type:PowerLevel
Raises:TimeoutException – if the response is not received before the read timeout expires.

See also

get_pwm_duty_cycle(io_line)

Returns the PWM duty cycle in % corresponding to the provided IO line.

Parameters:

io_line (IOLine) – the IO line to get its PWM duty cycle.

Returns:

the PWM duty cycle of the given IO line or None if the response is empty.

Return type:

Integer

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – if the response is not as expected.
  • ValueError – if the passed IO_LINE has no PWM capability.

See also

get_role()

Gets the XBee role.

Returns:the role of the XBee.
Return type:digi.xbee.models.protocol.Role
get_serial_port()

Returns the serial port of the local XBee device associated to the remote one.

Returns:the serial port of the local XBee device associated to the remote one.
Return type:XBeeSerialPort

See also

XBeeSerialPort
get_sync_ops_timeout()

Returns the serial port read timeout.

Returns:the serial port read timeout in seconds.
Return type:Integer
is_apply_changes_enabled()

Returns whether the apply_changes flag is enabled or not.

Returns:True if the apply_changes flag is enabled, False otherwise.
Return type:Boolean
is_remote()

Override method.

log

Returns the XBee device log.

Returns:the XBee device logger.
Return type:Logger
read_device_info(init=True)

Updates all instance parameters reading them from the XBee device.

Parameters:

init (Boolean, optional, default=`True`) – If False only not initialized parameters are read, all if True.

Raises:
read_io_sample()

Returns an IO sample from the XBee device containing the value of all enabled digital IO and analog input channels.

Returns:

the IO sample read from the XBee device.

Return type:

IOSample

Raises:

See also

reset()

Override method.

set_16bit_addr(value)

Sets the 16-bit address of the XBee device.

Parameters:

value (XBee16BitAddress) – the new 16-bit address of the XBee device.

Raises:
set_api_output_mode(api_output_mode)

Deprecated since version 1.3: Use set_api_output_mode_value()

Sets the API output mode of the XBee device.

Parameters:

api_output_mode (APIOutputMode) – the new API output mode of the XBee device.

Raises:

See also

set_api_output_mode_value(api_output_mode)

Sets the API output mode of the XBee.

Parameters:

api_output_mode (Integer) – new API output mode options. Calculate this value using the method digi.xbee.models.mode.APIOutputModeBit.calculate_api_output_mode_value() with a set of digi.xbee.models.mode.APIOutputModeBit.

Raises:
set_dest_address(addr)

Sets the 64-bit address of the XBee device that data will be reported to.

Parameters:

addr (XBee64BitAddress or RemoteXBeeDevice) – the address itself or the remote XBee device that you want to set up its address as destination address.

Raises:
  • TimeoutException – If the response is not received before the read timeout expires.
  • XBeeException – If the XBee device’s serial port is closed.
  • InvalidOperatingModeException – If the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If the response is not as expected.
  • ValueError – If addr is None.
set_dio_change_detection(io_lines_set)

Sets the digital IO lines to be monitored and sampled whenever their status changes.

A None set of lines disables this feature.

Parameters:

io_lines_set – set of IOLine.

Raises:

See also

set_dio_value(io_line, io_value)

Sets the digital value (high or low) to the provided IO line.

Parameters:
  • io_line (IOLine) – the digital IO line to sets its value.
  • io_value (IOValue) – the IO value to set to the IO line.
Raises:

See also

set_io_configuration(io_line, io_mode)

Sets the configuration of the provided IO line.

Parameters:
  • io_line (IOLine) – the IO line to configure.
  • io_mode (IOMode) – the IO mode to set to the IO line.
Raises:

See also

set_io_sampling_rate(rate)

Sets the IO sampling rate of the XBee device in seconds. A sample rate of 0 means the IO sampling feature is disabled.

Parameters:

rate (Integer) – the new IO sampling rate of the XBee device in seconds.

Raises:
set_local_xbee_device(local_xbee_device)

This methods associates a XBeeDevice to the remote XBee device.

Parameters:local_xbee_device (XBeeDevice) – the new local XBee device associated to the remote one.

See also

set_node_id(node_id)

Sets the Node Identifier (NI) value of the XBee device..

Parameters:

node_id (String) – the new Node Identifier (NI) of the XBee device.

Raises:
  • ValueError – if node_id is None or its length is greater than 20.
  • TimeoutException – if the response is not received before the read timeout expires.
set_pan_id(value)

Sets the operating PAN ID of the XBee device.

Parameters:value (Bytearray) – the new operating PAN ID of the XBee device.. Must have only 1 or 2 bytes.
Raises:TimeoutException – if the response is not received before the read timeout expires.
set_parameter(parameter, value)

Override.

set_power_level(power_level)

Sets the power level of the XBee device.

Parameters:power_level (PowerLevel) – the new power level of the XBee device.
Raises:TimeoutException – if the response is not received before the read timeout expires.

See also

set_pwm_duty_cycle(io_line, cycle)

Sets the duty cycle in % of the provided IO line.

The provided IO line must be PWM-capable, previously configured as PWM output.

Parameters:
  • io_line (IOLine) – the IO Line to be assigned.
  • cycle (Integer) – duty cycle in % to be assigned. Must be between 0 and 100.
Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – if the response is not as expected.
  • ValueError – if the given IO line does not have PWM capability or cycle is not between 0 and 100.

See also

set_sync_ops_timeout(sync_ops_timeout)

Sets the serial port read timeout.

Parameters:sync_ops_timeout (Integer) – the read timeout, expressed in seconds.
update_bluetooth_password(new_password)

Changes the password of this Bluetooth device with the new one provided.

Note that your device must have Bluetooth Low Energy support to use this method.

Parameters:

new_password (String) – New Bluetooth password.

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
update_device_data_from(device)

Updates the current device reference with the data provided for the given device.

This is only for internal use.

Parameters:device (AbstractXBeeDevice) – the XBee device to get the data from.
Returns:True if the device data has been updated, False otherwise.
Return type:Boolean
update_firmware(xml_firmware_file, xbee_firmware_file=None, bootloader_firmware_file=None, timeout=None, progress_callback=None)

Performs a firmware update operation of the device.

Parameters:
  • xml_firmware_file (String) – path of the XML file that describes the firmware to upload.
  • xbee_firmware_file (String, optional) – location of the XBee binary firmware file.
  • bootloader_firmware_file (String, optional) – location of the bootloader binary firmware file.
  • timeout (Integer, optional) – the maximum time to wait for target read operations during the update process.
  • progress_callback (Function, optional) –
    function to execute to receive progress information. Receives two
    arguments:
    • The current update task as a String
    • The current update task percentage as an Integer
Raises:
write_changes()

Writes configurable parameter values to the non-volatile memory of the XBee device so that parameter modifications persist through subsequent resets.

Parameters values remain in this device’s memory until overwritten by subsequent use of this method.

If changes are made without writing them to non-volatile memory, the module reverts back to previously saved parameters the next time the module is powered-on.

Writing the parameter modifications does not mean those values are immediately applied, this depends on the status of the ‘apply configuration changes’ option. Use method is_apply_configuration_changes_enabled() to get its status and enable_apply_configuration_changes() to enable/disable the option. If it is disabled, method apply_changes() can be used in order to manually apply the changes.

Raises:
class digi.xbee.devices.RemoteZigBeeDevice(local_xbee_device, x64bit_addr=None, x16bit_addr=None, node_id=None)[source]

Bases: digi.xbee.devices.RemoteXBeeDevice

This class represents a remote ZigBee XBee device.

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

Parameters:
  • local_xbee_device (XBeeDevice) – the local XBee device associated with the remote one.
  • x64bit_addr (XBee64BitAddress) – the 64-bit address of the remote XBee device.
  • x16bit_addr (XBee16BitAddress) – the 16-bit address of the remote XBee device.
  • node_id (String, optional) – the node identifier of the remote XBee device. Optional.
Raises:

XBeeException – if the protocol of local_xbee_device is invalid.

See also

XBee16BitAddress
XBee64BitAddress
get_protocol()[source]

Override.

get_ai_status()[source]

Override.

See also

AbstractXBeeDevice._get_ai_status()
force_disassociate()[source]

Override.

See also

AbstractXBeeDevice._force_disassociate()
apply_changes()

Applies changes via AC command.

Raises:
apply_profile(profile_path, progress_callback=None)

Applies the given XBee profile to the XBee device.

Parameters:
  • profile_path (String) – path of the XBee profile file to apply.
  • progress_callback (Function, optional) –
    function to execute to receive progress information. Receives two
    arguments:
    • The current apply profile task as a String
    • The current apply profile task percentage as an Integer
Raises:
disable_bluetooth()

Disables the Bluetooth interface of this XBee device.

Note that your device must have Bluetooth Low Energy support to use this method.

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
enable_apply_changes(value)

Sets the apply_changes flag.

Parameters:value (Boolean) – True to enable the apply changes flag, False to disable it.
enable_bluetooth()

Enables the Bluetooth interface of this XBee device.

To work with this interface, you must also configure the Bluetooth password if not done previously. You can use the AbstractXBeeDevice.update_bluetooth_password() method for that purpose.

Note that your device must have Bluetooth Low Energy support to use this method.

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
execute_command(parameter)

Executes the provided command.

Parameters:

parameter (String) – The name of the AT command to be executed.

Raises:
get_16bit_addr()

Returns the 16-bit address of the XBee device.

Returns:the 16-bit address of the XBee device.
Return type:XBee16BitAddress

See also

get_64bit_addr()

Returns the 64-bit address of the XBee device.

Returns:the 64-bit address of the XBee device.
Return type:XBee64BitAddress

See also

get_adc_value(io_line)

Returns the analog value of the provided IO line.

The provided IO line must be previously configured as ADC. To do so, use AbstractXBeeDevice.set_io_configuration() and IOMode.ADC.

Parameters:

io_line (IOLine) – the IO line to get its ADC value.

Returns:

the analog value corresponding to the provided IO line.

Return type:

Integer

Raises:

See also

get_api_output_mode()

Deprecated since version 1.3: Use get_api_output_mode_value()

Returns the API output mode of the XBee device.

The API output mode determines the format that the received data is output through the serial interface of the XBee device.

Returns:

the API output mode of the XBee device.

Return type:

APIOutputMode

Raises:

See also

get_api_output_mode_value()

Returns the API output mode of the XBee.

The API output mode determines the format that the received data is output through the serial interface of the XBee.

Returns:

the parameter value.

Return type:

Bytearray

Raises:
get_bluetooth_mac_addr()

Reads and returns the EUI-48 Bluetooth MAC address of this XBee device in a format such as 00112233AABB.

Note that your device must have Bluetooth Low Energy support to use this method.

Returns:

The Bluetooth MAC address.

Return type:

String

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
get_comm_iface()

Returns the communication interface of the local XBee device associated to the remote one.

Returns:
the communication interface of the local XBee device associated to
the remote one.
Return type:XBeeCommunicationInterface

See also

XBeeCommunicationInterface
get_current_frame_id()

Returns the last used frame ID.

Returns:the last used frame ID.
Return type:Integer
get_dest_address()

Returns the 64-bit address of the XBee device that data will be reported to.

Returns:the address.
Return type:XBee64BitAddress
Raises:TimeoutException – if the response is not received before the read timeout expires.

See also

get_dio_value(io_line)

Returns the digital value of the provided IO line.

The provided IO line must be previously configured as digital I/O. To do so, use AbstractXBeeDevice.set_io_configuration().

Parameters:

io_line (IOLine) – the DIO line to gets its digital value.

Returns:

current value of the provided IO line.

Return type:

IOValue

Raises:

See also

get_firmware_version()

Returns the firmware version of the XBee device.

Returns:the hardware version of the XBee device.
Return type:Bytearray
get_hardware_version()

Returns the hardware version of the XBee device.

Returns:the hardware version of the XBee device.
Return type:HardwareVersion

See also

get_io_configuration(io_line)

Returns the configuration of the provided IO line.

Parameters:

io_line (IOLine) – the io line to configure.

Returns:

the IO mode of the IO line provided.

Return type:

IOMode

Raises:
get_io_sampling_rate()

Returns the IO sampling rate of the XBee device.

Returns:

the IO sampling rate of XBee device.

Return type:

Integer

Raises:
get_local_xbee_device()

Returns the local XBee device associated to the remote one.

Returns:XBeeDevice
get_node_id()

Returns the Node Identifier (NI) value of the XBee device.

Returns:the Node Identifier (NI) of the XBee device.
Return type:String
get_pan_id()

Returns the operating PAN ID of the XBee device.

Returns:operating PAN ID of the XBee device.
Return type:Bytearray
Raises:TimeoutException – if the response is not received before the read timeout expires.
get_parameter(parameter, parameter_value=None)

Override.

get_power_level()

Returns the power level of the XBee device.

Returns:the power level of the XBee device.
Return type:PowerLevel
Raises:TimeoutException – if the response is not received before the read timeout expires.

See also

get_pwm_duty_cycle(io_line)

Returns the PWM duty cycle in % corresponding to the provided IO line.

Parameters:

io_line (IOLine) – the IO line to get its PWM duty cycle.

Returns:

the PWM duty cycle of the given IO line or None if the response is empty.

Return type:

Integer

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – if the response is not as expected.
  • ValueError – if the passed IO_LINE has no PWM capability.

See also

get_role()

Gets the XBee role.

Returns:the role of the XBee.
Return type:digi.xbee.models.protocol.Role
get_serial_port()

Returns the serial port of the local XBee device associated to the remote one.

Returns:the serial port of the local XBee device associated to the remote one.
Return type:XBeeSerialPort

See also

XBeeSerialPort
get_sync_ops_timeout()

Returns the serial port read timeout.

Returns:the serial port read timeout in seconds.
Return type:Integer
is_apply_changes_enabled()

Returns whether the apply_changes flag is enabled or not.

Returns:True if the apply_changes flag is enabled, False otherwise.
Return type:Boolean
is_remote()

Override method.

log

Returns the XBee device log.

Returns:the XBee device logger.
Return type:Logger
read_device_info(init=True)

Updates all instance parameters reading them from the XBee device.

Parameters:

init (Boolean, optional, default=`True`) – If False only not initialized parameters are read, all if True.

Raises:
read_io_sample()

Returns an IO sample from the XBee device containing the value of all enabled digital IO and analog input channels.

Returns:

the IO sample read from the XBee device.

Return type:

IOSample

Raises:

See also

reset()

Override method.

set_16bit_addr(value)

Sets the 16-bit address of the XBee device.

Parameters:

value (XBee16BitAddress) – the new 16-bit address of the XBee device.

Raises:
set_api_output_mode(api_output_mode)

Deprecated since version 1.3: Use set_api_output_mode_value()

Sets the API output mode of the XBee device.

Parameters:

api_output_mode (APIOutputMode) – the new API output mode of the XBee device.

Raises:

See also

set_api_output_mode_value(api_output_mode)

Sets the API output mode of the XBee.

Parameters:

api_output_mode (Integer) – new API output mode options. Calculate this value using the method digi.xbee.models.mode.APIOutputModeBit.calculate_api_output_mode_value() with a set of digi.xbee.models.mode.APIOutputModeBit.

Raises:
set_dest_address(addr)

Sets the 64-bit address of the XBee device that data will be reported to.

Parameters:

addr (XBee64BitAddress or RemoteXBeeDevice) – the address itself or the remote XBee device that you want to set up its address as destination address.

Raises:
  • TimeoutException – If the response is not received before the read timeout expires.
  • XBeeException – If the XBee device’s serial port is closed.
  • InvalidOperatingModeException – If the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If the response is not as expected.
  • ValueError – If addr is None.
set_dio_change_detection(io_lines_set)

Sets the digital IO lines to be monitored and sampled whenever their status changes.

A None set of lines disables this feature.

Parameters:

io_lines_set – set of IOLine.

Raises:

See also

set_dio_value(io_line, io_value)

Sets the digital value (high or low) to the provided IO line.

Parameters:
  • io_line (IOLine) – the digital IO line to sets its value.
  • io_value (IOValue) – the IO value to set to the IO line.
Raises:

See also

set_io_configuration(io_line, io_mode)

Sets the configuration of the provided IO line.

Parameters:
  • io_line (IOLine) – the IO line to configure.
  • io_mode (IOMode) – the IO mode to set to the IO line.
Raises:

See also

set_io_sampling_rate(rate)

Sets the IO sampling rate of the XBee device in seconds. A sample rate of 0 means the IO sampling feature is disabled.

Parameters:

rate (Integer) – the new IO sampling rate of the XBee device in seconds.

Raises:
set_local_xbee_device(local_xbee_device)

This methods associates a XBeeDevice to the remote XBee device.

Parameters:local_xbee_device (XBeeDevice) – the new local XBee device associated to the remote one.

See also

set_node_id(node_id)

Sets the Node Identifier (NI) value of the XBee device..

Parameters:

node_id (String) – the new Node Identifier (NI) of the XBee device.

Raises:
  • ValueError – if node_id is None or its length is greater than 20.
  • TimeoutException – if the response is not received before the read timeout expires.
set_pan_id(value)

Sets the operating PAN ID of the XBee device.

Parameters:value (Bytearray) – the new operating PAN ID of the XBee device.. Must have only 1 or 2 bytes.
Raises:TimeoutException – if the response is not received before the read timeout expires.
set_parameter(parameter, value)

Override.

set_power_level(power_level)

Sets the power level of the XBee device.

Parameters:power_level (PowerLevel) – the new power level of the XBee device.
Raises:TimeoutException – if the response is not received before the read timeout expires.

See also

set_pwm_duty_cycle(io_line, cycle)

Sets the duty cycle in % of the provided IO line.

The provided IO line must be PWM-capable, previously configured as PWM output.

Parameters:
  • io_line (IOLine) – the IO Line to be assigned.
  • cycle (Integer) – duty cycle in % to be assigned. Must be between 0 and 100.
Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – if the response is not as expected.
  • ValueError – if the given IO line does not have PWM capability or cycle is not between 0 and 100.

See also

set_sync_ops_timeout(sync_ops_timeout)

Sets the serial port read timeout.

Parameters:sync_ops_timeout (Integer) – the read timeout, expressed in seconds.
update_bluetooth_password(new_password)

Changes the password of this Bluetooth device with the new one provided.

Note that your device must have Bluetooth Low Energy support to use this method.

Parameters:

new_password (String) – New Bluetooth password.

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
update_device_data_from(device)

Updates the current device reference with the data provided for the given device.

This is only for internal use.

Parameters:device (AbstractXBeeDevice) – the XBee device to get the data from.
Returns:True if the device data has been updated, False otherwise.
Return type:Boolean
update_firmware(xml_firmware_file, xbee_firmware_file=None, bootloader_firmware_file=None, timeout=None, progress_callback=None)

Performs a firmware update operation of the device.

Parameters:
  • xml_firmware_file (String) – path of the XML file that describes the firmware to upload.
  • xbee_firmware_file (String, optional) – location of the XBee binary firmware file.
  • bootloader_firmware_file (String, optional) – location of the bootloader binary firmware file.
  • timeout (Integer, optional) – the maximum time to wait for target read operations during the update process.
  • progress_callback (Function, optional) –
    function to execute to receive progress information. Receives two
    arguments:
    • The current update task as a String
    • The current update task percentage as an Integer
Raises:
write_changes()

Writes configurable parameter values to the non-volatile memory of the XBee device so that parameter modifications persist through subsequent resets.

Parameters values remain in this device’s memory until overwritten by subsequent use of this method.

If changes are made without writing them to non-volatile memory, the module reverts back to previously saved parameters the next time the module is powered-on.

Writing the parameter modifications does not mean those values are immediately applied, this depends on the status of the ‘apply configuration changes’ option. Use method is_apply_configuration_changes_enabled() to get its status and enable_apply_configuration_changes() to enable/disable the option. If it is disabled, method apply_changes() can be used in order to manually apply the changes.

Raises:
class digi.xbee.devices.XBeeNetwork(xbee_device)[source]

Bases: object

This class represents an XBee Network.

The network allows the discovery of remote devices in the same network as the local one and stores them.

Class constructor. Instantiates a new XBeeNetwork.

Parameters:xbee_device (XBeeDevice) – the local XBee device to get the network from.
Raises:ValueError – if xbee_device is None.
ND_PACKET_FINISH = 1

Flag that indicates a “discovery process finish” packet.

ND_PACKET_REMOTE = 2

Flag that indicates a discovery process packet with info about a remote XBee device.

start_discovery_process()[source]

Starts the discovery process. This method is not blocking.

The discovery process will be running until the configured timeout expires or, in case of 802.15.4, until the ‘end’ packet is read.

It may be that, after the timeout expires, there are devices that continue sending discovery packets to this XBee device. In this case, these devices will not be added to the network.

stop_discovery_process()[source]

Stops the discovery process if it is running.

Note that DigiMesh/DigiPoint devices are blocked until the discovery time configured (NT parameter) has elapsed, so if you try to get/set any parameter during the discovery process you will receive a timeout exception.

discover_device(node_id)[source]

Blocking method. Discovers and reports the first remote XBee device that matches the supplied identifier.

Parameters:node_id (String) – the node identifier of the device to be discovered.
Returns:
the discovered remote XBee device with the given identifier,
None if the timeout expires and the device was not found.
Return type:RemoteXBeeDevice
discover_devices(device_id_list)[source]

Blocking method. Attempts to discover a list of devices and add them to the current network.

This method does not guarantee that all devices of device_id_list will be found, even if they exist physically. This will depend on the node discovery operation (ND) and timeout.

Parameters:device_id_list (List) – list of device IDs to discover.
Returns:a list with the discovered devices. It may not contain all devices specified in device_id_list
Return type:List
is_discovery_running()[source]

Returns whether the discovery process is running or not.

Returns:True if the discovery process is running, False otherwise.
Return type:Boolean
get_devices()[source]

Returns a copy of the XBee devices list of the network.

If another XBee device is added to the list before the execution of this method, this XBee device will not be added to the list returned by this method.

Returns:a copy of the XBee devices list of the network.
Return type:List
has_devices()[source]

Returns whether there is any device in the network or not.

Returns:True if there is at least one device in the network, False otherwise.
Return type:Boolean
get_number_devices()[source]

Returns the number of devices in the network.

Returns:the number of devices in the network.
Return type:Integer
add_network_modified_callback(callback)[source]

Adds a callback for the event digi.xbee.reader.NetworkModified.

Parameters:callback (Function) –

the callback. Receives one argument.

add_device_discovered_callback(callback)[source]

Adds a callback for the event DeviceDiscovered.

Parameters:callback (Function) –

the callback. Receives one argument.

add_discovery_process_finished_callback(callback)[source]

Adds a callback for the event DiscoveryProcessFinished.

Parameters:callback (Function) –

the callback. Receives one argument.

  • The event code as an Integer
del_network_modified_callback(callback)[source]

Deletes a callback for the callback list of digi.xbee.reader.NetworkModified.

Parameters:callback (Function) – the callback to delete.
del_device_discovered_callback(callback)[source]

Deletes a callback for the callback list of DeviceDiscovered event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of DeviceDiscovered event.
del_discovery_process_finished_callback(callback)[source]

Deletes a callback for the callback list of DiscoveryProcessFinished event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of DiscoveryProcessFinished event.
clear()[source]

Removes all the remote XBee devices from the network.

get_discovery_options()[source]

Returns the network discovery process options.

Returns:

the parameter value.

Return type:

Bytearray

Raises:
set_discovery_options(options)[source]

Configures the discovery options (NO parameter) with the given value.

Parameters:

options (Set of DiscoveryOptions) – new discovery options, empty set to clear the options.

Raises:
  • ValueError – if options is None.
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – if the response is not as expected.

See also

get_discovery_timeout()[source]

Returns the network discovery timeout.

Returns:

the network discovery timeout.

Return type:

Float

Raises:
set_discovery_timeout(discovery_timeout)[source]

Sets the discovery network timeout.

Parameters:

discovery_timeout (Float) – timeout in seconds.

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – if the response is not as expected.
  • ValueError – if discovery_timeout is not between 0x20 and 0xFF
get_device_by_64(x64bit_addr)[source]

Returns the XBee in the network whose 64-bit address matches the given one.

Parameters:x64bit_addr (XBee64BitAddress) – The 64-bit address of the device to be retrieved.
Returns:the XBee device in the network or None if it is not found.
Return type:AbstractXBeeDevice
Raises:ValueError – if x64bit_addr is None or unknown.
get_device_by_16(x16bit_addr)[source]

Returns the XBee in the network whose 16-bit address matches the given one.

Parameters:x16bit_addr (XBee16BitAddress) – The 16-bit address of the device to be retrieved.
Returns:the XBee device in the network or None if it is not found.
Return type:AbstractXBeeDevice
Raises:ValueError – if x16bit_addr is None or unknown.
get_device_by_node_id(node_id)[source]

Returns the XBee in the network whose node identifier matches the given one.

Parameters:node_id (String) – The node identifier of the device to be retrieved.
Returns:the XBee device in the network or None if it is not found.
Return type:AbstractXBeeDevice
Raises:ValueError – if node_id is None.
add_if_not_exist(x64bit_addr=None, x16bit_addr=None, node_id=None)[source]

Adds an XBee device with the provided parameters if it does not exist in the current network.

If the XBee device already exists, its data will be updated with the provided parameters that are not None.

Parameters:
  • x64bit_addr (XBee64BitAddress, optional) – XBee device’s 64bit address. Optional.
  • x16bit_addr (XBee16BitAddress, optional) – XBee device’s 16bit address. Optional.
  • node_id (String, optional) – the node identifier of the XBee device. Optional.
Returns:

the remote XBee device with the updated parameters. If the XBee device

was not in the list yet, this method returns the given XBee device without changes.

Return type:

AbstractXBeeDevice

add_remote(remote_xbee_device)[source]

Adds the provided remote XBee device to the network if it is not contained yet.

If the XBee device is already contained in the network, its data will be updated with the parameters of the XBee device that are not None.

Parameters:remote_xbee_device (RemoteXBeeDevice) – the remote XBee device to add to the network.
Returns:
the provided XBee device with the updated parameters. If the XBee device
was not in the list yet, this method returns it without changes.
Return type:RemoteXBeeDevice
add_remotes(remote_xbee_devices)[source]

Adds a list of remote XBee devices to the network.

If any XBee device of the list is already contained in the network, its data will be updated with the parameters of the XBee device that are not None.

Parameters:remote_xbee_devices (List) – the list of RemoteXBeeDevice to add to the network.
remove_device(remote_xbee_device)[source]

Removes the provided remote XBee device from the network.

Parameters:remote_xbee_device (RemoteXBeeDevice) – the remote XBee device to be removed from the list.
Raises:ValueError – if the provided RemoteXBeeDevice is not in the network.
get_discovery_callbacks()[source]

Returns the API callbacks that are used in the device discovery process.

This callbacks notify the user callbacks for each XBee device discovered.

Returns:
callback for generic devices discovery process,
callback for discovery specific XBee device ops.
Return type:Tuple (Function, Function)
class digi.xbee.devices.ZigBeeNetwork(device)[source]

Bases: digi.xbee.devices.XBeeNetwork

This class represents a ZigBee network.

The network allows the discovery of remote devices in the same network as the local one and stores them.

Class constructor. Instantiates a new ZigBeeNetwork.

Parameters:device (ZigBeeDevice) – the local ZigBee device to get the network from.
Raises:ValueError – if device is None.
add_device_discovered_callback(callback)

Adds a callback for the event DeviceDiscovered.

Parameters:callback (Function) –

the callback. Receives one argument.

add_discovery_process_finished_callback(callback)

Adds a callback for the event DiscoveryProcessFinished.

Parameters:callback (Function) –

the callback. Receives one argument.

  • The event code as an Integer
add_if_not_exist(x64bit_addr=None, x16bit_addr=None, node_id=None)

Adds an XBee device with the provided parameters if it does not exist in the current network.

If the XBee device already exists, its data will be updated with the provided parameters that are not None.

Parameters:
  • x64bit_addr (XBee64BitAddress, optional) – XBee device’s 64bit address. Optional.
  • x16bit_addr (XBee16BitAddress, optional) – XBee device’s 16bit address. Optional.
  • node_id (String, optional) – the node identifier of the XBee device. Optional.
Returns:

the remote XBee device with the updated parameters. If the XBee device

was not in the list yet, this method returns the given XBee device without changes.

Return type:

AbstractXBeeDevice

add_network_modified_callback(callback)

Adds a callback for the event digi.xbee.reader.NetworkModified.

Parameters:callback (Function) –

the callback. Receives one argument.

add_remote(remote_xbee_device)

Adds the provided remote XBee device to the network if it is not contained yet.

If the XBee device is already contained in the network, its data will be updated with the parameters of the XBee device that are not None.

Parameters:remote_xbee_device (RemoteXBeeDevice) – the remote XBee device to add to the network.
Returns:
the provided XBee device with the updated parameters. If the XBee device
was not in the list yet, this method returns it without changes.
Return type:RemoteXBeeDevice
add_remotes(remote_xbee_devices)

Adds a list of remote XBee devices to the network.

If any XBee device of the list is already contained in the network, its data will be updated with the parameters of the XBee device that are not None.

Parameters:remote_xbee_devices (List) – the list of RemoteXBeeDevice to add to the network.
clear()

Removes all the remote XBee devices from the network.

del_device_discovered_callback(callback)

Deletes a callback for the callback list of DeviceDiscovered event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of DeviceDiscovered event.
del_discovery_process_finished_callback(callback)

Deletes a callback for the callback list of DiscoveryProcessFinished event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of DiscoveryProcessFinished event.
del_network_modified_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.NetworkModified.

Parameters:callback (Function) – the callback to delete.
discover_device(node_id)

Blocking method. Discovers and reports the first remote XBee device that matches the supplied identifier.

Parameters:node_id (String) – the node identifier of the device to be discovered.
Returns:
the discovered remote XBee device with the given identifier,
None if the timeout expires and the device was not found.
Return type:RemoteXBeeDevice
discover_devices(device_id_list)

Blocking method. Attempts to discover a list of devices and add them to the current network.

This method does not guarantee that all devices of device_id_list will be found, even if they exist physically. This will depend on the node discovery operation (ND) and timeout.

Parameters:device_id_list (List) – list of device IDs to discover.
Returns:a list with the discovered devices. It may not contain all devices specified in device_id_list
Return type:List
get_device_by_16(x16bit_addr)

Returns the XBee in the network whose 16-bit address matches the given one.

Parameters:x16bit_addr (XBee16BitAddress) – The 16-bit address of the device to be retrieved.
Returns:the XBee device in the network or None if it is not found.
Return type:AbstractXBeeDevice
Raises:ValueError – if x16bit_addr is None or unknown.
get_device_by_64(x64bit_addr)

Returns the XBee in the network whose 64-bit address matches the given one.

Parameters:x64bit_addr (XBee64BitAddress) – The 64-bit address of the device to be retrieved.
Returns:the XBee device in the network or None if it is not found.
Return type:AbstractXBeeDevice
Raises:ValueError – if x64bit_addr is None or unknown.
get_device_by_node_id(node_id)

Returns the XBee in the network whose node identifier matches the given one.

Parameters:node_id (String) – The node identifier of the device to be retrieved.
Returns:the XBee device in the network or None if it is not found.
Return type:AbstractXBeeDevice
Raises:ValueError – if node_id is None.
get_devices()

Returns a copy of the XBee devices list of the network.

If another XBee device is added to the list before the execution of this method, this XBee device will not be added to the list returned by this method.

Returns:a copy of the XBee devices list of the network.
Return type:List
get_discovery_callbacks()

Returns the API callbacks that are used in the device discovery process.

This callbacks notify the user callbacks for each XBee device discovered.

Returns:
callback for generic devices discovery process,
callback for discovery specific XBee device ops.
Return type:Tuple (Function, Function)
get_discovery_options()

Returns the network discovery process options.

Returns:

the parameter value.

Return type:

Bytearray

Raises:
get_discovery_timeout()

Returns the network discovery timeout.

Returns:

the network discovery timeout.

Return type:

Float

Raises:
get_number_devices()

Returns the number of devices in the network.

Returns:the number of devices in the network.
Return type:Integer
has_devices()

Returns whether there is any device in the network or not.

Returns:True if there is at least one device in the network, False otherwise.
Return type:Boolean
is_discovery_running()

Returns whether the discovery process is running or not.

Returns:True if the discovery process is running, False otherwise.
Return type:Boolean
remove_device(remote_xbee_device)

Removes the provided remote XBee device from the network.

Parameters:remote_xbee_device (RemoteXBeeDevice) – the remote XBee device to be removed from the list.
Raises:ValueError – if the provided RemoteXBeeDevice is not in the network.
set_discovery_options(options)

Configures the discovery options (NO parameter) with the given value.

Parameters:

options (Set of DiscoveryOptions) – new discovery options, empty set to clear the options.

Raises:
  • ValueError – if options is None.
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – if the response is not as expected.

See also

set_discovery_timeout(discovery_timeout)

Sets the discovery network timeout.

Parameters:

discovery_timeout (Float) – timeout in seconds.

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – if the response is not as expected.
  • ValueError – if discovery_timeout is not between 0x20 and 0xFF
start_discovery_process()

Starts the discovery process. This method is not blocking.

The discovery process will be running until the configured timeout expires or, in case of 802.15.4, until the ‘end’ packet is read.

It may be that, after the timeout expires, there are devices that continue sending discovery packets to this XBee device. In this case, these devices will not be added to the network.

stop_discovery_process()

Stops the discovery process if it is running.

Note that DigiMesh/DigiPoint devices are blocked until the discovery time configured (NT parameter) has elapsed, so if you try to get/set any parameter during the discovery process you will receive a timeout exception.

class digi.xbee.devices.Raw802Network(device)[source]

Bases: digi.xbee.devices.XBeeNetwork

This class represents an 802.15.4 network.

The network allows the discovery of remote devices in the same network as the local one and stores them.

Class constructor. Instantiates a new Raw802Network.

Parameters:device (Raw802Device) – the local 802.15.4 device to get the network from.
Raises:ValueError – if device is None.
add_device_discovered_callback(callback)

Adds a callback for the event DeviceDiscovered.

Parameters:callback (Function) –

the callback. Receives one argument.

add_discovery_process_finished_callback(callback)

Adds a callback for the event DiscoveryProcessFinished.

Parameters:callback (Function) –

the callback. Receives one argument.

  • The event code as an Integer
add_if_not_exist(x64bit_addr=None, x16bit_addr=None, node_id=None)

Adds an XBee device with the provided parameters if it does not exist in the current network.

If the XBee device already exists, its data will be updated with the provided parameters that are not None.

Parameters:
  • x64bit_addr (XBee64BitAddress, optional) – XBee device’s 64bit address. Optional.
  • x16bit_addr (XBee16BitAddress, optional) – XBee device’s 16bit address. Optional.
  • node_id (String, optional) – the node identifier of the XBee device. Optional.
Returns:

the remote XBee device with the updated parameters. If the XBee device

was not in the list yet, this method returns the given XBee device without changes.

Return type:

AbstractXBeeDevice

add_network_modified_callback(callback)

Adds a callback for the event digi.xbee.reader.NetworkModified.

Parameters:callback (Function) –

the callback. Receives one argument.

add_remote(remote_xbee_device)

Adds the provided remote XBee device to the network if it is not contained yet.

If the XBee device is already contained in the network, its data will be updated with the parameters of the XBee device that are not None.

Parameters:remote_xbee_device (RemoteXBeeDevice) – the remote XBee device to add to the network.
Returns:
the provided XBee device with the updated parameters. If the XBee device
was not in the list yet, this method returns it without changes.
Return type:RemoteXBeeDevice
add_remotes(remote_xbee_devices)

Adds a list of remote XBee devices to the network.

If any XBee device of the list is already contained in the network, its data will be updated with the parameters of the XBee device that are not None.

Parameters:remote_xbee_devices (List) – the list of RemoteXBeeDevice to add to the network.
clear()

Removes all the remote XBee devices from the network.

del_device_discovered_callback(callback)

Deletes a callback for the callback list of DeviceDiscovered event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of DeviceDiscovered event.
del_discovery_process_finished_callback(callback)

Deletes a callback for the callback list of DiscoveryProcessFinished event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of DiscoveryProcessFinished event.
del_network_modified_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.NetworkModified.

Parameters:callback (Function) – the callback to delete.
discover_device(node_id)

Blocking method. Discovers and reports the first remote XBee device that matches the supplied identifier.

Parameters:node_id (String) – the node identifier of the device to be discovered.
Returns:
the discovered remote XBee device with the given identifier,
None if the timeout expires and the device was not found.
Return type:RemoteXBeeDevice
discover_devices(device_id_list)

Blocking method. Attempts to discover a list of devices and add them to the current network.

This method does not guarantee that all devices of device_id_list will be found, even if they exist physically. This will depend on the node discovery operation (ND) and timeout.

Parameters:device_id_list (List) – list of device IDs to discover.
Returns:a list with the discovered devices. It may not contain all devices specified in device_id_list
Return type:List
get_device_by_16(x16bit_addr)

Returns the XBee in the network whose 16-bit address matches the given one.

Parameters:x16bit_addr (XBee16BitAddress) – The 16-bit address of the device to be retrieved.
Returns:the XBee device in the network or None if it is not found.
Return type:AbstractXBeeDevice
Raises:ValueError – if x16bit_addr is None or unknown.
get_device_by_64(x64bit_addr)

Returns the XBee in the network whose 64-bit address matches the given one.

Parameters:x64bit_addr (XBee64BitAddress) – The 64-bit address of the device to be retrieved.
Returns:the XBee device in the network or None if it is not found.
Return type:AbstractXBeeDevice
Raises:ValueError – if x64bit_addr is None or unknown.
get_device_by_node_id(node_id)

Returns the XBee in the network whose node identifier matches the given one.

Parameters:node_id (String) – The node identifier of the device to be retrieved.
Returns:the XBee device in the network or None if it is not found.
Return type:AbstractXBeeDevice
Raises:ValueError – if node_id is None.
get_devices()

Returns a copy of the XBee devices list of the network.

If another XBee device is added to the list before the execution of this method, this XBee device will not be added to the list returned by this method.

Returns:a copy of the XBee devices list of the network.
Return type:List
get_discovery_callbacks()

Returns the API callbacks that are used in the device discovery process.

This callbacks notify the user callbacks for each XBee device discovered.

Returns:
callback for generic devices discovery process,
callback for discovery specific XBee device ops.
Return type:Tuple (Function, Function)
get_discovery_options()

Returns the network discovery process options.

Returns:

the parameter value.

Return type:

Bytearray

Raises:
get_discovery_timeout()

Returns the network discovery timeout.

Returns:

the network discovery timeout.

Return type:

Float

Raises:
get_number_devices()

Returns the number of devices in the network.

Returns:the number of devices in the network.
Return type:Integer
has_devices()

Returns whether there is any device in the network or not.

Returns:True if there is at least one device in the network, False otherwise.
Return type:Boolean
is_discovery_running()

Returns whether the discovery process is running or not.

Returns:True if the discovery process is running, False otherwise.
Return type:Boolean
remove_device(remote_xbee_device)

Removes the provided remote XBee device from the network.

Parameters:remote_xbee_device (RemoteXBeeDevice) – the remote XBee device to be removed from the list.
Raises:ValueError – if the provided RemoteXBeeDevice is not in the network.
set_discovery_options(options)

Configures the discovery options (NO parameter) with the given value.

Parameters:

options (Set of DiscoveryOptions) – new discovery options, empty set to clear the options.

Raises:
  • ValueError – if options is None.
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – if the response is not as expected.

See also

set_discovery_timeout(discovery_timeout)

Sets the discovery network timeout.

Parameters:

discovery_timeout (Float) – timeout in seconds.

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – if the response is not as expected.
  • ValueError – if discovery_timeout is not between 0x20 and 0xFF
start_discovery_process()

Starts the discovery process. This method is not blocking.

The discovery process will be running until the configured timeout expires or, in case of 802.15.4, until the ‘end’ packet is read.

It may be that, after the timeout expires, there are devices that continue sending discovery packets to this XBee device. In this case, these devices will not be added to the network.

stop_discovery_process()

Stops the discovery process if it is running.

Note that DigiMesh/DigiPoint devices are blocked until the discovery time configured (NT parameter) has elapsed, so if you try to get/set any parameter during the discovery process you will receive a timeout exception.

class digi.xbee.devices.DigiMeshNetwork(device)[source]

Bases: digi.xbee.devices.XBeeNetwork

This class represents a DigiMesh network.

The network allows the discovery of remote devices in the same network as the local one and stores them.

Class constructor. Instantiates a new DigiMeshNetwork.

Parameters:device (DigiMeshDevice) – the local DigiMesh device to get the network from.
Raises:ValueError – if device is None.
add_device_discovered_callback(callback)

Adds a callback for the event DeviceDiscovered.

Parameters:callback (Function) –

the callback. Receives one argument.

add_discovery_process_finished_callback(callback)

Adds a callback for the event DiscoveryProcessFinished.

Parameters:callback (Function) –

the callback. Receives one argument.

  • The event code as an Integer
add_if_not_exist(x64bit_addr=None, x16bit_addr=None, node_id=None)

Adds an XBee device with the provided parameters if it does not exist in the current network.

If the XBee device already exists, its data will be updated with the provided parameters that are not None.

Parameters:
  • x64bit_addr (XBee64BitAddress, optional) – XBee device’s 64bit address. Optional.
  • x16bit_addr (XBee16BitAddress, optional) – XBee device’s 16bit address. Optional.
  • node_id (String, optional) – the node identifier of the XBee device. Optional.
Returns:

the remote XBee device with the updated parameters. If the XBee device

was not in the list yet, this method returns the given XBee device without changes.

Return type:

AbstractXBeeDevice

add_network_modified_callback(callback)

Adds a callback for the event digi.xbee.reader.NetworkModified.

Parameters:callback (Function) –

the callback. Receives one argument.

add_remote(remote_xbee_device)

Adds the provided remote XBee device to the network if it is not contained yet.

If the XBee device is already contained in the network, its data will be updated with the parameters of the XBee device that are not None.

Parameters:remote_xbee_device (RemoteXBeeDevice) – the remote XBee device to add to the network.
Returns:
the provided XBee device with the updated parameters. If the XBee device
was not in the list yet, this method returns it without changes.
Return type:RemoteXBeeDevice
add_remotes(remote_xbee_devices)

Adds a list of remote XBee devices to the network.

If any XBee device of the list is already contained in the network, its data will be updated with the parameters of the XBee device that are not None.

Parameters:remote_xbee_devices (List) – the list of RemoteXBeeDevice to add to the network.
clear()

Removes all the remote XBee devices from the network.

del_device_discovered_callback(callback)

Deletes a callback for the callback list of DeviceDiscovered event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of DeviceDiscovered event.
del_discovery_process_finished_callback(callback)

Deletes a callback for the callback list of DiscoveryProcessFinished event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of DiscoveryProcessFinished event.
del_network_modified_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.NetworkModified.

Parameters:callback (Function) – the callback to delete.
discover_device(node_id)

Blocking method. Discovers and reports the first remote XBee device that matches the supplied identifier.

Parameters:node_id (String) – the node identifier of the device to be discovered.
Returns:
the discovered remote XBee device with the given identifier,
None if the timeout expires and the device was not found.
Return type:RemoteXBeeDevice
discover_devices(device_id_list)

Blocking method. Attempts to discover a list of devices and add them to the current network.

This method does not guarantee that all devices of device_id_list will be found, even if they exist physically. This will depend on the node discovery operation (ND) and timeout.

Parameters:device_id_list (List) – list of device IDs to discover.
Returns:a list with the discovered devices. It may not contain all devices specified in device_id_list
Return type:List
get_device_by_16(x16bit_addr)

Returns the XBee in the network whose 16-bit address matches the given one.

Parameters:x16bit_addr (XBee16BitAddress) – The 16-bit address of the device to be retrieved.
Returns:the XBee device in the network or None if it is not found.
Return type:AbstractXBeeDevice
Raises:ValueError – if x16bit_addr is None or unknown.
get_device_by_64(x64bit_addr)

Returns the XBee in the network whose 64-bit address matches the given one.

Parameters:x64bit_addr (XBee64BitAddress) – The 64-bit address of the device to be retrieved.
Returns:the XBee device in the network or None if it is not found.
Return type:AbstractXBeeDevice
Raises:ValueError – if x64bit_addr is None or unknown.
get_device_by_node_id(node_id)

Returns the XBee in the network whose node identifier matches the given one.

Parameters:node_id (String) – The node identifier of the device to be retrieved.
Returns:the XBee device in the network or None if it is not found.
Return type:AbstractXBeeDevice
Raises:ValueError – if node_id is None.
get_devices()

Returns a copy of the XBee devices list of the network.

If another XBee device is added to the list before the execution of this method, this XBee device will not be added to the list returned by this method.

Returns:a copy of the XBee devices list of the network.
Return type:List
get_discovery_callbacks()

Returns the API callbacks that are used in the device discovery process.

This callbacks notify the user callbacks for each XBee device discovered.

Returns:
callback for generic devices discovery process,
callback for discovery specific XBee device ops.
Return type:Tuple (Function, Function)
get_discovery_options()

Returns the network discovery process options.

Returns:

the parameter value.

Return type:

Bytearray

Raises:
get_discovery_timeout()

Returns the network discovery timeout.

Returns:

the network discovery timeout.

Return type:

Float

Raises:
get_number_devices()

Returns the number of devices in the network.

Returns:the number of devices in the network.
Return type:Integer
has_devices()

Returns whether there is any device in the network or not.

Returns:True if there is at least one device in the network, False otherwise.
Return type:Boolean
is_discovery_running()

Returns whether the discovery process is running or not.

Returns:True if the discovery process is running, False otherwise.
Return type:Boolean
remove_device(remote_xbee_device)

Removes the provided remote XBee device from the network.

Parameters:remote_xbee_device (RemoteXBeeDevice) – the remote XBee device to be removed from the list.
Raises:ValueError – if the provided RemoteXBeeDevice is not in the network.
set_discovery_options(options)

Configures the discovery options (NO parameter) with the given value.

Parameters:

options (Set of DiscoveryOptions) – new discovery options, empty set to clear the options.

Raises:
  • ValueError – if options is None.
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – if the response is not as expected.

See also

set_discovery_timeout(discovery_timeout)

Sets the discovery network timeout.

Parameters:

discovery_timeout (Float) – timeout in seconds.

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – if the response is not as expected.
  • ValueError – if discovery_timeout is not between 0x20 and 0xFF
start_discovery_process()

Starts the discovery process. This method is not blocking.

The discovery process will be running until the configured timeout expires or, in case of 802.15.4, until the ‘end’ packet is read.

It may be that, after the timeout expires, there are devices that continue sending discovery packets to this XBee device. In this case, these devices will not be added to the network.

stop_discovery_process()

Stops the discovery process if it is running.

Note that DigiMesh/DigiPoint devices are blocked until the discovery time configured (NT parameter) has elapsed, so if you try to get/set any parameter during the discovery process you will receive a timeout exception.

class digi.xbee.devices.DigiPointNetwork(device)[source]

Bases: digi.xbee.devices.XBeeNetwork

This class represents a DigiPoint network.

The network allows the discovery of remote devices in the same network as the local one and stores them.

Class constructor. Instantiates a new DigiPointNetwork.

Parameters:device (DigiPointDevice) – the local DigiPoint device to get the network from.
Raises:ValueError – if device is None.
add_device_discovered_callback(callback)

Adds a callback for the event DeviceDiscovered.

Parameters:callback (Function) –

the callback. Receives one argument.

add_discovery_process_finished_callback(callback)

Adds a callback for the event DiscoveryProcessFinished.

Parameters:callback (Function) –

the callback. Receives one argument.

  • The event code as an Integer
add_if_not_exist(x64bit_addr=None, x16bit_addr=None, node_id=None)

Adds an XBee device with the provided parameters if it does not exist in the current network.

If the XBee device already exists, its data will be updated with the provided parameters that are not None.

Parameters:
  • x64bit_addr (XBee64BitAddress, optional) – XBee device’s 64bit address. Optional.
  • x16bit_addr (XBee16BitAddress, optional) – XBee device’s 16bit address. Optional.
  • node_id (String, optional) – the node identifier of the XBee device. Optional.
Returns:

the remote XBee device with the updated parameters. If the XBee device

was not in the list yet, this method returns the given XBee device without changes.

Return type:

AbstractXBeeDevice

add_network_modified_callback(callback)

Adds a callback for the event digi.xbee.reader.NetworkModified.

Parameters:callback (Function) –

the callback. Receives one argument.

add_remote(remote_xbee_device)

Adds the provided remote XBee device to the network if it is not contained yet.

If the XBee device is already contained in the network, its data will be updated with the parameters of the XBee device that are not None.

Parameters:remote_xbee_device (RemoteXBeeDevice) – the remote XBee device to add to the network.
Returns:
the provided XBee device with the updated parameters. If the XBee device
was not in the list yet, this method returns it without changes.
Return type:RemoteXBeeDevice
add_remotes(remote_xbee_devices)

Adds a list of remote XBee devices to the network.

If any XBee device of the list is already contained in the network, its data will be updated with the parameters of the XBee device that are not None.

Parameters:remote_xbee_devices (List) – the list of RemoteXBeeDevice to add to the network.
clear()

Removes all the remote XBee devices from the network.

del_device_discovered_callback(callback)

Deletes a callback for the callback list of DeviceDiscovered event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of DeviceDiscovered event.
del_discovery_process_finished_callback(callback)

Deletes a callback for the callback list of DiscoveryProcessFinished event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of DiscoveryProcessFinished event.
del_network_modified_callback(callback)

Deletes a callback for the callback list of digi.xbee.reader.NetworkModified.

Parameters:callback (Function) – the callback to delete.
discover_device(node_id)

Blocking method. Discovers and reports the first remote XBee device that matches the supplied identifier.

Parameters:node_id (String) – the node identifier of the device to be discovered.
Returns:
the discovered remote XBee device with the given identifier,
None if the timeout expires and the device was not found.
Return type:RemoteXBeeDevice
discover_devices(device_id_list)

Blocking method. Attempts to discover a list of devices and add them to the current network.

This method does not guarantee that all devices of device_id_list will be found, even if they exist physically. This will depend on the node discovery operation (ND) and timeout.

Parameters:device_id_list (List) – list of device IDs to discover.
Returns:a list with the discovered devices. It may not contain all devices specified in device_id_list
Return type:List
get_device_by_16(x16bit_addr)

Returns the XBee in the network whose 16-bit address matches the given one.

Parameters:x16bit_addr (XBee16BitAddress) – The 16-bit address of the device to be retrieved.
Returns:the XBee device in the network or None if it is not found.
Return type:AbstractXBeeDevice
Raises:ValueError – if x16bit_addr is None or unknown.
get_device_by_64(x64bit_addr)

Returns the XBee in the network whose 64-bit address matches the given one.

Parameters:x64bit_addr (XBee64BitAddress) – The 64-bit address of the device to be retrieved.
Returns:the XBee device in the network or None if it is not found.
Return type:AbstractXBeeDevice
Raises:ValueError – if x64bit_addr is None or unknown.
get_device_by_node_id(node_id)

Returns the XBee in the network whose node identifier matches the given one.

Parameters:node_id (String) – The node identifier of the device to be retrieved.
Returns:the XBee device in the network or None if it is not found.
Return type:AbstractXBeeDevice
Raises:ValueError – if node_id is None.
get_devices()

Returns a copy of the XBee devices list of the network.

If another XBee device is added to the list before the execution of this method, this XBee device will not be added to the list returned by this method.

Returns:a copy of the XBee devices list of the network.
Return type:List
get_discovery_callbacks()

Returns the API callbacks that are used in the device discovery process.

This callbacks notify the user callbacks for each XBee device discovered.

Returns:
callback for generic devices discovery process,
callback for discovery specific XBee device ops.
Return type:Tuple (Function, Function)
get_discovery_options()

Returns the network discovery process options.

Returns:

the parameter value.

Return type:

Bytearray

Raises:
get_discovery_timeout()

Returns the network discovery timeout.

Returns:

the network discovery timeout.

Return type:

Float

Raises:
get_number_devices()

Returns the number of devices in the network.

Returns:the number of devices in the network.
Return type:Integer
has_devices()

Returns whether there is any device in the network or not.

Returns:True if there is at least one device in the network, False otherwise.
Return type:Boolean
is_discovery_running()

Returns whether the discovery process is running or not.

Returns:True if the discovery process is running, False otherwise.
Return type:Boolean
remove_device(remote_xbee_device)

Removes the provided remote XBee device from the network.

Parameters:remote_xbee_device (RemoteXBeeDevice) – the remote XBee device to be removed from the list.
Raises:ValueError – if the provided RemoteXBeeDevice is not in the network.
set_discovery_options(options)

Configures the discovery options (NO parameter) with the given value.

Parameters:

options (Set of DiscoveryOptions) – new discovery options, empty set to clear the options.

Raises:
  • ValueError – if options is None.
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – if the response is not as expected.

See also

set_discovery_timeout(discovery_timeout)

Sets the discovery network timeout.

Parameters:

discovery_timeout (Float) – timeout in seconds.

Raises:
  • TimeoutException – if the response is not received before the read timeout expires.
  • XBeeException – if the XBee device’s serial port is closed.
  • InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – if the response is not as expected.
  • ValueError – if discovery_timeout is not between 0x20 and 0xFF
start_discovery_process()

Starts the discovery process. This method is not blocking.

The discovery process will be running until the configured timeout expires or, in case of 802.15.4, until the ‘end’ packet is read.

It may be that, after the timeout expires, there are devices that continue sending discovery packets to this XBee device. In this case, these devices will not be added to the network.

stop_discovery_process()

Stops the discovery process if it is running.

Note that DigiMesh/DigiPoint devices are blocked until the discovery time configured (NT parameter) has elapsed, so if you try to get/set any parameter during the discovery process you will receive a timeout exception.

class digi.xbee.devices.NetworkEventType(code, description)[source]

Bases: enum.Enum

Enumerates the different network event types.
Values:
NetworkEventType.ADD = (0, ‘XBee added to the network’)
NetworkEventType.DEL = (1, ‘XBee removed from the network’)
NetworkEventType.UPDATE = (2, ‘XBee in the network updated’)
NetworkEventType.CLEAR = (3, ‘Network cleared’)

code

Returns the code of the NetworkEventType element.

Returns:the code of the NetworkEventType element.
Return type:Integer
description

Returns the description of the NetworkEventType element.

Returns:the description of the NetworkEventType element.
Return type:String
class digi.xbee.devices.NetworkEventReason(code, description)[source]

Bases: enum.Enum

Enumerates the different network event reasons.
Values:
NetworkEventReason.DISCOVERED = (0, ‘Discovered XBee’)
NetworkEventReason.RECEIVED_MSG = (1, ‘Received message from XBee’)
NetworkEventReason.MANUAL = (2, ‘Manual modification’)

code

Returns the code of the NetworkEventReason element.

Returns:the code of the NetworkEventReason element.
Return type:Integer
description

Returns the description of the NetworkEventReason element.

Returns:the description of the NetworkEventReason element.
Return type:String