|
19 | 19 | #include <AsyncTCP.h> |
20 | 20 | #include "asyncbufferedtcplogger.h" |
21 | 21 |
|
22 | | -#include "time.h" |
23 | | -#include "esp_sntp.h" |
24 | 22 | Scheduler scheduler; |
25 | 23 | AsyncServer loggerServer{9911}; |
26 | 24 |
|
@@ -52,16 +50,15 @@ void setup() { |
52 | 50 |
|
53 | 51 | Log.begin(LOG_LEVEL_VERBOSE, &Serial, true); |
54 | 52 | Log.infoln(LOG_SCOPE "setup, core: %d", xPortGetCoreID()); |
| 53 | + |
| 54 | + Log.addHandler(&bufferedLogger); |
55 | 55 |
|
56 | 56 | LittleFS.begin(); |
57 | 57 | APB::Settings::Instance.setup(); |
58 | 58 | APB::StatusLed::Instance.setup(); |
59 | 59 |
|
60 | 60 | APB::WiFiManager::Instance.setup(scheduler); |
61 | 61 | loggerServer.begin(); |
62 | | - |
63 | | - Log.addHandler(&bufferedLogger); |
64 | | - |
65 | 62 | Wire.begin(I2C_SDA_PIN, I2C_SCL_PIN); |
66 | 63 | Wire.setClock(100000); |
67 | 64 | APB::Ambient::Instance.setup(scheduler); |
@@ -103,28 +100,31 @@ void setupArduinoOTA() { |
103 | 100 | } |
104 | 101 |
|
105 | 102 | // NOTE: if updating SPIFFS this would be the place to unmount SPIFFS using SPIFFS.end() |
106 | | - Serial.println("Start updating " + type); |
| 103 | + Log.infoln("Start updating %s", type.c_str()); |
107 | 104 | LittleFS.end(); |
108 | 105 | }) |
109 | 106 | .onEnd([]() { |
110 | | - Serial.println("\nEnd"); |
| 107 | + Log.infoln("\nEnd"); |
111 | 108 | }) |
112 | 109 | .onProgress([](unsigned int progress, unsigned int total) { |
113 | | - Serial.printf("Progress: %u%%\r", (progress / (total / 100))); |
| 110 | + Log.infoln("Progress: %u%%\r", (progress / (total / 100))); |
114 | 111 | }) |
115 | 112 | .onError([](ota_error_t error) { |
116 | | - Serial.printf("Error[%u]: ", error); |
| 113 | + String errorMessage; |
117 | 114 | if (error == OTA_AUTH_ERROR) { |
118 | | - Serial.println("Auth Failed"); |
| 115 | + errorMessage = "Auth Failed"; |
119 | 116 | } else if (error == OTA_BEGIN_ERROR) { |
120 | | - Serial.println("Begin Failed"); |
| 117 | + errorMessage = "Begin Failed"; |
121 | 118 | } else if (error == OTA_CONNECT_ERROR) { |
122 | | - Serial.println("Connect Failed"); |
| 119 | + errorMessage = "Connect Failed"; |
123 | 120 | } else if (error == OTA_RECEIVE_ERROR) { |
124 | | - Serial.println("Receive Failed"); |
| 121 | + errorMessage = "Receive Failed"; |
125 | 122 | } else if (error == OTA_END_ERROR) { |
126 | | - Serial.println("End Failed"); |
| 123 | + errorMessage = "End Failed"; |
| 124 | + } else { |
| 125 | + errorMessage = "Unknown error"; |
127 | 126 | } |
| 127 | + Log.errorln("Error[%u]: %s", error, errorMessage.c_str()); |
128 | 128 | }); |
129 | 129 |
|
130 | 130 | ArduinoOTA.begin(); |
|
0 commit comments