This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to scan and get list of nearby discoverable mobile devices?

Hi,

I am using 

I am able to list BLE devices using the below example.

SDK = nRF5_SDK_15.3.0_59ac345,

Example : nRF5_SDK_15.3.0_59ac345\examples\ble_central\ble_app_gatts

I have just added one case in "ble_evt_handler" this function.

        
        case BLE_GAP_EVT_ADV_REPORT: 
          if(p_gap_evt->params.adv_report.data.len != 0)
          {

             tmp_rssi = -(p_gap_evt->params.adv_report.rssi);
             if(RSSI == 0)
             RSSI =  tmp_rssi;
             if(tmp_rssi < RSSI){
              RSSI =  tmp_rssi;
             }
            if( p_gap_evt->params.adv_report.data.len!=0){
            NRF_LOG_INFO("RSSI : %d, MAX RSSI: %d, MAX DEVICE : %d",p_gap_evt->params.adv_report.rssi,
            //ble_advdata_parse(p_gap_evt->params.adv_report.data.p_data, p_gap_evt->params.adv_report.data.len, BLE_GAP_AD_TYPE_COMPLETE_LOCAL_NAME),
                              -RSSI,++dev_count);
          NRF_LOG_INFO("MAC: %02x:%02x:%02x:%02x:%02x:%02x",
          p_gap_evt->params.adv_report.peer_addr.addr[5],
          p_gap_evt->params.adv_report.peer_addr.addr[4], 
          p_gap_evt->params.adv_report.peer_addr.addr[3],
          p_gap_evt->params.adv_report.peer_addr.addr[2],
          p_gap_evt->params.adv_report.peer_addr.addr[1],
          p_gap_evt->params.adv_report.peer_addr.addr[0]);
              {
                char name[20]={0};
                strcpy(name,ble_advdata_parse(p_gap_evt->params.adv_report.data.p_data, p_gap_evt->params.adv_report.data.len, BLE_GAP_AD_TYPE_COMPLETE_LOCAL_NAME));
                NRF_LOG_RAW_INFO("\n NAME:");
                for(int i=0;i<strlen(name);i++)
                    NRF_LOG_RAW_INFO("%c",name[i]);
                NRF_LOG_RAW_INFO("\n");
              }
            }
         }
         break;

But not be able to scan mobile devices which are discoverable in other mobiles.

 

So, Guide me to scan nearby mobile devices. What change I should make in the above example?

If any other suggestion, Guide us.

Thanks.

Parents Reply Children
No Data
Related