openthread / ot-esp32

BSD 3-Clause "New" or "Revised" License
56 stars 10 forks source link

[api] add API to break the mainloop #15

Closed wgtdkp closed 4 years ago

wgtdkp commented 4 years ago

This PR adds a new API otSysMainloopBreak to break otSysMainloopPoll.

An example usage:

static void break_select(void *aContext)
{
    while (true)
    {
        usleep(100 * 1000);
        ESP_LOGI(CLI_LOG_TAG, "breaking the OpenThread event loop");
        otSysMainloopBreak();
    }
}

void app_main()
{
    xTaskCreate(break_select, "break_select", 5 * 1024, NULL, 4, NULL);
    xTaskCreate(run_cli, "cli", 10 * 1024, NULL, 5, NULL);
}