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

How to change the open-mesh polling to interrupt notification

I've got a problem to change polling method to interrupt notification on open-mesh with freertos project.

The example "BLE_Gateway" of open-mesh as flow:

    if (rbc_mesh_event_get(&evt) == NRF_SUCCESS)
    {
        rbc_mesh_event_handler(&evt);
        rbc_mesh_event_release(&evt);
    }

I copy the method of nRF5_SDK_12.0.0 \examples\ble_peripheral\ble_app_hrs_freertos\ using Semaphore to notificate task(I set ble_stack_thread task).

  1. Register handler

SOFTDEVICE_HANDLER_INIT(MESH_CLOCK_SOURCE, ble_new_event_handler);

2.handler function

static uint32_t ble_new_event_handler(void) { BaseType_t yield_req = pdFALSE; UNUSED_VARIABLE(xSemaphoreGiveFromISR(m_ble_event_ready, &yield_req)); portYIELD_FROM_ISR(yield_req); return NRF_SUCCESS; }

  1. Semaphore I relready created.
m_ble_event_ready = xSemaphoreCreateBinary();
if (NULL == m_ble_event_ready)
{
    APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
}
  1. Task
while (1)
{
    /* Wait for event from SoftDevice */
    while (pdFALSE == xSemaphoreTake(m_ble_event_ready, portMAX_DELAY))
    {
        // Just wait again in the case when INCLUDE_vTaskSuspend is not enabled
    }
    // This function gets events from the SoftDevice and processes them by calling the function
    // registered by softdevice_ble_evt_handler_set during stack initialization.
    // In this code ble_evt_dispatch would be called for every event found.
        rbc_mesh_event_handler(&evt);
        rbc_mesh_event_release(&evt);	
}

The problem is when I use lightblue to connect ble device, TIME OUT!

which part do I lost? I need your help.

Related