Skip to content
Snippets Groups Projects
Verified Commit c871d105 authored by Anian Bühler's avatar Anian Bühler
Browse files

added Broker -verbose Mode

parent 6b459b62
No related branches found
No related tags found
1 merge request!10Dev verbose
...@@ -515,6 +515,9 @@ bool DidacticPSNetBroker::handleData() ...@@ -515,6 +515,9 @@ bool DidacticPSNetBroker::handleData()
int currentTopicNr = 0; int currentTopicNr = 0;
int topicLength = 0; int topicLength = 0;
int dataLength = 0; int dataLength = 0;
printVerbose(_readBufferMessage);
if (_readBufferMessage[1] == MSG_PUBLISH) if (_readBufferMessage[1] == MSG_PUBLISH)
{ {
topicLength = extractData(2, MAX_LEN_TOPICS, _bufferTopic, MSG_SEPARATOR); topicLength = extractData(2, MAX_LEN_TOPICS, _bufferTopic, MSG_SEPARATOR);
...@@ -604,6 +607,34 @@ int DidacticPSNetBroker::getFreeTopicNr() ...@@ -604,6 +607,34 @@ int DidacticPSNetBroker::getFreeTopicNr()
return -1; 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 ;-) // LITTLE HELPERS FOR CLIENTS ;-)
//************************************************************************* //*************************************************************************
......
...@@ -223,21 +223,27 @@ public: ...@@ -223,21 +223,27 @@ public:
class DidacticPSNetBroker : public DidacticPSNet class DidacticPSNetBroker : public DidacticPSNet
{ {
private: private:
Stream *_verbosePort;
char _topic[MAX_NR_TOPICS_BROKER][MAX_LEN_TOPICS + 1] = {{0}}; char _topic[MAX_NR_TOPICS_BROKER][MAX_LEN_TOPICS + 1] = {{0}};
char _data[MAX_NR_TOPICS_BROKER][MAX_LEN_PAYLOAD + 1] = {{0}}; char _data[MAX_NR_TOPICS_BROKER][MAX_LEN_PAYLOAD + 1] = {{0}};
bool _isVerbose = false;
bool savePayload(char *, int); bool savePayload(char *, int);
bool getMessageFilter(char); bool getMessageFilter(char);
void writeDataToTopic(int, char *, char *); void writeDataToTopic(int, char *, char *);
bool handleData(); bool handleData();
int getTopicNr(char *); int getTopicNr(char *);
int getFreeTopicNr(); int getFreeTopicNr();
bool update(char *, int, char *, int); // TEST: moved from public
bool printVerbose(char *); // TEST: new & untested
public: public:
DidacticPSNetBroker(); DidacticPSNetBroker();
~DidacticPSNetBroker(); ~DidacticPSNetBroker();
bool update(char *, int, char *, int); void setVerbose(Stream &_port); // TEST: new & untested
void setNoneVerbose(); // TEST: new & untested
}; };
#endif #endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment