Skip to content

Commit

Permalink
chore: add reading in a do while
Browse files Browse the repository at this point in the history
  • Loading branch information
JeremyTubongbanua committed Aug 3, 2023
1 parent b9e7fb4 commit 8366a91
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/at_client/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,21 @@ int atclient_connection_send(atclient_connection_ctx *ctx, unsigned char *recv,
}
// printf("mbedtls_ssl_write: %d\n", ret);

ret = mbedtls_ssl_read(ctx->ssl, recv, recvlen);
memset(recv, 0, recvlen);
do
{
ret = mbedtls_ssl_read(ctx->ssl, recv, recvlen);
if(ret < 0)
{
goto exit;
}
*olen = ret;
// printf("mbedtls_ssl_read: %d\n", ret);

// size_t bytesavail = mbedtls_ssl_get_bytes_avail(ctx->ssl);
// printf("bytes_avail: %lu\n", bytesavail);
} while(ret == MBEDTLS_ERR_SSL_WANT_READ);

if(ret < 0)
{
goto exit;
Expand All @@ -194,7 +208,6 @@ int atclient_connection_send(atclient_connection_ctx *ctx, unsigned char *recv,
}
}


void atclient_connection_free(atclient_connection_ctx *ctx)
{
free(ctx->server_fd);
Expand Down

0 comments on commit 8366a91

Please sign in to comment.