/* * SPDX-License-Identifier: Apache-2.0 */ #include "esp_log.h" #include "nvs_flash.h" #include "sdkconfig.h" #include "ddp.h" #include "espnow_link.h" #include "net.h" #include "ota.h" #include "patterns.h" #include "presets.h" #include "usb_cfg.h" #include "web.h" static const char *TAG = "example"; extern "C" void app_main(void) { // NVS holds the saved Wi-Fi client credentials esp_err_t err = nvs_flash_init(); if (err == ESP_ERR_NVS_NO_FREE_PAGES || err == ESP_ERR_NVS_NEW_VERSION_FOUND) { ESP_ERROR_CHECK(nvs_flash_erase()); err = nvs_flash_init(); } ESP_ERROR_CHECK(err); hw_cfg_t hw; settings_load_hw(&hw); patterns_start(hw); ESP_ERROR_CHECK(presets_init()); presets_apply_startup(); ESP_ERROR_CHECK(net_start()); espnow_link_start(); // ESP-NOW from led-controller (always, in the bare build) #if CONFIG_LED_ESPNOW_ONLY // Bare ESP-NOW driver: nothing else runs, and nothing else is linked in (no calls to it). The settings // come from the controller over ESP-NOW. ota_confirm_later(); // a freshly flashed image is marked good (app rollback is on) ESP_LOGI(TAG, "Ready: bare ESP-NOW driver (settings from the controller over ESP-NOW)"); #else usb_cfg_start(); // led-tool over USB; the LEDs and Wi-Fi work without it // ESP-NOW only (access point off, Wi-Fi client off): nothing reaches the driver over IP, so no web // interface or DDP. Turning the access point on starts the web interface (net.cpp). if (!net_espnow_only()) { ESP_ERROR_CHECK(web_start()); ESP_ERROR_CHECK(ddp_start()); } ota_confirm_later(); if (net_espnow_only()) { ESP_LOGI(TAG, "Ready: ESP-NOW only (set up over USB with led-cli)"); return; } char ssid[16]; net_ap_ssid(ssid, sizeof(ssid)); ESP_LOGI(TAG, "Ready: join Wi-Fi %s and open http://192.168.4.1/, or http://led.local/ on your network", ssid); #endif }