Problem with wifi join semaphore

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
BeDe_2507241
Level 4
Level 4
First like received

I am using the following function to join an AP:

wwd_result_t wwd_wifi_join_specific( const wiced_scan_result_t* ap,

                                   const uint8_t* security_key,

                                   uint8_t key_length,

                                   host_semaphore_type_t* semaphore,

                                   wwd_interface_t interface )

I pass the following semaphore to the function:

host_semaphore_type_t semph_wifi_join_cmpltd_hdle; // this semaphore resumes the wifi connection thread

But the semaphore is never set!

The function returns successfully and connects to the AP. But the semaphore is never set to indicate the end of the association process.

0 Likes
3 Replies
RaktimR_11
Moderator
Moderator
Moderator
500 replies posted 250 replies posted 100 replies posted

You can try checking the active_join_mutex status; instead of your own semaphore which should give you the indication of assoc completed. If you are setting up WICED platform as a softAP, then you can check for WLC_E_ASSOC_IND for the event and put debug prints/asserts if necessary.

This is part of the code I am using:

static host_semaphore_type_t  WICED_DEEP_SLEEP_SAVED_VAR( active_join_mutex );

    wwd_result_t     result;

    result = wiced_rtos_init_semaphore(&active_join_mutex);

    if ( result != WWD_SUCCESS )

    {

        /* could not create semaphore */

        WPRINT_APP_ERROR(("||||||||| ERROR: Could not create LwIP semph_wifi_join_cmpltd_hdle semaphore"));

        return;

    }

            if (wwd_wifi_join_specific( (const) &alternative_ap, (const) security_key, key_length,

                    &active_join_mutex, WICED_STA_INTERFACE ) != WWD_SUCCESS)

            {

                WPRINT_APP_INFO(( "\nAlternate join failed! \n"));

                wwd_wifi_set_down();

            }

            else

                WPRINT_APP_INFO(( "\n***JOIN SPECIFIC***: Switching the AP...! \n"));

        WPRINT_APP_INFO(( "\n******Waiting for a join process to complete...******\n"));

        host_rtos_get_semaphore( &active_join_mutex, NEVER_TIMEOUT, WICED_FALSE );

        WPRINT_APP_INFO(( "\n******Semaphore for join has been set******\n"));

And the semaphore is never set!

Could you please provide a sample code for checking the mutex?

active_join_mutex is internal and cannot be accessed easily.

0 Likes

You can print the active_join_mutex status in a debug build by just putting a print statement

pastedImage_0.png

If you want to use the release build, you can print done variable in wwd_wifi_join_wait_for_complete in the following way

pastedImage_1.png

If the value of done is WICED_TRUE, the assoc process is not completed or if it is WICED_FALSE, the assoc process has gone through. I haven't tried using my own semaphore though but can try it if this does not help your use-case.

0 Likes