I'm migrating from SDK 14.0.0 to SDK 15.0.0, due to Migration guide I have changed my `advertising_start` function so it looks as follows:
#include "my_ble.h"
BLE_LBS_DEF(m_lbs);
NRF_BLE_GATT_DEF(m_gatt);
#define APP_ADV_DURATION BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED /**< The advertising time-out (in units of seconds). When s et to 0, we will never time out. */
#define APP_ADV_INTERVAL 64 /**< The advertising interval (in units of 0.625 ms; this v alue corresponds to 40 ms). */
static uint8_t m_enc_scan_response_data[BLE_GAP_ADV_SET_DATA_SIZE_MAX]; /**< Buffer for storing an encoded scan data. */
static uint8_t m_enc_advdata[BLE_GAP_ADV_SET_DATA_SIZE_MAX]; /**< Buffer for storing an encoded advertising set. */
static uint8_t m_adv_handle = BLE_GAP_ADV_SET_HANDLE_NOT_SET; /**< Advertising handle used to identify an advertising set . */
/**@brief Struct that contains pointers to the encoded advertising data. */
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 = m_enc_scan_response_data,
.len = BLE_GAP_ADV_SET_DATA_SIZE_MAX
}
};
void advertising_start(void)
{
ret_code_t err_code;
ble_advdata_t advdata;
ble_advdata_t srdata;
ble_advdata_manuf_data_t manuf_data;
ble_gap_adv_params_t adv_params;
ble_uuid_t adv_uuids[] = {{MY_UUID_SERVICE, m_lbs.uuid_type}};
// Build and set advertising data.
memset(&advdata, 0, sizeof(advdata));
advdata.name_type = BLE_ADVDATA_FULL_NAME;
advdata.include_appearance = true;
advdata.flags = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;
memset(&manuf_data, 0, sizeof(manuf_data));
manuf_data.company_identifier = BEST_COMPANY_IDENTIFIER;
memset(&srdata, 0, sizeof(srdata));
srdata.uuids_complete.uuid_cnt = sizeof(adv_uuids) / sizeof(adv_uuids[0]);
srdata.uuids_complete.p_uuids = adv_uuids;
srdata.p_manuf_specific_data = &manuf_data;
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);
// Set advertising parameters.
memset(&adv_params, 0, sizeof(adv_params));
adv_params.primary_phy = BLE_GAP_PHY_1MBPS;
adv_params.duration = APP_ADV_DURATION;
adv_params.properties.type = BLE_GAP_ADV_TYPE_CONNECTABLE_SCANNABLE_UNDIRECTED;
adv_params.p_peer_addr = NULL;
adv_params.filter_policy = BLE_GAP_ADV_FP_ANY;
adv_params.interval = APP_ADV_INTERVAL;
err_code = sd_ble_gap_adv_set_configure(&m_adv_handle, &m_adv_data, &adv_params);
NRF_LOG_INFO("err_code: %d\n", err_code );
NRF_LOG_FLUSH();
APP_ERROR_CHECK(err_code);
err_code = sd_ble_gap_adv_start(m_adv_handle ,APP_BLE_CONN_CFG_TAG);
NRF_LOG_INFO("err_code: %d\n", err_code );
NRF_LOG_FLUSH();
APP_ERROR_CHECK(err_code);
}
However I got an error 9 for `sd_ble_gap_adv_set_configure`, which is `Invalid Length`. Why?
Details: nRF52832; SDK 15.0.0 ; Linux