added bluetooth console
This commit is contained in:
@@ -1,30 +0,0 @@
|
|||||||
/**
|
|
||||||
* @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 "outputBufMqtt.h"
|
|
||||||
|
|
||||||
OutputBufMqtt::OutputBufMqtt(DebugMqtt* debugMqtt)
|
|
||||||
: std::streambuf() {
|
|
||||||
this->debugMqtt = debugMqtt;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::streambuf::int_type OutputBufMqtt::overflow(std::streambuf::int_type c) {
|
|
||||||
if (c != EOF) {
|
|
||||||
// c = std::toupper(static_cast<char>(c), getloc());
|
|
||||||
|
|
||||||
this->debugMqtt->addCharacter((char) c);
|
|
||||||
Serial.print((char) c);
|
|
||||||
// if (putchar(c) == EOF) {
|
|
||||||
// return EOF;
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
@@ -14,7 +14,9 @@ board = esp32doit-devkit-v1
|
|||||||
board_build.partitions = no_ota.csv
|
board_build.partitions = no_ota.csv
|
||||||
framework = arduino
|
framework = arduino
|
||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
|
upload_speed = 921600
|
||||||
monitor_port = COM3
|
monitor_port = COM3
|
||||||
|
;build_flags = -DCORE_DEBUG_LEVEL=5
|
||||||
lib_deps =
|
lib_deps =
|
||||||
madhephaestus/ESP32Encoder@^0.4.0
|
madhephaestus/ESP32Encoder@^0.4.0
|
||||||
jvpernis/PS3 Controller Host@^1.1.0
|
jvpernis/PS3 Controller Host@^1.1.0
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
@@ -23,6 +23,8 @@
|
|||||||
|
|
||||||
#include "debugMqtt.h"
|
#include "debugMqtt.h"
|
||||||
|
|
||||||
|
#include <BluetoothSerial.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief A alternativ streambuf for std::cout
|
* @brief A alternativ streambuf for std::cout
|
||||||
*
|
*
|
||||||
@@ -30,14 +32,20 @@
|
|||||||
* and MQTT.
|
* and MQTT.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class OutputBufMqtt : public std::streambuf {
|
class OutputBuf : public std::streambuf {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Construct a new Output Buf Mqtt object
|
* @brief Construct a new Output Buf Mqtt object
|
||||||
*
|
*
|
||||||
* @param debugMqtt
|
* @param debugMqtt
|
||||||
*/
|
*/
|
||||||
OutputBufMqtt(DebugMqtt* debugMqtt);
|
OutputBuf(DebugMqtt* debugMqtt = nullptr, BluetoothSerial* serialBT = nullptr);
|
||||||
|
void activateMqtt(bool status);
|
||||||
|
void activateSerialBT(bool status);
|
||||||
|
|
||||||
|
void setDebugMqtt(DebugMqtt* debugMqtt);
|
||||||
|
void setSerialBT(BluetoothSerial* serialBT);
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
@@ -48,8 +56,12 @@ class OutputBufMqtt : public std::streambuf {
|
|||||||
*/
|
*/
|
||||||
virtual std::streambuf::int_type overflow(std::streambuf::int_type c);
|
virtual std::streambuf::int_type overflow(std::streambuf::int_type c);
|
||||||
|
|
||||||
public:
|
private:
|
||||||
|
bool isMqttActive = false;
|
||||||
|
bool isSerialBTActive = false;
|
||||||
|
|
||||||
DebugMqtt* debugMqtt;
|
DebugMqtt* debugMqtt;
|
||||||
|
BluetoothSerial* serialBT;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // OUTPUT_STREAM_MQTT_H
|
#endif // OUTPUT_STREAM_MQTT_H
|
||||||
Reference in New Issue
Block a user