File tree 1 file changed +33
-1
lines changed
libraries/OTAUpdate/examples/WiFiFirmwareOTA
1 file changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,31 @@ int status = WL_IDLE_STATUS;
27
27
OTAUpdate ota;
28
28
static char const OTA_FILE_LOCATION[] = " https://downloads.arduino.cc/ota/UNOR4USBBridge.ino.ota" ;
29
29
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
+
30
55
/* -------------------------------------------------------------------------- */
31
56
void setup () {
32
57
/* -------------------------------------------------------------------------- */
@@ -64,6 +89,13 @@ void setup() {
64
89
65
90
printWiFiStatus ();
66
91
92
+ Serial.println (" \n WARNING! 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
+
67
99
int ret = ota.begin ();
68
100
if (ret != OTAUpdate::OTA_ERROR_NONE) {
69
101
Serial.println (" ota.begin() error: " );
@@ -108,7 +140,7 @@ void loop() {
108
140
/* -------------------------------------------------------------------------- */
109
141
110
142
String fv = WiFi.firmwareVersion ();
111
- Serial.print (" Updated Wi-Fi firmware version: " );
143
+ Serial.print (" Wi-Fi firmware version: " );
112
144
Serial.println (fv);
113
145
delay (1000 );
114
146
}
You can’t perform that action at this time.
0 commit comments