Hi everyone,
I have a BLE project and i added the Nordic UART Service to it. It compile without error or warnings but ble_advertising_init() return NRF_ERROR_INVALID_PARAMS
static void advertising_init(void) { ret_code_t err_code; ble_advertising_init_t init; memset(&init, 0, sizeof(init)); init.advdata.name_type = BLE_ADVDATA_FULL_NAME; init.advdata.include_appearance = true; init.advdata.flags = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE; init.advdata.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]); init.advdata.uuids_complete.p_uuids = m_adv_uuids; init.config.ble_adv_fast_enabled = true; init.config.ble_adv_fast_interval = APP_ADV_INTERVAL; init.config.ble_adv_fast_timeout = APP_ADV_DURATION; init.evt_handler = on_adv_evt; err_code = ble_advertising_init(&m_advertising, &init); // At this point err_code = 7 -> NRF_ERROR_INVALID_PARAMS APP_ERROR_CHECK(err_code); ble_advertising_conn_cfg_tag_set(&m_advertising, APP_BLE_CONN_CFG_TAG); }
Here is the Log
<error> app: ERROR 7 [NRF_ERROR_INVALID_PARAM] at ../../../main.c:813 PC at: 0x00032BD3 <error> app: End of error report
Here is the Line 812 & 813 of my main.c
ret_code_t err_code = ble_advertising_start(&m_advertising, BLE_ADV_MODE_FAST); APP_ERROR_CHECK(err_code);
After some diging i found that VERIFY_SUCCESS(ret) at line 475 in ble_advertising.c fail (ret = 7). This means the error come from
ret = ble_advdata_encode(&p_init->advdata, p_advertising->enc_advdata, &p_advertising->adv_data.adv_data.len);
Putting some NRF_LOG_INFO() in ble_adv_data_encode(), i found out the error comes from uuid_list_encode at line 563 in ble_advdata.c
// Encode 'complete' uuid list. if (p_advdata->uuids_complete.uuid_cnt > 0) { err_code = uuid_list_encode(&p_advdata->uuids_complete, BLE_GAP_AD_TYPE_16BIT_SERVICE_UUID_COMPLETE, BLE_GAP_AD_TYPE_128BIT_SERVICE_UUID_COMPLETE, p_encoded_data, p_len, max_size); VERIFY_SUCCESS(err_code); }
So i think the error comes from
#define NUS_SERVICE_UUID_TYPE BLE_UUID_TYPE_VENDOR_BEGIN /**< UUID type for the Nordic UART Service (vendor specific). */ ... static ble_uuid_t m_adv_uuids[] = /**< Universally unique service identifiers. */ { {BLE_UUID_BATTERY_SERVICE, BLE_UUID_TYPE_BLE}, {BLE_UUID_DEVICE_INFORMATION_SERVICE, BLE_UUID_TYPE_BLE}, {BLE_UUID_NUS_SERVICE, NUS_SERVICE_UUID_TYPE} };
I used the ble_app_uart example for reference as how to implement the NUS. Mine sdk_config.h is almost the same as the example's one. By almost, i mean i have enabled the driver i need, BAS and DIS.
NRF_SDH_BLE_VS_UUID_COUNT is define to 1 as i only have NUS which is vendor specific.
Something is not right but i don't know what it is.
I use SDK 15.3.0, SoftDevice S132 V6.1.1 on a nRF52832 in a custom board. My IDE is Eclipse on Windows 10