Browse Source

fix: https and first ota process

feature/ota_https
Hendrik Schutter 1 year ago
parent
commit
f1fb982e21
  1. 10
      components/mesh_ota/https_client.c
  2. 32
      main/main.c
  3. 2
      sdkconfig

10
components/mesh_ota/https_client.c

@ -74,19 +74,17 @@ https_client_ret_t https_clientRetrieveData(char* pu8Data, uint32_t* pu32DataLen
int32_t i32RetRetrieveData = ESP_OK;
bzero(pu8Data, *pu32DataLenght);
bool bRetriveData = true;
*pu32BytesRead = 0U;
while (bRetriveData)
{
//Reading HTTP response
i32RetRetrieveData = mbedtls_ssl_read(&sHTTPS_ClientConfig.ssl, (unsigned char *)pu8Data, *pu32DataLenght);
i32RetRetrieveData = mbedtls_ssl_read(&sHTTPS_ClientConfig.ssl, (unsigned char *)(pu8Data+(*pu32BytesRead)), ((*pu32DataLenght)-(*pu32BytesRead)));
printf("HTTPSread: %i\n", i32RetRetrieveData);
if(i32RetRetrieveData > 0)
{
//Data received
*pu32BytesRead = *pu32BytesRead + i32RetRetrieveData;
*pu32DataLenght = *pu32DataLenght - *pu32BytesRead;
if(*pu32DataLenght > 0)
{
@ -106,10 +104,6 @@ https_client_ret_t https_clientRetrieveData(char* pu8Data, uint32_t* pu32DataLen
bRetriveData = false;
pu32BytesRead = 0;
printf("finished HTTPSread: %i\n", i32RetRetrieveData);
while(1){}
}
if(i32RetRetrieveData == MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY)

32
main/main.c

@ -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
{

2
sdkconfig

@ -159,7 +159,7 @@ CONFIG_MESH_AP_CONNECTIONS=6
CONFIG_MESH_ROUTE_TABLE_SIZE=50
CONFIG_OTA_HTTPS_SERVER_COMMON_NAME="ota.hendrikschutter.com"
CONFIG_OTA_HTTPS_SERVER_PORT="443"
CONFIG_OTA_HTTPS_URL="https://ota.hendrikschutter.com/hex.txt"
CONFIG_OTA_HTTPS_URL="https://ota.hendrikschutter.com/hello-world.bin"
CONFIG_OTA_HTTPS_AUTH="b3RhOnB3"
# end of Mesh OTA Configuration

Loading…
Cancel
Save

Du besuchst diese Seite mit einem veralteten IPv4-Internetzugang. Möglicherweise treten in Zukunft Probleme mit der Erreichbarkeit und Performance auf. Bitte frage deinen Internetanbieter oder Netzwerkadministrator nach IPv6-Unterstützung.
You are visiting this site with an outdated IPv4 internet access. You may experience problems with accessibility and performance in the future. Please ask your ISP or network administrator for IPv6 support.
Weitere Infos | More Information
Klicke zum schließen | Click to close