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

Device Name Missing from Advertising Response

I'm trying to build a quick application to scan for all devices in the vicinity and print out their details (device name, manf data, RSSI, and BLE address). I am parsing the p_scan_evt->params.p_not_found object to do this. It looks like it's working to read manufacturing info and address of all devices, however the packets appear to be missing the device name. The length of the data packet confirms this.

If I scan in the nRF Connect Android app, I am able to verify the same data my nRF52 does, but the raw advertising packet data has additional data. It contains the buffer the nRF52 sees and the device name in addition.

Do I need to issue a scan request from the device? If so how do I do that? I tried to handle the NRF_BLE_SCAN_EVT_SCAN_REQ_REPORT event but I never enter that case.

Any other suggestions?

static void scan_evt_handler(scan_evt_t const * p_scan_evt)
{
    ret_code_t err_code;

    switch(p_scan_evt->scan_evt_id)
    {
         case NRF_BLE_SCAN_EVT_NOT_FOUND:
             device_found(p_scan_evt->params.p_not_found);
             break;

          case NRF_BLE_SCAN_EVT_SCAN_REQ_REPORT:          
              NRF_LOG_INFO("--------------------- SCAN REQ--------------");
              break;
    }
}

Parents
  • Hi Daniel

    I'm sorry, I was positive the advertising reports were added in that example by default. Your ble_evt_handler will have to look something like this:

    static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context)
    {
        ret_code_t            err_code;
        ble_gap_evt_t const * p_gap_evt = &p_ble_evt->evt.gap_evt;
    
    
        switch (p_ble_evt->header.evt_id)
        {
            case BLE_GAP_EVT_ADV_REPORT:
                if (p_ble_evt->evt.gap_evt.params.adv_report.peer_addr.addr[0] == 0xD3)
                {
                    NRF_LOG_INFO("adv_report from %02x:02x:02x:02x:02x:02x", p_ble_evt->evt.gap_evt.params.adv_report.peer_addr.addr[0],
                                                                            p_ble_evt->evt.gap_evt.params.adv_report.peer_addr.addr[1],
                                                                            p_ble_evt->evt.gap_evt.params.adv_report.peer_addr.addr[2],
                                                                            p_ble_evt->evt.gap_evt.params.adv_report.peer_addr.addr[3],
                                                                            p_ble_evt->evt.gap_evt.params.adv_report.peer_addr.addr[4],
                                                                            p_ble_evt->evt.gap_evt.params.adv_report.peer_addr.addr[5]);
                    uint8_t channel = p_ble_evt->evt.gap_evt.params.adv_report.ch_index;
                    uint16_t len = (uint16_t)p_ble_evt->evt.gap_evt.params.adv_report.data.len;
                    NRF_LOG_INFO("adv_report channel %d, len %d", channel, len);
                    
                    NRF_LOG_INFO("advertisement:");
                    for (uint16_t i=0; i<len; i++)
                    {
                        NRF_LOG_RAW_INFO("%02x", p_ble_evt->evt.gap_evt.params.adv_report.data.p_data[i]);
                        if(i%10 == 0 && i != 0)
                        {
                            NRF_LOG_RAW_INFO("\r\n");
                        }
                        else if(i<len-1)
                        {
                            NRF_LOG_RAW_INFO(":");
                        }
                    }
                    NRF_LOG_RAW_INFO("\r\n");
                }
                break;
    
    
    
    

    Keep in mind that this snippet has been edited to add print into the ble_evt_handler, but it is what I had available at the time. The advertising report (BLE_GAP_EVT_ADV_REPORT) should handle the initial advertisement and the scan response if any.

    Best regards,

    Simon

  • @srimonr , Im having the same issue here with nrf52832 + sd132 7.0.1 + sdk17

    Im receiving adv packets during scanning, the packet is correct from the gap perspective (the format and size are correct), but it does not contain the advertising name within. I CAN see the advertising name in the Android App, so the name is there, its just not presented to me from the SoftDevice event - can you think of a reason this happens? 

    Im handling this in NRF_BLE_SCAN_EVT_FILTER_MATCH event in 

    scan_evt_handler() from here:


    static void scan_init(void) {
      ret_code_t err_code;
      nrf_ble_scan_init_t init_scan;
    
      memset(&init_scan, 0, sizeof(init_scan));
    
      init_scan.connect_if_match = false;
      init_scan.conn_cfg_tag = APP_BLE_CONN_CFG_TAG;
    
      err_code = nrf_ble_scan_init(&m_scan, &init_scan, scan_evt_handler);
      APP_ERROR_CHECK(err_code);
    
      err_code = nrf_ble_scan_filter_set(&m_scan, SCAN_UUID_FILTER, &m_nus_uuid);
      APP_ERROR_CHECK(err_code);
    
      err_code =
          nrf_ble_scan_filters_enable(&m_scan, NRF_BLE_SCAN_UUID_FILTER, false);
      APP_ERROR_CHECK(err_code);
    }
    
    
    

    Thanks!

Reply
  • @srimonr , Im having the same issue here with nrf52832 + sd132 7.0.1 + sdk17

    Im receiving adv packets during scanning, the packet is correct from the gap perspective (the format and size are correct), but it does not contain the advertising name within. I CAN see the advertising name in the Android App, so the name is there, its just not presented to me from the SoftDevice event - can you think of a reason this happens? 

    Im handling this in NRF_BLE_SCAN_EVT_FILTER_MATCH event in 

    scan_evt_handler() from here:


    static void scan_init(void) {
      ret_code_t err_code;
      nrf_ble_scan_init_t init_scan;
    
      memset(&init_scan, 0, sizeof(init_scan));
    
      init_scan.connect_if_match = false;
      init_scan.conn_cfg_tag = APP_BLE_CONN_CFG_TAG;
    
      err_code = nrf_ble_scan_init(&m_scan, &init_scan, scan_evt_handler);
      APP_ERROR_CHECK(err_code);
    
      err_code = nrf_ble_scan_filter_set(&m_scan, SCAN_UUID_FILTER, &m_nus_uuid);
      APP_ERROR_CHECK(err_code);
    
      err_code =
          nrf_ble_scan_filters_enable(&m_scan, NRF_BLE_SCAN_UUID_FILTER, false);
      APP_ERROR_CHECK(err_code);
    }
    
    
    

    Thanks!

Children
No Data
Related