digi.xbee.devices module¶
-
class
digi.xbee.devices.
AbstractXBeeDevice
(local_xbee_device=None, serial_port=None, sync_ops_timeout=4, comm_iface=None)[source]¶ Bases:
object
This class provides common functionality for all XBee devices.
Class constructor. Instantiates a new
AbstractXBeeDevice
object with the provided parameters.Parameters: - local_xbee_device (
XBeeDevice
, optional) – only necessary if XBee device is remote. The local XBee device that will behave as connection interface to communicate with the remote XBee one. - serial_port (
XBeeSerialPort
, optional) – only necessary if the XBee device is local. The serial port that will be used to communicate with this XBee. - (Integer, default (sync_ops_timeout) –
AbstractXBeeDevice._DEFAULT_TIMEOUT_SYNC_OPERATIONS
): the timeout (in seconds) that will be applied for all synchronous operations. - comm_iface (
XBeeCommunicationInterface
, optional) – only necessary if the XBee device is local. The hardware interface that will be used to communicate with this XBee.
See also
-
LOG_PATTERN
= '{comm_iface:s} - {event:s} - {opmode:s}: {content:s}'¶ Pattern used to log packet events.
-
update_device_data_from
(device)[source]¶ Updates the current device reference with the data provided for the given device.
This is only for internal use.
Parameters: device ( AbstractXBeeDevice
) – the XBee device to get the data from.Returns: True
if the device data has been updated,False
otherwise.Return type: Boolean
-
get_parameter
(parameter, parameter_value=None)[source]¶ Returns the value of the provided parameter via an AT Command.
Parameters: - parameter (String) – parameter to get.
- parameter_value (Bytearray, optional) – The value of the parameter to execute (if any).
Returns: the parameter value.
Return type: Bytearray
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
set_parameter
(parameter, value)[source]¶ Sets the value of a parameter via an AT Command.
If you send parameter to a local XBee device, all changes will be applied automatically, except for non-volatile memory, in which case you will need to execute the parameter “WR” via
AbstractXBeeDevice.execute_command()
method, orAbstractXBeeDevice.apply_changes()
method.If you are sending parameters to a remote XBee device, the changes will be not applied automatically, unless the “apply_changes” flag is activated.
You can set this flag via the method
AbstractXBeeDevice.enable_apply_changes()
.This flag only works for volatile memory, if you want to save changed parameters in non-volatile memory, even for remote devices, you must execute “WR” command by one of the 2 ways mentioned above.
Parameters: - parameter (String) – parameter to set.
- value (Bytearray) – value of the parameter.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- ValueError – if
parameter
isNone
orvalue
isNone
.
-
execute_command
(parameter)[source]¶ Executes the provided command.
Parameters: parameter (String) – The name of the AT command to be executed.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
apply_changes
()[source]¶ Applies changes via
AC
command.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
write_changes
()[source]¶ Writes configurable parameter values to the non-volatile memory of the XBee device so that parameter modifications persist through subsequent resets.
Parameters values remain in this device’s memory until overwritten by subsequent use of this method.
If changes are made without writing them to non-volatile memory, the module reverts back to previously saved parameters the next time the module is powered-on.
Writing the parameter modifications does not mean those values are immediately applied, this depends on the status of the ‘apply configuration changes’ option. Use method
is_apply_configuration_changes_enabled()
to get its status andenable_apply_configuration_changes()
to enable/disable the option. If it is disabled, methodapply_changes()
can be used in order to manually apply the changes.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
reset
()[source]¶ Performs a software reset on this XBee device and blocks until the process is completed.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
read_device_info
(init=True)[source]¶ Updates all instance parameters reading them from the XBee device.
Parameters: init (Boolean, optional, default=`True`) – If
False
only not initialized parameters are read, all ifTrue
.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
get_node_id
()[source]¶ Returns the Node Identifier (
NI
) value of the XBee device.Returns: the Node Identifier ( NI
) of the XBee device.Return type: String
-
set_node_id
(node_id)[source]¶ Sets the Node Identifier (
NI
) value of the XBee device..Parameters: node_id (String) – the new Node Identifier (
NI
) of the XBee device.Raises: - ValueError – if
node_id
isNone
or its length is greater than 20. - TimeoutException – if the response is not received before the read timeout expires.
- ValueError – if
-
get_hardware_version
()[source]¶ Returns the hardware version of the XBee device.
Returns: the hardware version of the XBee device. Return type: HardwareVersion
See also
-
get_firmware_version
()[source]¶ Returns the firmware version of the XBee device.
Returns: the hardware version of the XBee device. Return type: Bytearray
-
get_protocol
()[source]¶ Returns the current protocol of the XBee device.
Returns: the current protocol of the XBee device. Return type: XBeeProtocol
See also
-
get_16bit_addr
()[source]¶ Returns the 16-bit address of the XBee device.
Returns: the 16-bit address of the XBee device. Return type: XBee16BitAddress
See also
-
set_16bit_addr
(value)[source]¶ Sets the 16-bit address of the XBee device.
Parameters: value (
XBee16BitAddress
) – the new 16-bit address of the XBee device.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the current protocol is not 802.15.4.
-
get_64bit_addr
()[source]¶ Returns the 64-bit address of the XBee device.
Returns: the 64-bit address of the XBee device. Return type: XBee64BitAddress
See also
-
get_role
()[source]¶ Gets the XBee role.
Returns: the role of the XBee. Return type: digi.xbee.models.protocol.Role
See also
-
get_current_frame_id
()[source]¶ Returns the last used frame ID.
Returns: the last used frame ID. Return type: Integer
-
enable_apply_changes
(value)[source]¶ Sets the apply_changes flag.
Parameters: value (Boolean) – True
to enable the apply changes flag,False
to disable it.
-
is_apply_changes_enabled
()[source]¶ Returns whether the apply_changes flag is enabled or not.
Returns: True
if the apply_changes flag is enabled,False
otherwise.Return type: Boolean
-
is_remote
()[source]¶ Determines whether the XBee device is remote or not.
Returns: True
if the XBee device is remote,False
otherwise.Return type: Boolean
-
set_sync_ops_timeout
(sync_ops_timeout)[source]¶ Sets the serial port read timeout.
Parameters: sync_ops_timeout (Integer) – the read timeout, expressed in seconds.
-
get_sync_ops_timeout
()[source]¶ Returns the serial port read timeout.
Returns: the serial port read timeout in seconds. Return type: Integer
-
get_dest_address
()[source]¶ Returns the 64-bit address of the XBee device that data will be reported to.
Returns: the address. Return type: XBee64BitAddress
Raises: TimeoutException – if the response is not received before the read timeout expires. See also
-
set_dest_address
(addr)[source]¶ Sets the 64-bit address of the XBee device that data will be reported to.
Parameters: addr (
XBee64BitAddress
orRemoteXBeeDevice
) – the address itself or the remote XBee device that you want to set up its address as destination address.Raises: - TimeoutException – If the response is not received before the read timeout expires.
- XBeeException – If the XBee device’s serial port is closed.
- InvalidOperatingModeException – If the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – If the response is not as expected.
- ValueError – If
addr
isNone
.
-
get_pan_id
()[source]¶ Returns the operating PAN ID of the XBee device.
Returns: operating PAN ID of the XBee device. Return type: Bytearray Raises: TimeoutException – if the response is not received before the read timeout expires.
-
set_pan_id
(value)[source]¶ Sets the operating PAN ID of the XBee device.
Parameters: value (Bytearray) – the new operating PAN ID of the XBee device.. Must have only 1 or 2 bytes. Raises: TimeoutException – if the response is not received before the read timeout expires.
-
get_power_level
()[source]¶ Returns the power level of the XBee device.
Returns: the power level of the XBee device. Return type: PowerLevel
Raises: TimeoutException – if the response is not received before the read timeout expires. See also
-
set_power_level
(power_level)[source]¶ Sets the power level of the XBee device.
Parameters: power_level ( PowerLevel
) – the new power level of the XBee device.Raises: TimeoutException – if the response is not received before the read timeout expires. See also
-
set_io_configuration
(io_line, io_mode)[source]¶ Sets the configuration of the provided IO line.
Parameters: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
get_io_configuration
(io_line)[source]¶ Returns the configuration of the provided IO line.
Parameters: io_line (
IOLine
) – the io line to configure.Returns: the IO mode of the IO line provided.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the received data is not an IO mode.
-
get_io_sampling_rate
()[source]¶ Returns the IO sampling rate of the XBee device.
Returns: the IO sampling rate of XBee device.
Return type: Integer
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
set_io_sampling_rate
(rate)[source]¶ Sets the IO sampling rate of the XBee device in seconds. A sample rate of 0 means the IO sampling feature is disabled.
Parameters: rate (Integer) – the new IO sampling rate of the XBee device in seconds.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
read_io_sample
()[source]¶ Returns an IO sample from the XBee device containing the value of all enabled digital IO and analog input channels.
Returns: the IO sample read from the XBee device.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
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()
andIOMode.ADC
.Parameters: io_line (
IOLine
) – the IO line to get its ADC value.Returns: the analog value corresponding to the provided IO line.
Return type: Integer
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the response does not contain the value for the given IO line.
See also
-
set_pwm_duty_cycle
(io_line, cycle)[source]¶ Sets the duty cycle in % of the provided IO line.
The provided IO line must be PWM-capable, previously configured as PWM output.
Parameters: - io_line (
IOLine
) – the IO Line to be assigned. - cycle (Integer) – duty cycle in % to be assigned. Must be between 0 and 100.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- ValueError – if the given IO line does not have PWM capability or
cycle
is not between 0 and 100.
See also
- io_line (
-
get_pwm_duty_cycle
(io_line)[source]¶ Returns the PWM duty cycle in % corresponding to the provided IO line.
Parameters: io_line (
IOLine
) – the IO line to get its PWM duty cycle.Returns: the PWM duty cycle of the given IO line or
None
if the response is empty.Return type: Integer
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- ValueError – if the passed
IO_LINE
has no PWM capability.
See also
-
get_dio_value
(io_line)[source]¶ Returns the digital value of the provided IO line.
The provided IO line must be previously configured as digital I/O. To do so, use
AbstractXBeeDevice.set_io_configuration()
.Parameters: io_line (
IOLine
) – the DIO line to gets its digital value.Returns: current value of the provided IO line.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the 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: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
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 the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
See also
-
get_api_output_mode
()[source]¶ Deprecated since version 1.3: Use
get_api_output_mode_value()
Returns the API output mode of the XBee device.
The API output mode determines the format that the received data is output through the serial interface of the XBee device.
Returns: the API output mode of the XBee device.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
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 the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- 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 device.
Parameters: api_output_mode (
APIOutputMode
) – the new API output mode of the XBee device.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the current protocol is ZigBee
See also
-
set_api_output_mode_value
(api_output_mode)[source]¶ Sets the API output mode of the XBee.
Parameters: api_output_mode (Integer) – new API output mode options. Calculate this value using the method
digi.xbee.models.mode.APIOutputModeBit.calculate_api_output_mode_value()
with a set ofdigi.xbee.models.mode.APIOutputModeBit
.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if it is not supported by the current protocol.
-
enable_bluetooth
()[source]¶ Enables the Bluetooth interface of this XBee device.
To work with this interface, you must also configure the Bluetooth password if not done previously. You can use the
AbstractXBeeDevice.update_bluetooth_password()
method for that purpose.Note that your device must have Bluetooth Low Energy support to use this method.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
disable_bluetooth
()[source]¶ Disables the Bluetooth interface of this XBee device.
Note that your device must have Bluetooth Low Energy support to use this method.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
get_bluetooth_mac_addr
()[source]¶ Reads and returns the EUI-48 Bluetooth MAC address of this XBee device in a format such as
00112233AABB
.Note that your device must have Bluetooth Low Energy support to use this method.
Returns: The Bluetooth MAC address.
Return type: String
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
update_bluetooth_password
(new_password)[source]¶ Changes the password of this Bluetooth device with the new one provided.
Note that your device must have Bluetooth Low Energy support to use this method.
Parameters: new_password (String) – New Bluetooth password.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
update_firmware
(xml_firmware_file, xbee_firmware_file=None, bootloader_firmware_file=None, timeout=None, progress_callback=None)[source]¶ Performs a firmware update operation of the device.
Parameters: - xml_firmware_file (String) – path of the XML file that describes the firmware to upload.
- xbee_firmware_file (String, optional) – location of the XBee binary firmware file.
- bootloader_firmware_file (String, optional) – location of the bootloader binary firmware file.
- timeout (Integer, optional) – the maximum time to wait for target read operations during the update process.
- progress_callback (Function, optional) –
- function to execute to receive progress information. Receives two
- arguments:
- The current update task as a String
- The current update task percentage as an Integer
Raises: - XBeeException – if the device is not open.
- InvalidOperatingModeException – if the device operating mode is invalid.
- OperationNotSupportedException – if the firmware update is not supported in the XBee device.
- FirmwareUpdateException – if there is any error performing the firmware update.
-
apply_profile
(profile_path, progress_callback=None)[source]¶ Applies the given XBee profile to the XBee device.
Parameters: - profile_path (String) – path of the XBee profile file to apply.
- progress_callback (Function, optional) –
- function to execute to receive progress information. Receives two
- arguments:
- The current apply profile task as a String
- The current apply profile task percentage as an Integer
Raises: - XBeeException – if the device is not open.
- InvalidOperatingModeException – if the device operating mode is invalid.
- UpdateProfileException – if there is any error applying the XBee profile.
- OperationNotSupportedException – if XBee profiles are not supported in the XBee device.
-
log
¶ Logger
. The XBee device logger.
- local_xbee_device (
-
class
digi.xbee.devices.
XBeeDevice
(port=None, baud_rate=None, data_bits=<sphinx.ext.autodoc.importer._MockObject object>, stop_bits=<sphinx.ext.autodoc.importer._MockObject object>, parity=<sphinx.ext.autodoc.importer._MockObject object>, flow_control=<FlowControl.NONE: None>, _sync_ops_timeout=4, comm_iface=None)[source]¶ Bases:
digi.xbee.devices.AbstractXBeeDevice
This class represents a non-remote generic XBee device.
This class has fields that are events. Its recommended to use only the append() and remove() method on them, or -= and += operators. If you do something more with them, it’s for your own risk.
Class constructor. Instantiates a new
XBeeDevice
with the provided parameters.Parameters: - port (Integer or String) – serial port identifier. Integer: number of XBee device, numbering starts at zero. Device name: depending on operating system. e.g. ‘/dev/ttyUSB0’ on ‘GNU/Linux’ or ‘COM3’ on Windows.
- baud_rate (Integer) – the serial port baud rate.
- (Integer, default (_sync_ops_timeout) –
serial.EIGHTBITS
): comm port bitsize. - (Integer, default –
serial.STOPBITS_ONE
): comm port stop bits. - (Character, default (parity) –
serial.PARITY_NONE
): comm port parity. - (Integer, default –
FlowControl.NONE
): comm port flow control. - (Integer, default – 3): the read timeout (in seconds).
- comm_iface (
XBeeCommunicationInterface
) – the communication interface.
Raises: All exceptions raised by PySerial's Serial class constructor. –
See also
PySerial documentation: http://pyserial.sourceforge.net-
TIMEOUT_READ_PACKET
= 3¶ Timeout to read packets.
-
classmethod
create_xbee_device
(comm_port_data)[source]¶ Creates and returns an
XBeeDevice
from data of the port to which is connected.Parameters: - comm_port_data (Dictionary) – dictionary with all comm port data needed.
- dictionary keys are (The) – “baudRate” –> Baud rate.”port” –> Port number.”bitSize” –> Bit size.”stopBits” –> Stop bits.”parity” –> Parity.”flowControl” –> Flow control.”timeout” for –> Timeout for synchronous operations (in seconds).
Returns: the XBee device created.
Return type: Raises: SerialException – if the port you want to open does not exist or is already opened.
See also
-
open
(force_settings=False)[source]¶ Opens the communication with the XBee device and loads some information about it.
Parameters: force_settings (Boolean, optional) –
True
to open the device ensuring/forcing that the specified serial settings are applied even if the current configuration is different,False
to open the device with the current configuration. Default to False.Raises: - TimeoutException – if there is any problem with the communication.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- XBeeException – if the XBee device is already open.
-
close
()[source]¶ Closes the communication with the XBee device.
This method guarantees that all threads running are stopped and the serial port is closed.
-
send_data
(remote_xbee_device, data, transmit_options=0)[source]¶ Blocking method. This method sends data to a remote XBee device synchronously.
This method will wait for the packet response.
The default timeout for this method is
XBeeDevice._DEFAULT_TIMEOUT_SYNC_OPERATIONS
.Parameters: - remote_xbee_device (
RemoteXBeeDevice
) – the remote XBee device to send data to. - data (String or Bytearray) – the raw data to send.
- transmit_options (Integer, optional) – transmit options, bitfield of
TransmitOptions
. Default toTransmitOptions.NONE.value
.
Returns: XBeePacket
the response.Raises: - ValueError – if
remote_xbee_device
isNone
. - TimeoutException – if this method can’t read a response packet in
XBeeDevice._DEFAULT_TIMEOUT_SYNC_OPERATIONS
seconds. - InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- TransmitException – if the status of the response received is not OK.
- XBeeException – if the XBee device’s serial port is closed.
See also
- remote_xbee_device (
-
send_data_async
(remote_xbee_device, data, transmit_options=0)[source]¶ Non-blocking method. This method sends data to a remote XBee device.
This method won’t wait for the response.
Parameters: - remote_xbee_device (
RemoteXBeeDevice
) – the remote XBee device to send data to. - data (String or Bytearray) – the raw data to send.
- transmit_options (Integer, optional) – transmit options, bitfield of
TransmitOptions
. Default toTransmitOptions.NONE.value
.
Raises: - InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- XBeeException – if the XBee device’s serial port is closed.
See also
- remote_xbee_device (
-
send_data_broadcast
(data, transmit_options=0)[source]¶ Sends the provided data to all the XBee nodes of the network (broadcast).
This method blocks till a success or error transmit status arrives or the configured receive timeout expires.
The received timeout is configured using the
AbstractXBeeDevice.set_sync_ops_timeout()
method and can be consulted withAbstractXBeeDevice.get_sync_ops_timeout()
method.Parameters: - data (String or Bytearray) – data to send.
- transmit_options (Integer, optional) – transmit options, bitfield of
TransmitOptions
. Default toTransmitOptions.NONE.value
.
Raises: - TimeoutException – if this method can’t read a response packet in
XBeeDevice._DEFAULT_TIMEOUT_SYNC_OPERATIONS
seconds. - InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- TransmitException – if the status of the response received is not OK.
- XBeeException – if the XBee device’s serial port is closed.
-
send_user_data_relay
(local_interface, data)[source]¶ Sends the given data to the given XBee local interface.
Parameters: - local_interface (
XBeeLocalInterface
) – Destination XBee local interface. - data (Bytearray) – Data to send.
Raises: - InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ValueError – if
local_interface
isNone
. - XBeeException – if there is any problem sending the User Data Relay.
See also
- local_interface (
-
send_bluetooth_data
(data)[source]¶ Sends the given data to the Bluetooth interface using a User Data Relay frame.
Parameters: data (Bytearray) – Data to send.
Raises: - InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- XBeeException – if there is any problem sending the data.
-
send_micropython_data
(data)[source]¶ Sends the given data to the MicroPython interface using a User Data Relay frame.
Parameters: data (Bytearray) – Data to send.
Raises: - InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- XBeeException – if there is any problem sending the data.
-
read_data
(timeout=None)[source]¶ Reads new data received by this XBee device.
If a
timeout
is specified, this method blocks until new data is received or the timeout expires, throwing in that case aTimeoutException
.Parameters: timeout (Integer, optional) – read timeout in seconds. If it’s
None
, this method is non-blocking and will returnNone
if there is no data available.Returns: the read message or
None
if this XBee did not receive new data.Return type: Raises: - ValueError – if a timeout is specified and is less than 0.
- TimeoutException – if a timeout is specified and no data was received during that time.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- XBeeException – if the XBee device’s serial port is closed.
See also
-
read_data_from
(remote_xbee_device, timeout=None)[source]¶ Reads new data received from the given remote XBee device.
If a
timeout
is specified, this method blocks until new data is received or the timeout expires, throwing in that case aTimeoutException
.Parameters: - remote_xbee_device (
RemoteXBeeDevice
) – the remote XBee device that sent the data. - timeout (Integer, optional) – read timeout in seconds. If it’s
None
, this method is non-blocking and will returnNone
if there is no data available.
Returns: - the read message sent by
remote_xbee_device
orNone
if this XBee did not receive new data.
Return type: Raises: - ValueError – if a timeout is specified and is less than 0.
- TimeoutException – if a timeout is specified and no data was received during that time.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- XBeeException – if the XBee device’s serial port is closed.
See also
- remote_xbee_device (
-
has_packets
()[source]¶ Returns whether the XBee device’s queue has packets or not. This do not include explicit packets.
Returns: True
if this XBee device’s queue has packets,False
otherwise.Return type: Boolean See also
-
has_explicit_packets
()[source]¶ Returns whether the XBee device’s queue has explicit packets or not. This do not include non-explicit packets.
Returns: True
if this XBee device’s queue has explicit packets,False
otherwise.Return type: Boolean See also
-
add_packet_received_callback
(callback)[source]¶ Adds a callback for the event
digi.xbee.reader.PacketReceived
.Parameters: callback (Function) – the callback. Receives two arguments.
- The received packet as a
digi.xbee.packets.base.XBeeAPIPacket
- The received packet as a
-
add_data_received_callback
(callback)[source]¶ Adds a callback for the event
digi.xbee.reader.DataReceived
.Parameters: callback (Function) – the callback. Receives one argument.
- The data received as an
digi.xbee.models.message.XBeeMessage
- The data received as an
-
add_modem_status_received_callback
(callback)[source]¶ Adds a callback for the event
digi.xbee.reader.ModemStatusReceived
.Parameters: callback (Function) – the callback. Receives one argument.
- The modem status as a
digi.xbee.models.status.ModemStatus
- The modem status as a
-
add_io_sample_received_callback
(callback)[source]¶ Adds a callback for the event
digi.xbee.reader.IOSampleReceived
.Parameters: callback (Function) – the callback. Receives three arguments.
- The received IO sample as an
digi.xbee.io.IOSample
- The remote XBee device who has sent the packet as a
RemoteXBeeDevice
- The time in which the packet was received as an Integer
- The received IO sample as an
-
add_expl_data_received_callback
(callback)[source]¶ Adds a callback for the event
digi.xbee.reader.ExplicitDataReceived
.Parameters: callback (Function) – the callback. Receives one argument.
- The explicit data received as a
digi.xbee.models.message.ExplicitXBeeMessage
.
- The explicit data received as a
-
add_user_data_relay_received_callback
(callback)[source]¶ Adds a callback for the event
digi.xbee.reader.RelayDataReceived
.Parameters: callback (Function) – the callback. Receives one argument.
- The relay data as a
digi.xbee.models.message.UserDataRelayMessage
- The relay data as a
-
add_bluetooth_data_received_callback
(callback)[source]¶ Adds a callback for the event
digi.xbee.reader.BluetoothDataReceived
.Parameters: callback (Function) – the callback. Receives one argument.
- The Bluetooth data as a Bytearray
-
add_micropython_data_received_callback
(callback)[source]¶ Adds a callback for the event
digi.xbee.reader.MicroPythonDataReceived
.Parameters: callback (Function) – the callback. Receives one argument.
- The MicroPython data as a Bytearray
-
add_socket_state_received_callback
(callback)[source]¶ Adds a callback for the event
digi.xbee.reader.SocketStateReceived
.Parameters: callback (Function) – the callback. Receives two arguments.
- The socket ID as an Integer.
- The state received as a
SocketState
-
add_socket_data_received_callback
(callback)[source]¶ Adds a callback for the event
digi.xbee.reader.SocketDataReceived
.Parameters: callback (Function) – the callback. Receives two arguments.
- The socket ID as an Integer.
- The data received as Bytearray
-
add_socket_data_received_from_callback
(callback)[source]¶ Adds a callback for the event
digi.xbee.reader.SocketDataReceivedFrom
.Parameters: callback (Function) – the callback. Receives three arguments.
- The socket ID as an Integer.
- A pair (host, port) of the source address where host is a string
- representing an IPv4 address like ‘100.50.200.5’, and port is an integer.
- The data received as Bytearray
-
del_packet_received_callback
(callback)[source]¶ Deletes a callback for the callback list of
digi.xbee.reader.PacketReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.PacketReceived
event.
-
del_data_received_callback
(callback)[source]¶ Deletes a callback for the callback list of
digi.xbee.reader.DataReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.DataReceived
event.
-
del_modem_status_received_callback
(callback)[source]¶ Deletes a callback for the callback list of
digi.xbee.reader.ModemStatusReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.ModemStatusReceived
event.
-
del_io_sample_received_callback
(callback)[source]¶ Deletes a callback for the callback list of
digi.xbee.reader.IOSampleReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.IOSampleReceived
event.
-
del_expl_data_received_callback
(callback)[source]¶ Deletes a callback for the callback list of
digi.xbee.reader.ExplicitDataReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.ExplicitDataReceived
event.
-
del_user_data_relay_received_callback
(callback)[source]¶ Deletes a callback for the callback list of
digi.xbee.reader.RelayDataReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.RelayDataReceived
event.
-
del_bluetooth_data_received_callback
(callback)[source]¶ Deletes a callback for the callback list of
digi.xbee.reader.BluetoothDataReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.BluetoothDataReceived
event.
-
del_micropython_data_received_callback
(callback)[source]¶ Deletes a callback for the callback list of
digi.xbee.reader.MicroPythonDataReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.MicroPythonDataReceived
event.
-
del_socket_state_received_callback
(callback)[source]¶ Deletes a callback for the callback list of
digi.xbee.reader.SocketStateReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.SocketStateReceived
event.
-
del_socket_data_received_callback
(callback)[source]¶ Deletes a callback for the callback list of
digi.xbee.reader.SocketDataReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.SocketDataReceived
event.
-
del_socket_data_received_from_callback
(callback)[source]¶ Deletes a callback for the callback list of
digi.xbee.reader.SocketDataReceivedFrom
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.SocketDataReceivedFrom
event.
-
get_xbee_device_callbacks
()[source]¶ Returns this XBee internal callbacks for process received packets.
This method is called by the PacketListener associated with this XBee to get its callbacks. These callbacks will be executed before user callbacks.
Returns: PacketReceived
-
is_open
()[source]¶ Returns whether this XBee device is open or not.
Returns: Boolean. True
if this XBee device is open,False
otherwise.
-
send_packet_sync_and_get_response
(packet_to_send, timeout=None)[source]¶ Override method.
See also
AbstractXBeeDevice._send_packet_sync_and_get_response()
-
send_packet
(packet, sync=False)[source]¶ Override method.
See also
AbstractXBeeDevice._send_packet()
-
get_next_frame_id
()[source]¶ Returns the next frame ID of the XBee device.
Returns: The next frame ID of the XBee device. Return type: Integer
-
comm_iface
¶ XBeeCommunicationInterface
. The hardware interface associated to the XBee device.
-
serial_port
¶ XBeeSerialPort
. The serial port associated to the XBee device.
-
operating_mode
¶ OperatingMode
. The operating mode of the XBee device.
-
apply_changes
()¶ Applies changes via
AC
command.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
apply_profile
(profile_path, progress_callback=None)¶ Applies the given XBee profile to the XBee device.
Parameters: - profile_path (String) – path of the XBee profile file to apply.
- progress_callback (Function, optional) –
- function to execute to receive progress information. Receives two
- arguments:
- The current apply profile task as a String
- The current apply profile task percentage as an Integer
Raises: - XBeeException – if the device is not open.
- InvalidOperatingModeException – if the device operating mode is invalid.
- UpdateProfileException – if there is any error applying the XBee profile.
- OperationNotSupportedException – if XBee profiles are not supported in the XBee device.
-
disable_bluetooth
()¶ Disables the Bluetooth interface of this XBee device.
Note that your device must have Bluetooth Low Energy support to use this method.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
enable_apply_changes
(value)¶ Sets the apply_changes flag.
Parameters: value (Boolean) – True
to enable the apply changes flag,False
to disable it.
-
enable_bluetooth
()¶ Enables the Bluetooth interface of this XBee device.
To work with this interface, you must also configure the Bluetooth password if not done previously. You can use the
AbstractXBeeDevice.update_bluetooth_password()
method for that purpose.Note that your device must have Bluetooth Low Energy support to use this method.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
execute_command
(parameter)¶ Executes the provided command.
Parameters: parameter (String) – The name of the AT command to be executed.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
get_16bit_addr
()¶ Returns the 16-bit address of the XBee device.
Returns: the 16-bit address of the XBee device. Return type: XBee16BitAddress
See also
-
get_64bit_addr
()¶ Returns the 64-bit address of the XBee device.
Returns: the 64-bit address of the XBee device. Return type: XBee64BitAddress
See also
-
get_adc_value
(io_line)¶ Returns the analog value of the provided IO line.
The provided IO line must be previously configured as ADC. To do so, use
AbstractXBeeDevice.set_io_configuration()
andIOMode.ADC
.Parameters: io_line (
IOLine
) – the IO line to get its ADC value.Returns: the analog value corresponding to the provided IO line.
Return type: Integer
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the response does not contain the value for the given IO line.
See also
-
get_api_output_mode
()¶ Deprecated since version 1.3: Use
get_api_output_mode_value()
Returns the API output mode of the XBee device.
The API output mode determines the format that the received data is output through the serial interface of the XBee device.
Returns: the API output mode of the XBee device.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
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 the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- 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 device in a format such as
00112233AABB
.Note that your device must have Bluetooth Low Energy support to use this method.
Returns: The Bluetooth MAC address.
Return type: String
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
get_current_frame_id
()¶ Returns the last used frame ID.
Returns: the last used frame ID. Return type: Integer
-
get_dest_address
()¶ Returns the 64-bit address of the XBee device that data will be reported to.
Returns: the address. Return type: XBee64BitAddress
Raises: TimeoutException – if the response is not received before the read timeout expires. See also
-
get_dio_value
(io_line)¶ Returns the digital value of the provided IO line.
The provided IO line must be previously configured as digital I/O. To do so, use
AbstractXBeeDevice.set_io_configuration()
.Parameters: io_line (
IOLine
) – the DIO line to gets its digital value.Returns: current value of the provided IO line.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the response does not contain the value for the given IO line.
-
get_firmware_version
()¶ Returns the firmware version of the XBee device.
Returns: the hardware version of the XBee device. Return type: Bytearray
-
get_hardware_version
()¶ Returns the hardware version of the XBee device.
Returns: the hardware version of the XBee device. Return type: HardwareVersion
See also
-
get_io_configuration
(io_line)¶ Returns the configuration of the provided IO line.
Parameters: io_line (
IOLine
) – the io line to configure.Returns: the IO mode of the IO line provided.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the received data is not an IO mode.
-
get_io_sampling_rate
()¶ Returns the IO sampling rate of the XBee device.
Returns: the IO sampling rate of XBee device.
Return type: Integer
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
get_node_id
()¶ Returns the Node Identifier (
NI
) value of the XBee device.Returns: the Node Identifier ( NI
) of the XBee device.Return type: String
-
get_pan_id
()¶ Returns the operating PAN ID of the XBee device.
Returns: operating PAN ID of the XBee device. Return type: Bytearray Raises: TimeoutException – if the response is not received before the read timeout expires.
-
get_power_level
()¶ Returns the power level of the XBee device.
Returns: the power level of the XBee device. Return type: PowerLevel
Raises: TimeoutException – if the response is not received before the read timeout expires. See also
-
get_protocol
()¶ Returns the current protocol of the XBee device.
Returns: the current protocol of the XBee device. Return type: XBeeProtocol
See also
-
get_pwm_duty_cycle
(io_line)¶ Returns the PWM duty cycle in % corresponding to the provided IO line.
Parameters: io_line (
IOLine
) – the IO line to get its PWM duty cycle.Returns: the PWM duty cycle of the given IO line or
None
if the response is empty.Return type: Integer
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- ValueError – if the passed
IO_LINE
has no PWM capability.
See also
-
get_role
()¶ Gets the XBee role.
Returns: the role of the XBee. Return type: digi.xbee.models.protocol.Role
See also
-
get_sync_ops_timeout
()¶ Returns the serial port read timeout.
Returns: the serial port read timeout in seconds. Return type: Integer
-
is_apply_changes_enabled
()¶ Returns whether the apply_changes flag is enabled or not.
Returns: True
if the apply_changes flag is enabled,False
otherwise.Return type: Boolean
-
log
¶ Returns the XBee device log.
Returns: the XBee device logger. Return type: Logger
-
read_device_info
(init=True)¶ Updates all instance parameters reading them from the XBee device.
Parameters: init (Boolean, optional, default=`True`) – If
False
only not initialized parameters are read, all ifTrue
.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
read_io_sample
()¶ Returns an IO sample from the XBee device containing the value of all enabled digital IO and analog input channels.
Returns: the IO sample read from the XBee device.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
See also
-
set_16bit_addr
(value)¶ Sets the 16-bit address of the XBee device.
Parameters: value (
XBee16BitAddress
) – the new 16-bit address of the XBee device.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the current 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 device.
Parameters: api_output_mode (
APIOutputMode
) – the new API output mode of the XBee device.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the current protocol is ZigBee
See also
-
set_api_output_mode_value
(api_output_mode)¶ Sets the API output mode of the XBee.
Parameters: api_output_mode (Integer) – new API output mode options. Calculate this value using the method
digi.xbee.models.mode.APIOutputModeBit.calculate_api_output_mode_value()
with a set ofdigi.xbee.models.mode.APIOutputModeBit
.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if it is not supported by the current protocol.
-
set_dest_address
(addr)¶ Sets the 64-bit address of the XBee device that data will be reported to.
Parameters: addr (
XBee64BitAddress
orRemoteXBeeDevice
) – the address itself or the remote XBee device that you want to set up its address as destination address.Raises: - TimeoutException – If the response is not received before the read timeout expires.
- XBeeException – If the XBee device’s serial port is closed.
- InvalidOperatingModeException – If the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – If the response is not as expected.
- ValueError – If
addr
isNone
.
-
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 the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
See also
-
set_dio_value
(io_line, io_value)¶ Sets the digital value (high or low) to the provided IO line.
Parameters: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
set_io_configuration
(io_line, io_mode)¶ Sets the configuration of the provided IO line.
Parameters: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
set_io_sampling_rate
(rate)¶ Sets the IO sampling rate of the XBee device in seconds. A sample rate of 0 means the IO sampling feature is disabled.
Parameters: rate (Integer) – the new IO sampling rate of the XBee device in seconds.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
set_node_id
(node_id)¶ Sets the Node Identifier (
NI
) value of the XBee device..Parameters: node_id (String) – the new Node Identifier (
NI
) of the XBee device.Raises: - ValueError – if
node_id
isNone
or its length is greater than 20. - TimeoutException – if the response is not received before the read timeout expires.
- ValueError – if
-
set_pan_id
(value)¶ Sets the operating PAN ID of the XBee device.
Parameters: value (Bytearray) – the new operating PAN ID of the XBee device.. Must have only 1 or 2 bytes. Raises: TimeoutException – if the response is not received before the read timeout expires.
-
set_power_level
(power_level)¶ Sets the power level of the XBee device.
Parameters: power_level ( PowerLevel
) – the new power level of the XBee device.Raises: TimeoutException – if the response is not received before the read timeout expires. See also
-
set_pwm_duty_cycle
(io_line, cycle)¶ Sets the duty cycle in % of the provided IO line.
The provided IO line must be PWM-capable, previously configured as PWM output.
Parameters: - io_line (
IOLine
) – the IO Line to be assigned. - cycle (Integer) – duty cycle in % to be assigned. Must be between 0 and 100.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- ValueError – if the given IO line does not have PWM capability or
cycle
is not between 0 and 100.
See also
- io_line (
-
set_sync_ops_timeout
(sync_ops_timeout)¶ Sets the serial port read timeout.
Parameters: sync_ops_timeout (Integer) – the read timeout, expressed in seconds.
-
update_bluetooth_password
(new_password)¶ Changes the password of this Bluetooth device with the new one provided.
Note that your device must have Bluetooth Low Energy support to use this method.
Parameters: new_password (String) – New Bluetooth password.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
update_device_data_from
(device)¶ Updates the current device reference with the data provided for the given device.
This is only for internal use.
Parameters: device ( AbstractXBeeDevice
) – the XBee device to get the data from.Returns: True
if the device data has been updated,False
otherwise.Return type: Boolean
-
update_firmware
(xml_firmware_file, xbee_firmware_file=None, bootloader_firmware_file=None, timeout=None, progress_callback=None)¶ Performs a firmware update operation of the device.
Parameters: - xml_firmware_file (String) – path of the XML file that describes the firmware to upload.
- xbee_firmware_file (String, optional) – location of the XBee binary firmware file.
- bootloader_firmware_file (String, optional) – location of the bootloader binary firmware file.
- timeout (Integer, optional) – the maximum time to wait for target read operations during the update process.
- progress_callback (Function, optional) –
- function to execute to receive progress information. Receives two
- arguments:
- The current update task as a String
- The current update task percentage as an Integer
Raises: - XBeeException – if the device is not open.
- InvalidOperatingModeException – if the device operating mode is invalid.
- OperationNotSupportedException – if the firmware update is not supported in the XBee device.
- FirmwareUpdateException – if there is any error performing the firmware update.
-
write_changes
()¶ Writes configurable parameter values to the non-volatile memory of the XBee device so that parameter modifications persist through subsequent resets.
Parameters values remain in this device’s memory until overwritten by subsequent use of this method.
If changes are made without writing them to non-volatile memory, the module reverts back to previously saved parameters the next time the module is powered-on.
Writing the parameter modifications does not mean those values are immediately applied, this depends on the status of the ‘apply configuration changes’ option. Use method
is_apply_configuration_changes_enabled()
to get its status andenable_apply_configuration_changes()
to enable/disable the option. If it is disabled, methodapply_changes()
can be used in order to manually apply the changes.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
class
digi.xbee.devices.
Raw802Device
(port=None, baud_rate=None, data_bits=<sphinx.ext.autodoc.importer._MockObject object>, stop_bits=<sphinx.ext.autodoc.importer._MockObject object>, parity=<sphinx.ext.autodoc.importer._MockObject object>, flow_control=<FlowControl.NONE: None>, _sync_ops_timeout=4, comm_iface=None)[source]¶ Bases:
digi.xbee.devices.XBeeDevice
This class represents a local 802.15.4 XBee device.
Class constructor. Instantiates a new
Raw802Device
with the provided parameters.Parameters: - port (Integer or String) – serial port identifier. Integer: number of XBee device, numbering starts at zero. Device name: depending on operating system. e.g. ‘/dev/ttyUSB0’ on ‘GNU/Linux’ or ‘COM3’ on Windows.
- baud_rate (Integer) – the serial port baud rate.
- (Integer, default (flow_control) –
serial.EIGHTBITS
): comm port bitsize. - (Integer, default –
serial.STOPBITS_ONE
): comm port stop bits. - (Character, default (parity) –
serial.PARITY_NONE
): comm port parity. - (Integer, default –
FlowControl.NONE
): comm port flow control.- _sync_ops_timeout (Integer, default: 3): the read timeout (in seconds).
- comm_iface (
XBeeCommunicationInterface
): the communication interface.
:raises All exceptions raised by
XBeeDevice.__init__()
constructor.:See also
XBeeDevice.__init__()
-
open
(force_settings=False)[source]¶ Override.
Raises: - TimeoutException – If there is any problem with the communication.
- InvalidOperatingModeException – If the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- XBeeException – If the protocol is invalid or if the XBee device is already open.
See also
-
send_data_64
(x64addr, data, transmit_options=0)[source]¶ Override.
See also
XBeeDevice.send_data_64()
-
send_data_async_64
(x64addr, data, transmit_options=0)[source]¶ Override.
See also
XBeeDevice.send_data_async_64()
-
send_data_16
(x16addr, data, transmit_options=0)[source]¶ Override.
See also
XBeeDevice._send_data_16()
-
send_data_async_16
(x16addr, data, transmit_options=0)[source]¶ Override.
See also
XBeeDevice._send_data_async_16()
-
add_bluetooth_data_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.BluetoothDataReceived
.Parameters: callback (Function) – the callback. Receives one argument.
- The Bluetooth data as a Bytearray
-
add_data_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.DataReceived
.Parameters: callback (Function) – the callback. Receives one argument.
- The data received as an
digi.xbee.models.message.XBeeMessage
- The data received as an
-
add_expl_data_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.ExplicitDataReceived
.Parameters: callback (Function) – the callback. Receives one argument.
- The explicit data received as a
digi.xbee.models.message.ExplicitXBeeMessage
.
- The explicit data received as a
-
add_io_sample_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.IOSampleReceived
.Parameters: callback (Function) – the callback. Receives three arguments.
- The received IO sample as an
digi.xbee.io.IOSample
- The remote XBee device who has sent the packet as a
RemoteXBeeDevice
- The time in which the packet was received as an Integer
- The received IO sample as an
-
add_micropython_data_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.MicroPythonDataReceived
.Parameters: callback (Function) – the callback. Receives one argument.
- The MicroPython data as a Bytearray
-
add_modem_status_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.ModemStatusReceived
.Parameters: callback (Function) – the callback. Receives one argument.
- The modem status as a
digi.xbee.models.status.ModemStatus
- The modem status as a
-
add_packet_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.PacketReceived
.Parameters: callback (Function) – the callback. Receives two arguments.
- The received packet as a
digi.xbee.packets.base.XBeeAPIPacket
- The received packet as a
-
add_socket_data_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.SocketDataReceived
.Parameters: callback (Function) – the callback. Receives two arguments.
- The socket ID as an Integer.
- The data received as Bytearray
-
add_socket_data_received_from_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.SocketDataReceivedFrom
.Parameters: callback (Function) – the callback. Receives three arguments.
- The socket ID as an Integer.
- A pair (host, port) of the source address where host is a string
- representing an IPv4 address like ‘100.50.200.5’, and port is an integer.
- The data received as Bytearray
-
add_socket_state_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.SocketStateReceived
.Parameters: callback (Function) – the callback. Receives two arguments.
- The socket ID as an Integer.
- The state received as a
SocketState
-
add_user_data_relay_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.RelayDataReceived
.Parameters: callback (Function) – the callback. Receives one argument.
- The relay data as a
digi.xbee.models.message.UserDataRelayMessage
- The relay data as a
-
apply_changes
()¶ Applies changes via
AC
command.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
apply_profile
(profile_path, progress_callback=None)¶ Applies the given XBee profile to the XBee device.
Parameters: - profile_path (String) – path of the XBee profile file to apply.
- progress_callback (Function, optional) –
- function to execute to receive progress information. Receives two
- arguments:
- The current apply profile task as a String
- The current apply profile task percentage as an Integer
Raises: - XBeeException – if the device is not open.
- InvalidOperatingModeException – if the device operating mode is invalid.
- UpdateProfileException – if there is any error applying the XBee profile.
- OperationNotSupportedException – if XBee profiles are not supported in the XBee device.
-
close
()¶ Closes the communication with the XBee device.
This method guarantees that all threads running are stopped and the serial port is closed.
-
comm_iface
¶ Returns the hardware interface associated to the XBee device.
Returns: the hardware interface associated to the XBee device. Return type: XBeeCommunicationInterface
See also
-
classmethod
create_xbee_device
(comm_port_data)¶ Creates and returns an
XBeeDevice
from data of the port to which is connected.Parameters: - comm_port_data (Dictionary) – dictionary with all comm port data needed.
- dictionary keys are (The) – “baudRate” –> Baud rate.”port” –> Port number.”bitSize” –> Bit size.”stopBits” –> Stop bits.”parity” –> Parity.”flowControl” –> Flow control.”timeout” for –> Timeout for synchronous operations (in seconds).
Returns: the XBee device created.
Return type: Raises: SerialException – if the port you want to open does not exist or is already opened.
See also
-
del_bluetooth_data_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.BluetoothDataReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.BluetoothDataReceived
event.
-
del_data_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.DataReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.DataReceived
event.
-
del_expl_data_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.ExplicitDataReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.ExplicitDataReceived
event.
-
del_io_sample_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.IOSampleReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.IOSampleReceived
event.
-
del_micropython_data_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.MicroPythonDataReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.MicroPythonDataReceived
event.
-
del_modem_status_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.ModemStatusReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.ModemStatusReceived
event.
-
del_packet_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.PacketReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.PacketReceived
event.
-
del_socket_data_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.SocketDataReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.SocketDataReceived
event.
-
del_socket_data_received_from_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.SocketDataReceivedFrom
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.SocketDataReceivedFrom
event.
-
del_socket_state_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.SocketStateReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.SocketStateReceived
event.
-
del_user_data_relay_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.RelayDataReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.RelayDataReceived
event.
-
disable_bluetooth
()¶ Disables the Bluetooth interface of this XBee device.
Note that your device must have Bluetooth Low Energy support to use this method.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
enable_apply_changes
(value)¶ Sets the apply_changes flag.
Parameters: value (Boolean) – True
to enable the apply changes flag,False
to disable it.
-
enable_bluetooth
()¶ Enables the Bluetooth interface of this XBee device.
To work with this interface, you must also configure the Bluetooth password if not done previously. You can use the
AbstractXBeeDevice.update_bluetooth_password()
method for that purpose.Note that your device must have Bluetooth Low Energy support to use this method.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
execute_command
(parameter)¶ Executes the provided command.
Parameters: parameter (String) – The name of the AT command to be executed.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
flush_queues
()¶ Flushes the packets queue.
-
get_16bit_addr
()¶ Returns the 16-bit address of the XBee device.
Returns: the 16-bit address of the XBee device. Return type: XBee16BitAddress
See also
-
get_64bit_addr
()¶ Returns the 64-bit address of the XBee device.
Returns: the 64-bit address of the XBee device. Return type: XBee64BitAddress
See also
-
get_adc_value
(io_line)¶ Returns the analog value of the provided IO line.
The provided IO line must be previously configured as ADC. To do so, use
AbstractXBeeDevice.set_io_configuration()
andIOMode.ADC
.Parameters: io_line (
IOLine
) – the IO line to get its ADC value.Returns: the analog value corresponding to the provided IO line.
Return type: Integer
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the response does not contain the value for the given IO line.
See also
-
get_api_output_mode
()¶ Deprecated since version 1.3: Use
get_api_output_mode_value()
Returns the API output mode of the XBee device.
The API output mode determines the format that the received data is output through the serial interface of the XBee device.
Returns: the API output mode of the XBee device.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
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 the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- 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 device in a format such as
00112233AABB
.Note that your device must have Bluetooth Low Energy support to use this method.
Returns: The Bluetooth MAC address.
Return type: String
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
get_current_frame_id
()¶ Returns the last used frame ID.
Returns: the last used frame ID. Return type: Integer
-
get_dest_address
()¶ Returns the 64-bit address of the XBee device that data will be reported to.
Returns: the address. Return type: XBee64BitAddress
Raises: TimeoutException – if the response is not received before the read timeout expires. See also
-
get_dio_value
(io_line)¶ Returns the digital value of the provided IO line.
The provided IO line must be previously configured as digital I/O. To do so, use
AbstractXBeeDevice.set_io_configuration()
.Parameters: io_line (
IOLine
) – the DIO line to gets its digital value.Returns: current value of the provided IO line.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the response does not contain the value for the given IO line.
-
get_firmware_version
()¶ Returns the firmware version of the XBee device.
Returns: the hardware version of the XBee device. Return type: Bytearray
-
get_hardware_version
()¶ Returns the hardware version of the XBee device.
Returns: the hardware version of the XBee device. Return type: HardwareVersion
See also
-
get_io_configuration
(io_line)¶ Returns the configuration of the provided IO line.
Parameters: io_line (
IOLine
) – the io line to configure.Returns: the IO mode of the IO line provided.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the received data is not an IO mode.
-
get_io_sampling_rate
()¶ Returns the IO sampling rate of the XBee device.
Returns: the IO sampling rate of XBee device.
Return type: Integer
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
get_network
()¶ Returns this XBee device’s current network.
Returns: XBeeDevice.XBeeNetwork
-
get_next_frame_id
()¶ Returns the next frame ID of the XBee device.
Returns: The next frame ID of the XBee device. Return type: Integer
-
get_node_id
()¶ Returns the Node Identifier (
NI
) value of the XBee device.Returns: the Node Identifier ( NI
) of the XBee device.Return type: String
-
get_pan_id
()¶ Returns the operating PAN ID of the XBee device.
Returns: operating PAN ID of the XBee device. Return type: Bytearray Raises: TimeoutException – if the response is not received before the read timeout expires.
-
get_parameter
(param, parameter_value=None)¶ Override.
See also
-
get_power_level
()¶ Returns the power level of the XBee device.
Returns: the power level of the XBee device. Return type: PowerLevel
Raises: TimeoutException – if the response is not received before the read timeout expires. See also
-
get_pwm_duty_cycle
(io_line)¶ Returns the PWM duty cycle in % corresponding to the provided IO line.
Parameters: io_line (
IOLine
) – the IO line to get its PWM duty cycle.Returns: the PWM duty cycle of the given IO line or
None
if the response is empty.Return type: Integer
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- ValueError – if the passed
IO_LINE
has no PWM capability.
See also
-
get_role
()¶ Gets the XBee role.
Returns: the role of the XBee. Return type: digi.xbee.models.protocol.Role
See also
-
get_sync_ops_timeout
()¶ Returns the serial port read timeout.
Returns: the serial port read timeout in seconds. Return type: Integer
-
get_xbee_device_callbacks
()¶ Returns this XBee internal callbacks for process received packets.
This method is called by the PacketListener associated with this XBee to get its callbacks. These callbacks will be executed before user callbacks.
Returns: PacketReceived
-
has_explicit_packets
()¶ Returns whether the XBee device’s queue has explicit packets or not. This do not include non-explicit packets.
Returns: True
if this XBee device’s queue has explicit packets,False
otherwise.Return type: Boolean See also
-
has_packets
()¶ Returns whether the XBee device’s queue has packets or not. This do not include explicit packets.
Returns: True
if this XBee device’s queue has packets,False
otherwise.Return type: Boolean See also
-
is_apply_changes_enabled
()¶ Returns whether the apply_changes flag is enabled or not.
Returns: True
if the apply_changes flag is enabled,False
otherwise.Return type: Boolean
-
is_open
()¶ Returns whether this XBee device is open or not.
Returns: Boolean. True
if this XBee device is open,False
otherwise.
-
is_remote
()¶ Override method.
See also
-
log
¶ Returns the XBee device log.
Returns: the XBee device logger. Return type: Logger
-
operating_mode
¶ Returns this XBee device’s operating mode.
Returns: OperatingMode
. This XBee device’s operating mode.
-
read_data
(timeout=None)¶ Reads new data received by this XBee device.
If a
timeout
is specified, this method blocks until new data is received or the timeout expires, throwing in that case aTimeoutException
.Parameters: timeout (Integer, optional) – read timeout in seconds. If it’s
None
, this method is non-blocking and will returnNone
if there is no data available.Returns: the read message or
None
if this XBee did not receive new data.Return type: Raises: - ValueError – if a timeout is specified and is less than 0.
- TimeoutException – if a timeout is specified and no data was received during that time.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- XBeeException – if the XBee device’s serial port is closed.
See also
-
read_data_from
(remote_xbee_device, timeout=None)¶ Reads new data received from the given remote XBee device.
If a
timeout
is specified, this method blocks until new data is received or the timeout expires, throwing in that case aTimeoutException
.Parameters: - remote_xbee_device (
RemoteXBeeDevice
) – the remote XBee device that sent the data. - timeout (Integer, optional) – read timeout in seconds. If it’s
None
, this method is non-blocking and will returnNone
if there is no data available.
Returns: - the read message sent by
remote_xbee_device
orNone
if this XBee did not receive new data.
Return type: Raises: - ValueError – if a timeout is specified and is less than 0.
- TimeoutException – if a timeout is specified and no data was received during that time.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- XBeeException – if the XBee device’s serial port is closed.
See also
- remote_xbee_device (
-
read_device_info
(init=True)¶ Updates all instance parameters reading them from the XBee device.
Parameters: init (Boolean, optional, default=`True`) – If
False
only not initialized parameters are read, all ifTrue
.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
read_io_sample
()¶ Returns an IO sample from the XBee device containing the value of all enabled digital IO and analog input channels.
Returns: the IO sample read from the XBee device.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
See also
-
reset
()¶ Override method.
See also
-
send_bluetooth_data
(data)¶ Sends the given data to the Bluetooth interface using a User Data Relay frame.
Parameters: data (Bytearray) – Data to send.
Raises: - InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- XBeeException – if there is any problem sending the data.
-
send_data
(remote_xbee_device, data, transmit_options=0)¶ Blocking method. This method sends data to a remote XBee device synchronously.
This method will wait for the packet response.
The default timeout for this method is
XBeeDevice._DEFAULT_TIMEOUT_SYNC_OPERATIONS
.Parameters: - remote_xbee_device (
RemoteXBeeDevice
) – the remote XBee device to send data to. - data (String or Bytearray) – the raw data to send.
- transmit_options (Integer, optional) – transmit options, bitfield of
TransmitOptions
. Default toTransmitOptions.NONE.value
.
Returns: XBeePacket
the response.Raises: - ValueError – if
remote_xbee_device
isNone
. - TimeoutException – if this method can’t read a response packet in
XBeeDevice._DEFAULT_TIMEOUT_SYNC_OPERATIONS
seconds. - InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- TransmitException – if the status of the response received is not OK.
- XBeeException – if the XBee device’s serial port is closed.
See also
- remote_xbee_device (
-
send_data_async
(remote_xbee_device, data, transmit_options=0)¶ Non-blocking method. This method sends data to a remote XBee device.
This method won’t wait for the response.
Parameters: - remote_xbee_device (
RemoteXBeeDevice
) – the remote XBee device to send data to. - data (String or Bytearray) – the raw data to send.
- transmit_options (Integer, optional) – transmit options, bitfield of
TransmitOptions
. Default toTransmitOptions.NONE.value
.
Raises: - InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- XBeeException – if the XBee device’s serial port is closed.
See also
- remote_xbee_device (
-
send_data_broadcast
(data, transmit_options=0)¶ Sends the provided data to all the XBee nodes of the network (broadcast).
This method blocks till a success or error transmit status arrives or the configured receive timeout expires.
The received timeout is configured using the
AbstractXBeeDevice.set_sync_ops_timeout()
method and can be consulted withAbstractXBeeDevice.get_sync_ops_timeout()
method.Parameters: - data (String or Bytearray) – data to send.
- transmit_options (Integer, optional) – transmit options, bitfield of
TransmitOptions
. Default toTransmitOptions.NONE.value
.
Raises: - TimeoutException – if this method can’t read a response packet in
XBeeDevice._DEFAULT_TIMEOUT_SYNC_OPERATIONS
seconds. - InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- TransmitException – if the status of the response received is not OK.
- XBeeException – if the XBee device’s serial port is closed.
-
send_micropython_data
(data)¶ Sends the given data to the MicroPython interface using a User Data Relay frame.
Parameters: data (Bytearray) – Data to send.
Raises: - InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- XBeeException – if there is any problem sending the data.
-
send_packet
(packet, sync=False)¶ Override method.
See also
AbstractXBeeDevice._send_packet()
-
send_packet_sync_and_get_response
(packet_to_send, timeout=None)¶ Override method.
See also
AbstractXBeeDevice._send_packet_sync_and_get_response()
-
send_user_data_relay
(local_interface, data)¶ Sends the given data to the given XBee local interface.
Parameters: - local_interface (
XBeeLocalInterface
) – Destination XBee local interface. - data (Bytearray) – Data to send.
Raises: - InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ValueError – if
local_interface
isNone
. - XBeeException – if there is any problem sending the User Data Relay.
See also
- local_interface (
-
serial_port
¶ Returns the serial port associated to the XBee device, if any.
Returns: - the serial port associated to the XBee device. Returns
None
if the local XBee - does not use serial communication.
Return type: XBeeSerialPort
See also
- the serial port associated to the XBee device. Returns
-
set_16bit_addr
(value)¶ Sets the 16-bit address of the XBee device.
Parameters: value (
XBee16BitAddress
) – the new 16-bit address of the XBee device.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the current 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 device.
Parameters: api_output_mode (
APIOutputMode
) – the new API output mode of the XBee device.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the current protocol is ZigBee
See also
-
set_api_output_mode_value
(api_output_mode)¶ Sets the API output mode of the XBee.
Parameters: api_output_mode (Integer) – new API output mode options. Calculate this value using the method
digi.xbee.models.mode.APIOutputModeBit.calculate_api_output_mode_value()
with a set ofdigi.xbee.models.mode.APIOutputModeBit
.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if it is not supported by the current protocol.
-
set_dest_address
(addr)¶ Sets the 64-bit address of the XBee device that data will be reported to.
Parameters: addr (
XBee64BitAddress
orRemoteXBeeDevice
) – the address itself or the remote XBee device that you want to set up its address as destination address.Raises: - TimeoutException – If the response is not received before the read timeout expires.
- XBeeException – If the XBee device’s serial port is closed.
- InvalidOperatingModeException – If the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – If the response is not as expected.
- ValueError – If
addr
isNone
.
-
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 the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
See also
-
set_dio_value
(io_line, io_value)¶ Sets the digital value (high or low) to the provided IO line.
Parameters: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
set_io_configuration
(io_line, io_mode)¶ Sets the configuration of the provided IO line.
Parameters: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
set_io_sampling_rate
(rate)¶ Sets the IO sampling rate of the XBee device in seconds. A sample rate of 0 means the IO sampling feature is disabled.
Parameters: rate (Integer) – the new IO sampling rate of the XBee device in seconds.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
set_node_id
(node_id)¶ Sets the Node Identifier (
NI
) value of the XBee device..Parameters: node_id (String) – the new Node Identifier (
NI
) of the XBee device.Raises: - ValueError – if
node_id
isNone
or its length is greater than 20. - TimeoutException – if the response is not received before the read timeout expires.
- ValueError – if
-
set_pan_id
(value)¶ Sets the operating PAN ID of the XBee device.
Parameters: value (Bytearray) – the new operating PAN ID of the XBee device.. Must have only 1 or 2 bytes. Raises: TimeoutException – if the response is not received before the read timeout expires.
-
set_parameter
(param, value)¶ Override.
-
set_power_level
(power_level)¶ Sets the power level of the XBee device.
Parameters: power_level ( PowerLevel
) – the new power level of the XBee device.Raises: TimeoutException – if the response is not received before the read timeout expires. See also
-
set_pwm_duty_cycle
(io_line, cycle)¶ Sets the duty cycle in % of the provided IO line.
The provided IO line must be PWM-capable, previously configured as PWM output.
Parameters: - io_line (
IOLine
) – the IO Line to be assigned. - cycle (Integer) – duty cycle in % to be assigned. Must be between 0 and 100.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- ValueError – if the given IO line does not have PWM capability or
cycle
is not between 0 and 100.
See also
- io_line (
-
set_sync_ops_timeout
(sync_ops_timeout)¶ Sets the serial port read timeout.
Parameters: sync_ops_timeout (Integer) – the read timeout, expressed in seconds.
-
update_bluetooth_password
(new_password)¶ Changes the password of this Bluetooth device with the new one provided.
Note that your device must have Bluetooth Low Energy support to use this method.
Parameters: new_password (String) – New Bluetooth password.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
update_device_data_from
(device)¶ Updates the current device reference with the data provided for the given device.
This is only for internal use.
Parameters: device ( AbstractXBeeDevice
) – the XBee device to get the data from.Returns: True
if the device data has been updated,False
otherwise.Return type: Boolean
-
update_firmware
(xml_firmware_file, xbee_firmware_file=None, bootloader_firmware_file=None, timeout=None, progress_callback=None)¶ Performs a firmware update operation of the device.
Parameters: - xml_firmware_file (String) – path of the XML file that describes the firmware to upload.
- xbee_firmware_file (String, optional) – location of the XBee binary firmware file.
- bootloader_firmware_file (String, optional) – location of the bootloader binary firmware file.
- timeout (Integer, optional) – the maximum time to wait for target read operations during the update process.
- progress_callback (Function, optional) –
- function to execute to receive progress information. Receives two
- arguments:
- The current update task as a String
- The current update task percentage as an Integer
Raises: - XBeeException – if the device is not open.
- InvalidOperatingModeException – if the device operating mode is invalid.
- OperationNotSupportedException – if the firmware update is not supported in the XBee device.
- FirmwareUpdateException – if there is any error performing the firmware update.
-
write_changes
()¶ Writes configurable parameter values to the non-volatile memory of the XBee device so that parameter modifications persist through subsequent resets.
Parameters values remain in this device’s memory until overwritten by subsequent use of this method.
If changes are made without writing them to non-volatile memory, the module reverts back to previously saved parameters the next time the module is powered-on.
Writing the parameter modifications does not mean those values are immediately applied, this depends on the status of the ‘apply configuration changes’ option. Use method
is_apply_configuration_changes_enabled()
to get its status andenable_apply_configuration_changes()
to enable/disable the option. If it is disabled, methodapply_changes()
can be used in order to manually apply the changes.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
class
digi.xbee.devices.
DigiMeshDevice
(port=None, baud_rate=None, data_bits=<sphinx.ext.autodoc.importer._MockObject object>, stop_bits=<sphinx.ext.autodoc.importer._MockObject object>, parity=<sphinx.ext.autodoc.importer._MockObject object>, flow_control=<FlowControl.NONE: None>, _sync_ops_timeout=4, comm_iface=None)[source]¶ Bases:
digi.xbee.devices.XBeeDevice
This class represents a local DigiMesh XBee device.
Class constructor. Instantiates a new
DigiMeshDevice
with the provided parameters.Parameters: - port (Integer or String) – serial port identifier. Integer: number of XBee device, numbering starts at zero. Device name: depending on operating system. e.g. ‘/dev/ttyUSB0’ on ‘GNU/Linux’ or ‘COM3’ on Windows.
- baud_rate (Integer) – the serial port baud rate.
- (Integer, default (flow_control) –
serial.EIGHTBITS
): comm port bitsize. - (Integer, default –
serial.STOPBITS_ONE
): comm port stop bits. - (Character, default (parity) –
serial.PARITY_NONE
): comm port parity. - (Integer, default –
FlowControl.NONE
): comm port flow control.- _sync_ops_timeout (Integer, default: 3): the read timeout (in seconds).
- comm_iface (
XBeeCommunicationInterface
): the communication interface.
:raises All exceptions raised by
XBeeDevice.__init__()
constructor.:See also
XBeeDevice.__init__()
-
open
(force_settings=False)[source]¶ Override.
Raises: - TimeoutException – If there is any problem with the communication.
- InvalidOperatingModeException – If the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- XBeeException – If the protocol is invalid or if the XBee device is already open.
See also
-
send_data_64
(x64addr, data, transmit_options=0)[source]¶ Override.
See also
XBeeDevice.send_data_64()
-
send_data_async_64
(x64addr, data, transmit_options=0)[source]¶ Override.
See also
XBeeDevice.send_data_async_64()
-
read_expl_data_from
(remote_xbee_device, timeout=None)[source]¶ Override.
See also
XBeeDevice.read_expl_data_from()
-
send_expl_data
(remote_xbee_device, data, src_endpoint, dest_endpoint, cluster_id, profile_id, transmit_options=0)[source]¶ Override.
See also
XBeeDevice.send_expl_data()
-
send_expl_data_broadcast
(data, src_endpoint, dest_endpoint, cluster_id, profile_id, transmit_options=0)[source]¶ Override.
See also
XBeeDevice._send_expl_data_broadcast()
-
send_expl_data_async
(remote_xbee_device, data, src_endpoint, dest_endpoint, cluster_id, profile_id, transmit_options=0)[source]¶ Override.
See also
XBeeDevice.send_expl_data_async()
-
add_bluetooth_data_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.BluetoothDataReceived
.Parameters: callback (Function) – the callback. Receives one argument.
- The Bluetooth data as a Bytearray
-
add_data_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.DataReceived
.Parameters: callback (Function) – the callback. Receives one argument.
- The data received as an
digi.xbee.models.message.XBeeMessage
- The data received as an
-
add_expl_data_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.ExplicitDataReceived
.Parameters: callback (Function) – the callback. Receives one argument.
- The explicit data received as a
digi.xbee.models.message.ExplicitXBeeMessage
.
- The explicit data received as a
-
add_io_sample_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.IOSampleReceived
.Parameters: callback (Function) – the callback. Receives three arguments.
- The received IO sample as an
digi.xbee.io.IOSample
- The remote XBee device who has sent the packet as a
RemoteXBeeDevice
- The time in which the packet was received as an Integer
- The received IO sample as an
-
add_micropython_data_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.MicroPythonDataReceived
.Parameters: callback (Function) – the callback. Receives one argument.
- The MicroPython data as a Bytearray
-
add_modem_status_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.ModemStatusReceived
.Parameters: callback (Function) – the callback. Receives one argument.
- The modem status as a
digi.xbee.models.status.ModemStatus
- The modem status as a
-
add_packet_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.PacketReceived
.Parameters: callback (Function) – the callback. Receives two arguments.
- The received packet as a
digi.xbee.packets.base.XBeeAPIPacket
- The received packet as a
-
add_socket_data_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.SocketDataReceived
.Parameters: callback (Function) – the callback. Receives two arguments.
- The socket ID as an Integer.
- The data received as Bytearray
-
add_socket_data_received_from_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.SocketDataReceivedFrom
.Parameters: callback (Function) – the callback. Receives three arguments.
- The socket ID as an Integer.
- A pair (host, port) of the source address where host is a string
- representing an IPv4 address like ‘100.50.200.5’, and port is an integer.
- The data received as Bytearray
-
add_socket_state_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.SocketStateReceived
.Parameters: callback (Function) – the callback. Receives two arguments.
- The socket ID as an Integer.
- The state received as a
SocketState
-
add_user_data_relay_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.RelayDataReceived
.Parameters: callback (Function) – the callback. Receives one argument.
- The relay data as a
digi.xbee.models.message.UserDataRelayMessage
- The relay data as a
-
apply_changes
()¶ Applies changes via
AC
command.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
apply_profile
(profile_path, progress_callback=None)¶ Applies the given XBee profile to the XBee device.
Parameters: - profile_path (String) – path of the XBee profile file to apply.
- progress_callback (Function, optional) –
- function to execute to receive progress information. Receives two
- arguments:
- The current apply profile task as a String
- The current apply profile task percentage as an Integer
Raises: - XBeeException – if the device is not open.
- InvalidOperatingModeException – if the device operating mode is invalid.
- UpdateProfileException – if there is any error applying the XBee profile.
- OperationNotSupportedException – if XBee profiles are not supported in the XBee device.
-
close
()¶ Closes the communication with the XBee device.
This method guarantees that all threads running are stopped and the serial port is closed.
-
comm_iface
¶ Returns the hardware interface associated to the XBee device.
Returns: the hardware interface associated to the XBee device. Return type: XBeeCommunicationInterface
See also
-
classmethod
create_xbee_device
(comm_port_data)¶ Creates and returns an
XBeeDevice
from data of the port to which is connected.Parameters: - comm_port_data (Dictionary) – dictionary with all comm port data needed.
- dictionary keys are (The) – “baudRate” –> Baud rate.”port” –> Port number.”bitSize” –> Bit size.”stopBits” –> Stop bits.”parity” –> Parity.”flowControl” –> Flow control.”timeout” for –> Timeout for synchronous operations (in seconds).
Returns: the XBee device created.
Return type: Raises: SerialException – if the port you want to open does not exist or is already opened.
See also
-
del_bluetooth_data_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.BluetoothDataReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.BluetoothDataReceived
event.
-
del_data_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.DataReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.DataReceived
event.
-
del_expl_data_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.ExplicitDataReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.ExplicitDataReceived
event.
-
del_io_sample_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.IOSampleReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.IOSampleReceived
event.
-
del_micropython_data_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.MicroPythonDataReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.MicroPythonDataReceived
event.
-
del_modem_status_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.ModemStatusReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.ModemStatusReceived
event.
-
del_packet_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.PacketReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.PacketReceived
event.
-
del_socket_data_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.SocketDataReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.SocketDataReceived
event.
-
del_socket_data_received_from_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.SocketDataReceivedFrom
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.SocketDataReceivedFrom
event.
-
del_socket_state_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.SocketStateReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.SocketStateReceived
event.
-
del_user_data_relay_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.RelayDataReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.RelayDataReceived
event.
-
disable_bluetooth
()¶ Disables the Bluetooth interface of this XBee device.
Note that your device must have Bluetooth Low Energy support to use this method.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
enable_apply_changes
(value)¶ Sets the apply_changes flag.
Parameters: value (Boolean) – True
to enable the apply changes flag,False
to disable it.
-
enable_bluetooth
()¶ Enables the Bluetooth interface of this XBee device.
To work with this interface, you must also configure the Bluetooth password if not done previously. You can use the
AbstractXBeeDevice.update_bluetooth_password()
method for that purpose.Note that your device must have Bluetooth Low Energy support to use this method.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
execute_command
(parameter)¶ Executes the provided command.
Parameters: parameter (String) – The name of the AT command to be executed.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
flush_queues
()¶ Flushes the packets queue.
-
get_16bit_addr
()¶ Returns the 16-bit address of the XBee device.
Returns: the 16-bit address of the XBee device. Return type: XBee16BitAddress
See also
-
get_64bit_addr
()¶ Returns the 64-bit address of the XBee device.
Returns: the 64-bit address of the XBee device. Return type: XBee64BitAddress
See also
-
get_adc_value
(io_line)¶ Returns the analog value of the provided IO line.
The provided IO line must be previously configured as ADC. To do so, use
AbstractXBeeDevice.set_io_configuration()
andIOMode.ADC
.Parameters: io_line (
IOLine
) – the IO line to get its ADC value.Returns: the analog value corresponding to the provided IO line.
Return type: Integer
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the response does not contain the value for the given IO line.
See also
-
get_api_output_mode
()¶ Deprecated since version 1.3: Use
get_api_output_mode_value()
Returns the API output mode of the XBee device.
The API output mode determines the format that the received data is output through the serial interface of the XBee device.
Returns: the API output mode of the XBee device.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
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 the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- 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 device in a format such as
00112233AABB
.Note that your device must have Bluetooth Low Energy support to use this method.
Returns: The Bluetooth MAC address.
Return type: String
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
get_current_frame_id
()¶ Returns the last used frame ID.
Returns: the last used frame ID. Return type: Integer
-
get_dest_address
()¶ Returns the 64-bit address of the XBee device that data will be reported to.
Returns: the address. Return type: XBee64BitAddress
Raises: TimeoutException – if the response is not received before the read timeout expires. See also
-
get_dio_value
(io_line)¶ Returns the digital value of the provided IO line.
The provided IO line must be previously configured as digital I/O. To do so, use
AbstractXBeeDevice.set_io_configuration()
.Parameters: io_line (
IOLine
) – the DIO line to gets its digital value.Returns: current value of the provided IO line.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the response does not contain the value for the given IO line.
-
get_firmware_version
()¶ Returns the firmware version of the XBee device.
Returns: the hardware version of the XBee device. Return type: Bytearray
-
get_hardware_version
()¶ Returns the hardware version of the XBee device.
Returns: the hardware version of the XBee device. Return type: HardwareVersion
See also
-
get_io_configuration
(io_line)¶ Returns the configuration of the provided IO line.
Parameters: io_line (
IOLine
) – the io line to configure.Returns: the IO mode of the IO line provided.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the received data is not an IO mode.
-
get_io_sampling_rate
()¶ Returns the IO sampling rate of the XBee device.
Returns: the IO sampling rate of XBee device.
Return type: Integer
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
get_network
()¶ Returns this XBee device’s current network.
Returns: XBeeDevice.XBeeNetwork
-
get_next_frame_id
()¶ Returns the next frame ID of the XBee device.
Returns: The next frame ID of the XBee device. Return type: Integer
-
get_node_id
()¶ Returns the Node Identifier (
NI
) value of the XBee device.Returns: the Node Identifier ( NI
) of the XBee device.Return type: String
-
get_pan_id
()¶ Returns the operating PAN ID of the XBee device.
Returns: operating PAN ID of the XBee device. Return type: Bytearray Raises: TimeoutException – if the response is not received before the read timeout expires.
-
get_parameter
(param, parameter_value=None)¶ Override.
See also
-
get_power_level
()¶ Returns the power level of the XBee device.
Returns: the power level of the XBee device. Return type: PowerLevel
Raises: TimeoutException – if the response is not received before the read timeout expires. See also
-
get_pwm_duty_cycle
(io_line)¶ Returns the PWM duty cycle in % corresponding to the provided IO line.
Parameters: io_line (
IOLine
) – the IO line to get its PWM duty cycle.Returns: the PWM duty cycle of the given IO line or
None
if the response is empty.Return type: Integer
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- ValueError – if the passed
IO_LINE
has no PWM capability.
See also
-
get_role
()¶ Gets the XBee role.
Returns: the role of the XBee. Return type: digi.xbee.models.protocol.Role
See also
-
get_sync_ops_timeout
()¶ Returns the serial port read timeout.
Returns: the serial port read timeout in seconds. Return type: Integer
-
get_xbee_device_callbacks
()¶ Returns this XBee internal callbacks for process received packets.
This method is called by the PacketListener associated with this XBee to get its callbacks. These callbacks will be executed before user callbacks.
Returns: PacketReceived
-
has_explicit_packets
()¶ Returns whether the XBee device’s queue has explicit packets or not. This do not include non-explicit packets.
Returns: True
if this XBee device’s queue has explicit packets,False
otherwise.Return type: Boolean See also
-
has_packets
()¶ Returns whether the XBee device’s queue has packets or not. This do not include explicit packets.
Returns: True
if this XBee device’s queue has packets,False
otherwise.Return type: Boolean See also
-
is_apply_changes_enabled
()¶ Returns whether the apply_changes flag is enabled or not.
Returns: True
if the apply_changes flag is enabled,False
otherwise.Return type: Boolean
-
is_open
()¶ Returns whether this XBee device is open or not.
Returns: Boolean. True
if this XBee device is open,False
otherwise.
-
is_remote
()¶ Override method.
See also
-
log
¶ Returns the XBee device log.
Returns: the XBee device logger. Return type: Logger
-
operating_mode
¶ Returns this XBee device’s operating mode.
Returns: OperatingMode
. This XBee device’s operating mode.
-
read_data
(timeout=None)¶ Reads new data received by this XBee device.
If a
timeout
is specified, this method blocks until new data is received or the timeout expires, throwing in that case aTimeoutException
.Parameters: timeout (Integer, optional) – read timeout in seconds. If it’s
None
, this method is non-blocking and will returnNone
if there is no data available.Returns: the read message or
None
if this XBee did not receive new data.Return type: Raises: - ValueError – if a timeout is specified and is less than 0.
- TimeoutException – if a timeout is specified and no data was received during that time.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- XBeeException – if the XBee device’s serial port is closed.
See also
-
read_data_from
(remote_xbee_device, timeout=None)¶ Reads new data received from the given remote XBee device.
If a
timeout
is specified, this method blocks until new data is received or the timeout expires, throwing in that case aTimeoutException
.Parameters: - remote_xbee_device (
RemoteXBeeDevice
) – the remote XBee device that sent the data. - timeout (Integer, optional) – read timeout in seconds. If it’s
None
, this method is non-blocking and will returnNone
if there is no data available.
Returns: - the read message sent by
remote_xbee_device
orNone
if this XBee did not receive new data.
Return type: Raises: - ValueError – if a timeout is specified and is less than 0.
- TimeoutException – if a timeout is specified and no data was received during that time.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- XBeeException – if the XBee device’s serial port is closed.
See also
- remote_xbee_device (
-
read_device_info
(init=True)¶ Updates all instance parameters reading them from the XBee device.
Parameters: init (Boolean, optional, default=`True`) – If
False
only not initialized parameters are read, all ifTrue
.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
read_io_sample
()¶ Returns an IO sample from the XBee device containing the value of all enabled digital IO and analog input channels.
Returns: the IO sample read from the XBee device.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
See also
-
reset
()¶ Override method.
See also
-
send_bluetooth_data
(data)¶ Sends the given data to the Bluetooth interface using a User Data Relay frame.
Parameters: data (Bytearray) – Data to send.
Raises: - InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- XBeeException – if there is any problem sending the data.
-
send_data
(remote_xbee_device, data, transmit_options=0)¶ Blocking method. This method sends data to a remote XBee device synchronously.
This method will wait for the packet response.
The default timeout for this method is
XBeeDevice._DEFAULT_TIMEOUT_SYNC_OPERATIONS
.Parameters: - remote_xbee_device (
RemoteXBeeDevice
) – the remote XBee device to send data to. - data (String or Bytearray) – the raw data to send.
- transmit_options (Integer, optional) – transmit options, bitfield of
TransmitOptions
. Default toTransmitOptions.NONE.value
.
Returns: XBeePacket
the response.Raises: - ValueError – if
remote_xbee_device
isNone
. - TimeoutException – if this method can’t read a response packet in
XBeeDevice._DEFAULT_TIMEOUT_SYNC_OPERATIONS
seconds. - InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- TransmitException – if the status of the response received is not OK.
- XBeeException – if the XBee device’s serial port is closed.
See also
- remote_xbee_device (
-
send_data_async
(remote_xbee_device, data, transmit_options=0)¶ Non-blocking method. This method sends data to a remote XBee device.
This method won’t wait for the response.
Parameters: - remote_xbee_device (
RemoteXBeeDevice
) – the remote XBee device to send data to. - data (String or Bytearray) – the raw data to send.
- transmit_options (Integer, optional) – transmit options, bitfield of
TransmitOptions
. Default toTransmitOptions.NONE.value
.
Raises: - InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- XBeeException – if the XBee device’s serial port is closed.
See also
- remote_xbee_device (
-
send_data_broadcast
(data, transmit_options=0)¶ Sends the provided data to all the XBee nodes of the network (broadcast).
This method blocks till a success or error transmit status arrives or the configured receive timeout expires.
The received timeout is configured using the
AbstractXBeeDevice.set_sync_ops_timeout()
method and can be consulted withAbstractXBeeDevice.get_sync_ops_timeout()
method.Parameters: - data (String or Bytearray) – data to send.
- transmit_options (Integer, optional) – transmit options, bitfield of
TransmitOptions
. Default toTransmitOptions.NONE.value
.
Raises: - TimeoutException – if this method can’t read a response packet in
XBeeDevice._DEFAULT_TIMEOUT_SYNC_OPERATIONS
seconds. - InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- TransmitException – if the status of the response received is not OK.
- XBeeException – if the XBee device’s serial port is closed.
-
send_micropython_data
(data)¶ Sends the given data to the MicroPython interface using a User Data Relay frame.
Parameters: data (Bytearray) – Data to send.
Raises: - InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- XBeeException – if there is any problem sending the data.
-
send_packet
(packet, sync=False)¶ Override method.
See also
AbstractXBeeDevice._send_packet()
-
send_packet_sync_and_get_response
(packet_to_send, timeout=None)¶ Override method.
See also
AbstractXBeeDevice._send_packet_sync_and_get_response()
-
send_user_data_relay
(local_interface, data)¶ Sends the given data to the given XBee local interface.
Parameters: - local_interface (
XBeeLocalInterface
) – Destination XBee local interface. - data (Bytearray) – Data to send.
Raises: - InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ValueError – if
local_interface
isNone
. - XBeeException – if there is any problem sending the User Data Relay.
See also
- local_interface (
-
serial_port
¶ Returns the serial port associated to the XBee device, if any.
Returns: - the serial port associated to the XBee device. Returns
None
if the local XBee - does not use serial communication.
Return type: XBeeSerialPort
See also
- the serial port associated to the XBee device. Returns
-
set_16bit_addr
(value)¶ Sets the 16-bit address of the XBee device.
Parameters: value (
XBee16BitAddress
) – the new 16-bit address of the XBee device.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the current 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 device.
Parameters: api_output_mode (
APIOutputMode
) – the new API output mode of the XBee device.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the current protocol is ZigBee
See also
-
set_api_output_mode_value
(api_output_mode)¶ Sets the API output mode of the XBee.
Parameters: api_output_mode (Integer) – new API output mode options. Calculate this value using the method
digi.xbee.models.mode.APIOutputModeBit.calculate_api_output_mode_value()
with a set ofdigi.xbee.models.mode.APIOutputModeBit
.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if it is not supported by the current protocol.
-
set_dest_address
(addr)¶ Sets the 64-bit address of the XBee device that data will be reported to.
Parameters: addr (
XBee64BitAddress
orRemoteXBeeDevice
) – the address itself or the remote XBee device that you want to set up its address as destination address.Raises: - TimeoutException – If the response is not received before the read timeout expires.
- XBeeException – If the XBee device’s serial port is closed.
- InvalidOperatingModeException – If the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – If the response is not as expected.
- ValueError – If
addr
isNone
.
-
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 the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
See also
-
set_dio_value
(io_line, io_value)¶ Sets the digital value (high or low) to the provided IO line.
Parameters: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
set_io_configuration
(io_line, io_mode)¶ Sets the configuration of the provided IO line.
Parameters: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
set_io_sampling_rate
(rate)¶ Sets the IO sampling rate of the XBee device in seconds. A sample rate of 0 means the IO sampling feature is disabled.
Parameters: rate (Integer) – the new IO sampling rate of the XBee device in seconds.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
set_node_id
(node_id)¶ Sets the Node Identifier (
NI
) value of the XBee device..Parameters: node_id (String) – the new Node Identifier (
NI
) of the XBee device.Raises: - ValueError – if
node_id
isNone
or its length is greater than 20. - TimeoutException – if the response is not received before the read timeout expires.
- ValueError – if
-
set_pan_id
(value)¶ Sets the operating PAN ID of the XBee device.
Parameters: value (Bytearray) – the new operating PAN ID of the XBee device.. Must have only 1 or 2 bytes. Raises: TimeoutException – if the response is not received before the read timeout expires.
-
set_parameter
(param, value)¶ Override.
-
set_power_level
(power_level)¶ Sets the power level of the XBee device.
Parameters: power_level ( PowerLevel
) – the new power level of the XBee device.Raises: TimeoutException – if the response is not received before the read timeout expires. See also
-
set_pwm_duty_cycle
(io_line, cycle)¶ Sets the duty cycle in % of the provided IO line.
The provided IO line must be PWM-capable, previously configured as PWM output.
Parameters: - io_line (
IOLine
) – the IO Line to be assigned. - cycle (Integer) – duty cycle in % to be assigned. Must be between 0 and 100.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- ValueError – if the given IO line does not have PWM capability or
cycle
is not between 0 and 100.
See also
- io_line (
-
set_sync_ops_timeout
(sync_ops_timeout)¶ Sets the serial port read timeout.
Parameters: sync_ops_timeout (Integer) – the read timeout, expressed in seconds.
-
update_bluetooth_password
(new_password)¶ Changes the password of this Bluetooth device with the new one provided.
Note that your device must have Bluetooth Low Energy support to use this method.
Parameters: new_password (String) – New Bluetooth password.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
update_device_data_from
(device)¶ Updates the current device reference with the data provided for the given device.
This is only for internal use.
Parameters: device ( AbstractXBeeDevice
) – the XBee device to get the data from.Returns: True
if the device data has been updated,False
otherwise.Return type: Boolean
-
update_firmware
(xml_firmware_file, xbee_firmware_file=None, bootloader_firmware_file=None, timeout=None, progress_callback=None)¶ Performs a firmware update operation of the device.
Parameters: - xml_firmware_file (String) – path of the XML file that describes the firmware to upload.
- xbee_firmware_file (String, optional) – location of the XBee binary firmware file.
- bootloader_firmware_file (String, optional) – location of the bootloader binary firmware file.
- timeout (Integer, optional) – the maximum time to wait for target read operations during the update process.
- progress_callback (Function, optional) –
- function to execute to receive progress information. Receives two
- arguments:
- The current update task as a String
- The current update task percentage as an Integer
Raises: - XBeeException – if the device is not open.
- InvalidOperatingModeException – if the device operating mode is invalid.
- OperationNotSupportedException – if the firmware update is not supported in the XBee device.
- FirmwareUpdateException – if there is any error performing the firmware update.
-
write_changes
()¶ Writes configurable parameter values to the non-volatile memory of the XBee device so that parameter modifications persist through subsequent resets.
Parameters values remain in this device’s memory until overwritten by subsequent use of this method.
If changes are made without writing them to non-volatile memory, the module reverts back to previously saved parameters the next time the module is powered-on.
Writing the parameter modifications does not mean those values are immediately applied, this depends on the status of the ‘apply configuration changes’ option. Use method
is_apply_configuration_changes_enabled()
to get its status andenable_apply_configuration_changes()
to enable/disable the option. If it is disabled, methodapply_changes()
can be used in order to manually apply the changes.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
class
digi.xbee.devices.
DigiPointDevice
(port=None, baud_rate=None, data_bits=<sphinx.ext.autodoc.importer._MockObject object>, stop_bits=<sphinx.ext.autodoc.importer._MockObject object>, parity=<sphinx.ext.autodoc.importer._MockObject object>, flow_control=<FlowControl.NONE: None>, _sync_ops_timeout=4, comm_iface=None)[source]¶ Bases:
digi.xbee.devices.XBeeDevice
This class represents a local DigiPoint XBee device.
Class constructor. Instantiates a new
DigiPointDevice
with the provided parameters.Parameters: - port (Integer or String) – serial port identifier. Integer: number of XBee device, numbering starts at zero. Device name: depending on operating system. e.g. ‘/dev/ttyUSB0’ on ‘GNU/Linux’ or ‘COM3’ on Windows.
- baud_rate (Integer) – the serial port baud rate.
- (Integer, default (_sync_ops_timeout) –
serial.EIGHTBITS
): comm port bitsize. - (Integer, default –
serial.STOPBITS_ONE
): comm port stop bits. - (Character, default (parity) –
serial.PARITY_NONE
): comm port parity. - (Integer, default –
FlowControl.NONE
): comm port flow control. - (Integer, default – 3): the read timeout (in seconds).
- comm_iface (
XBeeCommunicationInterface
) – the communication interface.
:raises All exceptions raised by
XBeeDevice.__init__()
constructor.:See also
XBeeDevice.__init__()
-
open
(force_settings=False)[source]¶ Override.
Raises: - TimeoutException – If there is any problem with the communication.
- InvalidOperatingModeException – If the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- XBeeException – If the protocol is invalid or if the XBee device is already open.
See also
-
send_data_64_16
(x64addr, x16addr, data, transmit_options=0)[source]¶ Override.
See also
XBeeDevice.send_data_64_16()
-
send_data_async_64_16
(x64addr, x16addr, data, transmit_options=0)[source]¶ Override.
See also
XBeeDevice.send_data_async_64_16()
-
read_expl_data_from
(remote_xbee_device, timeout=None)[source]¶ Override.
See also
XBeeDevice.read_expl_data_from()
-
send_expl_data
(remote_xbee_device, data, src_endpoint, dest_endpoint, cluster_id, profile_id, transmit_options=0)[source]¶ Override.
See also
XBeeDevice.send_expl_data()
-
send_expl_data_broadcast
(data, src_endpoint, dest_endpoint, cluster_id, profile_id, transmit_options=0)[source]¶ Override.
See also
XBeeDevice._send_expl_data_broadcast()
-
send_expl_data_async
(remote_xbee_device, data, src_endpoint, dest_endpoint, cluster_id, profile_id, transmit_options=0)[source]¶ Override.
See also
XBeeDevice.send_expl_data_async()
-
add_bluetooth_data_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.BluetoothDataReceived
.Parameters: callback (Function) – the callback. Receives one argument.
- The Bluetooth data as a Bytearray
-
add_data_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.DataReceived
.Parameters: callback (Function) – the callback. Receives one argument.
- The data received as an
digi.xbee.models.message.XBeeMessage
- The data received as an
-
add_expl_data_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.ExplicitDataReceived
.Parameters: callback (Function) – the callback. Receives one argument.
- The explicit data received as a
digi.xbee.models.message.ExplicitXBeeMessage
.
- The explicit data received as a
-
add_io_sample_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.IOSampleReceived
.Parameters: callback (Function) – the callback. Receives three arguments.
- The received IO sample as an
digi.xbee.io.IOSample
- The remote XBee device who has sent the packet as a
RemoteXBeeDevice
- The time in which the packet was received as an Integer
- The received IO sample as an
-
add_micropython_data_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.MicroPythonDataReceived
.Parameters: callback (Function) – the callback. Receives one argument.
- The MicroPython data as a Bytearray
-
add_modem_status_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.ModemStatusReceived
.Parameters: callback (Function) – the callback. Receives one argument.
- The modem status as a
digi.xbee.models.status.ModemStatus
- The modem status as a
-
add_packet_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.PacketReceived
.Parameters: callback (Function) – the callback. Receives two arguments.
- The received packet as a
digi.xbee.packets.base.XBeeAPIPacket
- The received packet as a
-
add_socket_data_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.SocketDataReceived
.Parameters: callback (Function) – the callback. Receives two arguments.
- The socket ID as an Integer.
- The data received as Bytearray
-
add_socket_data_received_from_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.SocketDataReceivedFrom
.Parameters: callback (Function) – the callback. Receives three arguments.
- The socket ID as an Integer.
- A pair (host, port) of the source address where host is a string
- representing an IPv4 address like ‘100.50.200.5’, and port is an integer.
- The data received as Bytearray
-
add_socket_state_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.SocketStateReceived
.Parameters: callback (Function) – the callback. Receives two arguments.
- The socket ID as an Integer.
- The state received as a
SocketState
-
add_user_data_relay_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.RelayDataReceived
.Parameters: callback (Function) – the callback. Receives one argument.
- The relay data as a
digi.xbee.models.message.UserDataRelayMessage
- The relay data as a
-
apply_changes
()¶ Applies changes via
AC
command.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
apply_profile
(profile_path, progress_callback=None)¶ Applies the given XBee profile to the XBee device.
Parameters: - profile_path (String) – path of the XBee profile file to apply.
- progress_callback (Function, optional) –
- function to execute to receive progress information. Receives two
- arguments:
- The current apply profile task as a String
- The current apply profile task percentage as an Integer
Raises: - XBeeException – if the device is not open.
- InvalidOperatingModeException – if the device operating mode is invalid.
- UpdateProfileException – if there is any error applying the XBee profile.
- OperationNotSupportedException – if XBee profiles are not supported in the XBee device.
-
close
()¶ Closes the communication with the XBee device.
This method guarantees that all threads running are stopped and the serial port is closed.
-
comm_iface
¶ Returns the hardware interface associated to the XBee device.
Returns: the hardware interface associated to the XBee device. Return type: XBeeCommunicationInterface
See also
-
classmethod
create_xbee_device
(comm_port_data)¶ Creates and returns an
XBeeDevice
from data of the port to which is connected.Parameters: - comm_port_data (Dictionary) – dictionary with all comm port data needed.
- dictionary keys are (The) – “baudRate” –> Baud rate.”port” –> Port number.”bitSize” –> Bit size.”stopBits” –> Stop bits.”parity” –> Parity.”flowControl” –> Flow control.”timeout” for –> Timeout for synchronous operations (in seconds).
Returns: the XBee device created.
Return type: Raises: SerialException – if the port you want to open does not exist or is already opened.
See also
-
del_bluetooth_data_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.BluetoothDataReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.BluetoothDataReceived
event.
-
del_data_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.DataReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.DataReceived
event.
-
del_expl_data_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.ExplicitDataReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.ExplicitDataReceived
event.
-
del_io_sample_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.IOSampleReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.IOSampleReceived
event.
-
del_micropython_data_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.MicroPythonDataReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.MicroPythonDataReceived
event.
-
del_modem_status_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.ModemStatusReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.ModemStatusReceived
event.
-
del_packet_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.PacketReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.PacketReceived
event.
-
del_socket_data_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.SocketDataReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.SocketDataReceived
event.
-
del_socket_data_received_from_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.SocketDataReceivedFrom
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.SocketDataReceivedFrom
event.
-
del_socket_state_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.SocketStateReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.SocketStateReceived
event.
-
del_user_data_relay_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.RelayDataReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.RelayDataReceived
event.
-
disable_bluetooth
()¶ Disables the Bluetooth interface of this XBee device.
Note that your device must have Bluetooth Low Energy support to use this method.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
enable_apply_changes
(value)¶ Sets the apply_changes flag.
Parameters: value (Boolean) – True
to enable the apply changes flag,False
to disable it.
-
enable_bluetooth
()¶ Enables the Bluetooth interface of this XBee device.
To work with this interface, you must also configure the Bluetooth password if not done previously. You can use the
AbstractXBeeDevice.update_bluetooth_password()
method for that purpose.Note that your device must have Bluetooth Low Energy support to use this method.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
execute_command
(parameter)¶ Executes the provided command.
Parameters: parameter (String) – The name of the AT command to be executed.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
flush_queues
()¶ Flushes the packets queue.
-
get_16bit_addr
()¶ Returns the 16-bit address of the XBee device.
Returns: the 16-bit address of the XBee device. Return type: XBee16BitAddress
See also
-
get_64bit_addr
()¶ Returns the 64-bit address of the XBee device.
Returns: the 64-bit address of the XBee device. Return type: XBee64BitAddress
See also
-
get_adc_value
(io_line)¶ Returns the analog value of the provided IO line.
The provided IO line must be previously configured as ADC. To do so, use
AbstractXBeeDevice.set_io_configuration()
andIOMode.ADC
.Parameters: io_line (
IOLine
) – the IO line to get its ADC value.Returns: the analog value corresponding to the provided IO line.
Return type: Integer
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the response does not contain the value for the given IO line.
See also
-
get_api_output_mode
()¶ Deprecated since version 1.3: Use
get_api_output_mode_value()
Returns the API output mode of the XBee device.
The API output mode determines the format that the received data is output through the serial interface of the XBee device.
Returns: the API output mode of the XBee device.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
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 the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- 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 device in a format such as
00112233AABB
.Note that your device must have Bluetooth Low Energy support to use this method.
Returns: The Bluetooth MAC address.
Return type: String
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
get_current_frame_id
()¶ Returns the last used frame ID.
Returns: the last used frame ID. Return type: Integer
-
get_dest_address
()¶ Returns the 64-bit address of the XBee device that data will be reported to.
Returns: the address. Return type: XBee64BitAddress
Raises: TimeoutException – if the response is not received before the read timeout expires. See also
-
get_dio_value
(io_line)¶ Returns the digital value of the provided IO line.
The provided IO line must be previously configured as digital I/O. To do so, use
AbstractXBeeDevice.set_io_configuration()
.Parameters: io_line (
IOLine
) – the DIO line to gets its digital value.Returns: current value of the provided IO line.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the response does not contain the value for the given IO line.
-
get_firmware_version
()¶ Returns the firmware version of the XBee device.
Returns: the hardware version of the XBee device. Return type: Bytearray
-
get_hardware_version
()¶ Returns the hardware version of the XBee device.
Returns: the hardware version of the XBee device. Return type: HardwareVersion
See also
-
get_io_configuration
(io_line)¶ Returns the configuration of the provided IO line.
Parameters: io_line (
IOLine
) – the io line to configure.Returns: the IO mode of the IO line provided.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the received data is not an IO mode.
-
get_io_sampling_rate
()¶ Returns the IO sampling rate of the XBee device.
Returns: the IO sampling rate of XBee device.
Return type: Integer
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
get_network
()¶ Returns this XBee device’s current network.
Returns: XBeeDevice.XBeeNetwork
-
get_next_frame_id
()¶ Returns the next frame ID of the XBee device.
Returns: The next frame ID of the XBee device. Return type: Integer
-
get_node_id
()¶ Returns the Node Identifier (
NI
) value of the XBee device.Returns: the Node Identifier ( NI
) of the XBee device.Return type: String
-
get_pan_id
()¶ Returns the operating PAN ID of the XBee device.
Returns: operating PAN ID of the XBee device. Return type: Bytearray Raises: TimeoutException – if the response is not received before the read timeout expires.
-
get_parameter
(param, parameter_value=None)¶ Override.
See also
-
get_power_level
()¶ Returns the power level of the XBee device.
Returns: the power level of the XBee device. Return type: PowerLevel
Raises: TimeoutException – if the response is not received before the read timeout expires. See also
-
get_pwm_duty_cycle
(io_line)¶ Returns the PWM duty cycle in % corresponding to the provided IO line.
Parameters: io_line (
IOLine
) – the IO line to get its PWM duty cycle.Returns: the PWM duty cycle of the given IO line or
None
if the response is empty.Return type: Integer
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- ValueError – if the passed
IO_LINE
has no PWM capability.
See also
-
get_role
()¶ Gets the XBee role.
Returns: the role of the XBee. Return type: digi.xbee.models.protocol.Role
See also
-
get_sync_ops_timeout
()¶ Returns the serial port read timeout.
Returns: the serial port read timeout in seconds. Return type: Integer
-
get_xbee_device_callbacks
()¶ Returns this XBee internal callbacks for process received packets.
This method is called by the PacketListener associated with this XBee to get its callbacks. These callbacks will be executed before user callbacks.
Returns: PacketReceived
-
has_explicit_packets
()¶ Returns whether the XBee device’s queue has explicit packets or not. This do not include non-explicit packets.
Returns: True
if this XBee device’s queue has explicit packets,False
otherwise.Return type: Boolean See also
-
has_packets
()¶ Returns whether the XBee device’s queue has packets or not. This do not include explicit packets.
Returns: True
if this XBee device’s queue has packets,False
otherwise.Return type: Boolean See also
-
is_apply_changes_enabled
()¶ Returns whether the apply_changes flag is enabled or not.
Returns: True
if the apply_changes flag is enabled,False
otherwise.Return type: Boolean
-
is_open
()¶ Returns whether this XBee device is open or not.
Returns: Boolean. True
if this XBee device is open,False
otherwise.
-
is_remote
()¶ Override method.
See also
-
log
¶ Returns the XBee device log.
Returns: the XBee device logger. Return type: Logger
-
operating_mode
¶ Returns this XBee device’s operating mode.
Returns: OperatingMode
. This XBee device’s operating mode.
-
read_data
(timeout=None)¶ Reads new data received by this XBee device.
If a
timeout
is specified, this method blocks until new data is received or the timeout expires, throwing in that case aTimeoutException
.Parameters: timeout (Integer, optional) – read timeout in seconds. If it’s
None
, this method is non-blocking and will returnNone
if there is no data available.Returns: the read message or
None
if this XBee did not receive new data.Return type: Raises: - ValueError – if a timeout is specified and is less than 0.
- TimeoutException – if a timeout is specified and no data was received during that time.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- XBeeException – if the XBee device’s serial port is closed.
See also
-
read_data_from
(remote_xbee_device, timeout=None)¶ Reads new data received from the given remote XBee device.
If a
timeout
is specified, this method blocks until new data is received or the timeout expires, throwing in that case aTimeoutException
.Parameters: - remote_xbee_device (
RemoteXBeeDevice
) – the remote XBee device that sent the data. - timeout (Integer, optional) – read timeout in seconds. If it’s
None
, this method is non-blocking and will returnNone
if there is no data available.
Returns: - the read message sent by
remote_xbee_device
orNone
if this XBee did not receive new data.
Return type: Raises: - ValueError – if a timeout is specified and is less than 0.
- TimeoutException – if a timeout is specified and no data was received during that time.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- XBeeException – if the XBee device’s serial port is closed.
See also
- remote_xbee_device (
-
read_device_info
(init=True)¶ Updates all instance parameters reading them from the XBee device.
Parameters: init (Boolean, optional, default=`True`) – If
False
only not initialized parameters are read, all ifTrue
.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
read_io_sample
()¶ Returns an IO sample from the XBee device containing the value of all enabled digital IO and analog input channels.
Returns: the IO sample read from the XBee device.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
See also
-
reset
()¶ Override method.
See also
-
send_bluetooth_data
(data)¶ Sends the given data to the Bluetooth interface using a User Data Relay frame.
Parameters: data (Bytearray) – Data to send.
Raises: - InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- XBeeException – if there is any problem sending the data.
-
send_data
(remote_xbee_device, data, transmit_options=0)¶ Blocking method. This method sends data to a remote XBee device synchronously.
This method will wait for the packet response.
The default timeout for this method is
XBeeDevice._DEFAULT_TIMEOUT_SYNC_OPERATIONS
.Parameters: - remote_xbee_device (
RemoteXBeeDevice
) – the remote XBee device to send data to. - data (String or Bytearray) – the raw data to send.
- transmit_options (Integer, optional) – transmit options, bitfield of
TransmitOptions
. Default toTransmitOptions.NONE.value
.
Returns: XBeePacket
the response.Raises: - ValueError – if
remote_xbee_device
isNone
. - TimeoutException – if this method can’t read a response packet in
XBeeDevice._DEFAULT_TIMEOUT_SYNC_OPERATIONS
seconds. - InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- TransmitException – if the status of the response received is not OK.
- XBeeException – if the XBee device’s serial port is closed.
See also
- remote_xbee_device (
-
send_data_async
(remote_xbee_device, data, transmit_options=0)¶ Non-blocking method. This method sends data to a remote XBee device.
This method won’t wait for the response.
Parameters: - remote_xbee_device (
RemoteXBeeDevice
) – the remote XBee device to send data to. - data (String or Bytearray) – the raw data to send.
- transmit_options (Integer, optional) – transmit options, bitfield of
TransmitOptions
. Default toTransmitOptions.NONE.value
.
Raises: - InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- XBeeException – if the XBee device’s serial port is closed.
See also
- remote_xbee_device (
-
send_data_broadcast
(data, transmit_options=0)¶ Sends the provided data to all the XBee nodes of the network (broadcast).
This method blocks till a success or error transmit status arrives or the configured receive timeout expires.
The received timeout is configured using the
AbstractXBeeDevice.set_sync_ops_timeout()
method and can be consulted withAbstractXBeeDevice.get_sync_ops_timeout()
method.Parameters: - data (String or Bytearray) – data to send.
- transmit_options (Integer, optional) – transmit options, bitfield of
TransmitOptions
. Default toTransmitOptions.NONE.value
.
Raises: - TimeoutException – if this method can’t read a response packet in
XBeeDevice._DEFAULT_TIMEOUT_SYNC_OPERATIONS
seconds. - InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- TransmitException – if the status of the response received is not OK.
- XBeeException – if the XBee device’s serial port is closed.
-
send_micropython_data
(data)¶ Sends the given data to the MicroPython interface using a User Data Relay frame.
Parameters: data (Bytearray) – Data to send.
Raises: - InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- XBeeException – if there is any problem sending the data.
-
send_packet
(packet, sync=False)¶ Override method.
See also
AbstractXBeeDevice._send_packet()
-
send_packet_sync_and_get_response
(packet_to_send, timeout=None)¶ Override method.
See also
AbstractXBeeDevice._send_packet_sync_and_get_response()
-
send_user_data_relay
(local_interface, data)¶ Sends the given data to the given XBee local interface.
Parameters: - local_interface (
XBeeLocalInterface
) – Destination XBee local interface. - data (Bytearray) – Data to send.
Raises: - InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ValueError – if
local_interface
isNone
. - XBeeException – if there is any problem sending the User Data Relay.
See also
- local_interface (
-
serial_port
¶ Returns the serial port associated to the XBee device, if any.
Returns: - the serial port associated to the XBee device. Returns
None
if the local XBee - does not use serial communication.
Return type: XBeeSerialPort
See also
- the serial port associated to the XBee device. Returns
-
set_16bit_addr
(value)¶ Sets the 16-bit address of the XBee device.
Parameters: value (
XBee16BitAddress
) – the new 16-bit address of the XBee device.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the current 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 device.
Parameters: api_output_mode (
APIOutputMode
) – the new API output mode of the XBee device.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the current protocol is ZigBee
See also
-
set_api_output_mode_value
(api_output_mode)¶ Sets the API output mode of the XBee.
Parameters: api_output_mode (Integer) – new API output mode options. Calculate this value using the method
digi.xbee.models.mode.APIOutputModeBit.calculate_api_output_mode_value()
with a set ofdigi.xbee.models.mode.APIOutputModeBit
.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if it is not supported by the current protocol.
-
set_dest_address
(addr)¶ Sets the 64-bit address of the XBee device that data will be reported to.
Parameters: addr (
XBee64BitAddress
orRemoteXBeeDevice
) – the address itself or the remote XBee device that you want to set up its address as destination address.Raises: - TimeoutException – If the response is not received before the read timeout expires.
- XBeeException – If the XBee device’s serial port is closed.
- InvalidOperatingModeException – If the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – If the response is not as expected.
- ValueError – If
addr
isNone
.
-
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 the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
See also
-
set_dio_value
(io_line, io_value)¶ Sets the digital value (high or low) to the provided IO line.
Parameters: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
set_io_configuration
(io_line, io_mode)¶ Sets the configuration of the provided IO line.
Parameters: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
set_io_sampling_rate
(rate)¶ Sets the IO sampling rate of the XBee device in seconds. A sample rate of 0 means the IO sampling feature is disabled.
Parameters: rate (Integer) – the new IO sampling rate of the XBee device in seconds.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
set_node_id
(node_id)¶ Sets the Node Identifier (
NI
) value of the XBee device..Parameters: node_id (String) – the new Node Identifier (
NI
) of the XBee device.Raises: - ValueError – if
node_id
isNone
or its length is greater than 20. - TimeoutException – if the response is not received before the read timeout expires.
- ValueError – if
-
set_pan_id
(value)¶ Sets the operating PAN ID of the XBee device.
Parameters: value (Bytearray) – the new operating PAN ID of the XBee device.. Must have only 1 or 2 bytes. Raises: TimeoutException – if the response is not received before the read timeout expires.
-
set_parameter
(param, value)¶ Override.
-
set_power_level
(power_level)¶ Sets the power level of the XBee device.
Parameters: power_level ( PowerLevel
) – the new power level of the XBee device.Raises: TimeoutException – if the response is not received before the read timeout expires. See also
-
set_pwm_duty_cycle
(io_line, cycle)¶ Sets the duty cycle in % of the provided IO line.
The provided IO line must be PWM-capable, previously configured as PWM output.
Parameters: - io_line (
IOLine
) – the IO Line to be assigned. - cycle (Integer) – duty cycle in % to be assigned. Must be between 0 and 100.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- ValueError – if the given IO line does not have PWM capability or
cycle
is not between 0 and 100.
See also
- io_line (
-
set_sync_ops_timeout
(sync_ops_timeout)¶ Sets the serial port read timeout.
Parameters: sync_ops_timeout (Integer) – the read timeout, expressed in seconds.
-
update_bluetooth_password
(new_password)¶ Changes the password of this Bluetooth device with the new one provided.
Note that your device must have Bluetooth Low Energy support to use this method.
Parameters: new_password (String) – New Bluetooth password.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
update_device_data_from
(device)¶ Updates the current device reference with the data provided for the given device.
This is only for internal use.
Parameters: device ( AbstractXBeeDevice
) – the XBee device to get the data from.Returns: True
if the device data has been updated,False
otherwise.Return type: Boolean
-
update_firmware
(xml_firmware_file, xbee_firmware_file=None, bootloader_firmware_file=None, timeout=None, progress_callback=None)¶ Performs a firmware update operation of the device.
Parameters: - xml_firmware_file (String) – path of the XML file that describes the firmware to upload.
- xbee_firmware_file (String, optional) – location of the XBee binary firmware file.
- bootloader_firmware_file (String, optional) – location of the bootloader binary firmware file.
- timeout (Integer, optional) – the maximum time to wait for target read operations during the update process.
- progress_callback (Function, optional) –
- function to execute to receive progress information. Receives two
- arguments:
- The current update task as a String
- The current update task percentage as an Integer
Raises: - XBeeException – if the device is not open.
- InvalidOperatingModeException – if the device operating mode is invalid.
- OperationNotSupportedException – if the firmware update is not supported in the XBee device.
- FirmwareUpdateException – if there is any error performing the firmware update.
-
write_changes
()¶ Writes configurable parameter values to the non-volatile memory of the XBee device so that parameter modifications persist through subsequent resets.
Parameters values remain in this device’s memory until overwritten by subsequent use of this method.
If changes are made without writing them to non-volatile memory, the module reverts back to previously saved parameters the next time the module is powered-on.
Writing the parameter modifications does not mean those values are immediately applied, this depends on the status of the ‘apply configuration changes’ option. Use method
is_apply_configuration_changes_enabled()
to get its status andenable_apply_configuration_changes()
to enable/disable the option. If it is disabled, methodapply_changes()
can be used in order to manually apply the changes.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
class
digi.xbee.devices.
ZigBeeDevice
(port=None, baud_rate=None, data_bits=<sphinx.ext.autodoc.importer._MockObject object>, stop_bits=<sphinx.ext.autodoc.importer._MockObject object>, parity=<sphinx.ext.autodoc.importer._MockObject object>, flow_control=<FlowControl.NONE: None>, _sync_ops_timeout=4, comm_iface=None)[source]¶ Bases:
digi.xbee.devices.XBeeDevice
This class represents a local ZigBee XBee device.
Class constructor. Instantiates a new
ZigBeeDevice
with the provided parameters.Parameters: - port (Integer or String) – serial port identifier. Integer: number of XBee device, numbering starts at zero. Device name: depending on operating system. e.g. ‘/dev/ttyUSB0’ on ‘GNU/Linux’ or ‘COM3’ on Windows.
- baud_rate (Integer) – the serial port baud rate.
- (Integer, default (flow_control) –
serial.EIGHTBITS
): comm port bitsize. - (Integer, default –
serial.STOPBITS_ONE
): comm port stop bits. - (Character, default (parity) –
serial.PARITY_NONE
): comm port parity. - (Integer, default –
FlowControl.NONE
): comm port flow control.- _sync_ops_timeout (Integer, default: 3): the read timeout (in seconds).
- comm_iface (
XBeeCommunicationInterface
): the communication interface.
:raises All exceptions raised by
XBeeDevice.__init__()
constructor.:See also
XBeeDevice.__init__()
-
open
(force_settings=False)[source]¶ Override.
Raises: - TimeoutException – If there is any problem with the communication.
- InvalidOperatingModeException – If the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- XBeeException – If the protocol is invalid or if the XBee device is already open.
See also
-
send_data_64_16
(x64addr, x16addr, data, transmit_options=0)[source]¶ Override.
See also
XBeeDevice.send_data_64_16()
-
send_data_async_64_16
(x64addr, x16addr, data, transmit_options=0)[source]¶ Override.
See also
XBeeDevice.send_data_async_64_16()
-
read_expl_data_from
(remote_xbee_device, timeout=None)[source]¶ Override.
See also
XBeeDevice._read_expl_data_from()
-
send_expl_data
(remote_xbee_device, data, src_endpoint, dest_endpoint, cluster_id, profile_id, transmit_options=0)[source]¶ Override.
See also
XBeeDevice._send_expl_data()
-
send_expl_data_broadcast
(data, src_endpoint, dest_endpoint, cluster_id, profile_id, transmit_options=0)[source]¶ Override.
See also
XBeeDevice._send_expl_data_broadcast()
-
send_expl_data_async
(remote_xbee_device, data, src_endpoint, dest_endpoint, cluster_id, profile_id, transmit_options=0)[source]¶ Override.
See also
XBeeDevice.send_expl_data_async()
-
send_multicast_data
(group_id, data, src_endpoint, dest_endpoint, cluster_id, profile_id)[source]¶ Blocking method. This method sends multicast data to the provided group ID synchronously.
This method will wait for the packet response.
The default timeout for this method is
XBeeDevice._DEFAULT_TIMEOUT_SYNC_OPERATIONS
.Parameters: - group_id (
XBee16BitAddress
) – the 16 bit address of the multicast group. - data (Bytearray) – the raw data to send.
- src_endpoint (Integer) – source endpoint of the transmission. 1 byte.
- dest_endpoint (Integer) – destination endpoint of the transmission. 1 byte.
- cluster_id (Integer) – Cluster ID of the transmission. Must be between 0x0 and 0xFFFF.
- profile_id (Integer) – Profile ID of the transmission. Must be between 0x0 and 0xFFFF.
Returns: the response packet.
Return type: Raises: - TimeoutException – if this method can’t read a response packet in
XBeeDevice._DEFAULT_TIMEOUT_SYNC_OPERATIONS
seconds. - InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- XBeeException – if the XBee device’s serial port is closed.
- XBeeException – if the status of the response received is not OK.
See also
XBee16BitAddress
XBeePacket
- group_id (
-
send_multicast_data_async
(group_id, data, src_endpoint, dest_endpoint, cluster_id, profile_id)[source]¶ Non-blocking method. This method sends multicast data to the provided group ID.
This method won’t wait for the response.
Parameters: - group_id (
XBee16BitAddress
) – the 16 bit address of the multicast group. - data (Bytearray) – the raw data to send.
- src_endpoint (Integer) – source endpoint of the transmission. 1 byte.
- dest_endpoint (Integer) – destination endpoint of the transmission. 1 byte.
- cluster_id (Integer) – Cluster ID of the transmission. Must be between 0x0 and 0xFFFF.
- profile_id (Integer) – Profile ID of the transmission. Must be between 0x0 and 0xFFFF.
Raises: - TimeoutException – if this method can’t read a response packet in
XBeeDevice._DEFAULT_TIMEOUT_SYNC_OPERATIONS
seconds. - InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- XBeeException – if the XBee device’s serial port is closed.
See also
XBee16BitAddress
- group_id (
-
register_joining_device
(registrant_address, options, key)[source]¶ Securely registers a joining device to a trust center. Registration is the process by which a node is authorized to join the network using a preconfigured link key or installation code that is conveyed to the trust center out-of-band (using a physical interface and not over-the-air).
This method is synchronous, it sends the register joining device packet and waits for the answer of the operation. Then, returns the corresponding status.
Parameters: - registrant_address (
XBee64BitAddress
) – the 64-bit address of the device to register. - options (RegisterKeyOptions) – the register options indicating the key source.
- key (Bytearray) – key of the device to register.
Returns: - the register device operation status or
None
if the answer received is not a
RegisterDeviceStatusPacket
.
Return type: Raises: - TimeoutException – if the answer is not received in the configured timeout.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- XBeeException – if the XBee device’s serial port is closed.
- ValueError – if
registrant_address
isNone
or ifoptions
isNone
.
See also
RegisterKeyOptions
XBee64BitAddress
ZigbeeRegisterStatus
- registrant_address (
-
register_joining_device_async
(registrant_address, options, key)[source]¶ Securely registers a joining device to a trust center. Registration is the process by which a node is authorized to join the network using a preconfigured link key or installation code that is conveyed to the trust center out-of-band (using a physical interface and not over-the-air).
This method is asynchronous, which means that it will not wait for an answer after sending the register frame.
Parameters: - registrant_address (
XBee64BitAddress
) – the 64-bit address of the device to register. - options (RegisterKeyOptions) – the register options indicating the key source.
- key (Bytearray) – key of the device to register.
Raises: - InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- XBeeException – if the XBee device’s serial port is closed.
- ValueError – if
registrant_address
isNone
or ifoptions
isNone
.
See also
RegisterKeyOptions
XBee64BitAddress
- registrant_address (
-
unregister_joining_device
(unregistrant_address)[source]¶ Unregisters a joining device from a trust center.
This method is synchronous, it sends the unregister joining device packet and waits for the answer of the operation. Then, returns the corresponding status.
Parameters: unregistrant_address (
XBee64BitAddress
) – the 64-bit address of the device to unregister.Returns: - the unregister device operation status or
None
if the answer received is not a
RegisterDeviceStatusPacket
.
Return type: Raises: - TimeoutException – if the answer is not received in the configured timeout.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- XBeeException – if the XBee device’s serial port is closed.
- ValueError – if
registrant_address
isNone
.
See also
XBee64BitAddress
ZigbeeRegisterStatus
- the unregister device operation status or
-
unregister_joining_device_async
(unregistrant_address)[source]¶ Unregisters a joining device from a trust center.
This method is asynchronous, which means that it will not wait for an answer after sending the uregister frame.
Parameters: unregistrant_address (
XBee64BitAddress
) – the 64-bit address of the device to unregister.Raises: - InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- XBeeException – if the XBee device’s serial port is closed.
- ValueError – if
registrant_address
isNone
.
See also
XBee64BitAddress
-
add_bluetooth_data_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.BluetoothDataReceived
.Parameters: callback (Function) – the callback. Receives one argument.
- The Bluetooth data as a Bytearray
-
add_data_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.DataReceived
.Parameters: callback (Function) – the callback. Receives one argument.
- The data received as an
digi.xbee.models.message.XBeeMessage
- The data received as an
-
add_expl_data_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.ExplicitDataReceived
.Parameters: callback (Function) – the callback. Receives one argument.
- The explicit data received as a
digi.xbee.models.message.ExplicitXBeeMessage
.
- The explicit data received as a
-
add_io_sample_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.IOSampleReceived
.Parameters: callback (Function) – the callback. Receives three arguments.
- The received IO sample as an
digi.xbee.io.IOSample
- The remote XBee device who has sent the packet as a
RemoteXBeeDevice
- The time in which the packet was received as an Integer
- The received IO sample as an
-
add_micropython_data_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.MicroPythonDataReceived
.Parameters: callback (Function) – the callback. Receives one argument.
- The MicroPython data as a Bytearray
-
add_modem_status_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.ModemStatusReceived
.Parameters: callback (Function) – the callback. Receives one argument.
- The modem status as a
digi.xbee.models.status.ModemStatus
- The modem status as a
-
add_packet_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.PacketReceived
.Parameters: callback (Function) – the callback. Receives two arguments.
- The received packet as a
digi.xbee.packets.base.XBeeAPIPacket
- The received packet as a
-
add_socket_data_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.SocketDataReceived
.Parameters: callback (Function) – the callback. Receives two arguments.
- The socket ID as an Integer.
- The data received as Bytearray
-
add_socket_data_received_from_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.SocketDataReceivedFrom
.Parameters: callback (Function) – the callback. Receives three arguments.
- The socket ID as an Integer.
- A pair (host, port) of the source address where host is a string
- representing an IPv4 address like ‘100.50.200.5’, and port is an integer.
- The data received as Bytearray
-
add_socket_state_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.SocketStateReceived
.Parameters: callback (Function) – the callback. Receives two arguments.
- The socket ID as an Integer.
- The state received as a
SocketState
-
add_user_data_relay_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.RelayDataReceived
.Parameters: callback (Function) – the callback. Receives one argument.
- The relay data as a
digi.xbee.models.message.UserDataRelayMessage
- The relay data as a
-
apply_changes
()¶ Applies changes via
AC
command.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
apply_profile
(profile_path, progress_callback=None)¶ Applies the given XBee profile to the XBee device.
Parameters: - profile_path (String) – path of the XBee profile file to apply.
- progress_callback (Function, optional) –
- function to execute to receive progress information. Receives two
- arguments:
- The current apply profile task as a String
- The current apply profile task percentage as an Integer
Raises: - XBeeException – if the device is not open.
- InvalidOperatingModeException – if the device operating mode is invalid.
- UpdateProfileException – if there is any error applying the XBee profile.
- OperationNotSupportedException – if XBee profiles are not supported in the XBee device.
-
close
()¶ Closes the communication with the XBee device.
This method guarantees that all threads running are stopped and the serial port is closed.
-
comm_iface
¶ Returns the hardware interface associated to the XBee device.
Returns: the hardware interface associated to the XBee device. Return type: XBeeCommunicationInterface
See also
-
classmethod
create_xbee_device
(comm_port_data)¶ Creates and returns an
XBeeDevice
from data of the port to which is connected.Parameters: - comm_port_data (Dictionary) – dictionary with all comm port data needed.
- dictionary keys are (The) – “baudRate” –> Baud rate.”port” –> Port number.”bitSize” –> Bit size.”stopBits” –> Stop bits.”parity” –> Parity.”flowControl” –> Flow control.”timeout” for –> Timeout for synchronous operations (in seconds).
Returns: the XBee device created.
Return type: Raises: SerialException – if the port you want to open does not exist or is already opened.
See also
-
del_bluetooth_data_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.BluetoothDataReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.BluetoothDataReceived
event.
-
del_data_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.DataReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.DataReceived
event.
-
del_expl_data_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.ExplicitDataReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.ExplicitDataReceived
event.
-
del_io_sample_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.IOSampleReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.IOSampleReceived
event.
-
del_micropython_data_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.MicroPythonDataReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.MicroPythonDataReceived
event.
-
del_modem_status_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.ModemStatusReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.ModemStatusReceived
event.
-
del_packet_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.PacketReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.PacketReceived
event.
-
del_socket_data_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.SocketDataReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.SocketDataReceived
event.
-
del_socket_data_received_from_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.SocketDataReceivedFrom
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.SocketDataReceivedFrom
event.
-
del_socket_state_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.SocketStateReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.SocketStateReceived
event.
-
del_user_data_relay_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.RelayDataReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.RelayDataReceived
event.
-
disable_bluetooth
()¶ Disables the Bluetooth interface of this XBee device.
Note that your device must have Bluetooth Low Energy support to use this method.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
enable_apply_changes
(value)¶ Sets the apply_changes flag.
Parameters: value (Boolean) – True
to enable the apply changes flag,False
to disable it.
-
enable_bluetooth
()¶ Enables the Bluetooth interface of this XBee device.
To work with this interface, you must also configure the Bluetooth password if not done previously. You can use the
AbstractXBeeDevice.update_bluetooth_password()
method for that purpose.Note that your device must have Bluetooth Low Energy support to use this method.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
execute_command
(parameter)¶ Executes the provided command.
Parameters: parameter (String) – The name of the AT command to be executed.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
flush_queues
()¶ Flushes the packets queue.
-
get_16bit_addr
()¶ Returns the 16-bit address of the XBee device.
Returns: the 16-bit address of the XBee device. Return type: XBee16BitAddress
See also
-
get_64bit_addr
()¶ Returns the 64-bit address of the XBee device.
Returns: the 64-bit address of the XBee device. Return type: XBee64BitAddress
See also
-
get_adc_value
(io_line)¶ Returns the analog value of the provided IO line.
The provided IO line must be previously configured as ADC. To do so, use
AbstractXBeeDevice.set_io_configuration()
andIOMode.ADC
.Parameters: io_line (
IOLine
) – the IO line to get its ADC value.Returns: the analog value corresponding to the provided IO line.
Return type: Integer
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the response does not contain the value for the given IO line.
See also
-
get_api_output_mode
()¶ Deprecated since version 1.3: Use
get_api_output_mode_value()
Returns the API output mode of the XBee device.
The API output mode determines the format that the received data is output through the serial interface of the XBee device.
Returns: the API output mode of the XBee device.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
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 the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- 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 device in a format such as
00112233AABB
.Note that your device must have Bluetooth Low Energy support to use this method.
Returns: The Bluetooth MAC address.
Return type: String
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
get_current_frame_id
()¶ Returns the last used frame ID.
Returns: the last used frame ID. Return type: Integer
-
get_dest_address
()¶ Returns the 64-bit address of the XBee device that data will be reported to.
Returns: the address. Return type: XBee64BitAddress
Raises: TimeoutException – if the response is not received before the read timeout expires. See also
-
get_dio_value
(io_line)¶ Returns the digital value of the provided IO line.
The provided IO line must be previously configured as digital I/O. To do so, use
AbstractXBeeDevice.set_io_configuration()
.Parameters: io_line (
IOLine
) – the DIO line to gets its digital value.Returns: current value of the provided IO line.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the response does not contain the value for the given IO line.
-
get_firmware_version
()¶ Returns the firmware version of the XBee device.
Returns: the hardware version of the XBee device. Return type: Bytearray
-
get_hardware_version
()¶ Returns the hardware version of the XBee device.
Returns: the hardware version of the XBee device. Return type: HardwareVersion
See also
-
get_io_configuration
(io_line)¶ Returns the configuration of the provided IO line.
Parameters: io_line (
IOLine
) – the io line to configure.Returns: the IO mode of the IO line provided.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the received data is not an IO mode.
-
get_io_sampling_rate
()¶ Returns the IO sampling rate of the XBee device.
Returns: the IO sampling rate of XBee device.
Return type: Integer
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
get_network
()¶ Returns this XBee device’s current network.
Returns: XBeeDevice.XBeeNetwork
-
get_next_frame_id
()¶ Returns the next frame ID of the XBee device.
Returns: The next frame ID of the XBee device. Return type: Integer
-
get_node_id
()¶ Returns the Node Identifier (
NI
) value of the XBee device.Returns: the Node Identifier ( NI
) of the XBee device.Return type: String
-
get_pan_id
()¶ Returns the operating PAN ID of the XBee device.
Returns: operating PAN ID of the XBee device. Return type: Bytearray Raises: TimeoutException – if the response is not received before the read timeout expires.
-
get_parameter
(param, parameter_value=None)¶ Override.
See also
-
get_power_level
()¶ Returns the power level of the XBee device.
Returns: the power level of the XBee device. Return type: PowerLevel
Raises: TimeoutException – if the response is not received before the read timeout expires. See also
-
get_pwm_duty_cycle
(io_line)¶ Returns the PWM duty cycle in % corresponding to the provided IO line.
Parameters: io_line (
IOLine
) – the IO line to get its PWM duty cycle.Returns: the PWM duty cycle of the given IO line or
None
if the response is empty.Return type: Integer
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- ValueError – if the passed
IO_LINE
has no PWM capability.
See also
-
get_role
()¶ Gets the XBee role.
Returns: the role of the XBee. Return type: digi.xbee.models.protocol.Role
See also
-
get_sync_ops_timeout
()¶ Returns the serial port read timeout.
Returns: the serial port read timeout in seconds. Return type: Integer
-
get_xbee_device_callbacks
()¶ Returns this XBee internal callbacks for process received packets.
This method is called by the PacketListener associated with this XBee to get its callbacks. These callbacks will be executed before user callbacks.
Returns: PacketReceived
-
has_explicit_packets
()¶ Returns whether the XBee device’s queue has explicit packets or not. This do not include non-explicit packets.
Returns: True
if this XBee device’s queue has explicit packets,False
otherwise.Return type: Boolean See also
-
has_packets
()¶ Returns whether the XBee device’s queue has packets or not. This do not include explicit packets.
Returns: True
if this XBee device’s queue has packets,False
otherwise.Return type: Boolean See also
-
is_apply_changes_enabled
()¶ Returns whether the apply_changes flag is enabled or not.
Returns: True
if the apply_changes flag is enabled,False
otherwise.Return type: Boolean
-
is_open
()¶ Returns whether this XBee device is open or not.
Returns: Boolean. True
if this XBee device is open,False
otherwise.
-
is_remote
()¶ Override method.
See also
-
log
¶ Returns the XBee device log.
Returns: the XBee device logger. Return type: Logger
-
operating_mode
¶ Returns this XBee device’s operating mode.
Returns: OperatingMode
. This XBee device’s operating mode.
-
read_data
(timeout=None)¶ Reads new data received by this XBee device.
If a
timeout
is specified, this method blocks until new data is received or the timeout expires, throwing in that case aTimeoutException
.Parameters: timeout (Integer, optional) – read timeout in seconds. If it’s
None
, this method is non-blocking and will returnNone
if there is no data available.Returns: the read message or
None
if this XBee did not receive new data.Return type: Raises: - ValueError – if a timeout is specified and is less than 0.
- TimeoutException – if a timeout is specified and no data was received during that time.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- XBeeException – if the XBee device’s serial port is closed.
See also
-
read_data_from
(remote_xbee_device, timeout=None)¶ Reads new data received from the given remote XBee device.
If a
timeout
is specified, this method blocks until new data is received or the timeout expires, throwing in that case aTimeoutException
.Parameters: - remote_xbee_device (
RemoteXBeeDevice
) – the remote XBee device that sent the data. - timeout (Integer, optional) – read timeout in seconds. If it’s
None
, this method is non-blocking and will returnNone
if there is no data available.
Returns: - the read message sent by
remote_xbee_device
orNone
if this XBee did not receive new data.
Return type: Raises: - ValueError – if a timeout is specified and is less than 0.
- TimeoutException – if a timeout is specified and no data was received during that time.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- XBeeException – if the XBee device’s serial port is closed.
See also
- remote_xbee_device (
-
read_device_info
(init=True)¶ Updates all instance parameters reading them from the XBee device.
Parameters: init (Boolean, optional, default=`True`) – If
False
only not initialized parameters are read, all ifTrue
.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
read_io_sample
()¶ Returns an IO sample from the XBee device containing the value of all enabled digital IO and analog input channels.
Returns: the IO sample read from the XBee device.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
See also
-
reset
()¶ Override method.
See also
-
send_bluetooth_data
(data)¶ Sends the given data to the Bluetooth interface using a User Data Relay frame.
Parameters: data (Bytearray) – Data to send.
Raises: - InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- XBeeException – if there is any problem sending the data.
-
send_data
(remote_xbee_device, data, transmit_options=0)¶ Blocking method. This method sends data to a remote XBee device synchronously.
This method will wait for the packet response.
The default timeout for this method is
XBeeDevice._DEFAULT_TIMEOUT_SYNC_OPERATIONS
.Parameters: - remote_xbee_device (
RemoteXBeeDevice
) – the remote XBee device to send data to. - data (String or Bytearray) – the raw data to send.
- transmit_options (Integer, optional) – transmit options, bitfield of
TransmitOptions
. Default toTransmitOptions.NONE.value
.
Returns: XBeePacket
the response.Raises: - ValueError – if
remote_xbee_device
isNone
. - TimeoutException – if this method can’t read a response packet in
XBeeDevice._DEFAULT_TIMEOUT_SYNC_OPERATIONS
seconds. - InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- TransmitException – if the status of the response received is not OK.
- XBeeException – if the XBee device’s serial port is closed.
See also
- remote_xbee_device (
-
send_data_async
(remote_xbee_device, data, transmit_options=0)¶ Non-blocking method. This method sends data to a remote XBee device.
This method won’t wait for the response.
Parameters: - remote_xbee_device (
RemoteXBeeDevice
) – the remote XBee device to send data to. - data (String or Bytearray) – the raw data to send.
- transmit_options (Integer, optional) – transmit options, bitfield of
TransmitOptions
. Default toTransmitOptions.NONE.value
.
Raises: - InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- XBeeException – if the XBee device’s serial port is closed.
See also
- remote_xbee_device (
-
send_data_broadcast
(data, transmit_options=0)¶ Sends the provided data to all the XBee nodes of the network (broadcast).
This method blocks till a success or error transmit status arrives or the configured receive timeout expires.
The received timeout is configured using the
AbstractXBeeDevice.set_sync_ops_timeout()
method and can be consulted withAbstractXBeeDevice.get_sync_ops_timeout()
method.Parameters: - data (String or Bytearray) – data to send.
- transmit_options (Integer, optional) – transmit options, bitfield of
TransmitOptions
. Default toTransmitOptions.NONE.value
.
Raises: - TimeoutException – if this method can’t read a response packet in
XBeeDevice._DEFAULT_TIMEOUT_SYNC_OPERATIONS
seconds. - InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- TransmitException – if the status of the response received is not OK.
- XBeeException – if the XBee device’s serial port is closed.
-
send_micropython_data
(data)¶ Sends the given data to the MicroPython interface using a User Data Relay frame.
Parameters: data (Bytearray) – Data to send.
Raises: - InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- XBeeException – if there is any problem sending the data.
-
send_packet
(packet, sync=False)¶ Override method.
See also
AbstractXBeeDevice._send_packet()
-
send_packet_sync_and_get_response
(packet_to_send, timeout=None)¶ Override method.
See also
AbstractXBeeDevice._send_packet_sync_and_get_response()
-
send_user_data_relay
(local_interface, data)¶ Sends the given data to the given XBee local interface.
Parameters: - local_interface (
XBeeLocalInterface
) – Destination XBee local interface. - data (Bytearray) – Data to send.
Raises: - InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ValueError – if
local_interface
isNone
. - XBeeException – if there is any problem sending the User Data Relay.
See also
- local_interface (
-
serial_port
¶ Returns the serial port associated to the XBee device, if any.
Returns: - the serial port associated to the XBee device. Returns
None
if the local XBee - does not use serial communication.
Return type: XBeeSerialPort
See also
- the serial port associated to the XBee device. Returns
-
set_16bit_addr
(value)¶ Sets the 16-bit address of the XBee device.
Parameters: value (
XBee16BitAddress
) – the new 16-bit address of the XBee device.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the current 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 device.
Parameters: api_output_mode (
APIOutputMode
) – the new API output mode of the XBee device.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the current protocol is ZigBee
See also
-
set_api_output_mode_value
(api_output_mode)¶ Sets the API output mode of the XBee.
Parameters: api_output_mode (Integer) – new API output mode options. Calculate this value using the method
digi.xbee.models.mode.APIOutputModeBit.calculate_api_output_mode_value()
with a set ofdigi.xbee.models.mode.APIOutputModeBit
.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if it is not supported by the current protocol.
-
set_dest_address
(addr)¶ Sets the 64-bit address of the XBee device that data will be reported to.
Parameters: addr (
XBee64BitAddress
orRemoteXBeeDevice
) – the address itself or the remote XBee device that you want to set up its address as destination address.Raises: - TimeoutException – If the response is not received before the read timeout expires.
- XBeeException – If the XBee device’s serial port is closed.
- InvalidOperatingModeException – If the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – If the response is not as expected.
- ValueError – If
addr
isNone
.
-
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 the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
See also
-
set_dio_value
(io_line, io_value)¶ Sets the digital value (high or low) to the provided IO line.
Parameters: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
set_io_configuration
(io_line, io_mode)¶ Sets the configuration of the provided IO line.
Parameters: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
set_io_sampling_rate
(rate)¶ Sets the IO sampling rate of the XBee device in seconds. A sample rate of 0 means the IO sampling feature is disabled.
Parameters: rate (Integer) – the new IO sampling rate of the XBee device in seconds.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
set_node_id
(node_id)¶ Sets the Node Identifier (
NI
) value of the XBee device..Parameters: node_id (String) – the new Node Identifier (
NI
) of the XBee device.Raises: - ValueError – if
node_id
isNone
or its length is greater than 20. - TimeoutException – if the response is not received before the read timeout expires.
- ValueError – if
-
set_pan_id
(value)¶ Sets the operating PAN ID of the XBee device.
Parameters: value (Bytearray) – the new operating PAN ID of the XBee device.. Must have only 1 or 2 bytes. Raises: TimeoutException – if the response is not received before the read timeout expires.
-
set_parameter
(param, value)¶ Override.
-
set_power_level
(power_level)¶ Sets the power level of the XBee device.
Parameters: power_level ( PowerLevel
) – the new power level of the XBee device.Raises: TimeoutException – if the response is not received before the read timeout expires. See also
-
set_pwm_duty_cycle
(io_line, cycle)¶ Sets the duty cycle in % of the provided IO line.
The provided IO line must be PWM-capable, previously configured as PWM output.
Parameters: - io_line (
IOLine
) – the IO Line to be assigned. - cycle (Integer) – duty cycle in % to be assigned. Must be between 0 and 100.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- ValueError – if the given IO line does not have PWM capability or
cycle
is not between 0 and 100.
See also
- io_line (
-
set_sync_ops_timeout
(sync_ops_timeout)¶ Sets the serial port read timeout.
Parameters: sync_ops_timeout (Integer) – the read timeout, expressed in seconds.
-
update_bluetooth_password
(new_password)¶ Changes the password of this Bluetooth device with the new one provided.
Note that your device must have Bluetooth Low Energy support to use this method.
Parameters: new_password (String) – New Bluetooth password.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
update_device_data_from
(device)¶ Updates the current device reference with the data provided for the given device.
This is only for internal use.
Parameters: device ( AbstractXBeeDevice
) – the XBee device to get the data from.Returns: True
if the device data has been updated,False
otherwise.Return type: Boolean
-
update_firmware
(xml_firmware_file, xbee_firmware_file=None, bootloader_firmware_file=None, timeout=None, progress_callback=None)¶ Performs a firmware update operation of the device.
Parameters: - xml_firmware_file (String) – path of the XML file that describes the firmware to upload.
- xbee_firmware_file (String, optional) – location of the XBee binary firmware file.
- bootloader_firmware_file (String, optional) – location of the bootloader binary firmware file.
- timeout (Integer, optional) – the maximum time to wait for target read operations during the update process.
- progress_callback (Function, optional) –
- function to execute to receive progress information. Receives two
- arguments:
- The current update task as a String
- The current update task percentage as an Integer
Raises: - XBeeException – if the device is not open.
- InvalidOperatingModeException – if the device operating mode is invalid.
- OperationNotSupportedException – if the firmware update is not supported in the XBee device.
- FirmwareUpdateException – if there is any error performing the firmware update.
-
write_changes
()¶ Writes configurable parameter values to the non-volatile memory of the XBee device so that parameter modifications persist through subsequent resets.
Parameters values remain in this device’s memory until overwritten by subsequent use of this method.
If changes are made without writing them to non-volatile memory, the module reverts back to previously saved parameters the next time the module is powered-on.
Writing the parameter modifications does not mean those values are immediately applied, this depends on the status of the ‘apply configuration changes’ option. Use method
is_apply_configuration_changes_enabled()
to get its status andenable_apply_configuration_changes()
to enable/disable the option. If it is disabled, methodapply_changes()
can be used in order to manually apply the changes.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
class
digi.xbee.devices.
IPDevice
(port=None, baud_rate=None, data_bits=<sphinx.ext.autodoc.importer._MockObject object>, stop_bits=<sphinx.ext.autodoc.importer._MockObject object>, parity=<sphinx.ext.autodoc.importer._MockObject object>, flow_control=<FlowControl.NONE: None>, _sync_ops_timeout=4, comm_iface=None)[source]¶ Bases:
digi.xbee.devices.XBeeDevice
This class provides common functionality for XBee IP devices.
Class constructor. Instantiates a new
IPDevice
with the provided parameters.Parameters: - port (Integer or String) – serial port identifier. Integer: number of XBee device, numbering starts at zero. Device name: depending on operating system. e.g. ‘/dev/ttyUSB0’ on ‘GNU/Linux’ or ‘COM3’ on Windows.
- baud_rate (Integer) – the serial port baud rate.
- (Integer, default (_sync_ops_timeout) –
serial.EIGHTBITS
): comm port bitsize. - (Integer, default –
serial.STOPBITS_ONE
): comm port stop bits. - (Character, default (parity) –
serial.PARITY_NONE
): comm port parity. - (Integer, default –
FlowControl.NONE
): comm port flow control. - (Integer, default – 3): the read timeout (in seconds).
- comm_iface (
XBeeCommunicationInterface
) – the communication interface.
:raises All exceptions raised by
XBeeDevice.__init__()
constructor.:See also
XBeeDevice.__init__()
-
get_ip_addr
()[source]¶ Returns the IP address of this IP device.
To refresh this value use the method
IPDevice.read_device_info()
.Returns: The IP address of this IP device. Return type: ipaddress.IPv4Address
See also
ipaddress.IPv4Address
-
set_dest_ip_addr
(address)[source]¶ Sets the destination IP address.
Parameters: address (
ipaddress.IPv4Address
) – Destination IP address.Raises: - ValueError – if
address
isNone
. - TimeoutException – if there is a timeout setting the destination IP address.
- XBeeException – if there is any other XBee related exception.
See also
ipaddress.IPv4Address
- ValueError – if
-
get_dest_ip_addr
()[source]¶ Returns the destination IP address.
Returns: The configured destination IP address.
Return type: ipaddress.IPv4Address
Raises: - TimeoutException – if there is a timeout getting the destination IP address.
- XBeeException – if there is any other XBee related exception.
See also
ipaddress.IPv4Address
-
add_ip_data_received_callback
(callback)[source]¶ Adds a callback for the event
digi.xbee.reader.IPDataReceived
.Parameters: callback (Function) – the callback. Receives one argument.
- The data received as an
digi.xbee.models.message.IPMessage
- The data received as an
-
del_ip_data_received_callback
(callback)[source]¶ Deletes a callback for the callback list of
digi.xbee.reader.IPDataReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.IPDataReceived
event.
-
start_listening
(source_port)[source]¶ Starts listening for incoming IP transmissions in the provided port.
Parameters: source_port (Integer) – Port to listen for incoming transmissions.
Raises: - ValueError – if
source_port
is less than 0 or greater than 65535. - TimeoutException – if there is a timeout setting the source port.
- XBeeException – if there is any other XBee related exception.
- ValueError – if
-
stop_listening
()[source]¶ Stops listening for incoming IP transmissions.
Raises: - TimeoutException – if there is a timeout processing the operation.
- XBeeException – if there is any other XBee related exception.
-
send_ip_data
(ip_addr, dest_port, protocol, data, close_socket=False)[source]¶ Sends the provided IP data to the given IP address and port using the specified IP protocol. For TCP and TCP SSL protocols, you can also indicate if the socket should be closed when data is sent.
This method blocks till a success or error response arrives or the configured receive timeout expires.
Parameters: - ip_addr (
ipaddress.IPv4Address
) – The IP address to send IP data to. - dest_port (Integer) – The destination port of the transmission.
- protocol (
IPProtocol
) – The IP protocol used for the transmission. - data (String or Bytearray) – The IP data to be sent.
- close_socket (Boolean, optional) –
True
to close the socket just after the transmission.False
to keep it open. Default toFalse
.
Raises: - ValueError – if
ip_addr
isNone
. - ValueError – if
protocol
isNone
. - ValueError – if
data
isNone
. - ValueError – if
dest_port
is less than 0 or greater than 65535. - OperationNotSupportedException – if the device is remote.
- TimeoutException – if there is a timeout sending the data.
- XBeeException – if there is any other XBee related exception.
- ip_addr (
-
send_ip_data_async
(ip_addr, dest_port, protocol, data, close_socket=False)[source]¶ Sends the provided IP data to the given IP address and port asynchronously using the specified IP protocol. For TCP and TCP SSL protocols, you can also indicate if the socket should be closed when data is sent.
Asynchronous transmissions do not wait for answer from the remote device or for transmit status packet.
Parameters: - ip_addr (
ipaddress.IPv4Address
) – The IP address to send IP data to. - dest_port (Integer) – The destination port of the transmission.
- protocol (
IPProtocol
) – The IP protocol used for the transmission. - data (String or Bytearray) – The IP data to be sent.
- close_socket (Boolean, optional) –
True
to close the socket just after the transmission.False
to keep it open. Default toFalse
.
Raises: - ValueError – if
ip_addr
isNone
. - ValueError – if
protocol
isNone
. - ValueError – if
data
isNone
. - ValueError – if
dest_port
is less than 0 or greater than 65535. - OperationNotSupportedException – if the device is remote.
- XBeeException – if there is any other XBee related exception.
- ip_addr (
-
send_ip_data_broadcast
(dest_port, data)[source]¶ Sends the provided IP data to all clients.
This method blocks till a success or error transmit status arrives or the configured receive timeout expires.
Parameters: - dest_port (Integer) – The destination port of the transmission.
- data (String or Bytearray) – The IP data to be sent.
Raises: - ValueError – if
data
isNone
. - ValueError – if
dest_port
is less than 0 or greater than 65535. - TimeoutException – if there is a timeout sending the data.
- XBeeException – if there is any other XBee related exception.
-
read_ip_data
(timeout=3)[source]¶ Reads new IP data received by this XBee device during the provided timeout.
This method blocks until new IP data is received or the provided timeout expires.
For non-blocking operations, register a callback and use the method
IPDevice.add_ip_data_received_callback()
.Before reading IP data you need to start listening for incoming IP data at a specific port. Use the method
IPDevice.start_listening()
for that purpose. When finished, you can use the methodIPDevice.stop_listening()
to stop listening for incoming IP data.Parameters: timeout (Integer, optional) – The time to wait for new IP data in seconds. Returns: IP message, None
if this device did not receive new data.Return type: IPMessage
Raises: ValueError – if timeout
is less than 0.
-
read_ip_data_from
(ip_addr, timeout=3)[source]¶ Reads new IP data received from the given IP address during the provided timeout.
This method blocks until new IP data from the provided IP address is received or the given timeout expires.
For non-blocking operations, register a callback and use the method
IPDevice.add_ip_data_received_callback()
.Before reading IP data you need to start listening for incoming IP data at a specific port. Use the method
IPDevice.start_listening()
for that purpose. When finished, you can use the methodIPDevice.stop_listening()
to stop listening for incoming IP data.Parameters: - ip_addr (
ipaddress.IPv4Address
) – The IP address to read data from. - timeout (Integer, optional) – The time to wait for new IP data in seconds.
Returns: - IP message,
None
if this device did not receive new data from the provided IP address.
Return type: Raises: ValueError – if
timeout
is less than 0.- ip_addr (
-
get_dest_address
()[source]¶ Deprecated.
Operation not supported in this protocol. Use
IPDevice.get_dest_ip_addr()
instead. This method will raise anAttributeError
.
-
set_dest_address
(addr)[source]¶ Deprecated.
Operation not supported in this protocol. Use
IPDevice.set_dest_ip_addr()
instead. This method will raise anAttributeError
.
-
get_pan_id
()[source]¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
set_pan_id
(value)[source]¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
add_data_received_callback
(callback)[source]¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
del_data_received_callback
(callback)[source]¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
add_expl_data_received_callback
(callback)[source]¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
del_expl_data_received_callback
(callback)[source]¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
read_data
(timeout=None, explicit=False)[source]¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
read_data_from
(remote_xbee_device, timeout=None, explicit=False)[source]¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
send_data_broadcast
(data, transmit_options=0)[source]¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
send_data
(remote_xbee_device, data, transmit_options=0)[source]¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
send_data_async
(remote_xbee_device, data, transmit_options=0)[source]¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
add_bluetooth_data_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.BluetoothDataReceived
.Parameters: callback (Function) – the callback. Receives one argument.
- The Bluetooth data as a Bytearray
-
add_io_sample_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.IOSampleReceived
.Parameters: callback (Function) – the callback. Receives three arguments.
- The received IO sample as an
digi.xbee.io.IOSample
- The remote XBee device who has sent the packet as a
RemoteXBeeDevice
- The time in which the packet was received as an Integer
- The received IO sample as an
-
add_micropython_data_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.MicroPythonDataReceived
.Parameters: callback (Function) – the callback. Receives one argument.
- The MicroPython data as a Bytearray
-
add_modem_status_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.ModemStatusReceived
.Parameters: callback (Function) – the callback. Receives one argument.
- The modem status as a
digi.xbee.models.status.ModemStatus
- The modem status as a
-
add_packet_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.PacketReceived
.Parameters: callback (Function) – the callback. Receives two arguments.
- The received packet as a
digi.xbee.packets.base.XBeeAPIPacket
- The received packet as a
-
add_socket_data_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.SocketDataReceived
.Parameters: callback (Function) – the callback. Receives two arguments.
- The socket ID as an Integer.
- The data received as Bytearray
-
add_socket_data_received_from_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.SocketDataReceivedFrom
.Parameters: callback (Function) – the callback. Receives three arguments.
- The socket ID as an Integer.
- A pair (host, port) of the source address where host is a string
- representing an IPv4 address like ‘100.50.200.5’, and port is an integer.
- The data received as Bytearray
-
add_socket_state_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.SocketStateReceived
.Parameters: callback (Function) – the callback. Receives two arguments.
- The socket ID as an Integer.
- The state received as a
SocketState
-
add_user_data_relay_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.RelayDataReceived
.Parameters: callback (Function) – the callback. Receives one argument.
- The relay data as a
digi.xbee.models.message.UserDataRelayMessage
- The relay data as a
-
apply_changes
()¶ Applies changes via
AC
command.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
apply_profile
(profile_path, progress_callback=None)¶ Applies the given XBee profile to the XBee device.
Parameters: - profile_path (String) – path of the XBee profile file to apply.
- progress_callback (Function, optional) –
- function to execute to receive progress information. Receives two
- arguments:
- The current apply profile task as a String
- The current apply profile task percentage as an Integer
Raises: - XBeeException – if the device is not open.
- InvalidOperatingModeException – if the device operating mode is invalid.
- UpdateProfileException – if there is any error applying the XBee profile.
- OperationNotSupportedException – if XBee profiles are not supported in the XBee device.
-
close
()¶ Closes the communication with the XBee device.
This method guarantees that all threads running are stopped and the serial port is closed.
-
comm_iface
¶ Returns the hardware interface associated to the XBee device.
Returns: the hardware interface associated to the XBee device. Return type: XBeeCommunicationInterface
See also
-
classmethod
create_xbee_device
(comm_port_data)¶ Creates and returns an
XBeeDevice
from data of the port to which is connected.Parameters: - comm_port_data (Dictionary) – dictionary with all comm port data needed.
- dictionary keys are (The) – “baudRate” –> Baud rate.”port” –> Port number.”bitSize” –> Bit size.”stopBits” –> Stop bits.”parity” –> Parity.”flowControl” –> Flow control.”timeout” for –> Timeout for synchronous operations (in seconds).
Returns: the XBee device created.
Return type: Raises: SerialException – if the port you want to open does not exist or is already opened.
See also
-
del_bluetooth_data_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.BluetoothDataReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.BluetoothDataReceived
event.
-
del_io_sample_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.IOSampleReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.IOSampleReceived
event.
-
del_micropython_data_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.MicroPythonDataReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.MicroPythonDataReceived
event.
-
del_modem_status_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.ModemStatusReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.ModemStatusReceived
event.
-
del_packet_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.PacketReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.PacketReceived
event.
-
del_socket_data_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.SocketDataReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.SocketDataReceived
event.
-
del_socket_data_received_from_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.SocketDataReceivedFrom
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.SocketDataReceivedFrom
event.
-
del_socket_state_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.SocketStateReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.SocketStateReceived
event.
-
del_user_data_relay_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.RelayDataReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.RelayDataReceived
event.
-
disable_bluetooth
()¶ Disables the Bluetooth interface of this XBee device.
Note that your device must have Bluetooth Low Energy support to use this method.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
enable_apply_changes
(value)¶ Sets the apply_changes flag.
Parameters: value (Boolean) – True
to enable the apply changes flag,False
to disable it.
-
enable_bluetooth
()¶ Enables the Bluetooth interface of this XBee device.
To work with this interface, you must also configure the Bluetooth password if not done previously. You can use the
AbstractXBeeDevice.update_bluetooth_password()
method for that purpose.Note that your device must have Bluetooth Low Energy support to use this method.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
execute_command
(parameter)¶ Executes the provided command.
Parameters: parameter (String) – The name of the AT command to be executed.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
flush_queues
()¶ Flushes the packets queue.
-
get_64bit_addr
()¶ Returns the 64-bit address of the XBee device.
Returns: the 64-bit address of the XBee device. Return type: XBee64BitAddress
See also
-
get_adc_value
(io_line)¶ Returns the analog value of the provided IO line.
The provided IO line must be previously configured as ADC. To do so, use
AbstractXBeeDevice.set_io_configuration()
andIOMode.ADC
.Parameters: io_line (
IOLine
) – the IO line to get its ADC value.Returns: the analog value corresponding to the provided IO line.
Return type: Integer
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the response does not contain the value for the given IO line.
See also
-
get_api_output_mode
()¶ Deprecated since version 1.3: Use
get_api_output_mode_value()
Returns the API output mode of the XBee device.
The API output mode determines the format that the received data is output through the serial interface of the XBee device.
Returns: the API output mode of the XBee device.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
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 the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- 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 device in a format such as
00112233AABB
.Note that your device must have Bluetooth Low Energy support to use this method.
Returns: The Bluetooth MAC address.
Return type: String
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
get_current_frame_id
()¶ Returns the last used frame ID.
Returns: the last used frame ID. Return type: Integer
-
get_dio_value
(io_line)¶ Returns the digital value of the provided IO line.
The provided IO line must be previously configured as digital I/O. To do so, use
AbstractXBeeDevice.set_io_configuration()
.Parameters: io_line (
IOLine
) – the DIO line to gets its digital value.Returns: current value of the provided IO line.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the response does not contain the value for the given IO line.
-
get_firmware_version
()¶ Returns the firmware version of the XBee device.
Returns: the hardware version of the XBee device. Return type: Bytearray
-
get_hardware_version
()¶ Returns the hardware version of the XBee device.
Returns: the hardware version of the XBee device. Return type: HardwareVersion
See also
-
get_io_configuration
(io_line)¶ Returns the configuration of the provided IO line.
Parameters: io_line (
IOLine
) – the io line to configure.Returns: the IO mode of the IO line provided.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the received data is not an IO mode.
-
get_io_sampling_rate
()¶ Returns the IO sampling rate of the XBee device.
Returns: the IO sampling rate of XBee device.
Return type: Integer
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
get_next_frame_id
()¶ Returns the next frame ID of the XBee device.
Returns: The next frame ID of the XBee device. Return type: Integer
-
get_node_id
()¶ Returns the Node Identifier (
NI
) value of the XBee device.Returns: the Node Identifier ( NI
) of the XBee device.Return type: String
-
get_parameter
(param, parameter_value=None)¶ Override.
See also
-
get_power_level
()¶ Returns the power level of the XBee device.
Returns: the power level of the XBee device. Return type: PowerLevel
Raises: TimeoutException – if the response is not received before the read timeout expires. See also
-
get_protocol
()¶ Returns the current protocol of the XBee device.
Returns: the current protocol of the XBee device. Return type: XBeeProtocol
See also
-
get_pwm_duty_cycle
(io_line)¶ Returns the PWM duty cycle in % corresponding to the provided IO line.
Parameters: io_line (
IOLine
) – the IO line to get its PWM duty cycle.Returns: the PWM duty cycle of the given IO line or
None
if the response is empty.Return type: Integer
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- ValueError – if the passed
IO_LINE
has no PWM capability.
See also
-
get_role
()¶ Gets the XBee role.
Returns: the role of the XBee. Return type: digi.xbee.models.protocol.Role
See also
-
get_sync_ops_timeout
()¶ Returns the serial port read timeout.
Returns: the serial port read timeout in seconds. Return type: Integer
-
get_xbee_device_callbacks
()¶ Returns this XBee internal callbacks for process received packets.
This method is called by the PacketListener associated with this XBee to get its callbacks. These callbacks will be executed before user callbacks.
Returns: PacketReceived
-
has_explicit_packets
()¶ Returns whether the XBee device’s queue has explicit packets or not. This do not include non-explicit packets.
Returns: True
if this XBee device’s queue has explicit packets,False
otherwise.Return type: Boolean See also
-
has_packets
()¶ Returns whether the XBee device’s queue has packets or not. This do not include explicit packets.
Returns: True
if this XBee device’s queue has packets,False
otherwise.Return type: Boolean See also
-
is_apply_changes_enabled
()¶ Returns whether the apply_changes flag is enabled or not.
Returns: True
if the apply_changes flag is enabled,False
otherwise.Return type: Boolean
-
is_open
()¶ Returns whether this XBee device is open or not.
Returns: Boolean. True
if this XBee device is open,False
otherwise.
-
is_remote
()¶ Override method.
See also
-
log
¶ Returns the XBee device log.
Returns: the XBee device logger. Return type: Logger
-
open
(force_settings=False)¶ Opens the communication with the XBee device and loads some information about it.
Parameters: force_settings (Boolean, optional) –
True
to open the device ensuring/forcing that the specified serial settings are applied even if the current configuration is different,False
to open the device with the current configuration. Default to False.Raises: - TimeoutException – if there is any problem with the communication.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- XBeeException – if the XBee device is already open.
-
operating_mode
¶ Returns this XBee device’s operating mode.
Returns: OperatingMode
. This XBee device’s operating mode.
-
read_io_sample
()¶ Returns an IO sample from the XBee device containing the value of all enabled digital IO and analog input channels.
Returns: the IO sample read from the XBee device.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
See also
-
reset
()¶ Override method.
See also
-
send_bluetooth_data
(data)¶ Sends the given data to the Bluetooth interface using a User Data Relay frame.
Parameters: data (Bytearray) – Data to send.
Raises: - InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- XBeeException – if there is any problem sending the data.
-
send_micropython_data
(data)¶ Sends the given data to the MicroPython interface using a User Data Relay frame.
Parameters: data (Bytearray) – Data to send.
Raises: - InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- XBeeException – if there is any problem sending the data.
-
send_packet
(packet, sync=False)¶ Override method.
See also
AbstractXBeeDevice._send_packet()
-
send_packet_sync_and_get_response
(packet_to_send, timeout=None)¶ Override method.
See also
AbstractXBeeDevice._send_packet_sync_and_get_response()
-
send_user_data_relay
(local_interface, data)¶ Sends the given data to the given XBee local interface.
Parameters: - local_interface (
XBeeLocalInterface
) – Destination XBee local interface. - data (Bytearray) – Data to send.
Raises: - InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ValueError – if
local_interface
isNone
. - XBeeException – if there is any problem sending the User Data Relay.
See also
- local_interface (
-
serial_port
¶ Returns the serial port associated to the XBee device, if any.
Returns: - the serial port associated to the XBee device. Returns
None
if the local XBee - does not use serial communication.
Return type: XBeeSerialPort
See also
- the serial port associated to the XBee device. Returns
-
set_16bit_addr
(value)¶ Sets the 16-bit address of the XBee device.
Parameters: value (
XBee16BitAddress
) – the new 16-bit address of the XBee device.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the current 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 device.
Parameters: api_output_mode (
APIOutputMode
) – the new API output mode of the XBee device.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the current protocol is ZigBee
See also
-
set_api_output_mode_value
(api_output_mode)¶ Sets the API output mode of the XBee.
Parameters: api_output_mode (Integer) – new API output mode options. Calculate this value using the method
digi.xbee.models.mode.APIOutputModeBit.calculate_api_output_mode_value()
with a set ofdigi.xbee.models.mode.APIOutputModeBit
.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if it is not supported by the current protocol.
-
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 the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
See also
-
set_dio_value
(io_line, io_value)¶ Sets the digital value (high or low) to the provided IO line.
Parameters: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
set_io_configuration
(io_line, io_mode)¶ Sets the configuration of the provided IO line.
Parameters: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
set_io_sampling_rate
(rate)¶ Sets the IO sampling rate of the XBee device in seconds. A sample rate of 0 means the IO sampling feature is disabled.
Parameters: rate (Integer) – the new IO sampling rate of the XBee device in seconds.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
set_node_id
(node_id)¶ Sets the Node Identifier (
NI
) value of the XBee device..Parameters: node_id (String) – the new Node Identifier (
NI
) of the XBee device.Raises: - ValueError – if
node_id
isNone
or its length is greater than 20. - TimeoutException – if the response is not received before the read timeout expires.
- ValueError – if
-
set_parameter
(param, value)¶ Override.
-
set_power_level
(power_level)¶ Sets the power level of the XBee device.
Parameters: power_level ( PowerLevel
) – the new power level of the XBee device.Raises: TimeoutException – if the response is not received before the read timeout expires. See also
-
set_pwm_duty_cycle
(io_line, cycle)¶ Sets the duty cycle in % of the provided IO line.
The provided IO line must be PWM-capable, previously configured as PWM output.
Parameters: - io_line (
IOLine
) – the IO Line to be assigned. - cycle (Integer) – duty cycle in % to be assigned. Must be between 0 and 100.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- ValueError – if the given IO line does not have PWM capability or
cycle
is not between 0 and 100.
See also
- io_line (
-
set_sync_ops_timeout
(sync_ops_timeout)¶ Sets the serial port read timeout.
Parameters: sync_ops_timeout (Integer) – the read timeout, expressed in seconds.
-
update_bluetooth_password
(new_password)¶ Changes the password of this Bluetooth device with the new one provided.
Note that your device must have Bluetooth Low Energy support to use this method.
Parameters: new_password (String) – New Bluetooth password.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
update_device_data_from
(device)¶ Updates the current device reference with the data provided for the given device.
This is only for internal use.
Parameters: device ( AbstractXBeeDevice
) – the XBee device to get the data from.Returns: True
if the device data has been updated,False
otherwise.Return type: Boolean
-
update_firmware
(xml_firmware_file, xbee_firmware_file=None, bootloader_firmware_file=None, timeout=None, progress_callback=None)¶ Performs a firmware update operation of the device.
Parameters: - xml_firmware_file (String) – path of the XML file that describes the firmware to upload.
- xbee_firmware_file (String, optional) – location of the XBee binary firmware file.
- bootloader_firmware_file (String, optional) – location of the bootloader binary firmware file.
- timeout (Integer, optional) – the maximum time to wait for target read operations during the update process.
- progress_callback (Function, optional) –
- function to execute to receive progress information. Receives two
- arguments:
- The current update task as a String
- The current update task percentage as an Integer
Raises: - XBeeException – if the device is not open.
- InvalidOperatingModeException – if the device operating mode is invalid.
- OperationNotSupportedException – if the firmware update is not supported in the XBee device.
- FirmwareUpdateException – if there is any error performing the firmware update.
-
write_changes
()¶ Writes configurable parameter values to the non-volatile memory of the XBee device so that parameter modifications persist through subsequent resets.
Parameters values remain in this device’s memory until overwritten by subsequent use of this method.
If changes are made without writing them to non-volatile memory, the module reverts back to previously saved parameters the next time the module is powered-on.
Writing the parameter modifications does not mean those values are immediately applied, this depends on the status of the ‘apply configuration changes’ option. Use method
is_apply_configuration_changes_enabled()
to get its status andenable_apply_configuration_changes()
to enable/disable the option. If it is disabled, methodapply_changes()
can be used in order to manually apply the changes.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
class
digi.xbee.devices.
CellularDevice
(port=None, baud_rate=None, data_bits=<sphinx.ext.autodoc.importer._MockObject object>, stop_bits=<sphinx.ext.autodoc.importer._MockObject object>, parity=<sphinx.ext.autodoc.importer._MockObject object>, flow_control=<FlowControl.NONE: None>, _sync_ops_timeout=4, comm_iface=None)[source]¶ Bases:
digi.xbee.devices.IPDevice
This class represents a local Cellular device.
Class constructor. Instantiates a new
CellularDevice
with the provided parameters.Parameters: - port (Integer or String) – serial port identifier. Integer: number of XBee device, numbering starts at zero. Device name: depending on operating system. e.g. ‘/dev/ttyUSB0’ on ‘GNU/Linux’ or ‘COM3’ on Windows.
- baud_rate (Integer) – the serial port baud rate.
- (Integer, default (_sync_ops_timeout) –
serial.EIGHTBITS
): comm port bitsize. - (Integer, default –
serial.STOPBITS_ONE
): comm port stop bits. - (Character, default (parity) –
serial.PARITY_NONE
): comm port parity. - (Integer, default –
FlowControl.NONE
): comm port flow control. - (Integer, default – 3): the read timeout (in seconds).
- comm_iface (
XBeeCommunicationInterface
) – the communication interface.
:raises All exceptions raised by
XBeeDevice.__init__()
constructor.:See also
XBeeDevice.__init__()
-
open
(force_settings=False)[source]¶ Override.
Raises: - TimeoutException – If there is any problem with the communication.
- InvalidOperatingModeException – If the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- XBeeException – If the protocol is invalid or if the XBee device is already open.
See also
-
is_connected
()[source]¶ Returns whether the device is connected to the Internet or not.
Returns: True
if the device is connected to the Internet,False
otherwise.Return type: Boolean
Raises: - TimeoutException – if there is a timeout getting the association indication status.
- XBeeException – if there is any other XBee related exception.
-
get_cellular_ai_status
()[source]¶ Returns the current association status of this Cellular device.
It indicates occurrences of errors during the modem initialization and connection.
Returns: The association indication status of the Cellular device.
Return type: Raises: - TimeoutException – if there is a timeout getting the association indication status.
- XBeeException – if there is any other XBee related exception.
-
add_sms_callback
(callback)[source]¶ Adds a callback for the event
digi.xbee.reader.SMSReceived
.Parameters: callback (Function) – the callback. Receives one argument.
- The data received as an
digi.xbee.models.message.SMSMessage
- The data received as an
-
del_sms_callback
(callback)[source]¶ Deletes a callback for the callback list of
digi.xbee.reader.SMSReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.SMSReceived
event.
-
get_imei_addr
()[source]¶ Returns the IMEI address of this Cellular device.
To refresh this value use the method
CellularDevice.read_device_info()
.Returns: The IMEI address of this Cellular device. Return type: XBeeIMEIAddress
-
send_sms
(phone_number, data)[source]¶ Sends the provided SMS message to the given phone number.
This method blocks till a success or error response arrives or the configured receive timeout expires.
For non-blocking operations use the method
CellularDevice.send_sms_async()
.Parameters: - phone_number (String) – The phone number to send the SMS to.
- data (String) – Text of the SMS.
Raises: - ValueError – if
phone_number
isNone
. - ValueError – if
data
isNone
. - OperationNotSupportedException – if the device is remote.
- TimeoutException – if there is a timeout sending the SMS.
- XBeeException – if there is any other XBee related exception.
-
send_sms_async
(phone_number, data)[source]¶ Sends asynchronously the provided SMS to the given phone number.
Asynchronous transmissions do not wait for answer or for transmit status packet.
Parameters: - phone_number (String) – The phone number to send the SMS to.
- data (String) – Text of the SMS.
Raises: - ValueError – if
phone_number
isNone
. - ValueError – if
data
isNone
. - OperationNotSupportedException – if the device is remote.
- XBeeException – if there is any other XBee related exception.
-
get_sockets_list
()[source]¶ Returns a list with the IDs of all active (open) sockets.
Returns: list with the IDs of all active (open) sockets, or empty list if there is not any active socket.
Return type: List
Raises: - InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
-
get_socket_info
(socket_id)[source]¶ Returns the information of the socket with the given socket ID.
Parameters: socket_id (Integer) – ID of the socket.
Returns: The socket information, or
None
if the socket with that ID does not exist.Return type: SocketInfo
Raises: - InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
See also
SocketInfo
-
add_io_sample_received_callback
(callback)[source]¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
del_io_sample_received_callback
(callback)[source]¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
set_dio_change_detection
(io_lines_set)[source]¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
get_io_sampling_rate
()[source]¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
set_io_sampling_rate
(rate)[source]¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
get_node_id
()[source]¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
set_node_id
(node_id)[source]¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
get_power_level
()[source]¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
set_power_level
(power_level)[source]¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
add_bluetooth_data_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.BluetoothDataReceived
.Parameters: callback (Function) – the callback. Receives one argument.
- The Bluetooth data as a Bytearray
-
add_data_received_callback
(callback)¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
add_expl_data_received_callback
(callback)¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
add_ip_data_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.IPDataReceived
.Parameters: callback (Function) – the callback. Receives one argument.
- The data received as an
digi.xbee.models.message.IPMessage
- The data received as an
-
add_micropython_data_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.MicroPythonDataReceived
.Parameters: callback (Function) – the callback. Receives one argument.
- The MicroPython data as a Bytearray
-
add_modem_status_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.ModemStatusReceived
.Parameters: callback (Function) – the callback. Receives one argument.
- The modem status as a
digi.xbee.models.status.ModemStatus
- The modem status as a
-
add_packet_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.PacketReceived
.Parameters: callback (Function) – the callback. Receives two arguments.
- The received packet as a
digi.xbee.packets.base.XBeeAPIPacket
- The received packet as a
-
add_socket_data_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.SocketDataReceived
.Parameters: callback (Function) – the callback. Receives two arguments.
- The socket ID as an Integer.
- The data received as Bytearray
-
add_socket_data_received_from_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.SocketDataReceivedFrom
.Parameters: callback (Function) – the callback. Receives three arguments.
- The socket ID as an Integer.
- A pair (host, port) of the source address where host is a string
- representing an IPv4 address like ‘100.50.200.5’, and port is an integer.
- The data received as Bytearray
-
add_socket_state_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.SocketStateReceived
.Parameters: callback (Function) – the callback. Receives two arguments.
- The socket ID as an Integer.
- The state received as a
SocketState
-
add_user_data_relay_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.RelayDataReceived
.Parameters: callback (Function) – the callback. Receives one argument.
- The relay data as a
digi.xbee.models.message.UserDataRelayMessage
- The relay data as a
-
apply_changes
()¶ Applies changes via
AC
command.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
apply_profile
(profile_path, progress_callback=None)¶ Applies the given XBee profile to the XBee device.
Parameters: - profile_path (String) – path of the XBee profile file to apply.
- progress_callback (Function, optional) –
- function to execute to receive progress information. Receives two
- arguments:
- The current apply profile task as a String
- The current apply profile task percentage as an Integer
Raises: - XBeeException – if the device is not open.
- InvalidOperatingModeException – if the device operating mode is invalid.
- UpdateProfileException – if there is any error applying the XBee profile.
- OperationNotSupportedException – if XBee profiles are not supported in the XBee device.
-
close
()¶ Closes the communication with the XBee device.
This method guarantees that all threads running are stopped and the serial port is closed.
-
comm_iface
¶ Returns the hardware interface associated to the XBee device.
Returns: the hardware interface associated to the XBee device. Return type: XBeeCommunicationInterface
See also
-
classmethod
create_xbee_device
(comm_port_data)¶ Creates and returns an
XBeeDevice
from data of the port to which is connected.Parameters: - comm_port_data (Dictionary) – dictionary with all comm port data needed.
- dictionary keys are (The) – “baudRate” –> Baud rate.”port” –> Port number.”bitSize” –> Bit size.”stopBits” –> Stop bits.”parity” –> Parity.”flowControl” –> Flow control.”timeout” for –> Timeout for synchronous operations (in seconds).
Returns: the XBee device created.
Return type: Raises: SerialException – if the port you want to open does not exist or is already opened.
See also
-
del_bluetooth_data_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.BluetoothDataReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.BluetoothDataReceived
event.
-
del_data_received_callback
(callback)¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
del_expl_data_received_callback
(callback)¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
del_ip_data_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.IPDataReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.IPDataReceived
event.
-
del_micropython_data_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.MicroPythonDataReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.MicroPythonDataReceived
event.
-
del_modem_status_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.ModemStatusReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.ModemStatusReceived
event.
-
del_packet_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.PacketReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.PacketReceived
event.
-
del_socket_data_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.SocketDataReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.SocketDataReceived
event.
-
del_socket_data_received_from_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.SocketDataReceivedFrom
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.SocketDataReceivedFrom
event.
-
del_socket_state_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.SocketStateReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.SocketStateReceived
event.
-
del_user_data_relay_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.RelayDataReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.RelayDataReceived
event.
-
disable_bluetooth
()¶ Disables the Bluetooth interface of this XBee device.
Note that your device must have Bluetooth Low Energy support to use this method.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
enable_apply_changes
(value)¶ Sets the apply_changes flag.
Parameters: value (Boolean) – True
to enable the apply changes flag,False
to disable it.
-
enable_bluetooth
()¶ Enables the Bluetooth interface of this XBee device.
To work with this interface, you must also configure the Bluetooth password if not done previously. You can use the
AbstractXBeeDevice.update_bluetooth_password()
method for that purpose.Note that your device must have Bluetooth Low Energy support to use this method.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
execute_command
(parameter)¶ Executes the provided command.
Parameters: parameter (String) – The name of the AT command to be executed.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
flush_queues
()¶ Flushes the packets queue.
-
get_16bit_addr
()¶ Deprecated.
This protocol does not have an associated 16-bit address.
-
get_adc_value
(io_line)¶ Returns the analog value of the provided IO line.
The provided IO line must be previously configured as ADC. To do so, use
AbstractXBeeDevice.set_io_configuration()
andIOMode.ADC
.Parameters: io_line (
IOLine
) – the IO line to get its ADC value.Returns: the analog value corresponding to the provided IO line.
Return type: Integer
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the response does not contain the value for the given IO line.
See also
-
get_api_output_mode
()¶ Deprecated since version 1.3: Use
get_api_output_mode_value()
Returns the API output mode of the XBee device.
The API output mode determines the format that the received data is output through the serial interface of the XBee device.
Returns: the API output mode of the XBee device.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
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 the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- 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 device in a format such as
00112233AABB
.Note that your device must have Bluetooth Low Energy support to use this method.
Returns: The Bluetooth MAC address.
Return type: String
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
get_current_frame_id
()¶ Returns the last used frame ID.
Returns: the last used frame ID. Return type: Integer
-
get_dest_address
()¶ Deprecated.
Operation not supported in this protocol. Use
IPDevice.get_dest_ip_addr()
instead. This method will raise anAttributeError
.
-
get_dest_ip_addr
()¶ Returns the destination IP address.
Returns: The configured destination IP address.
Return type: ipaddress.IPv4Address
Raises: - TimeoutException – if there is a timeout getting the destination IP address.
- XBeeException – if there is any other XBee related exception.
See also
ipaddress.IPv4Address
-
get_dio_value
(io_line)¶ Returns the digital value of the provided IO line.
The provided IO line must be previously configured as digital I/O. To do so, use
AbstractXBeeDevice.set_io_configuration()
.Parameters: io_line (
IOLine
) – the DIO line to gets its digital value.Returns: current value of the provided IO line.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the response does not contain the value for the given IO line.
-
get_firmware_version
()¶ Returns the firmware version of the XBee device.
Returns: the hardware version of the XBee device. Return type: Bytearray
-
get_hardware_version
()¶ Returns the hardware version of the XBee device.
Returns: the hardware version of the XBee device. Return type: HardwareVersion
See also
-
get_io_configuration
(io_line)¶ Returns the configuration of the provided IO line.
Parameters: io_line (
IOLine
) – the io line to configure.Returns: the IO mode of the IO line provided.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the received data is not an IO mode.
-
get_ip_addr
()¶ Returns the IP address of this IP device.
To refresh this value use the method
IPDevice.read_device_info()
.Returns: The IP address of this IP device. Return type: ipaddress.IPv4Address
See also
ipaddress.IPv4Address
-
get_network
()¶ Deprecated.
This protocol does not support the network functionality.
-
get_next_frame_id
()¶ Returns the next frame ID of the XBee device.
Returns: The next frame ID of the XBee device. Return type: Integer
-
get_pan_id
()¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
get_parameter
(param, parameter_value=None)¶ Override.
See also
-
get_pwm_duty_cycle
(io_line)¶ Returns the PWM duty cycle in % corresponding to the provided IO line.
Parameters: io_line (
IOLine
) – the IO line to get its PWM duty cycle.Returns: the PWM duty cycle of the given IO line or
None
if the response is empty.Return type: Integer
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- ValueError – if the passed
IO_LINE
has no PWM capability.
See also
-
get_role
()¶ Gets the XBee role.
Returns: the role of the XBee. Return type: digi.xbee.models.protocol.Role
See also
-
get_sync_ops_timeout
()¶ Returns the serial port read timeout.
Returns: the serial port read timeout in seconds. Return type: Integer
-
get_xbee_device_callbacks
()¶ Returns this XBee internal callbacks for process received packets.
This method is called by the PacketListener associated with this XBee to get its callbacks. These callbacks will be executed before user callbacks.
Returns: PacketReceived
-
has_explicit_packets
()¶ Returns whether the XBee device’s queue has explicit packets or not. This do not include non-explicit packets.
Returns: True
if this XBee device’s queue has explicit packets,False
otherwise.Return type: Boolean See also
-
has_packets
()¶ Returns whether the XBee device’s queue has packets or not. This do not include explicit packets.
Returns: True
if this XBee device’s queue has packets,False
otherwise.Return type: Boolean See also
-
is_apply_changes_enabled
()¶ Returns whether the apply_changes flag is enabled or not.
Returns: True
if the apply_changes flag is enabled,False
otherwise.Return type: Boolean
-
is_open
()¶ Returns whether this XBee device is open or not.
Returns: Boolean. True
if this XBee device is open,False
otherwise.
-
is_remote
()¶ Override method.
See also
-
log
¶ Returns the XBee device log.
Returns: the XBee device logger. Return type: Logger
-
operating_mode
¶ Returns this XBee device’s operating mode.
Returns: OperatingMode
. This XBee device’s operating mode.
-
read_data
(timeout=None, explicit=False)¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
read_data_from
(remote_xbee_device, timeout=None, explicit=False)¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
read_io_sample
()¶ Returns an IO sample from the XBee device containing the value of all enabled digital IO and analog input channels.
Returns: the IO sample read from the XBee device.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
See also
-
read_ip_data
(timeout=3)¶ Reads new IP data received by this XBee device during the provided timeout.
This method blocks until new IP data is received or the provided timeout expires.
For non-blocking operations, register a callback and use the method
IPDevice.add_ip_data_received_callback()
.Before reading IP data you need to start listening for incoming IP data at a specific port. Use the method
IPDevice.start_listening()
for that purpose. When finished, you can use the methodIPDevice.stop_listening()
to stop listening for incoming IP data.Parameters: timeout (Integer, optional) – The time to wait for new IP data in seconds. Returns: IP message, None
if this device did not receive new data.Return type: IPMessage
Raises: ValueError – if timeout
is less than 0.
-
read_ip_data_from
(ip_addr, timeout=3)¶ Reads new IP data received from the given IP address during the provided timeout.
This method blocks until new IP data from the provided IP address is received or the given timeout expires.
For non-blocking operations, register a callback and use the method
IPDevice.add_ip_data_received_callback()
.Before reading IP data you need to start listening for incoming IP data at a specific port. Use the method
IPDevice.start_listening()
for that purpose. When finished, you can use the methodIPDevice.stop_listening()
to stop listening for incoming IP data.Parameters: - ip_addr (
ipaddress.IPv4Address
) – The IP address to read data from. - timeout (Integer, optional) – The time to wait for new IP data in seconds.
Returns: - IP message,
None
if this device did not receive new data from the provided IP address.
Return type: Raises: ValueError – if
timeout
is less than 0.- ip_addr (
-
reset
()¶ Override method.
See also
-
send_bluetooth_data
(data)¶ Sends the given data to the Bluetooth interface using a User Data Relay frame.
Parameters: data (Bytearray) – Data to send.
Raises: - InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- XBeeException – if there is any problem sending the data.
-
send_data
(remote_xbee_device, data, transmit_options=0)¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
send_data_async
(remote_xbee_device, data, transmit_options=0)¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
send_data_broadcast
(data, transmit_options=0)¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
send_ip_data
(ip_addr, dest_port, protocol, data, close_socket=False)¶ Sends the provided IP data to the given IP address and port using the specified IP protocol. For TCP and TCP SSL protocols, you can also indicate if the socket should be closed when data is sent.
This method blocks till a success or error response arrives or the configured receive timeout expires.
Parameters: - ip_addr (
ipaddress.IPv4Address
) – The IP address to send IP data to. - dest_port (Integer) – The destination port of the transmission.
- protocol (
IPProtocol
) – The IP protocol used for the transmission. - data (String or Bytearray) – The IP data to be sent.
- close_socket (Boolean, optional) –
True
to close the socket just after the transmission.False
to keep it open. Default toFalse
.
Raises: - ValueError – if
ip_addr
isNone
. - ValueError – if
protocol
isNone
. - ValueError – if
data
isNone
. - ValueError – if
dest_port
is less than 0 or greater than 65535. - OperationNotSupportedException – if the device is remote.
- TimeoutException – if there is a timeout sending the data.
- XBeeException – if there is any other XBee related exception.
- ip_addr (
-
send_ip_data_async
(ip_addr, dest_port, protocol, data, close_socket=False)¶ Sends the provided IP data to the given IP address and port asynchronously using the specified IP protocol. For TCP and TCP SSL protocols, you can also indicate if the socket should be closed when data is sent.
Asynchronous transmissions do not wait for answer from the remote device or for transmit status packet.
Parameters: - ip_addr (
ipaddress.IPv4Address
) – The IP address to send IP data to. - dest_port (Integer) – The destination port of the transmission.
- protocol (
IPProtocol
) – The IP protocol used for the transmission. - data (String or Bytearray) – The IP data to be sent.
- close_socket (Boolean, optional) –
True
to close the socket just after the transmission.False
to keep it open. Default toFalse
.
Raises: - ValueError – if
ip_addr
isNone
. - ValueError – if
protocol
isNone
. - ValueError – if
data
isNone
. - ValueError – if
dest_port
is less than 0 or greater than 65535. - OperationNotSupportedException – if the device is remote.
- XBeeException – if there is any other XBee related exception.
- ip_addr (
-
send_ip_data_broadcast
(dest_port, data)¶ Sends the provided IP data to all clients.
This method blocks till a success or error transmit status arrives or the configured receive timeout expires.
Parameters: - dest_port (Integer) – The destination port of the transmission.
- data (String or Bytearray) – The IP data to be sent.
Raises: - ValueError – if
data
isNone
. - ValueError – if
dest_port
is less than 0 or greater than 65535. - TimeoutException – if there is a timeout sending the data.
- XBeeException – if there is any other XBee related exception.
-
send_micropython_data
(data)¶ Sends the given data to the MicroPython interface using a User Data Relay frame.
Parameters: data (Bytearray) – Data to send.
Raises: - InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- XBeeException – if there is any problem sending the data.
-
send_packet
(packet, sync=False)¶ Override method.
See also
AbstractXBeeDevice._send_packet()
-
send_packet_sync_and_get_response
(packet_to_send, timeout=None)¶ Override method.
See also
AbstractXBeeDevice._send_packet_sync_and_get_response()
-
send_user_data_relay
(local_interface, data)¶ Sends the given data to the given XBee local interface.
Parameters: - local_interface (
XBeeLocalInterface
) – Destination XBee local interface. - data (Bytearray) – Data to send.
Raises: - InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ValueError – if
local_interface
isNone
. - XBeeException – if there is any problem sending the User Data Relay.
See also
- local_interface (
-
serial_port
¶ Returns the serial port associated to the XBee device, if any.
Returns: - the serial port associated to the XBee device. Returns
None
if the local XBee - does not use serial communication.
Return type: XBeeSerialPort
See also
- the serial port associated to the XBee device. Returns
-
set_16bit_addr
(value)¶ Sets the 16-bit address of the XBee device.
Parameters: value (
XBee16BitAddress
) – the new 16-bit address of the XBee device.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the current 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 device.
Parameters: api_output_mode (
APIOutputMode
) – the new API output mode of the XBee device.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the current protocol is ZigBee
See also
-
set_api_output_mode_value
(api_output_mode)¶ Sets the API output mode of the XBee.
Parameters: api_output_mode (Integer) – new API output mode options. Calculate this value using the method
digi.xbee.models.mode.APIOutputModeBit.calculate_api_output_mode_value()
with a set ofdigi.xbee.models.mode.APIOutputModeBit
.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if it is not supported by the current protocol.
-
set_dest_address
(addr)¶ Deprecated.
Operation not supported in this protocol. Use
IPDevice.set_dest_ip_addr()
instead. This method will raise anAttributeError
.
-
set_dest_ip_addr
(address)¶ Sets the destination IP address.
Parameters: address (
ipaddress.IPv4Address
) – Destination IP address.Raises: - ValueError – if
address
isNone
. - TimeoutException – if there is a timeout setting the destination IP address.
- XBeeException – if there is any other XBee related exception.
See also
ipaddress.IPv4Address
- ValueError – if
-
set_dio_value
(io_line, io_value)¶ Sets the digital value (high or low) to the provided IO line.
Parameters: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
set_io_configuration
(io_line, io_mode)¶ Sets the configuration of the provided IO line.
Parameters: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
set_pan_id
(value)¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
set_parameter
(param, value)¶ Override.
-
set_pwm_duty_cycle
(io_line, cycle)¶ Sets the duty cycle in % of the provided IO line.
The provided IO line must be PWM-capable, previously configured as PWM output.
Parameters: - io_line (
IOLine
) – the IO Line to be assigned. - cycle (Integer) – duty cycle in % to be assigned. Must be between 0 and 100.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- ValueError – if the given IO line does not have PWM capability or
cycle
is not between 0 and 100.
See also
- io_line (
-
set_sync_ops_timeout
(sync_ops_timeout)¶ Sets the serial port read timeout.
Parameters: sync_ops_timeout (Integer) – the read timeout, expressed in seconds.
-
start_listening
(source_port)¶ Starts listening for incoming IP transmissions in the provided port.
Parameters: source_port (Integer) – Port to listen for incoming transmissions.
Raises: - ValueError – if
source_port
is less than 0 or greater than 65535. - TimeoutException – if there is a timeout setting the source port.
- XBeeException – if there is any other XBee related exception.
- ValueError – if
-
stop_listening
()¶ Stops listening for incoming IP transmissions.
Raises: - TimeoutException – if there is a timeout processing the operation.
- XBeeException – if there is any other XBee related exception.
-
update_bluetooth_password
(new_password)¶ Changes the password of this Bluetooth device with the new one provided.
Note that your device must have Bluetooth Low Energy support to use this method.
Parameters: new_password (String) – New Bluetooth password.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
update_device_data_from
(device)¶ Updates the current device reference with the data provided for the given device.
This is only for internal use.
Parameters: device ( AbstractXBeeDevice
) – the XBee device to get the data from.Returns: True
if the device data has been updated,False
otherwise.Return type: Boolean
-
update_firmware
(xml_firmware_file, xbee_firmware_file=None, bootloader_firmware_file=None, timeout=None, progress_callback=None)¶ Performs a firmware update operation of the device.
Parameters: - xml_firmware_file (String) – path of the XML file that describes the firmware to upload.
- xbee_firmware_file (String, optional) – location of the XBee binary firmware file.
- bootloader_firmware_file (String, optional) – location of the bootloader binary firmware file.
- timeout (Integer, optional) – the maximum time to wait for target read operations during the update process.
- progress_callback (Function, optional) –
- function to execute to receive progress information. Receives two
- arguments:
- The current update task as a String
- The current update task percentage as an Integer
Raises: - XBeeException – if the device is not open.
- InvalidOperatingModeException – if the device operating mode is invalid.
- OperationNotSupportedException – if the firmware update is not supported in the XBee device.
- FirmwareUpdateException – if there is any error performing the firmware update.
-
write_changes
()¶ Writes configurable parameter values to the non-volatile memory of the XBee device so that parameter modifications persist through subsequent resets.
Parameters values remain in this device’s memory until overwritten by subsequent use of this method.
If changes are made without writing them to non-volatile memory, the module reverts back to previously saved parameters the next time the module is powered-on.
Writing the parameter modifications does not mean those values are immediately applied, this depends on the status of the ‘apply configuration changes’ option. Use method
is_apply_configuration_changes_enabled()
to get its status andenable_apply_configuration_changes()
to enable/disable the option. If it is disabled, methodapply_changes()
can be used in order to manually apply the changes.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
class
digi.xbee.devices.
LPWANDevice
(port=None, baud_rate=None, data_bits=<sphinx.ext.autodoc.importer._MockObject object>, stop_bits=<sphinx.ext.autodoc.importer._MockObject object>, parity=<sphinx.ext.autodoc.importer._MockObject object>, flow_control=<FlowControl.NONE: None>, _sync_ops_timeout=4, comm_iface=None)[source]¶ Bases:
digi.xbee.devices.CellularDevice
This class provides common functionality for XBee Low-Power Wide-Area Network devices.
Class constructor. Instantiates a new
LPWANDevice
with the provided parameters.Parameters: - port (Integer or String) – serial port identifier. Integer: number of XBee device, numbering starts at zero. Device name: depending on operating system. e.g. ‘/dev/ttyUSB0’ on ‘GNU/Linux’ or ‘COM3’ on Windows.
- baud_rate (Integer) – the serial port baud rate.
- (Integer, default (_sync_ops_timeout) –
serial.EIGHTBITS
): comm port bitsize. - (Integer, default –
serial.STOPBITS_ONE
): comm port stop bits. - (Character, default (parity) –
serial.PARITY_NONE
): comm port parity. - (Integer, default –
FlowControl.NONE
): comm port flow control. - (Integer, default – 3): the read timeout (in seconds).
- comm_iface (
XBeeCommunicationInterface
) – the communication interface.
:raises All exceptions raised by
XBeeDevice.__init__()
constructor.:See also
CellularDevice.__init__()
-
send_ip_data
(ip_addr, dest_port, protocol, data, close_socket=False)[source]¶ Sends the provided IP data to the given IP address and port using the specified IP protocol.
This method blocks till a success or error response arrives or the configured receive timeout expires.
Parameters: - ip_addr (
ipaddress.IPv4Address
) – The IP address to send IP data to. - dest_port (Integer) – The destination port of the transmission.
- protocol (
IPProtocol
) – The IP protocol used for the transmission. - data (String or Bytearray) – The IP data to be sent.
- close_socket (Boolean, optional) – Must be
False
.
Raises: ValueError – if
protocol
is not UDP.- ip_addr (
-
send_ip_data_async
(ip_addr, dest_port, protocol, data, close_socket=False)[source]¶ Sends the provided IP data to the given IP address and port asynchronously using the specified IP protocol.
Asynchronous transmissions do not wait for answer from the remote device or for transmit status packet.
Parameters: - ip_addr (
ipaddress.IPv4Address
) – The IP address to send IP data to. - dest_port (Integer) – The destination port of the transmission.
- protocol (
IPProtocol
) – The IP protocol used for the transmission. - data (String or Bytearray) – The IP data to be sent.
- close_socket (Boolean, optional) – Must be
False
.
Raises: ValueError – if
protocol
is not UDP.- ip_addr (
-
add_sms_callback
(callback)[source]¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
del_sms_callback
(callback)[source]¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
send_sms
(phone_number, data)[source]¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
send_sms_async
(phone_number, data)[source]¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
add_bluetooth_data_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.BluetoothDataReceived
.Parameters: callback (Function) – the callback. Receives one argument.
- The Bluetooth data as a Bytearray
-
add_data_received_callback
(callback)¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
add_expl_data_received_callback
(callback)¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
add_io_sample_received_callback
(callback)¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
add_ip_data_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.IPDataReceived
.Parameters: callback (Function) – the callback. Receives one argument.
- The data received as an
digi.xbee.models.message.IPMessage
- The data received as an
-
add_micropython_data_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.MicroPythonDataReceived
.Parameters: callback (Function) – the callback. Receives one argument.
- The MicroPython data as a Bytearray
-
add_modem_status_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.ModemStatusReceived
.Parameters: callback (Function) – the callback. Receives one argument.
- The modem status as a
digi.xbee.models.status.ModemStatus
- The modem status as a
-
add_packet_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.PacketReceived
.Parameters: callback (Function) – the callback. Receives two arguments.
- The received packet as a
digi.xbee.packets.base.XBeeAPIPacket
- The received packet as a
-
add_socket_data_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.SocketDataReceived
.Parameters: callback (Function) – the callback. Receives two arguments.
- The socket ID as an Integer.
- The data received as Bytearray
-
add_socket_data_received_from_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.SocketDataReceivedFrom
.Parameters: callback (Function) – the callback. Receives three arguments.
- The socket ID as an Integer.
- A pair (host, port) of the source address where host is a string
- representing an IPv4 address like ‘100.50.200.5’, and port is an integer.
- The data received as Bytearray
-
add_socket_state_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.SocketStateReceived
.Parameters: callback (Function) – the callback. Receives two arguments.
- The socket ID as an Integer.
- The state received as a
SocketState
-
add_user_data_relay_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.RelayDataReceived
.Parameters: callback (Function) – the callback. Receives one argument.
- The relay data as a
digi.xbee.models.message.UserDataRelayMessage
- The relay data as a
-
apply_changes
()¶ Applies changes via
AC
command.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
apply_profile
(profile_path, progress_callback=None)¶ Applies the given XBee profile to the XBee device.
Parameters: - profile_path (String) – path of the XBee profile file to apply.
- progress_callback (Function, optional) –
- function to execute to receive progress information. Receives two
- arguments:
- The current apply profile task as a String
- The current apply profile task percentage as an Integer
Raises: - XBeeException – if the device is not open.
- InvalidOperatingModeException – if the device operating mode is invalid.
- UpdateProfileException – if there is any error applying the XBee profile.
- OperationNotSupportedException – if XBee profiles are not supported in the XBee device.
-
close
()¶ Closes the communication with the XBee device.
This method guarantees that all threads running are stopped and the serial port is closed.
-
comm_iface
¶ Returns the hardware interface associated to the XBee device.
Returns: the hardware interface associated to the XBee device. Return type: XBeeCommunicationInterface
See also
-
classmethod
create_xbee_device
(comm_port_data)¶ Creates and returns an
XBeeDevice
from data of the port to which is connected.Parameters: - comm_port_data (Dictionary) – dictionary with all comm port data needed.
- dictionary keys are (The) – “baudRate” –> Baud rate.”port” –> Port number.”bitSize” –> Bit size.”stopBits” –> Stop bits.”parity” –> Parity.”flowControl” –> Flow control.”timeout” for –> Timeout for synchronous operations (in seconds).
Returns: the XBee device created.
Return type: Raises: SerialException – if the port you want to open does not exist or is already opened.
See also
-
del_bluetooth_data_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.BluetoothDataReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.BluetoothDataReceived
event.
-
del_data_received_callback
(callback)¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
del_expl_data_received_callback
(callback)¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
del_io_sample_received_callback
(callback)¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
del_ip_data_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.IPDataReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.IPDataReceived
event.
-
del_micropython_data_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.MicroPythonDataReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.MicroPythonDataReceived
event.
-
del_modem_status_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.ModemStatusReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.ModemStatusReceived
event.
-
del_packet_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.PacketReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.PacketReceived
event.
-
del_socket_data_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.SocketDataReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.SocketDataReceived
event.
-
del_socket_data_received_from_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.SocketDataReceivedFrom
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.SocketDataReceivedFrom
event.
-
del_socket_state_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.SocketStateReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.SocketStateReceived
event.
-
del_user_data_relay_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.RelayDataReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.RelayDataReceived
event.
-
disable_bluetooth
()¶ Disables the Bluetooth interface of this XBee device.
Note that your device must have Bluetooth Low Energy support to use this method.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
enable_apply_changes
(value)¶ Sets the apply_changes flag.
Parameters: value (Boolean) – True
to enable the apply changes flag,False
to disable it.
-
enable_bluetooth
()¶ Enables the Bluetooth interface of this XBee device.
To work with this interface, you must also configure the Bluetooth password if not done previously. You can use the
AbstractXBeeDevice.update_bluetooth_password()
method for that purpose.Note that your device must have Bluetooth Low Energy support to use this method.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
execute_command
(parameter)¶ Executes the provided command.
Parameters: parameter (String) – The name of the AT command to be executed.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
flush_queues
()¶ Flushes the packets queue.
-
get_16bit_addr
()¶ Deprecated.
This protocol does not have an associated 16-bit address.
-
get_64bit_addr
()¶ Deprecated.
Cellular protocol does not have an associated 64-bit address.
-
get_adc_value
(io_line)¶ Returns the analog value of the provided IO line.
The provided IO line must be previously configured as ADC. To do so, use
AbstractXBeeDevice.set_io_configuration()
andIOMode.ADC
.Parameters: io_line (
IOLine
) – the IO line to get its ADC value.Returns: the analog value corresponding to the provided IO line.
Return type: Integer
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the response does not contain the value for the given IO line.
See also
-
get_api_output_mode
()¶ Deprecated since version 1.3: Use
get_api_output_mode_value()
Returns the API output mode of the XBee device.
The API output mode determines the format that the received data is output through the serial interface of the XBee device.
Returns: the API output mode of the XBee device.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
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 the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- 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 device in a format such as
00112233AABB
.Note that your device must have Bluetooth Low Energy support to use this method.
Returns: The Bluetooth MAC address.
Return type: String
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
get_cellular_ai_status
()¶ Returns the current association status of this Cellular device.
It indicates occurrences of errors during the modem initialization and connection.
Returns: The association indication status of the Cellular device.
Return type: Raises: - TimeoutException – if there is a timeout getting the association indication status.
- XBeeException – if there is any other XBee related exception.
-
get_current_frame_id
()¶ Returns the last used frame ID.
Returns: the last used frame ID. Return type: Integer
-
get_dest_address
()¶ Deprecated.
Operation not supported in this protocol. Use
IPDevice.get_dest_ip_addr()
instead. This method will raise anAttributeError
.
-
get_dest_ip_addr
()¶ Returns the destination IP address.
Returns: The configured destination IP address.
Return type: ipaddress.IPv4Address
Raises: - TimeoutException – if there is a timeout getting the destination IP address.
- XBeeException – if there is any other XBee related exception.
See also
ipaddress.IPv4Address
-
get_dio_value
(io_line)¶ Returns the digital value of the provided IO line.
The provided IO line must be previously configured as digital I/O. To do so, use
AbstractXBeeDevice.set_io_configuration()
.Parameters: io_line (
IOLine
) – the DIO line to gets its digital value.Returns: current value of the provided IO line.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the response does not contain the value for the given IO line.
-
get_firmware_version
()¶ Returns the firmware version of the XBee device.
Returns: the hardware version of the XBee device. Return type: Bytearray
-
get_hardware_version
()¶ Returns the hardware version of the XBee device.
Returns: the hardware version of the XBee device. Return type: HardwareVersion
See also
-
get_imei_addr
()¶ Returns the IMEI address of this Cellular device.
To refresh this value use the method
CellularDevice.read_device_info()
.Returns: The IMEI address of this Cellular device. Return type: XBeeIMEIAddress
-
get_io_configuration
(io_line)¶ Returns the configuration of the provided IO line.
Parameters: io_line (
IOLine
) – the io line to configure.Returns: the IO mode of the IO line provided.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the received data is not an IO mode.
-
get_io_sampling_rate
()¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
get_ip_addr
()¶ Returns the IP address of this IP device.
To refresh this value use the method
IPDevice.read_device_info()
.Returns: The IP address of this IP device. Return type: ipaddress.IPv4Address
See also
ipaddress.IPv4Address
-
get_network
()¶ Deprecated.
This protocol does not support the network functionality.
-
get_next_frame_id
()¶ Returns the next frame ID of the XBee device.
Returns: The next frame ID of the XBee device. Return type: Integer
-
get_node_id
()¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
get_pan_id
()¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
get_parameter
(param, parameter_value=None)¶ Override.
See also
-
get_power_level
()¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
get_protocol
()¶ Override.
See also
-
get_pwm_duty_cycle
(io_line)¶ Returns the PWM duty cycle in % corresponding to the provided IO line.
Parameters: io_line (
IOLine
) – the IO line to get its PWM duty cycle.Returns: the PWM duty cycle of the given IO line or
None
if the response is empty.Return type: Integer
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- ValueError – if the passed
IO_LINE
has no PWM capability.
See also
-
get_role
()¶ Gets the XBee role.
Returns: the role of the XBee. Return type: digi.xbee.models.protocol.Role
See also
-
get_socket_info
(socket_id)¶ Returns the information of the socket with the given socket ID.
Parameters: socket_id (Integer) – ID of the socket.
Returns: The socket information, or
None
if the socket with that ID does not exist.Return type: SocketInfo
Raises: - InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
See also
SocketInfo
-
get_sockets_list
()¶ Returns a list with the IDs of all active (open) sockets.
Returns: list with the IDs of all active (open) sockets, or empty list if there is not any active socket.
Return type: List
Raises: - InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
-
get_sync_ops_timeout
()¶ Returns the serial port read timeout.
Returns: the serial port read timeout in seconds. Return type: Integer
-
get_xbee_device_callbacks
()¶ Returns this XBee internal callbacks for process received packets.
This method is called by the PacketListener associated with this XBee to get its callbacks. These callbacks will be executed before user callbacks.
Returns: PacketReceived
-
has_explicit_packets
()¶ Returns whether the XBee device’s queue has explicit packets or not. This do not include non-explicit packets.
Returns: True
if this XBee device’s queue has explicit packets,False
otherwise.Return type: Boolean See also
-
has_packets
()¶ Returns whether the XBee device’s queue has packets or not. This do not include explicit packets.
Returns: True
if this XBee device’s queue has packets,False
otherwise.Return type: Boolean See also
-
is_apply_changes_enabled
()¶ Returns whether the apply_changes flag is enabled or not.
Returns: True
if the apply_changes flag is enabled,False
otherwise.Return type: Boolean
-
is_connected
()¶ Returns whether the device is connected to the Internet or not.
Returns: True
if the device is connected to the Internet,False
otherwise.Return type: Boolean
Raises: - TimeoutException – if there is a timeout getting the association indication status.
- XBeeException – if there is any other XBee related exception.
-
is_open
()¶ Returns whether this XBee device is open or not.
Returns: Boolean. True
if this XBee device is open,False
otherwise.
-
is_remote
()¶ Override method.
See also
-
log
¶ Returns the XBee device log.
Returns: the XBee device logger. Return type: Logger
-
open
(force_settings=False)¶ Override.
Raises: - TimeoutException – If there is any problem with the communication.
- InvalidOperatingModeException – If the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- XBeeException – If the protocol is invalid or if the XBee device is already open.
See also
-
operating_mode
¶ Returns this XBee device’s operating mode.
Returns: OperatingMode
. This XBee device’s operating mode.
-
read_data
(timeout=None, explicit=False)¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
read_data_from
(remote_xbee_device, timeout=None, explicit=False)¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
read_device_info
(init=True)¶ Override.
See also
XBeeDevice.read_device _info()
-
read_io_sample
()¶ Returns an IO sample from the XBee device containing the value of all enabled digital IO and analog input channels.
Returns: the IO sample read from the XBee device.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
See also
-
read_ip_data
(timeout=3)¶ Reads new IP data received by this XBee device during the provided timeout.
This method blocks until new IP data is received or the provided timeout expires.
For non-blocking operations, register a callback and use the method
IPDevice.add_ip_data_received_callback()
.Before reading IP data you need to start listening for incoming IP data at a specific port. Use the method
IPDevice.start_listening()
for that purpose. When finished, you can use the methodIPDevice.stop_listening()
to stop listening for incoming IP data.Parameters: timeout (Integer, optional) – The time to wait for new IP data in seconds. Returns: IP message, None
if this device did not receive new data.Return type: IPMessage
Raises: ValueError – if timeout
is less than 0.
-
read_ip_data_from
(ip_addr, timeout=3)¶ Reads new IP data received from the given IP address during the provided timeout.
This method blocks until new IP data from the provided IP address is received or the given timeout expires.
For non-blocking operations, register a callback and use the method
IPDevice.add_ip_data_received_callback()
.Before reading IP data you need to start listening for incoming IP data at a specific port. Use the method
IPDevice.start_listening()
for that purpose. When finished, you can use the methodIPDevice.stop_listening()
to stop listening for incoming IP data.Parameters: - ip_addr (
ipaddress.IPv4Address
) – The IP address to read data from. - timeout (Integer, optional) – The time to wait for new IP data in seconds.
Returns: - IP message,
None
if this device did not receive new data from the provided IP address.
Return type: Raises: ValueError – if
timeout
is less than 0.- ip_addr (
-
reset
()¶ Override method.
See also
-
send_bluetooth_data
(data)¶ Sends the given data to the Bluetooth interface using a User Data Relay frame.
Parameters: data (Bytearray) – Data to send.
Raises: - InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- XBeeException – if there is any problem sending the data.
-
send_data
(remote_xbee_device, data, transmit_options=0)¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
send_data_async
(remote_xbee_device, data, transmit_options=0)¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
send_data_broadcast
(data, transmit_options=0)¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
send_ip_data_broadcast
(dest_port, data)¶ Sends the provided IP data to all clients.
This method blocks till a success or error transmit status arrives or the configured receive timeout expires.
Parameters: - dest_port (Integer) – The destination port of the transmission.
- data (String or Bytearray) – The IP data to be sent.
Raises: - ValueError – if
data
isNone
. - ValueError – if
dest_port
is less than 0 or greater than 65535. - TimeoutException – if there is a timeout sending the data.
- XBeeException – if there is any other XBee related exception.
-
send_micropython_data
(data)¶ Sends the given data to the MicroPython interface using a User Data Relay frame.
Parameters: data (Bytearray) – Data to send.
Raises: - InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- XBeeException – if there is any problem sending the data.
-
send_packet
(packet, sync=False)¶ Override method.
See also
AbstractXBeeDevice._send_packet()
-
send_packet_sync_and_get_response
(packet_to_send, timeout=None)¶ Override method.
See also
AbstractXBeeDevice._send_packet_sync_and_get_response()
-
send_user_data_relay
(local_interface, data)¶ Sends the given data to the given XBee local interface.
Parameters: - local_interface (
XBeeLocalInterface
) – Destination XBee local interface. - data (Bytearray) – Data to send.
Raises: - InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ValueError – if
local_interface
isNone
. - XBeeException – if there is any problem sending the User Data Relay.
See also
- local_interface (
-
serial_port
¶ Returns the serial port associated to the XBee device, if any.
Returns: - the serial port associated to the XBee device. Returns
None
if the local XBee - does not use serial communication.
Return type: XBeeSerialPort
See also
- the serial port associated to the XBee device. Returns
-
set_16bit_addr
(value)¶ Sets the 16-bit address of the XBee device.
Parameters: value (
XBee16BitAddress
) – the new 16-bit address of the XBee device.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the current 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 device.
Parameters: api_output_mode (
APIOutputMode
) – the new API output mode of the XBee device.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the current protocol is ZigBee
See also
-
set_api_output_mode_value
(api_output_mode)¶ Sets the API output mode of the XBee.
Parameters: api_output_mode (Integer) – new API output mode options. Calculate this value using the method
digi.xbee.models.mode.APIOutputModeBit.calculate_api_output_mode_value()
with a set ofdigi.xbee.models.mode.APIOutputModeBit
.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if it is not supported by the current protocol.
-
set_dest_address
(addr)¶ Deprecated.
Operation not supported in this protocol. Use
IPDevice.set_dest_ip_addr()
instead. This method will raise anAttributeError
.
-
set_dest_ip_addr
(address)¶ Sets the destination IP address.
Parameters: address (
ipaddress.IPv4Address
) – Destination IP address.Raises: - ValueError – if
address
isNone
. - TimeoutException – if there is a timeout setting the destination IP address.
- XBeeException – if there is any other XBee related exception.
See also
ipaddress.IPv4Address
- ValueError – if
-
set_dio_change_detection
(io_lines_set)¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
set_dio_value
(io_line, io_value)¶ Sets the digital value (high or low) to the provided IO line.
Parameters: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
set_io_configuration
(io_line, io_mode)¶ Sets the configuration of the provided IO line.
Parameters: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
set_io_sampling_rate
(rate)¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
set_node_id
(node_id)¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
set_pan_id
(value)¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
set_parameter
(param, value)¶ Override.
-
set_power_level
(power_level)¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
set_pwm_duty_cycle
(io_line, cycle)¶ Sets the duty cycle in % of the provided IO line.
The provided IO line must be PWM-capable, previously configured as PWM output.
Parameters: - io_line (
IOLine
) – the IO Line to be assigned. - cycle (Integer) – duty cycle in % to be assigned. Must be between 0 and 100.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- ValueError – if the given IO line does not have PWM capability or
cycle
is not between 0 and 100.
See also
- io_line (
-
set_sync_ops_timeout
(sync_ops_timeout)¶ Sets the serial port read timeout.
Parameters: sync_ops_timeout (Integer) – the read timeout, expressed in seconds.
-
start_listening
(source_port)¶ Starts listening for incoming IP transmissions in the provided port.
Parameters: source_port (Integer) – Port to listen for incoming transmissions.
Raises: - ValueError – if
source_port
is less than 0 or greater than 65535. - TimeoutException – if there is a timeout setting the source port.
- XBeeException – if there is any other XBee related exception.
- ValueError – if
-
stop_listening
()¶ Stops listening for incoming IP transmissions.
Raises: - TimeoutException – if there is a timeout processing the operation.
- XBeeException – if there is any other XBee related exception.
-
update_bluetooth_password
(new_password)¶ Changes the password of this Bluetooth device with the new one provided.
Note that your device must have Bluetooth Low Energy support to use this method.
Parameters: new_password (String) – New Bluetooth password.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
update_device_data_from
(device)¶ Updates the current device reference with the data provided for the given device.
This is only for internal use.
Parameters: device ( AbstractXBeeDevice
) – the XBee device to get the data from.Returns: True
if the device data has been updated,False
otherwise.Return type: Boolean
-
update_firmware
(xml_firmware_file, xbee_firmware_file=None, bootloader_firmware_file=None, timeout=None, progress_callback=None)¶ Performs a firmware update operation of the device.
Parameters: - xml_firmware_file (String) – path of the XML file that describes the firmware to upload.
- xbee_firmware_file (String, optional) – location of the XBee binary firmware file.
- bootloader_firmware_file (String, optional) – location of the bootloader binary firmware file.
- timeout (Integer, optional) – the maximum time to wait for target read operations during the update process.
- progress_callback (Function, optional) –
- function to execute to receive progress information. Receives two
- arguments:
- The current update task as a String
- The current update task percentage as an Integer
Raises: - XBeeException – if the device is not open.
- InvalidOperatingModeException – if the device operating mode is invalid.
- OperationNotSupportedException – if the firmware update is not supported in the XBee device.
- FirmwareUpdateException – if there is any error performing the firmware update.
-
write_changes
()¶ Writes configurable parameter values to the non-volatile memory of the XBee device so that parameter modifications persist through subsequent resets.
Parameters values remain in this device’s memory until overwritten by subsequent use of this method.
If changes are made without writing them to non-volatile memory, the module reverts back to previously saved parameters the next time the module is powered-on.
Writing the parameter modifications does not mean those values are immediately applied, this depends on the status of the ‘apply configuration changes’ option. Use method
is_apply_configuration_changes_enabled()
to get its status andenable_apply_configuration_changes()
to enable/disable the option. If it is disabled, methodapply_changes()
can be used in order to manually apply the changes.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
class
digi.xbee.devices.
NBIoTDevice
(port=None, baud_rate=None, data_bits=<sphinx.ext.autodoc.importer._MockObject object>, stop_bits=<sphinx.ext.autodoc.importer._MockObject object>, parity=<sphinx.ext.autodoc.importer._MockObject object>, flow_control=<FlowControl.NONE: None>, _sync_ops_timeout=4, comm_iface=None)[source]¶ Bases:
digi.xbee.devices.LPWANDevice
This class represents a local NB-IoT device.
Class constructor. Instantiates a new
NBIoTDevice
with the provided parameters.Parameters: - port (Integer or String) – serial port identifier. Integer: number of XBee device, numbering starts at zero. Device name: depending on operating system. e.g. ‘/dev/ttyUSB0’ on ‘GNU/Linux’ or ‘COM3’ on Windows.
- baud_rate (Integer) – the serial port baud rate.
- (Integer, default (_sync_ops_timeout) –
serial.EIGHTBITS
): comm port bitsize. - (Integer, default –
serial.STOPBITS_ONE
): comm port stop bits. - (Character, default (parity) –
serial.PARITY_NONE
): comm port parity. - (Integer, default –
FlowControl.NONE
): comm port flow control. - (Integer, default – 3): the read timeout (in seconds).
- comm_iface (
XBeeCommunicationInterface
) – the communication interface.
:raises All exceptions raised by
XBeeDevice.__init__()
constructor.:See also
LPWANDevice.__init__()
-
open
(force_settings=False)[source]¶ Override.
Raises: - TimeoutException – If there is any problem with the communication.
- InvalidOperatingModeException – If the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- XBeeException – If the protocol is invalid or if the XBee device is already open.
See also
-
add_bluetooth_data_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.BluetoothDataReceived
.Parameters: callback (Function) – the callback. Receives one argument.
- The Bluetooth data as a Bytearray
-
add_data_received_callback
(callback)¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
add_expl_data_received_callback
(callback)¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
add_io_sample_received_callback
(callback)¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
add_ip_data_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.IPDataReceived
.Parameters: callback (Function) – the callback. Receives one argument.
- The data received as an
digi.xbee.models.message.IPMessage
- The data received as an
-
add_micropython_data_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.MicroPythonDataReceived
.Parameters: callback (Function) – the callback. Receives one argument.
- The MicroPython data as a Bytearray
-
add_modem_status_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.ModemStatusReceived
.Parameters: callback (Function) – the callback. Receives one argument.
- The modem status as a
digi.xbee.models.status.ModemStatus
- The modem status as a
-
add_packet_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.PacketReceived
.Parameters: callback (Function) – the callback. Receives two arguments.
- The received packet as a
digi.xbee.packets.base.XBeeAPIPacket
- The received packet as a
-
add_sms_callback
(callback)¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
add_socket_data_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.SocketDataReceived
.Parameters: callback (Function) – the callback. Receives two arguments.
- The socket ID as an Integer.
- The data received as Bytearray
-
add_socket_data_received_from_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.SocketDataReceivedFrom
.Parameters: callback (Function) – the callback. Receives three arguments.
- The socket ID as an Integer.
- A pair (host, port) of the source address where host is a string
- representing an IPv4 address like ‘100.50.200.5’, and port is an integer.
- The data received as Bytearray
-
add_socket_state_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.SocketStateReceived
.Parameters: callback (Function) – the callback. Receives two arguments.
- The socket ID as an Integer.
- The state received as a
SocketState
-
add_user_data_relay_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.RelayDataReceived
.Parameters: callback (Function) – the callback. Receives one argument.
- The relay data as a
digi.xbee.models.message.UserDataRelayMessage
- The relay data as a
-
apply_changes
()¶ Applies changes via
AC
command.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
apply_profile
(profile_path, progress_callback=None)¶ Applies the given XBee profile to the XBee device.
Parameters: - profile_path (String) – path of the XBee profile file to apply.
- progress_callback (Function, optional) –
- function to execute to receive progress information. Receives two
- arguments:
- The current apply profile task as a String
- The current apply profile task percentage as an Integer
Raises: - XBeeException – if the device is not open.
- InvalidOperatingModeException – if the device operating mode is invalid.
- UpdateProfileException – if there is any error applying the XBee profile.
- OperationNotSupportedException – if XBee profiles are not supported in the XBee device.
-
close
()¶ Closes the communication with the XBee device.
This method guarantees that all threads running are stopped and the serial port is closed.
-
comm_iface
¶ Returns the hardware interface associated to the XBee device.
Returns: the hardware interface associated to the XBee device. Return type: XBeeCommunicationInterface
See also
-
classmethod
create_xbee_device
(comm_port_data)¶ Creates and returns an
XBeeDevice
from data of the port to which is connected.Parameters: - comm_port_data (Dictionary) – dictionary with all comm port data needed.
- dictionary keys are (The) – “baudRate” –> Baud rate.”port” –> Port number.”bitSize” –> Bit size.”stopBits” –> Stop bits.”parity” –> Parity.”flowControl” –> Flow control.”timeout” for –> Timeout for synchronous operations (in seconds).
Returns: the XBee device created.
Return type: Raises: SerialException – if the port you want to open does not exist or is already opened.
See also
-
del_bluetooth_data_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.BluetoothDataReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.BluetoothDataReceived
event.
-
del_data_received_callback
(callback)¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
del_expl_data_received_callback
(callback)¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
del_io_sample_received_callback
(callback)¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
del_ip_data_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.IPDataReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.IPDataReceived
event.
-
del_micropython_data_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.MicroPythonDataReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.MicroPythonDataReceived
event.
-
del_modem_status_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.ModemStatusReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.ModemStatusReceived
event.
-
del_packet_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.PacketReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.PacketReceived
event.
-
del_sms_callback
(callback)¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
del_socket_data_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.SocketDataReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.SocketDataReceived
event.
-
del_socket_data_received_from_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.SocketDataReceivedFrom
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.SocketDataReceivedFrom
event.
-
del_socket_state_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.SocketStateReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.SocketStateReceived
event.
-
del_user_data_relay_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.RelayDataReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.RelayDataReceived
event.
-
disable_bluetooth
()¶ Disables the Bluetooth interface of this XBee device.
Note that your device must have Bluetooth Low Energy support to use this method.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
enable_apply_changes
(value)¶ Sets the apply_changes flag.
Parameters: value (Boolean) – True
to enable the apply changes flag,False
to disable it.
-
enable_bluetooth
()¶ Enables the Bluetooth interface of this XBee device.
To work with this interface, you must also configure the Bluetooth password if not done previously. You can use the
AbstractXBeeDevice.update_bluetooth_password()
method for that purpose.Note that your device must have Bluetooth Low Energy support to use this method.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
execute_command
(parameter)¶ Executes the provided command.
Parameters: parameter (String) – The name of the AT command to be executed.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
flush_queues
()¶ Flushes the packets queue.
-
get_16bit_addr
()¶ Deprecated.
This protocol does not have an associated 16-bit address.
-
get_64bit_addr
()¶ Deprecated.
Cellular protocol does not have an associated 64-bit address.
-
get_adc_value
(io_line)¶ Returns the analog value of the provided IO line.
The provided IO line must be previously configured as ADC. To do so, use
AbstractXBeeDevice.set_io_configuration()
andIOMode.ADC
.Parameters: io_line (
IOLine
) – the IO line to get its ADC value.Returns: the analog value corresponding to the provided IO line.
Return type: Integer
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the response does not contain the value for the given IO line.
See also
-
get_api_output_mode
()¶ Deprecated since version 1.3: Use
get_api_output_mode_value()
Returns the API output mode of the XBee device.
The API output mode determines the format that the received data is output through the serial interface of the XBee device.
Returns: the API output mode of the XBee device.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
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 the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- 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 device in a format such as
00112233AABB
.Note that your device must have Bluetooth Low Energy support to use this method.
Returns: The Bluetooth MAC address.
Return type: String
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
get_cellular_ai_status
()¶ Returns the current association status of this Cellular device.
It indicates occurrences of errors during the modem initialization and connection.
Returns: The association indication status of the Cellular device.
Return type: Raises: - TimeoutException – if there is a timeout getting the association indication status.
- XBeeException – if there is any other XBee related exception.
-
get_current_frame_id
()¶ Returns the last used frame ID.
Returns: the last used frame ID. Return type: Integer
-
get_dest_address
()¶ Deprecated.
Operation not supported in this protocol. Use
IPDevice.get_dest_ip_addr()
instead. This method will raise anAttributeError
.
-
get_dest_ip_addr
()¶ Returns the destination IP address.
Returns: The configured destination IP address.
Return type: ipaddress.IPv4Address
Raises: - TimeoutException – if there is a timeout getting the destination IP address.
- XBeeException – if there is any other XBee related exception.
See also
ipaddress.IPv4Address
-
get_dio_value
(io_line)¶ Returns the digital value of the provided IO line.
The provided IO line must be previously configured as digital I/O. To do so, use
AbstractXBeeDevice.set_io_configuration()
.Parameters: io_line (
IOLine
) – the DIO line to gets its digital value.Returns: current value of the provided IO line.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the response does not contain the value for the given IO line.
-
get_firmware_version
()¶ Returns the firmware version of the XBee device.
Returns: the hardware version of the XBee device. Return type: Bytearray
-
get_hardware_version
()¶ Returns the hardware version of the XBee device.
Returns: the hardware version of the XBee device. Return type: HardwareVersion
See also
-
get_imei_addr
()¶ Returns the IMEI address of this Cellular device.
To refresh this value use the method
CellularDevice.read_device_info()
.Returns: The IMEI address of this Cellular device. Return type: XBeeIMEIAddress
-
get_io_configuration
(io_line)¶ Returns the configuration of the provided IO line.
Parameters: io_line (
IOLine
) – the io line to configure.Returns: the IO mode of the IO line provided.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the received data is not an IO mode.
-
get_io_sampling_rate
()¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
get_ip_addr
()¶ Returns the IP address of this IP device.
To refresh this value use the method
IPDevice.read_device_info()
.Returns: The IP address of this IP device. Return type: ipaddress.IPv4Address
See also
ipaddress.IPv4Address
-
get_network
()¶ Deprecated.
This protocol does not support the network functionality.
-
get_next_frame_id
()¶ Returns the next frame ID of the XBee device.
Returns: The next frame ID of the XBee device. Return type: Integer
-
get_node_id
()¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
get_pan_id
()¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
get_parameter
(param, parameter_value=None)¶ Override.
See also
-
get_power_level
()¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
get_pwm_duty_cycle
(io_line)¶ Returns the PWM duty cycle in % corresponding to the provided IO line.
Parameters: io_line (
IOLine
) – the IO line to get its PWM duty cycle.Returns: the PWM duty cycle of the given IO line or
None
if the response is empty.Return type: Integer
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- ValueError – if the passed
IO_LINE
has no PWM capability.
See also
-
get_role
()¶ Gets the XBee role.
Returns: the role of the XBee. Return type: digi.xbee.models.protocol.Role
See also
-
get_socket_info
(socket_id)¶ Returns the information of the socket with the given socket ID.
Parameters: socket_id (Integer) – ID of the socket.
Returns: The socket information, or
None
if the socket with that ID does not exist.Return type: SocketInfo
Raises: - InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
See also
SocketInfo
-
get_sockets_list
()¶ Returns a list with the IDs of all active (open) sockets.
Returns: list with the IDs of all active (open) sockets, or empty list if there is not any active socket.
Return type: List
Raises: - InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
-
get_sync_ops_timeout
()¶ Returns the serial port read timeout.
Returns: the serial port read timeout in seconds. Return type: Integer
-
get_xbee_device_callbacks
()¶ Returns this XBee internal callbacks for process received packets.
This method is called by the PacketListener associated with this XBee to get its callbacks. These callbacks will be executed before user callbacks.
Returns: PacketReceived
-
has_explicit_packets
()¶ Returns whether the XBee device’s queue has explicit packets or not. This do not include non-explicit packets.
Returns: True
if this XBee device’s queue has explicit packets,False
otherwise.Return type: Boolean See also
-
has_packets
()¶ Returns whether the XBee device’s queue has packets or not. This do not include explicit packets.
Returns: True
if this XBee device’s queue has packets,False
otherwise.Return type: Boolean See also
-
is_apply_changes_enabled
()¶ Returns whether the apply_changes flag is enabled or not.
Returns: True
if the apply_changes flag is enabled,False
otherwise.Return type: Boolean
-
is_connected
()¶ Returns whether the device is connected to the Internet or not.
Returns: True
if the device is connected to the Internet,False
otherwise.Return type: Boolean
Raises: - TimeoutException – if there is a timeout getting the association indication status.
- XBeeException – if there is any other XBee related exception.
-
is_open
()¶ Returns whether this XBee device is open or not.
Returns: Boolean. True
if this XBee device is open,False
otherwise.
-
is_remote
()¶ Override method.
See also
-
log
¶ Returns the XBee device log.
Returns: the XBee device logger. Return type: Logger
-
operating_mode
¶ Returns this XBee device’s operating mode.
Returns: OperatingMode
. This XBee device’s operating mode.
-
read_data
(timeout=None, explicit=False)¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
read_data_from
(remote_xbee_device, timeout=None, explicit=False)¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
read_device_info
(init=True)¶ Override.
See also
XBeeDevice.read_device _info()
-
read_io_sample
()¶ Returns an IO sample from the XBee device containing the value of all enabled digital IO and analog input channels.
Returns: the IO sample read from the XBee device.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
See also
-
read_ip_data
(timeout=3)¶ Reads new IP data received by this XBee device during the provided timeout.
This method blocks until new IP data is received or the provided timeout expires.
For non-blocking operations, register a callback and use the method
IPDevice.add_ip_data_received_callback()
.Before reading IP data you need to start listening for incoming IP data at a specific port. Use the method
IPDevice.start_listening()
for that purpose. When finished, you can use the methodIPDevice.stop_listening()
to stop listening for incoming IP data.Parameters: timeout (Integer, optional) – The time to wait for new IP data in seconds. Returns: IP message, None
if this device did not receive new data.Return type: IPMessage
Raises: ValueError – if timeout
is less than 0.
-
read_ip_data_from
(ip_addr, timeout=3)¶ Reads new IP data received from the given IP address during the provided timeout.
This method blocks until new IP data from the provided IP address is received or the given timeout expires.
For non-blocking operations, register a callback and use the method
IPDevice.add_ip_data_received_callback()
.Before reading IP data you need to start listening for incoming IP data at a specific port. Use the method
IPDevice.start_listening()
for that purpose. When finished, you can use the methodIPDevice.stop_listening()
to stop listening for incoming IP data.Parameters: - ip_addr (
ipaddress.IPv4Address
) – The IP address to read data from. - timeout (Integer, optional) – The time to wait for new IP data in seconds.
Returns: - IP message,
None
if this device did not receive new data from the provided IP address.
Return type: Raises: ValueError – if
timeout
is less than 0.- ip_addr (
-
reset
()¶ Override method.
See also
-
send_bluetooth_data
(data)¶ Sends the given data to the Bluetooth interface using a User Data Relay frame.
Parameters: data (Bytearray) – Data to send.
Raises: - InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- XBeeException – if there is any problem sending the data.
-
send_data
(remote_xbee_device, data, transmit_options=0)¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
send_data_async
(remote_xbee_device, data, transmit_options=0)¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
send_data_broadcast
(data, transmit_options=0)¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
send_ip_data
(ip_addr, dest_port, protocol, data, close_socket=False)¶ Sends the provided IP data to the given IP address and port using the specified IP protocol.
This method blocks till a success or error response arrives or the configured receive timeout expires.
Parameters: - ip_addr (
ipaddress.IPv4Address
) – The IP address to send IP data to. - dest_port (Integer) – The destination port of the transmission.
- protocol (
IPProtocol
) – The IP protocol used for the transmission. - data (String or Bytearray) – The IP data to be sent.
- close_socket (Boolean, optional) – Must be
False
.
Raises: ValueError – if
protocol
is not UDP.- ip_addr (
-
send_ip_data_async
(ip_addr, dest_port, protocol, data, close_socket=False)¶ Sends the provided IP data to the given IP address and port asynchronously using the specified IP protocol.
Asynchronous transmissions do not wait for answer from the remote device or for transmit status packet.
Parameters: - ip_addr (
ipaddress.IPv4Address
) – The IP address to send IP data to. - dest_port (Integer) – The destination port of the transmission.
- protocol (
IPProtocol
) – The IP protocol used for the transmission. - data (String or Bytearray) – The IP data to be sent.
- close_socket (Boolean, optional) – Must be
False
.
Raises: ValueError – if
protocol
is not UDP.- ip_addr (
-
send_ip_data_broadcast
(dest_port, data)¶ Sends the provided IP data to all clients.
This method blocks till a success or error transmit status arrives or the configured receive timeout expires.
Parameters: - dest_port (Integer) – The destination port of the transmission.
- data (String or Bytearray) – The IP data to be sent.
Raises: - ValueError – if
data
isNone
. - ValueError – if
dest_port
is less than 0 or greater than 65535. - TimeoutException – if there is a timeout sending the data.
- XBeeException – if there is any other XBee related exception.
-
send_micropython_data
(data)¶ Sends the given data to the MicroPython interface using a User Data Relay frame.
Parameters: data (Bytearray) – Data to send.
Raises: - InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- XBeeException – if there is any problem sending the data.
-
send_packet
(packet, sync=False)¶ Override method.
See also
AbstractXBeeDevice._send_packet()
-
send_packet_sync_and_get_response
(packet_to_send, timeout=None)¶ Override method.
See also
AbstractXBeeDevice._send_packet_sync_and_get_response()
-
send_sms
(phone_number, data)¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
send_sms_async
(phone_number, data)¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
send_user_data_relay
(local_interface, data)¶ Sends the given data to the given XBee local interface.
Parameters: - local_interface (
XBeeLocalInterface
) – Destination XBee local interface. - data (Bytearray) – Data to send.
Raises: - InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ValueError – if
local_interface
isNone
. - XBeeException – if there is any problem sending the User Data Relay.
See also
- local_interface (
-
serial_port
¶ Returns the serial port associated to the XBee device, if any.
Returns: - the serial port associated to the XBee device. Returns
None
if the local XBee - does not use serial communication.
Return type: XBeeSerialPort
See also
- the serial port associated to the XBee device. Returns
-
set_16bit_addr
(value)¶ Sets the 16-bit address of the XBee device.
Parameters: value (
XBee16BitAddress
) – the new 16-bit address of the XBee device.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the current 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 device.
Parameters: api_output_mode (
APIOutputMode
) – the new API output mode of the XBee device.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the current protocol is ZigBee
See also
-
set_api_output_mode_value
(api_output_mode)¶ Sets the API output mode of the XBee.
Parameters: api_output_mode (Integer) – new API output mode options. Calculate this value using the method
digi.xbee.models.mode.APIOutputModeBit.calculate_api_output_mode_value()
with a set ofdigi.xbee.models.mode.APIOutputModeBit
.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if it is not supported by the current protocol.
-
set_dest_address
(addr)¶ Deprecated.
Operation not supported in this protocol. Use
IPDevice.set_dest_ip_addr()
instead. This method will raise anAttributeError
.
-
set_dest_ip_addr
(address)¶ Sets the destination IP address.
Parameters: address (
ipaddress.IPv4Address
) – Destination IP address.Raises: - ValueError – if
address
isNone
. - TimeoutException – if there is a timeout setting the destination IP address.
- XBeeException – if there is any other XBee related exception.
See also
ipaddress.IPv4Address
- ValueError – if
-
set_dio_change_detection
(io_lines_set)¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
set_dio_value
(io_line, io_value)¶ Sets the digital value (high or low) to the provided IO line.
Parameters: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
set_io_configuration
(io_line, io_mode)¶ Sets the configuration of the provided IO line.
Parameters: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
set_io_sampling_rate
(rate)¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
set_node_id
(node_id)¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
set_pan_id
(value)¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
set_parameter
(param, value)¶ Override.
-
set_power_level
(power_level)¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
set_pwm_duty_cycle
(io_line, cycle)¶ Sets the duty cycle in % of the provided IO line.
The provided IO line must be PWM-capable, previously configured as PWM output.
Parameters: - io_line (
IOLine
) – the IO Line to be assigned. - cycle (Integer) – duty cycle in % to be assigned. Must be between 0 and 100.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- ValueError – if the given IO line does not have PWM capability or
cycle
is not between 0 and 100.
See also
- io_line (
-
set_sync_ops_timeout
(sync_ops_timeout)¶ Sets the serial port read timeout.
Parameters: sync_ops_timeout (Integer) – the read timeout, expressed in seconds.
-
start_listening
(source_port)¶ Starts listening for incoming IP transmissions in the provided port.
Parameters: source_port (Integer) – Port to listen for incoming transmissions.
Raises: - ValueError – if
source_port
is less than 0 or greater than 65535. - TimeoutException – if there is a timeout setting the source port.
- XBeeException – if there is any other XBee related exception.
- ValueError – if
-
stop_listening
()¶ Stops listening for incoming IP transmissions.
Raises: - TimeoutException – if there is a timeout processing the operation.
- XBeeException – if there is any other XBee related exception.
-
update_bluetooth_password
(new_password)¶ Changes the password of this Bluetooth device with the new one provided.
Note that your device must have Bluetooth Low Energy support to use this method.
Parameters: new_password (String) – New Bluetooth password.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
update_device_data_from
(device)¶ Updates the current device reference with the data provided for the given device.
This is only for internal use.
Parameters: device ( AbstractXBeeDevice
) – the XBee device to get the data from.Returns: True
if the device data has been updated,False
otherwise.Return type: Boolean
-
update_firmware
(xml_firmware_file, xbee_firmware_file=None, bootloader_firmware_file=None, timeout=None, progress_callback=None)¶ Performs a firmware update operation of the device.
Parameters: - xml_firmware_file (String) – path of the XML file that describes the firmware to upload.
- xbee_firmware_file (String, optional) – location of the XBee binary firmware file.
- bootloader_firmware_file (String, optional) – location of the bootloader binary firmware file.
- timeout (Integer, optional) – the maximum time to wait for target read operations during the update process.
- progress_callback (Function, optional) –
- function to execute to receive progress information. Receives two
- arguments:
- The current update task as a String
- The current update task percentage as an Integer
Raises: - XBeeException – if the device is not open.
- InvalidOperatingModeException – if the device operating mode is invalid.
- OperationNotSupportedException – if the firmware update is not supported in the XBee device.
- FirmwareUpdateException – if there is any error performing the firmware update.
-
write_changes
()¶ Writes configurable parameter values to the non-volatile memory of the XBee device so that parameter modifications persist through subsequent resets.
Parameters values remain in this device’s memory until overwritten by subsequent use of this method.
If changes are made without writing them to non-volatile memory, the module reverts back to previously saved parameters the next time the module is powered-on.
Writing the parameter modifications does not mean those values are immediately applied, this depends on the status of the ‘apply configuration changes’ option. Use method
is_apply_configuration_changes_enabled()
to get its status andenable_apply_configuration_changes()
to enable/disable the option. If it is disabled, methodapply_changes()
can be used in order to manually apply the changes.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
class
digi.xbee.devices.
WiFiDevice
(port=None, baud_rate=None, data_bits=<sphinx.ext.autodoc.importer._MockObject object>, stop_bits=<sphinx.ext.autodoc.importer._MockObject object>, parity=<sphinx.ext.autodoc.importer._MockObject object>, flow_control=<FlowControl.NONE: None>, _sync_ops_timeout=4, comm_iface=None)[source]¶ Bases:
digi.xbee.devices.IPDevice
This class represents a local Wi-Fi XBee device.
Class constructor. Instantiates a new
WiFiDevice
with the provided parameters.Parameters: - port (Integer or String) – serial port identifier. Integer: number of XBee device, numbering starts at zero. Device name: depending on operating system. e.g. ‘/dev/ttyUSB0’ on ‘GNU/Linux’ or ‘COM3’ on Windows.
- baud_rate (Integer) – the serial port baud rate.
- (Integer, default (_sync_ops_timeout) –
serial.EIGHTBITS
): comm port bitsize. - (Integer, default –
serial.STOPBITS_ONE
): comm port stop bits. - (Character, default (parity) –
serial.PARITY_NONE
): comm port parity. - (Integer, default –
FlowControl.NONE
): comm port flow control. - (Integer, default – 3): the read timeout (in seconds).
- comm_iface (
XBeeCommunicationInterface
) – the communication interface.
:raises All exceptions raised by
XBeeDevice.__init__()
constructor.:See also
v.__init__()
-
open
(force_settings=False)[source]¶ Override.
Raises: - TimeoutException – If there is any problem with the communication.
- InvalidOperatingModeException – If the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- XBeeException – If the protocol is invalid or if the XBee device is already open.
See also
-
get_wifi_ai_status
()[source]¶ Returns the current association status of the device.
Returns: the current association status of the device.
Return type: Raises: - TimeoutException – if there is a timeout getting the association indication status.
- XBeeException – if there is any other XBee related exception.
See also
-
get_access_point
(ssid)[source]¶ Finds and returns the access point that matches the supplied SSID.
Parameters: ssid (String) – the SSID of the access point to get.
Returns: - the discovered access point with the provided SSID, or
None
if the timeout expires and the access point was not found.
Return type: Raises: - TimeoutException – if there is a timeout getting the access point.
- XBeeException – if there is an error sending the discovery command.
See also
- the discovered access point with the provided SSID, or
-
scan_access_points
()[source]¶ Performs a scan to search for access points in the vicinity.
This method blocks until all the access points are discovered or the configured access point timeout expires.
The access point timeout is configured using the
WiFiDevice.set_access_point_timeout()
method and can be consulted withWiFiDevice.get_access_point_timeout()
method.Returns: the list of
AccessPoint
objects discovered.Return type: List
Raises: - TimeoutException – if there is a timeout scanning the access points.
- XBeeException – if there is any other XBee related exception.
See also
-
connect_by_ap
(access_point, password=None)[source]¶ Connects to the provided access point.
This method blocks until the connection with the access point is established or the configured access point timeout expires.
The access point timeout is configured using the
WiFiDevice.set_access_point_timeout()
method and can be consulted withWiFiDevice.get_access_point_timeout()
method.Once the module is connected to the access point, you can issue the
WiFiDevice.write_changes()
method to save the connection settings. This way the module will try to connect to the access point every time it is powered on.Parameters: - access_point (
AccessPoint
) – The access point to connect to. - password (String, optional) – The password for the access point,
None
if it does not have any encryption enabled. Optional.
Returns: True
if the module connected to the access point successfully,False
otherwise.Return type: Boolean
Raises: - ValueError – if
access_point
isNone
. - TimeoutException – if there is a timeout sending the connect commands.
- XBeeException – if there is any other XBee related exception.
- access_point (
-
connect_by_ssid
(ssid, password=None)[source]¶ Connects to the access point with provided SSID.
This method blocks until the connection with the access point is established or the configured access point timeout expires.
The access point timeout is configured using the
WiFiDevice.set_access_point_timeout()
method and can be consulted withWiFiDevice.get_access_point_timeout()
method.Once the module is connected to the access point, you can issue the
WiFiDevice.write_changes()
method to save the connection settings. This way the module will try to connect to the access point every time it is powered on.Parameters: - ssid (String) – the SSID of the access point to connect to.
- password (String, optional) – The password for the access point,
None
if it does not have any encryption enabled. Optional.
Returns: True
if the module connected to the access point successfully,False
otherwise.Return type: Boolean
Raises: - ValueError – if
ssid
isNone
. - TimeoutException – if there is a timeout sending the connect commands.
- XBeeException – if the access point with the provided SSID cannot be found.
- XBeeException – if there is any other XBee related exception.
-
disconnect
()[source]¶ Disconnects from the access point that the device is connected to.
This method blocks until the device disconnects totally from the access point or the configured access point timeout expires.
The access point timeout is configured using the
WiFiDevice.set_access_point_timeout()
method and can be consulted withWiFiDevice.get_access_point_timeout()
method.Returns: True
if the module disconnected from the access point successfully,False
otherwise.Return type: Boolean
Raises: - TimeoutException – if there is a timeout sending the disconnect command.
- XBeeException – if there is any other XBee related exception.
-
is_connected
()[source]¶ Returns whether the device is connected to an access point or not.
Returns: True
if the device is connected to an access point,False
otherwise.Return type: Boolean Raises: TimeoutException – if there is a timeout getting the association indication status.
-
get_access_point_timeout
()[source]¶ Returns the configured access point timeout for connecting, disconnecting and scanning access points.
Returns: the current access point timeout in milliseconds. Return type: Integer
-
set_access_point_timeout
(ap_timeout)[source]¶ Configures the access point timeout in milliseconds for connecting, disconnecting and scanning access points.
Parameters: ap_timeout (Integer) – the new access point timeout in milliseconds. Raises: ValueError – if ap_timeout
is less than 0.
-
get_ip_addressing_mode
()[source]¶ Returns the IP addressing mode of the device.
Returns: the IP addressing mode. Return type: IPAddressingMode
Raises: TimeoutException – if there is a timeout reading the IP addressing mode.
-
set_ip_addressing_mode
(mode)[source]¶ Sets the IP addressing mode of the device.
Parameters: mode ( IPAddressingMode
) – the new IP addressing mode to set.Raises: TimeoutException – if there is a timeout setting the IP addressing mode.
-
set_ip_address
(ip_address)[source]¶ Sets the IP address of the module.
This method can only be called if the module is configured in
IPAddressingMode.STATIC
mode. Otherwise anXBeeException
will be thrown.Parameters: ip_address ( ipaddress.IPv4Address
) – the new IP address to set.Raises: TimeoutException – if there is a timeout setting the IP address. See also
ipaddress.IPv4Address
-
get_mask_address
()[source]¶ Returns the subnet mask IP address.
Returns: the subnet mask IP address. Return type: ipaddress.IPv4Address
Raises: TimeoutException – if there is a timeout reading the subnet mask address. See also
ipaddress.IPv4Address
-
set_mask_address
(mask_address)[source]¶ Sets the subnet mask IP address.
This method can only be called if the module is configured in
IPAddressingMode.STATIC
mode. Otherwise anXBeeException
will be thrown.Parameters: mask_address ( ipaddress.IPv4Address
) – the new subnet mask address to set.Raises: TimeoutException – if there is a timeout setting the subnet mask address. See also
ipaddress.IPv4Address
-
get_gateway_address
()[source]¶ Returns the IP address of the gateway.
Returns: the IP address of the gateway. Return type: ipaddress.IPv4Address
Raises: TimeoutException – if there is a timeout reading the gateway address. See also
ipaddress.IPv4Address
-
set_gateway_address
(gateway_address)[source]¶ Sets the IP address of the gateway.
This method can only be called if the module is configured in
IPAddressingMode.STATIC
mode. Otherwise anXBeeException
will be thrown.Parameters: gateway_address ( ipaddress.IPv4Address
) – the new gateway address to set.Raises: TimeoutException – if there is a timeout setting the gateway address. See also
ipaddress.IPv4Address
-
get_dns_address
()[source]¶ Returns the IP address of Domain Name Server (DNS).
Returns: the DNS address configured. Return type: ipaddress.IPv4Address
Raises: TimeoutException – if there is a timeout reading the DNS address. See also
ipaddress.IPv4Address
-
set_dns_address
(dns_address)[source]¶ Sets the IP address of Domain Name Server (DNS).
Parameters: dns_address ( ipaddress.IPv4Address
) – the new DNS address to set.Raises: TimeoutException – if there is a timeout setting the DNS address. See also
ipaddress.IPv4Address
-
add_bluetooth_data_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.BluetoothDataReceived
.Parameters: callback (Function) – the callback. Receives one argument.
- The Bluetooth data as a Bytearray
-
add_data_received_callback
(callback)¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
add_expl_data_received_callback
(callback)¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
add_io_sample_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.IOSampleReceived
.Parameters: callback (Function) – the callback. Receives three arguments.
- The received IO sample as an
digi.xbee.io.IOSample
- The remote XBee device who has sent the packet as a
RemoteXBeeDevice
- The time in which the packet was received as an Integer
- The received IO sample as an
-
add_ip_data_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.IPDataReceived
.Parameters: callback (Function) – the callback. Receives one argument.
- The data received as an
digi.xbee.models.message.IPMessage
- The data received as an
-
add_micropython_data_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.MicroPythonDataReceived
.Parameters: callback (Function) – the callback. Receives one argument.
- The MicroPython data as a Bytearray
-
add_modem_status_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.ModemStatusReceived
.Parameters: callback (Function) – the callback. Receives one argument.
- The modem status as a
digi.xbee.models.status.ModemStatus
- The modem status as a
-
add_packet_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.PacketReceived
.Parameters: callback (Function) – the callback. Receives two arguments.
- The received packet as a
digi.xbee.packets.base.XBeeAPIPacket
- The received packet as a
-
add_socket_data_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.SocketDataReceived
.Parameters: callback (Function) – the callback. Receives two arguments.
- The socket ID as an Integer.
- The data received as Bytearray
-
add_socket_data_received_from_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.SocketDataReceivedFrom
.Parameters: callback (Function) – the callback. Receives three arguments.
- The socket ID as an Integer.
- A pair (host, port) of the source address where host is a string
- representing an IPv4 address like ‘100.50.200.5’, and port is an integer.
- The data received as Bytearray
-
add_socket_state_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.SocketStateReceived
.Parameters: callback (Function) – the callback. Receives two arguments.
- The socket ID as an Integer.
- The state received as a
SocketState
-
add_user_data_relay_received_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.RelayDataReceived
.Parameters: callback (Function) – the callback. Receives one argument.
- The relay data as a
digi.xbee.models.message.UserDataRelayMessage
- The relay data as a
-
apply_changes
()¶ Applies changes via
AC
command.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
apply_profile
(profile_path, progress_callback=None)¶ Applies the given XBee profile to the XBee device.
Parameters: - profile_path (String) – path of the XBee profile file to apply.
- progress_callback (Function, optional) –
- function to execute to receive progress information. Receives two
- arguments:
- The current apply profile task as a String
- The current apply profile task percentage as an Integer
Raises: - XBeeException – if the device is not open.
- InvalidOperatingModeException – if the device operating mode is invalid.
- UpdateProfileException – if there is any error applying the XBee profile.
- OperationNotSupportedException – if XBee profiles are not supported in the XBee device.
-
close
()¶ Closes the communication with the XBee device.
This method guarantees that all threads running are stopped and the serial port is closed.
-
comm_iface
¶ Returns the hardware interface associated to the XBee device.
Returns: the hardware interface associated to the XBee device. Return type: XBeeCommunicationInterface
See also
-
classmethod
create_xbee_device
(comm_port_data)¶ Creates and returns an
XBeeDevice
from data of the port to which is connected.Parameters: - comm_port_data (Dictionary) – dictionary with all comm port data needed.
- dictionary keys are (The) – “baudRate” –> Baud rate.”port” –> Port number.”bitSize” –> Bit size.”stopBits” –> Stop bits.”parity” –> Parity.”flowControl” –> Flow control.”timeout” for –> Timeout for synchronous operations (in seconds).
Returns: the XBee device created.
Return type: Raises: SerialException – if the port you want to open does not exist or is already opened.
See also
-
del_bluetooth_data_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.BluetoothDataReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.BluetoothDataReceived
event.
-
del_data_received_callback
(callback)¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
del_expl_data_received_callback
(callback)¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
del_io_sample_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.IOSampleReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.IOSampleReceived
event.
-
del_ip_data_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.IPDataReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.IPDataReceived
event.
-
del_micropython_data_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.MicroPythonDataReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.MicroPythonDataReceived
event.
-
del_modem_status_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.ModemStatusReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.ModemStatusReceived
event.
-
del_packet_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.PacketReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.PacketReceived
event.
-
del_socket_data_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.SocketDataReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.SocketDataReceived
event.
-
del_socket_data_received_from_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.SocketDataReceivedFrom
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.SocketDataReceivedFrom
event.
-
del_socket_state_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.SocketStateReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.SocketStateReceived
event.
-
del_user_data_relay_received_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.RelayDataReceived
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofdigi.xbee.reader.RelayDataReceived
event.
-
disable_bluetooth
()¶ Disables the Bluetooth interface of this XBee device.
Note that your device must have Bluetooth Low Energy support to use this method.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
enable_apply_changes
(value)¶ Sets the apply_changes flag.
Parameters: value (Boolean) – True
to enable the apply changes flag,False
to disable it.
-
enable_bluetooth
()¶ Enables the Bluetooth interface of this XBee device.
To work with this interface, you must also configure the Bluetooth password if not done previously. You can use the
AbstractXBeeDevice.update_bluetooth_password()
method for that purpose.Note that your device must have Bluetooth Low Energy support to use this method.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
execute_command
(parameter)¶ Executes the provided command.
Parameters: parameter (String) – The name of the AT command to be executed.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
flush_queues
()¶ Flushes the packets queue.
-
get_16bit_addr
()¶ Deprecated.
This protocol does not have an associated 16-bit address.
-
get_64bit_addr
()¶ Returns the 64-bit address of the XBee device.
Returns: the 64-bit address of the XBee device. Return type: XBee64BitAddress
See also
-
get_adc_value
(io_line)¶ Returns the analog value of the provided IO line.
The provided IO line must be previously configured as ADC. To do so, use
AbstractXBeeDevice.set_io_configuration()
andIOMode.ADC
.Parameters: io_line (
IOLine
) – the IO line to get its ADC value.Returns: the analog value corresponding to the provided IO line.
Return type: Integer
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the response does not contain the value for the given IO line.
See also
-
get_api_output_mode
()¶ Deprecated since version 1.3: Use
get_api_output_mode_value()
Returns the API output mode of the XBee device.
The API output mode determines the format that the received data is output through the serial interface of the XBee device.
Returns: the API output mode of the XBee device.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
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 the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- 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 device in a format such as
00112233AABB
.Note that your device must have Bluetooth Low Energy support to use this method.
Returns: The Bluetooth MAC address.
Return type: String
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
get_current_frame_id
()¶ Returns the last used frame ID.
Returns: the last used frame ID. Return type: Integer
-
get_dest_address
()¶ Deprecated.
Operation not supported in this protocol. Use
IPDevice.get_dest_ip_addr()
instead. This method will raise anAttributeError
.
-
get_dest_ip_addr
()¶ Returns the destination IP address.
Returns: The configured destination IP address.
Return type: ipaddress.IPv4Address
Raises: - TimeoutException – if there is a timeout getting the destination IP address.
- XBeeException – if there is any other XBee related exception.
See also
ipaddress.IPv4Address
-
get_dio_value
(io_line)¶ Returns the digital value of the provided IO line.
The provided IO line must be previously configured as digital I/O. To do so, use
AbstractXBeeDevice.set_io_configuration()
.Parameters: io_line (
IOLine
) – the DIO line to gets its digital value.Returns: current value of the provided IO line.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the response does not contain the value for the given IO line.
-
get_firmware_version
()¶ Returns the firmware version of the XBee device.
Returns: the hardware version of the XBee device. Return type: Bytearray
-
get_hardware_version
()¶ Returns the hardware version of the XBee device.
Returns: the hardware version of the XBee device. Return type: HardwareVersion
See also
-
get_io_configuration
(io_line)¶ Returns the configuration of the provided IO line.
Parameters: io_line (
IOLine
) – the io line to configure.Returns: the IO mode of the IO line provided.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the received data is not an IO mode.
-
get_io_sampling_rate
()¶ Returns the IO sampling rate of the XBee device.
Returns: the IO sampling rate of XBee device.
Return type: Integer
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
get_ip_addr
()¶ Returns the IP address of this IP device.
To refresh this value use the method
IPDevice.read_device_info()
.Returns: The IP address of this IP device. Return type: ipaddress.IPv4Address
See also
ipaddress.IPv4Address
-
get_network
()¶ Deprecated.
This protocol does not support the network functionality.
-
get_next_frame_id
()¶ Returns the next frame ID of the XBee device.
Returns: The next frame ID of the XBee device. Return type: Integer
-
get_node_id
()¶ Returns the Node Identifier (
NI
) value of the XBee device.Returns: the Node Identifier ( NI
) of the XBee device.Return type: String
-
get_pan_id
()¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
get_parameter
(param, parameter_value=None)¶ Override.
See also
-
get_power_level
()¶ Returns the power level of the XBee device.
Returns: the power level of the XBee device. Return type: PowerLevel
Raises: TimeoutException – if the response is not received before the read timeout expires. See also
-
get_pwm_duty_cycle
(io_line)¶ Returns the PWM duty cycle in % corresponding to the provided IO line.
Parameters: io_line (
IOLine
) – the IO line to get its PWM duty cycle.Returns: the PWM duty cycle of the given IO line or
None
if the response is empty.Return type: Integer
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- ValueError – if the passed
IO_LINE
has no PWM capability.
See also
-
get_role
()¶ Gets the XBee role.
Returns: the role of the XBee. Return type: digi.xbee.models.protocol.Role
See also
-
get_sync_ops_timeout
()¶ Returns the serial port read timeout.
Returns: the serial port read timeout in seconds. Return type: Integer
-
get_xbee_device_callbacks
()¶ Returns this XBee internal callbacks for process received packets.
This method is called by the PacketListener associated with this XBee to get its callbacks. These callbacks will be executed before user callbacks.
Returns: PacketReceived
-
has_explicit_packets
()¶ Returns whether the XBee device’s queue has explicit packets or not. This do not include non-explicit packets.
Returns: True
if this XBee device’s queue has explicit packets,False
otherwise.Return type: Boolean See also
-
has_packets
()¶ Returns whether the XBee device’s queue has packets or not. This do not include explicit packets.
Returns: True
if this XBee device’s queue has packets,False
otherwise.Return type: Boolean See also
-
is_apply_changes_enabled
()¶ Returns whether the apply_changes flag is enabled or not.
Returns: True
if the apply_changes flag is enabled,False
otherwise.Return type: Boolean
-
is_open
()¶ Returns whether this XBee device is open or not.
Returns: Boolean. True
if this XBee device is open,False
otherwise.
-
is_remote
()¶ Override method.
See also
-
log
¶ Returns the XBee device log.
Returns: the XBee device logger. Return type: Logger
-
operating_mode
¶ Returns this XBee device’s operating mode.
Returns: OperatingMode
. This XBee device’s operating mode.
-
read_data
(timeout=None, explicit=False)¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
read_data_from
(remote_xbee_device, timeout=None, explicit=False)¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
read_device_info
(init=True)¶ Override.
-
read_io_sample
()¶ Returns an IO sample from the XBee device containing the value of all enabled digital IO and analog input channels.
Returns: the IO sample read from the XBee device.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
See also
-
read_ip_data
(timeout=3)¶ Reads new IP data received by this XBee device during the provided timeout.
This method blocks until new IP data is received or the provided timeout expires.
For non-blocking operations, register a callback and use the method
IPDevice.add_ip_data_received_callback()
.Before reading IP data you need to start listening for incoming IP data at a specific port. Use the method
IPDevice.start_listening()
for that purpose. When finished, you can use the methodIPDevice.stop_listening()
to stop listening for incoming IP data.Parameters: timeout (Integer, optional) – The time to wait for new IP data in seconds. Returns: IP message, None
if this device did not receive new data.Return type: IPMessage
Raises: ValueError – if timeout
is less than 0.
-
read_ip_data_from
(ip_addr, timeout=3)¶ Reads new IP data received from the given IP address during the provided timeout.
This method blocks until new IP data from the provided IP address is received or the given timeout expires.
For non-blocking operations, register a callback and use the method
IPDevice.add_ip_data_received_callback()
.Before reading IP data you need to start listening for incoming IP data at a specific port. Use the method
IPDevice.start_listening()
for that purpose. When finished, you can use the methodIPDevice.stop_listening()
to stop listening for incoming IP data.Parameters: - ip_addr (
ipaddress.IPv4Address
) – The IP address to read data from. - timeout (Integer, optional) – The time to wait for new IP data in seconds.
Returns: - IP message,
None
if this device did not receive new data from the provided IP address.
Return type: Raises: ValueError – if
timeout
is less than 0.- ip_addr (
-
reset
()¶ Override method.
See also
-
send_bluetooth_data
(data)¶ Sends the given data to the Bluetooth interface using a User Data Relay frame.
Parameters: data (Bytearray) – Data to send.
Raises: - InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- XBeeException – if there is any problem sending the data.
-
send_data
(remote_xbee_device, data, transmit_options=0)¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
send_data_async
(remote_xbee_device, data, transmit_options=0)¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
send_data_broadcast
(data, transmit_options=0)¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
send_ip_data
(ip_addr, dest_port, protocol, data, close_socket=False)¶ Sends the provided IP data to the given IP address and port using the specified IP protocol. For TCP and TCP SSL protocols, you can also indicate if the socket should be closed when data is sent.
This method blocks till a success or error response arrives or the configured receive timeout expires.
Parameters: - ip_addr (
ipaddress.IPv4Address
) – The IP address to send IP data to. - dest_port (Integer) – The destination port of the transmission.
- protocol (
IPProtocol
) – The IP protocol used for the transmission. - data (String or Bytearray) – The IP data to be sent.
- close_socket (Boolean, optional) –
True
to close the socket just after the transmission.False
to keep it open. Default toFalse
.
Raises: - ValueError – if
ip_addr
isNone
. - ValueError – if
protocol
isNone
. - ValueError – if
data
isNone
. - ValueError – if
dest_port
is less than 0 or greater than 65535. - OperationNotSupportedException – if the device is remote.
- TimeoutException – if there is a timeout sending the data.
- XBeeException – if there is any other XBee related exception.
- ip_addr (
-
send_ip_data_async
(ip_addr, dest_port, protocol, data, close_socket=False)¶ Sends the provided IP data to the given IP address and port asynchronously using the specified IP protocol. For TCP and TCP SSL protocols, you can also indicate if the socket should be closed when data is sent.
Asynchronous transmissions do not wait for answer from the remote device or for transmit status packet.
Parameters: - ip_addr (
ipaddress.IPv4Address
) – The IP address to send IP data to. - dest_port (Integer) – The destination port of the transmission.
- protocol (
IPProtocol
) – The IP protocol used for the transmission. - data (String or Bytearray) – The IP data to be sent.
- close_socket (Boolean, optional) –
True
to close the socket just after the transmission.False
to keep it open. Default toFalse
.
Raises: - ValueError – if
ip_addr
isNone
. - ValueError – if
protocol
isNone
. - ValueError – if
data
isNone
. - ValueError – if
dest_port
is less than 0 or greater than 65535. - OperationNotSupportedException – if the device is remote.
- XBeeException – if there is any other XBee related exception.
- ip_addr (
-
send_ip_data_broadcast
(dest_port, data)¶ Sends the provided IP data to all clients.
This method blocks till a success or error transmit status arrives or the configured receive timeout expires.
Parameters: - dest_port (Integer) – The destination port of the transmission.
- data (String or Bytearray) – The IP data to be sent.
Raises: - ValueError – if
data
isNone
. - ValueError – if
dest_port
is less than 0 or greater than 65535. - TimeoutException – if there is a timeout sending the data.
- XBeeException – if there is any other XBee related exception.
-
send_micropython_data
(data)¶ Sends the given data to the MicroPython interface using a User Data Relay frame.
Parameters: data (Bytearray) – Data to send.
Raises: - InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- XBeeException – if there is any problem sending the data.
-
send_packet
(packet, sync=False)¶ Override method.
See also
AbstractXBeeDevice._send_packet()
-
send_packet_sync_and_get_response
(packet_to_send, timeout=None)¶ Override method.
See also
AbstractXBeeDevice._send_packet_sync_and_get_response()
-
send_user_data_relay
(local_interface, data)¶ Sends the given data to the given XBee local interface.
Parameters: - local_interface (
XBeeLocalInterface
) – Destination XBee local interface. - data (Bytearray) – Data to send.
Raises: - InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ValueError – if
local_interface
isNone
. - XBeeException – if there is any problem sending the User Data Relay.
See also
- local_interface (
-
serial_port
¶ Returns the serial port associated to the XBee device, if any.
Returns: - the serial port associated to the XBee device. Returns
None
if the local XBee - does not use serial communication.
Return type: XBeeSerialPort
See also
- the serial port associated to the XBee device. Returns
-
set_16bit_addr
(value)¶ Sets the 16-bit address of the XBee device.
Parameters: value (
XBee16BitAddress
) – the new 16-bit address of the XBee device.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the current 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 device.
Parameters: api_output_mode (
APIOutputMode
) – the new API output mode of the XBee device.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the current protocol is ZigBee
See also
-
set_api_output_mode_value
(api_output_mode)¶ Sets the API output mode of the XBee.
Parameters: api_output_mode (Integer) – new API output mode options. Calculate this value using the method
digi.xbee.models.mode.APIOutputModeBit.calculate_api_output_mode_value()
with a set ofdigi.xbee.models.mode.APIOutputModeBit
.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if it is not supported by the current protocol.
-
set_dest_address
(addr)¶ Deprecated.
Operation not supported in this protocol. Use
IPDevice.set_dest_ip_addr()
instead. This method will raise anAttributeError
.
-
set_dest_ip_addr
(address)¶ Sets the destination IP address.
Parameters: address (
ipaddress.IPv4Address
) – Destination IP address.Raises: - ValueError – if
address
isNone
. - TimeoutException – if there is a timeout setting the destination IP address.
- XBeeException – if there is any other XBee related exception.
See also
ipaddress.IPv4Address
- ValueError – if
-
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 the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
See also
-
set_dio_value
(io_line, io_value)¶ Sets the digital value (high or low) to the provided IO line.
Parameters: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
set_io_configuration
(io_line, io_mode)¶ Sets the configuration of the provided IO line.
Parameters: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
set_io_sampling_rate
(rate)¶ Sets the IO sampling rate of the XBee device in seconds. A sample rate of 0 means the IO sampling feature is disabled.
Parameters: rate (Integer) – the new IO sampling rate of the XBee device in seconds.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
set_node_id
(node_id)¶ Sets the Node Identifier (
NI
) value of the XBee device..Parameters: node_id (String) – the new Node Identifier (
NI
) of the XBee device.Raises: - ValueError – if
node_id
isNone
or its length is greater than 20. - TimeoutException – if the response is not received before the read timeout expires.
- ValueError – if
-
set_pan_id
(value)¶ Deprecated.
Operation not supported in this protocol. This method will raise an
AttributeError
.
-
set_parameter
(param, value)¶ Override.
-
set_power_level
(power_level)¶ Sets the power level of the XBee device.
Parameters: power_level ( PowerLevel
) – the new power level of the XBee device.Raises: TimeoutException – if the response is not received before the read timeout expires. See also
-
set_pwm_duty_cycle
(io_line, cycle)¶ Sets the duty cycle in % of the provided IO line.
The provided IO line must be PWM-capable, previously configured as PWM output.
Parameters: - io_line (
IOLine
) – the IO Line to be assigned. - cycle (Integer) – duty cycle in % to be assigned. Must be between 0 and 100.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- ValueError – if the given IO line does not have PWM capability or
cycle
is not between 0 and 100.
See also
- io_line (
-
set_sync_ops_timeout
(sync_ops_timeout)¶ Sets the serial port read timeout.
Parameters: sync_ops_timeout (Integer) – the read timeout, expressed in seconds.
-
start_listening
(source_port)¶ Starts listening for incoming IP transmissions in the provided port.
Parameters: source_port (Integer) – Port to listen for incoming transmissions.
Raises: - ValueError – if
source_port
is less than 0 or greater than 65535. - TimeoutException – if there is a timeout setting the source port.
- XBeeException – if there is any other XBee related exception.
- ValueError – if
-
stop_listening
()¶ Stops listening for incoming IP transmissions.
Raises: - TimeoutException – if there is a timeout processing the operation.
- XBeeException – if there is any other XBee related exception.
-
update_bluetooth_password
(new_password)¶ Changes the password of this Bluetooth device with the new one provided.
Note that your device must have Bluetooth Low Energy support to use this method.
Parameters: new_password (String) – New Bluetooth password.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
update_device_data_from
(device)¶ Updates the current device reference with the data provided for the given device.
This is only for internal use.
Parameters: device ( AbstractXBeeDevice
) – the XBee device to get the data from.Returns: True
if the device data has been updated,False
otherwise.Return type: Boolean
-
update_firmware
(xml_firmware_file, xbee_firmware_file=None, bootloader_firmware_file=None, timeout=None, progress_callback=None)¶ Performs a firmware update operation of the device.
Parameters: - xml_firmware_file (String) – path of the XML file that describes the firmware to upload.
- xbee_firmware_file (String, optional) – location of the XBee binary firmware file.
- bootloader_firmware_file (String, optional) – location of the bootloader binary firmware file.
- timeout (Integer, optional) – the maximum time to wait for target read operations during the update process.
- progress_callback (Function, optional) –
- function to execute to receive progress information. Receives two
- arguments:
- The current update task as a String
- The current update task percentage as an Integer
Raises: - XBeeException – if the device is not open.
- InvalidOperatingModeException – if the device operating mode is invalid.
- OperationNotSupportedException – if the firmware update is not supported in the XBee device.
- FirmwareUpdateException – if there is any error performing the firmware update.
-
write_changes
()¶ Writes configurable parameter values to the non-volatile memory of the XBee device so that parameter modifications persist through subsequent resets.
Parameters values remain in this device’s memory until overwritten by subsequent use of this method.
If changes are made without writing them to non-volatile memory, the module reverts back to previously saved parameters the next time the module is powered-on.
Writing the parameter modifications does not mean those values are immediately applied, this depends on the status of the ‘apply configuration changes’ option. Use method
is_apply_configuration_changes_enabled()
to get its status andenable_apply_configuration_changes()
to enable/disable the option. If it is disabled, methodapply_changes()
can be used in order to manually apply the changes.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
class
digi.xbee.devices.
RemoteXBeeDevice
(local_xbee_device, x64bit_addr=<digi.xbee.models.address.XBee64BitAddress object>, x16bit_addr=<digi.xbee.models.address.XBee16BitAddress object>, node_id=None)[source]¶ Bases:
digi.xbee.devices.AbstractXBeeDevice
This class represents a remote XBee device.
Class constructor. Instantiates a new
RemoteXBeeDevice
with the provided parameters.Parameters: - local_xbee_device (
XBeeDevice
) – the local XBee device associated with the remote one. - x64bit_addr (
XBee64BitAddress
) – the 64-bit address of the remote XBee device. - x16bit_addr (
XBee16BitAddress
) – the 16-bit address of the remote XBee device. - node_id (String, optional) – the node identifier of the remote XBee device. Optional.
See also
-
get_local_xbee_device
()[source]¶ Returns the local XBee device associated to the remote one.
Returns: XBeeDevice
-
set_local_xbee_device
(local_xbee_device)[source]¶ This methods associates a
XBeeDevice
to the remote XBee device.Parameters: local_xbee_device ( XBeeDevice
) – the new local XBee device associated to the remote one.See also
-
get_serial_port
()[source]¶ Returns the serial port of the local XBee device associated to the remote one.
Returns: the serial port of the local XBee device associated to the remote one. Return type: XBeeSerialPort
See also
XBeeSerialPort
-
get_comm_iface
()[source]¶ Returns the communication interface of the local XBee device associated to the remote one.
Returns: - the communication interface of the local XBee device associated to
- the remote one.
Return type: XBeeCommunicationInterface
See also
XBeeCommunicationInterface
-
apply_changes
()¶ Applies changes via
AC
command.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
apply_profile
(profile_path, progress_callback=None)¶ Applies the given XBee profile to the XBee device.
Parameters: - profile_path (String) – path of the XBee profile file to apply.
- progress_callback (Function, optional) –
- function to execute to receive progress information. Receives two
- arguments:
- The current apply profile task as a String
- The current apply profile task percentage as an Integer
Raises: - XBeeException – if the device is not open.
- InvalidOperatingModeException – if the device operating mode is invalid.
- UpdateProfileException – if there is any error applying the XBee profile.
- OperationNotSupportedException – if XBee profiles are not supported in the XBee device.
-
disable_bluetooth
()¶ Disables the Bluetooth interface of this XBee device.
Note that your device must have Bluetooth Low Energy support to use this method.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
enable_apply_changes
(value)¶ Sets the apply_changes flag.
Parameters: value (Boolean) – True
to enable the apply changes flag,False
to disable it.
-
enable_bluetooth
()¶ Enables the Bluetooth interface of this XBee device.
To work with this interface, you must also configure the Bluetooth password if not done previously. You can use the
AbstractXBeeDevice.update_bluetooth_password()
method for that purpose.Note that your device must have Bluetooth Low Energy support to use this method.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
execute_command
(parameter)¶ Executes the provided command.
Parameters: parameter (String) – The name of the AT command to be executed.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
get_16bit_addr
()¶ Returns the 16-bit address of the XBee device.
Returns: the 16-bit address of the XBee device. Return type: XBee16BitAddress
See also
-
get_64bit_addr
()¶ Returns the 64-bit address of the XBee device.
Returns: the 64-bit address of the XBee device. Return type: XBee64BitAddress
See also
-
get_adc_value
(io_line)¶ Returns the analog value of the provided IO line.
The provided IO line must be previously configured as ADC. To do so, use
AbstractXBeeDevice.set_io_configuration()
andIOMode.ADC
.Parameters: io_line (
IOLine
) – the IO line to get its ADC value.Returns: the analog value corresponding to the provided IO line.
Return type: Integer
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the response does not contain the value for the given IO line.
See also
-
get_api_output_mode
()¶ Deprecated since version 1.3: Use
get_api_output_mode_value()
Returns the API output mode of the XBee device.
The API output mode determines the format that the received data is output through the serial interface of the XBee device.
Returns: the API output mode of the XBee device.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
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 the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- 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 device in a format such as
00112233AABB
.Note that your device must have Bluetooth Low Energy support to use this method.
Returns: The Bluetooth MAC address.
Return type: String
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
get_current_frame_id
()¶ Returns the last used frame ID.
Returns: the last used frame ID. Return type: Integer
-
get_dest_address
()¶ Returns the 64-bit address of the XBee device that data will be reported to.
Returns: the address. Return type: XBee64BitAddress
Raises: TimeoutException – if the response is not received before the read timeout expires. See also
-
get_dio_value
(io_line)¶ Returns the digital value of the provided IO line.
The provided IO line must be previously configured as digital I/O. To do so, use
AbstractXBeeDevice.set_io_configuration()
.Parameters: io_line (
IOLine
) – the DIO line to gets its digital value.Returns: current value of the provided IO line.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the response does not contain the value for the given IO line.
-
get_firmware_version
()¶ Returns the firmware version of the XBee device.
Returns: the hardware version of the XBee device. Return type: Bytearray
-
get_hardware_version
()¶ Returns the hardware version of the XBee device.
Returns: the hardware version of the XBee device. Return type: HardwareVersion
See also
-
get_io_configuration
(io_line)¶ Returns the configuration of the provided IO line.
Parameters: io_line (
IOLine
) – the io line to configure.Returns: the IO mode of the IO line provided.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the received data is not an IO mode.
-
get_io_sampling_rate
()¶ Returns the IO sampling rate of the XBee device.
Returns: the IO sampling rate of XBee device.
Return type: Integer
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
get_node_id
()¶ Returns the Node Identifier (
NI
) value of the XBee device.Returns: the Node Identifier ( NI
) of the XBee device.Return type: String
-
get_pan_id
()¶ Returns the operating PAN ID of the XBee device.
Returns: operating PAN ID of the XBee device. Return type: Bytearray Raises: TimeoutException – if the response is not received before the read timeout expires.
-
get_power_level
()¶ Returns the power level of the XBee device.
Returns: the power level of the XBee device. Return type: PowerLevel
Raises: TimeoutException – if the response is not received before the read timeout expires. See also
-
get_protocol
()¶ Returns the current protocol of the XBee device.
Returns: the current protocol of the XBee device. Return type: XBeeProtocol
See also
-
get_pwm_duty_cycle
(io_line)¶ Returns the PWM duty cycle in % corresponding to the provided IO line.
Parameters: io_line (
IOLine
) – the IO line to get its PWM duty cycle.Returns: the PWM duty cycle of the given IO line or
None
if the response is empty.Return type: Integer
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- ValueError – if the passed
IO_LINE
has no PWM capability.
See also
-
get_role
()¶ Gets the XBee role.
Returns: the role of the XBee. Return type: digi.xbee.models.protocol.Role
See also
-
get_sync_ops_timeout
()¶ Returns the serial port read timeout.
Returns: the serial port read timeout in seconds. Return type: Integer
-
is_apply_changes_enabled
()¶ Returns whether the apply_changes flag is enabled or not.
Returns: True
if the apply_changes flag is enabled,False
otherwise.Return type: Boolean
-
log
¶ Returns the XBee device log.
Returns: the XBee device logger. Return type: Logger
-
read_device_info
(init=True)¶ Updates all instance parameters reading them from the XBee device.
Parameters: init (Boolean, optional, default=`True`) – If
False
only not initialized parameters are read, all ifTrue
.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
read_io_sample
()¶ Returns an IO sample from the XBee device containing the value of all enabled digital IO and analog input channels.
Returns: the IO sample read from the XBee device.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
See also
-
set_16bit_addr
(value)¶ Sets the 16-bit address of the XBee device.
Parameters: value (
XBee16BitAddress
) – the new 16-bit address of the XBee device.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the current 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 device.
Parameters: api_output_mode (
APIOutputMode
) – the new API output mode of the XBee device.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the current protocol is ZigBee
See also
-
set_api_output_mode_value
(api_output_mode)¶ Sets the API output mode of the XBee.
Parameters: api_output_mode (Integer) – new API output mode options. Calculate this value using the method
digi.xbee.models.mode.APIOutputModeBit.calculate_api_output_mode_value()
with a set ofdigi.xbee.models.mode.APIOutputModeBit
.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if it is not supported by the current protocol.
-
set_dest_address
(addr)¶ Sets the 64-bit address of the XBee device that data will be reported to.
Parameters: addr (
XBee64BitAddress
orRemoteXBeeDevice
) – the address itself or the remote XBee device that you want to set up its address as destination address.Raises: - TimeoutException – If the response is not received before the read timeout expires.
- XBeeException – If the XBee device’s serial port is closed.
- InvalidOperatingModeException – If the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – If the response is not as expected.
- ValueError – If
addr
isNone
.
-
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 the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
See also
-
set_dio_value
(io_line, io_value)¶ Sets the digital value (high or low) to the provided IO line.
Parameters: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
set_io_configuration
(io_line, io_mode)¶ Sets the configuration of the provided IO line.
Parameters: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
set_io_sampling_rate
(rate)¶ Sets the IO sampling rate of the XBee device in seconds. A sample rate of 0 means the IO sampling feature is disabled.
Parameters: rate (Integer) – the new IO sampling rate of the XBee device in seconds.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
set_node_id
(node_id)¶ Sets the Node Identifier (
NI
) value of the XBee device..Parameters: node_id (String) – the new Node Identifier (
NI
) of the XBee device.Raises: - ValueError – if
node_id
isNone
or its length is greater than 20. - TimeoutException – if the response is not received before the read timeout expires.
- ValueError – if
-
set_pan_id
(value)¶ Sets the operating PAN ID of the XBee device.
Parameters: value (Bytearray) – the new operating PAN ID of the XBee device.. Must have only 1 or 2 bytes. Raises: TimeoutException – if the response is not received before the read timeout expires.
-
set_power_level
(power_level)¶ Sets the power level of the XBee device.
Parameters: power_level ( PowerLevel
) – the new power level of the XBee device.Raises: TimeoutException – if the response is not received before the read timeout expires. See also
-
set_pwm_duty_cycle
(io_line, cycle)¶ Sets the duty cycle in % of the provided IO line.
The provided IO line must be PWM-capable, previously configured as PWM output.
Parameters: - io_line (
IOLine
) – the IO Line to be assigned. - cycle (Integer) – duty cycle in % to be assigned. Must be between 0 and 100.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- ValueError – if the given IO line does not have PWM capability or
cycle
is not between 0 and 100.
See also
- io_line (
-
set_sync_ops_timeout
(sync_ops_timeout)¶ Sets the serial port read timeout.
Parameters: sync_ops_timeout (Integer) – the read timeout, expressed in seconds.
-
update_bluetooth_password
(new_password)¶ Changes the password of this Bluetooth device with the new one provided.
Note that your device must have Bluetooth Low Energy support to use this method.
Parameters: new_password (String) – New Bluetooth password.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
update_device_data_from
(device)¶ Updates the current device reference with the data provided for the given device.
This is only for internal use.
Parameters: device ( AbstractXBeeDevice
) – the XBee device to get the data from.Returns: True
if the device data has been updated,False
otherwise.Return type: Boolean
-
update_firmware
(xml_firmware_file, xbee_firmware_file=None, bootloader_firmware_file=None, timeout=None, progress_callback=None)¶ Performs a firmware update operation of the device.
Parameters: - xml_firmware_file (String) – path of the XML file that describes the firmware to upload.
- xbee_firmware_file (String, optional) – location of the XBee binary firmware file.
- bootloader_firmware_file (String, optional) – location of the bootloader binary firmware file.
- timeout (Integer, optional) – the maximum time to wait for target read operations during the update process.
- progress_callback (Function, optional) –
- function to execute to receive progress information. Receives two
- arguments:
- The current update task as a String
- The current update task percentage as an Integer
Raises: - XBeeException – if the device is not open.
- InvalidOperatingModeException – if the device operating mode is invalid.
- OperationNotSupportedException – if the firmware update is not supported in the XBee device.
- FirmwareUpdateException – if there is any error performing the firmware update.
-
write_changes
()¶ Writes configurable parameter values to the non-volatile memory of the XBee device so that parameter modifications persist through subsequent resets.
Parameters values remain in this device’s memory until overwritten by subsequent use of this method.
If changes are made without writing them to non-volatile memory, the module reverts back to previously saved parameters the next time the module is powered-on.
Writing the parameter modifications does not mean those values are immediately applied, this depends on the status of the ‘apply configuration changes’ option. Use method
is_apply_configuration_changes_enabled()
to get its status andenable_apply_configuration_changes()
to enable/disable the option. If it is disabled, methodapply_changes()
can be used in order to manually apply the changes.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- local_xbee_device (
-
class
digi.xbee.devices.
RemoteRaw802Device
(local_xbee_device, x64bit_addr=None, x16bit_addr=None, node_id=None)[source]¶ Bases:
digi.xbee.devices.RemoteXBeeDevice
This class represents a remote 802.15.4 XBee device.
Class constructor. Instantiates a new
RemoteXBeeDevice
with the provided parameters.Parameters: - local_xbee_device (
XBeeDevice
) – the local XBee device associated with the remote one. - x64bit_addr (
XBee64BitAddress
) – the 64-bit address of the remote XBee device. - x16bit_addr (
XBee16BitAddress
) – the 16-bit address of the remote XBee device. - node_id (String, optional) – the node identifier of the remote XBee device. Optional.
Raises: XBeeException – if the protocol of
local_xbee_device
is invalid.See also
-
set_64bit_addr
(address)[source]¶ Sets the 64-bit address of this remote 802.15.4 device.
Parameters: address ( XBee64BitAddress
) – The 64-bit address to be set to the device.Raises: ValueError – if address
isNone
.
-
apply_changes
()¶ Applies changes via
AC
command.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
apply_profile
(profile_path, progress_callback=None)¶ Applies the given XBee profile to the XBee device.
Parameters: - profile_path (String) – path of the XBee profile file to apply.
- progress_callback (Function, optional) –
- function to execute to receive progress information. Receives two
- arguments:
- The current apply profile task as a String
- The current apply profile task percentage as an Integer
Raises: - XBeeException – if the device is not open.
- InvalidOperatingModeException – if the device operating mode is invalid.
- UpdateProfileException – if there is any error applying the XBee profile.
- OperationNotSupportedException – if XBee profiles are not supported in the XBee device.
-
disable_bluetooth
()¶ Disables the Bluetooth interface of this XBee device.
Note that your device must have Bluetooth Low Energy support to use this method.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
enable_apply_changes
(value)¶ Sets the apply_changes flag.
Parameters: value (Boolean) – True
to enable the apply changes flag,False
to disable it.
-
enable_bluetooth
()¶ Enables the Bluetooth interface of this XBee device.
To work with this interface, you must also configure the Bluetooth password if not done previously. You can use the
AbstractXBeeDevice.update_bluetooth_password()
method for that purpose.Note that your device must have Bluetooth Low Energy support to use this method.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
execute_command
(parameter)¶ Executes the provided command.
Parameters: parameter (String) – The name of the AT command to be executed.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
get_16bit_addr
()¶ Returns the 16-bit address of the XBee device.
Returns: the 16-bit address of the XBee device. Return type: XBee16BitAddress
See also
-
get_64bit_addr
()¶ Returns the 64-bit address of the XBee device.
Returns: the 64-bit address of the XBee device. Return type: XBee64BitAddress
See also
-
get_adc_value
(io_line)¶ Returns the analog value of the provided IO line.
The provided IO line must be previously configured as ADC. To do so, use
AbstractXBeeDevice.set_io_configuration()
andIOMode.ADC
.Parameters: io_line (
IOLine
) – the IO line to get its ADC value.Returns: the analog value corresponding to the provided IO line.
Return type: Integer
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the response does not contain the value for the given IO line.
See also
-
get_api_output_mode
()¶ Deprecated since version 1.3: Use
get_api_output_mode_value()
Returns the API output mode of the XBee device.
The API output mode determines the format that the received data is output through the serial interface of the XBee device.
Returns: the API output mode of the XBee device.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
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 the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- 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 device in a format such as
00112233AABB
.Note that your device must have Bluetooth Low Energy support to use this method.
Returns: The Bluetooth MAC address.
Return type: String
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
get_comm_iface
()¶ Returns the communication interface of the local XBee device associated to the remote one.
Returns: - the communication interface of the local XBee device associated to
- the remote one.
Return type: XBeeCommunicationInterface
See also
XBeeCommunicationInterface
-
get_current_frame_id
()¶ Returns the last used frame ID.
Returns: the last used frame ID. Return type: Integer
-
get_dest_address
()¶ Returns the 64-bit address of the XBee device that data will be reported to.
Returns: the address. Return type: XBee64BitAddress
Raises: TimeoutException – if the response is not received before the read timeout expires. See also
-
get_dio_value
(io_line)¶ Returns the digital value of the provided IO line.
The provided IO line must be previously configured as digital I/O. To do so, use
AbstractXBeeDevice.set_io_configuration()
.Parameters: io_line (
IOLine
) – the DIO line to gets its digital value.Returns: current value of the provided IO line.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the response does not contain the value for the given IO line.
-
get_firmware_version
()¶ Returns the firmware version of the XBee device.
Returns: the hardware version of the XBee device. Return type: Bytearray
-
get_hardware_version
()¶ Returns the hardware version of the XBee device.
Returns: the hardware version of the XBee device. Return type: HardwareVersion
See also
-
get_io_configuration
(io_line)¶ Returns the configuration of the provided IO line.
Parameters: io_line (
IOLine
) – the io line to configure.Returns: the IO mode of the IO line provided.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the received data is not an IO mode.
-
get_io_sampling_rate
()¶ Returns the IO sampling rate of the XBee device.
Returns: the IO sampling rate of XBee device.
Return type: Integer
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
get_local_xbee_device
()¶ Returns the local XBee device associated to the remote one.
Returns: XBeeDevice
-
get_node_id
()¶ Returns the Node Identifier (
NI
) value of the XBee device.Returns: the Node Identifier ( NI
) of the XBee device.Return type: String
-
get_pan_id
()¶ Returns the operating PAN ID of the XBee device.
Returns: operating PAN ID of the XBee device. Return type: Bytearray Raises: TimeoutException – if the response is not received before the read timeout expires.
-
get_parameter
(parameter, parameter_value=None)¶ Override.
See also
-
get_power_level
()¶ Returns the power level of the XBee device.
Returns: the power level of the XBee device. Return type: PowerLevel
Raises: TimeoutException – if the response is not received before the read timeout expires. See also
-
get_pwm_duty_cycle
(io_line)¶ Returns the PWM duty cycle in % corresponding to the provided IO line.
Parameters: io_line (
IOLine
) – the IO line to get its PWM duty cycle.Returns: the PWM duty cycle of the given IO line or
None
if the response is empty.Return type: Integer
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- ValueError – if the passed
IO_LINE
has no PWM capability.
See also
-
get_role
()¶ Gets the XBee role.
Returns: the role of the XBee. Return type: digi.xbee.models.protocol.Role
See also
-
get_serial_port
()¶ Returns the serial port of the local XBee device associated to the remote one.
Returns: the serial port of the local XBee device associated to the remote one. Return type: XBeeSerialPort
See also
XBeeSerialPort
-
get_sync_ops_timeout
()¶ Returns the serial port read timeout.
Returns: the serial port read timeout in seconds. Return type: Integer
-
is_apply_changes_enabled
()¶ Returns whether the apply_changes flag is enabled or not.
Returns: True
if the apply_changes flag is enabled,False
otherwise.Return type: Boolean
-
is_remote
()¶ Override method.
See also
-
log
¶ Returns the XBee device log.
Returns: the XBee device logger. Return type: Logger
-
read_device_info
(init=True)¶ Updates all instance parameters reading them from the XBee device.
Parameters: init (Boolean, optional, default=`True`) – If
False
only not initialized parameters are read, all ifTrue
.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
read_io_sample
()¶ Returns an IO sample from the XBee device containing the value of all enabled digital IO and analog input channels.
Returns: the IO sample read from the XBee device.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
See also
-
reset
()¶ Override method.
See also
-
set_16bit_addr
(value)¶ Sets the 16-bit address of the XBee device.
Parameters: value (
XBee16BitAddress
) – the new 16-bit address of the XBee device.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the current 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 device.
Parameters: api_output_mode (
APIOutputMode
) – the new API output mode of the XBee device.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the current protocol is ZigBee
See also
-
set_api_output_mode_value
(api_output_mode)¶ Sets the API output mode of the XBee.
Parameters: api_output_mode (Integer) – new API output mode options. Calculate this value using the method
digi.xbee.models.mode.APIOutputModeBit.calculate_api_output_mode_value()
with a set ofdigi.xbee.models.mode.APIOutputModeBit
.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if it is not supported by the current protocol.
-
set_dest_address
(addr)¶ Sets the 64-bit address of the XBee device that data will be reported to.
Parameters: addr (
XBee64BitAddress
orRemoteXBeeDevice
) – the address itself or the remote XBee device that you want to set up its address as destination address.Raises: - TimeoutException – If the response is not received before the read timeout expires.
- XBeeException – If the XBee device’s serial port is closed.
- InvalidOperatingModeException – If the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – If the response is not as expected.
- ValueError – If
addr
isNone
.
-
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 the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
See also
-
set_dio_value
(io_line, io_value)¶ Sets the digital value (high or low) to the provided IO line.
Parameters: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
set_io_configuration
(io_line, io_mode)¶ Sets the configuration of the provided IO line.
Parameters: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
set_io_sampling_rate
(rate)¶ Sets the IO sampling rate of the XBee device in seconds. A sample rate of 0 means the IO sampling feature is disabled.
Parameters: rate (Integer) – the new IO sampling rate of the XBee device in seconds.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
set_local_xbee_device
(local_xbee_device)¶ This methods associates a
XBeeDevice
to the remote XBee device.Parameters: local_xbee_device ( XBeeDevice
) – the new local XBee device associated to the remote one.See also
-
set_node_id
(node_id)¶ Sets the Node Identifier (
NI
) value of the XBee device..Parameters: node_id (String) – the new Node Identifier (
NI
) of the XBee device.Raises: - ValueError – if
node_id
isNone
or its length is greater than 20. - TimeoutException – if the response is not received before the read timeout expires.
- ValueError – if
-
set_pan_id
(value)¶ Sets the operating PAN ID of the XBee device.
Parameters: value (Bytearray) – the new operating PAN ID of the XBee device.. Must have only 1 or 2 bytes. Raises: TimeoutException – if the response is not received before the read timeout expires.
-
set_parameter
(parameter, value)¶ Override.
See also
-
set_power_level
(power_level)¶ Sets the power level of the XBee device.
Parameters: power_level ( PowerLevel
) – the new power level of the XBee device.Raises: TimeoutException – if the response is not received before the read timeout expires. See also
-
set_pwm_duty_cycle
(io_line, cycle)¶ Sets the duty cycle in % of the provided IO line.
The provided IO line must be PWM-capable, previously configured as PWM output.
Parameters: - io_line (
IOLine
) – the IO Line to be assigned. - cycle (Integer) – duty cycle in % to be assigned. Must be between 0 and 100.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- ValueError – if the given IO line does not have PWM capability or
cycle
is not between 0 and 100.
See also
- io_line (
-
set_sync_ops_timeout
(sync_ops_timeout)¶ Sets the serial port read timeout.
Parameters: sync_ops_timeout (Integer) – the read timeout, expressed in seconds.
-
update_bluetooth_password
(new_password)¶ Changes the password of this Bluetooth device with the new one provided.
Note that your device must have Bluetooth Low Energy support to use this method.
Parameters: new_password (String) – New Bluetooth password.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
update_device_data_from
(device)¶ Updates the current device reference with the data provided for the given device.
This is only for internal use.
Parameters: device ( AbstractXBeeDevice
) – the XBee device to get the data from.Returns: True
if the device data has been updated,False
otherwise.Return type: Boolean
-
update_firmware
(xml_firmware_file, xbee_firmware_file=None, bootloader_firmware_file=None, timeout=None, progress_callback=None)¶ Performs a firmware update operation of the device.
Parameters: - xml_firmware_file (String) – path of the XML file that describes the firmware to upload.
- xbee_firmware_file (String, optional) – location of the XBee binary firmware file.
- bootloader_firmware_file (String, optional) – location of the bootloader binary firmware file.
- timeout (Integer, optional) – the maximum time to wait for target read operations during the update process.
- progress_callback (Function, optional) –
- function to execute to receive progress information. Receives two
- arguments:
- The current update task as a String
- The current update task percentage as an Integer
Raises: - XBeeException – if the device is not open.
- InvalidOperatingModeException – if the device operating mode is invalid.
- OperationNotSupportedException – if the firmware update is not supported in the XBee device.
- FirmwareUpdateException – if there is any error performing the firmware update.
-
write_changes
()¶ Writes configurable parameter values to the non-volatile memory of the XBee device so that parameter modifications persist through subsequent resets.
Parameters values remain in this device’s memory until overwritten by subsequent use of this method.
If changes are made without writing them to non-volatile memory, the module reverts back to previously saved parameters the next time the module is powered-on.
Writing the parameter modifications does not mean those values are immediately applied, this depends on the status of the ‘apply configuration changes’ option. Use method
is_apply_configuration_changes_enabled()
to get its status andenable_apply_configuration_changes()
to enable/disable the option. If it is disabled, methodapply_changes()
can be used in order to manually apply the changes.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- local_xbee_device (
-
class
digi.xbee.devices.
RemoteDigiMeshDevice
(local_xbee_device, x64bit_addr=None, node_id=None)[source]¶ Bases:
digi.xbee.devices.RemoteXBeeDevice
This class represents a remote DigiMesh XBee device.
Class constructor. Instantiates a new
RemoteDigiMeshDevice
with the provided parameters.Parameters: - local_xbee_device (
XBeeDevice
) – the local XBee device associated with the remote one. - x64bit_addr (
XBee64BitAddress
) – the 64-bit address of the remote XBee device. - node_id (String, optional) – the node identifier of the remote XBee device. Optional.
Raises: XBeeException – if the protocol of
local_xbee_device
is invalid.See also
-
apply_changes
()¶ Applies changes via
AC
command.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
apply_profile
(profile_path, progress_callback=None)¶ Applies the given XBee profile to the XBee device.
Parameters: - profile_path (String) – path of the XBee profile file to apply.
- progress_callback (Function, optional) –
- function to execute to receive progress information. Receives two
- arguments:
- The current apply profile task as a String
- The current apply profile task percentage as an Integer
Raises: - XBeeException – if the device is not open.
- InvalidOperatingModeException – if the device operating mode is invalid.
- UpdateProfileException – if there is any error applying the XBee profile.
- OperationNotSupportedException – if XBee profiles are not supported in the XBee device.
-
disable_bluetooth
()¶ Disables the Bluetooth interface of this XBee device.
Note that your device must have Bluetooth Low Energy support to use this method.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
enable_apply_changes
(value)¶ Sets the apply_changes flag.
Parameters: value (Boolean) – True
to enable the apply changes flag,False
to disable it.
-
enable_bluetooth
()¶ Enables the Bluetooth interface of this XBee device.
To work with this interface, you must also configure the Bluetooth password if not done previously. You can use the
AbstractXBeeDevice.update_bluetooth_password()
method for that purpose.Note that your device must have Bluetooth Low Energy support to use this method.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
execute_command
(parameter)¶ Executes the provided command.
Parameters: parameter (String) – The name of the AT command to be executed.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
get_16bit_addr
()¶ Returns the 16-bit address of the XBee device.
Returns: the 16-bit address of the XBee device. Return type: XBee16BitAddress
See also
-
get_64bit_addr
()¶ Returns the 64-bit address of the XBee device.
Returns: the 64-bit address of the XBee device. Return type: XBee64BitAddress
See also
-
get_adc_value
(io_line)¶ Returns the analog value of the provided IO line.
The provided IO line must be previously configured as ADC. To do so, use
AbstractXBeeDevice.set_io_configuration()
andIOMode.ADC
.Parameters: io_line (
IOLine
) – the IO line to get its ADC value.Returns: the analog value corresponding to the provided IO line.
Return type: Integer
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the response does not contain the value for the given IO line.
See also
-
get_api_output_mode
()¶ Deprecated since version 1.3: Use
get_api_output_mode_value()
Returns the API output mode of the XBee device.
The API output mode determines the format that the received data is output through the serial interface of the XBee device.
Returns: the API output mode of the XBee device.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
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 the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- 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 device in a format such as
00112233AABB
.Note that your device must have Bluetooth Low Energy support to use this method.
Returns: The Bluetooth MAC address.
Return type: String
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
get_comm_iface
()¶ Returns the communication interface of the local XBee device associated to the remote one.
Returns: - the communication interface of the local XBee device associated to
- the remote one.
Return type: XBeeCommunicationInterface
See also
XBeeCommunicationInterface
-
get_current_frame_id
()¶ Returns the last used frame ID.
Returns: the last used frame ID. Return type: Integer
-
get_dest_address
()¶ Returns the 64-bit address of the XBee device that data will be reported to.
Returns: the address. Return type: XBee64BitAddress
Raises: TimeoutException – if the response is not received before the read timeout expires. See also
-
get_dio_value
(io_line)¶ Returns the digital value of the provided IO line.
The provided IO line must be previously configured as digital I/O. To do so, use
AbstractXBeeDevice.set_io_configuration()
.Parameters: io_line (
IOLine
) – the DIO line to gets its digital value.Returns: current value of the provided IO line.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the response does not contain the value for the given IO line.
-
get_firmware_version
()¶ Returns the firmware version of the XBee device.
Returns: the hardware version of the XBee device. Return type: Bytearray
-
get_hardware_version
()¶ Returns the hardware version of the XBee device.
Returns: the hardware version of the XBee device. Return type: HardwareVersion
See also
-
get_io_configuration
(io_line)¶ Returns the configuration of the provided IO line.
Parameters: io_line (
IOLine
) – the io line to configure.Returns: the IO mode of the IO line provided.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the received data is not an IO mode.
-
get_io_sampling_rate
()¶ Returns the IO sampling rate of the XBee device.
Returns: the IO sampling rate of XBee device.
Return type: Integer
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
get_local_xbee_device
()¶ Returns the local XBee device associated to the remote one.
Returns: XBeeDevice
-
get_node_id
()¶ Returns the Node Identifier (
NI
) value of the XBee device.Returns: the Node Identifier ( NI
) of the XBee device.Return type: String
-
get_pan_id
()¶ Returns the operating PAN ID of the XBee device.
Returns: operating PAN ID of the XBee device. Return type: Bytearray Raises: TimeoutException – if the response is not received before the read timeout expires.
-
get_parameter
(parameter, parameter_value=None)¶ Override.
See also
-
get_power_level
()¶ Returns the power level of the XBee device.
Returns: the power level of the XBee device. Return type: PowerLevel
Raises: TimeoutException – if the response is not received before the read timeout expires. See also
-
get_pwm_duty_cycle
(io_line)¶ Returns the PWM duty cycle in % corresponding to the provided IO line.
Parameters: io_line (
IOLine
) – the IO line to get its PWM duty cycle.Returns: the PWM duty cycle of the given IO line or
None
if the response is empty.Return type: Integer
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- ValueError – if the passed
IO_LINE
has no PWM capability.
See also
-
get_role
()¶ Gets the XBee role.
Returns: the role of the XBee. Return type: digi.xbee.models.protocol.Role
See also
-
get_serial_port
()¶ Returns the serial port of the local XBee device associated to the remote one.
Returns: the serial port of the local XBee device associated to the remote one. Return type: XBeeSerialPort
See also
XBeeSerialPort
-
get_sync_ops_timeout
()¶ Returns the serial port read timeout.
Returns: the serial port read timeout in seconds. Return type: Integer
-
is_apply_changes_enabled
()¶ Returns whether the apply_changes flag is enabled or not.
Returns: True
if the apply_changes flag is enabled,False
otherwise.Return type: Boolean
-
is_remote
()¶ Override method.
See also
-
log
¶ Returns the XBee device log.
Returns: the XBee device logger. Return type: Logger
-
read_device_info
(init=True)¶ Updates all instance parameters reading them from the XBee device.
Parameters: init (Boolean, optional, default=`True`) – If
False
only not initialized parameters are read, all ifTrue
.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
read_io_sample
()¶ Returns an IO sample from the XBee device containing the value of all enabled digital IO and analog input channels.
Returns: the IO sample read from the XBee device.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
See also
-
reset
()¶ Override method.
See also
-
set_16bit_addr
(value)¶ Sets the 16-bit address of the XBee device.
Parameters: value (
XBee16BitAddress
) – the new 16-bit address of the XBee device.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the current 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 device.
Parameters: api_output_mode (
APIOutputMode
) – the new API output mode of the XBee device.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the current protocol is ZigBee
See also
-
set_api_output_mode_value
(api_output_mode)¶ Sets the API output mode of the XBee.
Parameters: api_output_mode (Integer) – new API output mode options. Calculate this value using the method
digi.xbee.models.mode.APIOutputModeBit.calculate_api_output_mode_value()
with a set ofdigi.xbee.models.mode.APIOutputModeBit
.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if it is not supported by the current protocol.
-
set_dest_address
(addr)¶ Sets the 64-bit address of the XBee device that data will be reported to.
Parameters: addr (
XBee64BitAddress
orRemoteXBeeDevice
) – the address itself or the remote XBee device that you want to set up its address as destination address.Raises: - TimeoutException – If the response is not received before the read timeout expires.
- XBeeException – If the XBee device’s serial port is closed.
- InvalidOperatingModeException – If the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – If the response is not as expected.
- ValueError – If
addr
isNone
.
-
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 the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
See also
-
set_dio_value
(io_line, io_value)¶ Sets the digital value (high or low) to the provided IO line.
Parameters: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
set_io_configuration
(io_line, io_mode)¶ Sets the configuration of the provided IO line.
Parameters: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
set_io_sampling_rate
(rate)¶ Sets the IO sampling rate of the XBee device in seconds. A sample rate of 0 means the IO sampling feature is disabled.
Parameters: rate (Integer) – the new IO sampling rate of the XBee device in seconds.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
set_local_xbee_device
(local_xbee_device)¶ This methods associates a
XBeeDevice
to the remote XBee device.Parameters: local_xbee_device ( XBeeDevice
) – the new local XBee device associated to the remote one.See also
-
set_node_id
(node_id)¶ Sets the Node Identifier (
NI
) value of the XBee device..Parameters: node_id (String) – the new Node Identifier (
NI
) of the XBee device.Raises: - ValueError – if
node_id
isNone
or its length is greater than 20. - TimeoutException – if the response is not received before the read timeout expires.
- ValueError – if
-
set_pan_id
(value)¶ Sets the operating PAN ID of the XBee device.
Parameters: value (Bytearray) – the new operating PAN ID of the XBee device.. Must have only 1 or 2 bytes. Raises: TimeoutException – if the response is not received before the read timeout expires.
-
set_parameter
(parameter, value)¶ Override.
See also
-
set_power_level
(power_level)¶ Sets the power level of the XBee device.
Parameters: power_level ( PowerLevel
) – the new power level of the XBee device.Raises: TimeoutException – if the response is not received before the read timeout expires. See also
-
set_pwm_duty_cycle
(io_line, cycle)¶ Sets the duty cycle in % of the provided IO line.
The provided IO line must be PWM-capable, previously configured as PWM output.
Parameters: - io_line (
IOLine
) – the IO Line to be assigned. - cycle (Integer) – duty cycle in % to be assigned. Must be between 0 and 100.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- ValueError – if the given IO line does not have PWM capability or
cycle
is not between 0 and 100.
See also
- io_line (
-
set_sync_ops_timeout
(sync_ops_timeout)¶ Sets the serial port read timeout.
Parameters: sync_ops_timeout (Integer) – the read timeout, expressed in seconds.
-
update_bluetooth_password
(new_password)¶ Changes the password of this Bluetooth device with the new one provided.
Note that your device must have Bluetooth Low Energy support to use this method.
Parameters: new_password (String) – New Bluetooth password.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
update_device_data_from
(device)¶ Updates the current device reference with the data provided for the given device.
This is only for internal use.
Parameters: device ( AbstractXBeeDevice
) – the XBee device to get the data from.Returns: True
if the device data has been updated,False
otherwise.Return type: Boolean
-
update_firmware
(xml_firmware_file, xbee_firmware_file=None, bootloader_firmware_file=None, timeout=None, progress_callback=None)¶ Performs a firmware update operation of the device.
Parameters: - xml_firmware_file (String) – path of the XML file that describes the firmware to upload.
- xbee_firmware_file (String, optional) – location of the XBee binary firmware file.
- bootloader_firmware_file (String, optional) – location of the bootloader binary firmware file.
- timeout (Integer, optional) – the maximum time to wait for target read operations during the update process.
- progress_callback (Function, optional) –
- function to execute to receive progress information. Receives two
- arguments:
- The current update task as a String
- The current update task percentage as an Integer
Raises: - XBeeException – if the device is not open.
- InvalidOperatingModeException – if the device operating mode is invalid.
- OperationNotSupportedException – if the firmware update is not supported in the XBee device.
- FirmwareUpdateException – if there is any error performing the firmware update.
-
write_changes
()¶ Writes configurable parameter values to the non-volatile memory of the XBee device so that parameter modifications persist through subsequent resets.
Parameters values remain in this device’s memory until overwritten by subsequent use of this method.
If changes are made without writing them to non-volatile memory, the module reverts back to previously saved parameters the next time the module is powered-on.
Writing the parameter modifications does not mean those values are immediately applied, this depends on the status of the ‘apply configuration changes’ option. Use method
is_apply_configuration_changes_enabled()
to get its status andenable_apply_configuration_changes()
to enable/disable the option. If it is disabled, methodapply_changes()
can be used in order to manually apply the changes.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- local_xbee_device (
-
class
digi.xbee.devices.
RemoteDigiPointDevice
(local_xbee_device, x64bit_addr=None, node_id=None)[source]¶ Bases:
digi.xbee.devices.RemoteXBeeDevice
This class represents a remote DigiPoint XBee device.
Class constructor. Instantiates a new
RemoteDigiMeshDevice
with the provided parameters.Parameters: - local_xbee_device (
XBeeDevice
) – the local XBee device associated with the remote one. - x64bit_addr (
XBee64BitAddress
) – the 64-bit address of the remote XBee device. - node_id (String, optional) – the node identifier of the remote XBee device. Optional.
Raises: XBeeException – if the protocol of
local_xbee_device
is invalid.See also
-
apply_changes
()¶ Applies changes via
AC
command.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
apply_profile
(profile_path, progress_callback=None)¶ Applies the given XBee profile to the XBee device.
Parameters: - profile_path (String) – path of the XBee profile file to apply.
- progress_callback (Function, optional) –
- function to execute to receive progress information. Receives two
- arguments:
- The current apply profile task as a String
- The current apply profile task percentage as an Integer
Raises: - XBeeException – if the device is not open.
- InvalidOperatingModeException – if the device operating mode is invalid.
- UpdateProfileException – if there is any error applying the XBee profile.
- OperationNotSupportedException – if XBee profiles are not supported in the XBee device.
-
disable_bluetooth
()¶ Disables the Bluetooth interface of this XBee device.
Note that your device must have Bluetooth Low Energy support to use this method.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
enable_apply_changes
(value)¶ Sets the apply_changes flag.
Parameters: value (Boolean) – True
to enable the apply changes flag,False
to disable it.
-
enable_bluetooth
()¶ Enables the Bluetooth interface of this XBee device.
To work with this interface, you must also configure the Bluetooth password if not done previously. You can use the
AbstractXBeeDevice.update_bluetooth_password()
method for that purpose.Note that your device must have Bluetooth Low Energy support to use this method.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
execute_command
(parameter)¶ Executes the provided command.
Parameters: parameter (String) – The name of the AT command to be executed.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
get_16bit_addr
()¶ Returns the 16-bit address of the XBee device.
Returns: the 16-bit address of the XBee device. Return type: XBee16BitAddress
See also
-
get_64bit_addr
()¶ Returns the 64-bit address of the XBee device.
Returns: the 64-bit address of the XBee device. Return type: XBee64BitAddress
See also
-
get_adc_value
(io_line)¶ Returns the analog value of the provided IO line.
The provided IO line must be previously configured as ADC. To do so, use
AbstractXBeeDevice.set_io_configuration()
andIOMode.ADC
.Parameters: io_line (
IOLine
) – the IO line to get its ADC value.Returns: the analog value corresponding to the provided IO line.
Return type: Integer
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the response does not contain the value for the given IO line.
See also
-
get_api_output_mode
()¶ Deprecated since version 1.3: Use
get_api_output_mode_value()
Returns the API output mode of the XBee device.
The API output mode determines the format that the received data is output through the serial interface of the XBee device.
Returns: the API output mode of the XBee device.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
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 the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- 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 device in a format such as
00112233AABB
.Note that your device must have Bluetooth Low Energy support to use this method.
Returns: The Bluetooth MAC address.
Return type: String
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
get_comm_iface
()¶ Returns the communication interface of the local XBee device associated to the remote one.
Returns: - the communication interface of the local XBee device associated to
- the remote one.
Return type: XBeeCommunicationInterface
See also
XBeeCommunicationInterface
-
get_current_frame_id
()¶ Returns the last used frame ID.
Returns: the last used frame ID. Return type: Integer
-
get_dest_address
()¶ Returns the 64-bit address of the XBee device that data will be reported to.
Returns: the address. Return type: XBee64BitAddress
Raises: TimeoutException – if the response is not received before the read timeout expires. See also
-
get_dio_value
(io_line)¶ Returns the digital value of the provided IO line.
The provided IO line must be previously configured as digital I/O. To do so, use
AbstractXBeeDevice.set_io_configuration()
.Parameters: io_line (
IOLine
) – the DIO line to gets its digital value.Returns: current value of the provided IO line.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the response does not contain the value for the given IO line.
-
get_firmware_version
()¶ Returns the firmware version of the XBee device.
Returns: the hardware version of the XBee device. Return type: Bytearray
-
get_hardware_version
()¶ Returns the hardware version of the XBee device.
Returns: the hardware version of the XBee device. Return type: HardwareVersion
See also
-
get_io_configuration
(io_line)¶ Returns the configuration of the provided IO line.
Parameters: io_line (
IOLine
) – the io line to configure.Returns: the IO mode of the IO line provided.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the received data is not an IO mode.
-
get_io_sampling_rate
()¶ Returns the IO sampling rate of the XBee device.
Returns: the IO sampling rate of XBee device.
Return type: Integer
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
get_local_xbee_device
()¶ Returns the local XBee device associated to the remote one.
Returns: XBeeDevice
-
get_node_id
()¶ Returns the Node Identifier (
NI
) value of the XBee device.Returns: the Node Identifier ( NI
) of the XBee device.Return type: String
-
get_pan_id
()¶ Returns the operating PAN ID of the XBee device.
Returns: operating PAN ID of the XBee device. Return type: Bytearray Raises: TimeoutException – if the response is not received before the read timeout expires.
-
get_parameter
(parameter, parameter_value=None)¶ Override.
See also
-
get_power_level
()¶ Returns the power level of the XBee device.
Returns: the power level of the XBee device. Return type: PowerLevel
Raises: TimeoutException – if the response is not received before the read timeout expires. See also
-
get_pwm_duty_cycle
(io_line)¶ Returns the PWM duty cycle in % corresponding to the provided IO line.
Parameters: io_line (
IOLine
) – the IO line to get its PWM duty cycle.Returns: the PWM duty cycle of the given IO line or
None
if the response is empty.Return type: Integer
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- ValueError – if the passed
IO_LINE
has no PWM capability.
See also
-
get_role
()¶ Gets the XBee role.
Returns: the role of the XBee. Return type: digi.xbee.models.protocol.Role
See also
-
get_serial_port
()¶ Returns the serial port of the local XBee device associated to the remote one.
Returns: the serial port of the local XBee device associated to the remote one. Return type: XBeeSerialPort
See also
XBeeSerialPort
-
get_sync_ops_timeout
()¶ Returns the serial port read timeout.
Returns: the serial port read timeout in seconds. Return type: Integer
-
is_apply_changes_enabled
()¶ Returns whether the apply_changes flag is enabled or not.
Returns: True
if the apply_changes flag is enabled,False
otherwise.Return type: Boolean
-
is_remote
()¶ Override method.
See also
-
log
¶ Returns the XBee device log.
Returns: the XBee device logger. Return type: Logger
-
read_device_info
(init=True)¶ Updates all instance parameters reading them from the XBee device.
Parameters: init (Boolean, optional, default=`True`) – If
False
only not initialized parameters are read, all ifTrue
.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
read_io_sample
()¶ Returns an IO sample from the XBee device containing the value of all enabled digital IO and analog input channels.
Returns: the IO sample read from the XBee device.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
See also
-
reset
()¶ Override method.
See also
-
set_16bit_addr
(value)¶ Sets the 16-bit address of the XBee device.
Parameters: value (
XBee16BitAddress
) – the new 16-bit address of the XBee device.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the current 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 device.
Parameters: api_output_mode (
APIOutputMode
) – the new API output mode of the XBee device.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the current protocol is ZigBee
See also
-
set_api_output_mode_value
(api_output_mode)¶ Sets the API output mode of the XBee.
Parameters: api_output_mode (Integer) – new API output mode options. Calculate this value using the method
digi.xbee.models.mode.APIOutputModeBit.calculate_api_output_mode_value()
with a set ofdigi.xbee.models.mode.APIOutputModeBit
.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if it is not supported by the current protocol.
-
set_dest_address
(addr)¶ Sets the 64-bit address of the XBee device that data will be reported to.
Parameters: addr (
XBee64BitAddress
orRemoteXBeeDevice
) – the address itself or the remote XBee device that you want to set up its address as destination address.Raises: - TimeoutException – If the response is not received before the read timeout expires.
- XBeeException – If the XBee device’s serial port is closed.
- InvalidOperatingModeException – If the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – If the response is not as expected.
- ValueError – If
addr
isNone
.
-
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 the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
See also
-
set_dio_value
(io_line, io_value)¶ Sets the digital value (high or low) to the provided IO line.
Parameters: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
set_io_configuration
(io_line, io_mode)¶ Sets the configuration of the provided IO line.
Parameters: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
set_io_sampling_rate
(rate)¶ Sets the IO sampling rate of the XBee device in seconds. A sample rate of 0 means the IO sampling feature is disabled.
Parameters: rate (Integer) – the new IO sampling rate of the XBee device in seconds.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
set_local_xbee_device
(local_xbee_device)¶ This methods associates a
XBeeDevice
to the remote XBee device.Parameters: local_xbee_device ( XBeeDevice
) – the new local XBee device associated to the remote one.See also
-
set_node_id
(node_id)¶ Sets the Node Identifier (
NI
) value of the XBee device..Parameters: node_id (String) – the new Node Identifier (
NI
) of the XBee device.Raises: - ValueError – if
node_id
isNone
or its length is greater than 20. - TimeoutException – if the response is not received before the read timeout expires.
- ValueError – if
-
set_pan_id
(value)¶ Sets the operating PAN ID of the XBee device.
Parameters: value (Bytearray) – the new operating PAN ID of the XBee device.. Must have only 1 or 2 bytes. Raises: TimeoutException – if the response is not received before the read timeout expires.
-
set_parameter
(parameter, value)¶ Override.
See also
-
set_power_level
(power_level)¶ Sets the power level of the XBee device.
Parameters: power_level ( PowerLevel
) – the new power level of the XBee device.Raises: TimeoutException – if the response is not received before the read timeout expires. See also
-
set_pwm_duty_cycle
(io_line, cycle)¶ Sets the duty cycle in % of the provided IO line.
The provided IO line must be PWM-capable, previously configured as PWM output.
Parameters: - io_line (
IOLine
) – the IO Line to be assigned. - cycle (Integer) – duty cycle in % to be assigned. Must be between 0 and 100.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- ValueError – if the given IO line does not have PWM capability or
cycle
is not between 0 and 100.
See also
- io_line (
-
set_sync_ops_timeout
(sync_ops_timeout)¶ Sets the serial port read timeout.
Parameters: sync_ops_timeout (Integer) – the read timeout, expressed in seconds.
-
update_bluetooth_password
(new_password)¶ Changes the password of this Bluetooth device with the new one provided.
Note that your device must have Bluetooth Low Energy support to use this method.
Parameters: new_password (String) – New Bluetooth password.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
update_device_data_from
(device)¶ Updates the current device reference with the data provided for the given device.
This is only for internal use.
Parameters: device ( AbstractXBeeDevice
) – the XBee device to get the data from.Returns: True
if the device data has been updated,False
otherwise.Return type: Boolean
-
update_firmware
(xml_firmware_file, xbee_firmware_file=None, bootloader_firmware_file=None, timeout=None, progress_callback=None)¶ Performs a firmware update operation of the device.
Parameters: - xml_firmware_file (String) – path of the XML file that describes the firmware to upload.
- xbee_firmware_file (String, optional) – location of the XBee binary firmware file.
- bootloader_firmware_file (String, optional) – location of the bootloader binary firmware file.
- timeout (Integer, optional) – the maximum time to wait for target read operations during the update process.
- progress_callback (Function, optional) –
- function to execute to receive progress information. Receives two
- arguments:
- The current update task as a String
- The current update task percentage as an Integer
Raises: - XBeeException – if the device is not open.
- InvalidOperatingModeException – if the device operating mode is invalid.
- OperationNotSupportedException – if the firmware update is not supported in the XBee device.
- FirmwareUpdateException – if there is any error performing the firmware update.
-
write_changes
()¶ Writes configurable parameter values to the non-volatile memory of the XBee device so that parameter modifications persist through subsequent resets.
Parameters values remain in this device’s memory until overwritten by subsequent use of this method.
If changes are made without writing them to non-volatile memory, the module reverts back to previously saved parameters the next time the module is powered-on.
Writing the parameter modifications does not mean those values are immediately applied, this depends on the status of the ‘apply configuration changes’ option. Use method
is_apply_configuration_changes_enabled()
to get its status andenable_apply_configuration_changes()
to enable/disable the option. If it is disabled, methodapply_changes()
can be used in order to manually apply the changes.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- local_xbee_device (
-
class
digi.xbee.devices.
RemoteZigBeeDevice
(local_xbee_device, x64bit_addr=None, x16bit_addr=None, node_id=None)[source]¶ Bases:
digi.xbee.devices.RemoteXBeeDevice
This class represents a remote ZigBee XBee device.
Class constructor. Instantiates a new
RemoteDigiMeshDevice
with the provided parameters.Parameters: - local_xbee_device (
XBeeDevice
) – the local XBee device associated with the remote one. - x64bit_addr (
XBee64BitAddress
) – the 64-bit address of the remote XBee device. - x16bit_addr (
XBee16BitAddress
) – the 16-bit address of the remote XBee device. - node_id (String, optional) – the node identifier of the remote XBee device. Optional.
Raises: XBeeException – if the protocol of
local_xbee_device
is invalid.See also
-
apply_changes
()¶ Applies changes via
AC
command.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
apply_profile
(profile_path, progress_callback=None)¶ Applies the given XBee profile to the XBee device.
Parameters: - profile_path (String) – path of the XBee profile file to apply.
- progress_callback (Function, optional) –
- function to execute to receive progress information. Receives two
- arguments:
- The current apply profile task as a String
- The current apply profile task percentage as an Integer
Raises: - XBeeException – if the device is not open.
- InvalidOperatingModeException – if the device operating mode is invalid.
- UpdateProfileException – if there is any error applying the XBee profile.
- OperationNotSupportedException – if XBee profiles are not supported in the XBee device.
-
disable_bluetooth
()¶ Disables the Bluetooth interface of this XBee device.
Note that your device must have Bluetooth Low Energy support to use this method.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
enable_apply_changes
(value)¶ Sets the apply_changes flag.
Parameters: value (Boolean) – True
to enable the apply changes flag,False
to disable it.
-
enable_bluetooth
()¶ Enables the Bluetooth interface of this XBee device.
To work with this interface, you must also configure the Bluetooth password if not done previously. You can use the
AbstractXBeeDevice.update_bluetooth_password()
method for that purpose.Note that your device must have Bluetooth Low Energy support to use this method.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
execute_command
(parameter)¶ Executes the provided command.
Parameters: parameter (String) – The name of the AT command to be executed.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
get_16bit_addr
()¶ Returns the 16-bit address of the XBee device.
Returns: the 16-bit address of the XBee device. Return type: XBee16BitAddress
See also
-
get_64bit_addr
()¶ Returns the 64-bit address of the XBee device.
Returns: the 64-bit address of the XBee device. Return type: XBee64BitAddress
See also
-
get_adc_value
(io_line)¶ Returns the analog value of the provided IO line.
The provided IO line must be previously configured as ADC. To do so, use
AbstractXBeeDevice.set_io_configuration()
andIOMode.ADC
.Parameters: io_line (
IOLine
) – the IO line to get its ADC value.Returns: the analog value corresponding to the provided IO line.
Return type: Integer
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the response does not contain the value for the given IO line.
See also
-
get_api_output_mode
()¶ Deprecated since version 1.3: Use
get_api_output_mode_value()
Returns the API output mode of the XBee device.
The API output mode determines the format that the received data is output through the serial interface of the XBee device.
Returns: the API output mode of the XBee device.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
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 the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- 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 device in a format such as
00112233AABB
.Note that your device must have Bluetooth Low Energy support to use this method.
Returns: The Bluetooth MAC address.
Return type: String
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
get_comm_iface
()¶ Returns the communication interface of the local XBee device associated to the remote one.
Returns: - the communication interface of the local XBee device associated to
- the remote one.
Return type: XBeeCommunicationInterface
See also
XBeeCommunicationInterface
-
get_current_frame_id
()¶ Returns the last used frame ID.
Returns: the last used frame ID. Return type: Integer
-
get_dest_address
()¶ Returns the 64-bit address of the XBee device that data will be reported to.
Returns: the address. Return type: XBee64BitAddress
Raises: TimeoutException – if the response is not received before the read timeout expires. See also
-
get_dio_value
(io_line)¶ Returns the digital value of the provided IO line.
The provided IO line must be previously configured as digital I/O. To do so, use
AbstractXBeeDevice.set_io_configuration()
.Parameters: io_line (
IOLine
) – the DIO line to gets its digital value.Returns: current value of the provided IO line.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the response does not contain the value for the given IO line.
-
get_firmware_version
()¶ Returns the firmware version of the XBee device.
Returns: the hardware version of the XBee device. Return type: Bytearray
-
get_hardware_version
()¶ Returns the hardware version of the XBee device.
Returns: the hardware version of the XBee device. Return type: HardwareVersion
See also
-
get_io_configuration
(io_line)¶ Returns the configuration of the provided IO line.
Parameters: io_line (
IOLine
) – the io line to configure.Returns: the IO mode of the IO line provided.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the received data is not an IO mode.
-
get_io_sampling_rate
()¶ Returns the IO sampling rate of the XBee device.
Returns: the IO sampling rate of XBee device.
Return type: Integer
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
get_local_xbee_device
()¶ Returns the local XBee device associated to the remote one.
Returns: XBeeDevice
-
get_node_id
()¶ Returns the Node Identifier (
NI
) value of the XBee device.Returns: the Node Identifier ( NI
) of the XBee device.Return type: String
-
get_pan_id
()¶ Returns the operating PAN ID of the XBee device.
Returns: operating PAN ID of the XBee device. Return type: Bytearray Raises: TimeoutException – if the response is not received before the read timeout expires.
-
get_parameter
(parameter, parameter_value=None)¶ Override.
See also
-
get_power_level
()¶ Returns the power level of the XBee device.
Returns: the power level of the XBee device. Return type: PowerLevel
Raises: TimeoutException – if the response is not received before the read timeout expires. See also
-
get_pwm_duty_cycle
(io_line)¶ Returns the PWM duty cycle in % corresponding to the provided IO line.
Parameters: io_line (
IOLine
) – the IO line to get its PWM duty cycle.Returns: the PWM duty cycle of the given IO line or
None
if the response is empty.Return type: Integer
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- ValueError – if the passed
IO_LINE
has no PWM capability.
See also
-
get_role
()¶ Gets the XBee role.
Returns: the role of the XBee. Return type: digi.xbee.models.protocol.Role
See also
-
get_serial_port
()¶ Returns the serial port of the local XBee device associated to the remote one.
Returns: the serial port of the local XBee device associated to the remote one. Return type: XBeeSerialPort
See also
XBeeSerialPort
-
get_sync_ops_timeout
()¶ Returns the serial port read timeout.
Returns: the serial port read timeout in seconds. Return type: Integer
-
is_apply_changes_enabled
()¶ Returns whether the apply_changes flag is enabled or not.
Returns: True
if the apply_changes flag is enabled,False
otherwise.Return type: Boolean
-
is_remote
()¶ Override method.
See also
-
log
¶ Returns the XBee device log.
Returns: the XBee device logger. Return type: Logger
-
read_device_info
(init=True)¶ Updates all instance parameters reading them from the XBee device.
Parameters: init (Boolean, optional, default=`True`) – If
False
only not initialized parameters are read, all ifTrue
.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
read_io_sample
()¶ Returns an IO sample from the XBee device containing the value of all enabled digital IO and analog input channels.
Returns: the IO sample read from the XBee device.
Return type: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
See also
-
reset
()¶ Override method.
See also
-
set_16bit_addr
(value)¶ Sets the 16-bit address of the XBee device.
Parameters: value (
XBee16BitAddress
) – the new 16-bit address of the XBee device.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the current 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 device.
Parameters: api_output_mode (
APIOutputMode
) – the new API output mode of the XBee device.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if the current protocol is ZigBee
See also
-
set_api_output_mode_value
(api_output_mode)¶ Sets the API output mode of the XBee.
Parameters: api_output_mode (Integer) – new API output mode options. Calculate this value using the method
digi.xbee.models.mode.APIOutputModeBit.calculate_api_output_mode_value()
with a set ofdigi.xbee.models.mode.APIOutputModeBit
.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- OperationNotSupportedException – if it is not supported by the current protocol.
-
set_dest_address
(addr)¶ Sets the 64-bit address of the XBee device that data will be reported to.
Parameters: addr (
XBee64BitAddress
orRemoteXBeeDevice
) – the address itself or the remote XBee device that you want to set up its address as destination address.Raises: - TimeoutException – If the response is not received before the read timeout expires.
- XBeeException – If the XBee device’s serial port is closed.
- InvalidOperatingModeException – If the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – If the response is not as expected.
- ValueError – If
addr
isNone
.
-
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 the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
See also
-
set_dio_value
(io_line, io_value)¶ Sets the digital value (high or low) to the provided IO line.
Parameters: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
set_io_configuration
(io_line, io_mode)¶ Sets the configuration of the provided IO line.
Parameters: Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
set_io_sampling_rate
(rate)¶ Sets the IO sampling rate of the XBee device in seconds. A sample rate of 0 means the IO sampling feature is disabled.
Parameters: rate (Integer) – the new IO sampling rate of the XBee device in seconds.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
set_local_xbee_device
(local_xbee_device)¶ This methods associates a
XBeeDevice
to the remote XBee device.Parameters: local_xbee_device ( XBeeDevice
) – the new local XBee device associated to the remote one.See also
-
set_node_id
(node_id)¶ Sets the Node Identifier (
NI
) value of the XBee device..Parameters: node_id (String) – the new Node Identifier (
NI
) of the XBee device.Raises: - ValueError – if
node_id
isNone
or its length is greater than 20. - TimeoutException – if the response is not received before the read timeout expires.
- ValueError – if
-
set_pan_id
(value)¶ Sets the operating PAN ID of the XBee device.
Parameters: value (Bytearray) – the new operating PAN ID of the XBee device.. Must have only 1 or 2 bytes. Raises: TimeoutException – if the response is not received before the read timeout expires.
-
set_parameter
(parameter, value)¶ Override.
See also
-
set_power_level
(power_level)¶ Sets the power level of the XBee device.
Parameters: power_level ( PowerLevel
) – the new power level of the XBee device.Raises: TimeoutException – if the response is not received before the read timeout expires. See also
-
set_pwm_duty_cycle
(io_line, cycle)¶ Sets the duty cycle in % of the provided IO line.
The provided IO line must be PWM-capable, previously configured as PWM output.
Parameters: - io_line (
IOLine
) – the IO Line to be assigned. - cycle (Integer) – duty cycle in % to be assigned. Must be between 0 and 100.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- ValueError – if the given IO line does not have PWM capability or
cycle
is not between 0 and 100.
See also
- io_line (
-
set_sync_ops_timeout
(sync_ops_timeout)¶ Sets the serial port read timeout.
Parameters: sync_ops_timeout (Integer) – the read timeout, expressed in seconds.
-
update_bluetooth_password
(new_password)¶ Changes the password of this Bluetooth device with the new one provided.
Note that your device must have Bluetooth Low Energy support to use this method.
Parameters: new_password (String) – New Bluetooth password.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
-
update_device_data_from
(device)¶ Updates the current device reference with the data provided for the given device.
This is only for internal use.
Parameters: device ( AbstractXBeeDevice
) – the XBee device to get the data from.Returns: True
if the device data has been updated,False
otherwise.Return type: Boolean
-
update_firmware
(xml_firmware_file, xbee_firmware_file=None, bootloader_firmware_file=None, timeout=None, progress_callback=None)¶ Performs a firmware update operation of the device.
Parameters: - xml_firmware_file (String) – path of the XML file that describes the firmware to upload.
- xbee_firmware_file (String, optional) – location of the XBee binary firmware file.
- bootloader_firmware_file (String, optional) – location of the bootloader binary firmware file.
- timeout (Integer, optional) – the maximum time to wait for target read operations during the update process.
- progress_callback (Function, optional) –
- function to execute to receive progress information. Receives two
- arguments:
- The current update task as a String
- The current update task percentage as an Integer
Raises: - XBeeException – if the device is not open.
- InvalidOperatingModeException – if the device operating mode is invalid.
- OperationNotSupportedException – if the firmware update is not supported in the XBee device.
- FirmwareUpdateException – if there is any error performing the firmware update.
-
write_changes
()¶ Writes configurable parameter values to the non-volatile memory of the XBee device so that parameter modifications persist through subsequent resets.
Parameters values remain in this device’s memory until overwritten by subsequent use of this method.
If changes are made without writing them to non-volatile memory, the module reverts back to previously saved parameters the next time the module is powered-on.
Writing the parameter modifications does not mean those values are immediately applied, this depends on the status of the ‘apply configuration changes’ option. Use method
is_apply_configuration_changes_enabled()
to get its status andenable_apply_configuration_changes()
to enable/disable the option. If it is disabled, methodapply_changes()
can be used in order to manually apply the changes.Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- local_xbee_device (
-
class
digi.xbee.devices.
XBeeNetwork
(xbee_device)[source]¶ Bases:
object
This class represents an XBee Network.
The network allows the discovery of remote devices in the same network as the local one and stores them.
Class constructor. Instantiates a new
XBeeNetwork
.Parameters: xbee_device ( XBeeDevice
) – the local XBee device to get the network from.Raises: ValueError – if xbee_device
isNone
.-
ND_PACKET_FINISH
= 1¶ Flag that indicates a “discovery process finish” packet.
-
ND_PACKET_REMOTE
= 2¶ Flag that indicates a discovery process packet with info about a remote XBee device.
-
start_discovery_process
()[source]¶ Starts the discovery process. This method is not blocking.
The discovery process will be running until the configured timeout expires or, in case of 802.15.4, until the ‘end’ packet is read.
It may be that, after the timeout expires, there are devices that continue sending discovery packets to this XBee device. In this case, these devices will not be added to the network.
-
stop_discovery_process
()[source]¶ Stops the discovery process if it is running.
Note that DigiMesh/DigiPoint devices are blocked until the discovery time configured (NT parameter) has elapsed, so if you try to get/set any parameter during the discovery process you will receive a timeout exception.
-
discover_device
(node_id)[source]¶ Blocking method. Discovers and reports the first remote XBee device that matches the supplied identifier.
Parameters: node_id (String) – the node identifier of the device to be discovered. Returns: - the discovered remote XBee device with the given identifier,
None
if the timeout expires and the device was not found.
Return type: RemoteXBeeDevice
-
discover_devices
(device_id_list)[source]¶ Blocking method. Attempts to discover a list of devices and add them to the current network.
This method does not guarantee that all devices of
device_id_list
will be found, even if they exist physically. This will depend on the node discovery operation (ND
) and timeout.Parameters: device_id_list (List) – list of device IDs to discover. Returns: a list with the discovered devices. It may not contain all devices specified in device_id_list
Return type: List
-
is_discovery_running
()[source]¶ Returns whether the discovery process is running or not.
Returns: True
if the discovery process is running,False
otherwise.Return type: Boolean
-
get_devices
()[source]¶ Returns a copy of the XBee devices list of the network.
If another XBee device is added to the list before the execution of this method, this XBee device will not be added to the list returned by this method.
Returns: a copy of the XBee devices list of the network. Return type: List
-
has_devices
()[source]¶ Returns whether there is any device in the network or not.
Returns: True
if there is at least one device in the network,False
otherwise.Return type: Boolean
-
get_number_devices
()[source]¶ Returns the number of devices in the network.
Returns: the number of devices in the network. Return type: Integer
-
add_network_modified_callback
(callback)[source]¶ Adds a callback for the event
digi.xbee.reader.NetworkModified
.Parameters: callback (Function) – the callback. Receives one argument.
- The event type as a
NetworkEventType
- The reason of the event as a
NetworkEventReason
- The node added, updated or removed from the network as a
XBeeDevice
orRemoteXBeeDevice
.
- The event type as a
-
add_device_discovered_callback
(callback)[source]¶ Adds a callback for the event
DeviceDiscovered
.Parameters: callback (Function) – the callback. Receives one argument.
- The discovered remote XBee device as a
RemoteXBeeDevice
- The discovered remote XBee device as a
-
add_discovery_process_finished_callback
(callback)[source]¶ Adds a callback for the event
DiscoveryProcessFinished
.Parameters: callback (Function) – the callback. Receives one argument.
- The event code as an
Integer
- The event code as an
-
del_network_modified_callback
(callback)[source]¶ Deletes a callback for the callback list of
digi.xbee.reader.NetworkModified
.Parameters: callback (Function) – the callback to delete.
-
del_device_discovered_callback
(callback)[source]¶ Deletes a callback for the callback list of
DeviceDiscovered
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofDeviceDiscovered
event.
-
del_discovery_process_finished_callback
(callback)[source]¶ Deletes a callback for the callback list of
DiscoveryProcessFinished
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofDiscoveryProcessFinished
event.
-
get_discovery_options
()[source]¶ Returns the network discovery process options.
Returns: the parameter value.
Return type: Bytearray
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
set_discovery_options
(options)[source]¶ Configures the discovery options (
NO
parameter) with the given value.Parameters: options (Set of
DiscoveryOptions
) – new discovery options, empty set to clear the options.Raises: - ValueError – if
options
isNone
. - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
See also
- ValueError – if
-
get_discovery_timeout
()[source]¶ Returns the network discovery timeout.
Returns: the network discovery timeout.
Return type: Float
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
set_discovery_timeout
(discovery_timeout)[source]¶ Sets the discovery network timeout.
Parameters: discovery_timeout (Float) – timeout in seconds.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- ValueError – if
discovery_timeout
is not between 0x20 and 0xFF
-
get_device_by_64
(x64bit_addr)[source]¶ Returns the XBee in the network whose 64-bit address matches the given one.
Parameters: x64bit_addr ( XBee64BitAddress
) – The 64-bit address of the device to be retrieved.Returns: the XBee device in the network or None
if it is not found.Return type: AbstractXBeeDevice
Raises: ValueError – if x64bit_addr
isNone
or unknown.
-
get_device_by_16
(x16bit_addr)[source]¶ Returns the XBee in the network whose 16-bit address matches the given one.
Parameters: x16bit_addr ( XBee16BitAddress
) – The 16-bit address of the device to be retrieved.Returns: the XBee device in the network or None
if it is not found.Return type: AbstractXBeeDevice
Raises: ValueError – if x16bit_addr
isNone
or unknown.
-
get_device_by_node_id
(node_id)[source]¶ Returns the XBee in the network whose node identifier matches the given one.
Parameters: node_id (String) – The node identifier of the device to be retrieved. Returns: the XBee device in the network or None
if it is not found.Return type: AbstractXBeeDevice
Raises: ValueError – if node_id
isNone
.
-
add_if_not_exist
(x64bit_addr=None, x16bit_addr=None, node_id=None)[source]¶ Adds an XBee device with the provided parameters if it does not exist in the current network.
If the XBee device already exists, its data will be updated with the provided parameters that are not
None
.Parameters: - x64bit_addr (
XBee64BitAddress
, optional) – XBee device’s 64bit address. Optional. - x16bit_addr (
XBee16BitAddress
, optional) – XBee device’s 16bit address. Optional. - node_id (String, optional) – the node identifier of the XBee device. Optional.
Returns: - the remote XBee device with the updated parameters. If the XBee device
was not in the list yet, this method returns the given XBee device without changes.
Return type: - x64bit_addr (
-
add_remote
(remote_xbee_device)[source]¶ Adds the provided remote XBee device to the network if it is not contained yet.
If the XBee device is already contained in the network, its data will be updated with the parameters of the XBee device that are not
None
.Parameters: remote_xbee_device ( RemoteXBeeDevice
) – the remote XBee device to add to the network.Returns: - the provided XBee device with the updated parameters. If the XBee device
- was not in the list yet, this method returns it without changes.
Return type: RemoteXBeeDevice
-
add_remotes
(remote_xbee_devices)[source]¶ Adds a list of remote XBee devices to the network.
If any XBee device of the list is already contained in the network, its data will be updated with the parameters of the XBee device that are not
None
.Parameters: remote_xbee_devices (List) – the list of RemoteXBeeDevice
to add to the network.
-
remove_device
(remote_xbee_device)[source]¶ Removes the provided remote XBee device from the network.
Parameters: remote_xbee_device ( RemoteXBeeDevice
) – the remote XBee device to be removed from the list.Raises: ValueError – if the provided RemoteXBeeDevice
is not in the network.
-
get_discovery_callbacks
()[source]¶ Returns the API callbacks that are used in the device discovery process.
This callbacks notify the user callbacks for each XBee device discovered.
Returns: - callback for generic devices discovery process,
- callback for discovery specific XBee device ops.
Return type: Tuple (Function, Function)
-
-
class
digi.xbee.devices.
ZigBeeNetwork
(device)[source]¶ Bases:
digi.xbee.devices.XBeeNetwork
This class represents a ZigBee network.
The network allows the discovery of remote devices in the same network as the local one and stores them.
Class constructor. Instantiates a new
ZigBeeNetwork
.Parameters: device ( ZigBeeDevice
) – the local ZigBee device to get the network from.Raises: ValueError – if device
isNone
.-
add_device_discovered_callback
(callback)¶ Adds a callback for the event
DeviceDiscovered
.Parameters: callback (Function) – the callback. Receives one argument.
- The discovered remote XBee device as a
RemoteXBeeDevice
- The discovered remote XBee device as a
-
add_discovery_process_finished_callback
(callback)¶ Adds a callback for the event
DiscoveryProcessFinished
.Parameters: callback (Function) – the callback. Receives one argument.
- The event code as an
Integer
- The event code as an
-
add_if_not_exist
(x64bit_addr=None, x16bit_addr=None, node_id=None)¶ Adds an XBee device with the provided parameters if it does not exist in the current network.
If the XBee device already exists, its data will be updated with the provided parameters that are not
None
.Parameters: - x64bit_addr (
XBee64BitAddress
, optional) – XBee device’s 64bit address. Optional. - x16bit_addr (
XBee16BitAddress
, optional) – XBee device’s 16bit address. Optional. - node_id (String, optional) – the node identifier of the XBee device. Optional.
Returns: - the remote XBee device with the updated parameters. If the XBee device
was not in the list yet, this method returns the given XBee device without changes.
Return type: - x64bit_addr (
-
add_network_modified_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.NetworkModified
.Parameters: callback (Function) – the callback. Receives one argument.
- The event type as a
NetworkEventType
- The reason of the event as a
NetworkEventReason
- The node added, updated or removed from the network as a
XBeeDevice
orRemoteXBeeDevice
.
- The event type as a
-
add_remote
(remote_xbee_device)¶ Adds the provided remote XBee device to the network if it is not contained yet.
If the XBee device is already contained in the network, its data will be updated with the parameters of the XBee device that are not
None
.Parameters: remote_xbee_device ( RemoteXBeeDevice
) – the remote XBee device to add to the network.Returns: - the provided XBee device with the updated parameters. If the XBee device
- was not in the list yet, this method returns it without changes.
Return type: RemoteXBeeDevice
-
add_remotes
(remote_xbee_devices)¶ Adds a list of remote XBee devices to the network.
If any XBee device of the list is already contained in the network, its data will be updated with the parameters of the XBee device that are not
None
.Parameters: remote_xbee_devices (List) – the list of RemoteXBeeDevice
to add to the network.
-
clear
()¶ Removes all the remote XBee devices from the network.
-
del_device_discovered_callback
(callback)¶ Deletes a callback for the callback list of
DeviceDiscovered
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofDeviceDiscovered
event.
-
del_discovery_process_finished_callback
(callback)¶ Deletes a callback for the callback list of
DiscoveryProcessFinished
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofDiscoveryProcessFinished
event.
-
del_network_modified_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.NetworkModified
.Parameters: callback (Function) – the callback to delete.
-
discover_device
(node_id)¶ Blocking method. Discovers and reports the first remote XBee device that matches the supplied identifier.
Parameters: node_id (String) – the node identifier of the device to be discovered. Returns: - the discovered remote XBee device with the given identifier,
None
if the timeout expires and the device was not found.
Return type: RemoteXBeeDevice
-
discover_devices
(device_id_list)¶ Blocking method. Attempts to discover a list of devices and add them to the current network.
This method does not guarantee that all devices of
device_id_list
will be found, even if they exist physically. This will depend on the node discovery operation (ND
) and timeout.Parameters: device_id_list (List) – list of device IDs to discover. Returns: a list with the discovered devices. It may not contain all devices specified in device_id_list
Return type: List
-
get_device_by_16
(x16bit_addr)¶ Returns the XBee in the network whose 16-bit address matches the given one.
Parameters: x16bit_addr ( XBee16BitAddress
) – The 16-bit address of the device to be retrieved.Returns: the XBee device in the network or None
if it is not found.Return type: AbstractXBeeDevice
Raises: ValueError – if x16bit_addr
isNone
or unknown.
-
get_device_by_64
(x64bit_addr)¶ Returns the XBee in the network whose 64-bit address matches the given one.
Parameters: x64bit_addr ( XBee64BitAddress
) – The 64-bit address of the device to be retrieved.Returns: the XBee device in the network or None
if it is not found.Return type: AbstractXBeeDevice
Raises: ValueError – if x64bit_addr
isNone
or unknown.
-
get_device_by_node_id
(node_id)¶ Returns the XBee in the network whose node identifier matches the given one.
Parameters: node_id (String) – The node identifier of the device to be retrieved. Returns: the XBee device in the network or None
if it is not found.Return type: AbstractXBeeDevice
Raises: ValueError – if node_id
isNone
.
-
get_devices
()¶ Returns a copy of the XBee devices list of the network.
If another XBee device is added to the list before the execution of this method, this XBee device will not be added to the list returned by this method.
Returns: a copy of the XBee devices list of the network. Return type: List
-
get_discovery_callbacks
()¶ Returns the API callbacks that are used in the device discovery process.
This callbacks notify the user callbacks for each XBee device discovered.
Returns: - callback for generic devices discovery process,
- callback for discovery specific XBee device ops.
Return type: Tuple (Function, Function)
-
get_discovery_options
()¶ Returns the network discovery process options.
Returns: the parameter value.
Return type: Bytearray
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
get_discovery_timeout
()¶ Returns the network discovery timeout.
Returns: the network discovery timeout.
Return type: Float
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
get_number_devices
()¶ Returns the number of devices in the network.
Returns: the number of devices in the network. Return type: Integer
-
has_devices
()¶ Returns whether there is any device in the network or not.
Returns: True
if there is at least one device in the network,False
otherwise.Return type: Boolean
-
is_discovery_running
()¶ Returns whether the discovery process is running or not.
Returns: True
if the discovery process is running,False
otherwise.Return type: Boolean
-
remove_device
(remote_xbee_device)¶ Removes the provided remote XBee device from the network.
Parameters: remote_xbee_device ( RemoteXBeeDevice
) – the remote XBee device to be removed from the list.Raises: ValueError – if the provided RemoteXBeeDevice
is not in the network.
-
set_discovery_options
(options)¶ Configures the discovery options (
NO
parameter) with the given value.Parameters: options (Set of
DiscoveryOptions
) – new discovery options, empty set to clear the options.Raises: - ValueError – if
options
isNone
. - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
See also
- ValueError – if
-
set_discovery_timeout
(discovery_timeout)¶ Sets the discovery network timeout.
Parameters: discovery_timeout (Float) – timeout in seconds.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- ValueError – if
discovery_timeout
is not between 0x20 and 0xFF
-
start_discovery_process
()¶ Starts the discovery process. This method is not blocking.
The discovery process will be running until the configured timeout expires or, in case of 802.15.4, until the ‘end’ packet is read.
It may be that, after the timeout expires, there are devices that continue sending discovery packets to this XBee device. In this case, these devices will not be added to the network.
-
stop_discovery_process
()¶ Stops the discovery process if it is running.
Note that DigiMesh/DigiPoint devices are blocked until the discovery time configured (NT parameter) has elapsed, so if you try to get/set any parameter during the discovery process you will receive a timeout exception.
-
-
class
digi.xbee.devices.
Raw802Network
(device)[source]¶ Bases:
digi.xbee.devices.XBeeNetwork
This class represents an 802.15.4 network.
The network allows the discovery of remote devices in the same network as the local one and stores them.
Class constructor. Instantiates a new
Raw802Network
.Parameters: device ( Raw802Device
) – the local 802.15.4 device to get the network from.Raises: ValueError – if device
isNone
.-
add_device_discovered_callback
(callback)¶ Adds a callback for the event
DeviceDiscovered
.Parameters: callback (Function) – the callback. Receives one argument.
- The discovered remote XBee device as a
RemoteXBeeDevice
- The discovered remote XBee device as a
-
add_discovery_process_finished_callback
(callback)¶ Adds a callback for the event
DiscoveryProcessFinished
.Parameters: callback (Function) – the callback. Receives one argument.
- The event code as an
Integer
- The event code as an
-
add_if_not_exist
(x64bit_addr=None, x16bit_addr=None, node_id=None)¶ Adds an XBee device with the provided parameters if it does not exist in the current network.
If the XBee device already exists, its data will be updated with the provided parameters that are not
None
.Parameters: - x64bit_addr (
XBee64BitAddress
, optional) – XBee device’s 64bit address. Optional. - x16bit_addr (
XBee16BitAddress
, optional) – XBee device’s 16bit address. Optional. - node_id (String, optional) – the node identifier of the XBee device. Optional.
Returns: - the remote XBee device with the updated parameters. If the XBee device
was not in the list yet, this method returns the given XBee device without changes.
Return type: - x64bit_addr (
-
add_network_modified_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.NetworkModified
.Parameters: callback (Function) – the callback. Receives one argument.
- The event type as a
NetworkEventType
- The reason of the event as a
NetworkEventReason
- The node added, updated or removed from the network as a
XBeeDevice
orRemoteXBeeDevice
.
- The event type as a
-
add_remote
(remote_xbee_device)¶ Adds the provided remote XBee device to the network if it is not contained yet.
If the XBee device is already contained in the network, its data will be updated with the parameters of the XBee device that are not
None
.Parameters: remote_xbee_device ( RemoteXBeeDevice
) – the remote XBee device to add to the network.Returns: - the provided XBee device with the updated parameters. If the XBee device
- was not in the list yet, this method returns it without changes.
Return type: RemoteXBeeDevice
-
add_remotes
(remote_xbee_devices)¶ Adds a list of remote XBee devices to the network.
If any XBee device of the list is already contained in the network, its data will be updated with the parameters of the XBee device that are not
None
.Parameters: remote_xbee_devices (List) – the list of RemoteXBeeDevice
to add to the network.
-
clear
()¶ Removes all the remote XBee devices from the network.
-
del_device_discovered_callback
(callback)¶ Deletes a callback for the callback list of
DeviceDiscovered
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofDeviceDiscovered
event.
-
del_discovery_process_finished_callback
(callback)¶ Deletes a callback for the callback list of
DiscoveryProcessFinished
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofDiscoveryProcessFinished
event.
-
del_network_modified_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.NetworkModified
.Parameters: callback (Function) – the callback to delete.
-
discover_device
(node_id)¶ Blocking method. Discovers and reports the first remote XBee device that matches the supplied identifier.
Parameters: node_id (String) – the node identifier of the device to be discovered. Returns: - the discovered remote XBee device with the given identifier,
None
if the timeout expires and the device was not found.
Return type: RemoteXBeeDevice
-
discover_devices
(device_id_list)¶ Blocking method. Attempts to discover a list of devices and add them to the current network.
This method does not guarantee that all devices of
device_id_list
will be found, even if they exist physically. This will depend on the node discovery operation (ND
) and timeout.Parameters: device_id_list (List) – list of device IDs to discover. Returns: a list with the discovered devices. It may not contain all devices specified in device_id_list
Return type: List
-
get_device_by_16
(x16bit_addr)¶ Returns the XBee in the network whose 16-bit address matches the given one.
Parameters: x16bit_addr ( XBee16BitAddress
) – The 16-bit address of the device to be retrieved.Returns: the XBee device in the network or None
if it is not found.Return type: AbstractXBeeDevice
Raises: ValueError – if x16bit_addr
isNone
or unknown.
-
get_device_by_64
(x64bit_addr)¶ Returns the XBee in the network whose 64-bit address matches the given one.
Parameters: x64bit_addr ( XBee64BitAddress
) – The 64-bit address of the device to be retrieved.Returns: the XBee device in the network or None
if it is not found.Return type: AbstractXBeeDevice
Raises: ValueError – if x64bit_addr
isNone
or unknown.
-
get_device_by_node_id
(node_id)¶ Returns the XBee in the network whose node identifier matches the given one.
Parameters: node_id (String) – The node identifier of the device to be retrieved. Returns: the XBee device in the network or None
if it is not found.Return type: AbstractXBeeDevice
Raises: ValueError – if node_id
isNone
.
-
get_devices
()¶ Returns a copy of the XBee devices list of the network.
If another XBee device is added to the list before the execution of this method, this XBee device will not be added to the list returned by this method.
Returns: a copy of the XBee devices list of the network. Return type: List
-
get_discovery_callbacks
()¶ Returns the API callbacks that are used in the device discovery process.
This callbacks notify the user callbacks for each XBee device discovered.
Returns: - callback for generic devices discovery process,
- callback for discovery specific XBee device ops.
Return type: Tuple (Function, Function)
-
get_discovery_options
()¶ Returns the network discovery process options.
Returns: the parameter value.
Return type: Bytearray
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
get_discovery_timeout
()¶ Returns the network discovery timeout.
Returns: the network discovery timeout.
Return type: Float
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
get_number_devices
()¶ Returns the number of devices in the network.
Returns: the number of devices in the network. Return type: Integer
-
has_devices
()¶ Returns whether there is any device in the network or not.
Returns: True
if there is at least one device in the network,False
otherwise.Return type: Boolean
-
is_discovery_running
()¶ Returns whether the discovery process is running or not.
Returns: True
if the discovery process is running,False
otherwise.Return type: Boolean
-
remove_device
(remote_xbee_device)¶ Removes the provided remote XBee device from the network.
Parameters: remote_xbee_device ( RemoteXBeeDevice
) – the remote XBee device to be removed from the list.Raises: ValueError – if the provided RemoteXBeeDevice
is not in the network.
-
set_discovery_options
(options)¶ Configures the discovery options (
NO
parameter) with the given value.Parameters: options (Set of
DiscoveryOptions
) – new discovery options, empty set to clear the options.Raises: - ValueError – if
options
isNone
. - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
See also
- ValueError – if
-
set_discovery_timeout
(discovery_timeout)¶ Sets the discovery network timeout.
Parameters: discovery_timeout (Float) – timeout in seconds.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- ValueError – if
discovery_timeout
is not between 0x20 and 0xFF
-
start_discovery_process
()¶ Starts the discovery process. This method is not blocking.
The discovery process will be running until the configured timeout expires or, in case of 802.15.4, until the ‘end’ packet is read.
It may be that, after the timeout expires, there are devices that continue sending discovery packets to this XBee device. In this case, these devices will not be added to the network.
-
stop_discovery_process
()¶ Stops the discovery process if it is running.
Note that DigiMesh/DigiPoint devices are blocked until the discovery time configured (NT parameter) has elapsed, so if you try to get/set any parameter during the discovery process you will receive a timeout exception.
-
-
class
digi.xbee.devices.
DigiMeshNetwork
(device)[source]¶ Bases:
digi.xbee.devices.XBeeNetwork
This class represents a DigiMesh network.
The network allows the discovery of remote devices in the same network as the local one and stores them.
Class constructor. Instantiates a new
DigiMeshNetwork
.Parameters: device ( DigiMeshDevice
) – the local DigiMesh device to get the network from.Raises: ValueError – if device
isNone
.-
add_device_discovered_callback
(callback)¶ Adds a callback for the event
DeviceDiscovered
.Parameters: callback (Function) – the callback. Receives one argument.
- The discovered remote XBee device as a
RemoteXBeeDevice
- The discovered remote XBee device as a
-
add_discovery_process_finished_callback
(callback)¶ Adds a callback for the event
DiscoveryProcessFinished
.Parameters: callback (Function) – the callback. Receives one argument.
- The event code as an
Integer
- The event code as an
-
add_if_not_exist
(x64bit_addr=None, x16bit_addr=None, node_id=None)¶ Adds an XBee device with the provided parameters if it does not exist in the current network.
If the XBee device already exists, its data will be updated with the provided parameters that are not
None
.Parameters: - x64bit_addr (
XBee64BitAddress
, optional) – XBee device’s 64bit address. Optional. - x16bit_addr (
XBee16BitAddress
, optional) – XBee device’s 16bit address. Optional. - node_id (String, optional) – the node identifier of the XBee device. Optional.
Returns: - the remote XBee device with the updated parameters. If the XBee device
was not in the list yet, this method returns the given XBee device without changes.
Return type: - x64bit_addr (
-
add_network_modified_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.NetworkModified
.Parameters: callback (Function) – the callback. Receives one argument.
- The event type as a
NetworkEventType
- The reason of the event as a
NetworkEventReason
- The node added, updated or removed from the network as a
XBeeDevice
orRemoteXBeeDevice
.
- The event type as a
-
add_remote
(remote_xbee_device)¶ Adds the provided remote XBee device to the network if it is not contained yet.
If the XBee device is already contained in the network, its data will be updated with the parameters of the XBee device that are not
None
.Parameters: remote_xbee_device ( RemoteXBeeDevice
) – the remote XBee device to add to the network.Returns: - the provided XBee device with the updated parameters. If the XBee device
- was not in the list yet, this method returns it without changes.
Return type: RemoteXBeeDevice
-
add_remotes
(remote_xbee_devices)¶ Adds a list of remote XBee devices to the network.
If any XBee device of the list is already contained in the network, its data will be updated with the parameters of the XBee device that are not
None
.Parameters: remote_xbee_devices (List) – the list of RemoteXBeeDevice
to add to the network.
-
clear
()¶ Removes all the remote XBee devices from the network.
-
del_device_discovered_callback
(callback)¶ Deletes a callback for the callback list of
DeviceDiscovered
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofDeviceDiscovered
event.
-
del_discovery_process_finished_callback
(callback)¶ Deletes a callback for the callback list of
DiscoveryProcessFinished
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofDiscoveryProcessFinished
event.
-
del_network_modified_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.NetworkModified
.Parameters: callback (Function) – the callback to delete.
-
discover_device
(node_id)¶ Blocking method. Discovers and reports the first remote XBee device that matches the supplied identifier.
Parameters: node_id (String) – the node identifier of the device to be discovered. Returns: - the discovered remote XBee device with the given identifier,
None
if the timeout expires and the device was not found.
Return type: RemoteXBeeDevice
-
discover_devices
(device_id_list)¶ Blocking method. Attempts to discover a list of devices and add them to the current network.
This method does not guarantee that all devices of
device_id_list
will be found, even if they exist physically. This will depend on the node discovery operation (ND
) and timeout.Parameters: device_id_list (List) – list of device IDs to discover. Returns: a list with the discovered devices. It may not contain all devices specified in device_id_list
Return type: List
-
get_device_by_16
(x16bit_addr)¶ Returns the XBee in the network whose 16-bit address matches the given one.
Parameters: x16bit_addr ( XBee16BitAddress
) – The 16-bit address of the device to be retrieved.Returns: the XBee device in the network or None
if it is not found.Return type: AbstractXBeeDevice
Raises: ValueError – if x16bit_addr
isNone
or unknown.
-
get_device_by_64
(x64bit_addr)¶ Returns the XBee in the network whose 64-bit address matches the given one.
Parameters: x64bit_addr ( XBee64BitAddress
) – The 64-bit address of the device to be retrieved.Returns: the XBee device in the network or None
if it is not found.Return type: AbstractXBeeDevice
Raises: ValueError – if x64bit_addr
isNone
or unknown.
-
get_device_by_node_id
(node_id)¶ Returns the XBee in the network whose node identifier matches the given one.
Parameters: node_id (String) – The node identifier of the device to be retrieved. Returns: the XBee device in the network or None
if it is not found.Return type: AbstractXBeeDevice
Raises: ValueError – if node_id
isNone
.
-
get_devices
()¶ Returns a copy of the XBee devices list of the network.
If another XBee device is added to the list before the execution of this method, this XBee device will not be added to the list returned by this method.
Returns: a copy of the XBee devices list of the network. Return type: List
-
get_discovery_callbacks
()¶ Returns the API callbacks that are used in the device discovery process.
This callbacks notify the user callbacks for each XBee device discovered.
Returns: - callback for generic devices discovery process,
- callback for discovery specific XBee device ops.
Return type: Tuple (Function, Function)
-
get_discovery_options
()¶ Returns the network discovery process options.
Returns: the parameter value.
Return type: Bytearray
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
get_discovery_timeout
()¶ Returns the network discovery timeout.
Returns: the network discovery timeout.
Return type: Float
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
get_number_devices
()¶ Returns the number of devices in the network.
Returns: the number of devices in the network. Return type: Integer
-
has_devices
()¶ Returns whether there is any device in the network or not.
Returns: True
if there is at least one device in the network,False
otherwise.Return type: Boolean
-
is_discovery_running
()¶ Returns whether the discovery process is running or not.
Returns: True
if the discovery process is running,False
otherwise.Return type: Boolean
-
remove_device
(remote_xbee_device)¶ Removes the provided remote XBee device from the network.
Parameters: remote_xbee_device ( RemoteXBeeDevice
) – the remote XBee device to be removed from the list.Raises: ValueError – if the provided RemoteXBeeDevice
is not in the network.
-
set_discovery_options
(options)¶ Configures the discovery options (
NO
parameter) with the given value.Parameters: options (Set of
DiscoveryOptions
) – new discovery options, empty set to clear the options.Raises: - ValueError – if
options
isNone
. - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
See also
- ValueError – if
-
set_discovery_timeout
(discovery_timeout)¶ Sets the discovery network timeout.
Parameters: discovery_timeout (Float) – timeout in seconds.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- ValueError – if
discovery_timeout
is not between 0x20 and 0xFF
-
start_discovery_process
()¶ Starts the discovery process. This method is not blocking.
The discovery process will be running until the configured timeout expires or, in case of 802.15.4, until the ‘end’ packet is read.
It may be that, after the timeout expires, there are devices that continue sending discovery packets to this XBee device. In this case, these devices will not be added to the network.
-
stop_discovery_process
()¶ Stops the discovery process if it is running.
Note that DigiMesh/DigiPoint devices are blocked until the discovery time configured (NT parameter) has elapsed, so if you try to get/set any parameter during the discovery process you will receive a timeout exception.
-
-
class
digi.xbee.devices.
DigiPointNetwork
(device)[source]¶ Bases:
digi.xbee.devices.XBeeNetwork
This class represents a DigiPoint network.
The network allows the discovery of remote devices in the same network as the local one and stores them.
Class constructor. Instantiates a new
DigiPointNetwork
.Parameters: device ( DigiPointDevice
) – the local DigiPoint device to get the network from.Raises: ValueError – if device
isNone
.-
add_device_discovered_callback
(callback)¶ Adds a callback for the event
DeviceDiscovered
.Parameters: callback (Function) – the callback. Receives one argument.
- The discovered remote XBee device as a
RemoteXBeeDevice
- The discovered remote XBee device as a
-
add_discovery_process_finished_callback
(callback)¶ Adds a callback for the event
DiscoveryProcessFinished
.Parameters: callback (Function) – the callback. Receives one argument.
- The event code as an
Integer
- The event code as an
-
add_if_not_exist
(x64bit_addr=None, x16bit_addr=None, node_id=None)¶ Adds an XBee device with the provided parameters if it does not exist in the current network.
If the XBee device already exists, its data will be updated with the provided parameters that are not
None
.Parameters: - x64bit_addr (
XBee64BitAddress
, optional) – XBee device’s 64bit address. Optional. - x16bit_addr (
XBee16BitAddress
, optional) – XBee device’s 16bit address. Optional. - node_id (String, optional) – the node identifier of the XBee device. Optional.
Returns: - the remote XBee device with the updated parameters. If the XBee device
was not in the list yet, this method returns the given XBee device without changes.
Return type: - x64bit_addr (
-
add_network_modified_callback
(callback)¶ Adds a callback for the event
digi.xbee.reader.NetworkModified
.Parameters: callback (Function) – the callback. Receives one argument.
- The event type as a
NetworkEventType
- The reason of the event as a
NetworkEventReason
- The node added, updated or removed from the network as a
XBeeDevice
orRemoteXBeeDevice
.
- The event type as a
-
add_remote
(remote_xbee_device)¶ Adds the provided remote XBee device to the network if it is not contained yet.
If the XBee device is already contained in the network, its data will be updated with the parameters of the XBee device that are not
None
.Parameters: remote_xbee_device ( RemoteXBeeDevice
) – the remote XBee device to add to the network.Returns: - the provided XBee device with the updated parameters. If the XBee device
- was not in the list yet, this method returns it without changes.
Return type: RemoteXBeeDevice
-
add_remotes
(remote_xbee_devices)¶ Adds a list of remote XBee devices to the network.
If any XBee device of the list is already contained in the network, its data will be updated with the parameters of the XBee device that are not
None
.Parameters: remote_xbee_devices (List) – the list of RemoteXBeeDevice
to add to the network.
-
clear
()¶ Removes all the remote XBee devices from the network.
-
del_device_discovered_callback
(callback)¶ Deletes a callback for the callback list of
DeviceDiscovered
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofDeviceDiscovered
event.
-
del_discovery_process_finished_callback
(callback)¶ Deletes a callback for the callback list of
DiscoveryProcessFinished
event.Parameters: callback (Function) – the callback to delete. Raises: ValueError – if callback
is not in the callback list ofDiscoveryProcessFinished
event.
-
del_network_modified_callback
(callback)¶ Deletes a callback for the callback list of
digi.xbee.reader.NetworkModified
.Parameters: callback (Function) – the callback to delete.
-
discover_device
(node_id)¶ Blocking method. Discovers and reports the first remote XBee device that matches the supplied identifier.
Parameters: node_id (String) – the node identifier of the device to be discovered. Returns: - the discovered remote XBee device with the given identifier,
None
if the timeout expires and the device was not found.
Return type: RemoteXBeeDevice
-
discover_devices
(device_id_list)¶ Blocking method. Attempts to discover a list of devices and add them to the current network.
This method does not guarantee that all devices of
device_id_list
will be found, even if they exist physically. This will depend on the node discovery operation (ND
) and timeout.Parameters: device_id_list (List) – list of device IDs to discover. Returns: a list with the discovered devices. It may not contain all devices specified in device_id_list
Return type: List
-
get_device_by_16
(x16bit_addr)¶ Returns the XBee in the network whose 16-bit address matches the given one.
Parameters: x16bit_addr ( XBee16BitAddress
) – The 16-bit address of the device to be retrieved.Returns: the XBee device in the network or None
if it is not found.Return type: AbstractXBeeDevice
Raises: ValueError – if x16bit_addr
isNone
or unknown.
-
get_device_by_64
(x64bit_addr)¶ Returns the XBee in the network whose 64-bit address matches the given one.
Parameters: x64bit_addr ( XBee64BitAddress
) – The 64-bit address of the device to be retrieved.Returns: the XBee device in the network or None
if it is not found.Return type: AbstractXBeeDevice
Raises: ValueError – if x64bit_addr
isNone
or unknown.
-
get_device_by_node_id
(node_id)¶ Returns the XBee in the network whose node identifier matches the given one.
Parameters: node_id (String) – The node identifier of the device to be retrieved. Returns: the XBee device in the network or None
if it is not found.Return type: AbstractXBeeDevice
Raises: ValueError – if node_id
isNone
.
-
get_devices
()¶ Returns a copy of the XBee devices list of the network.
If another XBee device is added to the list before the execution of this method, this XBee device will not be added to the list returned by this method.
Returns: a copy of the XBee devices list of the network. Return type: List
-
get_discovery_callbacks
()¶ Returns the API callbacks that are used in the device discovery process.
This callbacks notify the user callbacks for each XBee device discovered.
Returns: - callback for generic devices discovery process,
- callback for discovery specific XBee device ops.
Return type: Tuple (Function, Function)
-
get_discovery_options
()¶ Returns the network discovery process options.
Returns: the parameter value.
Return type: Bytearray
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
get_discovery_timeout
()¶ Returns the network discovery timeout.
Returns: the network discovery timeout.
Return type: Float
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
-
get_number_devices
()¶ Returns the number of devices in the network.
Returns: the number of devices in the network. Return type: Integer
-
has_devices
()¶ Returns whether there is any device in the network or not.
Returns: True
if there is at least one device in the network,False
otherwise.Return type: Boolean
-
is_discovery_running
()¶ Returns whether the discovery process is running or not.
Returns: True
if the discovery process is running,False
otherwise.Return type: Boolean
-
remove_device
(remote_xbee_device)¶ Removes the provided remote XBee device from the network.
Parameters: remote_xbee_device ( RemoteXBeeDevice
) – the remote XBee device to be removed from the list.Raises: ValueError – if the provided RemoteXBeeDevice
is not in the network.
-
set_discovery_options
(options)¶ Configures the discovery options (
NO
parameter) with the given value.Parameters: options (Set of
DiscoveryOptions
) – new discovery options, empty set to clear the options.Raises: - ValueError – if
options
isNone
. - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
See also
- ValueError – if
-
set_discovery_timeout
(discovery_timeout)¶ Sets the discovery network timeout.
Parameters: discovery_timeout (Float) – timeout in seconds.
Raises: - TimeoutException – if the response is not received before the read timeout expires.
- XBeeException – if the XBee device’s serial port is closed.
- InvalidOperatingModeException – if the XBee device’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.
- ATCommandException – if the response is not as expected.
- ValueError – if
discovery_timeout
is not between 0x20 and 0xFF
-
start_discovery_process
()¶ Starts the discovery process. This method is not blocking.
The discovery process will be running until the configured timeout expires or, in case of 802.15.4, until the ‘end’ packet is read.
It may be that, after the timeout expires, there are devices that continue sending discovery packets to this XBee device. In this case, these devices will not be added to the network.
-
stop_discovery_process
()¶ Stops the discovery process if it is running.
Note that DigiMesh/DigiPoint devices are blocked until the discovery time configured (NT parameter) has elapsed, so if you try to get/set any parameter during the discovery process you will receive a timeout exception.
-
-
class
digi.xbee.devices.
NetworkEventType
(code, description)[source]¶ Bases:
enum.Enum
Enumerates the different network event types.Values:NetworkEventType.ADD = (0, ‘XBee added to the network’)NetworkEventType.DEL = (1, ‘XBee removed from the network’)NetworkEventType.UPDATE = (2, ‘XBee in the network updated’)NetworkEventType.CLEAR = (3, ‘Network cleared’)-
code
¶ Returns the code of the
NetworkEventType
element.Returns: the code of the NetworkEventType
element.Return type: Integer
-
description
¶ Returns the description of the
NetworkEventType
element.Returns: the description of the NetworkEventType
element.Return type: String
-
-
class
digi.xbee.devices.
NetworkEventReason
(code, description)[source]¶ Bases:
enum.Enum
Enumerates the different network event reasons.Values:NetworkEventReason.DISCOVERED = (0, ‘Discovered XBee’)NetworkEventReason.RECEIVED_MSG = (1, ‘Received message from XBee’)NetworkEventReason.MANUAL = (2, ‘Manual modification’)-
code
¶ Returns the code of the
NetworkEventReason
element.Returns: the code of the NetworkEventReason
element.Return type: Integer
-
description
¶ Returns the description of the
NetworkEventReason
element.Returns: the description of the NetworkEventReason
element.Return type: String
-