mirror of
https://github.com/sweidac/kidsbox.git
synced 2026-10-27 22:52:57 +01:00
- Replace Arduino WiFi.h in Networking.cpp with native esp_wifi/esp_netif; uses event-driven connect with FreeRTOS EventGroup and 30 s timeout - Remove initArduino() / Arduino.h from main.cpp - Remove deprecated arduino-esp32 submodule (was uninitialized and marked deprecated since it was first added in Dec 2021) - rc522.h: guard VSPI_HOST → SPI3_HOST for ESP-IDF 5.x compatibility - WebInterface.cpp: drop redundant esp_wifi.h (esp_netif.h is sufficient) - CMakeLists.txt: add esp_wifi + nvs_flash to REQUIRES https://claude.ai/code/session_01MhAnh68DPNnTjcKqjNYDmk
54 lines
1.6 KiB
C++
54 lines
1.6 KiB
C++
#include "Networking.hpp"
|
|
#include "WebInterface.hpp"
|
|
#include "RFIDInterface.hpp"
|
|
#include "AudioPlayer.hpp"
|
|
#include "TagPlayerControl.hpp"
|
|
#include "CacheManager.hpp"
|
|
#include "BluetoothInterface.hpp"
|
|
|
|
#include <memory>
|
|
|
|
extern "C" {
|
|
void app_main();
|
|
}
|
|
|
|
Networking networking;
|
|
WebInterface webInterface;
|
|
RFIDInterface rfid;
|
|
BluetoothInterface bluetooth;
|
|
|
|
/* Shared objects — must be heap-allocated after app_main() starts the scheduler */
|
|
std::shared_ptr<AudioPlayer> audioPlayer;
|
|
std::shared_ptr<CacheManager> cacheManager;
|
|
std::shared_ptr<TagPlayerControl> tagPlayerControl;
|
|
|
|
void app_main(void) {
|
|
/* SD card must be mounted first — other components depend on it */
|
|
webInterface.initSD();
|
|
|
|
/* Network — non-blocking with 30 s timeout */
|
|
networking.connectWifi();
|
|
|
|
/* Audio pipeline — must run after scheduler is up */
|
|
audioPlayer = std::make_shared<AudioPlayer>();
|
|
cacheManager = std::make_shared<CacheManager>();
|
|
|
|
/* Wire web interface to audio/cache for API endpoints */
|
|
webInterface.setAudioPlayer(audioPlayer);
|
|
webInterface.setCacheManager(cacheManager);
|
|
|
|
/* Start HTTP server and register API + static-file handlers */
|
|
webInterface.start();
|
|
rfid.registerWebResources(&webInterface);
|
|
webInterface.finishResourceRegistrations();
|
|
|
|
tagPlayerControl = std::make_shared<TagPlayerControl>(audioPlayer, cacheManager);
|
|
|
|
/* RFID must start after the audio player (hardware init order constraint) */
|
|
rfid.start();
|
|
|
|
rfid.registerTagCallback([](const char* uid, const char* url) {
|
|
tagPlayerControl->onTagChanged(uid, url);
|
|
});
|
|
}
|