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

Receiving Scan Response Packet

Hi All!

I'm working a few weeks now with the NRF52 DK and having loads of fun!

Today I tried to make a central/scanner that scans for packages from a broadcaster. To make the broadcaster I followed the tutorial provided by Nordic ( devzone.nordicsemi.com/.../). This all seems to work fine: I can receive all packets, including the Scan Response Packet on my phone.

So with the advertiser working, I started working on the scanner side. I added a " case BLE_GAP_EVT_ADV_REPORT" inside on_ble_evt() and this works all fine.


    case BLE_GAP_EVT_ADV_REPORT:
    {	//
        if (strlen(m_target_periph_name) != 0)
        {
            if (find_adv_name(&p_gap_evt->params.adv_report, m_target_periph_name))
            {
            	NRF_LOG_INFO("Packet from device\r\n");
            	print_adv_data(&p_gap_evt->params.adv_report);
            }
        }
        else
        {
        	NRF_LOG_INFO("not from device\r \n");
        }
    }break;// BLE_GAP_ADV_REPORT

However, I want to be able to transmit more data, so I would like to process the Scan Response Packets as well. I think that I have to handle this with a case BLE_GAP_EVT_SCAN_REQ_REPORT. However, If I make a NRF_LOG_INFO() call inside that case statement, nothing happens. This gives me the idea that this is not the way to go.

I checked the scanner settings: m_scan_param.active = 1; m_scan_param.interval = SCAN_INTERVAL; m_scan_param.window = SCAN_WINDOW;

I hope some of you can help me a little further!

Cheers Rob

Parents
  • FormerMember
    0 FormerMember

    When initiating advertising, ble_advertising_init(..) --> ble_adv_data_set(..) --> sd_ble_gap_adv_data_set(..), both advertising data and scan response data can be set. When a central/scanner sends a scan request, the advertising device will automatically reply with a scan response containing the scan response data provided when initiating the advertising.

    The purpose of the event BLE_GAP_EVT_SCAN_REQ_REPORT is to tell the application that a scanner sent a scan response and that this device replied with the scan response.

Reply
  • FormerMember
    0 FormerMember

    When initiating advertising, ble_advertising_init(..) --> ble_adv_data_set(..) --> sd_ble_gap_adv_data_set(..), both advertising data and scan response data can be set. When a central/scanner sends a scan request, the advertising device will automatically reply with a scan response containing the scan response data provided when initiating the advertising.

    The purpose of the event BLE_GAP_EVT_SCAN_REQ_REPORT is to tell the application that a scanner sent a scan response and that this device replied with the scan response.

Children
  • To add to this: BLE_GAP_EVT_ADV_REPORT is used for both advertisements and scan responses. There is a flag in the event structure stating if it was a a scan response or not. For this to happen, the active field in scam_params must be set (you've done this) and the advertiser must have scan response data to respond with. The advertiser must also be advertising in a mode where scan requests are allowed (ADV_IND or ADV_SCAN_IND, not ADV_DIRECT_IND or ADV_NONCONN_IND). If it has filter policies enabled for scan requests, the scanners identity must be in the advertisers whitelist as well.

Related