Added Telemetry data report to the App
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "Player.hpp"
|
||||
#include "../Communication/CommunicationRouter/CommunicationRouter.hpp"
|
||||
#include "../BellEngine/BellEngine.hpp"
|
||||
#include "../Telemetry/Telemetry.hpp"
|
||||
|
||||
// Note: Removed global melody_steps dependency for cleaner architecture
|
||||
|
||||
@@ -28,6 +29,7 @@ Player::Player(CommunicationRouter* comm, FileManager* fm)
|
||||
, _commManager(comm)
|
||||
, _fileManager(fm)
|
||||
, _bellEngine(nullptr)
|
||||
, _telemetry(nullptr)
|
||||
, _durationTimerHandle(NULL) {
|
||||
}
|
||||
|
||||
@@ -55,6 +57,7 @@ Player::Player()
|
||||
, _commManager(nullptr)
|
||||
, _fileManager(nullptr)
|
||||
, _bellEngine(nullptr)
|
||||
, _telemetry(nullptr)
|
||||
, _durationTimerHandle(NULL) {
|
||||
}
|
||||
|
||||
@@ -123,6 +126,12 @@ void Player::forceStop() {
|
||||
hardStop = true;
|
||||
isPlaying = false;
|
||||
setStatus(PlayerStatus::STOPPED); // Immediate stop, notify clients
|
||||
|
||||
// Save strike counters after melody stops
|
||||
if (_telemetry) {
|
||||
_telemetry->saveStrikeCounters();
|
||||
}
|
||||
|
||||
LOG_DEBUG("Plbck: FORCE STOP");
|
||||
}
|
||||
|
||||
@@ -137,6 +146,12 @@ void Player::stop() {
|
||||
// Set STOPPING status - actual stop message will be sent when BellEngine finishes
|
||||
if (isPaused) {
|
||||
setStatus(PlayerStatus::STOPPED);
|
||||
|
||||
// Save strike counters after melody stops
|
||||
if (_telemetry) {
|
||||
_telemetry->saveStrikeCounters();
|
||||
}
|
||||
|
||||
LOG_DEBUG("Plbck: STOP from PAUSED state");
|
||||
} else {
|
||||
setStatus(PlayerStatus::STOPPING);
|
||||
@@ -361,7 +376,7 @@ void Player::onMelodyLoopCompleted() {
|
||||
// This is called by BellEngine when a melody loop actually finishes
|
||||
if (_status == PlayerStatus::STOPPING) {
|
||||
// We were in soft stop mode, now actually stop
|
||||
setStatus(PlayerStatus::STOPPED);
|
||||
setStatus(PlayerStatus::STOPPED);
|
||||
LOG_DEBUG("Plbck: ACTUAL STOP (melody loop completed)");
|
||||
}
|
||||
|
||||
|
||||
@@ -63,6 +63,7 @@
|
||||
// ═════════════════════════════════════════════════════════════════════════════════
|
||||
class CommunicationRouter; // Command handling and communication
|
||||
class BellEngine; // High-precision timing engine
|
||||
class Telemetry; // System telemetry and monitoring
|
||||
|
||||
// ═════════════════════════════════════════════════════════════════════════════════
|
||||
// PLAYER STATUS ENUMERATION
|
||||
@@ -126,6 +127,12 @@ public:
|
||||
*/
|
||||
void setBellEngine(BellEngine* engine) { _bellEngine = engine; }
|
||||
|
||||
/**
|
||||
* @brief Set Telemetry reference for strike counter persistence
|
||||
* @param telemetry Pointer to Telemetry instance
|
||||
*/
|
||||
void setTelemetry(Telemetry* telemetry) { _telemetry = telemetry; }
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════════════════
|
||||
// MELODY METADATA - Public access for compatibility
|
||||
// ═══════════════════════════════════════════════════════════════════════════════
|
||||
@@ -241,6 +248,7 @@ private:
|
||||
CommunicationRouter* _commManager; // 📡 Communication system reference
|
||||
FileManager* _fileManager; // 📁 File operations reference
|
||||
BellEngine* _bellEngine; // 🔥 High-precision timing engine reference
|
||||
Telemetry* _telemetry; // 📄 Telemetry system reference
|
||||
|
||||
std::vector<uint16_t> _melodySteps; // 🎵 Melody data owned by Player
|
||||
TimerHandle_t _durationTimerHandle = NULL; // ⏱️ FreeRTOS timer (saves 4KB vs task!)
|
||||
|
||||
Reference in New Issue
Block a user