8000 Update example. Removed some debug crud. Added a Flash Info hotkey op… · esp8266/Arduino@95eefed · GitHub
[go: up one dir, main page]

Skip to content

Commit 95eefed

Browse files
committed
Update example. Removed some debug crud. Added a Flash Info hotkey option.
1 parent 9d6e059 commit 95eefed

File tree

4 files changed

+57
-54
lines changed

4 files changed

+57
-54
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#ifndef ADDONS_H
2+
#define ADDONS_H
3+
4+
// Add additional includes here.
5+
6+
#endif
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
#ifdef ADDON_DEMO
3+
void printHelpAddOn(Print& oStream) {
4+
oStream.println(F(" x - use this space to add on extra hot key options"));
5+
}
6+
7+
int hotKeyHandlerAddOn(Print& oStream, char hotKey) {
8+
switch (hotKey) {
9+
case 'x':
10+
oStream.printf_P(PSTR("This could be an extra option"));
11+
break;
12+
default:
13+
oStream.println();
14+
return 0;
15+
}
16+
oStream.println();
17+
return 1;
18+
}
19+
#else
20+
void printHelpAddOn(Print& oStream) {
21+
(void)oStream;
22+
}
23+
int hotKeyHandlerAddOn(Print& oStream, char inChar) {
24+
(void)oStream;
25+
(void)inChar;
26+
return 0;
27+
}
28+
#endif
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#include <Esp.h>
2+
#include <Print.h>
3+
#define String_F(a) String(F(a))
4+
5+
void printFlashInfo(Print& oStream) {
6+
oStream.println(String_F("Flash Size as reported by:"));
7+
oStream.println(String_F(" flashchip->chip_size: 0x0") + String(flashchip->chip_size, HEX) + (", ") + String(flashchip->chip_size));
8+
oStream.println(String_F(" ESP.getFlashChipSize: 0x0") + String(ESP.getFlashChipSize(), HEX) + (", ") + String(ESP.getFlashChipSize()));
9+
oStream.println(String_F(" ESP.getFlashChipRealSize: 0x0") + String(ESP.getFlashChipRealSize(), HEX) + (", ") + String(ESP.getFlashChipRealSize()));
10+
}

libraries/ArduinoOTA/examples/OTAConfigErase/OTAConfigErase.ino

Lines changed: 13 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,10 @@
99
#include "WifiHealth.h"
1010

1111
#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"
2013

2114
#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.")
2316
#define STASSID "your-ssid"
2417
#define STAPSK "your-password"
2518
#endif
@@ -90,11 +83,9 @@ void setup() {
9083
WiFi.begin(ssid, password);
9184
while (WiFi.waitForConnectResult() != WL_CONNECTED) {
9285
Serial.println("Connection Failed! Rebooting...");
93-
EVLOG1("Connection Failed! Rebooting...");
9486
delay(5000);
9587
ESP.restart();
9688
}
97-
EVLOG1("WiFi Up!");
9889

9990
// Port defaults to 8266
10091
// ArduinoOTA.setPort(8266);
@@ -173,20 +164,13 @@ void printHelp(Print& oStream) {
173164
oStream.println(F(" u - umm_info"));
174165
oStream.println(F(" w - WiFi Stats"));
175166
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);
184169
oStream.println(F(" ? - This help message"));
185170
oStream.println();
186171
}
187172

188173
void printTimes(Print& out) {
189-
// #if (EVLOG_TIMESTAMP == EVLOG_TIMESTAMP_CLOCKCYCLES)
190174
{
191175
uint32_t fraction = esp_get_cycle_count();
192176
fraction /= clockCyclesPerMicrosecond();
@@ -199,7 +183,6 @@ void printTimes(Print& out) {
199183
out.printf_P(ts_fmt, buf, fraction, clockCyclesPerMicrosecond());
200184
out.println();
201185
}
202-
// #elif (EVLOG_TIMESTAMP == EVLOG_TIMESTAMP_MICROS)
203186
{
204187
uint32_t fraction = micros();
205188
time_t gtime = (time_t)(fraction / 1000000U);
@@ -211,7 +194,6 @@ void printTimes(Print& out) {
211194
out.printf_P(ts_fmt, buf, fraction);
212195
out.println();
213196
}
214-
// #elif (EVLOG_TIMESTAMP == EVLOG_TIMESTAMP_MILLIS)
215197
{
216198
uint32_t fraction = millis();
217199
time_t gtime = (time_t)(fraction / 1000U);
@@ -223,39 +205,26 @@ void printTimes(Print& out) {
223205
out.printf_P(ts_fmt, buf, fraction);
224206
out.println();
225207
}
226-
// #endif
227208
}
228209

229-
int cmdLoop(Print& oStream, char inChar) {
230-
switch (inChar) {
210+
int cmdLoop(Print& oStream, char hotKey) {
211+
switch (hotKey) {
231212
case 't':
232213
printLocalTime(oStream);
233214
oStream.println();
234215
printTimes(oStream);
235216
oStream.println();
236217
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
246218
case '?':
247219
printHelp(oStream);
248220
break;
249221
case 'u':
250222
umm_info(NULL, true);
251223
break;
252-
253-
#if ENABLE_FLASH_STATS
254224
case 'f':
255-
printFlashStatsReport(oStream);
225+
printFlashInfo(oStream);
256226
oStream.println();
257227
break;
258-
#endif
259228
case 'w':
260229
printWiFiStats(oStream);
261230
oStream.println();
@@ -266,25 +235,14 @@ int cmdLoop(Print& oStream, char inChar) {
266235
WiFi.mode(WIFI_OFF);
267236
ESP.restart();
268237
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
280238
case '0':
281239
case '1':
282240
case '2':
283241
case '3':
284242
case '4':
285243
case '5':
286244
case '6':
287-
if (queueEraseConfig(inChar)) {
245+
if (queueEraseConfig(hotKey)) {
288246
oStream.println(F("Erase config request queued. Press 'R' to process or start OTA Update."));
289247
}
290248
oStream.println();
@@ -294,16 +252,17 @@ int cmdLoop(Print& oStream, char inChar) {
294252
oStream.println();
295253
break;
296254
default:
297-
oStream.println();
255+
return hotKeyHandlerAddOn(oStream, hotKey);
298256
break;
299257
}
300-
return 0;
258+
oStream.println();
259+
return 1;
301260
}
302261

303262
void serialClientLoop(void) {
304263
if (Serial.available() > 0) {
305-
char inChar = Serial.read();
306-
cmdLoop(Serial, inChar);
264+
char hotKey = Serial.read();
265+
cmdLoop(Serial, hotKey);
307266
}
308267
}
309268

0 commit comments

Comments
 (0)
0