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);
}
Parents
  • Hi Geoffrey, What do you have in mdw_nus_data_handler() ? You need to define the function so that p_nus->data_handler(&evt); can be called. In the code you post you just have a declaration, not the definition of the function it self.

    Please have a look at nus_data_handler() function we have in main.c in ble_app_uart example.

  • No I did not. In Reality I received the event. this is the work flow I have done.

    - Init Nus                      : OK
    - Wait a msg                 : OK
    - Get event RX              : OK
    - Execute Callback        : OK
    - Reply                         : OK
    - send data onver ble    : OK
    - get the Event BLE_NUS_EVT_TX_RDY : OK
    - execute line p_nus->data_handler(&evt); : NOK as data_handler is NULL 
    

    When I try to send something I have got this problem.

    On solution is to replace this line directly by a global function pointer, it is enough for my application, but it is dirty and I really want to understand why when I send something over ble it does not work.

Reply
  • No I did not. In Reality I received the event. this is the work flow I have done.

    - Init Nus                      : OK
    - Wait a msg                 : OK
    - Get event RX              : OK
    - Execute Callback        : OK
    - Reply                         : OK
    - send data onver ble    : OK
    - get the Event BLE_NUS_EVT_TX_RDY : OK
    - execute line p_nus->data_handler(&evt); : NOK as data_handler is NULL 
    

    When I try to send something I have got this problem.

    On solution is to replace this line directly by a global function pointer, it is enough for my application, but it is dirty and I really want to understand why when I send something over ble it does not work.

Children
No Data
Related