![]() |
ThingsBoard Client SDK 0.16.0
Client SDK to connect with ThingsBoard IoT Platform from IoT devices (Arduino, Espressif, etc.)
|
Over the air firmware update callback wrapper. More...
#include <OTA_Update_Callback.h>
Public Member Functions | |
| OTA_Update_Callback ()=default | |
| Constructs empty callbacks, will result in never being called. Internals are simply default constructed as nullptr. More... | |
| OTA_Update_Callback (char const *current_fw_title, char const *current_fw_version, IUpdater *updater, function finished_callback, Callback< void, size_t const &, size_t const & >::function progress_callback=nullptr, Callback< void >::function update_starting_callback=nullptr, uint8_t chunk_retries=CHUNK_RETRIES, uint16_t chunk_size=CHUNK_SIZE, uint64_t const &timeout_microseconds=REQUEST_TIMEOUT_MS) | |
| Constructs callbacks that will be called to inform about the OTA firmware update process. More... | |
| ~OTA_Update_Callback () override=default | |
| char const * | Get_Firmware_Title () const |
| Gets the current firmware title. More... | |
| void | Set_Firmware_Title (const char *current_fw_title) |
| Sets the current firmware title. More... | |
| char const * | Get_Firmware_Version () const |
| Gets the current firmware version. More... | |
| void | Set_Firmware_Version (const char *current_fw_version) |
| Sets the current firmware version. More... | |
| IUpdater * | Get_Updater () const |
| Gets the updater implementation, used to write the actual firmware data into the needed memory location, so it can be used to reboot the given device with that new flashed firmware. More... | |
| void | Set_Updater (IUpdater *updater) |
| Sets the updater implementation, used to write the actual firmware data into the needed memory location, so it can be used to reboot the given device with that new flashed firmware. More... | |
| size_t const & | Get_Request_ID () const |
| Gets the unique request identifier that is connected to the original request. More... | |
| void | Set_Request_ID (size_t const &request_id) |
| Sets the unique request identifier that is connected to the original request. More... | |
| void | Call_Progress_Callback (size_t const ¤t, size_t const &total) const |
| Calls the progress callback that was subscribed, when this class instance was initally created. More... | |
| void | Set_Progress_Callback (Callback< void, size_t const &, size_t const & >::function progress_callback) |
| Sets the progress callback method. More... | |
| void | Call_Update_Starting_Callback () const |
| Calls the update starting callback that was subscribed, when this class instance was initally created. More... | |
| void | Set_Update_Starting_Callback (Callback< void >::function update_starting_callback) |
| Sets the update starting callback method. More... | |
| uint8_t | Get_Chunk_Retries () const |
| Gets the amount of times we attempt to download each chunk of the OTA firmware binary file. More... | |
| void | Set_Chunk_Retries (uint8_t chunk_retries) |
| Sets the amount of times we attempt to download each chunk of the OTA firmware binary file. More... | |
| uint16_t | Get_Chunk_Size () const |
| Gets the size of the chunks that the firmware binary data will be split into. More... | |
| void | Set_Chunk_Size (uint16_t chunk_size) |
| Sets the size of the chunks that the firmware binary data will be split into. More... | |
| Timeoutable_Request & | Get_Request_Timeout () |
| Gets the request timeout callback. More... | |
Public Member Functions inherited from Callback< void, bool const & > | |
| Callback ()=default | |
| Constructs empty callback, will result in never being called. Internals are simply default constructed as nullptr. More... | |
| Callback (function callback) | |
| Constructor. More... | |
| virtual | ~Callback ()=default |
| Virtual default destructor, created to ensure that if a pointer to this class is used and deleted, we will also call the derived base class destructor. More... | |
| void | Call_Callback (argument_types const &... arguments) const |
| Calls the callback that was subscribed, when this class instance was initally created. More... | |
| void | Set_Callback (function callback) |
| Sets the callback method that will be called upon data arrival with the given data that was received. If nullptr is passed the callback will never be called and instead return with a defaulted instance of the requested return variable. More... | |
Additional Inherited Members | |
Public Types inherited from Callback< void, bool const & > | |
| using | function = std::function< void(argument_types... arguments)> |
| Callback signature. More... | |
Over the air firmware update callback wrapper.
|
default |
Constructs empty callbacks, will result in never being called. Internals are simply default constructed as nullptr.
| OTA_Update_Callback::OTA_Update_Callback | ( | char const * | current_fw_title, |
| char const * | current_fw_version, | ||
| IUpdater * | updater, | ||
| function | finished_callback, | ||
| Callback< void, size_t const &, size_t const & >::function | progress_callback = nullptr, |
||
| Callback< void >::function | update_starting_callback = nullptr, |
||
| uint8_t | chunk_retries = CHUNK_RETRIES, |
||
| uint16_t | chunk_size = CHUNK_SIZE, |
||
| uint64_t const & | timeout_microseconds = REQUEST_TIMEOUT_MS |
||
| ) |
Constructs callbacks that will be called to inform about the OTA firmware update process.
| current_fw_title | Non owning pointer to the firmware title the device has choosen, is used to only allow updates with the same given title, other updates will be canceled. Additionally it has to be kept alive by the user for the runtime of the OTA Update process |
| current_fw_version | Non owning pointer to the firmware version the device is currently on, is used to only allow updates with a different version, other updates will be canceled. Additionally it has to be kept alive by the user for the runtime of the OTA Update process |
| updater | Non owning pointer to the updater implementation that writes the given firmware data. Additionally it has to be kept alive by the user for the runtime of the OTA Update process |
| finished_callback | End callback method that will be called as soon as the OTA firmware update, either finished successfully or failed. Is meant to allow to either restart the device if the udpate was successfull or to restart any stopped services before the update started in the subscribed update_starting_callback |
| progress_callback | Progress callback method that will be called every time our current progress of downloading the complete firmware data changed, meaning it will be called if the amount of already downloaded chunks increased. Is meant to allow to display a progress bar or print the current progress of the update into the console with the currently already downloaded amount of chunks and the total amount of chunks, default = nullptr |
| update_starting_callback | Update starting callback method that will be called as soon as the shared attribute firmware keys have been received and processed and the moment before we subscribe the necessary topics for the OTA firmware update. Is meant to give a moment were any additional processes or communication with the cloud can be stopped to ensure the update process runs as smooth as possible. To ensure that calling the ThingsBoardSized::Cleanup_Subscriptions() method can be used which stops any receiving of data over MQTT besides the one for the OTA firmware update, if this method is used ensure to call all subscribe methods again so they can be resubscribed, in the method passed to the finished_callback if the update failed and we do not restart the device, default = nullptr |
| chunk_retries | Amount of retries the OTA firmware update has to download each seperate chunk with a given size, before the complete download is stopped and registered as failed, default = CHUNK_RETRIES |
| chunk_size | Size of the chunks that the firmware binary data will be split into, increased chunk size might speed up the process by a little bit, but requires more heap memory, |
| timeout | Maximum amount of time in microseconds for the OTA firmware update for each seperate chunk, until that chunk counts as a timeout, retries is then subtraced by one and the download is retried, default = REQUEST_TIMEOUT_MS |
|
overridedefault |
| void OTA_Update_Callback::Call_Progress_Callback | ( | size_t const & | current, |
| size_t const & | total | ||
| ) | const |
Calls the progress callback that was subscribed, when this class instance was initally created.
| current | Already received and processsed amount of chunks |
| total | Total amount of chunks we need to receive and process until the update has completed |
| void OTA_Update_Callback::Call_Update_Starting_Callback | ( | ) | const |
Calls the update starting callback that was subscribed, when this class instance was initally created.
| uint8_t OTA_Update_Callback::Get_Chunk_Retries | ( | ) | const |
Gets the amount of times we attempt to download each chunk of the OTA firmware binary file.
| uint16_t OTA_Update_Callback::Get_Chunk_Size | ( | ) | const |
Gets the size of the chunks that the firmware binary data will be split into.
| char const * OTA_Update_Callback::Get_Firmware_Title | ( | ) | const |
Gets the current firmware title.
| char const * OTA_Update_Callback::Get_Firmware_Version | ( | ) | const |
Gets the current firmware version.
| size_t const & OTA_Update_Callback::Get_Request_ID | ( | ) | const |
Gets the unique request identifier that is connected to the original request.
| Timeoutable_Request & OTA_Update_Callback::Get_Request_Timeout | ( | ) |
Gets the request timeout callback.
| IUpdater * OTA_Update_Callback::Get_Updater | ( | ) | const |
Gets the updater implementation, used to write the actual firmware data into the needed memory location, so it can be used to reboot the given device with that new flashed firmware.
| void OTA_Update_Callback::Set_Chunk_Retries | ( | uint8_t | chunk_retries | ) |
Sets the amount of times we attempt to download each chunk of the OTA firmware binary file.
| chunk_retries | Amount of retries for each single chunk before we abort the update |
| void OTA_Update_Callback::Set_Chunk_Size | ( | uint16_t | chunk_size | ) |
Sets the size of the chunks that the firmware binary data will be split into.
| chunk_size | Size of each single chunk to be downloaded |
| void OTA_Update_Callback::Set_Firmware_Title | ( | const char * | current_fw_title | ) |
Sets the current firmware title.
| current_fw_title | Non owning pointer to the current firmware title of the device. Additionally it has to be kept alive by the user for the runtime of the OTA Update process |
| void OTA_Update_Callback::Set_Firmware_Version | ( | const char * | current_fw_version | ) |
Sets the current firmware version.
| current_fw_version | Non owning pointer to the current firmware version of the device. Additionally it has to be kept alive by the user for the runtime of the OTA Update process |
| void OTA_Update_Callback::Set_Progress_Callback | ( | Callback< void, size_t const &, size_t const & >::function | progress_callback | ) |
Sets the progress callback method.
| progress_callback | Progress callback method that will be called every time our current progress of downloading and processing the complete firmware data changed, meaning it will be called if the amount of already downloaded chunks increased |
| void OTA_Update_Callback::Set_Request_ID | ( | size_t const & | request_id | ) |
Sets the unique request identifier that is connected to the original request.
| request_id | Unique identifier connected to the request to start the OTA firmware update |
| void OTA_Update_Callback::Set_Update_Starting_Callback | ( | Callback< void >::function | update_starting_callback | ) |
Sets the update starting callback method.
| update_starting_callback | Update starting callback method that will be called as soon as the shared attribute firmware keys have been received and processed and the moment before we subscribe the necessary topics for the OTA firmware update |
| void OTA_Update_Callback::Set_Updater | ( | IUpdater * | updater | ) |
Sets the updater implementation, used to write the actual firmware data into the needed memory location, so it can be used to reboot the given device with that new flashed firmware.
| updater | Updater implementation that writes the given firmware data. Additionally it has to be kept alive by the user for the runtime of the OTA Update process |