HIGH LEVEL: I am simply trying to build the ble_app_uart example on top of the Buttonless DFU example from the NRF SDK. I have confirmed that I can successfully get the default "Nordic_Buttonless" DFU example to work properly. When I try and add the Nordic UART Service to this Buttonless DFU example, I can see a successful DFU of my new app image is completed, yet the board never starts because of an error when it tries to advertise itself. Below are the code changes I have made to the Buttonless DFU example in order to add support for UART:
static ble_uuid_t m_adv_uuids[] =
{
{BLE_UUID_DEVICE_INFORMATION_SERVICE, BLE_UUID_TYPE_BLE},
{BLE_UUID_NUS_SERVICE, BLE_UUID_TYPE_VENDOR_BEGIN} // Same as: NUS_SERVICE_UUID_TYPE from ble_app_uart example code
};
static void nus_data_handler(ble_nus_evt_t * p_evt)
{
// Added the basic default implementation from the ble_app_uart project
}
static void services_init(void)
{
// NOTE: These lines of code have been ADDED to the default implementation!
ble_nus_init_t nus_init;
// Initialize NUS.
memset(&nus_init, 0, sizeof(nus_init));
nus_init.data_handler = nus_data_handler;
err_code = ble_nus_init(&m_nus, &nus_init);
APP_ERROR_CHECK(err_code);
}
Also it should be noted that I have merged the sdk_configs and also made sure that NRF_SDH_BLE_VS_UUID_COUNT 2
The error I get comes from calling ble_advertising_init(). Following the Debugger through this function call, I am taken to ble_advdata_encode(). In this function, there is a comment that says // Encode 'complete' uuid list and in the following if-statement the Debugger steps into the execution of uuid_list_encode() and then again it steps into uuid_list_sized_encode() (for 16bit UUIDs). In uuid_list_sized_encode(), the error occurs with the call to sd_ble_uuid_encode(). The error produced is mostly SOFTDEVICE: INVALID MEMORY ACCESS (Info pointer has a value of 0x0), but I have also seen NRF_ERROR_INVALID_ADDR (Invalid pointer supplied) pop up a couple times. The error always occurs when trying to execute sd_ble_uuid_encode().
It seems to me that there is some issue with the way I am adding the NUS Service to the default Buttonless DFU app. When I tried adding the NUS Service as a BLE UUID Type in m_adv_uuids[], my custom app was able to actually advertise (Services: Device Information and 0001) even though I know UUID is not correct. Is something obviously incorrect with my array of uuids? Are there other crucial steps I need to take to add this UART UUID properly? What can I do to get this UART-extended Buttonless DFU app to run? Thank you in advance for your help!