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, default=`None`) – Only necessary if XBee is remote. The local XBee to be the connection interface to communicate with the remote XBee one.
  • serial_port (XBeeSerialPort, optional, default=`None`) – Only necessary if the XBee device is local. The serial port to communicate with this XBee.
  • (Integer, optional, default (sync_ops_timeout) – AbstractXBeeDevice._DEFAULT_TIMEOUT_SYNC_OPERATIONS): Timeout (in seconds) for all synchronous operations.
  • comm_iface (XBeeCommunicationInterface, optional, default=`None`) – Only necessary if the XBee is local. The hardware interface to communicate with this XBee.
update_device_data_from(device)[source]

Updates the current node information with provided data. This is only for internal use.

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

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

Parameters:
  • (String or (parameter) – class: .ATStringCommand): Parameter to get.
  • parameter_value (Bytearray, optional, default=`None`) – Value of the parameter to execute (if any).
  • apply (Boolean, optional, default=`None`) – True to apply changes in XBee configuration, False not to apply them, None to use is_apply_changes_enabled() returned value.
Returns:

Parameter value.

Return type:

Bytearray

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
set_parameter(parameter, value, apply=None)[source]

Sets the value of a parameter via an AT Command.

Any parameter changes are applied automatically, if apply is True or if it is None and apply flag is enabled (is_apply_changes_enabled())

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

This only applies modified values in the XBee configuration, to save changed parameters permanently (between resets), use AbstractXBeeDevice.write_changes().

Parameters:
  • (String or (parameter) – class: .ATStringCommand): Parameter to set.
  • value (Bytearray) – Value of the parameter.
  • apply (Boolean, optional, default=`None`) – True to apply changes, False otherwise, None to use is_apply_changes_enabled() returned value.
Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
  • ValueError – If parameter is None or value is None.
execute_command(parameter, value=None, apply=None)[source]

Executes the provided command.

Parameters:
  • (String or (parameter) – class: .ATStringCommand): AT command to execute.
  • value (bytearray, optional, default=`None`) – Command value (if any).
  • apply (Boolean, optional, default=`None`) – True to apply changes in XBee configuration, False not to apply them, None to use is_apply_changes_enabled() returned value.
Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
apply_changes()[source]

Applies changes via ‘AC’ command.

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

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

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

If changes are made without writing them, the XBee 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_changes_enabled() to get its status and enable_apply_changes() to enable/disable the option. Method apply_changes() can be used in order to manually apply the changes.

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

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

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
read_device_info(init=True, fire_event=True)[source]

Updates all instance parameters reading them from the XBee.

Parameters:
  • init (Boolean, optional, default=`True`) – If False only not initialized parameters are read, all if True.
  • fire_event (Boolean, optional, default=`True`) – True to throw and update event if any parameter changed, False otherwise.
Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
determine_protocol(hardware_version, firmware_version)[source]

Determines the XBee protocol based on the given hardware and firmware versions.

Parameters:
  • hardware_version (Integer) – Hardware version to get its protocol.
  • firmware_version (Bytearray) – Firmware version to get its protocol.
Returns:

XBee protocol corresponding to the given

hardware and firmware versions.

Return type:

XBeeProtocol

is_device_info_complete()[source]

Returns whether XBee node information is complete.

Returns:True if node information is complete, False otherwise.
Return type:Boolean
get_node_id()[source]

Returns the node identifier (‘NI’) value of the XBee.

Returns:Node identifier (‘NI’) of the XBee.
Return type:String
set_node_id(node_id)[source]

