1 2 Previous Next 28 Replies Latest reply on Jun 14, 2016 9:53 PM by alyoc_1740326

    wiced_wifi_scan_networks returns success but does not find AP when AP is connected

    mamec_1509466

      Scanning code that uses the wiced_wifi_scan_networks api works fine if run before creating an AP association.

       

      But if an AP is brought up, the wiced_wifi_scan_networks function returns WICED_SUCCESS when called, but the scan

      does not find any AP's even though there are many AP's present.

       

      The call to wiced_wifi_scan_networks is from a main thread and not from a callback.

        • 1. Re: wiced_wifi_scan_networks returns success but does not find AP when AP is connected
          MichaelF_56

          Adding ankr_1205151 as I understand he is working with you to resolve as well.

           

          MiltM_86

          • 2. Re: wiced_wifi_scan_networks returns success but does not find AP when AP is connected
            VikramR_26

            wiced_result_t wiced_wifi_scan_networks( wiced_scan_result_handler_t results_handler, void* user_data )

             

            The WICED_SUCCESS you are looking for is the response for caliing the wiced_wifi_scan_networks(), the scan result can found in results_handler.

            are you referring to the snip--> scan example ? You should see list of AP's around you being printed in the console log. Which version of SDK and what platform are you using ?

             

            hth

            vik86

            • 3. Re: wiced_wifi_scan_networks returns success but does not find AP when AP is connected
              mamec_1509466

              Thanks for the response VikramR_26

               

              The SDK is 3.3.1

               

              The results handler is not called when connected to an AP. If

              the AP is not connected, the results handler is called multiple

              times.

              • 4. Re: wiced_wifi_scan_networks returns success but does not find AP when AP is connected
                mamec_1509466

                The platform is an EMW3162 which is a 43362 module.

                • 5. Re: wiced_wifi_scan_networks returns success but does not find AP when AP is connected
                  nasac_2167841

                  This is partly by design

                   

                  The 43362 is a single Radio design.

                   

                  Once you have connected to a specific AP, then the radio is locked on to that channel and needs to service the AP for beacons to maintain a connection

                   

                  Due to this we cannot switch back to scan mode across all channels without losing a connection

                  • 6. Re: wiced_wifi_scan_networks returns success but does not find AP when AP is connected
                    mamec_1509466

                    nasac_2167841

                    Shouldn't the API have returned an error instead of success if a connection

                    was up and it could not perform the Scan?

                     

                    Also, now that we know this fact, we wiced_wifi_down() to kill any connections,

                    do a wiced_wifi_up() and then do the Scan, but it does not work reliably. What

                    else needs to be performed procedurally to take the network down, take the

                    wifi down, put wifi up, scan successfully, and then bring the network back up?

                    • 7. Re: wiced_wifi_scan_networks returns success but does not find AP when AP is connected
                      mamec_1509466

                      Shouldn't the API have returned an error instead of success if a connection

                      was up and it could not perform the Scan?

                       

                      Also, now that we know this fact, we wiced_wifi_down() to kill any connections,

                      do a wiced_wifi_up() and then do the Scan, but it does not work reliably. What

                      else needs to be performed procedurally to take the network down, take the

                      wifi down, put wifi up, scan successfully, and then bring the network back up?

                      • 8. Re: wiced_wifi_scan_networks returns success but does not find AP when AP is connected
                        mamec_1509466

                        Here is the code snippet we are using to take down the MQTT

                        and AP connections so we can do the Scan

                         

                        .

                        .

                        .

                             wiced_network_down(WICED_STA_INTERFACE);

                         

                            /* Wait for MQTT to report that it is disconnected */

                         

                            while ( mqtt_is_connected() ) {

                         

                                // mqtt still connected... wait.

                                wiced_rtos_delay_milliseconds(1000);

                            }

                         

                           

                        wiced_result = wiced_wifi_down();

                         

                            // wifi down

                         

                            wiced_result = wiced_wifi_up();

                         

                         

                            // Scanning WiFi networks...

                         

                         

                            result = wiced_wifi_scan_networks(ble_wifi_scan_result2_handler, &ble_wifi_connection);

                         

                         

                            wiced_rtos_get_semaphore(&(ble_wifi_connection.semaphore), 10000);            // 10 second timeout.

                        • 9. Re: wiced_wifi_scan_networks returns success but does not find AP when AP is connected
                          daprc_2123601

                          Hi-- are there other chips that can do the scan while connected to the AP?  Is there a particular item in the datasheet to look for?-- eg, will the 43341 or 4343 do it?

                           

                          Thanks!

                          • 10. Re: wiced_wifi_scan_networks returns success but does not find AP when AP is connected
                            nasac_2167841

                            If this functionality is absolutely needed - then currently you would have to wrap the scan with a wiced_wlan_connectivity_deinit and a wiced_wlan_connectivity_init

                             

                            wiced_wifi_down and wiced_wifi_up currently are not completely reliable for guaranteeing that the radio is free from any associations. This is being worked on.

                            • 11. Re: wiced_wifi_scan_networks returns success but does not find AP when AP is connected
                              mamec_1509466

                              nasac_2167841

                              Tried wrapping the scan in wiced_wlan_connectivity_deinit and

                              wiced_wlan_connectivity_init as suggested.

                               

                              Results are that Scan is still not returning results and WIfi

                              can not get re-estabished after the attempt.

                               

                              Traces of a good scan executed before Wifi is connected

                              and a bad scan attempted after Wifi is connected are attached.

                              • 12. Re: wiced_wifi_scan_networks returns success but does not find AP when AP is connected
                                nasac_2167841

                                Can you share the actual source snippet of the code you are using to do this?

                                • 13. Re: wiced_wifi_scan_networks returns success but does not find AP when AP is connected
                                  mamec_1509466

                                  wiced_network_down(WICED_STA_INTERFACE);

                                   

                                      /* Wait for MQTT to report that it is disconnected */

                                      while ( mqtt_is_connected() ) {

                                   

                                      SPRINKL_LOG_INFO("mqtt still connected... wait.\r\n");

                                      wiced_rtos_delay_milliseconds(1000);

                                      }

                                   

                                      wiced_result = wiced_wlan_connectivity_deinit();

                                   

                                      SPRINKL_LOG_INFO("wifi deinit%d\n", wiced_result);

                                   

                                      SPRINKL_LOG_INFO("wiced_network_is_ip_up %d\n", wiced_network_is_ip_up(WICED_STA_INTERFACE));

                                      SPRINKL_LOG_INFO("wiced_network_is_up %d\n", wiced_network_is_up(WICED_STA_INTERFACE));

                                   

                                      wiced_result = wiced_wlan_connectivity_init();

                                   

                                      SPRINKL_LOG_INFO("wifi init %d\n", wiced_result);

                                   

                                      SPRINKL_LOG_INFO("Scanning WiFi networks...");

                                      result = wiced_wifi_scan_networks(ble_wifi_scan_result2_handler, &ble_wifi_connection);

                                      SPRINKL_LOG_INFO("[BLE_ WIFI]: scan result: %lu\n", result);

                                   

                                      SPRINKL_LOG_INFO("[BLE WIFI] Waiting on semaphore\r\n");

                                   

                                      wiced_rtos_get_semaphore(&(ble_wifi_connection.semaphore), 10000);            // 10 second timeout.

                                  • 14. Re: wiced_wifi_scan_networks returns success but does not find AP when AP is connected
                                    nasac_2167841

                                    So I have gone back to SDK 3.3.1 and re-verified my comment and I have to undo my previous statement. It appears that our firmware for the BCM43362 supports scanning while connected in the general case

                                     

                                    This is also true of our other devices including the BCM4343W and the BCM43340

                                     

                                    However there is a limitation placed by the single radio and that is that some of the PHY parameters for the AP you are actively associated with and servicing might not be accurately reported in the scan report. For example RSSI.

                                     

                                    In addition due to the need to time manage the radio - some of the scan results might not be accurate - i.e. missing BSSIDs, but over the long term, or if you scan less often this should not be an issue.

                                     

                                    Here is the snippet of code to verify this

                                     

                                    void application_start( )

                                    {

                                        wiced_ip_address_t ip_address;

                                        wiced_init( );

                                        wiced_network_up( WICED_STA_INTERFACE, WICED_USE_EXTERNAL_DHCP_SERVER, NULL );

                                        wiced_hostname_lookup("www.google.com", &ip_address, 10000);

                                        WPRINT_APP_INFO( ( "Server is at %u.%u.%u.%u\n",  (uint8_t)(GET_IPV4_ADDRESS(ip_address) >> 24),

                                                                                          (uint8_t)(GET_IPV4_ADDRESS(ip_address) >> 16),

                                                                                          (uint8_t)(GET_IPV4_ADDRESS(ip_address) >> 8),

                                                                                          (uint8_t)(GET_IPV4_ADDRESS(ip_address) >> 0) ) );

                                     

                                        while(1)

                                        {

                                            record_count = 0;

                                            /* Send an ICMP ping to the address */

                                            send_ping( &ip_address );

                                           /* Start scanning while associated */

                                            WPRINT_APP_INFO( ( "Waiting for scan results...\n" ) );

                                            WPRINT_APP_INFO( ("  # Type  BSSID            RSSI  Rate Chan  Security        SSID\n" ) );

                                            WPRINT_APP_INFO( ("----------------------------------------------------------------------------------------------\n" ) );

                                            wiced_time_get_time(&scan_start_time);

                                            wiced_wifi_scan_networks(scan_result_handler, NULL );

                                            wiced_rtos_delay_milliseconds(DELAY_BETWEEN_SCANS);

                                        }

                                    }

                                     

                                    /*

                                    * Callback function to handle scan results

                                    */

                                    wiced_result_t scan_result_handler( wiced_scan_handler_result_t* malloced_scan_result )

                                    {

                                        if ( malloced_scan_result != NULL )

                                        {

                                            malloc_transfer_to_curr_thread( malloced_scan_result );

                                            if ( malloced_scan_result->status == WICED_SCAN_INCOMPLETE )

                                            {

                                                wiced_scan_result_t* record = &malloced_scan_result->ap_details;

                                                WPRINT_APP_INFO( ( "%3d ", record_count ) );

                                                print_scan_result(record);

                                                ++record_count;

                                            }

                                            else

                                            {

                                                wiced_time_t scan_end_time;

                                                wiced_time_get_time(&scan_end_time);

                                                WPRINT_APP_INFO( ("\nScan complete in %lu milliseconds\n", (unsigned long )(scan_end_time - scan_start_time) ) );

                                            }

                                            free( malloced_scan_result );

                                            malloced_scan_result = NULL;

                                        }

                                        return WICED_SUCCESS;

                                    }

                                     

                                     

                                    static wiced_result_t send_ping( wiced_ip_address_t *ping_target_ip )

                                    {

                                        const uint32_t    ping_timeout = 1000;

                                        uint32_t          elapsed_ms;

                                        wiced_result_t    status;

                                     

                                        status = wiced_ping( WICED_STA_INTERFACE, ping_target_ip, ping_timeout, &elapsed_ms );

                                        if ( status == WICED_SUCCESS )

                                        {

                                            WPRINT_APP_INFO(( "Ping Reply %lums\n", elapsed_ms ));

                                        }

                                        else if ( status == WICED_TIMEOUT )

                                        {

                                            WPRINT_APP_INFO(( "Ping timeout\n" ));

                                        }

                                        else

                                        {

                                            WPRINT_APP_INFO(( "Ping error\n" ));

                                        }

                                     

                                        return WICED_SUCCESS;

                                    }

                                    2 of 2 people found this helpful
                                    1 2 Previous Next