added tls read timeout
This commit is contained in:
parent
8e7f4e68dc
commit
7afe6bb195
|
@ -57,3 +57,6 @@ build/
|
|||
test/build/
|
||||
|
||||
*.old
|
||||
|
||||
*.orig
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
/* Constants that aren't configurable in menuconfig, yet */
|
||||
#define HTTPS_CLIENT_COMMON_NAME "ota.hendrikschutter.com"
|
||||
#define HTTPS_CLIENT_PORT "443"
|
||||
#define HTTPS_CLIENT_URL "https://ota.hendrikschutter.com/hello-world.bin"
|
||||
#define HTTPS_CLIENT_URL "https://ota.hendrikschutter.com/hex.txt"
|
||||
#define HTTPS_CLIENT_AUTH "b3RhOnB3" //base64("username:password")
|
||||
|
||||
#define HTTPS_CLIENT_OK 0
|
||||
|
@ -135,7 +135,8 @@ https_client_ret_t https_clientRetrieveData(unsigned char* pu8Data, uint32_t* pu
|
|||
while (bRetriveData)
|
||||
{
|
||||
//Reading HTTP response
|
||||
i32RetRetrieveData = mbedtls_ssl_read(&sHTTPS_ClientConfig.ssl, (unsigned char *)(pu8Data+(*pu32BytesRead)), ((*pu32DataLenght)-(*pu32BytesRead)));
|
||||
mbedtls_ssl_conf_read_timeout(&sHTTPS_ClientConfig.conf, 1000); //mbedtls_ssl_config * conf,
|
||||
i32RetRetrieveData = mbedtls_ssl_read(&sHTTPS_ClientConfig.ssl, (unsigned char *)(pu8Data+(*pu32BytesRead)), ((*pu32DataLenght)-(*pu32BytesRead)) );
|
||||
|
||||
if(i32RetRetrieveData > 0)
|
||||
{
|
||||
|
@ -152,7 +153,6 @@ https_client_ret_t https_clientRetrieveData(unsigned char* pu8Data, uint32_t* pu
|
|||
//buffer full --> stop reading
|
||||
bRetriveData = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(i32RetRetrieveData == 0)
|
||||
|
@ -161,6 +161,13 @@ https_client_ret_t https_clientRetrieveData(unsigned char* pu8Data, uint32_t* pu
|
|||
bRetriveData = false;
|
||||
}
|
||||
|
||||
if(i32RetRetrieveData == MBEDTLS_ERR_SSL_TIMEOUT ){
|
||||
printf("timeout\n");
|
||||
bRetriveData = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(i32RetRetrieveData == MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY)
|
||||
{
|
||||
//connection is going to be closed
|
||||
|
@ -280,7 +287,7 @@ https_client_ret_t https_clientConnectToServer()
|
|||
|
||||
if(i32RetServerConnect == ESP_OK)
|
||||
{
|
||||
mbedtls_ssl_set_bio(&sHTTPS_ClientConfig.ssl, &sHTTPS_ClientConfig.server_fd, mbedtls_net_send, mbedtls_net_recv, NULL);
|
||||
mbedtls_ssl_set_bio(&sHTTPS_ClientConfig.ssl, &sHTTPS_ClientConfig.server_fd, mbedtls_net_send, mbedtls_net_recv, mbedtls_net_recv_timeout);
|
||||
|
||||
//Performing the SSL/TLS handshake
|
||||
while ((i32RetServerConnect = mbedtls_ssl_handshake(&sHTTPS_ClientConfig.ssl)) != 0)
|
||||
|
@ -357,34 +364,32 @@ static void https_get_task(void *pvParameters)
|
|||
uint32_t u32BufferLenght = 1024U;
|
||||
unsigned char buffer[1024U];
|
||||
uint32_t u32BytesRead = 0;
|
||||
|
||||
|
||||
uint32_t u32readCount = 0U;
|
||||
|
||||
do {
|
||||
|
||||
https_clientRetrieveData(buffer, &u32BufferLenght, &u32BytesRead);
|
||||
https_clientRetrieveData(buffer, &u32BufferLenght, &u32BytesRead);
|
||||
printf("read: %i\n", u32BytesRead);
|
||||
u32readCount++;
|
||||
} while(u32BytesRead > 0);
|
||||
printf("\n END %i\n", u32readCount);
|
||||
https_clientDeinitialize();
|
||||
/*
|
||||
u32BytesRead = 0;
|
||||
u32readCount = 0U;
|
||||
|
||||
printf("\nread: %i\n", u32BytesRead);
|
||||
do {
|
||||
|
||||
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]);
|
||||
}
|
||||
}
|
||||
|
||||
}while(u32BytesRead > 0);
|
||||
|
||||
printf("\n END %i\n", u32readCount);
|
||||
https_clientRetrieveData(buffer, &u32BufferLenght, &u32BytesRead);
|
||||
printf("read: %i\n", u32BytesRead);
|
||||
u32readCount++;
|
||||
} while(u32BytesRead > 0);
|
||||
|
||||
printf("\n END %i\n", u32readCount);
|
||||
https_clientDeinitialize();
|
||||
|
||||
|
||||
*/
|
||||
while(1)
|
||||
{
|
||||
vTaskDelay( 500/portTICK_PERIOD_MS);
|
||||
|
|
32
sdkconfig
32
sdkconfig
|
@ -335,6 +335,7 @@ CONFIG_ESP_CONSOLE_UART_DEFAULT=y
|
|||
# CONFIG_ESP_CONSOLE_UART_CUSTOM is not set
|
||||
# CONFIG_ESP_CONSOLE_NONE is not set
|
||||
CONFIG_ESP_CONSOLE_UART=y
|
||||
CONFIG_ESP_CONSOLE_MULTIPLE_UART=y
|
||||
CONFIG_ESP_CONSOLE_UART_NUM=0
|
||||
CONFIG_ESP_CONSOLE_UART_BAUDRATE=115200
|
||||
CONFIG_ESP_INT_WDT=y
|
||||
|
@ -578,7 +579,8 @@ CONFIG_FREERTOS_IDLE_TASK_STACKSIZE=2304
|
|||
CONFIG_FREERTOS_ISR_STACKSIZE=1536
|
||||
# CONFIG_FREERTOS_LEGACY_HOOKS is not set
|
||||
CONFIG_FREERTOS_MAX_TASK_NAME_LEN=16
|
||||
# CONFIG_FREERTOS_SUPPORT_STATIC_ALLOCATION is not set
|
||||
CONFIG_FREERTOS_SUPPORT_STATIC_ALLOCATION=y
|
||||
# CONFIG_FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP is not set
|
||||
CONFIG_FREERTOS_TIMER_TASK_PRIORITY=1
|
||||
CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=2048
|
||||
CONFIG_FREERTOS_TIMER_QUEUE_LENGTH=10
|
||||
|
@ -675,7 +677,6 @@ CONFIG_LWIP_LOOPBACK_MAX_PBUFS=8
|
|||
#
|
||||
# TCP
|
||||
#
|
||||
CONFIG_LWIP_TCP_ISN_HOOK=y
|
||||
CONFIG_LWIP_MAX_ACTIVE_TCP=16
|
||||
CONFIG_LWIP_MAX_LISTENING_TCP=16
|
||||
CONFIG_LWIP_TCP_HIGH_SPEED_RETRANSMISSION=y
|
||||
|
@ -703,6 +704,14 @@ CONFIG_LWIP_MAX_UDP_PCBS=16
|
|||
CONFIG_LWIP_UDP_RECVMBOX_SIZE=6
|
||||
# end of UDP
|
||||
|
||||
#
|
||||
# Checksums
|
||||
#
|
||||
# CONFIG_LWIP_CHECKSUM_CHECK_IP is not set
|
||||
# CONFIG_LWIP_CHECKSUM_CHECK_UDP is not set
|
||||
CONFIG_LWIP_CHECKSUM_CHECK_ICMP=y
|
||||
# end of Checksums
|
||||
|
||||
CONFIG_LWIP_TCPIP_TASK_STACK_SIZE=3072
|
||||
CONFIG_LWIP_TCPIP_TASK_AFFINITY_NO_AFFINITY=y
|
||||
# CONFIG_LWIP_TCPIP_TASK_AFFINITY_CPU0 is not set
|
||||
|
@ -735,6 +744,20 @@ CONFIG_LWIP_SNTP_UPDATE_DELAY=3600000
|
|||
|
||||
CONFIG_LWIP_ESP_LWIP_ASSERT=y
|
||||
|
||||
#
|
||||
# Hooks
|
||||
#
|
||||
# CONFIG_LWIP_HOOK_TCP_ISN_NONE is not set
|
||||
CONFIG_LWIP_HOOK_TCP_ISN_DEFAULT=y
|
||||
# CONFIG_LWIP_HOOK_TCP_ISN_CUSTOM is not set
|
||||
CONFIG_LWIP_HOOK_IP6_ROUTE_NONE=y
|
||||
# CONFIG_LWIP_HOOK_IP6_ROUTE_DEFAULT is not set
|
||||
# CONFIG_LWIP_HOOK_IP6_ROUTE_CUSTOM is not set
|
||||
CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_NONE=y
|
||||
# CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_DEFAULT is not set
|
||||
# CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_CUSTOM is not set
|
||||
# end of Hooks
|
||||
|
||||
#
|
||||
# Debug
|
||||
#
|
||||
|
@ -745,8 +768,10 @@ CONFIG_LWIP_ESP_LWIP_ASSERT=y
|
|||
# CONFIG_LWIP_SOCKETS_DEBUG is not set
|
||||
# CONFIG_LWIP_IP_DEBUG is not set
|
||||
# CONFIG_LWIP_ICMP_DEBUG is not set
|
||||
# CONFIG_LWIP_DHCP_DEBUG is not set
|
||||
# CONFIG_LWIP_IP6_DEBUG is not set
|
||||
# CONFIG_LWIP_ICMP6_DEBUG is not set
|
||||
# CONFIG_LWIP_TCP_DEBUG is not set
|
||||
# end of Debug
|
||||
# end of LWIP
|
||||
|
||||
|
@ -1055,6 +1080,7 @@ CONFIG_WPA_MBEDTLS_CRYPTO=y
|
|||
# CONFIG_WPA_DEBUG_PRINT is not set
|
||||
# CONFIG_WPA_TESTING_OPTIONS is not set
|
||||
# CONFIG_WPA_WPS_WARS is not set
|
||||
# CONFIG_WPA_11KV_SUPPORT is not set
|
||||
# end of Supplicant
|
||||
# end of Component config
|
||||
|
||||
|
@ -1177,7 +1203,7 @@ CONFIG_MB_EVENT_QUEUE_TIMEOUT=20
|
|||
CONFIG_MB_TIMER_PORT_ENABLED=y
|
||||
CONFIG_MB_TIMER_GROUP=0
|
||||
CONFIG_MB_TIMER_INDEX=0
|
||||
# CONFIG_SUPPORT_STATIC_ALLOCATION is not set
|
||||
# CONFIG_ENABLE_STATIC_TASK_CLEAN_UP_HOOK is not set
|
||||
CONFIG_TIMER_TASK_PRIORITY=1
|
||||
CONFIG_TIMER_TASK_STACK_DEPTH=2048
|
||||
CONFIG_TIMER_QUEUE_LENGTH=10
|
||||
|
|
Loading…
Reference in New Issue