Sets the node identifier (‘NI`) value of the XBee.

Parameters:

node_id (String) – New node identifier (‘NI’) of the XBee.

Raises:
  • ValueError – If node_id is None or its length is greater than 20.
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
get_hardware_version()[source]

Returns the hardware version of the XBee.

Returns:Hardware version of the XBee.
Return type:HardwareVersion

See also

get_firmware_version()[source]

Returns the firmware version of the XBee.

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

Returns the current protocol of the XBee.

Returns:Current protocol of the XBee.
Return type:XBeeProtocol

See also

get_16bit_addr()[source]

Returns the 16-bit address of the XBee.

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

See also

set_16bit_addr(value)[source]

Sets the 16-bit address of the XBee.

Parameters:

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

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
  • OperationNotSupportedException – If the protocol is not 802.15.4.
get_64bit_addr()[source]

Returns the 64-bit address of the XBee.

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

See also

get_role()[source]

Gets the XBee role.

Returns:the role of the XBee.
Return type:Role

See also

get_current_frame_id()[source]

Returns the last used frame ID.

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

Sets apply changes flag.

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

Returns whether apply changes flag is enabled.

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

Determines whether XBee is remote.

Returns:True if the XBee 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) – Read timeout in seconds.
get_sync_ops_timeout()[source]

Returns the serial port read timeout.

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

Returns the 64-bit address of the XBee that is data destination.

Returns:

64-bit address of destination XBee.

Return type:

XBee64BitAddress

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

Sets the 64-bit address of the XBee that is data destination.

Parameters:

addr (XBee64BitAddress or RemoteXBeeDevice) – Address itself or remote XBee to be data destination.

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

Returns the operating PAN ID of the XBee.

Returns:

Operating PAN ID of the XBee.

Return type:

Bytearray

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.

See also

set_pan_id(value)[source]

Sets the operating PAN ID of the XBee.

Parameters:

value (Bytearray) – New operating PAN ID of the XBee. Must have only 1 or 2 bytes.

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.

See also

get_power_level()[source]

Returns the power level of the XBee.

Returns:

Power level of the XBee.

Return type:

PowerLevel

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
set_power_level(power_level)[source]

Sets the power level of the XBee.

Parameters:

power_level (PowerLevel) – New power level of the XBee.

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
set_io_configuration(io_line, io_mode)[source]

Sets the configuration of the provided IO line.

Parameters:
  • io_line (IOLine) – IO line to configure.
  • io_mode (IOMode) – IO mode to set to the IO line.
Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
get_io_configuration(io_line)[source]

Returns the configuration of the provided IO line.

Parameters:

io_line (IOLine) – IO line to get its configuration.

Returns:

IO mode of the IO line provided.

Return type:

IOMode

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

Returns the IO sampling rate of the XBee.

Returns:

IO sampling rate of XBee.

Return type:

Integer

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
set_io_sampling_rate(rate)[source]

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

Parameters:

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

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

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

Returns:

IO sample read from the XBee.

Return type:

IOSample

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.

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) – IO line to get its ADC value.

Returns:

Analog value corresponding to the provided IO line.

Return type:

Integer

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
  • OperationNotSupportedException – If response does not contain the value for the given IO line.
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) – IO Line to be assigned.
  • cycle (Integer) – Duty cycle in % to be assigned. Must be between 0 and 100.
Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If 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) – IO line to get its PWM duty cycle.

Returns:

PWM duty cycle of the given IO line.

Return type:

Integer

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
  • ValueError – If 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:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
  • OperationNotSupportedException – If response does not contain the value for the given IO line.
set_dio_value(io_line, io_value)[source]

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

Parameters:
  • io_line (IOLine) – Digital IO line to sets its value.
  • io_value (IOValue) – IO value to set to the IO line.
Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.

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:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.

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.

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

Returns:

API output mode of the XBee.

Return type:

APIOutputMode

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.

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:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
  • OperationNotSupportedException – If it is not supported by the current protocol.
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.

Parameters:

api_output_mode (APIOutputMode) – New API output mode.

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
  • OperationNotSupportedException – If it is not supported by the current protocol.

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 APIOutputModeBit.calculate_api_output_mode_value() with a set of APIOutputModeBit.

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
  • OperationNotSupportedException – If it is not supported by the current protocol.

See also

enable_bluetooth()[source]

Enables the Bluetooth interface of this XBee.

To work with this interface, you must also configure the Bluetooth password if not done previously. Use method AbstractXBeeDevice.update_bluetooth_password().

Note that your XBee must include Bluetooth Low Energy support.

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

Disables the Bluetooth interface of this XBee.

Note that your device must include Bluetooth Low Energy support.

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

Reads and returns the EUI-48 Bluetooth MAC address of this XBee following the format 00112233AABB.

Note that your device must include Bluetooth Low Energy support.

Returns:

The Bluetooth MAC address.

Return type:

String

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

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

Note that your device must include Bluetooth Low Energy support.

Parameters:

new_password (String) – New Bluetooth password.

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
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 XBee.

Parameters:
  • xml_firmware_file (String) – Path of the XML file that describes the firmware to upload.
  • xbee_firmware_file (String, optional, default=`None`) – Location of the XBee binary firmware file.
  • bootloader_firmware_file (String, optional, default=`None`) – Location of the bootloader binary firmware file.
  • timeout (Integer, optional, default=`None`) – Maximum time to wait for target read operations during the update process (seconds).
  • progress_callback (Function, optional, default=`None`) –

    Function to to receive progress information. Receives two arguments:

    • The current update task as a String
    • The current update task percentage as an Integer
Raises:
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • OperationNotSupportedException – If XBee does not support firmware update.
  • FirmwareUpdateException – If there is any error during the firmware update.
apply_profile(profile_path, timeout=None, progress_callback=None)[source]

Applies the given XBee profile to the XBee.

Parameters:
  • profile_path (String) – Path of the XBee profile file to apply.
  • timeout (Integer, optional, default=`None`) – Maximum time to wait for target read operations during the apply profile (seconds).
  • progress_callback (Function, optional, default=`None`) –

    Function 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:
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • UpdateProfileException – If there is any error applying the XBee profile.
get_file_manager()[source]

Returns the file system manager for the XBee.

Returns:The file system manager.
Return type:FileSystemManager
Raises:FileSystemNotSupportedException – If the XBee does not support filesystem.
reachable

Returns whether the XBee is reachable.

Returns:True if the device is reachable, False otherwise.
Return type:Boolean
scan_counter

Returns the scan counter for this node.

Returns:The scan counter for this node.
Return type:Integer
log

Returns the XBee logger.

Returns:The XBee device logger.
Return type: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.

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 (String) – Serial port identifier. Depends on operating system. e.g. ‘/dev/ttyUSB0’ on ‘GNU/Linux’ or ‘COM3’ on Windows.
  • baud_rate (Integer, optional, default=`None`) – Serial port baud rate.
  • (Integer, default (_sync_ops_timeout) – serial.EIGHTBITS): Port bitsize.
  • (Integer, defaultserial.STOPBITS_ONE): Port stop bits.
  • (Character, default (parity) – serial.PARITY_NONE): Port parity.
  • (Integer, defaultFlowControl.NONE): Port flow control.
  • (Integer, default – 4): Read timeout (in seconds).
  • comm_iface (XBeeCommunicationInterface) – 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:

XBee object created.

Return type:

XBeeDevice

Raises:

SerialException – If the port to open does not exist or is already opened.

See also

open(force_settings=False)[source]

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

Parameters:

force_settings (Boolean, optional, default=`False`) – 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.

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

Closes the communication with the XBee.

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

serial_port

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

Returns:
Serial port of the XBee. None if the
local XBee does not use serial communication.
Return type:XBeeSerialPort

See also

comm_iface

Returns the hardware interface associated to the XBee.

Returns:Hardware interface of the XBee.
Return type:XBeeCommunicationInterface
operating_mode

Returns the operating mode of this XBee.

Returns:OperatingMode. This XBee operating mode.
get_parameter(parameter, parameter_value=None, apply=None)[source]

Override.

set_parameter(parameter, value, apply=None)[source]

Override.

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

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

This method will wait for the packet response. The default timeout is XBeeDevice._DEFAULT_TIMEOUT_SYNC_OPERATIONS.

Parameters:
  • remote_xbee (RemoteXBeeDevice) – Remote XBee to send data to.
  • data (String or Bytearray) – Raw data to send.
  • transmit_options (Integer, optional) – Transmit options, bitfield of TransmitOptions. Default to TransmitOptions.NONE.value.
Returns:

The response.

Return type:

XBeePacket

Raises:
  • ValueError – If remote_xbee is None.
  • TimeoutException – If response is not received before the read timeout expires.
  • InvalidOperatingModeException – If the XBee’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’s communication interface is closed.
send_data_async(remote_xbee, data, transmit_options=0)[source]

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

This method does not wait for a response.

Parameters:
  • remote_xbee (RemoteXBeeDevice) – the remote XBee to send data to.
  • data (String or Bytearray) – Raw data to send.
  • transmit_options (Integer, optional) – Transmit options, bitfield of TransmitOptions. Default to TransmitOptions.NONE.value.
Raises:
  • ValueError – If remote_xbee is None.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – If the XBee’s communication interface 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 until a success or error transmit status arrives or the configured receive timeout expires.

The received timeout is configured using method AbstractXBeeDevice.set_sync_ops_timeout() 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 response is not received before the read timeout expires.
  • InvalidOperatingModeException – If the XBee’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’s communication interface 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’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’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’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.

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

Parameters:

timeout (Integer, optional) – Read timeout in seconds. If None, this method is non-blocking and returns None if no data is available.

Returns:

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’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – If the XBee’s communication interface is closed.

See also

read_data_from(remote_xbee, timeout=None)[source]

Reads new data received from the given remote XBee.

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

Parameters:
  • remote_xbee (RemoteXBeeDevice) – Remote XBee that sent the data.
  • timeout (Integer, optional) – Read timeout in seconds. If None, this method is non-blocking and returns None if no data is available.
Returns:

Read message sent by remote_xbee 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’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – If the XBee’s communication interface is closed.
has_packets()[source]

Returns if there are pending packets to read. This does not include explicit packets.

Returns:True if there are pending packets, False otherwise.
Return type:Boolean
has_explicit_packets()[source]

Returns if there are pending explicit packets to read. This does not include non-explicit packets.

Returns:True if there are pending 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 PacketReceived.

Parameters:callback (Function) –

The callback. Receives one argument.

add_data_received_callback(callback)[source]

Adds a callback for the event DataReceived.

Parameters:callback (Function) –

The callback. Receives one argument.

add_modem_status_received_callback(callback)[source]

Adds a callback for the event ModemStatusReceived.

Parameters:callback (Function) –

The callback. Receives one argument.

add_io_sample_received_callback(callback)[source]

Adds a callback for the event IOSampleReceived.

Parameters:callback (Function) –

The callback. Receives three arguments.

  • The received IO sample as an IOSample.
  • The remote XBee which sent the packet as a RemoteXBeeDevice.
  • The time in which the packet was received as an Integer.
add_expl_data_received_callback(callback)[source]

Adds a callback for the event ExplicitDataReceived.

Parameters:callback (Function) –

The callback. Receives one argument.

add_user_data_relay_received_callback(callback)[source]

Adds a callback for the event RelayDataReceived.

Parameters:callback (Function) –

The callback. Receives one argument.

add_bluetooth_data_received_callback(callback)[source]

Adds a callback for the event 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 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 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 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 SocketDataReceivedFrom.

Parameters:callback (Function) –

The callback. Receives three arguments.

  • The socket ID as an Integer.
  • Source address pair (host, port) 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_fs_frame_received_callback(callback)[source]

Adds a callback for the event FileSystemFrameReceived.

Parameters:callback (Function) –

The callback. Receives four arguments.

  • Source (AbstractXBeeDevice): The node that sent the file system frame.
  • Frame id (Integer): The received frame id.
  • Command (FSCmd): The file system command.
  • Receive options (Integer): Bitfield indicating receive options.
del_packet_received_callback(callback)[source]

Deletes a callback for the callback list of PacketReceived event.

Parameters:callback (Function) – The callback to delete.
del_data_received_callback(callback)[source]

Deletes a callback for the callback list of DataReceived event.

Parameters:callback (Function) – The callback to delete.
del_modem_status_received_callback(callback)[source]

Deletes a callback for the callback list of ModemStatusReceived event.

Parameters:callback (Function) – The callback to delete.
del_io_sample_received_callback(callback)[source]

Deletes a callback for the callback list of IOSampleReceived event.

Parameters:callback (Function) – The callback to delete.
del_expl_data_received_callback(callback)[source]

Deletes a callback for the callback list of ExplicitDataReceived event.

Parameters:callback (Function) – The callback to delete.
del_user_data_relay_received_callback(callback)[source]

Deletes a callback for the callback list of RelayDataReceived event.

Parameters:callback (Function) – The callback to delete.
del_bluetooth_data_received_callback(callback)[source]

Deletes a callback for the callback list of BluetoothDataReceived event.

Parameters:callback (Function) – The callback to delete.
del_micropython_data_received_callback(callback)[source]

Deletes a callback for the callback list of MicroPythonDataReceived event.

Parameters:callback (Function) – The callback to delete.
del_socket_state_received_callback(callback)[source]

Deletes a callback for the callback list of SocketStateReceived event.

Parameters:callback (Function) – The callback to delete.
del_socket_data_received_callback(callback)[source]

Deletes a callback for the callback list of SocketDataReceived event.

Parameters:callback (Function) – The callback to delete.
del_socket_data_received_from_callback(callback)[source]

Deletes a callback for the callback list of SocketDataReceivedFrom event.

Parameters:callback (Function) – The callback to delete.
del_fs_frame_received_callback(callback)[source]

Deletes a callback for the callback list of FileSystemFrameReceived event.

Parameters:callback (Function) – The callback to delete.
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 are executed before user callbacks.

Returns:PacketReceived
is_open()[source]

Returns whether this XBee is open.

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

Override method.

get_network()[source]

Returns the network of this XBee.

Returns:The XBee network.
Return type:XBeeNetwork
send_packet_sync_and_get_response(packet_to_send, timeout=None)[source]

Sends the packet and waits for its corresponding response.

Parameters:
  • packet_to_send (XBeePacket) – The packet to transmit.
  • timeout (Integer, optional, default=`None`) – Number of seconds to wait. -1 to wait indefinitely.
Returns:

Received response packet.

Return type:

XBeePacket

Raises:
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • TimeoutException – If response is not received in the configured timeout.
  • XBeeException – If the XBee’s communication interface is closed.

See also

send_packet(packet, sync=False)[source]

Sends the packet and waits for the response. The packet to send is escaped depending on the current operating mode.

This method can be synchronous or asynchronous.

If synchronous, this method discards all response packets until it finds the one that has the appropriate frame ID, that is, the sent packet’s frame ID.

If asynchronous, this method does not wait for any response and returns None.

Parameters:
  • packet (XBeePacket) – The packet to send.
  • sync (Boolean) – True to wait for the response of the sent packet and return it, False otherwise.
Returns:

Response packet if sync is True, None

otherwise.

Return type:

XBeePacket

Raises:
  • TimeoutException – If sync is True and the response packet for the sent one cannot be read.
  • InvalidOperatingModeException – If the XBee operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – If the packet listener is not running or the XBee’s communication interface is closed.

See also

get_next_frame_id()[source]

Returns the next frame ID of the XBee.

Returns:The next frame ID of the XBee.
Return type:Integer
add_route_received_callback(callback)[source]

Adds a callback for the event RouteReceived. This works for Zigbee and Digimesh devices.

Parameters:callback (Function) –

The callback. Receives three arguments.

del_route_received_callback(callback)[source]

Deletes a callback for the callback list of RouteReceived event.

Parameters:callback (Function) – The callback to delete.
get_route_to_node(remote, timeout=10, force=True)[source]

Gets the route from this XBee to the given remote node.

For Zigbee:
  • ‘AR’ parameter of the local node must be configured with a value different from ‘FF’.
  • Set force to True to force the Zigbee remote node to return its route independently of the local node configuration as high or low RAM concentrator (‘DO’ of the local value)
Parameters:
  • remote (RemoteXBeeDevice) – The remote node.
  • timeout (Float, optional, default=10) – Maximum number of seconds to wait for the route.
  • force (Boolean) – True to force asking for the route, False otherwise. Only for Zigbee.
Returns:

Tuple containing route data:
  • status (TransmitStatus): The transmit status.

  • Tuple with route data (None if the route was not read in the provided timeout):

    • source (RemoteXBeeDevice): The source node of the route.
    • destination (RemoteXBeeDevice): The destination node of the route.
    • hops (List): List of intermediate nodes (RemoteXBeeDevice) ordered from closest to source to closest to destination node (source and destination not included).

Return type:

Tuple

apply_changes()

Applies changes via ‘AC’ command.

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
apply_profile(profile_path, timeout=None, progress_callback=None)

Applies the given XBee profile to the XBee.

Parameters:
  • profile_path (String) – Path of the XBee profile file to apply.
  • timeout (Integer, optional, default=`None`) – Maximum time to wait for target read operations during the apply profile (seconds).
  • progress_callback (Function, optional, default=`None`) –

    Function 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:
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • UpdateProfileException – If there is any error applying the XBee profile.
determine_protocol(hardware_version, firmware_version)

Determines the XBee protocol based on the given hardware and firmware versions.

Parameters:
  • hardware_version (Integer) – Hardware version to get its protocol.
  • firmware_version (Bytearray) – Firmware version to get its protocol.
Returns:

XBee protocol corresponding to the given

hardware and firmware versions.

Return type:

XBeeProtocol

disable_bluetooth()

Disables the Bluetooth interface of this XBee.

Note that your device must include Bluetooth Low Energy support.

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
enable_apply_changes(value)

Sets apply changes flag.

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

Enables the Bluetooth interface of this XBee.

To work with this interface, you must also configure the Bluetooth password if not done previously. Use method AbstractXBeeDevice.update_bluetooth_password().

Note that your XBee must include Bluetooth Low Energy support.

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
execute_command(parameter, value=None, apply=None)

Executes the provided command.

Parameters:
  • (String or (parameter) – class: .ATStringCommand): AT command to execute.
  • value (bytearray, optional, default=`None`) – Command value (if any).
  • apply (Boolean, optional, default=`None`) – True to apply changes in XBee configuration, False not to apply them, None to use is_apply_changes_enabled() returned value.
Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
get_16bit_addr()

Returns the 16-bit address of the XBee.

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

See also

get_64bit_addr()

Returns the 64-bit address of the XBee.

Returns:64-bit address of the XBee.
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) – IO line to get its ADC value.

Returns:

Analog value corresponding to the provided IO line.

Return type:

Integer

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
  • OperationNotSupportedException – If response does not contain the value for the given IO line.
get_api_output_mode()

Deprecated since version 1.3: Use get_api_output_mode_value()

Returns the API output mode of the XBee.

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

Returns:

API output mode of the XBee.

Return type:

APIOutputMode

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.

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:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
  • OperationNotSupportedException – If it is not supported by the current protocol.
get_bluetooth_mac_addr()

Reads and returns the EUI-48 Bluetooth MAC address of this XBee following the format 00112233AABB.

Note that your device must include Bluetooth Low Energy support.

Returns:

The Bluetooth MAC address.

Return type:

String

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
get_current_frame_id()

Returns the last used frame ID.

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

Returns the 64-bit address of the XBee that is data destination.

Returns:

64-bit address of destination XBee.

Return type:

XBee64BitAddress

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
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:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
  • OperationNotSupportedException – If response does not contain the value for the given IO line.
get_file_manager()

Returns the file system manager for the XBee.

Returns:The file system manager.
Return type:FileSystemManager
Raises:FileSystemNotSupportedException – If the XBee does not support filesystem.
get_firmware_version()

Returns the firmware version of the XBee.

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

Returns the hardware version of the XBee.

Returns:Hardware version of the XBee.
Return type:HardwareVersion

See also

get_io_configuration(io_line)

Returns the configuration of the provided IO line.

Parameters:

io_line (IOLine) – IO line to get its configuration.

Returns:

IO mode of the IO line provided.

Return type:

IOMode

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
get_io_sampling_rate()

Returns the IO sampling rate of the XBee.

Returns:

IO sampling rate of XBee.

Return type:

Integer

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
get_node_id()

Returns the node identifier (‘NI’) value of the XBee.

Returns:Node identifier (‘NI’) of the XBee.
Return type:String
get_pan_id()

Returns the operating PAN ID of the XBee.

Returns:

Operating PAN ID of the XBee.

Return type:

Bytearray

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.

See also

get_power_level()

Returns the power level of the XBee.

Returns:

Power level of the XBee.

Return type:

PowerLevel

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
get_protocol()

Returns the current protocol of the XBee.

Returns:Current protocol of the XBee.
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) – IO line to get its PWM duty cycle.

Returns:

PWM duty cycle of the given IO line.

Return type:

Integer

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

See also

get_role()

Gets the XBee role.

Returns:the role of the XBee.
Return type:Role

See also

get_sync_ops_timeout()

Returns the serial port read timeout.

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

Returns whether apply changes flag is enabled.

Returns:True if apply changes flag is enabled, False otherwise.
Return type:Boolean
is_device_info_complete()

Returns whether XBee node information is complete.

Returns:True if node information is complete, False otherwise.
Return type:Boolean
log

Returns the XBee logger.

Returns:The XBee device logger.
Return type:Logger
reachable

Returns whether the XBee is reachable.

Returns:True if the device is reachable, False otherwise.
Return type:Boolean
read_device_info(init=True, fire_event=True)

Updates all instance parameters reading them from the XBee.

Parameters:
  • init (Boolean, optional, default=`True`) – If False only not initialized parameters are read, all if True.
  • fire_event (Boolean, optional, default=`True`) – True to throw and update event if any parameter changed, False otherwise.
Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
read_io_sample()

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

Returns:

IO sample read from the XBee.

Return type:

IOSample

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.

See also

scan_counter

Returns the scan counter for this node.

Returns:The scan counter for this node.
Return type:Integer
set_16bit_addr(value)

Sets the 16-bit address of the XBee.

Parameters:

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

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
  • OperationNotSupportedException – If the protocol is not 802.15.4.
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.

Parameters:

api_output_mode (APIOutputMode) – New API output mode.

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
  • OperationNotSupportedException – If it is not supported by the current protocol.

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 APIOutputModeBit.calculate_api_output_mode_value() with a set of APIOutputModeBit.

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
  • OperationNotSupportedException – If it is not supported by the current protocol.

See also

set_dest_address(addr)

Sets the 64-bit address of the XBee that is data destination.

Parameters:

addr (XBee64BitAddress or RemoteXBeeDevice) – Address itself or remote XBee to be data destination.

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If 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:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.

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) – Digital IO line to sets its value.
  • io_value (IOValue) – IO value to set to the IO line.
Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.

See also

set_io_configuration(io_line, io_mode)

Sets the configuration of the provided IO line.

Parameters:
  • io_line (IOLine) – IO line to configure.
  • io_mode (IOMode) – IO mode to set to the IO line.
Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
set_io_sampling_rate(rate)

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

Parameters:

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

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
set_node_id(node_id)

Sets the node identifier (‘NI`) value of the XBee.

Parameters:

node_id (String) – New node identifier (‘NI’) of the XBee.

Raises:
  • ValueError – If node_id is None or its length is greater than 20.
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
set_pan_id(value)

Sets the operating PAN ID of the XBee.

Parameters:

value (Bytearray) – New operating PAN ID of the XBee. Must have only 1 or 2 bytes.

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.

See also

set_power_level(power_level)

Sets the power level of the XBee.

Parameters:

power_level (PowerLevel) – New power level of the XBee.

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
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) – IO Line to be assigned.
  • cycle (Integer) – Duty cycle in % to be assigned. Must be between 0 and 100.
Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If 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) – Read timeout in seconds.
update_bluetooth_password(new_password)

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

Note that your device must include Bluetooth Low Energy support.

Parameters:

new_password (String) – New Bluetooth password.

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

Updates the current node information with provided data. This is only for internal use.

Parameters:device (AbstractXBeeDevice) – XBee to get the data from.
Returns:True if the node 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 XBee.

Parameters:
  • xml_firmware_file (String) – Path of the XML file that describes the firmware to upload.
  • xbee_firmware_file (String, optional, default=`None`) – Location of the XBee binary firmware file.
  • bootloader_firmware_file (String, optional, default=`None`) – Location of the bootloader binary firmware file.
  • timeout (Integer, optional, default=`None`) – Maximum time to wait for target read operations during the update process (seconds).
  • progress_callback (Function, optional, default=`None`) –

    Function to to receive progress information. Receives two arguments:

    • The current update task as a String
    • The current update task percentage as an Integer
Raises:
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • OperationNotSupportedException – If XBee does not support firmware update.
  • FirmwareUpdateException – If there is any error during the firmware update.
write_changes()

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

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

If changes are made without writing them, the XBee 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_changes_enabled() to get its status and enable_apply_changes() to enable/disable the option. Method apply_changes() can be used in order to manually apply the changes.

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
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.

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

Parameters:
  • port (String) – Serial port identifier. Depends on operating system. e.g. ‘/dev/ttyUSB0’ on ‘GNU/Linux’ or ‘COM3’ on Windows.
  • baud_rate (Integer) – Serial port baud rate.
  • (Integer, default (flow_control) – serial.EIGHTBITS): Port bitsize.
  • (Integer, defaultserial.STOPBITS_ONE): Port stop bits.
  • (Character, default (parity) – serial.PARITY_NONE): Port parity.
  • (Integer, default

    FlowControl.NONE): Port flow control.

    _sync_ops_timeout (Integer, default: 3): Read timeout (in seconds).
    comm_iface (XBeeCommunicationInterface): Communication interface.
Raises:

All exceptions raised by XBeeDevice.__init__() constructor.

See also

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

Override.

get_protocol()[source]

Override.

get_ai_status()[source]

Returns the current association status of this XBee. It indicates occurrences of errors during the modem initialization and connection.

Returns:

The XBee association

indication status.

Return type:

AssociationIndicationStatus

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
send_data_64(x64addr, data, transmit_options=0)[source]

Blocking method. This method sends data to a remote XBee with the given 64-bit address.

This method waits for the packet response. The default timeout is XBeeDevice._DEFAULT_TIMEOUT_SYNC_OPERATIONS.

Parameters:
  • x64addr (XBee64BitAddress) – 64-bit address of the destination XBee.
  • data (String or Bytearray) – Raw data to send.
  • transmit_options (Integer, optional) – Transmit options, bitfield of TransmitOptions. Default to TransmitOptions.NONE.value.
Returns:

The response.

Return type:

XBeePacket

Raises:
  • ValueError – If x64addr or data is None.
  • TimeoutException – If response is not received before the read timeout expires.
  • InvalidOperatingModeException – If the XBee’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’s communication interface is closed.
send_data_async_64(x64addr, data, transmit_options=0)[source]

Non-blocking method. This method sends data to a remote XBee with the given 64-bit address.

This method does not wait for a response.

Parameters:
  • x64addr (XBee64BitAddress) – 64-bit address of the destination XBee.
  • data (String or Bytearray) – Raw data to send.
  • transmit_options (Integer, optional) – Transmit options, bitfield of TransmitOptions. Default to TransmitOptions.NONE.value.
Raises:
  • ValueError – If x64addr or data is None.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – If the XBee’s communication interface is closed.
send_data_16(x16addr, data, transmit_options=0)[source]

Blocking method. This method sends data to a remote XBee with the given 16-bit address.

This method will wait for the packet response. The default timeout is XBeeDevice._DEFAULT_TIMEOUT_SYNC_OPERATIONS.

Parameters:
  • x16addr (XBee16BitAddress) – 16-bit address of the destination XBee.
  • data (String or Bytearray) – Raw data to send.
  • transmit_options (Integer, optional) – Transmit options, bitfield of TransmitOptions. Default to TransmitOptions.NONE.value.
Returns:

The response.

Return type:

XBeePacket

Raises:
  • ValueError – If x16addr or data is None.
  • TimeoutException – If response is not received before the read timeout expires.
  • InvalidOperatingModeException – If the XBee’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’s communication interface is closed.
send_data_async_16(x16addr, data, transmit_options=0)[source]

Non-blocking method. This method sends data to a remote XBee with the given 16-bit address.

This method does not wait for a response.

Parameters:
  • x16addr (XBee16BitAddress) – 16-bit address of the destination XBee.
  • data (String or Bytearray) – Raw data to send.
  • transmit_options (Integer, optional) – Transmit options, bitfield of TransmitOptions. Default to TransmitOptions.NONE.value.
Raises:
  • ValueError – If x16addr or data is None.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – If the XBee’s communication interface is closed.
add_bluetooth_data_received_callback(callback)

Adds a callback for the event 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 DataReceived.

Parameters:callback (Function) –

The callback. Receives one argument.

add_expl_data_received_callback(callback)

Adds a callback for the event ExplicitDataReceived.

Parameters:callback (Function) –

The callback. Receives one argument.

add_fs_frame_received_callback(callback)

Adds a callback for the event FileSystemFrameReceived.

Parameters:callback (Function) –

The callback. Receives four arguments.

  • Source (AbstractXBeeDevice): The node that sent the file system frame.
  • Frame id (Integer): The received frame id.
  • Command (FSCmd): The file system command.
  • Receive options (Integer): Bitfield indicating receive options.
add_io_sample_received_callback(callback)

Adds a callback for the event IOSampleReceived.

Parameters:callback (Function) –

The callback. Receives three arguments.

  • The received IO sample as an IOSample.
  • The remote XBee which sent the packet as a RemoteXBeeDevice.
  • The time in which the packet was received as an Integer.
add_micropython_data_received_callback(callback)

Adds a callback for the event 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 ModemStatusReceived.

Parameters:callback (Function) –

The callback. Receives one argument.

add_packet_received_callback(callback)

Adds a callback for the event PacketReceived.

Parameters:callback (Function) –

The callback. Receives one argument.

add_route_received_callback(callback)

Adds a callback for the event RouteReceived. This works for Zigbee and Digimesh devices.

Parameters:callback (Function) –

The callback. Receives three arguments.

add_socket_data_received_callback(callback)

Adds a callback for the event 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 SocketDataReceivedFrom.

Parameters:callback (Function) –

The callback. Receives three arguments.

  • The socket ID as an Integer.
  • Source address pair (host, port) 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 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 RelayDataReceived.

Parameters:callback (Function) –

The callback. Receives one argument.

apply_changes()

Applies changes via ‘AC’ command.

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
apply_profile(profile_path, timeout=None, progress_callback=None)

Applies the given XBee profile to the XBee.

Parameters:
  • profile_path (String) – Path of the XBee profile file to apply.
  • timeout (Integer, optional, default=`None`) – Maximum time to wait for target read operations during the apply profile (seconds).
  • progress_callback (Function, optional, default=`None`) –

    Function 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:
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • UpdateProfileException – If there is any error applying the XBee profile.
close()

Closes the communication with the XBee.

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.

Returns:Hardware interface of the XBee.
Return type:XBeeCommunicationInterface
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:

XBee object created.

Return type:

XBeeDevice

Raises:

SerialException – If the port 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 BluetoothDataReceived event.

Parameters:callback (Function) – The callback to delete.
del_data_received_callback(callback)

Deletes a callback for the callback list of DataReceived event.

Parameters:callback (Function) – The callback to delete.
del_expl_data_received_callback(callback)

Deletes a callback for the callback list of ExplicitDataReceived event.

Parameters:callback (Function) – The callback to delete.
del_fs_frame_received_callback(callback)

Deletes a callback for the callback list of FileSystemFrameReceived event.

Parameters:callback (Function) – The callback to delete.
del_io_sample_received_callback(callback)

Deletes a callback for the callback list of IOSampleReceived event.

Parameters:callback (Function) – The callback to delete.
del_micropython_data_received_callback(callback)

Deletes a callback for the callback list of MicroPythonDataReceived event.

Parameters:callback (Function) – The callback to delete.
del_modem_status_received_callback(callback)

Deletes a callback for the callback list of ModemStatusReceived event.

Parameters:callback (Function) – The callback to delete.
del_packet_received_callback(callback)

Deletes a callback for the callback list of PacketReceived event.

Parameters:callback (Function) – The callback to delete.
del_route_received_callback(callback)

Deletes a callback for the callback list of RouteReceived event.

Parameters:callback (Function) – The callback to delete.
del_socket_data_received_callback(callback)

Deletes a callback for the callback list of SocketDataReceived event.

Parameters:callback (Function) – The callback to delete.
del_socket_data_received_from_callback(callback)

Deletes a callback for the callback list of SocketDataReceivedFrom event.

Parameters:callback (Function) – The callback to delete.
del_socket_state_received_callback(callback)

Deletes a callback for the callback list of SocketStateReceived event.

Parameters:callback (Function) – The callback to delete.
del_user_data_relay_received_callback(callback)

Deletes a callback for the callback list of RelayDataReceived event.

Parameters:callback (Function) – The callback to delete.
determine_protocol(hardware_version, firmware_version)

Determines the XBee protocol based on the given hardware and firmware versions.

Parameters:
  • hardware_version (Integer) – Hardware version to get its protocol.
  • firmware_version (Bytearray) – Firmware version to get its protocol.
Returns:

XBee protocol corresponding to the given

hardware and firmware versions.

Return type:

XBeeProtocol

disable_bluetooth()

Disables the Bluetooth interface of this XBee.

Note that your device must include Bluetooth Low Energy support.

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
enable_apply_changes(value)

Sets apply changes flag.

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

Enables the Bluetooth interface of this XBee.

To work with this interface, you must also configure the Bluetooth password if not done previously. Use method AbstractXBeeDevice.update_bluetooth_password().

Note that your XBee must include Bluetooth Low Energy support.

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
execute_command(parameter, value=None, apply=None)

Executes the provided command.

Parameters:
  • (String or (parameter) – class: .ATStringCommand): AT command to execute.
  • value (bytearray, optional, default=`None`) – Command value (if any).
  • apply (Boolean, optional, default=`None`) – True to apply changes in XBee configuration, False not to apply them, None to use is_apply_changes_enabled() returned value.
Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
flush_queues()

Flushes the packets queue.

get_16bit_addr()

Returns the 16-bit address of the XBee.

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

See also

get_64bit_addr()

Returns the 64-bit address of the XBee.

Returns:64-bit address of the XBee.
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) – IO line to get its ADC value.

Returns:

Analog value corresponding to the provided IO line.

Return type:

Integer

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
  • OperationNotSupportedException – If response does not contain the value for the given IO line.
get_api_output_mode()

Deprecated since version 1.3: Use get_api_output_mode_value()

Returns the API output mode of the XBee.

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

Returns:

API output mode of the XBee.

Return type:

APIOutputMode

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.

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:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
  • OperationNotSupportedException – If it is not supported by the current protocol.
get_bluetooth_mac_addr()

Reads and returns the EUI-48 Bluetooth MAC address of this XBee following the format 00112233AABB.

Note that your device must include Bluetooth Low Energy support.

Returns:

The Bluetooth MAC address.

Return type:

String

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
get_current_frame_id()

Returns the last used frame ID.

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

Returns the 64-bit address of the XBee that is data destination.

Returns:

64-bit address of destination XBee.

Return type:

XBee64BitAddress

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
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:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
  • OperationNotSupportedException – If response does not contain the value for the given IO line.
