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

Related