added bluetooth console

This commit is contained in:
2022-03-03 15:13:48 +01:00
parent 552c98c71a
commit e127009601
4 changed files with 76 additions and 33 deletions
+59
View File
@@ -0,0 +1,59 @@
/**
* @file outputBufMqtt.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)
: std::streambuf() {
this->debugMqtt = debugMqtt;
this->serialBT = serialBT;
if (debugMqtt)
this->isMqttActive = true;
if (serialBT)
this->isMqttActive = true;
}
void OutputBuf::activateMqtt(bool status) {
if (debugMqtt)
this->isMqttActive = status;
}
void OutputBuf::activateSerialBT(bool status) {
if (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 c) {
if (c != EOF) {
// c = std::toupper(static_cast<char>(c), getloc());
if (this->debugMqtt && this->isMqttActive)
this->debugMqtt->addCharacter((char) c);
if (this->serialBT && this->isSerialBTActive && this->serialBT->connected())
this->serialBT->print((char) c);
Serial.print((char) c);
}
return c;
}