|
@@ -19,6 +19,8 @@ LM1640Display display(CLK, DIO);
|
19
|
19
|
static const int8_t timeZone = 7;
|
20
|
20
|
bool wifiFirstConnected = false;
|
21
|
21
|
bool ntp_online = false;
|
|
22
|
+String outside_termo = "00";
|
|
23
|
+
|
22
|
24
|
|
23
|
25
|
void onSTAConnected (WiFiEventStationModeConnected ipInfo) {
|
24
|
26
|
Serial.printf ("Connected to %s\r\n", ipInfo.ssid.c_str ());
|
|
@@ -56,6 +58,14 @@ void processSyncEvent(NTPSyncEvent_t ntpEvent) {
|
56
|
58
|
Serial.print("Got NTP time: ");
|
57
|
59
|
ntp_online = true;
|
58
|
60
|
Serial.println(NTP.getTimeDateString(NTP.getLastNTPSync()));
|
|
61
|
+ HTTPClient http;
|
|
62
|
+ http.begin("http://termo.tomsk.ru/data.txt");
|
|
63
|
+ int httpCode = http.GET();
|
|
64
|
+ if (httpCode > 0) {
|
|
65
|
+ if (httpCode == HTTP_CODE_OK) {
|
|
66
|
+ outside_termo = http.getString();
|
|
67
|
+ }
|
|
68
|
+ }
|
59
|
69
|
}
|
60
|
70
|
}
|
61
|
71
|
|
|
@@ -91,9 +101,9 @@ void starting() {
|
91
|
101
|
NTP.setInterval(10, 600);
|
92
|
102
|
|
93
|
103
|
display.clear();
|
94
|
|
-
|
|
104
|
+
|
95
|
105
|
//Serial.println("Starting NTP client");
|
96
|
|
-
|
|
106
|
+
|
97
|
107
|
while (ntp_online == false) {
|
98
|
108
|
if (syncEventTriggered) {
|
99
|
109
|
processSyncEvent (ntpEvent);
|
|
@@ -118,7 +128,7 @@ void starting() {
|
118
|
128
|
|
119
|
129
|
char timebuff[17];
|
120
|
130
|
|
121
|
|
-void loop() {
|
|
131
|
+void loop() {
|
122
|
132
|
if (ntp_online == true) {
|
123
|
133
|
if (syncEventTriggered) {
|
124
|
134
|
processSyncEvent (ntpEvent);
|
|
@@ -126,11 +136,12 @@ void loop() {
|
126
|
136
|
}
|
127
|
137
|
|
128
|
138
|
String timestamp = NTP.getTimeDateString();
|
|
139
|
+ String result = timestamp + " " + outside_termo;
|
129
|
140
|
|
130
|
141
|
//Serial.print(timestamp + "\n");
|
131
|
142
|
|
132
|
|
- timestamp.toCharArray(timebuff, 17);
|
133
|
|
-
|
|
143
|
+ result.toCharArray(timebuff, 17);
|
|
144
|
+
|
134
|
145
|
display.showString( timebuff );
|
135
|
146
|
|
136
|
147
|
delay(1000);
|