Detect TPC/IP Client Connections on DA16200 Server to establish SSL connection

Hi,

I'm working with the DA16200 Dialog Semiconductor kit and I have configured DA16200 as a TLS server using the example project "tls_server_sample".

The setup currently handles one client using mbedtls_net_accept() and mbedtls_ssl_handshake() functions.

However, I'd like to understand how to detect more than one TPC/IP client connection . Specifically:

  • How can I detect when a second client tries to connect to the server?

  • What's the best way to queue or reject additional connections once one client is active?

  • If it is allowed only one TLS client at a time, what's the recommended method to enforce that?

Parents
  • Hi DonatoC,

    Thank you for posting your question online.
    The DA16200 as a TCP Server can support up to 7 TCP clients.

    The DA16200 supports TLS v1.2

    I have configured DA16200 as a TLS server using the example project "tls_server_sample".

    Please refer on UM-WI-046 DA16200 DA16600 FreeRTOS SDK Programmer Guide on section 12.1.1.1 TLS Server

    However, let me check with the Wi-Fi team if this can be changed via SW.

    Best Regards,
    OV_Renesas

  • Hi,

    thank you for your support.

    My question specifically concerns the mechanism for detecting when a client connects to the TCP server.

    In the provided tls_server_sample.c example, the TLS handshake is initiated with mbedtls_net_accept() and mbedtls_ssl_handshake() ; however, the actual point where a new TCP client connection is accepted by the server via accept() or similar is not clearly distinguishable or externally hookable for event notification.

    How to detect when a client connect to the DA16200 server?
    For example, is there a callback or flag I can monitor before or during mbedtls_net_accept() to handle multiple connections or manage connection sessions?

  • Hi DonatoC,

    Thank you for the reply and apologies for the delay but I was OOO.
    The steps for TLS session:

    • the mbedtls_net_accept() is done, TCP connection is done. Not TLS session..
    • mbedtls_ssl_set_bio(), mbedtls_ssl_handshake can be called/handled in tasks for TLS session..

    but from my understanding, you want to manage the connection sessions.. so this kind of steps could be available. this is based on the mbedtls example.

    mbedtls/programs/ssl/ssl_pthread_server.c at development · Mbed-TLS/mbedtls

    • Create in advance two tasks like tls_client_session1 and tls_client_session2 in somewhere else.
    • Line 452, mbedtls_net_accept(), if there are any client connected to the TLS server, it goes to thread_create(),
    • But in our case, we can send event with data to tls_client_session1 and handle the connection there and save flag1 = 1 and set flag1 = 0 when it is disconnected in the task.
    • After sending the event to tls_client_session1 then go to reset then wait another client. when another client comes to be connected then send event to tls_client_session2 and set flag2 = 1, and set flag2=0 when it is disconnected..
    • when it goes to reset lable and both of flag1 and flag2 is set as "1" can't wait untill both/either of them are free to connect.

     

    To check in detail what could be available for you to check the client connection, this log may be helpful..

    [2025-06-12 15:28:23.753] Waiting for a remote connection......................................
    
    //Ssl_srv.c (core\system\src\crypto\mbedtls)
    [2025-06-12 15:28:39.286] mbedtls_ssl_handshake:6836: => handshake
    [2025-06-12 15:28:39.286] 
    [2025-06-12 15:28:39.286] mbedtls_ssl_handshake_server_step:3977: server state: 0
    [2025-06-12 15:28:39.286] 
    [2025-06-12 15:28:39.286] mbedtls_ssl_flush_output:2582: => flush output
    [2025-06-12 15:28:39.286] 
    [2025-06-12 15:28:39.286] mbedtls_ssl_flush_output:2594: <= flush output
    [2025-06-12 15:28:39.286] 
    [2025-06-12 15:28:39.286] mbedtls_ssl_handshake_server_step:3977: server state: 1
    [2025-06-12 15:28:39.286] 
    [2025-06-12 15:28:39.286] mbedtls_ssl_flush_output:2582: => flush output
    [2025-06-12 15:28:39.286] 
    [2025-06-12 15:28:39.286] mbedtls_ssl_flush_output:2594: <= flush output
    [2025-06-12 15:28:39.302] 
    [2025-06-12 15:28:39.302] ssl_parse_client_hello:1199: => parse client hello
    [2025-06-12 15:28:39.302] 
    [2025-06-12 15:28:39.302] mbedtls_ssl_fetch_input:2374: => fetch input
    [2025-06-12 15:28:39.302] 
    [2025-06-12 15:28:39.302] mbedtls_ssl_fetch_input:2531: in_left: 0, nb_want: 5
    
    [2025-06-12 15:28:39.349] Performing the TLS handshake...################################ 
    [2025-06-12 15:28:39.302] mbedtls_ssl_fetch_input:2531: in_left: 0, nb_want: 5

    Please also note that DA16200 configured as TLS server can support up to 2 TLS clients.

    Best Regards,
    OV_Renesas

    debug_sdk.zip

