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

Scan request with extended advertising

Hi,

I'm trying to send and receive scan request/scan response.  The system consists of 2 nrf52840, 1 central and 1 peripheral.  They both advertise and scan on 1M and coded PHY alternately.

I'm trying to get the central to send out a scan request, but the peripheral isn't receiving any scan request.  I have the following on peripheral side:

m_advertising.adv_params.scan_req_notification = 1;

and

          case BLE_GAP_EVT_SCAN_REQ_REPORT:  
          {
              NRF_LOG_INFO("SCAN REQ %d", valid_num_central);

On central side, I have:

static ble_gap_scan_params_t m_scan_params =
{
    .active   = 1, //scan req
    .interval = SCAN_INTERVAL,
    .window   = SCAN_WINDOW,
    .report_incomplete_evts = 0, 
    .extended = 1,
    .timeout           = SCAN_TIMEOUT,
    .scan_phys         = BLE_GAP_PHY_1MBPS | BLE_GAP_PHY_CODED, 
    .filter_policy     = BLE_GAP_SCAN_FP_ACCEPT_ALL,
    .channel_mask      = {0,0,0,0,0x00},
};

#define SCAN_INTERVAL 1280
#define SCAN_WINDOW 640
#define SCAN_TIMEOUT 0 

I'm using SDK 16.0.0, SD S140 7.0.1

Any suggestion would be appreciated.

Thanks,

Ken

Parents
  • Hi

    Can you also show me the advertising parameters, in the scan_req_notification define, it is stated that this parameter is ignored if ble_gap_adv_properties is set to a non-scannable advertising type.

    You can also take a sniffer trace to check whether a scan request is actually sent by the central device.

    Best regards,

    Simon

  • static void advertising_init(uint8_t phy)
    {
        ret_code_t             err_code;
        static ble_advdata_manuf_data_t manuf_specific_data;
        static ble_advdata_manuf_data_t srsp_manuf_specific_data;
    
        manuf_specific_data.company_identifier = COMPANY_IDENTIFIER;
        srsp_manuf_specific_data.company_identifier = COMPANY_IDENTIFIER;
    
        memset(&init, 0, sizeof(init));
    
        manuf_specific_data.data.p_data = (uint8_t *) m_srespons_info;
        manuf_specific_data.data.size   = APP_SRESPONSE_INFO_LENGTH;
        srsp_manuf_specific_data.data.p_data = (uint8_t *) m_srespons_info;
        srsp_manuf_specific_data.data.size = APP_SRESPONSE_INFO_LENGTH;
    
        init.advdata.name_type               = BLE_ADVDATA_NO_NAME;
        init.advdata.include_appearance      = false;
        init.advdata.flags                   = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;
        init.advdata.p_manuf_specific_data = &manuf_specific_data;
    //    init.srdata.p_manuf_specific_data = &srsp_manuf_specific_data;
    //    init.advdata.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
    //    init.advdata.uuids_complete.p_uuids  = m_adv_uuids;
        if(phy == BLE_GAP_PHY_CODED)
        {
            m_advertising.adv_params.primary_phy = BLE_GAP_PHY_CODED;
            m_advertising.adv_params.secondary_phy = BLE_GAP_PHY_CODED;
        }
        else 
        {
            m_advertising.adv_params.primary_phy = BLE_GAP_PHY_1MBPS;
            m_advertising.adv_params.secondary_phy = BLE_GAP_PHY_1MBPS;
        }
    //    m_advertising.adv_params.properties.type = BLE_GAP_ADV_TYPE_EXTENDED_NONCONNECTABLE_SCANNABLE_UNDIRECTED;
        m_advertising.adv_params.properties.type = BLE_GAP_ADV_TYPE_EXTENDED_NONCONNECTABLE_SCANNABLE_UNDIRECTED;
    //    m_advertising.adv_params.properties.type = BLE_GAP_ADV_TYPE_CONNECTABLE_SCANNABLE_UNDIRECTED;
        m_advertising.adv_params.scan_req_notification = 1;
        m_advertising.adv_params.p_peer_addr     = NULL;    // Undirected advertisement.
        m_advertising.adv_params.filter_policy   = BLE_GAP_ADV_FP_ANY;
        m_advertising.adv_params.interval        = APP_ADV_INTERVAL;
        m_advertising.adv_params.duration        = APP_ADV_DURATION_UNLIMITED;       // Timeout after 60 s
        m_advertising.adv_params.channel_mask[4] = 0x00;
    
        init.config.ble_adv_whitelist_enabled = true;
        init.config.ble_adv_fast_enabled  = true;
        init.config.ble_adv_fast_interval = APP_ADV_INTERVAL;
        init.config.ble_adv_fast_timeout  = APP_ADV_DURATION;
        init.config.ble_adv_slow_enabled = true;
        init.config.ble_adv_slow_interval = APP_SLOW_ADV_INTERVAL;
        init.config.ble_adv_slow_timeout = APP_SLOW_ADV_DURATION;
        init.config.ble_adv_extended_enabled = true;
        if(phy == BLE_GAP_PHY_CODED)
        {
            init.config.ble_adv_primary_phy = BLE_GAP_PHY_CODED;
            init.config.ble_adv_secondary_phy = BLE_GAP_PHY_CODED;
        }
        else
        {
            init.config.ble_adv_primary_phy = BLE_GAP_PHY_1MBPS;
            init.config.ble_adv_secondary_phy = BLE_GAP_PHY_1MBPS;
        }
    
    
        init.evt_handler = on_adv_evt;
    
        err_code = ble_advertising_init(&m_advertising, &init);
        APP_ERROR_CHECK(err_code);
    
        ble_advertising_conn_cfg_tag_set(&m_advertising, APP_BLE_CONN_CFG_TAG);
    
        err_code = sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_ADV, m_advertising.adv_handle, TX_POWER_LEVEL);
        APP_ERROR_CHECK(err_code);
    }
    
    
    #define APP_ADV_INTERVAL                320                       /**< The advertising interval (in units of 0.625 ms. This value corresponds to 150 ms). */
    #define APP_ADV_DURATION_UNLIMITED      0                                           /**< Unlimited period .*/
    #define APP_ADV_DURATION                2000                         /**< The advertising duration (60 seconds) in units of 10 milliseconds. */
    #define APP_SLOW_ADV_INTERVAL           2400                  /**< The advertising interval (in units of 0.625 ms. This value corresponds to 2000 ms). */
    #define APP_SLOW_ADV_DURATION           2000

    I don't have a BLE sniffer.  Is there another method of checking central's scan request message?

    Regards,

    Ken

  • Simon,

    I managed to get the sniffer going using one of the DK I have.

    PDU type is 0011, which seems to be scan request, correct?

    A sniff on peripheral adv package for coded PHY

    In extended advertising header, it indicates advertising mode as "Connectable Non-scannable" even though advertising property type is set to BLE_GAP_ADV_TYPE_EXTENDED_NONCONNECTABLE_SCANNABLE_UNDIRECTED.  Correct me if I'm wrong, but scannable means it is able to receive scan request.  I'm not sure why advertising header is showing non-scannable.

    Regards,

    Ken

Reply
  • Simon,

    I managed to get the sniffer going using one of the DK I have.

    PDU type is 0011, which seems to be scan request, correct?

    A sniff on peripheral adv package for coded PHY

    In extended advertising header, it indicates advertising mode as "Connectable Non-scannable" even though advertising property type is set to BLE_GAP_ADV_TYPE_EXTENDED_NONCONNECTABLE_SCANNABLE_UNDIRECTED.  Correct me if I'm wrong, but scannable means it is able to receive scan request.  I'm not sure why advertising header is showing non-scannable.

    Regards,

    Ken

Children
No Data
Related