Added Basic MQTT Support and JSON Deserialization

This commit is contained in:
2024-12-29 13:04:23 +02:00
parent c523b59e90
commit 30e708f048
6 changed files with 235 additions and 6 deletions

26
JSON_functions.hpp Normal file
View File

@@ -0,0 +1,26 @@
#pragma once
void reconstr (String payload) {
JsonDocument doc;
DeserializationError error = deserializeJson(doc, payload);
if (error) {
Serial.print("deserializeJson() failed: ");
Serial.println(error.c_str());
return;
}
// EXAMPLE PAYLOAD. CHANGE THIS TO THE APPROPRIATE ONE.
int a = doc["a"];
bool b = doc["b"];
float c = doc["c"];
Serial.println("The payload received contains: ");
Serial.print("a: ");
Serial.print(a);
Serial.print(" b: ");
Serial.print(b);
Serial.print(" c: ");
Serial.println(c);
}