26 CircularBuffer<myJSONStr, MAX_JSON_MESSAGES_SAVED>
_buffer;
32 void callback(
char* topic,
byte* payload,
unsigned int length) {
33 DBFUNCCALLln(
"callback(const char[] topic, byte* payload, unsigned int length)");
34 char payload_str[length];
35 for (
unsigned int i = 0; i < length; i++) {
36 payload_str[i] = (char)payload[i];
38 payload_str[length] =
'\0';
40 String topic_str = String((
char*)topic);
41 String currentMessage = topic_str +
" " + payload_str;
42 DBINFO3(
"CurrMessage: ");
43 DBINFO3ln(currentMessage);
44 DBINFO3(
"LastMessage: ");
48 DBINFO2ln(
"Duplicated Message");
50 DBINFO2ln(
"Add to Buffer");
53 newMessage.
topic = topic_str;
55 DBINFO3ln(newMessage.
id);
57 DBINFO3ln(newMessage.
topic);
59 DBINFO3ln(newMessage.
status);
61 DBINFO3ln(newMessage.
sector);
63 DBINFO3ln(newMessage.
line);
65 DBINFO3ln(newMessage.
ack);
67 DBINFO3ln(newMessage.
req);
69 DBINFO3ln(newMessage.
cargo);
71 DBINFO3ln(newMessage.
error);
73 DBINFO3ln(newMessage.
token);
The Connection-class is used as interface.
CircularBuffer< myJSONStr, MAX_JSON_MESSAGES_SAVED > _buffer
instance of CircularBuffer
myJSON Struct defines the format of the messages
Communication(String Hostname)
Construct a new Communication object.
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...
#define MAX_JSON_PARSE_SIZE
max buffer size to parse JSON objects, size of the pool in bytes, can be calculated in https://arduin...
myJSON _myjson(MAX_JSON_PARSE_SIZE)
instance of myJSON
void init()
Initializes the Hard- and Software for WLAN and MQTT-Connection.
myJSONStr parsingJSONToStruct(const char *json)
Parsing JSON-Format into myJSONStr.
String ack
Acknoledgement.
bool token
Gateway and Reset-token.
myJSON class handels the conversion from the JSON-Format into a struct