ESP_IOT v2.5
IOT ESP Coding
SMARTButton.cpp
Go to the documentation of this file.
1
2#include "SMARTButton.h"
3#ifdef PROCESS_SMART_BUTTON_JSON
4
5
6char *_SMARTButton = NULL;
7void runSMARTButton(char *SMAddress)
8{
9 //todo .. create an array .. but for now just run it..
10}
11
12//!@see https://arduinojson.org/v6/doc/deserialization/
13//!
14//!process the JSON message (looking for FEED, etc). Note: topic can be nil, or if not, it's an MQTT topic (so send replies if you want)
15boolean processJSONSMARTButton(DynamicJsonDocument smartJSONObject)
16{
17 SerialTemp.printf("processJSONSMARTButton: ");
18 serializeJsonPretty(smartJSONObject, Serial);
19 SerialTemp.println("");
20
21 StaticJsonDocument<2024> flows;
22 DynamicJsonDocument smartButtonObject(1024);
23// deserializeJson(doc1, ascii);
24// SerialTemp.printf("step1\n");
25
26 const char *dev = smartJSONObject["dev"];
27 SerialTemp.printf("dev = %s\n", dev?dev:"NULL");
28
29 deserializeJson(smartButtonObject, smartJSONObject["SMARTButton"]);
30
31 serializeJsonPretty(smartButtonObject, Serial);
32 SerialTemp.println("");
33
34
35 SerialTemp.printf("step2\n");
36
37 //NEW: 3.28.22 {'cmd':COMMANDS}
38 // {'sm':<sm>}
39 // {'guest':<passws>
40 //{ 'set':<object>,'val':<value>}
41 const char* name = smartButtonObject["name"];
42 const char* uuid = smartButtonObject["uuid"];
43 const char* flowNum = smartButtonObject["flowNum"];
44 SerialTemp.printf("processJSONSMARTButton: %s, %s, %s\n", name?name:"NULL", uuid?uuid:"NULL", flowNum?flowNum:"NULL");
45
46 deserializeJson(flows, smartButtonObject["flow"]);
47
48 SerialTemp.printf("step3\n");
49
50
51 return true;
52
53}
54
55#endif