added before OTA update hook
This commit is contained in:
parent
6cf7f4e4a9
commit
25f0da56f8
|
|
@ -108,6 +108,7 @@ void GetRFC3339Time(char *t);
|
|||
void StartTimeGet(void);
|
||||
|
||||
esp_err_t StartOTA(void);
|
||||
void regHookBeforeUpdate(void (*before_update)(void));
|
||||
char* GetAvailVersion();
|
||||
char* GetUpdateStatus();
|
||||
|
||||
|
|
|
|||
|
|
@ -48,6 +48,12 @@ char FwUpdStatus[64] = "<div class='clok'>Updated</div>";
|
|||
#define HASH_LEN 32
|
||||
#define REPORT_PACKETS_EVERY 100
|
||||
|
||||
void (*HookBeforeUpdate)(void);
|
||||
void regHookBeforeUpdate(void (*before_update)(void))
|
||||
{
|
||||
HookBeforeUpdate = before_update;
|
||||
}
|
||||
|
||||
esp_err_t _http_event_handler(esp_http_client_event_t *evt)
|
||||
{
|
||||
switch (evt->event_id)
|
||||
|
|
@ -174,6 +180,7 @@ esp_err_t my_esp_https_ota(const esp_http_client_config_t *config)
|
|||
if (need_to_update)
|
||||
{
|
||||
ESP_LOGW(TAG, "New firmware has newer build, START update firmware");
|
||||
HookBeforeUpdate();
|
||||
int countPackets = 0;
|
||||
while (1)
|
||||
{
|
||||
|
|
@ -304,7 +311,7 @@ esp_err_t StartOTA(void)
|
|||
}
|
||||
ESP_LOGI(TAG, "Starting OTA Task");
|
||||
strcpy(FwUpdStatus, "<div class='clwarn'>Start update...</div>");
|
||||
xTaskCreate(OTATask, "OTATask", 1024 * 8, (void*) 0, 3, NULL);
|
||||
xTaskCreate(OTATask, "OTATask", 1024 * 8, (void*) 0, 5, NULL);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user