9
9
#include " WifiHealth.h"
10
10
11
11
#include < umm_malloc/umm_malloc_cfg.h>
12
- #if HEAP_STATIC_RESERVE_SIZE
13
- #include < evlog/src/event_logger.h>
14
- #else
15
- #define EVLOG1 (a ) do { (void )a; } while (false )
16
- #endif
17
- #if ENABLE_FLASH_STATS
18
- #include < evlog/src/flash_stats.h>
19
- #endif
12
+ #include " AddOns.h"
20
13
21
14
#ifndef STASSID
22
- #pragma message("Using default SSID: your-ssid")
15
+ #pragma message("Using default SSID: your-ssid, this is probably not what you want. ")
23
16
#define STASSID " your-ssid"
24
17
#define STAPSK " your-password"
25
18
#endif
@@ -90,11 +83,9 @@ void setup() {
90
83
WiFi.begin (ssid, password);
91
84
while (WiFi.waitForConnectResult () != WL_CONNECTED) {
92
85
Serial.println (" Connection Failed! Rebooting..." );
93
- EVLOG1 (" Connection Failed! Rebooting..." );
94
86
delay (5000 );
95
87
ESP.restart ();
96
88
}
97
- EVLOG1 (" WiFi Up!" );
98
89
99
90
// Port defaults to 8266
100
91
// ArduinoOTA.setPort(8266);
@@ -173,20 +164,13 @@ void printHelp(Print& oStream) {
173
164
oStream.println (F (" u - umm_info" ));
174
165
oStream.println (F (" w - WiFi Stats" ));
175
166
oStream.println (F (" R - Restart" ));
176
- #if ENABLE_FLASH_STATS
177
- oStream.println (F (" f - flash Stats" ));
178
- #endif
179
- #if HEAP_STATIC_RESERVE_SIZE
180
- oStream.println (F (" m - static reserve memory information" ));
181
- oStream.println (F (" e - EvLog Report" ));
182
- oStream.println (F (" E - EvLog Clear" ));
183
- #endif
167
+ oStream.println (F (" f - flash info" ));
168
+ printHelpAddOn (oStream);
184
169
oStream.println (F (" ? - This help message" ));
185
170
oStream.println ();
186
171
}
187
172
188
173
void printTimes (Print& out) {
189
- // #if (EVLOG_TIMESTAMP == EVLOG_TIMESTAMP_CLOCKCYCLES)
190
174
{
191
175
uint32_t fraction = esp_get_cycle_count ();
192
176
fraction /= clockCyclesPerMicrosecond ();
@@ -199,7 +183,6 @@ void printTimes(Print& out) {
199
183
out.printf_P (ts_fmt, buf, fraction, clockCyclesPerMicrosecond ());
200
184
out.println ();
201
185
}
202
- // #elif (EVLOG_TIMESTAMP == EVLOG_TIMESTAMP_MICROS)
203
186
{
204
187
uint32_t fraction = micros ();
205
188
time_t gtime = (time_t )(fraction / 1000000U );
@@ -211,7 +194,6 @@ void printTimes(Print& out) {
211
194
out.printf_P (ts_fmt, buf, fraction);
212
195
out.println ();
213
196
}
214
- // #elif (EVLOG_TIMESTAMP == EVLOG_TIMESTAMP_MILLIS)
215
197
{
216
198
uint32_t fraction = millis ();
217
199
time_t gtime = (time_t )(fraction / 1000U );
@@ -223,39 +205,26 @@ void printTimes(Print& out) {
223
205
out.printf_P (ts_fmt, buf, fraction);
224
206
out.println ();
225
207
}
226
- // #endif
227
208
}
228
209
229
- int cmdLoop (Print& oStream, char inChar ) {
230
- switch (inChar ) {
210
+ int cmdLoop (Print& oStream, char hotKey ) {
211
+ switch (hotKey ) {
231
212
case ' t' :
232
213
printLocalTime (oStream);
233
214
oStream.println ();
234
215
printTimes (oStream);
235
216
oStream.println ();
236
217
break ;
237
- #if HEAP_STATIC_RESERVE_SIZE
238
- case ' m' :
239
- oStream.printf_P (PSTR (" umm_get_static_reserve_size %u" ), umm_get_static_reserve_size ());
240
- oStream.println ();
241
- oStream.printf_P (PSTR (" umm_get_static_reserve_addr %p" ), umm_get_static_reserve_addr ());
242
- oStream.println ();
243
- oStream.println ();
244
- break ;
245
- #endif
246
218
case ' ?' :
247
219
printHelp (oStream);
248
220
break ;
249
221
case ' u' :
250
222
umm_info (NULL , true );
251
223
break ;
252
-
253
- #if ENABLE_FLASH_STATS
254
224
case ' f' :
255
- printFlashStatsReport (oStream);
225
+ printFlashInfo (oStream);
256
226
oStream.println ();
257
227
break ;
258
- #endif
259
228
case ' w' :
260
229
printWiFiStats (oStream);
261
230
oStream.println ();
@@ -266,25 +235,14 @@ int cmdLoop(Print& oStream, char inChar) {
266
235
WiFi.mode (WIFI_OFF);
267
236
ESP.restart ();
268
237
break ;
269
-
270
- #if HEAP_STATIC_RESERVE_SIZE
271
- case ' E' :
272
- evlog_restart (1 );
273
- oStream.println (F (" EvLog restarted." ));
274
- break ;
275
- case ' e' :
276
- evlogPrintReport (oStream);
277
- oStream.println ();
278
- break ;
279
- #endif
280
238
case ' 0' :
281
239
case ' 1' :
282
240
case ' 2' :
283
241
case ' 3' :
284
242
case ' 4' :
285
243
case ' 5' :
286
244
case ' 6' :
287
- if (queueEraseConfig (inChar )) {
245
+ if (queueEraseConfig (hotKey )) {
288
246
oStream.println (F (" Erase config request queued. Press 'R' to process or start OTA Update." ));
289
247
}
290
248
oStream.println ();
@@ -294,16 +252,17 @@ int cmdLoop(Print& oStream, char inChar) {
294
252
oStream.println ();
295
253
break ;
296
254
default :
297
- oStream. println ( );
255
+ return hotKeyHandlerAddOn (oStream, hotKey );
298
256
break ;
299
257
}
300
- return 0 ;
258
+ oStream.println ();
259
+ return 1 ;
301
260
}
302
261
303
262
void serialClientLoop (void ) {
304
263
if (Serial.available () > 0 ) {
305
- char inChar = Serial.read ();
306
- cmdLoop (Serial, inChar );
264
+ char hotKey = Serial.read ();
265
+ cmdLoop (Serial, hotKey );
307
266
}
308
267
}
309
268
0 commit comments