1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-07-11 15:22:13 +03:00

Add progress callback to Updater class. (#5754)

* Add progress callback to Updater class.

This is a backport of the same functionality in the ESP32 core.

* Add progress callback to Updater class.

* Add typedef for callback function.

* Fixed initializing order.

* Added missing include (functional).
This commit is contained in:
Clemens Kirchgatterer
2019-02-17 03:45:24 +01:00
committed by Develo
parent 9f9c661d99
commit 14f1b1d4a7
2 changed files with 25 additions and 1 deletions

View File

@ -4,6 +4,7 @@
#include <Arduino.h>
#include <flash_utils.h>
#include <MD5Builder.h>
#include <functional>
#define UPDATE_ERROR_OK (0)
#define UPDATE_ERROR_WRITE (1)
@ -48,6 +49,8 @@ class UpdaterVerifyClass {
class UpdaterClass {
public:
typedef std::function<void(size_t, size_t)> THandlerFunction_Progress;
UpdaterClass();
/* Optionally add a cryptographic signature verification hash and method */
@ -111,6 +114,11 @@ class UpdaterClass {
*/
void md5(uint8_t * result){ return _md5.getBytes(result); }
/*
This callback will be called when Updater is receiving data
*/
UpdaterClass& onProgress(THandlerFunction_Progress fn);
//Helpers
uint8_t getError(){ return _error; }
void clearError(){ _error = UPDATE_ERROR_OK; }
@ -191,6 +199,8 @@ class UpdaterClass {
// Optional signed binary verification
UpdaterHashClass *_hash;
UpdaterVerifyClass *_verify;
// Optional progress callback function
THandlerFunction_Progress _progress_callback;
};
extern UpdaterClass Update;