get_file_manager()

Returns the file system manager for the XBee.

Returns:The file system manager.
Return type:FileSystemManager
Raises:FileSystemNotSupportedException – If the XBee does not support filesystem.
get_firmware_version()

Returns the firmware version of the XBee.

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

Returns the hardware version of the XBee.

Returns:Hardware version of the XBee.
Return type:HardwareVersion

See also

get_io_configuration(io_line)

Returns the configuration of the provided IO line.

Parameters:

io_line (IOLine) – IO line to get its configuration.

Returns:

IO mode of the IO line provided.

Return type:

IOMode

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
get_io_sampling_rate()

Returns the IO sampling rate of the XBee.

Returns:

IO sampling rate of XBee.

Return type:

Integer

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
get_network()

Returns the network of this XBee.

Returns:The XBee network.
Return type:XBeeNetwork
get_next_frame_id()

Returns the next frame ID of the XBee.

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

Returns the node identifier (‘NI’) value of the XBee.

Returns:Node identifier (‘NI’) of the XBee.
Return type:String
get_pan_id()

Returns the operating PAN ID of the XBee.

Returns:

Operating PAN ID of the XBee.

Return type:

Bytearray

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.

See also

get_parameter(parameter, parameter_value=None, apply=None)

Override.

get_power_level()

Returns the power level of the XBee.

Returns:

Power level of the XBee.

Return type:

PowerLevel

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
get_pwm_duty_cycle(io_line)

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

Parameters:

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

Returns:

PWM duty cycle of the given IO line.

Return type:

Integer

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

See also

get_role()

Gets the XBee role.

Returns:the role of the XBee.
Return type:Role

See also

get_route_to_node(remote, timeout=10, force=True)

Gets the route from this XBee to the given remote node.

For Zigbee:
  • ‘AR’ parameter of the local node must be configured with a value different from ‘FF’.
  • Set force to True to force the Zigbee remote node to return its route independently of the local node configuration as high or low RAM concentrator (‘DO’ of the local value)
Parameters:
  • remote (RemoteXBeeDevice) – The remote node.
  • timeout (Float, optional, default=10) – Maximum number of seconds to wait for the route.
  • force (Boolean) – True to force asking for the route, False otherwise. Only for Zigbee.
Returns:

Tuple containing route data:
  • status (TransmitStatus): The transmit status.

  • Tuple with route data (None if the route was not read in the provided timeout):

    • source (RemoteXBeeDevice): The source node of the route.
    • destination (RemoteXBeeDevice): The destination node of the route.
    • hops (List): List of intermediate nodes (RemoteXBeeDevice) ordered from closest to source to closest to destination node (source and destination not included).

Return type:

Tuple

get_sync_ops_timeout()

Returns the serial port read timeout.

Returns: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 are executed before user callbacks.

Returns:PacketReceived
has_explicit_packets()

Returns if there are pending explicit packets to read. This does not include non-explicit packets.

Returns:True if there are pending packets, False otherwise.
Return type:Boolean
has_packets()

Returns if there are pending packets to read. This does not include explicit packets.

Returns:True if there are pending packets, False otherwise.
Return type:Boolean
is_apply_changes_enabled()

Returns whether apply changes flag is enabled.

Returns:True if apply changes flag is enabled, False otherwise.
Return type:Boolean
is_device_info_complete()

Returns whether XBee node information is complete.

Returns:True if node information is complete, False otherwise.
Return type:Boolean
is_open()

Returns whether this XBee is open.

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

Override method.

log

Returns the XBee logger.

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

Returns the operating mode of this XBee.

Returns:OperatingMode. This XBee operating mode.
reachable

Returns whether the XBee is reachable.

Returns:True if the device is reachable, False otherwise.
Return type:Boolean
read_data(timeout=None)

Reads new data received by this XBee.

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

Parameters:

timeout (Integer, optional) – Read timeout in seconds. If None, this method is non-blocking and returns None if no data is available.

Returns:

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’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – If the XBee’s communication interface is closed.

See also

read_data_from(remote_xbee, timeout=None)

Reads new data received from the given remote XBee.

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

Parameters:
  • remote_xbee (RemoteXBeeDevice) – Remote XBee that sent the data.
  • timeout (Integer, optional) – Read timeout in seconds. If None, this method is non-blocking and returns None if no data is available.
Returns:

Read message sent by remote_xbee 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’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – If the XBee’s communication interface is closed.
read_device_info(init=True, fire_event=True)

Updates all instance parameters reading them from the XBee.

Parameters:
  • init (Boolean, optional, default=`True`) – If False only not initialized parameters are read, all if True.
  • fire_event (Boolean, optional, default=`True`) – True to throw and update event if any parameter changed, False otherwise.
Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
read_io_sample()

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

Returns:

IO sample read from the XBee.

Return type:

IOSample

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.

See also

reset()

Override method.

scan_counter

Returns the scan counter for this node.

Returns:The scan counter for this node.
Return type:Integer
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’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, data, transmit_options=0)

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

This method will wait for the packet response. The default timeout is XBeeDevice._DEFAULT_TIMEOUT_SYNC_OPERATIONS.

Parameters:
  • remote_xbee (RemoteXBeeDevice) – Remote XBee to send data to.
  • data (String or Bytearray) – Raw data to send.
  • transmit_options (Integer, optional) – Transmit options, bitfield of TransmitOptions. Default to TransmitOptions.NONE.value.
Returns:

The response.

Return type:

XBeePacket

Raises:
  • ValueError – If remote_xbee is None.
  • TimeoutException – If response is not received before the read timeout expires.
  • InvalidOperatingModeException – If the XBee’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’s communication interface is closed.
send_data_async(remote_xbee, data, transmit_options=0)

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

This method does not wait for a response.

Parameters:
  • remote_xbee (RemoteXBeeDevice) – the remote XBee to send data to.
  • data (String or Bytearray) – Raw data to send.
  • transmit_options (Integer, optional) – Transmit options, bitfield of TransmitOptions. Default to TransmitOptions.NONE.value.
Raises:
  • ValueError – If remote_xbee is None.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – If the XBee’s communication interface 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 until a success or error transmit status arrives or the configured receive timeout expires.

The received timeout is configured using method AbstractXBeeDevice.set_sync_ops_timeout() 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 response is not received before the read timeout expires.
  • InvalidOperatingModeException – If the XBee’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’s communication interface 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’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)

Sends the packet and waits for the response. The packet to send is escaped depending on the current operating mode.

This method can be synchronous or asynchronous.

If synchronous, this method discards all response packets until it finds the one that has the appropriate frame ID, that is, the sent packet’s frame ID.

If asynchronous, this method does not wait for any response and returns None.

Parameters:
  • packet (XBeePacket) – The packet to send.
  • sync (Boolean) – True to wait for the response of the sent packet and return it, False otherwise.
Returns:

Response packet if sync is True, None

otherwise.

Return type:

XBeePacket

Raises:
  • TimeoutException – If sync is True and the response packet for the sent one cannot be read.
  • InvalidOperatingModeException – If the XBee operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – If the packet listener is not running or the XBee’s communication interface is closed.

See also

send_packet_sync_and_get_response(packet_to_send, timeout=None)

Sends the packet and waits for its corresponding response.

Parameters:
  • packet_to_send (XBeePacket) – The packet to transmit.
  • timeout (Integer, optional, default=`None`) – Number of seconds to wait. -1 to wait indefinitely.
Returns:

Received response packet.

Return type:

XBeePacket

Raises:
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • TimeoutException – If response is not received in the configured timeout.
  • XBeeException – If the XBee’s communication interface is closed.

See also

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’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, if any.

Returns:
Serial port of the XBee. 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.

Parameters:

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

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
  • OperationNotSupportedException – If the protocol is not 802.15.4.
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.

Parameters:

api_output_mode (APIOutputMode) – New API output mode.

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
  • OperationNotSupportedException – If it is not supported by the current protocol.

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 APIOutputModeBit.calculate_api_output_mode_value() with a set of APIOutputModeBit.

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
  • OperationNotSupportedException – If it is not supported by the current protocol.

See also

set_dest_address(addr)

Sets the 64-bit address of the XBee that is data destination.

Parameters:

addr (XBee64BitAddress or RemoteXBeeDevice) – Address itself or remote XBee to be data destination.

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If 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:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.

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) – Digital IO line to sets its value.
  • io_value (IOValue) – IO value to set to the IO line.
Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.

See also

set_io_configuration(io_line, io_mode)

Sets the configuration of the provided IO line.

Parameters:
  • io_line (IOLine) – IO line to configure.
  • io_mode (IOMode) – IO mode to set to the IO line.
Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
set_io_sampling_rate(rate)

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

Parameters:

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

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
set_node_id(node_id)

