fix: https and first ota process
This commit is contained in:
parent
1ff0de1f49
commit
f1fb982e21
@ -74,19 +74,17 @@ https_client_ret_t https_clientRetrieveData(char* pu8Data, uint32_t* pu32DataLen
|
|||||||
int32_t i32RetRetrieveData = ESP_OK;
|
int32_t i32RetRetrieveData = ESP_OK;
|
||||||
bzero(pu8Data, *pu32DataLenght);
|
bzero(pu8Data, *pu32DataLenght);
|
||||||
bool bRetriveData = true;
|
bool bRetriveData = true;
|
||||||
|
*pu32BytesRead = 0U;
|
||||||
|
|
||||||
while (bRetriveData)
|
while (bRetriveData)
|
||||||
{
|
{
|
||||||
//Reading HTTP response
|
//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)
|
if(i32RetRetrieveData > 0)
|
||||||
{
|
{
|
||||||
//Data received
|
//Data received
|
||||||
*pu32BytesRead = *pu32BytesRead + i32RetRetrieveData;
|
*pu32BytesRead = *pu32BytesRead + i32RetRetrieveData;
|
||||||
*pu32DataLenght = *pu32DataLenght - *pu32BytesRead;
|
|
||||||
|
|
||||||
if(*pu32DataLenght > 0)
|
if(*pu32DataLenght > 0)
|
||||||
{
|
{
|
||||||
@ -106,10 +104,6 @@ https_client_ret_t https_clientRetrieveData(char* pu8Data, uint32_t* pu32DataLen
|
|||||||
bRetriveData = false;
|
bRetriveData = false;
|
||||||
pu32BytesRead = 0;
|
pu32BytesRead = 0;
|
||||||
|
|
||||||
printf("finished HTTPSread: %i\n", i32RetRetrieveData);
|
|
||||||
|
|
||||||
while(1){}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(i32RetRetrieveData == MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY)
|
if(i32RetRetrieveData == MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY)
|
||||||
|
32
main/main.c
32
main/main.c
@ -508,24 +508,24 @@ static void test(void *pvParameters)
|
|||||||
|
|
||||||
https_clientInitialize();
|
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(err == ESP_OK)
|
||||||
{
|
{
|
||||||
//if(bNewerVersion((curPartitionDesc).version, pcRemoteVersionNumber))
|
if(bNewerVersion((curPartitionDesc).version, pcRemoteVersionNumber))
|
||||||
// {
|
{
|
||||||
ESP_LOGI(MESH_TAG, "Newer Version available");
|
ESP_LOGI(MESH_TAG, "Newer Version available");
|
||||||
//write ota
|
//write ota
|
||||||
|
|
||||||
// const esp_partition_t * currentPartition = esp_ota_get_boot_partition();
|
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 * otaPartition = esp_ota_get_next_update_partition(currentPartition);
|
||||||
|
|
||||||
//static esp_ota_handle_t otaHandle;
|
static esp_ota_handle_t otaHandle;
|
||||||
// uint32_t u32StartOffset = 305; //TODO fix this
|
uint32_t u32StartOffset = 305; //TODO fix this
|
||||||
|
|
||||||
/*
|
/*
|
||||||
//esp_err_t err = errFindImageStart(pu8Data, pu32DataLenght, &u32StartOffset);
|
//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 offset: %i", u32StartOffset);
|
||||||
//ESP_LOGI(MESH_TAG, "first byte: %x", buffer[u32StartOffset]);
|
ESP_LOGI(MESH_TAG, "first byte: %x", buffer[u32StartOffset]);
|
||||||
|
|
||||||
|
|
||||||
// err = esp_ota_begin(otaPartition, OTA_SIZE_UNKNOWN, &otaHandle);
|
err = esp_ota_begin(otaPartition, OTA_SIZE_UNKNOWN, &otaHandle);
|
||||||
// ESP_ERROR_CHECK(err);
|
ESP_ERROR_CHECK(err);
|
||||||
|
/*
|
||||||
bool stop = false;
|
bool stop = false;
|
||||||
|
|
||||||
while(stop == false)
|
while(stop == false)
|
||||||
@ -559,7 +559,7 @@ static void test(void *pvParameters)
|
|||||||
|
|
||||||
ESP_LOGI(MESH_TAG, "END");
|
ESP_LOGI(MESH_TAG, "END");
|
||||||
|
|
||||||
/*
|
*/
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
|
||||||
@ -589,7 +589,7 @@ static void test(void *pvParameters)
|
|||||||
{
|
{
|
||||||
ESP_LOGI(MESH_TAG, "NO newer Version available");
|
ESP_LOGI(MESH_TAG, "NO newer Version available");
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -159,7 +159,7 @@ CONFIG_MESH_AP_CONNECTIONS=6
|
|||||||
CONFIG_MESH_ROUTE_TABLE_SIZE=50
|
CONFIG_MESH_ROUTE_TABLE_SIZE=50
|
||||||
CONFIG_OTA_HTTPS_SERVER_COMMON_NAME="ota.hendrikschutter.com"
|
CONFIG_OTA_HTTPS_SERVER_COMMON_NAME="ota.hendrikschutter.com"
|
||||||
CONFIG_OTA_HTTPS_SERVER_PORT="443"
|
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"
|
CONFIG_OTA_HTTPS_AUTH="b3RhOnB3"
|
||||||
# end of Mesh OTA Configuration
|
# end of Mesh OTA Configuration
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user