-
Notifications
You must be signed in to change notification settings - Fork 0
/
ENSABrewJson.ino
67 lines (56 loc) · 2.12 KB
/
ENSABrewJson.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//*******************************************************************************************
// Arquivo C/C++ do Projeto Controlador de Patamares -- ENSABrewControll
//-------------------------------------------------------------------------------------------
//
// Arquivo: ENSABrewJson.ino
//
//
// Autor : Jânio Anselmo, Eng. Me.
// Autor : Thiago Anselmo, Tecgº
// Autor : Gabriel da Silva Caetano
//
// CPU : ATMega2561 - MegaCore
// Clock : 16MHz
//
// Versão da biblioteca Json: 6.5.0
//
//*******************************************************************************************
//WWWWWWWWWW*********************************************************************************
// Função: setJsonData
// Data : 04/04/2017 13:45
//WWWWWWWWWW*********************************************************************************
void setJsonData(int type, byte cmd)
{
String typeCommandUpper = String(type, HEX);
typeCommandUpper.toUpperCase();
String commandUpper = String(cmd, HEX);
commandUpper.toUpperCase();
const size_t bufferSize = JSON_OBJECT_SIZE(7);
DynamicJsonDocument jsonSendBuffer(bufferSize);
JsonObject dataReceita = jsonSendBuffer.to<JsonObject>();
dataReceita[F("header")] = F("4E");
dataReceita[F("product")] = F("0002");
dataReceita[F("type")] = F("D002");
// Se o numero de serie nao for invalido, envia
if(code != F("E15"))
{
dataReceita[F("id")] = String(configGeral.idModule);
dataReceita[F("typeCmd")] = typeCommandUpper;
dataReceita[F("cmd")] = commandUpper;
}
JsonArray error = dataReceita.createNestedArray(F("code"));
error.add(code);
// Envia dados pelo módulo Wi-Fi/Bluetooth
serializeJsonPretty(dataReceita, Serial1);
dataReceita.clear();
}
//WWWWWWWWWW*********************************************************************************
// Função: getJsonData
// Data : 04/04/2017 13:45
//WWWWWWWWWW*********************************************************************************
void getJsonData(JsonObject dataSerialJson)
{
// Envia dados pelo módulo Wi-Fi/Bluetooth
serializeJsonPretty(dataSerialJson, Serial1);
dataSerialJson.clear();
}