examples/stm32/client_rtos_stm32l496g_discovery/src/main.c
/**
 * \brief           Event callback function for connection-only
 * \param[in]       evt: Event information with data
 * \return          espOK on success, member of \ref espr_t otherwise
 */
\brief           Event callback function for connection-only
\param[in]       evt: Event information with data
\return          espOK on success, member of \ref espr_t otherwise
\ brief Event callback function for connection - only \ param [ in ] evt : Event information with data \ return espOK on success member of \ ref espr_t otherwise
static espr_t
conn_callback_func(esp_evt_t* evt) {
    esp_conn_p conn;
    espr_t res;
    conn = esp_conn_get_from_evt(evt);          
    if (conn == NULL) {
        return espERR;
    }
    switch (esp_evt_get_type(evt)) {
        case ESP_EVT_CONN_ACTIVE: {             
            printf("Connection active!\r\n");
            res = esp_conn_send(conn, req_data, sizeof(req_data) - 1, NULL, 0); 
            if (res == espOK) {
                printf("Sending request data to server...\r\n");
            } else {
                printf("Cannot send request data to server. Closing connection manually...\r\n");
                esp_conn_close(conn, 0);        
            }
            break;
        }
        case ESP_EVT_CONN_CLOSE: {              
            if (esp_evt_conn_close_is_forced(evt)) {
                printf("Connection closed by client!\r\n");
            } else {
                printf("Connection closed by remote side!\r\n");
            }
            break;
        }
        case ESP_EVT_CONN_SEND: {               
            espr_t res = esp_evt_conn_send_get_result(evt);
            if (res == espOK) {
                printf("Data sent successfully...waiting to receive data from remote side...\r\n");
            } else {
                printf("Error while sending data!\r\n");
            }
            break;
        }
        case ESP_EVT_CONN_RECV: {               
            esp_pbuf_p pbuf = esp_evt_conn_recv_get_buff(evt);
            esp_conn_recved(conn, pbuf);        
            printf("Received %d bytes on connection..\r\n", (int)esp_pbuf_length(pbuf, 1));
            break;
        }
        default: break;
    }
    return espOK;
}
static espr_t conn_callback_func ( esp_evt_t * evt ) { esp_conn_p conn ; espr_t res ; conn = esp_conn_get_from_evt ( evt ) ; if ( conn == NULL ) { return espERR ; } switch ( esp_evt_get_type ( evt ) ) { case ESP_EVT_CONN_ACTIVE : { printf ( " \r \n " ) ; res = esp_conn_send ( conn , req_data , sizeof ( req_data ) - 1 , NULL , 0 ) ; if ( res == espOK ) { printf ( " \r \n " ) ; } else { printf ( " \r \n " ) ; esp_conn_close ( conn , 0 ) ; } break ; } case ESP_EVT_CONN_CLOSE : { if ( esp_evt_conn_close_is_forced ( evt ) ) { printf ( " \r \n " ) ; } else { printf ( " \r \n " ) ; } break ; } case ESP_EVT_CONN_SEND : { espr_t res = esp_evt_conn_send_get_result ( evt ) ; if ( res == espOK ) { printf ( " \r \n " ) ; } else { printf ( " \r \n " ) ; } break ; } case ESP_EVT_CONN_RECV : { esp_pbuf_p pbuf = esp_evt_conn_recv_get_buff ( evt ) ; esp_conn_recved ( conn , pbuf ) ; printf ( " \r \n " , ( int ) esp_pbuf_length ( pbuf , 1 ) ) ; break ; } default : break ; } return espOK ; }
\brief           Event callback function for connection-only
 \param[in]       evt: Event information with data
 \return          espOK on success, member of \ref espr_t otherwise
\ brief Event callback function for connection - only \ param [ in ] evt : Event information with data \ return espOK on success member of \ ref espr_t otherwise
/* Get connection handle from event */ /* Connection just active */ /* Start sending data in non-blocking mode */ /* Close the connection */ /* Connection closed */ /* Data send event */ /* Data received from remote side */ /* Notify stack about received pbuf */