mirror of
https://github.com/sweidac/kidsbox.git
synced 2026-10-28 06:52:57 +01:00
- rc522: add NDEF URL reading via WUPA+cascade anticoll+SELECT+TLV parse
- AudioPlayer: route http:// URIs to esp_player_http_music_play()
- CacheManager: download URLs async to /sdcard/cache/{hash}.{ext}
- TagPlayerControl: NDEF URL → cache-or-stream; fallback to UID local mapping
- RFIDInterface: wire ndef_callback, expose combined uid+url callback
- WebInterface: add /api/info, /api/storage, /api/playback, /api/bluetooth
- BluetoothInterface: stub for A2DP speaker mode
- Networking: WiFi connect with 30s timeout instead of blocking forever
- main.cpp: re-enable WiFi + web server, fix init order, add CacheManager
- www/: full SPA — playback controls, device info, storage, BT pairing
- .gitmodules: switch rc522 submodule URL to HTTPS
https://claude.ai/code/session_01MhAnh68DPNnTjcKqjNYDmk
58 lines
1.6 KiB
C++
58 lines
1.6 KiB
C++
#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 <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) {
|
|
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<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);
|
|
});
|
|
}
|