示例#1
0
/**
 * This function is called in interrupt context to handle BLE events; i.e. pull
 * system and user events out of the pending events-queue of the BLE stack. The
 * BLE stack signals the availability of events by the triggering the SWI2
 * interrupt, which forwards the handling to this function.
 *
 * The event processing loop is implemented in intern_softdevice_events_execute().
 *
 * In mbed OS, a callback for intern_softdevice_events_execute() is posted
 * to the scheduler, which then executes in thread mode. In mbed-classic,
 * event processing happens right-away in interrupt context (which is more
 * risk-prone). In either case, the logic of event processing is identical.
 */
static uint32_t eventHandler()
{
#ifdef YOTTA_CFG_MBED_OS
    minar::Scheduler::postCallback(intern_softdevice_events_execute);
#else
    intern_softdevice_events_execute();
#endif

    return NRF_SUCCESS;
}
示例#2
0
/**@brief   Function for handling the Application's BLE Stack events interrupt.
 *
 * @details This function is called whenever an event is ready to be pulled.
 */
void SWI2_IRQHandler(void)
{
    if (m_evt_schedule_func != NULL)
    {
        uint32_t err_code = m_evt_schedule_func();
        APP_ERROR_CHECK(err_code);
    }
    else
    {
        intern_softdevice_events_execute();
    }
}
示例#3
0
void nRF5xn::processEvents() {
    core_util_critical_section_enter();
    while (isEventsSignaled) {
        isEventsSignaled = false;
        core_util_critical_section_exit();
        #if NRF_SD_BLE_API_VERSION >= 5
        // We use the "polling" dispatch model
        // http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v14.2.0/group__nrf__sdh.html?cp=4_0_0_6_11_60_20#gab4d7be69304d4f5feefd1d440cc3e6c7
        // This will process any pending events from the Softdevice
        nrf_sdh_evts_poll();
        #else
        intern_softdevice_events_execute();
        #endif

        core_util_critical_section_enter();
    }
    core_util_critical_section_exit();
}
示例#4
0
文件: main.c 项目: IOIOI/nRF51
/**@brief Thread for handling the Application's BLE Stack events.
 *
 * @details This thread is responsible for handling BLE Stack events sent from on_ble_evt().
 *
 * @param[in]   arg   Pointer used for passing some arbitrary information (context) from the
 *                    osThreadCreate() call to the thread.
 */
static void ble_stack_thread(void * arg)
{
    uint32_t  err_code;
    bool      erase_bonds;

    UNUSED_PARAMETER(arg);

    // Initialize.
    timers_init();
    buttons_leds_init(&erase_bonds);
    ble_stack_init();
    device_manager_init(erase_bonds);
    gap_params_init();
    advertising_init();
    services_init();
    sensor_simulator_init();
    conn_params_init();

    application_timers_start();
    err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
    APP_ERROR_CHECK(err_code);

    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.
        intern_softdevice_events_execute();
    }
}
void softdevice_evt_get(void * p_event_data, uint16_t event_size)
{
    APP_ERROR_CHECK_BOOL(event_size == 0);
    intern_softdevice_events_execute();
}
示例#6
0
void nRF5xn::processEvents() {
    if (isEventsSignaled) {
        isEventsSignaled = false;
        intern_softdevice_events_execute();
    }
}