How to feed task watchdog from asynchronous code such as a BLE task?
Posted: Tue Sep 19, 2017 8:05 am
So I have a BLE task and the task contains a gatt server and advertisement data. Is there a way to feed the task watchdog. I have read the notes on the watchdogs but I can't find a way for my BleTask to be watched especially since BLE operations are very asynchronous.
Here is my trial at it.
Here is my trial at it.
Code: Select all
void BleTask(void *pvParameters)
{
esp_err_t nvs_state, bt_init_fail;
/* Initialise NVS*/
nvs_state = nvs_flash_init();
if (nvs_state == ESP_ERR_NVS_NO_FREE_PAGES)
{
ESP_ERROR_CHECK(nvs_flash_erase());
nvs_state = nvs_flash_init();
}
ESP_ERROR_CHECK(nvs_state);
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
bt_init_fail = esp_bt_controller_init(&bt_cfg);
if (bt_init_fail)
{
ESP_LOGE(BLE_TASK_TAG, "function:\"%s\" BLUETOOTH CONTROLLER INIT FAILED\n", __func__);
vTaskDelete(xBleTaskHandle);
}
bt_init_fail = esp_bt_controller_enable(ESP_BT_MODE_BTDM);
if (bt_init_fail)
{
ESP_LOGE(BLE_TASK_TAG, "function:\"%s\" BLUETOOTH CONTROLLER ENABLE FAILED\n", __func__);
vTaskDelete(xBleTaskHandle);
}
ESP_LOGI(BLE_TASK_TAG, "function:\"%s\" INITIALISED BLUETOOTH CONTROLLER\n", __func__);
bt_init_fail = esp_bluedroid_init();
if (bt_init_fail)
{
ESP_LOGE(BLE_TASK_TAG, "function:\"%s\" BLUEDROID STACK INIT FAILED\n", __func__);
vTaskDelete(xBleTaskHandle);
}
bt_init_fail = esp_bluedroid_enable();
if (bt_init_fail)
{
ESP_LOGE(BLE_TASK_TAG, "function:\"%s\" BLUEDROID STACK ENABLE FAILED\n", __func__);
vTaskDelete(xBleTaskHandle);
}
Ble_task_parameters* ble_param = NULL;
ble_param = (Ble_task_parameters*)pvParameters;
esp_ble_gatts_register_callback(gatts_event_handler);
esp_ble_gap_register_callback(gap_event_handler);
esp_ble_gatts_app_register(SYSTEM_APP_ID);
for(;;)
{
esp_task_wdt_feed();
}
}