Sets the node identifier (‘NI`) value of the XBee.

Parameters:

node_id (String) – New node identifier (‘NI’) of the XBee.

Raises:
  • ValueError – If node_id is None or its length is greater than 20.
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
set_pan_id(value)

Sets the operating PAN ID of the XBee.

Parameters:

value (Bytearray) – New operating PAN ID of the XBee. Must have only 1 or 2 bytes.

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.

See also

set_parameter(parameter, value, apply=None)

Override.

See:
AbstractXBeeDevice.set_parameter()
set_power_level(power_level)

Sets the power level of the XBee.

Parameters:

power_level (PowerLevel) – New power level of the XBee.

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
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) – IO Line to be assigned.
  • cycle (Integer) – Duty cycle in % to be assigned. Must be between 0 and 100.
Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If 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) – Read timeout in seconds.
update_bluetooth_password(new_password)

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

Note that your device must include Bluetooth Low Energy support.

Parameters:

new_password (String) – New Bluetooth password.

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

Updates the current node information with provided data. This is only for internal use.

Parameters:device (AbstractXBeeDevice) – XBee to get the data from.
Returns:True if the node 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 XBee.

Parameters:
  • xml_firmware_file (String) – Path of the XML file that describes the firmware to upload.
  • xbee_firmware_file (String, optional, default=`None`) – Location of the XBee binary firmware file.
  • bootloader_firmware_file (String, optional, default=`None`) – Location of the bootloader binary firmware file.
  • timeout (Integer, optional, default=`None`) – Maximum time to wait for target read operations during the update process (seconds).
  • progress_callback (Function, optional, default=`None`) –

    Function to to receive progress information. Receives two arguments:

    • The current update task as a String
    • The current update task percentage as an Integer
Raises:
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • OperationNotSupportedException – If XBee does not support firmware update.
  • FirmwareUpdateException – If there is any error during the firmware update.
write_changes()

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

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

If changes are made without writing them, the XBee 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_changes_enabled() to get its status and enable_apply_changes() to enable/disable the option. Method apply_changes() can be used in order to manually apply the changes.

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
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.

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

Parameters:
  • port (String) – serial port identifier. Depends on operating system. e.g. ‘/dev/ttyUSB0’ on ‘GNU/Linux’ or ‘COM3’ on Windows.
  • baud_rate (Integer) – Serial port baud rate.
  • (Integer, default (flow_control) – serial.EIGHTBITS): Port bitsize.
  • (Integer, defaultserial.STOPBITS_ONE): Port stop bits.
  • (Character, default (parity) – serial.PARITY_NONE): Port parity.
  • (Integer, default

    FlowControl.NONE): port flow control.

    _sync_ops_timeout (Integer, default: 3): Read timeout (in seconds).
    comm_iface (XBeeCommunicationInterface): Communication interface.
Raises:

All exceptions raised by XBeeDevice.__init__() constructor.

See also

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

Override.

get_protocol()[source]

Override.

build_aggregate_routes()[source]

Forces all nodes in the network to automatically build routes to this node. The receiving node establishes a route back to this node.

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
send_data_64(x64addr, data, transmit_options=0)[source]

Blocking method. This method sends data to a remote XBee with the given 64-bit address.

This method waits for the packet response. The default timeout is XBeeDevice._DEFAULT_TIMEOUT_SYNC_OPERATIONS.

Parameters:
  • x64addr (XBee64BitAddress) – 64-bit address of the destination XBee.
  • data (String or Bytearray) – Raw data to send.
  • transmit_options (Integer, optional) – Transmit options, bitfield of TransmitOptions. Default to TransmitOptions.NONE.value.
Returns:

The response.

Return type:

XBeePacket

Raises:
  • ValueError – If x64addr or data is None.
  • TimeoutException – If response is not received before the read timeout expires.
  • InvalidOperatingModeException – If the XBee’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’s communication interface is closed.
send_data_async_64(x64addr, data, transmit_options=0)[source]

Non-blocking method. This method sends data to a remote XBee with the given 64-bit address.

This method does not wait for a response.

Parameters:
  • x64addr (XBee64BitAddress) – 64-bit address of the destination XBee.
  • data (String or Bytearray) – Raw data to send.
  • transmit_options (Integer, optional) – Transmit options, bitfield of TransmitOptions. Default to TransmitOptions.NONE.value.
Raises:
  • ValueError – If x64addr or data is None.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – If the XBee’s communication interface is closed.
read_expl_data(timeout=None)[source]

Reads new explicit data received by this XBee.

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

Parameters:

timeout (Integer, optional) – Read timeout in seconds. If None, this method is non-blocking and returns None if there is no explicit data available.

Returns:

Read message or None if this XBee

did not receive new explicit data.

Return type:

ExplicitXBeeMessage

Raises:
  • ValueError – If a timeout is specified and is less than 0.
  • TimeoutException – If a timeout is specified and no explicit data was received during that time.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – If the XBee’s communication interface is closed.
read_expl_data_from(remote_xbee, timeout=None)[source]

Reads new explicit data received from the given remote XBee.

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

Parameters:
  • remote_xbee (RemoteXBeeDevice) – Remote XBee that sent the explicit data.
  • timeout (Integer, optional) – Read timeout in seconds. If None, this method is non-blocking and returns None if there is no data available.
Returns:

Read message sent by remote_xbee

or None if this XBee did not receive new data from that node.

Return type:

ExplicitXBeeMessage

Raises:
  • ValueError – If a timeout is specified and is less than 0.
  • TimeoutException – If a timeout is specified and no explicit data was received during that time.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – If the XBee’s communication interface is closed.
send_expl_data(remote_xbee, data, src_endpoint, dest_endpoint, cluster_id, profile_id, transmit_options=0)[source]

Blocking method. Sends the provided explicit data to the given XBee, source and destination end points, cluster and profile ids.

This method blocks until a success or error response arrives or the configured receive timeout expires. The default timeout is XBeeDevice._DEFAULT_TIMEOUT_SYNC_OPERATIONS.

Parameters:
  • remote_xbee (RemoteXBeeDevice) – Remote XBee to send data to.
  • data (String or Bytearray) – 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 (between 0x0 and 0xFFFF)
  • profile_id (Integer) – Profile ID of the transmission (between 0x0 and 0xFFFF)
  • transmit_options (Integer, optional) – Transmit options, bitfield of TransmitOptions. Default to TransmitOptions.NONE.value.
Returns:

Response packet obtained after sending data.

Return type:

XBeePacket

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • InvalidOperatingModeException – If the XBee’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’s communication interface is closed.
  • ValueError – if cluster_id or profile_id is less than 0x0 or greater than 0xFFFF.
send_expl_data_broadcast(data, src_endpoint, dest_endpoint, cluster_id, profile_id, transmit_options=0)[source]

Sends the provided explicit data to all the XBee nodes of the network (broadcast) using provided source and destination end points, cluster and profile ids.

This method blocks until 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 method AbstractXBeeDevice.get_sync_ops_timeout().

Parameters:
  • data (String or Bytearray) – 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 (between 0x0 and 0xFFFF)
  • profile_id (Integer) – Profile ID of the transmission (between 0x0 and 0xFFFF)
  • transmit_options (Integer, optional) – Transmit options, bitfield of TransmitOptions. Default to TransmitOptions.NONE.value.
Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • InvalidOperatingModeException – If the XBee’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’s communication interface is closed.
  • ValueError – if cluster_id or profile_id is less than 0x0 or greater than 0xFFFF.

See also

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

Non-blocking method. Sends the provided explicit data to the given XBee, source and destination end points, cluster and profile ids.

Parameters:
  • remote_xbee (RemoteXBeeDevice) – Remote XBee to send data to.
  • data (String or Bytearray) – 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 (between 0x0 and 0xFFFF)
  • profile_id (Integer) – Profile ID of the transmission (between 0x0 and 0xFFFF)
  • transmit_options (Integer, optional) – Transmit options, bitfield of TransmitOptions. Default to TransmitOptions.NONE.value.
Raises:
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – If the XBee’s communication interface is closed.
  • ValueError – if cluster_id or profile_id is less than 0x0 or greater than 0xFFFF.

See also

get_neighbors(neighbor_cb=None, finished_cb=None, timeout=None)[source]

Returns the neighbors of this XBee. If neighbor_cb is not defined, the process blocks during the specified timeout.

Parameters:
  • neighbor_cb (Function, optional, default=`None`) –

    Method called when a new neighbor is received. Receives two arguments:

    • The XBee that owns this new neighbor.
    • The new neighbor.
  • finished_cb (Function, optional, default=`None`) –

    Method to execute when the process finishes. Receives two arguments:

    • The XBee that is searching for its neighbors.
    • A list with the discovered neighbors.
    • An error message if something went wrong.
  • timeout (Float, optional, default=`NeighborFinder.DEFAULT_TIMEOUT`) – The timeout in seconds.
Returns:

List of Neighbor when neighbor_cb is not defined,

None otherwise (in this case neighbors are received in the callback).

Return type:

List

Raises:

OperationNotSupportedException – If XBee protocol is not DigiMesh.

See also

com.digi.models.zdo.Neighbor
add_bluetooth_data_received_callback(callback)

Adds a callback for the event 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 DataReceived.

Parameters:callback (Function) –

The callback. Receives one argument.

add_expl_data_received_callback(callback)

Adds a callback for the event ExplicitDataReceived.

Parameters:callback (Function) –

The callback. Receives one argument.

add_fs_frame_received_callback(callback)

Adds a callback for the event FileSystemFrameReceived.

Parameters:callback (Function) –

The callback. Receives four arguments.

  • Source (AbstractXBeeDevice): The node that sent the file system frame.
  • Frame id (Integer): The received frame id.
  • Command (FSCmd): The file system command.
  • Receive options (Integer): Bitfield indicating receive options.
add_io_sample_received_callback(callback)

Adds a callback for the event IOSampleReceived.

Parameters:callback (Function) –

The callback. Receives three arguments.

  • The received IO sample as an IOSample.
  • The remote XBee which sent the packet as a RemoteXBeeDevice.
  • The time in which the packet was received as an Integer.
add_micropython_data_received_callback(callback)

Adds a callback for the event 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 ModemStatusReceived.

Parameters:callback (Function) –

The callback. Receives one argument.

add_packet_received_callback(callback)

Adds a callback for the event PacketReceived.

Parameters:callback (Function) –

The callback. Receives one argument.

add_route_received_callback(callback)

Adds a callback for the event RouteReceived. This works for Zigbee and Digimesh devices.

Parameters:callback (Function) –

The callback. Receives three arguments.

add_socket_data_received_callback(callback)

Adds a callback for the event 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 SocketDataReceivedFrom.

Parameters:callback (Function) –

The callback. Receives three arguments.

  • The socket ID as an Integer.
  • Source address pair (host, port) 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 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 RelayDataReceived.

Parameters:callback (Function) –

The callback. Receives one argument.

apply_changes()

Applies changes via ‘AC’ command.

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
apply_profile(profile_path, timeout=None, progress_callback=None)

Applies the given XBee profile to the XBee.

Parameters:
  • profile_path (String) – Path of the XBee profile file to apply.
  • timeout (Integer, optional, default=`None`) – Maximum time to wait for target read operations during the apply profile (seconds).
  • progress_callback (Function, optional, default=`None`) –

    Function 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:
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • UpdateProfileException – If there is any error applying the XBee profile.
close()

Closes the communication with the XBee.

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.

Returns:Hardware interface of the XBee.
Return type:XBeeCommunicationInterface
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:

XBee object created.

Return type:

XBeeDevice

Raises:

SerialException – If the port 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 BluetoothDataReceived event.

Parameters:callback (Function) – The callback to delete.
del_data_received_callback(callback)

Deletes a callback for the callback list of DataReceived event.

Parameters:callback (Function) – The callback to delete.
del_expl_data_received_callback(callback)

Deletes a callback for the callback list of ExplicitDataReceived event.

Parameters:callback (Function) – The callback to delete.
del_fs_frame_received_callback(callback)

Deletes a callback for the callback list of FileSystemFrameReceived event.

Parameters:callback (Function) – The callback to delete.
del_io_sample_received_callback(callback)

Deletes a callback for the callback list of IOSampleReceived event.

Parameters:callback (Function) – The callback to delete.
del_micropython_data_received_callback(callback)

Deletes a callback for the callback list of MicroPythonDataReceived event.

Parameters:callback (Function) – The callback to delete.
del_modem_status_received_callback(callback)

Deletes a callback for the callback list of ModemStatusReceived event.

Parameters:callback (Function) – The callback to delete.
del_packet_received_callback(callback)

Deletes a callback for the callback list of PacketReceived event.

Parameters:callback (Function) – The callback to delete.
del_route_received_callback(callback)

Deletes a callback for the callback list of RouteReceived event.

Parameters:callback (Function) – The callback to delete.
del_socket_data_received_callback(callback)

Deletes a callback for the callback list of SocketDataReceived event.

Parameters:callback (Function) – The callback to delete.
del_socket_data_received_from_callback(callback)

Deletes a callback for the callback list of SocketDataReceivedFrom event.

Parameters:callback (Function) – The callback to delete.
del_socket_state_received_callback(callback)

Deletes a callback for the callback list of SocketStateReceived event.

Parameters:callback (Function) – The callback to delete.
del_user_data_relay_received_callback(callback)

Deletes a callback for the callback list of RelayDataReceived event.

Parameters:callback (Function) – The callback to delete.
determine_protocol(hardware_version, firmware_version)

Determines the XBee protocol based on the given hardware and firmware versions.

Parameters:
  • hardware_version (Integer) – Hardware version to get its protocol.
  • firmware_version (Bytearray) – Firmware version to get its protocol.
Returns:

XBee protocol corresponding to the given

hardware and firmware versions.

Return type:

XBeeProtocol

disable_bluetooth()

Disables the Bluetooth interface of this XBee.

Note that your device must include Bluetooth Low Energy support.

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
enable_apply_changes(value)

Sets apply changes flag.

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

Enables the Bluetooth interface of this XBee.

To work with this interface, you must also configure the Bluetooth password if not done previously. Use method AbstractXBeeDevice.update_bluetooth_password().

Note that your XBee must include Bluetooth Low Energy support.

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
execute_command(parameter, value=None, apply=None)

Executes the provided command.

Parameters:
  • (String or (parameter) – class: .ATStringCommand): AT command to execute.
  • value (bytearray, optional, default=`None`) – Command value (if any).
  • apply (Boolean, optional, default=`None`) – True to apply changes in XBee configuration, False not to apply them, None to use is_apply_changes_enabled() returned value.
Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
flush_queues()

Flushes the packets queue.

get_16bit_addr()

Returns the 16-bit address of the XBee.

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

See also

get_64bit_addr()

Returns the 64-bit address of the XBee.

Returns:64-bit address of the XBee.
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) – IO line to get its ADC value.

Returns:

Analog value corresponding to the provided IO line.

Return type:

Integer

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
  • OperationNotSupportedException – If response does not contain the value for the given IO line.
get_api_output_mode()

Deprecated since version 1.3: Use get_api_output_mode_value()

Returns the API output mode of the XBee.

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

Returns:

API output mode of the XBee.

Return type:

APIOutputMode

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.

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:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
  • OperationNotSupportedException – If it is not supported by the current protocol.
get_bluetooth_mac_addr()

Reads and returns the EUI-48 Bluetooth MAC address of this XBee following the format 00112233AABB.

Note that your device must include Bluetooth Low Energy support.

Returns:

The Bluetooth MAC address.

Return type:

String

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
get_current_frame_id()

Returns the last used frame ID.

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

Returns the 64-bit address of the XBee that is data destination.

Returns:

64-bit address of destination XBee.

Return type:

XBee64BitAddress

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
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:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
  • OperationNotSupportedException – If response does not contain the value for the given IO line.
get_file_manager()

Returns the file system manager for the XBee.

Returns:The file system manager.
Return type:FileSystemManager
Raises:FileSystemNotSupportedException – If the XBee does not support filesystem.
get_firmware_version()

Returns the firmware version of the XBee.

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

Returns the hardware version of the XBee.

Returns:Hardware version of the XBee.
Return type:HardwareVersion

See also

get_io_configuration(io_line)

Returns the configuration of the provided IO line.

Parameters:

io_line (IOLine) – IO line to get its configuration.

Returns:

IO mode of the IO line provided.

Return type:

IOMode

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
get_io_sampling_rate()

Returns the IO sampling rate of the XBee.

Returns:

IO sampling rate of XBee.

Return type:

Integer

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
get_network()

Returns the network of this XBee.

Returns:The XBee network.
Return type:XBeeNetwork
get_next_frame_id()

Returns the next frame ID of the XBee.

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

Returns the node identifier (‘NI’) value of the XBee.

Returns:Node identifier (‘NI’) of the XBee.
Return type:String
get_pan_id()

Returns the operating PAN ID of the XBee.

Returns:

Operating PAN ID of the XBee.

Return type:

Bytearray

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.

See also

get_parameter(parameter, parameter_value=None, apply=None)

Override.

get_power_level()

Returns the power level of the XBee.

Returns:

Power level of the XBee.

Return type:

PowerLevel

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
get_pwm_duty_cycle(io_line)

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

Parameters:

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

Returns:

PWM duty cycle of the given IO line.

Return type:

Integer

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

See also

get_role()

Gets the XBee role.

Returns:the role of the XBee.
Return type:Role

See also

get_route_to_node(remote, timeout=10, force=True)

Gets the route from this XBee to the given remote node.

For Zigbee:
  • ‘AR’ parameter of the local node must be configured with a value different from ‘FF’.
  • Set force to True to force the Zigbee remote node to return its route independently of the local node configuration as high or low RAM concentrator (‘DO’ of the local value)
Parameters:
  • remote (RemoteXBeeDevice) – The remote node.
  • timeout (Float, optional, default=10) – Maximum number of seconds to wait for the route.
  • force (Boolean) – True to force asking for the route, False otherwise. Only for Zigbee.
Returns:

Tuple containing route data:
  • status (TransmitStatus): The transmit status.

  • Tuple with route data (None if the route was not read in the provided timeout):

    • source (RemoteXBeeDevice): The source node of the route.
    • destination (RemoteXBeeDevice): The destination node of the route.
    • hops (List): List of intermediate nodes (RemoteXBeeDevice) ordered from closest to source to closest to destination node (source and destination not included).

Return type:

Tuple

get_sync_ops_timeout()

Returns the serial port read timeout.

Returns: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 are executed before user callbacks.

Returns:PacketReceived
has_explicit_packets()

Returns if there are pending explicit packets to read. This does not include non-explicit packets.

Returns:True if there are pending packets, False otherwise.
Return type:Boolean
has_packets()

Returns if there are pending packets to read. This does not include explicit packets.

Returns:True if there are pending packets, False otherwise.
Return type:Boolean
is_apply_changes_enabled()

Returns whether apply changes flag is enabled.

Returns:True if apply changes flag is enabled, False otherwise.
Return type:Boolean
is_device_info_complete()

Returns whether XBee node information is complete.

Returns:True if node information is complete, False otherwise.
Return type:Boolean
is_open()

Returns whether this XBee is open.

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

Override method.

log

Returns the XBee logger.

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

Returns the operating mode of this XBee.

Returns:OperatingMode. This XBee operating mode.
reachable

Returns whether the XBee is reachable.

Returns:True if the device is reachable, False otherwise.
Return type:Boolean
read_data(timeout=None)

Reads new data received by this XBee.

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

Parameters:

timeout (Integer, optional) – Read timeout in seconds. If None, this method is non-blocking and returns None if no data is available.

Returns:

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’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – If the XBee’s communication interface is closed.

See also

read_data_from(remote_xbee, timeout=None)

Reads new data received from the given remote XBee.

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

Parameters:
  • remote_xbee (RemoteXBeeDevice) – Remote XBee that sent the data.
  • timeout (Integer, optional) – Read timeout in seconds. If None, this method is non-blocking and returns None if no data is available.
Returns:

Read message sent by remote_xbee 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’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – If the XBee’s communication interface is closed.
read_device_info(init=True, fire_event=True)

Updates all instance parameters reading them from the XBee.

Parameters:
  • init (Boolean, optional, default=`True`) – If False only not initialized parameters are read, all if True.
  • fire_event (Boolean, optional, default=`True`) – True to throw and update event if any parameter changed, False otherwise.
Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
read_io_sample()

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

Returns:

IO sample read from the XBee.

Return type:

IOSample

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.

See also

reset()

Override method.

scan_counter

Returns the scan counter for this node.

Returns:The scan counter for this node.
Return type:Integer
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’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, data, transmit_options=0)

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

This method will wait for the packet response. The default timeout is XBeeDevice._DEFAULT_TIMEOUT_SYNC_OPERATIONS.

Parameters:
  • remote_xbee (RemoteXBeeDevice) – Remote XBee to send data to.
  • data (String or Bytearray) – Raw data to send.
  • transmit_options (Integer, optional) – Transmit options, bitfield of TransmitOptions. Default to TransmitOptions.NONE.value.
Returns:

The response.

Return type:

XBeePacket

Raises:
  • ValueError – If remote_xbee is None.
  • TimeoutException – If response is not received before the read timeout expires.
  • InvalidOperatingModeException – If the XBee’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’s communication interface is closed.
send_data_async(remote_xbee, data, transmit_options=0)

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

This method does not wait for a response.

Parameters:
  • remote_xbee (RemoteXBeeDevice) – the remote XBee to send data to.
  • data (String or Bytearray) – Raw data to send.
  • transmit_options (Integer, optional) – Transmit options, bitfield of TransmitOptions. Default to TransmitOptions.NONE.value.
Raises:
  • ValueError – If remote_xbee is None.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – If the XBee’s communication interface 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 until a success or error transmit status arrives or the configured receive timeout expires.

The received timeout is configured using method AbstractXBeeDevice.set_sync_ops_timeout() 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 response is not received before the read timeout expires.
  • InvalidOperatingModeException – If the XBee’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’s communication interface 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’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)

Sends the packet and waits for the response. The packet to send is escaped depending on the current operating mode.

This method can be synchronous or asynchronous.

If synchronous, this method discards all response packets until it finds the one that has the appropriate frame ID, that is, the sent packet’s frame ID.

If asynchronous, this method does not wait for any response and returns None.

Parameters:
  • packet (XBeePacket) – The packet to send.
  • sync (Boolean) – True to wait for the response of the sent packet and return it, False otherwise.
Returns:

Response packet if sync is True, None

otherwise.

Return type:

XBeePacket

Raises:
  • TimeoutException – If sync is True and the response packet for the sent one cannot be read.
  • InvalidOperatingModeException – If the XBee operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – If the packet listener is not running or the XBee’s communication interface is closed.

See also

send_packet_sync_and_get_response(packet_to_send, timeout=None)

Sends the packet and waits for its corresponding response.

Parameters:
  • packet_to_send (XBeePacket) – The packet to transmit.
  • timeout (Integer, optional, default=`None`) – Number of seconds to wait. -1 to wait indefinitely.
Returns:

Received response packet.

Return type:

XBeePacket

Raises:
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • TimeoutException – If response is not received in the configured timeout.
  • XBeeException – If the XBee’s communication interface is closed.

See also

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’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, if any.

Returns:
Serial port of the XBee. 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.

Parameters:

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

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
  • OperationNotSupportedException – If the protocol is not 802.15.4.
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.

Parameters:

api_output_mode (APIOutputMode) – New API output mode.

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
  • OperationNotSupportedException – If it is not supported by the current protocol.

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 APIOutputModeBit.calculate_api_output_mode_value() with a set of APIOutputModeBit.

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
  • OperationNotSupportedException – If it is not supported by the current protocol.

See also

set_dest_address(addr)

Sets the 64-bit address of the XBee that is data destination.

Parameters:

addr (XBee64BitAddress or RemoteXBeeDevice) – Address itself or remote XBee to be data destination.

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If 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:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.

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) – Digital IO line to sets its value.
  • io_value (IOValue) – IO value to set to the IO line.
Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.

See also

set_io_configuration(io_line, io_mode)

Sets the configuration of the provided IO line.

Parameters:
  • io_line (IOLine) – IO line to configure.
  • io_mode (IOMode) – IO mode to set to the IO line.
Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
set_io_sampling_rate(rate)

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

Parameters:

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

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
set_node_id(node_id)

Sets the node identifier (‘NI`) value of the XBee.

