Skip to content

Commit 1a03a41

Browse files
committed
style
fixed confused example
1 parent f5d7d4a commit 1a03a41

File tree

2 files changed

+4
-40
lines changed

2 files changed

+4
-40
lines changed

libraries/ArduinoOTA/examples/OTAEraseConfig/OTAEraseConfig.ino

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -16,46 +16,10 @@
1616
const char* ssid = STASSID;
1717
const char* password = STAPSK;
1818

19-
struct YourEEPROMData {
20-
// list of parameters you need to keep
21-
// ...
22-
23-
uint32_t sdkCrc; //add this one
24-
};
25-
26-
bool checkSdkCrc() {
27-
size_t length = strlen(SDK_VERSION);
28-
uint32_t sdkVersionCrc = crc32(SDK_VERSION, length);
29-
30-
uint32_t savedSdkVersionCrc;
31-
EEPROM.begin((sizeof(struct YourEEPROMData) + 3) & ~3);
32-
EEPROM.get(offsetof(struct YourEEPROMData, sdkCrc), savedSdkVersionCrc);
33-
34-
if (sdkVersionCrc == savedSdkVersionCrc) {
35-
return EEPROM.end();
36-
}
37-
38-
// Remember new SDK CRC
39-
EEPROM.put(offsetof(struct YourEEPROMData, sdkVersionCrc);
40-
if (EEPROM.commit() && EEPROM.end()) {
41-
// Erase WiFi settings and reset
42-
ArduinoOTA.eraseConfigAndReset();
43-
}
44-
45-
return false;
46-
}
47-
4819
void setup() {
4920
Serial.begin(115200);
5021
Serial.println("Booting");
5122

52-
Serial.println("Check for changes in SDK Version:");
53-
if (checkSdkCrc()) {
54-
Serial.println(" SDK version changed and update to saved details failed.");
55-
} else {
56-
Serial.println(" SDK version has not changed.");
57-
}
58-
5923
WiFi.mode(WIFI_STA);
6024
WiFi.begin(ssid, password);
6125
while (WiFi.waitForConnectResult() != WL_CONNECTED) {
@@ -98,7 +62,7 @@ void setup() {
9862
to meet your requirements.
9963
*/
10064
if (true) {
101-
ArduinoOTA.setRebootOnSuccess(true, true); // reboot = true, eraseConfig = true
65+
ArduinoOTA.setRebootOnSuccess(true, true); // reboot = true, eraseConfig = true
10266
}
10367
});
10468
ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {

libraries/ArduinoOTA/examples/OTASdkCheck/OTASdkCheck.ino

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#else
2222
#define CONSOLE Serial
2323
#endif
24-
#define DEBUG_PRINTF(fmt, ...) CONSOLE.printf_P(PSTR(fmt), ##__VA_ARGS__)
24+
#define DEBUG_PRINTF(fmt, ...) CONSOLE.printf_P(PSTR(fmt), ##__VA_ARGS__)
2525
#else
2626
#define DEBUG_PRINTF(...)
2727
#endif
@@ -55,7 +55,7 @@ bool checkSdkCrc() {
5555
return true;
5656
}
5757

58-
const char *sdkVerStr = ESP.getSdkVersion();
58+
const char* sdkVerStr = ESP.getSdkVersion();
5959
uint32_t sdkVersionCrc = crc32(sdkVerStr, strlen(sdkVerStr));
6060

6161
uint32_t savedSdkVersionCrc;
@@ -75,7 +75,7 @@ bool checkSdkCrc() {
7575
// Erase WiFi Settings and Reset
7676
DEBUG_PRINTF(" EEPROM update successful. New SDK CRC saved.\r\n");
7777
DEBUG_PRINTF(" Erase config and reset: ...\r\n");
78-
ArduinoOTA.eraseConfigAndReset(); // Only returns on fail
78+
ArduinoOTA.eraseConfigAndReset(); // Only returns on fail
7979
DEBUG_PRINTF(" ArduinoOTA.eraseConfigAndReset() failed!\r\n");
8080

8181
} else {

0 commit comments

Comments
 (0)