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

nrf52 nordic uart services

Hello,

I've got some trouble using Nordic Uart Services,

I correctly add the library to my project.

I can receive data from different devices. But when I want to send data over ble, the soft device Assert and make a hard fault interrupt.

After some investigationn the error comes from this function

ble_nus_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context)

in the file ble_nus.c @line 262.

I understood that p_context is the ble_nus_t instance that sent my message over ble.

But when I reach this line after a transmission. The data_handler value is 0 and not the address of my callback.

Could you help me to solve this issue ?

I work on nrf52832 with SDK14.1.0 and SES. I started from free RTOS hrs exemple

Thank You. Geoffrey

Ps : This is my ble_nus_initialization

static void mdw_nus_data_handler(ble_nus_evt_t * p_evt);

void mdw_console_ble_init(void)
{
    mdwConsBleFlagsHandle = xEventGroupCreate();
    ASSERT(NULL != mdwConsBleFlagsHandle);
    mdwConsBleWriteMutexHandle = xSemaphoreCreateMutex();
    ASSERT(NULL != mdwConsBleWriteMutexHandle);
    mdwConsBleReadMutexHandle = xSemaphoreCreateBinary();
    ASSERT(NULL != mdwConsBleReadMutexHandle);
    xSemaphoreGive(mdwConsBleReadMutexHandle);
    xSemaphoreTake(mdwConsBleWriteMutexHandle, portMAX_DELAY);

    ble_nus_init_t nus_init;
    memset(&nus_init, 0, sizeof(nus_init));

    nus_init.data_handler = mdw_nus_data_handler;

    mdwRxEnable = false;
    mdwTxEnable = false;

    uint32_t errCode = ble_nus_init(&m_nus, &nus_init);
    APP_ERROR_CHECK(errCode);

    xSemaphoreGive(mdwConsBleWriteMutexHandle);
}
Related