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

long range

Hello All,

I am having trouble changing the 'ble_app_multiperipheral_pca1056_s140' example to work with long range. I have read a few of the blog posts and similar devzone posts but I can't seem to find an answer that works. 

Here is my code for configuring the gap advertising set:

   // only extended advertising will allow primary phy to be coded
    NRF_LOG_INFO("Advertising type set to EXTENDED_CONNECTABLE_NONSCANNABLE_UNDIRECTED ");
    //adv_params.properties.type = BLE_GAP_ADV_TYPE_CONNECTABLE_SCANNABLE_UNDIRECTED;
    adv_params.properties.type = BLE_GAP_ADV_TYPE_EXTENDED_CONNECTABLE_NONSCANNABLE_UNDIRECTED;
              
    err_code = ble_advdata_encode(&advdata, m_adv_data.adv_data.p_data, &m_adv_data.adv_data.len);
    APP_ERROR_CHECK(err_code);

    // Start advertising.
    memset(&adv_params, 0, sizeof(adv_params));
    adv_params.p_peer_addr   = NULL;
    adv_params.filter_policy = BLE_GAP_ADV_FP_ANY;
    adv_params.interval      = APP_ADV_INTERVAL;
    adv_params.duration      = 0;//APP_ADV_DURATION;

    NRF_LOG_INFO("Setting adv params phy to coded phy .. ");
    adv_params.primary_phy     = BLE_GAP_PHY_CODED;
    //adv_params.secondary_phy   = BLE_GAP_PHY_CODED;

    err_code = sd_ble_gap_adv_set_configure(&m_adv_handle, &m_adv_data, &adv_params);
    APP_ERROR_CHECK(err_code);
}

The error I get is :

<info> app: Setting adv params phy to coded phy ..

<error> app: ERROR 7 [NRF_ERROR_INVALID_PARAM] at :0

PC at: 0x00000000

<error> app: End of error report

Any help where I am going wrong or anything that I have missed would really be appreciated.

Cheers

Michael

8ball

