first commit
This commit is contained in:
53
main/main.c
Executable file
53
main/main.c
Executable file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||
*/
|
||||
/* Includes */
|
||||
#include "ble_client.h"
|
||||
#include "common.h"
|
||||
#include "uart_bridge.h"
|
||||
|
||||
/* Private function declarations */
|
||||
static void nimble_host_task(void *param);
|
||||
|
||||
/* Private functions */
|
||||
static void nimble_host_task(void *param) {
|
||||
ESP_LOGI(TAG, "nimble host task started");
|
||||
|
||||
/* This function won't return until nimble_port_stop() is executed */
|
||||
nimble_port_run();
|
||||
|
||||
/* Clean up at exit */
|
||||
vTaskDelete(NULL);
|
||||
}
|
||||
|
||||
void app_main(void) {
|
||||
esp_err_t ret;
|
||||
|
||||
/* NVS flash initialization (required by BLE stack) */
|
||||
ret = nvs_flash_init();
|
||||
if (ret == ESP_ERR_NVS_NO_FREE_PAGES ||
|
||||
ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
|
||||
ESP_ERROR_CHECK(nvs_flash_erase());
|
||||
ret = nvs_flash_init();
|
||||
}
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(TAG, "failed to initialize nvs flash, error code: %d", ret);
|
||||
return;
|
||||
}
|
||||
|
||||
/* NimBLE stack initialization */
|
||||
ret = nimble_port_init();
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(TAG, "failed to initialize nimble stack, error code: %d",
|
||||
ret);
|
||||
return;
|
||||
}
|
||||
|
||||
uart_bridge_init();
|
||||
ble_client_init();
|
||||
|
||||
/* Start NimBLE host task thread and return */
|
||||
xTaskCreate(nimble_host_task, "NimBLE Host", 4 * 1024, NULL, 5, NULL);
|
||||
}
|
||||
Reference in New Issue
Block a user