diff --git a/src/DidacticNet.cpp b/src/DidacticNet.cpp index 3649719e6ab2dcabad84444ab796b6f4fa0e67d4..76dc62e54b6f23672eec06d48ef021ead1372060 100644 --- a/src/DidacticNet.cpp +++ b/src/DidacticNet.cpp @@ -515,6 +515,9 @@ bool DidacticPSNetBroker::handleData() int currentTopicNr = 0; int topicLength = 0; int dataLength = 0; + + printVerbose(_readBufferMessage); + if (_readBufferMessage[1] == MSG_PUBLISH) { topicLength = extractData(2, MAX_LEN_TOPICS, _bufferTopic, MSG_SEPARATOR); @@ -604,6 +607,34 @@ int DidacticPSNetBroker::getFreeTopicNr() return -1; } +void DidacticPSNetBroker::setVerbose(Stream &verbosePort) // TEST: new & untested +{ + _isVerbose = true; + _verbosePort = &verbosePort; +} + +void DidacticPSNetBroker::setNoneVerbose() // TEST: new & untested +{ + _isVerbose = false; +} + +bool DidacticPSNetBroker::printVerbose(char *recievedData) // TEST: new & untested +{ + char signBuffer = 0; + int signCounter = 0; + + if (_isVerbose) + { + while (signBuffer != MSG_DELIMITER) + { + signBuffer = recievedData[signCounter]; + _verbosePort->write(signBuffer); + signCounter++; + } + } + return _isVerbose; +} + //************************************************************************** // LITTLE HELPERS FOR CLIENTS ;-) //************************************************************************* diff --git a/src/DidacticNet.h b/src/DidacticNet.h index fe97293b8ea336f6de30f2550e994e8e366b6570..5812f7ac044dc029bcc403e155731371b776840f 100644 --- a/src/DidacticNet.h +++ b/src/DidacticNet.h @@ -223,21 +223,27 @@ public: class DidacticPSNetBroker : public DidacticPSNet { private: + Stream *_verbosePort; char _topic[MAX_NR_TOPICS_BROKER][MAX_LEN_TOPICS + 1] = {{0}}; char _data[MAX_NR_TOPICS_BROKER][MAX_LEN_PAYLOAD + 1] = {{0}}; + bool _isVerbose = false; + bool savePayload(char *, int); bool getMessageFilter(char); void writeDataToTopic(int, char *, char *); bool handleData(); int getTopicNr(char *); int getFreeTopicNr(); + bool update(char *, int, char *, int); // TEST: moved from public + bool printVerbose(char *); // TEST: new & untested public: DidacticPSNetBroker(); ~DidacticPSNetBroker(); - bool update(char *, int, char *, int); + void setVerbose(Stream &_port); // TEST: new & untested + void setNoneVerbose(); // TEST: new & untested }; #endif