Finish documention until someone change something

This commit is contained in:
2022-02-15 20:12:50 +01:00
parent 3a2e51713b
commit c8e3344b27
50 changed files with 991 additions and 223 deletions
+5 -3
View File
@@ -18,9 +18,11 @@ char DebugMqtt::msg[MQTT_BUFFER_SIZE];
char DebugMqtt::topic[MQTT_BUFFER_SIZE];
DebugMqtt::DebugMqtt(const char* name) {
DebugMqtt::DebugMqtt(const char* name, uint8_t bufSize) {
this->name = name;
this->buf = new char[this->bufSitze];
if (bufSize != 0)
this->bufSize = bufSize;
this->buf = new char[this->bufSize];
}
DebugMqtt::~DebugMqtt() {
@@ -62,7 +64,7 @@ void DebugMqtt::writeToInflux(String measurement_name, String field_set, float m
void DebugMqtt::addCharacter(char c) {
this->buf[this->bufPos] = c;
this->bufPos++;
if (c == '\n' || this->bufPos >= this->bufSitze - 1) {
if (c == '\n' || this->bufPos >= this->bufSize - 1) {
this->buf[this->bufPos - 1] = '\0';
this->sendMsg(Loglevel::info, buf);
this->bufPos = 0;
+19 -9
View File
@@ -69,15 +69,16 @@ class DebugMqtt {
* @brief Construct a new Debug Mqtt object.
*
* @param name A String with send with every Message.
* @param bufSize for the addCharacter function.
*/
DebugMqtt(const char* name);
DebugMqtt(const char* name, uint8_t bufSize = 0);
~DebugMqtt();
/**
* @brief Send a Message via MQTT
*
* This funtion uses sendData to send the given string and
* This function uses sendData to send the given string and
* add the name to the message given by the constructer.
*
* @see sendData()
@@ -93,9 +94,9 @@ class DebugMqtt {
/**
* @brief Send a Message via MQTT
*
* This funtion sends the Data via MQTT with the given topic
* This function sends the Data via MQTT with the given topic
* from Loglevel or followed by given String topic.
* Normaly this function is called by sendMsg() or by
* Normally this function is called by sendMsg() or by
* writeToInflux()
*
* @see sendData()
@@ -112,7 +113,7 @@ class DebugMqtt {
/**
* @brief Send a Message via MQTT for InfluxDB
*
* This funtion sends a MQTT message which is intended for
* This function sends a MQTT message which is intended for
* Telegraf. Telegraf can listen on MQTT messages and put
* them in an Influx Database.
*
@@ -123,14 +124,23 @@ class DebugMqtt {
*/
void writeToInflux(String measurement_name, String field_set, float measurement, uint64_t nanos);
/**
* @brief Adds a single character to the buf
*
* The buf will be flushed out:
* 1. when the buffer is full
* 2. when the character is '\n'
*
* @param c
*/
void addCharacter(char c);
/**
* @brief Initalize debugMQTT for all instances
* @brief Initialize debugMQTT for all instances
*
* You only have to call this function once for your project.
* If you call this funtion again you overwrite the client and
* the loglevel. If you only eant du overwrite the max_loglevel
* If you call this function again you overwrite the client and
* the loglevel. If you only want du overwrite the max_loglevel
* use changeLoglevel()
*
* @see changeLoglevel()
@@ -153,7 +163,7 @@ class DebugMqtt {
const char* name;
char* buf;
uint8_t bufPos = 0;
uint8_t bufSitze = 100;
uint8_t bufSize = 100;
static String enum_to_string(Loglevel loglevel);
+2 -2
View File
@@ -1,7 +1,7 @@
/**
* @file outputStreamMqtt.cpp
* @file outputBufMqtt.cpp
* @author Alexander Klein (alex@kleiax.de)
* @brief
* @brief Contains the implementation of the class OutputBufMqtt
* @version 0.1
* @date 2022-02-14
*
+24 -2
View File
@@ -1,7 +1,11 @@
/**
* @file outputStreamMqtt.h
* @file outputBufMqtt.h
* @author Alexander Klein (alex@kleiax.de)
* @brief
* @brief Contains a small class that provide a streambuf
*
* The streambuf is used to double the std::cout to consol
* and MQTT.
*
* @version 0.1
* @date 2022-02-14
*
@@ -19,11 +23,29 @@
#include "debugMqtt.h"
/**
* @brief A alternativ streambuf for std::cout
*
* The streambuf is used to double the std::cout to consol
* and MQTT.
*
*/
class OutputBufMqtt : public std::streambuf {
public:
/**
* @brief Construct a new Output Buf Mqtt object
*
* @param debugMqtt
*/
OutputBufMqtt(DebugMqtt* debugMqtt);
protected:
/**
* @brief
*
* @param c
* @return std::streambuf::int_type
*/
virtual std::streambuf::int_type overflow(std::streambuf::int_type c);
public: