#include "Arduino.h" #include "Networking.hpp" #include "WebInterface.hpp" #include "RFIDInterface.hpp" #include "AudioPlayer.hpp" #include "TagPlayerControl.hpp" #include "CacheManager.hpp" #include "BluetoothInterface.hpp" #include 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; std::shared_ptr cacheManager; std::shared_ptr tagPlayerControl; void app_main(void) { initArduino(); /* 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(); cacheManager = std::make_shared(); /* 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(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); }); }