fixed before OTA hook null pointer exception
This commit is contained in:
parent
e65b1e3075
commit
959a74252a
63
src/OTA.c
63
src/OTA.c
|
|
@ -180,7 +180,8 @@ esp_err_t my_esp_https_ota(const esp_http_client_config_t *config)
|
||||||
if (need_to_update)
|
if (need_to_update)
|
||||||
{
|
{
|
||||||
ESP_LOGW(TAG, "New firmware has newer build, START update firmware");
|
ESP_LOGW(TAG, "New firmware has newer build, START update firmware");
|
||||||
HookBeforeUpdate();
|
if (HookBeforeUpdate != NULL)
|
||||||
|
HookBeforeUpdate();
|
||||||
int countPackets = 0;
|
int countPackets = 0;
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
|
|
@ -236,35 +237,35 @@ esp_err_t my_esp_https_ota(const esp_http_client_config_t *config)
|
||||||
static void OTATask(void *pvParameter)
|
static void OTATask(void *pvParameter)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
espfs_file_t *file;
|
espfs_file_t *file;
|
||||||
struct espfs_stat_t stat;
|
struct espfs_stat_t stat;
|
||||||
|
|
||||||
//open file
|
//open file
|
||||||
file = espfs_fopen(fs, "res/ca_cert.pem");
|
file = espfs_fopen(fs, "res/ca_cert.pem");
|
||||||
if (!file)
|
if (!file)
|
||||||
{
|
{
|
||||||
ESP_LOGE(TAG, "Failed to read certificate file");
|
ESP_LOGE(TAG, "Failed to read certificate file");
|
||||||
goto update_error;
|
goto update_error;
|
||||||
}
|
}
|
||||||
//get file info
|
//get file info
|
||||||
espfs_stat(fs, "res/ca_cert.pem", &stat);
|
espfs_stat(fs, "res/ca_cert.pem", &stat);
|
||||||
uint32_t fileSize;
|
uint32_t fileSize;
|
||||||
fileSize = stat.size;
|
fileSize = stat.size;
|
||||||
char *certbuf = (char*) malloc(fileSize);
|
char *certbuf = (char*) malloc(fileSize);
|
||||||
if (certbuf)
|
if (certbuf)
|
||||||
{
|
{
|
||||||
espfs_fread(file, certbuf, fileSize);
|
espfs_fread(file, certbuf, fileSize);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ESP_LOGE(TAG, "Failed to allocate memory");
|
ESP_LOGE(TAG, "Failed to allocate memory");
|
||||||
espfs_fclose(file);
|
espfs_fclose(file);
|
||||||
goto update_error;
|
goto update_error;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
esp_http_client_config_t config = {
|
esp_http_client_config_t config = {
|
||||||
.url = GetSysConf()->OTAURL,
|
.url = GetSysConf()->OTAURL,
|
||||||
.cert_pem = (char *)server_cert_pem_start,
|
.cert_pem = (char*) server_cert_pem_start,
|
||||||
.event_handler = _http_event_handler,
|
.event_handler = _http_event_handler,
|
||||||
.keep_alive_enable = true,
|
.keep_alive_enable = true,
|
||||||
.skip_cert_common_name_check = true,
|
.skip_cert_common_name_check = true,
|
||||||
|
|
@ -284,11 +285,11 @@ static void OTATask(void *pvParameter)
|
||||||
strcpy(FwUpdStatus, "<div class='clerr'>Error update</div>");
|
strcpy(FwUpdStatus, "<div class='clerr'>Error update</div>");
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
free(certbuf);
|
free(certbuf);
|
||||||
espfs_fclose(file);
|
espfs_fclose(file);
|
||||||
|
|
||||||
update_error:
|
update_error:
|
||||||
*/
|
*/
|
||||||
vTaskDelete(NULL);
|
vTaskDelete(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user