blue_st_sdk.firmware_upgrade package¶
Subpackages¶
Submodules¶
blue_st_sdk.firmware_upgrade.firmware_upgrade module¶
firmware_upgrade
The firmware_upgrade module is responsible for managing the upgrading process of devices’ firmware via Bluetooth Low Energy (BLE).
-
class
blue_st_sdk.firmware_upgrade.firmware_upgrade.
FirmwareUpgrade
[source]¶ Bases:
object
Class to handle the firmware upgrade capability for a device running the BlueST Protocol.
-
add_listener
(listener)[source]¶ Add a listener.
- Args:
- listener (
blue_st_sdk.firmware_upgrade.utils.firmware_upgrade.FirmwareUpgradeListener
): Listener to be added.
-
get_console
(node)[source]¶ Get an instance of this class.
- Args:
- node (
blue_st_sdk.node.Node
): Node whose firmware has to be updated. - Returns:
blue_st_sdk.firmware_upgrade.firmware_upgrade.FirmwareUpgrade
: An instance of this class if the given node implements the BlueST protocol, “None” otherwise.- Raises:
NotImplementedError
if the method has not been implemented.
-
remove_listener
(listener)[source]¶ Remove a listener.
- Args:
- listener (
blue_st_sdk.firmware_upgrade.utils.firmware_upgrade.FirmwareUpgradeListener
): Listener to be removed.
-
upgrade_firmware
(firmware_file)[source]¶ Upgrade the firmware onto the device assiciated to the debug console. The firmware is loaded starting from the address “0x0804000”.
- Args:
- firmware_file (
blue_st_sdk.firmware_upgrade.utils.firmware_file.FirmwareFile
): Firmware file. - Raises:
NotImplementedError
if the method has not been implemented.OSError
if the file is not found or is inaccessible.ValueError
if the firmware file can not be read properly.- Returns:
- bool: True if the upload starts correctly, False otherwise.
-
-
class
blue_st_sdk.firmware_upgrade.firmware_upgrade.
FirmwareUpgradeError
[source]¶ Bases:
enum.Enum
Class with different errors that may happen when upgrading the firmware
-
CORRUPTED_FILE_ERROR
= 0¶
-
INVALID_FIRMWARE_ERROR
= 2¶
-
TRANSMISSION_ERROR
= 1¶
-
-
class
blue_st_sdk.firmware_upgrade.firmware_upgrade.
FirmwareUpgradeListener
[source]¶ Bases:
object
Interface used by the
blue_st_sdk.firmware_upgrade.firmware_upgrade.FirmwareUpgrade
class to notify changes of the firmware uprgade process.-
on_upgrade_firmware_complete
(debug_console, firmware_file, bytes_sent)[source]¶ To be called whenever the firmware has been upgraded correctly.
- Args:
- debug_console (
blue_st_sdk.debug_console.DebugConsole
): Debug console. firmware_file (blue_st_sdk.firmware_upgrade.utils.firmware_file.FirmwareFile
): Firmware file. bytes_sent (int): Data sent in bytes. - Raises:
NotImplementedError
if the method has not been implemented.
-
on_upgrade_firmware_error
(debug_console, firmware_file, error)[source]¶ To be called whenever there is an error in upgrading the firmware.
- Args:
- debug_console (
blue_st_sdk.debug_console.DebugConsole
): Debug console. firmware_file (blue_st_sdk.firmware_upgrade.utils.firmware_file.FirmwareFile
): Firmware file. error (blue_st_sdk.firmware_upgrade.firmware_upgrade.FirmwareUpgradeError
): Error code. - Raises:
NotImplementedError
if the method has not been implemented.
-
on_upgrade_firmware_progress
(debug_console, firmware_file, bytes_sent)[source]¶ To be called whenever there is an update in upgrading the firmware, i.e. a block of data has been correctly sent and it is possible to send a new one.
- Args:
- debug_console (
blue_st_sdk.debug_console.DebugConsole
): Debug console. firmware_file (blue_st_sdk.firmware_upgrade.utils.firmware_file.FirmwareFile
): Firmware file. bytes_sent (int): Data sent in bytes. bytes_to_send (int): Data to send in bytes. - Raises:
NotImplementedError
if the method has not been implemented.
-
blue_st_sdk.firmware_upgrade.firmware_upgrade_nucleo module¶
firmware_upgrade
The firmware_upgrade_nucleo module is responsible for managing the upgrading process of devices’firmware via Bluetooth Low Energy (BLE).
-
class
blue_st_sdk.firmware_upgrade.firmware_upgrade_nucleo.
FirmwareUpgradeDebugConsoleListener
(firmware_upgrade_console)[source]¶ Bases:
blue_st_sdk.debug_console.DebugConsoleListener
Class that handles the upgrade of the firmware file to a device via Bluetooth.
-
ACK_MSG
= u'\x01'¶ Acknowledgement message.
-
BLOCK_OF_PACKETS_SIZE
= 10¶ Sending a block of packets at a time, in order to not to stress the Bluetooth too much.
-
FIRMWARE_UPGRADE_COMMAND
= 'upgradeFw'¶ Firmware upgrade command.
-
FIRMWARE_UPGRADE_TIMEOUT_ms
= 4000¶ Increased timeout for sending a message
-
LOST_MSG_TIMEOUT_ms
= 1000¶ Timeout for sending a message.
-
MAX_MSG_SIZE
= 16¶ The STM32L4 Family can write only 8 bytes at a time, thus sending a multiple of 8 bytes simplifies the code.
-
__init__
(firmware_upgrade_console)[source]¶ Costructor.
- Args:
- firmware_upgrade_console (FirmwareUpgrade): Firmware upgrade console used to call user-defined listener’s methods.
-
load_file
(firmware_file)[source]¶ Starts to upload the firmware.
- Args:
- firmware_file (
blue_st_sdk.firmware_upgrade.utils.firmware_file.FirmwareFile
): Firmware file. - Raises:
OSError
if the file is not found or is inaccessible.ValueError
if the firmware file can not be read properly.
-
on_stderr_receive
(debug, message)[source]¶ Called whenever a message is received on the standard error.
- Args:
- debug_console (object): Console that sends the message. message (str): The message received on the stderr console.
- Raises:
NotImplementedError
if the method has not been implemented.
-
on_stdin_send
(debug_console, message, status)[source]¶ Called whenever a message is sent to the standard input.
A message is sent to the standard input whenever some data are written to the debug console.
- Args:
- debug_console (object): Console that receives the message. message (str): The message sent to the stdin console. status (bool): True if the message is sent correctly, False otherwise.
- Raises:
NotImplementedError
if the method has not been implemented.
-
on_stdout_receive
(debug_console, message)[source]¶ Called whenever a message is received on the standard output.
- A message is received on the standard output in two cases:
- When the device sends back the CRC received from the gateway.
- When the device sends an ACK or a NACK message after receiving the firmware file and comparing the CRC computed on it with the CRC previously received from the gateway.
- Args:
- debug_console (object): Console that sends the message. message (str): The message received on the stdout console.
- Raises:
NotImplementedError
if the method has not been implemented.
-
-
class
blue_st_sdk.firmware_upgrade.firmware_upgrade_nucleo.
FirmwareUpgradeNucleo
(debug_console)[source]¶ Bases:
blue_st_sdk.firmware_upgrade.firmware_upgrade.FirmwareUpgrade
Class that implements the firmware upgrade capability for a Nucleo device.
-
__init__
(debug_console)[source]¶ Constructor.
- Args:
- debug_console (
blue_st_sdk.firmware_upgrade.debug.Debug
): Console used to send commands.
-
classmethod
get_console
(node)[source]¶ Get an instance of this class.
- Args:
- node (
blue_st_sdk.node.Node
): Node whose firmware has to be updated. - Returns:
blue_st_sdk.firmware_upgrade.firmware_upgrade.FirmwareUpgrade
: An instance of this class if the given node implements the BlueST protocol, “None” otherwise.
-
upgrade_firmware
(firmware_file)[source]¶ Upgrade the firmware onto the device assiciated to the debug console. The firmware is loaded starting from the address “0x0804000”.
- Args:
- firmware_file (
blue_st_sdk.firmware_upgrade.utils.firmware_file.FirmwareFile
): Firmware file. - Raises:
OSError
if the file is not found or is inaccessible.ValueError
if the firmware file can not be read properly.- Returns:
- bool: True if the upload starts correctly, False otherwise.
-