4 Replies Latest reply on Jul 12, 2020 10:14 PM by AnjanaM_61

    CYBT-343026 BLE Scanner.

    Neeraj Dhekale



      I am trying to scan the BLE connectable non-connectable device. I have 100+ BLE around me. I have written the below code to scan and there is no any error. but I am not getting any scan data in the newAdv function.



          wiced_bt_set_pairable_mode(WICED_TRUE, 0);

          WICED_BT_TRACE("Starting Scan....");





      void newAdv(wiced_bt_ble_scan_results_t *p_scan_result, uint8_t *p_adv_data)



      //   uint8_t mfgLen;

         // uint8_t* mfgData = wiced_bt_ble_check_advertising_data( p_adv_data,0xFF,&mfgLen);



          WICED_BT_TRACE("Found device %B ",p_scan_result->remote_bd_addr);


          uint8_t index=0;

          int fieldLength=p_adv_data[index];

          do {

              for(int i=0;i<=fieldLength;i++)

                  WICED_BT_TRACE("%02X ",p_adv_data[index+i]);


              index = index + fieldLength + 1;

              fieldLength = p_adv_data[index];


          } while(fieldLength);





      /* Advertisement scan configuration */

              .high_duty_scan_interval         = WICED_BT_CFG_DEFAULT_HIGH_DUTY_SCAN_INTERVAL,               /**< High duty scan interval */

              .high_duty_scan_window           = WICED_BT_CFG_DEFAULT_HIGH_DUTY_SCAN_WINDOW,                 /**< High duty scan window */

              .high_duty_scan_duration         = 0,                                                          /**< High duty scan duration in seconds (0 for infinite) */


              .low_duty_scan_interval          = WICED_BT_CFG_DEFAULT_LOW_DUTY_SCAN_INTERVAL,                /**< Low duty scan interval  */

              .low_duty_scan_window            = WICED_BT_CFG_DEFAULT_LOW_DUTY_SCAN_WINDOW,                  /**< Low duty scan window */

              .low_duty_scan_duration          = 5,          

      /* Connection scan configuration */

              .high_duty_conn_scan_interval    = WICED_BT_CFG_DEFAULT_HIGH_DUTY_CONN_SCAN_INTERVAL,          /**< High duty cycle connection scan interval */

              .high_duty_conn_scan_window      = WICED_BT_CFG_DEFAULT_HIGH_DUTY_CONN_SCAN_WINDOW,            /**< High duty cycle connection scan window */

              .high_duty_conn_duration         = 30,                                                         /**< High duty cycle connection duration in seconds (0 for infinite) */


              .low_duty_conn_scan_interval     = WICED_BT_CFG_DEFAULT_LOW_DUTY_CONN_SCAN_INTERVAL,           /**< Low duty cycle connection scan interval */

              .low_duty_conn_scan_window       = WICED_BT_CFG_DEFAULT_LOW_DUTY_CONN_SCAN_WINDOW,             /**< Low duty cycle connection scan window */

              .low_duty_conn_duration          = 30,                    

      /* Connection configuration */

              .conn_min_interval               = WICED_BT_CFG_DEFAULT_CONN_MIN_INTERVAL,                     /**< Minimum connection interval */

              .conn_max_interval               = WICED_BT_CFG_DEFAULT_CONN_MAX_INTERVAL,                     /**< Maximum connection interval */

              .conn_latency                    = WICED_BT_CFG_DEFAULT_CONN_LATENCY,                          /**< Connection latency */

              .conn_supervision_timeout        = WICED_BT_CFG_DEFAULT_CONN_SUPERVISION_TIMEOUT,              /**< Connection link supervision timeout */




      Please correct me If I am doing anything wrong.


      Thanks in advance.




        • 1. Re: CYBT-343026 BLE Scanner.

          Hi NeDh_4602711 ,


          On a first look I couldn't figure out any issue.

          So do you mean the call back function didn't trigger at all?

          1. I remember your previous thread on facing issues with PUART. Can you please confirm you were able to see PUART logs prior to start scan API to confirm?


          2. Can you please check status of scan API ?


                status = wiced_bt_ble_scan( BTM_BLE_SCAN_TYPE_HIGH_DUTY, WICED_TRUE, hello_client_scan_result_cback );

                  WICED_BT_TRACE( "wiced_bt_ble_scan: %d\n", status );


          3. Please share the complete code, so that we can test at our side and help to figure out issue.


          4. Attached is a simple Observer / Le Scanner implementation which I tried at my side. You can refer that and try the same at your side. And let us know if you are still facing any issues.


          Thanks & Regards,


          1 of 1 people found this helpful
          • 2. Re: CYBT-343026 BLE Scanner.
            Neeraj Dhekale

            Hi Anjana,


            1. Yes, I got the solution and I have updated on forum Click Here.


            2. I am getting wiced_bt_ble_scan: 8104


            3. Yes sure, I will share the complete code from next time onwards.


            4. Thank you very much I will check this and will let you know.


            Thank and Regards,


            • 3. Re: CYBT-343026 BLE Scanner.
              Neeraj Dhekale

              Hello Anjana,


              After comparing with your code I found my mistake that I had called wiced_bt_ble_scan() function before BTM_ENABLED_EVT.


              It is working perfectly now.


              Thanks and regards,


              1 of 1 people found this helpful
              • 4. Re: CYBT-343026 BLE Scanner.

                Hi Neeraj,


                Thanks for the update.

                Always call all the application init functions after BTM_ENABLED_EVT. You may refer to the implementations in any of our SDK demo projects for reference.


                Thanks & Regards,