--- a/main/task_ble.c Mon Apr 17 16:20:58 2023 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,82 +0,0 @@ -/** - * @file task_ble.c - * @brief BLE task. Secure GATT server. - */ - -#include "config.h" - - -static const char *TAG = "task_ble"; - - - -void task_ble( void * pvParameters ) -{ - esp_err_t ret; - - ESP_LOGI(TAG, "Starting BLE task"); - - /* - * Initialize Bluetooth - */ - ESP_ERROR_CHECK(esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT)); - - esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT(); - ret = esp_bt_controller_init(&bt_cfg); - if (ret) { - ESP_LOGE(TAG, "init controller failed: %s", esp_err_to_name(ret)); - goto deadend; - } - - ret = esp_bt_controller_enable(ESP_BT_MODE_BLE); - if (ret) { - ESP_LOGE(TAG, "enable controller failed: %s", esp_err_to_name(ret)); - goto deadend; - } - - ESP_LOGI(TAG, "init bluetooth"); - ret = esp_bluedroid_init(); - if (ret) { - ESP_LOGE(TAG, "init bluetooth failed: %s", esp_err_to_name(ret)); - goto deadend; - } - - ret = esp_bluedroid_enable(); - if (ret) { - ESP_LOGE(TAG, "enable bluetooth failed: %s", esp_err_to_name(ret)); - goto deadend; - } - - ret = ble_balkon_gatts_register(); - if (ret) - goto deadend; - - ble_balkon_gap_register(); - - ret = ble_balkon_gatts_app_register(); - if (ret) - goto deadend; - - ret = ble_balkon_gatts_set_mtu(); - if (ret) - goto deadend; - - ESP_LOGI(TAG, "Start BLE done, enter loop"); - - for(;;) { - - - vTaskDelay(20 / portTICK_PERIOD_MS); - } /* for(;;) */ - - - /* - * Error point for init errors. - */ -deadend: - ESP_LOGI(TAG, "Startup error loop"); - for(;;) { - vTaskDelay(50 / portTICK_PERIOD_MS); - } -} -