Parameters:

node_id (String) – New node identifier (‘NI’) of the XBee.

Raises:
  • ValueError – If node_id is None or its length is greater than 20.
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
set_pan_id(value)

Sets the operating PAN ID of the XBee.

Parameters:

value (Bytearray) – New operating PAN ID of the XBee. Must have only 1 or 2 bytes.

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.

See also

set_parameter(parameter, value, apply=None)

Override.

See:
AbstractXBeeDevice.set_parameter()
set_power_level(power_level)

Sets the power level of the XBee.

Parameters:

power_level (PowerLevel) – New power level of the XBee.

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
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) – IO Line to be assigned.
  • cycle (Integer) – Duty cycle in % to be assigned. Must be between 0 and 100.
Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If 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) – Read timeout in seconds.
update_bluetooth_password(new_password)

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

Note that your device must include Bluetooth Low Energy support.

Parameters:

new_password (String) – New Bluetooth password.

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

Updates the current node information with provided data. This is only for internal use.

Parameters:device (AbstractXBeeDevice) – XBee to get the data from.
Returns:True if the node 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 XBee.

Parameters:
  • xml_firmware_file (String) – Path of the XML file that describes the firmware to upload.
  • xbee_firmware_file (String, optional, default=`None`) – Location of the XBee binary firmware file.
  • bootloader_firmware_file (String, optional, default=`None`) – Location of the bootloader binary firmware file.
  • timeout (Integer, optional, default=`None`) – Maximum time to wait for target read operations during the update process (seconds).
  • progress_callback (Function, optional, default=`None`) –

    Function to to receive progress information. Receives two arguments:

    • The current update task as a String
    • The current update task percentage as an Integer
Raises:
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • OperationNotSupportedException – If XBee does not support firmware update.
  • FirmwareUpdateException – If there is any error during the firmware update.
write_changes()

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

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

If changes are made without writing them, the XBee 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_changes_enabled() to get its status and enable_apply_changes() to enable/disable the option. Method apply_changes() can be used in order to manually apply the changes.

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
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.

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

Parameters:
  • port (String) – Serial port identifier. Depends on operating system. e.g. ‘/dev/ttyUSB0’ on ‘GNU/Linux’ or ‘COM3’ on Windows.
  • baud_rate (Integer) – Serial port baud rate.
  • (Integer, default (_sync_ops_timeout) – serial.EIGHTBITS): Port bitsize.
  • (Integer, defaultserial.STOPBITS_ONE): Port stop bits.
  • (Character, default (parity) – serial.PARITY_NONE): Port parity.
  • (Integer, defaultFlowControl.NONE): Port flow control.
  • (Integer, default – 3): Read timeout (in seconds).
  • comm_iface (XBeeCommunicationInterface) – Communication interface.
Raises:

All exceptions raised by XBeeDevice.__init__() constructor.

See also

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

Override.

get_protocol()[source]

Override.

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

Blocking method. This method sends data to the remote XBee with the given 64-bit/16-bit address.

This method waits for the packet response. The default timeout is XBeeDevice._DEFAULT_TIMEOUT_SYNC_OPERATIONS.

Parameters:
Returns:

The response.

Return type:

XBeePacket

Raises:
  • ValueError – If x64addr, x16addr or data is None.
  • TimeoutException – If response is not received before the read timeout expires.
  • InvalidOperatingModeException – If the XBee’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’s communication interface is closed.
send_data_async_64_16(x64addr, x16addr, data, transmit_options=0)[source]

Non-blocking method. This method sends data to a remote XBee with the given 64-bit/16-bit address.

This method does not wait for a response.

Parameters:
Raises:
  • ValueError – If x64addr, x16addr or data is None.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – If the XBee’s communication interface is closed.
read_expl_data(timeout=None)[source]

Reads new explicit data received by this XBee.

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

Parameters:

timeout (Integer, optional) – Read timeout in seconds. If None, this method is non-blocking and returns None if there is no explicit data available.

Returns:

Read message or None if this XBee

did not receive new explicit data.

Return type:

ExplicitXBeeMessage

Raises:
  • ValueError – If a timeout is specified and is less than 0.
  • TimeoutException – If a timeout is specified and no explicit data was received during that time.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – If the XBee’s communication interface is closed.
read_expl_data_from(remote_xbee, timeout=None)[source]

Reads new explicit data received from the given remote XBee.

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

Parameters:
  • remote_xbee (RemoteXBeeDevice) – Remote XBee that sent the explicit data.
  • timeout (Integer, optional) – Read timeout in seconds. If None, this method is non-blocking and returns None if there is no data available.
Returns:

Read message sent by remote_xbee

or None if this XBee did not receive new data from that node.

Return type:

ExplicitXBeeMessage

Raises:
  • ValueError – If a timeout is specified and is less than 0.
  • TimeoutException – If a timeout is specified and no explicit data was received during that time.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – If the XBee’s communication interface is closed.
send_expl_data(remote_xbee, data, src_endpoint, dest_endpoint, cluster_id, profile_id, transmit_options=0)[source]

Blocking method. Sends the provided explicit data to the given XBee, source and destination end points, cluster and profile ids.

This method blocks until a success or error response arrives or the configured receive timeout expires. The default timeout is XBeeDevice._DEFAULT_TIMEOUT_SYNC_OPERATIONS.

Parameters:
  • remote_xbee (RemoteXBeeDevice) – Remote XBee to send data to.
  • data (String or Bytearray) – 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 (between 0x0 and 0xFFFF)
  • profile_id (Integer) – Profile ID of the transmission (between 0x0 and 0xFFFF)
  • transmit_options (Integer, optional) – Transmit options, bitfield of TransmitOptions. Default to TransmitOptions.NONE.value.
Returns:

Response packet obtained after sending data.

Return type:

XBeePacket

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • InvalidOperatingModeException – If the XBee’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’s communication interface is closed.
  • ValueError – if cluster_id or profile_id is less than 0x0 or greater than 0xFFFF.
send_expl_data_broadcast(data, src_endpoint, dest_endpoint, cluster_id, profile_id, transmit_options=0)[source]

