digi.xbee.firmware module

class digi.xbee.firmware.UpdateConfigurer(node, timeout=None, callback=None)[source]

Bases: object

For internal use only. Helper class used to prepare nodes and/or network for an update.

Class constructor. Instantiates a new UpdateConfigurer with the given parameters.

Parameters:
  • node (AbstractXBeeDevice) – Target being updated.
  • timeout (Float, optional, default=`None`) – Operations timeout.
  • callback (Function) – Function to notify about the progress.
sync_sleep

Returns whether node is part of a DigiMesh synchronous sleeping network.

Returns:True if it synchronous sleeps, False otherwise.
Return type:Boolean
prepare_total

Returns the total work for update preparation step.

Returns:Total prepare work.
Return type:Integer
restore_total

Returns the total work for update restoration step.

Returns:Total restore work.
Return type:Integer
prepare_for_update(prepare_node=True, prepare_net=True, restore_later=True)[source]

Prepares the node for an update process.

Parameters:
  • prepare_node (Boolean, optional, default=`True`) – True to prepare the node.
  • prepare_net (Boolean, optional, default=`True`) – True to prepare the network.
  • restore_later (Boolean, optional, default=`True`) – True to restore node original values when finish the update process.
Raises:

XBeeException – If cannot get network synchronous sleep configuration, or cannot prepare the network.

restore_after_update(restore_settings=True, port_settings=None)[source]

Restores the node after an update process.

Parameters:
  • restore_settings (Boolean, optional, default=`True`) – True to restore stored settings, False otherwise.
  • port_settings (Dictionary, optional, default=`None`) – Dictionary with the new serial port configuration, None for remote node or if the serial config has not changed.
static exec_at_cmd(func, node, cmd, value=None, retries=5, apply=False)[source]

Reads the given parameter from the XBee with the given number of retries.

Parameters:
  • func (Function) – Function to execute.
  • node (AbstractXBeeDevice) – XBee to get/set parameter.
  • (String or (cmd) – class: ATStringCommand): Parameter to get/set.
  • value (Bytearray, optional, default=`None`) – Value to set.
  • retries (Integer, optional, default=5) – Number of retries to perform.
  • apply (Boolean, optional, default=`False`) – True to apply.
Returns:

Read parameter value.

Return type:

Bytearray

Raises:

XBeeException – If the value could be get/set after the retries.

progress_cb(task, done=0)[source]

If a callback was provided in the constructor, notifies it with the provided task and the corresponding percentage.

Parameters:
  • task (String) – The task to inform about, it must be TASK_PREPARE or TASK_RESTORE.
  • done (Integer, optional, default=0) – Total amount of done job. If 0, it is increased by one.
Returns:

Total work done for the task.

Return type:

Integer

class digi.xbee.firmware.FwUpdateTask(xbee, xml_fw_path, fw_path=None, bl_fw_path=None, timeout=None, progress_cb=None)[source]

Bases: object

This class represents a firmware update process for a given XBee.

Class constructor. Instantiates a new FwUpdateTask object.

Parameters:
  • xbee (AbstractXBeeDevice) – XBee to update.
  • xml_fw_path (String) – Path of the XML file that describes the firmware.
  • fw_path (String, optional) – Location of the XBee binary firmware file.
  • bl_fw_path (String, optional) – Location of the bootloader binary firmware file.
  • timeout (Integer, optional) – Serial port read data timeout.
  • progress_cb (Function, optional) –

    Function to receive progress information. Receives two arguments:

    • The current update task as a String
    • The current update task percentage as an Integer
Raises:

ValueError – If the XBee device or the XML firmware file path are None or invalid. Also if the firmware binary file path or the bootloader file path are specified and does not exist.

xbee

Gets the XBee for this task.

Returns:The XBee to update.
Return type:AbstractXBeeDevice
xml_path

Gets the XML firmware file path.

Returns:The XML file path for the update task.
Return type:String
fw_path

Gets the binary firmware file path.

Returns:The binary file path for the update task.
Return type:String
bl_path

Gets the bootloader file path.

Returns:The bootloader file path for the update task.
Return type:String
timeout

Gets the maximum time to wait for read operations.

Returns:The maximum time to wait for read operations.
Return type:Integer
callback

Returns the function to receive progress status information.

Returns:
The callback method to received progress information.
None if not registered.
Return type:Function
digi.xbee.firmware.update_local_firmware(target, xml_fw_file, xbee_firmware_file=None, bootloader_firmware_file=None, timeout=None, progress_callback=None)[source]

Performs a local firmware update operation in the given target.

Parameters:
  • target (String or XBeeDevice) – Target of the firmware upload operation. String: serial port identifier. XBeeDevice: XBee to upload its firmware.
  • xml_fw_file (String) – Path of the XML file that describes the firmware.
  • 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) – Serial port read data timeout.
  • progress_callback (Function, optional) –

    Function to receive progress information. Receives two arguments:

    • The current update task as a String
    • The current update task percentage as an Integer
Raises:

FirmwareUpdateException – If there is any error performing the firmware update.

digi.xbee.firmware.update_remote_firmware(remote, xml_fw_file, firmware_file=None, bootloader_file=None, max_block_size=0, timeout=None, progress_callback=None)[source]

Performs a remote firmware update operation in the given target.

Parameters:
  • remote (RemoteXBeeDevice) – Remote XBee to upload.
  • xml_fw_file (String) – Path of the XML file that describes the firmware.
  • firmware_file (String, optional) – Path of the binary firmware file.
  • bootloader_file (String, optional) – Path of the bootloader firmware file.
  • max_block_size (Integer, optional) – Maximum size of the ota block to send.
  • timeout (Integer, optional) – Timeout to wait for remote frame requests.
  • progress_callback (Function, optional) –

    Function to receive progress information. Receives two arguments:

    • The current update task as a String
    • The current update task percentage as an Integer
Raises:

FirmwareUpdateException – if there is any error performing the remote firmware update.

digi.xbee.firmware.update_remote_filesystem(remote, ota_fs_file, max_block_size=0, timeout=None, progress_callback=None)[source]

Performs a remote filesystem update operation in the given target.

Parameters:
  • remote (RemoteXBeeDevice) – Remote XBee to update its filesystem.
  • ota_fs_file (String) – Path of the OTA filesystem image file.
  • max_block_size (Integer, optional) – Maximum size of the ota block to send.
  • timeout (Integer, optional) – Timeout to wait for remote frame requests.
  • progress_callback (Function, optional) –

    Function to receive progress information. Receives two arguments:

    • The current update task as a String
    • The current update task percentage as an Integer
Raises:

FirmwareUpdateException – If there is any error updating the remote filesystem image.