fix: https and first ota process

This commit is contained in:
2021-01-08 23:08:07 +01:00
parent 1ff0de1f49
commit f1fb982e21
3 changed files with 19 additions and 25 deletions

View File

@ -508,24 +508,24 @@ static void test(void *pvParameters)
https_clientInitialize();
//https_clientRetrieveData(buffer, &u32BufferLenght, &u32BytesRead);
https_clientRetrieveData(buffer, &u32BufferLenght, &u32BytesRead);
//ESP_LOGI(MESH_TAG, "Data received: %i", u32BytesRead);
ESP_LOGI(MESH_TAG, "Data received: %i", u32BytesRead);
//err = errExtractVersionNumber(buffer, &u32BytesRead, pcRemoteVersionNumber);
err = errExtractVersionNumber(buffer, &u32BytesRead, pcRemoteVersionNumber);
if(err == ESP_OK)
{
//if(bNewerVersion((curPartitionDesc).version, pcRemoteVersionNumber))
// {
if(bNewerVersion((curPartitionDesc).version, pcRemoteVersionNumber))
{
ESP_LOGI(MESH_TAG, "Newer Version available");
//write ota
// const esp_partition_t * currentPartition = esp_ota_get_boot_partition();
//const esp_partition_t * otaPartition = esp_ota_get_next_update_partition(currentPartition);
const esp_partition_t * currentPartition = esp_ota_get_boot_partition();
const esp_partition_t * otaPartition = esp_ota_get_next_update_partition(currentPartition);
//static esp_ota_handle_t otaHandle;
// uint32_t u32StartOffset = 305; //TODO fix this
static esp_ota_handle_t otaHandle;
uint32_t u32StartOffset = 305; //TODO fix this
/*
//esp_err_t err = errFindImageStart(pu8Data, pu32DataLenght, &u32StartOffset);
@ -538,13 +538,13 @@ static void test(void *pvParameters)
}
*/
// ESP_LOGI(MESH_TAG, "first byte offset: %i", u32StartOffset);
//ESP_LOGI(MESH_TAG, "first byte: %x", buffer[u32StartOffset]);
ESP_LOGI(MESH_TAG, "first byte offset: %i", u32StartOffset);
ESP_LOGI(MESH_TAG, "first byte: %x", buffer[u32StartOffset]);
// err = esp_ota_begin(otaPartition, OTA_SIZE_UNKNOWN, &otaHandle);
// ESP_ERROR_CHECK(err);
err = esp_ota_begin(otaPartition, OTA_SIZE_UNKNOWN, &otaHandle);
ESP_ERROR_CHECK(err);
/*
bool stop = false;
while(stop == false)
@ -559,7 +559,7 @@ static void test(void *pvParameters)
ESP_LOGI(MESH_TAG, "END");
/*
*/
do {
@ -589,7 +589,7 @@ static void test(void *pvParameters)
{
ESP_LOGI(MESH_TAG, "NO newer Version available");
}
*/
}
else
{