cancel
Showing results for 
Search instead for 
Did you mean: 

WICED Studio Wi-Fi Combo

Anonymous
Not applicable

I am trying to register callbacks on a tcp socket but the callback functions are never called.

Basically, this is how my code looks like:

wiced_tcp_create_socket(&socket, WICED_STA_INTERFACE)

wiced_tcp_listen( &socket, PORT )

wiced_tcp_register_callbacks(&socket, (wiced_socket_callback_t)tcp_conn_callback,

                                                         (wiced_socket_callback_t)tcp_rx_callback,

                                                         (wiced_socket_callback_t)tcp_disc_callback)

static wiced_result_t tcp_conn_callback(wiced_tcp_socket_t* sock){

    wiced_rtos_lock_mutex(&UART);

    WPRINT_APP_INFO(("Conn!

"));

    wiced_rtos_unlock_mutex(&UART);

    return WICED_SUCCESS;

}

static wiced_result_t tcp_rx_callback(wiced_tcp_socket_t* sock){

    wiced_rtos_lock_mutex(&UART);

    WPRINT_APP_INFO(("Rx!

"));

    wiced_rtos_unlock_mutex(&UART);

    return WICED_SUCCESS;

}

static wiced_result_t tcp_disc_callback(wiced_tcp_socket_t* sock){

    wiced_rtos_lock_mutex(&UART);

    WPRINT_APP_INFO(("Disc!

"));

    wiced_rtos_unlock_mutex(&UART);

    return WICED_SUCCESS;

}

The code is compiling and running, but the callbacks are never called when I try to connect to the module.

Any suggestions what I am doing wrong?

Thank you,

Regards

Per D

0 Likes
Reply
4 Replies
Anonymous
Not applicable
Which network stack are you using?
0 Likes
Reply
Anonymous
Not applicable

Hi,

I am new to ThreadX and I am curios about the use of the Mutex in your code when writing to the UART. Can you explain why you ser using the mutexes? I ask because the sample WICED code never uses a mutex when calling WPRINT...

I appreciate your help.

Thanks

0 Likes
Reply
New Contributor II

Did you ever get this working?

I looked through the framework and I couldn't find any checks for socket callbacks, other than in libraries/daemons/HTTP_server/http_server.c:915

0 Likes
Reply
Anonymous
Not applicable

Hi

SDK 3.1  / tcp client mode( connect to remote tcp server)

- function name : wiced_tcp_register_callbacks

      *  it seems to work different way and some of problem

- for better test

      * you had better use "FreeRTOS+LwIP". 

- connection callback works 

   *  this callback does not need because we can get connection result from"wiced_tcp_connect"

- data receive callback works 

  * it works fine.

- dis-connect callback does not work( in STA interface and AP interface)

  * it never works ( this is my problem, we want to get async callback)

//-----------------------------------------------------------------------------------------

Followings are partial code for test

if(ex_tip[interface].sock[index].protocol =='T'){       

        ex_tip[interface].sock[index].connected=connect_remote_host(&ex_tip[interface].sock[index]);

        if(ex_tip[interface].sock[index].connected ==0) {

            close_socket(&ex_tip[interface].sock[index]);

            sprintf(cmdAck,"%s","ERR: Remote host connection failed");

            return RPLY_ERROR;

        }

        ret_val= wiced_tcp_register_callbacks( &(ex_tip[interface].sock[index].socket ), CALLBACK_TCP_C, CALLBACK_TCP_D, CALLBACK_TCP_X );

    }

//-----------------------------------------------------------------------------------------

We need dis-connect callback working.

0 Likes
Reply