http_get_mbedtls example: Remove fflush() calls as stdout is no longer line buffered

This commit is contained in:
Angus Gratton 2015-10-11 09:25:51 +11:00
parent c2e3541c05
commit a5a76ed93d

View file

@ -80,7 +80,6 @@ static void my_debug(void *ctx, int level,
file = file_sep+1; file = file_sep+1;
printf("%s:%04d: %s", file, line, str); printf("%s:%04d: %s", file, line, str);
fflush(stdout);
} }
#endif #endif
@ -107,7 +106,6 @@ void http_get_task(void *pvParameters)
mbedtls_x509_crt_init(&cacert); mbedtls_x509_crt_init(&cacert);
mbedtls_ctr_drbg_init(&ctr_drbg); mbedtls_ctr_drbg_init(&ctr_drbg);
printf("\n . Seeding the random number generator..."); printf("\n . Seeding the random number generator...");
fflush(stdout);
mbedtls_ssl_config_init(&conf); mbedtls_ssl_config_init(&conf);
@ -126,7 +124,6 @@ void http_get_task(void *pvParameters)
* 0. Initialize certificates * 0. Initialize certificates
*/ */
printf(" . Loading the CA root certificate ..."); printf(" . Loading the CA root certificate ...");
fflush(stdout);
ret = mbedtls_x509_crt_parse(&cacert, (uint8_t*)server_root_cert, strlen(server_root_cert)+1); ret = mbedtls_x509_crt_parse(&cacert, (uint8_t*)server_root_cert, strlen(server_root_cert)+1);
if(ret < 0) if(ret < 0)
@ -148,7 +145,6 @@ void http_get_task(void *pvParameters)
* 2. Setup stuff * 2. Setup stuff
*/ */
printf(" . Setting up the SSL/TLS structure..."); printf(" . Setting up the SSL/TLS structure...");
fflush(stdout);
if((ret = mbedtls_ssl_config_defaults(&conf, if((ret = mbedtls_ssl_config_defaults(&conf,
MBEDTLS_SSL_IS_CLIENT, MBEDTLS_SSL_IS_CLIENT,
@ -182,7 +178,6 @@ void http_get_task(void *pvParameters)
our network is probably working... our network is probably working...
*/ */
printf("Waiting for server DNS to resolve... "); printf("Waiting for server DNS to resolve... ");
fflush(stdout);
err_t dns_err; err_t dns_err;
ip_addr_t host_ip; ip_addr_t host_ip;
do { do {
@ -198,7 +193,6 @@ void http_get_task(void *pvParameters)
* 1. Start the connection * 1. Start the connection
*/ */
printf(" . Connecting to %s:%s...", WEB_SERVER, WEB_PORT); printf(" . Connecting to %s:%s...", WEB_SERVER, WEB_PORT);
fflush(stdout);
if((ret = mbedtls_net_connect(&server_fd, WEB_SERVER, if((ret = mbedtls_net_connect(&server_fd, WEB_SERVER,
WEB_PORT, MBEDTLS_NET_PROTO_TCP)) != 0) WEB_PORT, MBEDTLS_NET_PROTO_TCP)) != 0)
@ -215,7 +209,6 @@ void http_get_task(void *pvParameters)
* 4. Handshake * 4. Handshake
*/ */
printf(" . Performing the SSL/TLS handshake..."); printf(" . Performing the SSL/TLS handshake...");
fflush(stdout);
while((ret = mbedtls_ssl_handshake(&ssl)) != 0) while((ret = mbedtls_ssl_handshake(&ssl)) != 0)
{ {
@ -251,7 +244,6 @@ void http_get_task(void *pvParameters)
* 3. Write the GET request * 3. Write the GET request
*/ */
printf(" > Write to server:"); printf(" > Write to server:");
fflush(stdout);
int len = sprintf((char *) buf, GET_REQUEST); int len = sprintf((char *) buf, GET_REQUEST);
@ -271,7 +263,6 @@ void http_get_task(void *pvParameters)
* 7. Read the HTTP response * 7. Read the HTTP response
*/ */
printf(" < Read from server:"); printf(" < Read from server:");
fflush(stdout);
do do
{ {
@ -322,7 +313,6 @@ void http_get_task(void *pvParameters)
printf("\n\nsuccesses = %d failures = %d\n", successes, failures); printf("\n\nsuccesses = %d failures = %d\n", successes, failures);
for(int countdown = successes ? 10 : 5; countdown >= 0; countdown--) { for(int countdown = successes ? 10 : 5; countdown >= 0; countdown--) {
printf("%d... ", countdown); printf("%d... ", countdown);
fflush(stdout);
vTaskDelay(1000 / portTICK_RATE_MS); vTaskDelay(1000 / portTICK_RATE_MS);
} }
printf("\nStarting again!\n"); printf("\nStarting again!\n");