forked from tamntn/aquagrow-esp32
-
Notifications
You must be signed in to change notification settings - Fork 0
/
get.ino
55 lines (50 loc) · 1.65 KB
/
get.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
void getCom() {
if (WiFi.status() == WL_CONNECTED) { //Check WiFi connection status
HTTPClient httpG;
Serial.println("Getting Commands");
httpG.begin(gUrl);
int httpGResponseCode = httpG.GET();
if (httpGResponseCode > 0) {
command = httpG.getString();
Serial.println(httpGResponseCode);
} else {
getErrorCount++;
Serial.print("Error on getting command count = " + (String)getErrorCount);
Serial.println(httpGResponseCode);
}
httpG.end();
} else {
Serial.println("Error in WiFi connection");
}
Serial.println(command);
}
void parseC(){
Serial.println("Parsing started");
StaticJsonBuffer<1500> JSONBuffer;
JsonObject& parsed = JSONBuffer.parseObject(command);
if (!parsed.success()) {
Serial.println("Parsing failed");
delay(50);
return;
}else{
getErrorCount=0;
Serial.println("Successfully Parsed");
wPumpStatus = parsed["data"]["waterPump"];
lightStatus = parsed["data"]["growLight"];
heatStatus = parsed["data"]["heatingMat"];
ohPumpStatus = parsed["data"]["phPumpHigh"];
hPumpStatus = parsed["data"]["phPumpLow"];
//int wPumpInt = parsed["Data"]["waterPumpInt"];
//int lightInt = parsed["Data"]["waterPumpInt"];
delay(50);
}
}
void printC(){
Serial.println("Water Pump Status = " + (String)wPumpStatus);
Serial.println("Grow Light Status = " + (String)lightStatus);
Serial.println("Heating mat Status = " + (String)heatStatus );
Serial.println("H+ Pump Status = " + (String)hPumpStatus);
Serial.println("OH- Pump Status = " + (String)ohPumpStatus);
// Serial.println("Water Pump Speed = " + wPumpInt );
// Serial.println("Grow light internsity = " + lightInt );
}