Added Basic MQTT Support and JSON Deserialization
This commit is contained in:
26
JSON_functions.hpp
Normal file
26
JSON_functions.hpp
Normal 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);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user