1 2 3 Previous Next 36 Replies Latest reply on Apr 30, 2018 7:50 AM by axel.lin_1746341

    SDK-3.7.0: Set scan_mode = BTM_BLE_SCAN_MODE_PASSIVE has no effect

    axel.lin_1746341

      Hi,

      To test BTM_BLE_SCAN_MODE_PASSIVE and BTM_BLE_SCAN_MODE_ACTIVE:

       

      I set

      .scan_mode = BTM_BLE_SCAN_MODE_PASSIVE;

       

      I expect .scan_mode = BTM_BLE_SCAN_MODE_PASSIVE should not receive BTM_BLE_EVT_SCAN_RSP data.

      But still receive data with BTM_BLE_EVT_SCAN_RSP (p_scan_result->ble_evt_type == BTM_BLE_EVT_SCAN_RSP).

       

      Note, I remember it was working in SDK-3.5.x.

       

      kask

      SDK-3.7.0-7 is not yet release, so I cannot test it. Maybe your team should test this issue.

       

      [The test_active_passive_switch() call implement is wrong in my previous post, so I just remove it and re-post.]

        • 1. Re: SDK-3.7.0: Set scan_mode = BTM_BLE_SCAN_MODE_PASSIVE has no effect
          axel.lin_1746341

          What is the correct steps to switch ACTIVE/PASSIVE scan mode at run time?

          Should I stop scanning before changing scan_mode setting?

           

          wiced_bt_dev_status_t wiced_bt_ble_observe (wiced_bool_t start, uint8_t duration, wiced_bt_ble_scan_result_cback_t *p_scan_result_cback);

          I'm wondering if set WICED_FALSE as first parameter of wiced_bt_ble_observe() means stop.

          For wiced_bt_ble_scan() I seem don't find the API to stop it.

          1 of 1 people found this helpful
          • 2. Re: SDK-3.7.0: Set scan_mode = BTM_BLE_SCAN_MODE_PASSIVE has no effect
            axel.lin_1746341

            axel.lin wrote:

             

            kausik

            SDK-3.7.0-7 is not yet release, so I cannot test it. Maybe your team should test this issue.

             

            [The test_active_passive_switch() call implement is wrong in my previous post, so I just remove it and re-post.]

            kask

            Now I can confirm that SDK-3.7.0-7 has the same issue.

            Even I set .scan_mode = BTM_BLE_SCAN_MODE_PASSIVE I still got BTM_BLE_EVT_SCAN_RSP type data.

            • 3. Re: SDK-3.7.0: Set scan_mode = BTM_BLE_SCAN_MODE_PASSIVE has no effect
              axel.lin_1746341

              axel.lin wrote:

               

              axel.lin wrote:

               

              kausik

              SDK-3.7.0-7 is not yet release, so I cannot test it. Maybe your team should test this issue.

               

              [The test_active_passive_switch() call implement is wrong in my previous post, so I just remove it and re-post.]

              kausik

              Now I can confirm that SDK-3.7.0-7 has the same issue.

              Even I set .scan_mode = BTM_BLE_SCAN_MODE_PASSIVE I still got BTM_BLE_EVT_SCAN_RSP type data.

              kask jayi jact

              Just for your reference:

              I found this issue only happens when using wiced_bt_ble_observe() but does not happen if using wiced_bt_ble_scan().

              Hope this is helpful for debugging and fixing the issue.

              • 4. Re: SDK-3.7.0: Set scan_mode = BTM_BLE_SCAN_MODE_PASSIVE has no effect
                kask

                Hello Axel,

                This was discussed internally a while back - I will dig up the thread and respond tomorrow.

                 

                regards

                /kausik

                1 of 1 people found this helpful
                • 5. Re: SDK-3.7.0: Set scan_mode = BTM_BLE_SCAN_MODE_PASSIVE has no effect
                  axel.lin_1746341

                  kausik wrote:

                   

                  Hello Axel,

                  This was discussed internally a while back - I will dig up the thread and respond tomorrow.

                   

                  Hi kausik,

                  Thanks.

                   

                  Please also let me know what is the correct steps to switch scan_mode.

                  I have read the BT/BLE related APIs in the header files.

                  However, all the example code includes in the sdk seems assume the scan_mode is set before init BT stack.

                  It's not clear to me if it's ok to run-time switching scan_mode.

                  i.e.

                  Is it necessary to stop/restart scan after switching scan_mode?

                  Is it fine to set scan_mode and/or calling wiced_bt_ble_observe/wiced_bt_ble_scan at application thread

                  even the device is scanning?

                   

                  A similar question is for run-time setting BLE broadcast payload.

                  I known the wiced_bt_start_advertisements() API, but I don't know if it's fine to call it at run-time

                  at my application thread especially when my device is doing scan. 

                  • 6. Re: SDK-3.7.0: Set scan_mode = BTM_BLE_SCAN_MODE_PASSIVE has no effect
                    prpa

                    Hi Alex

                     

                    Below are your answers

                     

                    1> To stop scan you should pass BTM_BLE_SCAN_TYPE_NONE as the first paramter for the api wiced_bt_ble_scan , i think we will document the usage in wiced_bt_ble.h

                     

                    2> At run time to switch between Active/passive scan , you need to first stop the scan , change the settings of the scan mode and then call the scan

                    below is the test snippet

                    extern wiced_bt_cfg_settings_t wiced_bt_cfg_settings;

                    wiced_result_t restful_smart_passive_scan()

                    {

                    wiced_bt_cfg_settings.ble_scan_cfg.scan_mode = BTM_BLE_SCAN_MODE_PASSIVE;

                        wiced_bt_ble_scan( BTM_BLE_SCAN_TYPE_HIGH_DUTY, WICED_TRUE, scan_result_callback );

                        return WICED_SUCCESS;

                    }

                     

                    wiced_result_t restful_smart_active_scan( wiced_http_response_stream_t* stream )

                    {

                    wiced_bt_cfg_settings.ble_scan_cfg.scan_mode = BTM_BLE_SCAN_MODE_ACTIVE;

                     

                        wiced_bt_ble_scan( BTM_BLE_SCAN_TYPE_HIGH_DUTY, WICED_TRUE, scan_result_callback );

                                                                                                                                            

                        return WICED_SUCCESS;

                    }

                     

                    3> when you use the above implementation you can see that only active scan will respond with scan result and not the passive scan

                     

                    static void scan_result_callback( wiced_bt_ble_scan_results_t *result, uint8_t *data )

                    {

                      printf("\n recvd result type is = %d\n" , result->ble_evt_type);

                    ..

                    .

                    }

                     

                    4> wiced_bt_ble_observe : is an api that is used to scan beacons adv and scan mode switch may not have any effect, I shall test it and let you know

                     

                    5> You can run Scan and ADV at the same time , kindly go through the below post which i had replied earlier may be this could be helpful

                    3.7.0 BLE: Simultaneous Central / Peripheral?

                     

                     

                    Sequence for simultaneous BLE Central/Peripheral

                     

                    1. 1> Init the BT stack with a management callback

                        /* Register call back and configuration with stack */wiced_bt_stack_init( hello_sensor_management_callback ,&wiced_bt_cfg_settings, wiced_bt_cfg_buf_pools );

                    1. 2> In the management callback on receiving BTM_ENABLED, I register for GATT  and then start adv , and then start scan

                    static wiced_result_t hello_sensor_management_callback( wiced_bt_management_evt_t event,wiced_bt_management_evt_data_t *p_event_data )

                    {

                    WPRINT_BT_APP_INFO(("hello_sensor_management_callback: %x\n", event ));

                     

                        switch( event )

                        {

                    /* Bluetooth  stack enabled */

                      case BTM_ENABLED_EVT:

                      // Register for GATT callback

                      // Start ADV

                      // Start Scan

                    1 of 1 people found this helpful
                    • 7. Re: SDK-3.7.0: Set scan_mode = BTM_BLE_SCAN_MODE_PASSIVE has no effect
                      axel.lin_1746341

                      prejith wrote:

                       

                      5> You can run Scan and ADV at the same time , kindly go through the below post which i had replied earlier may be this could be helpful

                      3.7.0 BLE: Simultaneous Central / Peripheral?

                       

                       

                      Sequence for simultaneous BLE Central/Peripheral

                       

                      1. 1> Init the BT stack with a management callback

                          /* Register call back and configuration with stack */wiced_bt_stack_init( hello_sensor_management_callback ,&wiced_bt_cfg_settings, wiced_bt_cfg_buf_pools );

                      1. 2> In the management callback on receiving BTM_ENABLED, I register for GATT  and then start adv , and then start scan

                      static wiced_result_t hello_sensor_management_callback( wiced_bt_management_evt_t event,wiced_bt_management_evt_data_t *p_event_data )

                      {

                      WPRINT_BT_APP_INFO(("hello_sensor_management_callback: %x\n", event ));

                       

                          switch( event )

                          {

                      /* Bluetooth  stack enabled */

                        case BTM_ENABLED_EVT:

                        // Register for GATT callback

                        // Start ADV

                        // Start Scan

                      Can I call start ADV / Start Scan at run-time in application thread rather than int the callback(e.g. hello_sensor_management_callback). My point is to run-time start/stop ADV/Scan, I'm not able to put the code in the callback you mentioned, it's in application's logic.

                      • 8. Re: SDK-3.7.0: Set scan_mode = BTM_BLE_SCAN_MODE_PASSIVE has no effect
                        prpa

                        Hi Alex

                         

                        you should be able to put it any where , only pre-requisite is start scan  or ADV only after you have received BTM_ENABLED_EVT , infact the callback is implemented in application

                         

                        Regarding your issue on using observe ? : Can you let me know to swich between Active/Passive if you can use wiced_bt_ble_scan instead of observe ?

                         

                        Regards

                        Prejith

                        • 9. Re: SDK-3.7.0: Set scan_mode = BTM_BLE_SCAN_MODE_PASSIVE has no effect
                          axel.lin_1746341

                          prejith wrote:

                           

                          Hi Alex

                           

                          you should be able to put it any where , only pre-requisite is start scan  or ADV only after you have received BTM_ENABLED_EVT , infact the callback is implemented in application

                           

                          Regarding your issue on using observe ? : Can you let me know to swich between Active/Passive if you can use wiced_bt_ble_scan instead of observe ?

                           

                          Regards

                          Prejith

                          The problem of wiced_bt_ble_scan() is it cannot scan non-connectable devices. e.g. beacons/tags.

                          So we need to use observe API.

                          (honestly, other BLE stacks have no problem to support scanning non-connectable devices and also support active/passive scan switch. I think it should be supported by WICED sdk.)

                          • 10. Re: SDK-3.7.0: Set scan_mode = BTM_BLE_SCAN_MODE_PASSIVE has no effect
                            prpa

                            Hi Axel


                            I would like to look at your logs on 3.7.07 with the below simple changes 
                            (since the test
                            which you are trying is independent on platform you can run restful_smart_server app on BCM4343W instead of 43438 )


                            Below are the changes you should make ,

                            1> Change the wrapper of restful_smart_passive_scan

                            2> put a print on the restful_smart_scan_result_callback to print the ble_evt_type

                            3> build the app and execute the the curl command  curl -v -X GET http://192.168.0.184/gap/nodes?passive=1

                             

                            wiced_result_t restful_smart_passive_scan( wiced_http_response_stream_t* stream )

                            {

                                current_stream    = stream;

                                scan_result_count = 0;

                                 wiced_bt_cfg_settings.ble_scan_cfg.scan_mode = BTM_BLE_SCAN_MODE_PASSIVE;

                                rest_smart_response_write_status_code( current_stream, REST_SMART_STATUS_200 );

                                rest_smart_response_write_node_array_start( current_stream );

                                 wiced_bt_ble_observe(WICED_TRUE,60,restful_smart_scan_result_callback)

                                 return WICED_SUCCESS;

                            }

                             

                            static void restful_smart_scan_result_callback( wiced_bt_ble_scan_results_t *result, uint8_t *data )

                            {

                             

                               printf("\n recvd result type is = %d\n" , result->ble_evt_type);

                            XX

                            XX

                             

                            }



                            Regards

                            Prejith

                            • 11. Re: SDK-3.7.0: Set scan_mode = BTM_BLE_SCAN_MODE_PASSIVE has no effect
                              rash

                              Hello Axel Lin,

                               

                              As pert of testing we have seen in observe mode "Type:4" events which is related to SCAN. We have reproduced the issue and discussing internally for a FIX. Following is the UART debug log

                               

                              [BtReader] 404040406666,-92,RAW(16) 0201060909496F542042756C62020A00

                              #type=4

                              [BtReader] 404040406666,-91,RAW(16) 0201060909496F542042756C62020A00

                              #type=0

                              [BtReader] 404040406666,-91,RAW(16) 0201060909496F542042756C62020A00

                              #type=4

                              [BtReader] 404040406666,-92,RAW(16) 0201060909496F542042756C62020A00

                              #type=0

                              [BtReader] 404040406666,-91,RAW(16) 0201060909496F542042756C62020A00

                              #type=0

                              [BtReader] 404040406666,-96,RAW(16) 0201060909496F542042756C62020A00

                              #type=4

                               

                              I will let you know once we got the fix.

                               

                              -Ramesh Mylavarapu

                              1 of 1 people found this helpful
                              • 12. Re: SDK-3.7.0: Set scan_mode = BTM_BLE_SCAN_MODE_PASSIVE has no effect
                                axel.lin_1746341

                                rash wrote:

                                 

                                Hello Axel Lin,

                                 

                                As pert of testing we have seen in observe mode "Type:4" events which is related to SCAN. We have reproduced the issue and discussing internally for a FIX. Following is the UART debug log

                                 

                                 

                                I will let you know once we got the fix.

                                 

                                -Ramesh Mylavarapu

                                prpa rash

                                Okay, and thank you.

                                • 13. Re: SDK-3.7.0: Set scan_mode = BTM_BLE_SCAN_MODE_PASSIVE has no effect
                                  rash

                                  Hello Axel Lin,

                                   

                                  As a reply to my previous response, we have checked this issue and found the bug. We have fixed it and we will consolidate it in the next SDK release.

                                   

                                  -Ramesh Mylavarapu

                                  • 14. Re: SDK-3.7.0: Set scan_mode = BTM_BLE_SCAN_MODE_PASSIVE has no effect
                                    axel.lin_1746341

                                    rash wrote:

                                     

                                    Hello Axel Lin,

                                     

                                    As a reply to my previous response, we have checked this issue and found the bug. We have fixed it and we will consolidate it in the next SDK release.

                                     

                                    -Ramesh Mylavarapu

                                    Great!

                                    I'm waiting for next SDK release (for3.7.x serial).

                                    Do you know when will the SDK available?

                                     

                                    Axel

                                    1 2 3 Previous Next