Reply
  • Hi DonatoC,

    Thank you for the reply and apologies for the delay but I was OOO.
    The steps for TLS session:

    • the mbedtls_net_accept() is done, TCP connection is done. Not TLS session..
    • mbedtls_ssl_set_bio(), mbedtls_ssl_handshake can be called/handled in tasks for TLS session..

    but from my understanding, you want to manage the connection sessions.. so this kind of steps could be available. this is based on the mbedtls example.

    mbedtls/programs/ssl/ssl_pthread_server.c at development · Mbed-TLS/mbedtls

    • Create in advance two tasks like tls_client_session1 and tls_client_session2 in somewhere else.
    • Line 452, mbedtls_net_accept(), if there are any client connected to the TLS server, it goes to thread_create(),
    • But in our case, we can send event with data to tls_client_session1 and handle the connection there and save flag1 = 1 and set flag1 = 0 when it is disconnected in the task.
    • After sending the event to tls_client_session1 then go to reset then wait another client. when another client comes to be connected then send event to tls_client_session2 and set flag2 = 1, and set flag2=0 when it is disconnected..
    • when it goes to reset lable and both of flag1 and flag2 is set as "1" can't wait untill both/either of them are free to connect.

     

    To check in detail what could be available for you to check the client connection, this log may be helpful..

    [2025-06-12 15:28:23.753] Waiting for a remote connection......................................
    
    //Ssl_srv.c (core\system\src\crypto\mbedtls)
    [2025-06-12 15:28:39.286] mbedtls_ssl_handshake:6836: => handshake
    [2025-06-12 15:28:39.286] 
    [2025-06-12 15:28:39.286] mbedtls_ssl_handshake_server_step:3977: server state: 0
    [2025-06-12 15:28:39.286] 
    [2025-06-12 15:28:39.286] mbedtls_ssl_flush_output:2582: => flush output
    [2025-06-12 15:28:39.286] 
    [2025-06-12 15:28:39.286] mbedtls_ssl_flush_output:2594: <= flush output
    [2025-06-12 15:28:39.286] 
    [2025-06-12 15:28:39.286] mbedtls_ssl_handshake_server_step:3977: server state: 1
    [2025-06-12 15:28:39.286] 
    [2025-06-12 15:28:39.286] mbedtls_ssl_flush_output:2582: => flush output
    [2025-06-12 15:28:39.286] 
    [2025-06-12 15:28:39.286] mbedtls_ssl_flush_output:2594: <= flush output
    [2025-06-12 15:28:39.302] 
    [2025-06-12 15:28:39.302] ssl_parse_client_hello:1199: => parse client hello
    [2025-06-12 15:28:39.302] 
    [2025-06-12 15:28:39.302] mbedtls_ssl_fetch_input:2374: => fetch input
    [2025-06-12 15:28:39.302] 
    [2025-06-12 15:28:39.302] mbedtls_ssl_fetch_input:2531: in_left: 0, nb_want: 5
    
    [2025-06-12 15:28:39.349] Performing the TLS handshake...################################ 
    [2025-06-12 15:28:39.302] mbedtls_ssl_fetch_input:2531: in_left: 0, nb_want: 5

    Please also note that DA16200 configured as TLS server can support up to 2 TLS clients.

    Best Regards,
    OV_Renesas

    debug_sdk.zip

Children
No Data