/** * @file outputBuf.cpp * @author Alexander Klein (alex@kleiax.de) * @brief Contains the implementation of the class OutputBufMqtt * @version 0.1 * @date 2022-02-14 * * @copyright Copyright (c) 2022 * */ #include "OutputBuf/outputBuf.h" OutputBuf::OutputBuf(DebugMqtt *debugMqtt, BluetoothSerial *serialBT) : debugMqtt{debugMqtt}, serialBT{serialBT} { if (static_cast(debugMqtt)) { this->isMqttActive = true; } if (static_cast(serialBT)) { this->isMqttActive = true; } } void OutputBuf::activateMqtt(bool status) { if (static_cast(debugMqtt)) { this->isMqttActive = status; } } void OutputBuf::activateSerialBT(bool status) { if (static_cast(serialBT)) { this->isSerialBTActive = status; } } void OutputBuf::setDebugMqtt(DebugMqtt *debugMqtt) { this->debugMqtt = debugMqtt; this->isMqttActive = true; } void OutputBuf::setSerialBT(BluetoothSerial *serialBT) { this->serialBT = serialBT; this->isSerialBTActive = true; ; } std::streambuf::int_type OutputBuf::overflow(std::streambuf::int_type character) { if (character != EOF) { // c = std::toupper(static_cast(c), getloc()); if (this->debugMqtt && this->isMqttActive) { this->debugMqtt->addCharacter(static_cast(character)); } if (this->serialBT && this->isSerialBTActive && this->serialBT->connected()) { this->serialBT->print(static_cast(character)); } Serial.print(static_cast(character)); } return character; }