Loading files
This file is pinned to the selected release. Download the original to open it in your design tool.
4e8d38ea1This file is pinned to the selected release. Download the original to open it in your design tool.
#include "TelemetryManager.h"
#include "Stream/Printer.hpp"
namespace Espfc {
TelemetryManager::TelemetryManager(Model& model): _model(model), _msp(model), _text(model), _crsf(model) {}
int TelemetryManager::process(Stream::ReadWritable& s, TelemetryProtocol protocol) const
{
Utils::Stats::Measure measure(_model.state.stats, COUNTER_TELEMETRY);
switch (protocol)
{
case TELEMETRY_PROTOCOL_TEXT: {
Stream::Printer printer(s);
_text.process(printer);
break;
}
case TELEMETRY_PROTOCOL_CRSF:
_crsf.process(s);
break;
}
return 1;
}
int TelemetryManager::processMsp(Stream::ReadWritable& s, TelemetryProtocol protocol, Connect::MspMessage m,
uint8_t origin)
{
Connect::MspResponse r;
// not valid msp message, stop processing
if (!m.isReady() || !m.isCmd()) return 0;
_msp.processCommand(m, r, s);
switch (protocol)
{
case TELEMETRY_PROTOCOL_CRSF:
_crsf.sendMsp(s, r, origin);
break;
default:
break;
}
_msp.postCommand();
return 1;
}
} // namespace Espfc