Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

ble_advertising_init returning NRF_ERROR_INVALID_PARAM for parameters set by the function itself

Hello,

i'm trying to use ble_advertising_init to initialize my advertising data, but when i use this function like it is used in the examples i get NRF_ERROR_INVALID_PARAM.

i located the error in the following code part of the function:

    // Configure a initial advertising configuration. The advertising data and and advertising
    // parameters will be changed later when we call @ref ble_advertising_start, but must be set
    // to legal values here to define an advertising handle.
    p_advertising->adv_params.primary_phy     = BLE_GAP_PHY_1MBPS;
    p_advertising->adv_params.duration        = p_advertising->adv_modes_config.ble_adv_fast_timeout;
    p_advertising->adv_params.properties.type = BLE_GAP_ADV_TYPE_CONNECTABLE_SCANNABLE_UNDIRECTED;
    p_advertising->adv_params.p_peer_addr     = NULL;
    p_advertising->adv_params.filter_policy   = BLE_GAP_ADV_FP_ANY;
    p_advertising->adv_params.interval        = p_advertising->adv_modes_config.ble_adv_fast_interval;

    ret = sd_ble_gap_adv_set_configure(&p_advertising->adv_handle, NULL, &p_advertising->adv_params);

Since all parameters given to the function are the default params defined by the function itself, there should be no error.

Also the comment is kind of irritating, since you can't set any advertising parameters in ble_advertising_start. Although it seems, that ble_advertising_start overwrites your set paramters with default values again. But since these parameters can only be set when advertising is stopped, this would make setting them pointless.

Am i missing something here?

If someone could provide some inside on this, i would appreciate it.

Best regards,

Niclas

  • Hello Niclas

    Could you please provide the code which you use to call ble_advertising_init, both ble_advertising_t and ble_advertising_init_t ? 
    Also, are you modifying one of the examples? 

    Which Softdevice, SDK and DK are you using?

    I will need this to try to replicate your error.

    Best regards, 

    Martin

  • Hello Martin,

    i'm using SDK15 with Softdevice s132_6.0.0 and a pca10040.

    i use BLE_ADVERTISING_DEF(m_advertising) to set the ble_advertising_t and don't modify it further before calling ble_advertising_init

    The ble_advertising_init_t should be irrelevant since it is not used in the call to sd_ble_gap_adv_set_configure() where the error occurs.

    I used the ble_app_hrs example as a guideline.

    Thanks for your help,

    Niclas

  • Hi Niclas, from what I can see sd_ble_gap_adv_set_configure returns NRF_INVALID_PARAM from "
    *- Invalid advertising data configuration specified. See @ref ble_gap_adv_data_t.
    * - Invalid configuration of p_adv_params. See @ref ble_gap_adv_params_t.
    * - Use of whitelist requested but whitelist has not been set,
    * see @ref sd_ble_gap_whitelist_set."
    You should look at what is being put int sd_ble_gap_adv_set_configure by putting a breakpoint where it starts and look through all the variables. Hope this helps.

  • Hi Martin,

    I already posted what is being put into the function in my original post.

    This is a SDK function and i use it as provided by the example. Only parameters that come from the call to ble_advertising_init are

        p_advertising->adv_params.duration        = p_advertising->adv_modes_config.ble_adv_fast_timeout;
    ...
        p_advertising->adv_params.interval        = p_advertising->adv_modes_config.ble_adv_fast_interval;

    The error comes from adv_params.interval beeing 0, because it is never set.

    But if this are only default values, that shoudln't matter because they get overwritten later on anyway, why is it not using valid parameters directly?

    Besides from BLE_ADVERTISING_DEF() the variable is not modified in the hrs example, so adv_modes_config values are not modified. This means in the example adv_params.interval schould also be 0 and it should not work.

    I would suggest changing the parameters in ble_advertising_init to:

        p_advertising->adv_params.primary_phy     = BLE_GAP_PHY_1MBPS;
        p_advertising->adv_params.duration        = BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED;
        p_advertising->adv_params.properties.type = BLE_GAP_ADV_TYPE_CONNECTABLE_SCANNABLE_UNDIRECTED;
        p_advertising->adv_params.p_peer_addr     = NULL;
        p_advertising->adv_params.filter_policy   = BLE_GAP_ADV_FP_ANY;
        p_advertising->adv_params.interval        = BLE_GAP_ADV_INTERVAL_MIN;

    Best regards,

    Niclas

  • Hi Niclas,

    If your adv_params.interval is below 20ms you will get an error as you are outside of the Bluetooth Specifications, see Bluetooth Core Specifications 5.0 :"If the advertising interval range provided by the Host (Advertising_Interval_Min,
    Advertising_Interval_Max) is outside the advertising interval range supported
    by the Controller, then the Controller shall return the Unsupported Feature or
    Parameter Value (0x11) error code". As you are forcing this value to zero you will get an error. Can I suggest using APP_ADV_INTERVAL for this setting and you will not get an error. 

    Hope this solves your issue.

    Regards,

    Martin

Related