52 lines
1.7 KiB
C
52 lines
1.7 KiB
C
#include <stdio.h>
|
|
#include "freertos/FreeRTOS.h"
|
|
#include "freertos/task.h"
|
|
#include "esp_log.h"
|
|
#include "storage_manager.h"
|
|
#include "rfid_manager.h"
|
|
#include "display_manager.h"
|
|
#include "ui_task.h"
|
|
#include "wifi_manager.h"
|
|
#include "scryfall_client.h"
|
|
#include "web_server.h"
|
|
|
|
static const char *TAG = "MAIN";
|
|
|
|
void app_main(void)
|
|
{
|
|
ESP_LOGI(TAG, "MTG RFID Companion booting...");
|
|
|
|
ESP_ERROR_CHECK(storage_manager_init());
|
|
|
|
/* RFID comes BEFORE the display: the reader lives on its own SPI3 bus
|
|
* (display owns SPI2), but initializing it before the panel's init traffic
|
|
* gives the startup the quietest possible bus timing. */
|
|
esp_err_t ret = rfid_manager_init();
|
|
if (ret != ESP_OK || rfid_manager_start() != ESP_OK) {
|
|
ESP_LOGW(TAG, "RFID unavailable (%s) - continuing without card scanning", esp_err_to_name(ret));
|
|
}
|
|
|
|
ESP_ERROR_CHECK(display_manager_init());
|
|
|
|
/* Networking is not fatal either: without it the device runs offline
|
|
* (cached cards + AP pairing). Init failures are logged, boot continues. */
|
|
ret = wifi_manager_init();
|
|
if (ret != ESP_OK) {
|
|
ESP_LOGW(TAG, "wifi init failed (%s) - continuing offline", esp_err_to_name(ret));
|
|
} else {
|
|
if (wifi_manager_start() != ESP_OK) {
|
|
ESP_LOGW(TAG, "wifi start failed - continuing offline");
|
|
}
|
|
if (scryfall_client_start() != ESP_OK) {
|
|
ESP_LOGW(TAG, "scryfall client start failed");
|
|
}
|
|
}
|
|
if (web_server_start() != ESP_OK) {
|
|
ESP_LOGW(TAG, "web server start failed - continuing without AP");
|
|
}
|
|
|
|
ESP_ERROR_CHECK(ui_task_start());
|
|
|
|
ESP_LOGI(TAG, "Boot sequence complete. Main task exiting to reclaim stack.");
|
|
vTaskDelete(NULL);
|
|
} |