This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "config.h" | |
| #include "display.h" | |
| #include "wifi.h" | |
| #include "json.h" | |
| #include "firebase_database.h" | |
| void setup() | |
| { | |
| setupDisplay(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void resetWiFi() { | |
| wiFiDrv.wifiDriverDeinit(); | |
| wiFiDrv.wifiDriverInit(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if (statusCode != 200) { | |
| displayError(String(statusCode) + " " + response); | |
| return false; | |
| } | |
| displayStatus("Saved to RTDB."); | |
| return true; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| String host = String(PROJECT_ID) + ".firebaseio.com"; | |
| WiFiSSLClient wifiClient; | |
| HttpClient httpClient = HttpClient(wifiClient, host, 443); | |
| String url = "/" + path + ".json"; | |
| httpClient.put(url, "application/json", jsonStr); | |
| int statusCode = httpClient.responseStatusCode(); | |
| String response = httpClient.responseBody(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| DynamicJsonDocument toJsonDocument(String str, int size = 0) { | |
| if (size == 0) { | |
| size = JSON_OBJECT_SIZE(1) + str.length(); | |
| } | |
| DynamicJsonDocument jsonDoc(str.length() * 2); | |
| DeserializationError error = deserializeJson(jsonDoc, str); | |
| if (error) { | |
| displayError("JSON " + String(error.c_str()) + ": " + str); | |
| jsonDoc.clear(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "config.h" | |
| #include "display.h" | |
| #include "wifi.h" | |
| void setup() | |
| { | |
| setupDisplay(); | |
| setupWiFi(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void displaySuspend(String msg) { | |
| displayText("Execution suspended: " + msg); | |
| digitalWrite(LED_BUILTIN, HIGH); // Turn on LED. | |
| while (true) { | |
| // Stop execution. | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void displayError(String msg) { | |
| displayText("Error: " + msg); | |
| blinkLED(300); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void displayStatus(String msg) { | |
| displayText(msg); | |
| blinkLED(100); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void blinkLED(int duration) { | |
| digitalWrite(LED_BUILTIN, HIGH); | |
| delay(duration); | |
| digitalWrite(LED_BUILTIN, LOW); | |
| delay(100); | |
| } |