Sends the provided explicit data to all the XBee nodes of the network (broadcast) using provided source and destination end points, cluster and profile ids.

This method blocks until 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 method AbstractXBeeDevice.get_sync_ops_timeout().

Parameters:
  • data (String or Bytearray) – 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 (between 0x0 and 0xFFFF)
  • profile_id (Integer) – Profile ID of the transmission (between 0x0 and 0xFFFF)
  • transmit_options (Integer, optional) – Transmit options, bitfield of TransmitOptions. Default to TransmitOptions.NONE.value.
Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • InvalidOperatingModeException – If the XBee’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’s communication interface is closed.
  • ValueError – if cluster_id or profile_id is less than 0x0 or greater than 0xFFFF.

See also

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

Non-blocking method. Sends the provided explicit data to the given XBee, source and destination end points, cluster and profile ids.

Parameters:
  • remote_xbee (RemoteXBeeDevice) – Remote XBee to send data to.
  • data (String or Bytearray) – 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 (between 0x0 and 0xFFFF)
  • profile_id (Integer) – Profile ID of the transmission (between 0x0 and 0xFFFF)
  • transmit_options (Integer, optional) – Transmit options, bitfield of TransmitOptions. Default to TransmitOptions.NONE.value.
Raises:
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – If the XBee’s communication interface is closed.
  • ValueError – if cluster_id or profile_id is less than 0x0 or greater than 0xFFFF.

See also

add_bluetooth_data_received_callback(callback)

Adds a callback for the event 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 DataReceived.

Parameters:callback (Function) –

The callback. Receives one argument.

add_expl_data_received_callback(callback)

Adds a callback for the event ExplicitDataReceived.

Parameters:callback (Function) –

The callback. Receives one argument.

add_fs_frame_received_callback(callback)

Adds a callback for the event FileSystemFrameReceived.

Parameters:callback (Function) –

The callback. Receives four arguments.

  • Source (AbstractXBeeDevice): The node that sent the file system frame.
  • Frame id (Integer): The received frame id.
  • Command (FSCmd): The file system command.
  • Receive options (Integer): Bitfield indicating receive options.
add_io_sample_received_callback(callback)

Adds a callback for the event IOSampleReceived.

Parameters:callback (Function) –

The callback. Receives three arguments.

  • The received IO sample as an IOSample.
  • The remote XBee which sent the packet as a RemoteXBeeDevice.
  • The time in which the packet was received as an Integer.
add_micropython_data_received_callback(callback)

Adds a callback for the event 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 ModemStatusReceived.

Parameters:callback (Function) –

The callback. Receives one argument.

add_packet_received_callback(callback)

Adds a callback for the event PacketReceived.

Parameters:callback (Function) –

The callback. Receives one argument.

add_route_received_callback(callback)

Adds a callback for the event RouteReceived. This works for Zigbee and Digimesh devices.

Parameters:callback (Function) –

The callback. Receives three arguments.

add_socket_data_received_callback(callback)

Adds a callback for the event 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 SocketDataReceivedFrom.

Parameters:callback (Function) –

The callback. Receives three arguments.

  • The socket ID as an Integer.
  • Source address pair (host, port) 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 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 RelayDataReceived.

Parameters:callback (Function) –

The callback. Receives one argument.

apply_changes()

Applies changes via ‘AC’ command.

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
apply_profile(profile_path, timeout=None, progress_callback=None)

Applies the given XBee profile to the XBee.

Parameters:
  • profile_path (String) – Path of the XBee profile file to apply.
  • timeout (Integer, optional, default=`None`) – Maximum time to wait for target read operations during the apply profile (seconds).
  • progress_callback (Function, optional, default=`None`) –

    Function 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:
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • UpdateProfileException – If there is any error applying the XBee profile.
close()

Closes the communication with the XBee.

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.

Returns:Hardware interface of the XBee.
Return type:XBeeCommunicationInterface
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:

XBee object created.

Return type:

XBeeDevice

Raises:

SerialException – If the port 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 BluetoothDataReceived event.

Parameters:callback (Function) – The callback to delete.
del_data_received_callback(callback)

Deletes a callback for the callback list of DataReceived event.

Parameters:callback (Function) – The callback to delete.
del_expl_data_received_callback(callback)

Deletes a callback for the callback list of ExplicitDataReceived event.

Parameters:callback (Function) – The callback to delete.
del_fs_frame_received_callback(callback)

Deletes a callback for the callback list of FileSystemFrameReceived event.

Parameters:callback (Function) – The callback to delete.
del_io_sample_received_callback(callback)

Deletes a callback for the callback list of IOSampleReceived event.

Parameters:callback (Function) – The callback to delete.
del_micropython_data_received_callback(callback)

Deletes a callback for the callback list of MicroPythonDataReceived event.

Parameters:callback (Function) – The callback to delete.
del_modem_status_received_callback(callback)

Deletes a callback for the callback list of ModemStatusReceived event.

Parameters:callback (Function) – The callback to delete.
del_packet_received_callback(callback)

Deletes a callback for the callback list of PacketReceived event.

Parameters:callback (Function) – The callback to delete.
del_route_received_callback(callback)

Deletes a callback for the callback list of RouteReceived event.

Parameters:callback (Function) – The callback to delete.
del_socket_data_received_callback(callback)

Deletes a callback for the callback list of SocketDataReceived event.

Parameters:callback (Function) – The callback to delete.
del_socket_data_received_from_callback(callback)

Deletes a callback for the callback list of SocketDataReceivedFrom event.

Parameters:callback (Function) – The callback to delete.
del_socket_state_received_callback(callback)

Deletes a callback for the callback list of SocketStateReceived event.

Parameters:callback (Function) – The callback to delete.
del_user_data_relay_received_callback(callback)

Deletes a callback for the callback list of RelayDataReceived event.

Parameters:callback (Function) – The callback to delete.
determine_protocol(hardware_version, firmware_version)

Determines the XBee protocol based on the given hardware and firmware versions.

Parameters:
  • hardware_version (Integer) – Hardware version to get its protocol.
  • firmware_version (Bytearray) – Firmware version to get its protocol.
Returns:

XBee protocol corresponding to the given

hardware and firmware versions.

Return type:

XBeeProtocol

disable_bluetooth()

Disables the Bluetooth interface of this XBee.

Note that your device must include Bluetooth Low Energy support.

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
enable_apply_changes(value)

Sets apply changes flag.

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

Enables the Bluetooth interface of this XBee.

To work with this interface, you must also configure the Bluetooth password if not done previously. Use method AbstractXBeeDevice.update_bluetooth_password().

Note that your XBee must include Bluetooth Low Energy support.

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
execute_command(parameter, value=None, apply=None)

Executes the provided command.

Parameters:
  • (String or (parameter) – class: .ATStringCommand): AT command to execute.
  • value (bytearray, optional, default=`None`) – Command value (if any).
  • apply (Boolean, optional, default=`None`) – True to apply changes in XBee configuration, False not to apply them, None to use is_apply_changes_enabled() returned value.
Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
flush_queues()

Flushes the packets queue.

get_16bit_addr()

Returns the 16-bit address of the XBee.

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

See also

get_64bit_addr()

Returns the 64-bit address of the XBee.

Returns:64-bit address of the XBee.
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) – IO line to get its ADC value.

Returns:

Analog value corresponding to the provided IO line.

Return type:

Integer

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
  • OperationNotSupportedException – If response does not contain the value for the given IO line.
get_api_output_mode()

Deprecated since version 1.3: Use get_api_output_mode_value()

Returns the API output mode of the XBee.

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

Returns:

API output mode of the XBee.

Return type:

APIOutputMode

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.

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:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
  • OperationNotSupportedException – If it is not supported by the current protocol.
get_bluetooth_mac_addr()

Reads and returns the EUI-48 Bluetooth MAC address of this XBee following the format 00112233AABB.

Note that your device must include Bluetooth Low Energy support.

Returns:

The Bluetooth MAC address.

Return type:

String

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
get_current_frame_id()

Returns the last used frame ID.

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

Returns the 64-bit address of the XBee that is data destination.

Returns:

64-bit address of destination XBee.

Return type:

XBee64BitAddress

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
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:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
  • OperationNotSupportedException – If response does not contain the value for the given IO line.
get_file_manager()

Returns the file system manager for the XBee.

Returns:The file system manager.
Return type:FileSystemManager
Raises:FileSystemNotSupportedException – If the XBee does not support filesystem.
get_firmware_version()

Returns the firmware version of the XBee.

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

Returns the hardware version of the XBee.

Returns:Hardware version of the XBee.
Return type:HardwareVersion

See also

get_io_configuration(io_line)

Returns the configuration of the provided IO line.

Parameters:

io_line (IOLine) – IO line to get its configuration.

Returns:

IO mode of the IO line provided.

Return type:

IOMode

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
get_io_sampling_rate()

Returns the IO sampling rate of the XBee.

Returns:

IO sampling rate of XBee.

Return type:

Integer

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
get_network()

Returns the network of this XBee.

Returns:The XBee network.
Return type:XBeeNetwork
get_next_frame_id()

Returns the next frame ID of the XBee.

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

Returns the node identifier (‘NI’) value of the XBee.

Returns:Node identifier (‘NI’) of the XBee.
Return type:String
get_pan_id()

Returns the operating PAN ID of the XBee.

Returns:

Operating PAN ID of the XBee.

Return type:

Bytearray

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.

See also

get_parameter(parameter, parameter_value=None, apply=None)

Override.

get_power_level()

Returns the power level of the XBee.

Returns:

Power level of the XBee.

Return type:

PowerLevel

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
get_pwm_duty_cycle(io_line)

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

Parameters:

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

Returns:

PWM duty cycle of the given IO line.

Return type:

Integer

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

See also

get_role()

Gets the XBee role.

Returns:the role of the XBee.
Return type:Role

See also

get_route_to_node(remote, timeout=10, force=True)

Gets the route from this XBee to the given remote node.

For Zigbee:
  • ‘AR’ parameter of the local node must be configured with a value different from ‘FF’.
  • Set force to True to force the Zigbee remote node to return its route independently of the local node configuration as high or low RAM concentrator (‘DO’ of the local value)
Parameters:
  • remote (RemoteXBeeDevice) – The remote node.
  • timeout (Float, optional, default=10) – Maximum number of seconds to wait for the route.
  • force (Boolean) – True to force asking for the route, False otherwise. Only for Zigbee.
Returns:

Tuple containing route data:
  • status (TransmitStatus): The transmit status.

  • Tuple with route data (None if the route was not read in the provided timeout):

    • source (RemoteXBeeDevice): The source node of the route.
    • destination (RemoteXBeeDevice): The destination node of the route.
    • hops (List): List of intermediate nodes (RemoteXBeeDevice) ordered from closest to source to closest to destination node (source and destination not included).

Return type:

Tuple

get_sync_ops_timeout()

Returns the serial port read timeout.

Returns: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 are executed before user callbacks.

Returns:PacketReceived
has_explicit_packets()

Returns if there are pending explicit packets to read. This does not include non-explicit packets.

Returns:True if there are pending packets, False otherwise.
Return type:Boolean
has_packets()

Returns if there are pending packets to read. This does not include explicit packets.

Returns:True if there are pending packets, False otherwise.
Return type:Boolean
is_apply_changes_enabled()

Returns whether apply changes flag is enabled.

Returns:True if apply changes flag is enabled, False otherwise.
Return type:Boolean
is_device_info_complete()

Returns whether XBee node information is complete.

Returns:True if node information is complete, False otherwise.
Return type:Boolean
is_open()

Returns whether this XBee is open.

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

Override method.

log

Returns the XBee logger.

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

Returns the operating mode of this XBee.

Returns:OperatingMode. This XBee operating mode.
reachable

Returns whether the XBee is reachable.

Returns:True if the device is reachable, False otherwise.
Return type:Boolean
read_data(timeout=None)

Reads new data received by this XBee.

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

Parameters:

timeout (Integer, optional) – Read timeout in seconds. If None, this method is non-blocking and returns None if no data is available.

Returns:

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’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – If the XBee’s communication interface is closed.

See also

read_data_from(remote_xbee, timeout=None)

Reads new data received from the given remote XBee.

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

Parameters:
  • remote_xbee (RemoteXBeeDevice) – Remote XBee that sent the data.
  • timeout (Integer, optional) – Read timeout in seconds. If None, this method is non-blocking and returns None if no data is available.
Returns:

Read message sent by remote_xbee 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’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – If the XBee’s communication interface is closed.
read_device_info(init=True, fire_event=True)

Updates all instance parameters reading them from the XBee.

Parameters:
  • init (Boolean, optional, default=`True`) – If False only not initialized parameters are read, all if True.
  • fire_event (Boolean, optional, default=`True`) – True to throw and update event if any parameter changed, False otherwise.
Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
read_io_sample()

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

Returns:

IO sample read from the XBee.

Return type:

IOSample

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.

See also

reset()

Override method.

scan_counter

Returns the scan counter for this node.

Returns:The scan counter for this node.
Return type:Integer
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’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, data, transmit_options=0)

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

This method will wait for the packet response. The default timeout is XBeeDevice._DEFAULT_TIMEOUT_SYNC_OPERATIONS.

