Skip to content

Commit 3902329

Browse files
committed
OTAUpdate: warn the user about what firmware will be installed on WiFi chip
1 parent cb21927 commit 3902329

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

Diff for: libraries/OTAUpdate/examples/WiFiFirmwareOTA/WiFiFirmwareOTA.ino

+33-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,31 @@ int status = WL_IDLE_STATUS;
2727
OTAUpdate ota;
2828
static char const OTA_FILE_LOCATION[] = "https://downloads.arduino.cc/ota/UNOR4USBBridge.ino.ota";
2929

30+
/* -------------------------------------------------------------------------- */
31+
bool waitResponse() {
32+
/* -------------------------------------------------------------------------- */
33+
bool confirmation = false;
34+
while (confirmation == false) {
35+
if (Serial.available()) {
36+
char choice = Serial.read();
37+
switch (choice) {
38+
case 'y':
39+
case 'Y':
40+
confirmation = true;
41+
return true;
42+
break;
43+
case 'n':
44+
case 'N':
45+
confirmation = true;
46+
return false;
47+
break;
48+
default:
49+
continue;
50+
}
51+
}
52+
}
53+
}
54+
3055
/* -------------------------------------------------------------------------- */
3156
void setup() {
3257
/* -------------------------------------------------------------------------- */
@@ -64,6 +89,13 @@ void setup() {
6489

6590
printWiFiStatus();
6691

92+
Serial.println("\nWARNING! Running the sketch a test version of the WiFi firmware will be flashed on your board.");
93+
Serial.println("Do you want to proceed? Y/[n]");
94+
95+
if (false == waitResponse()) {
96+
return;
97+
}
98+
6799
int ret = ota.begin();
68100
if(ret != OTAUpdate::OTA_ERROR_NONE) {
69101
Serial.println("ota.begin() error: ");
@@ -108,7 +140,7 @@ void loop() {
108140
/* -------------------------------------------------------------------------- */
109141

110142
String fv = WiFi.firmwareVersion();
111-
Serial.print("Updated Wi-Fi firmware version: ");
143+
Serial.print("Wi-Fi firmware version: ");
112144
Serial.println(fv);
113145
delay(1000);
114146
}

0 commit comments

Comments
 (0)