fix: https download offset
This commit is contained in:
parent
d50985c577
commit
8e7f4e68dc
|
@ -130,17 +130,17 @@ https_client_ret_t https_clientRetrieveData(unsigned char* pu8Data, uint32_t* pu
|
|||
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)));
|
||||
|
||||
if(i32RetRetrieveData > 0)
|
||||
{
|
||||
//Data received
|
||||
*pu32BytesRead = *pu32BytesRead + i32RetRetrieveData;
|
||||
*pu32DataLenght = *pu32DataLenght - *pu32BytesRead;
|
||||
|
||||
if(*pu32DataLenght > 0)
|
||||
{
|
||||
|
@ -152,6 +152,7 @@ https_client_ret_t https_clientRetrieveData(unsigned char* pu8Data, uint32_t* pu
|
|||
//buffer full --> stop reading
|
||||
bRetriveData = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(i32RetRetrieveData == 0)
|
||||
|
@ -357,20 +358,36 @@ static void https_get_task(void *pvParameters)
|
|||
unsigned char buffer[1024U];
|
||||
uint32_t u32BytesRead = 0;
|
||||
|
||||
|
||||
uint32_t u32readCount = 0U;
|
||||
|
||||
do {
|
||||
|
||||
https_clientRetrieveData(buffer, &u32BufferLenght, &u32BytesRead);
|
||||
|
||||
printf("\nread: %i\n", u32BytesRead);
|
||||
|
||||
u32readCount++;
|
||||
|
||||
if(u32BytesRead == 293)
|
||||
{
|
||||
|
||||
// Print response directly to stdout as it is read
|
||||
for(uint32_t i = 0; i < u32BytesRead; i++) {
|
||||
putchar(buffer[i]);
|
||||
// printf("%x ", buffer[i]);
|
||||
//putchar(buffer[i]);
|
||||
printf("%x ", buffer[i]);
|
||||
}
|
||||
printf("\n END \n");
|
||||
|
||||
}
|
||||
|
||||
}while(u32BytesRead > 0);
|
||||
|
||||
printf("\n END %i\n", u32readCount);
|
||||
|
||||
https_clientDeinitialize();
|
||||
|
||||
while(1)
|
||||
{
|
||||
|
||||
vTaskDelay( 500/portTICK_PERIOD_MS);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue