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

sys_evt_dispatch What is?

Hi all,

I have understood that sys_evt_dispatch is used for all events that aren't BLE but concern the softdevice.

I start to develop my code on gls_example, here in sys_evt_dispatch there are two function

static void sys_evt_dispatch(uint32_t sys_evt)
{
    fs_sys_event_handler(sys_evt);
    ble_advertising_on_sys_evt(sys_evt);
}

Someone can explain me what does this function do? Can i don't use it? ( I need on my application have a pairing and bonding).

void fs_sys_event_handler(uint32_t sys_evt)
{
    fs_op_t * const p_op = &m_queue.op[m_queue.rp];
    
    if (m_flags & FS_FLAG_PROCESSING)
    {
        // A flash operation was initiated by this module. Handle the result.
        switch (sys_evt)
        {
            case NRF_EVT_FLASH_OPERATION_SUCCESS:
                on_operation_success(p_op);
                break;

            case NRF_EVT_FLASH_OPERATION_ERROR:
                on_operation_failure(p_op);
                break;
        }
    }
    else if ((m_flags & FS_FLAG_FLASH_REQ_PENDING))
    {
        // A flash operation was initiated outside this module.
        // A callback which indicates that it has finished was received.
        m_flags &= ~FS_FLAG_FLASH_REQ_PENDING;

        // If there are any elements left in the queue, set FS_FLAG_PROCESSING.
        if (m_queue.count > 0)
        {
           m_flags |= FS_FLAG_PROCESSING;
        }
    }

    // Resume processing the queue, if necessary.
    queue_process();
}




void ble_advertising_on_sys_evt(uint32_t sys_evt)
{
    uint32_t err_code = NRF_SUCCESS;
    switch (sys_evt)
    {

        case NRF_EVT_FLASH_OPERATION_SUCCESS:
        // Fall through.

        //When a flash operation finishes, advertising no longer needs to be pending.
        case NRF_EVT_FLASH_OPERATION_ERROR:
            if (m_advertising_start_pending)
            {
                m_advertising_start_pending = false;
                err_code = ble_advertising_start(m_adv_mode_current);
                if ((err_code != NRF_SUCCESS) && (m_error_handler != NULL))
                {
                    m_error_handler(err_code);
                }
            }
            break;

        default:
            // No implementation needed.
            break;
    }
}

I have seen that if i comment them have some problems, so i would understand better what this function do.

Thanks, Anna

Parents
  • The fs_sys_event_handler() is needed because the peer manager uses flash storage (the fs stands for flash storage). If the peer manager writes to flash, this handler will notify the peer manager that the write is finished.

    Advertising doesn't start until all flash events have finished. The ble_advertising_on_sys_evt function tells the advertising module when all flash events are finished, so it can start advertising.

Reply
  • The fs_sys_event_handler() is needed because the peer manager uses flash storage (the fs stands for flash storage). If the peer manager writes to flash, this handler will notify the peer manager that the write is finished.

    Advertising doesn't start until all flash events have finished. The ble_advertising_on_sys_evt function tells the advertising module when all flash events are finished, so it can start advertising.

Children
Related