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

ble_advertising_advdata_update error

oid ble_service_update_advertising_data() {
   ret_code_t ret_code;
    ble_gap_adv_data_t new_data;

    memcpy(&new_data,&(m_advertising.adv_data), sizeof(new_data));

    uint8_t data[29] = "";
    format_advertising_data(data);

    new_data.adv_data.p_data = data;
    new_data.adv_data.len = strlen(data);

    ret_code = ble_advertising_advdata_update(&m_advertising, &new_data, true);
    APP_ERROR_CHECK(ret_code);

}

<error> app: ERROR 8 [NRF_ERROR_INVALID_STATE] at the same line as

    ret_code = ble_advertising_advdata_update(&m_advertising, &new_data, true);
    APP_ERROR_CHECK(ret_code);

My code is based on

https://devzone.nordicsemi.com/tutorials/b/bluetooth-low-energy/posts/ble-advertising-a-beginners-tutorial

I am trying to add sensor data into the advertising field packet

Parents
  • Hi.

    Are you trying to update the advertising data while advertising?

    ble_advertising_advdata_update():
    "This function can be called if you wish to reconfigure the advertising data The update will be effective even if advertising has already been started. If you set permanent to true, the advertising data will be permanently updated inside the module instance."

    The function will return NRF_SUCCESS or any error from sd_ble_gap_adv_set_configure().

    sd_ble_gap_adv_set_configure():
    "Configure an advertising set. Set, clear or update advertising and scan response data.
    In order to update advertising data while advertising, new advertising buffers must be provided."

    Return value;

    NRF_ERROR_INVALID_STATE Invalid state to perform operation. Either:
    • It is invalid to provide non-NULL advertising set parameters while advertising.
    • It is invalid to provide the same data buffers while advertising. To update advertising data, provide new advertising buffers.

    Regards,
    Joakim

Reply
  • Hi.

    Are you trying to update the advertising data while advertising?

    ble_advertising_advdata_update():
    "This function can be called if you wish to reconfigure the advertising data The update will be effective even if advertising has already been started. If you set permanent to true, the advertising data will be permanently updated inside the module instance."

    The function will return NRF_SUCCESS or any error from sd_ble_gap_adv_set_configure().

    sd_ble_gap_adv_set_configure():
    "Configure an advertising set. Set, clear or update advertising and scan response data.
    In order to update advertising data while advertising, new advertising buffers must be provided."

    Return value;

    NRF_ERROR_INVALID_STATE Invalid state to perform operation. Either:
    • It is invalid to provide non-NULL advertising set parameters while advertising.
    • It is invalid to provide the same data buffers while advertising. To update advertising data, provide new advertising buffers.

    Regards,
    Joakim

Children
Related