Files
Bachelorarbeit-Rover/src/OutputBuf/outputBuf.cpp
T
kleiax db74898b72 documentation checked and edit
for all files in lib folder
2023-10-12 18:45:12 +02:00

77 lines
1.6 KiB
C++

/**
* @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<bool>(debugMqtt))
{
this->isMqttActive = true;
}
if (static_cast<bool>(serialBT))
{
this->isMqttActive = true;
}
}
void OutputBuf::activateMqtt(bool status)
{
if (static_cast<bool>(debugMqtt))
{
this->isMqttActive = status;
}
}
void OutputBuf::activateSerialBT(bool status)
{
if (static_cast<bool>(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<char>(c), getloc());
if (this->debugMqtt && this->isMqttActive)
{
this->debugMqtt->addCharacter(static_cast<char>(character));
}
if (this->serialBT && this->isSerialBTActive && this->serialBT->connected())
{
this->serialBT->print(static_cast<char>(character));
}
Serial.print(static_cast<char>(character));
}
return character;
}