Parents
  • Hi Michael, for extended advertising to work, it must use the secondary phy.

    When using extended advertising, the primary phy is only used to "point" over to the secondary phy, where the much longer data can exist.

    So you probably don't want to comment out the secondary phy. :)

  • Hi 

    Thanks for the input. I have tried it with and without priory to submitting the ticket and it didn't make any difference (the error 7 was still reported). 

    Also;

    Do you know what the 'adv_params.duration'  should be set too? (I have tried both 0 and APP_ADV_DURATION)  ??

    Do I need to add the line (i'm not sure what the srdata is used for) - 

    err_code = ble_advdata_encode(&srdata, m_adv_data.scan_rsp_data.p_data, &m_adv_data.scan_rsp_data.len);  ??

    I can't seem to find a large amount of information on the setting requirements for long range so I'm shooting in the dark 

    Any help appreciated

    Cheers

    Michael

  • Well Michael after trying your code I can tell you why you have not found this problem elsewhere.

    You are setting adv_params.properties.type, and then clearing adv_params with memset, and then setting the rest of the adv_params. please move  adv_params.properties.type = BLE_GAP_ADV_TYPE_EXTENDED_CONNECTABLE_NONSCANNABLE_UNDIRECTED; down a few codelines, after  the memset.

    Enjoy your coded phy. Innocent

  • Hi 

    Good spot, as you say that wouldn't help. I would love to say that this has solved my problem, but even after I move the line to below the memset (clr),I still get the same error 7 code. 

    "app: ERROR 7 [NRF_ERROR_INVALID_PARAM] at :0 "

    This is my modified code as you suggested:

    #define LONG_RANGE_SELECTED 1
    #if  defined(LONG_RANGE_SELECTED)
        // only extended advertising will allow primary phy to be coded
        //NRF_LOG_INFO("Advertising type set to EXTENDED_CONNECTABLE_NONSCANNABLE_UNDIRECTED ");
        //adv_params.properties.type = BLE_GAP_ADV_TYPE_CONNECTABLE_SCANNABLE_UNDIRECTED;
        //adv_params.properties.type = BLE_GAP_ADV_TYPE_EXTENDED_CONNECTABLE_NONSCANNABLE_UNDIRECTED;
                  
        err_code = ble_advdata_encode(&advdata, m_adv_data.adv_data.p_data, &m_adv_data.adv_data.len);
        APP_ERROR_CHECK(err_code);
    
        // Start advertising.
        memset(&adv_params, 0, sizeof(adv_params)); //clear Advertising memory
        NRF_LOG_INFO("Advertising type set to EXTENDED_CONNECTABLE_NONSCANNABLE_UNDIRECTED ");
        adv_params.properties.type = BLE_GAP_ADV_TYPE_EXTENDED_CONNECTABLE_NONSCANNABLE_UNDIRECTED;//MD moved to here below the memset
        adv_params.p_peer_addr   = NULL;
        adv_params.filter_policy = BLE_GAP_ADV_FP_ANY;
        adv_params.interval      = APP_ADV_INTERVAL;
        adv_params.duration      = APP_ADV_DURATION;
        NRF_LOG_INFO("Setting adv params phy to coded phy .. ");
        adv_params.primary_phy     = BLE_GAP_PHY_CODED;
        adv_params.secondary_phy   = BLE_GAP_PHY_CODED;
        adv_params.scan_req_notification =1; //recently added MD 7/9/18
    
    #else
        err_code = ble_advdata_encode(&advdata, m_adv_data.adv_data.p_data, &m_adv_data.adv_data.len);
        APP_ERROR_CHECK(err_code);
    
        err_code = ble_advdata_encode(&srdata, m_adv_data.scan_rsp_data.p_data, &m_adv_data.scan_rsp_data.len);
        APP_ERROR_CHECK(err_code);
    
        // Start advertising.
        memset(&adv_params, 0, sizeof(adv_params));
        adv_params.p_peer_addr   = NULL;
        adv_params.filter_policy = BLE_GAP_ADV_FP_ANY;
        adv_params.interval      = APP_ADV_INTERVAL;
    
        adv_params.properties.type = BLE_GAP_ADV_TYPE_CONNECTABLE_SCANNABLE_UNDIRECTED;
        adv_params.duration        = APP_ADV_DURATION;
        adv_params.primary_phy     = BLE_GAP_PHY_1MBPS;  //MD changed for extended broadcast range -old
    
    #endif
    
        err_code = sd_ble_gap_adv_set_configure(&m_adv_handle, &m_adv_data, &adv_params);
        APP_ERROR_CHECK(err_code);

    Any further suggestions?

    Disappointed relieved

    Cheers

    Michael

  • It is working in my project.

    Did you set scan_rsp_data to NULL?

    static ble_gap_adv_data_t m_adv_data =
    {
        .adv_data =
        {
            .p_data = m_enc_advdata,
            .len    = BLE_GAP_ADV_SET_DATA_SIZE_MAX
        },
        .scan_rsp_data =
        {
            .p_data = NULL,
            .len    = 0
    
        }
    };

  • Hi 

    Yes that has cleared up the error. Do you know if there is a white paper or similar document from Nordic that describes the setting requirements to enable some of these modes (and there dependencies)??

    I understand that the Infocenter document holds a lot of information about the SoftDevice API (including defines, Enumerations, functions and structures) .... but as far as I can see it doesn't tell you a lot of information for the requirements to enable a particular connection type (in my case the long range). 

    For example a search of 'long range' in the Infocentrer it returns no results. 

    If I search 'BLE_GAP_PHY_CODED' one of the returned functions is for the  sd_ble_gap_phy_update function, which has a note :

    "Note: BLE_GAP_PHY_CODED is only supported as an experimental feature in this SoftDevice."

    None of the returned information is of any real help into what I need to set as opposed to what I can set - I guess that is why this is a common question on the devzone site?? 

    Thanks for your help 

    Cheers

    Michael

  • I'm glad you got it working Michael. :)

    I am not aware of any whitepaper, or step by step tutorial for long range or other "modes", that clearly list the dependencies. But there are some examples that use long range:

    https://github.com/NordicPlayground/nRF52-ble-long-range-demo

    https://github.com/NordicPlayground/nrf52-ble-app-uart-long-range

    ATT_MTU Throughput Example (For the connection, not advertising or scanning)

    There are several resources to give a more general understanding of long range (I know that is not what you are asking for, but for completeness, I want to add links for others to see):

    https://www.nordicsemi.com/eng/Products/Bluetooth-5

    https://blog.nordicsemi.com/getconnected/tested-by-nordic-bluetooth-long-range

    https://blog.nordicsemi.com/getconnected/things-you-should-know-about-bluetooth-range

    https://devzone.nordicsemi.com/b/blog/posts/testing-long-range-coded-phy-with-nordic-solution-it-simply-works-922075585

    I agree that it could be more explicitly stated in the API that the scan response data must be NULL when the advertising type is non-scannable.

    It is said more implicitly under GAP Advertising types

    "Scan response data can only be specified for a @ref ble_gap_adv_properties_t::type
    that is scannable."

    and under GAP advertising data buffers:
    "non-scannable types do not support scan response data."

    And when you add too many implicit parameters on top of each other mistakes get easy to make.

    I will check internally if someone wants to clean up the API a bit or make a blog post about advertising- and connection phys. (I assume this is what you mean by "modes" but feel free to specify it more).

    Good luck with your project.

     -Håvard

Reply Children
Related