Announcements
IMPORTANT: Cypress Developer Community is transitioning on October 20th. To learn more and be prepared for this change, check out our latest announcement.
cancel
Showing results for 
Search instead for 
Did you mean: 

ModusToolbox Bluetooth SDK

NeDh_4602711
Contributor II

Hello,

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_app_init();

    wiced_bt_set_pairable_mode(WICED_TRUE, 0);

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

    wiced_bt_ble_scan(BTM_BLE_SCAN_TYPE_HIGH_DUTY,FALSE,newAdv);

.

-----------------------------------------------------------------------------

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);

    WICED_BT_TRACE("\n");

}

--------------------------------------------------------------------------------------------------------------

/* 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.

Regards,

Neeraj

0 Likes
1 Solution
AnjanaM_61
Moderator
Moderator

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 ?

Example:

      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,

Anjana

View solution in original post

4 Replies
AnjanaM_61
Moderator
Moderator

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 ?

Example:

      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,

Anjana

View solution in original post

NeDh_4602711
Contributor II

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,

Neeraj

0 Likes
NeDh_4602711
Contributor II

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,

Neeraj

AnjanaM_61
Moderator
Moderator

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,

Anjana