Parameters:
  • remote_xbee (RemoteXBeeDevice) – Remote XBee to send data to.
  • data (String or Bytearray) – Raw data to send.
  • transmit_options (Integer, optional) – Transmit options, bitfield of TransmitOptions. Default to TransmitOptions.NONE.value.
Returns:

The response.

Return type:

XBeePacket

Raises:
  • ValueError – If remote_xbee is None.
  • TimeoutException – If response is not received before the read timeout expires.
  • InvalidOperatingModeException – If the XBee’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’s communication interface is closed.
send_data_async(remote_xbee, data, transmit_options=0)

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

This method does not wait for a response.

Parameters:
  • remote_xbee (RemoteXBeeDevice) – the remote XBee to send data to.
  • data (String or Bytearray) – Raw data to send.
  • transmit_options (Integer, optional) – Transmit options, bitfield of TransmitOptions. Default to TransmitOptions.NONE.value.
Raises:
  • ValueError – If remote_xbee is None.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – If the XBee’s communication interface 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 until a success or error transmit status arrives or the configured receive timeout expires.

The received timeout is configured using method AbstractXBeeDevice.set_sync_ops_timeout() 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 response is not received before the read timeout expires.
  • InvalidOperatingModeException – If the XBee’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’s communication interface 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’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)

Sends the packet and waits for the response. The packet to send is escaped depending on the current operating mode.

This method can be synchronous or asynchronous.

If synchronous, this method discards all response packets until it finds the one that has the appropriate frame ID, that is, the sent packet’s frame ID.

If asynchronous, this method does not wait for any response and returns None.

Parameters:
  • packet (XBeePacket) – The packet to send.
  • sync (Boolean) – True to wait for the response of the sent packet and return it, False otherwise.
Returns:

Response packet if sync is True, None

otherwise.

Return type:

XBeePacket

Raises:
  • TimeoutException – If sync is True and the response packet for the sent one cannot be read.
  • InvalidOperatingModeException – If the XBee operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – If the packet listener is not running or the XBee’s communication interface is closed.

See also

send_packet_sync_and_get_response(packet_to_send, timeout=None)

Sends the packet and waits for its corresponding response.

Parameters:
  • packet_to_send (XBeePacket) – The packet to transmit.
  • timeout (Integer, optional, default=`None`) – Number of seconds to wait. -1 to wait indefinitely.
Returns:

Received response packet.

Return type:

XBeePacket

Raises:
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • TimeoutException – If response is not received in the configured timeout.
  • XBeeException – If the XBee’s communication interface is closed.

See also

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’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, if any.

Returns:
Serial port of the XBee. 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.

Parameters:

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

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
  • OperationNotSupportedException – If the protocol is not 802.15.4.
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.

Parameters:

api_output_mode (APIOutputMode) – New API output mode.

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
  • OperationNotSupportedException – If it is not supported by the current protocol.

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 APIOutputModeBit.calculate_api_output_mode_value() with a set of APIOutputModeBit.

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
  • OperationNotSupportedException – If it is not supported by the current protocol.

See also

set_dest_address(addr)

Sets the 64-bit address of the XBee that is data destination.

Parameters:

addr (XBee64BitAddress or RemoteXBeeDevice) – Address itself or remote XBee to be data destination.

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If 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:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.

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) – Digital IO line to sets its value.
  • io_value (IOValue) – IO value to set to the IO line.
Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.

See also

set_io_configuration(io_line, io_mode)

Sets the configuration of the provided IO line.

Parameters:
  • io_line (IOLine) – IO line to configure.
  • io_mode (IOMode) – IO mode to set to the IO line.
Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
set_io_sampling_rate(rate)

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

Parameters:

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

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
set_node_id(node_id)

Sets the node identifier (‘NI`) value of the XBee.

Parameters:

node_id (String) – New node identifier (‘NI’) of the XBee.

Raises:
  • ValueError – If node_id is None or its length is greater than 20.
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
set_pan_id(value)

Sets the operating PAN ID of the XBee.

Parameters:

value (Bytearray) – New operating PAN ID of the XBee. Must have only 1 or 2 bytes.

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.

See also

set_parameter(parameter, value, apply=None)

Override.

See:
AbstractXBeeDevice.set_parameter()
set_power_level(power_level)

Sets the power level of the XBee.

Parameters:

power_level (PowerLevel) – New power level of the XBee.

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
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) – IO Line to be assigned.
  • cycle (Integer) – Duty cycle in % to be assigned. Must be between 0 and 100.
Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If 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) – Read timeout in seconds.
update_bluetooth_password(new_password)

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

Note that your device must include Bluetooth Low Energy support.

Parameters:

new_password (String) – New Bluetooth password.

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

Updates the current node information with provided data. This is only for internal use.

Parameters:device (AbstractXBeeDevice) – XBee to get the data from.
Returns:True if the node 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 XBee.

Parameters:
  • xml_firmware_file (String) – Path of the XML file that describes the firmware to upload.
  • xbee_firmware_file (String, optional, default=`None`) – Location of the XBee binary firmware file.
  • bootloader_firmware_file (String, optional, default=`None`) – Location of the bootloader binary firmware file.
  • timeout (Integer, optional, default=`None`) – Maximum time to wait for target read operations during the update process (seconds).
  • progress_callback (Function, optional, default=`None`) –

    Function to to receive progress information. Receives two arguments:

    • The current update task as a String
    • The current update task percentage as an Integer
Raises:
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • OperationNotSupportedException – If XBee does not support firmware update.
  • FirmwareUpdateException – If there is any error during the firmware update.
write_changes()

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

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

If changes are made without writing them, the XBee 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_changes_enabled() to get its status and enable_apply_changes() to enable/disable the option. Method apply_changes() can be used in order to manually apply the changes.

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
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.

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

Parameters:
  • port (String) – Serial port identifier. Depends on operating system. e.g. ‘/dev/ttyUSB0’ on ‘GNU/Linux’ or ‘COM3’ on Windows.
  • baud_rate (Integer) – Serial port baud rate.
  • (Integer, default (flow_control) – serial.EIGHTBITS): Port bitsize.
  • (Integer, defaultserial.STOPBITS_ONE): Port stop bits.
  • (Character, default (parity) – serial.PARITY_NONE): Port parity.
  • (Integer, default

    FlowControl.NONE): Port flow control.

    _sync_ops_timeout (Integer, default: 3): Read timeout (in seconds).
    comm_iface (XBeeCommunicationInterface): Communication interface.
Raises:

All exceptions raised by XBeeDevice.__init__() constructor.

See also

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

Override.

get_protocol()[source]

Override.

get_ai_status()[source]

Returns the current association status of this XBee. It indicates occurrences of errors during the modem initialization and connection.

Returns:

The XBee association

indication status.

Return type:

AssociationIndicationStatus

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

Forces this XBee to immediately disassociate from the network and re-attempt to associate.

Only valid for End Devices.

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

Returns the time between aggregation route broadcast in tenths of a second.

Returns:

The number of tenths of a second between aggregation route

broadcasts. -1 if it is disabled.

Return type:

Integer

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
set_many_to_one_broadcasting_time(tenths_second)[source]

Configures the time between aggregation route broadcast in tenths of a second.

Parameters:

tenths_second (Integer) – The number of tenths of a second between aggregation route broadcasts. -1 to disable. 0 to only send one broadcast.

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • XBeeException – If the XBee’s communication interface is closed.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • ATCommandException – If response is not as expected.
  • ValueError – If tenths_second is None or is lower than -1, or bigger than 254.
send_data_64_16(x64addr, x16addr, data, transmit_options=0)[source]

Blocking method. This method sends data to the remote XBee with the given 64-bit/16-bit address.

This method waits for the packet response. The default timeout is XBeeDevice._DEFAULT_TIMEOUT_SYNC_OPERATIONS.

Parameters:
Returns:

The response.

Return type:

XBeePacket

Raises:
  • ValueError – If x64addr, x16addr or data is None.
  • TimeoutException – If response is not received before the read timeout expires.
  • InvalidOperatingModeException – If the XBee’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’s communication interface is closed.
send_data_async_64_16(x64addr, x16addr, data, transmit_options=0)[source]

Non-blocking method. This method sends data to a remote XBee with the given 64-bit/16-bit address.

This method does not wait for a response.

Parameters:
Raises:
  • ValueError – If x64addr, x16addr or data is None.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – If the XBee’s communication interface is closed.
read_expl_data(timeout=None)[source]

Reads new explicit data received by this XBee.

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

Parameters:

timeout (Integer, optional) – Read timeout in seconds. If None, this method is non-blocking and returns None if there is no explicit data available.

Returns:

Read message or None if this XBee

did not receive new explicit data.

Return type:

ExplicitXBeeMessage

Raises:
  • ValueError – If a timeout is specified and is less than 0.
  • TimeoutException – If a timeout is specified and no explicit data was received during that time.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – If the XBee’s communication interface is closed.
read_expl_data_from(remote_xbee, timeout=None)[source]

Reads new explicit data received from the given remote XBee.

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

Parameters:
  • remote_xbee (RemoteXBeeDevice) – Remote XBee that sent the explicit data.
  • timeout (Integer, optional) – Read timeout in seconds. If None, this method is non-blocking and returns None if there is no data available.
Returns:

Read message sent by remote_xbee

or None if this XBee did not receive new data from that node.

Return type:

ExplicitXBeeMessage

Raises:
  • ValueError – If a timeout is specified and is less than 0.
  • TimeoutException – If a timeout is specified and no explicit data was received during that time.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – If the XBee’s communication interface is closed.
send_expl_data(remote_xbee, data, src_endpoint, dest_endpoint, cluster_id, profile_id, transmit_options=0)[source]

Blocking method. Sends the provided explicit data to the given XBee, source and destination end points, cluster and profile ids.

This method blocks until a success or error response arrives or the configured receive timeout expires. The default timeout is XBeeDevice._DEFAULT_TIMEOUT_SYNC_OPERATIONS.

Parameters:
  • remote_xbee (RemoteXBeeDevice) – Remote XBee to send data to.
  • data (String or Bytearray) – 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 (between 0x0 and 0xFFFF)
  • profile_id (Integer) – Profile ID of the transmission (between 0x0 and 0xFFFF)
  • transmit_options (Integer, optional) – Transmit options, bitfield of TransmitOptions. Default to TransmitOptions.NONE.value.
Returns:

Response packet obtained after sending data.

Return type:

XBeePacket

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • InvalidOperatingModeException – If the XBee’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’s communication interface is closed.
  • ValueError – if cluster_id or profile_id is less than 0x0 or greater than 0xFFFF.
send_expl_data_broadcast(data, src_endpoint, dest_endpoint, cluster_id, profile_id, transmit_options=0)[source]

Sends the provided explicit data to all the XBee nodes of the network (broadcast) using provided source and destination end points, cluster and profile ids.

This method blocks until 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 method AbstractXBeeDevice.get_sync_ops_timeout().

Parameters:
  • data (String or Bytearray) – 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 (between 0x0 and 0xFFFF)
  • profile_id (Integer) – Profile ID of the transmission (between 0x0 and 0xFFFF)
  • transmit_options (Integer, optional) – Transmit options, bitfield of TransmitOptions. Default to TransmitOptions.NONE.value.
Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • InvalidOperatingModeException – If the XBee’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’s communication interface is closed.
  • ValueError – if cluster_id or profile_id is less than 0x0 or greater than 0xFFFF.

See also

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

Non-blocking method. Sends the provided explicit data to the given XBee, source and destination end points, cluster and profile ids.

Parameters:
  • remote_xbee (RemoteXBeeDevice) – Remote XBee to send data to.
  • data (String or Bytearray) – 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 (between 0x0 and 0xFFFF)
  • profile_id (Integer) – Profile ID of the transmission (between 0x0 and 0xFFFF)
  • transmit_options (Integer, optional) – Transmit options, bitfield of TransmitOptions. Default to TransmitOptions.NONE.value.
Raises:
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – If the XBee’s communication interface is closed.
  • ValueError – if cluster_id or profile_id is less than 0x0 or greater than 0xFFFF.

See also

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) – 16-bit address of the multicast group.
  • data (Bytearray) – 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 (between 0x0 and 0xFFFF)
  • profile_id (Integer) – Profile ID of the transmission (between 0x0 and 0xFFFF)
Returns:

the response packet.

Return type:

XBeePacket

Raises:
  • TimeoutException – If response is not received before the read timeout expires.
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – If the XBee’s communication interface is closed.

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 does not wait for a response.

Parameters:
  • group_id (XBee16BitAddress) – 16-bit address of the multicast group.
  • data (Bytearray) – 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 (between 0x0 and 0xFFFF)
  • profile_id (Integer) – Profile ID of the transmission (between 0x0 and 0xFFFF)
Raises:
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
  • XBeeException – If the XBee’s communication interface 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 request and waits for the answer of the operation. Then, returns the corresponding status.

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

Register device operation status or

None if the answer is not a RegisterDeviceStatusPacket.

Return type:

ZigbeeRegisterStatus

Raises: