MQTT Communication
Smart Factory
|
The Connection-class is used as interface. More...
#include "Arduino.h"
#include "CommunicationConfiguration.h"
#include <CircularBuffer.h>
#include "Network/Network.h"
#include "myJSON/myJSON.h"
#include "myMQTT/myMQTT.h"
Go to the source code of this file.
Classes | |
class | Communication |
The Connection-class provides the interface. More... | |
Functions | |
void | callback (char *topic, byte *payload, unsigned int length) |
If the client is used to subscribe to topics, a callback function must be provided in the constructor. his function is called when new messages arrive at the client. More... | |
Variables | |
myJSON | _myjson |
Declare a global variable from typ myJSON so it can be accessed in callback. More... | |
CircularBuffer< myJSONStr, MAX_JSON_MESSAGES_SAVED > | _buffer |
Declares a global Circular Buffer of type myJSONStr with max Elements of MAX_JSON_MESSAGES_SAVED. More... | |
The Connection-class is used as interface.
Definition in file MQTTCommunication.h.
void callback | ( | char * | topic, |
byte * | payload, | ||
unsigned int | length | ||
) |
If the client is used to subscribe to topics, a callback function must be provided in the constructor. his function is called when new messages arrive at the client.
Internally, the client uses the same buffer for both inbound and outbound messages. After the callback function returns, or if a call to either publish or subscribe is made from within the callback function, the topic and payload values passed to the function will be overwritten. The application should create its own copy of the values if they are required beyond this.
https://pubsubclient.knolleary.net/api.html#callback
This Function is global because you need to access it from a diffrent class and pass it as pointer. This would be possible if it's static but then all function which get called in callback need to be static too.
topic | - the topic the message arrived on (const char[]) |
payload | - the message payload (byte array) |
length | - the length of the message payload (unsigned int) |
Definition at line 32 of file MQTTCommunication.cpp.
CircularBuffer<myJSONStr, MAX_JSON_MESSAGES_SAVED> _buffer |
Declares a global Circular Buffer of type myJSONStr with max Elements of MAX_JSON_MESSAGES_SAVED.
When declaring your buffer you should specify the data type it must handle and the buffer capacity: those two parameters will influence the memory consumed by the buffer. https://github.com/rlogiacco/CircularBuffer
Declares a global Circular Buffer of type myJSONStr with max Elements of MAX_JSON_MESSAGES_SAVED.
Definition at line 26 of file MQTTCommunication.cpp.