-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Correct OTA process message show on display #137
Changes from all commits
ed02f66
c04ab90
6e54409
6ea0ab9
65e759f
11ecea1
ef6b041
14b152a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -219,6 +219,7 @@ void setup() { | |
#ifdef ESP8266 | ||
// ota not supported | ||
#else | ||
otaHandler.setHandlerCallback(otaHandlerCallback); | ||
otaHandler.updateFirmwareIfOutdated(ag->deviceId()); | ||
|
||
/** Update first OTA */ | ||
|
@@ -489,6 +490,7 @@ static bool sgp41Init(void) { | |
} | ||
|
||
static void otaHandlerCallback(OtaState state, String mesasge) { | ||
Serial.println("OTA message: " + mesasge); | ||
switch (state) { | ||
case OtaState::OTA_STATE_BEGIN: | ||
displayExecuteOta(state, fwNewVersion, 0); | ||
|
@@ -511,7 +513,7 @@ static void displayExecuteOta(OtaState state, String msg, int processing) { | |
switch (state) { | ||
case OtaState::OTA_STATE_BEGIN: { | ||
if (ag->isOne()) { | ||
oledDisplay.showNewFirmwareVersion(msg); | ||
oledDisplay.showFirmwareUpdateVersion(msg); | ||
} else { | ||
Serial.println("New firmware: " + msg); | ||
} | ||
|
@@ -520,17 +522,37 @@ static void displayExecuteOta(OtaState state, String msg, int processing) { | |
} | ||
case OtaState::OTA_STATE_FAIL: { | ||
if (ag->isOne()) { | ||
oledDisplay.showNewFirmwareFailed(); | ||
oledDisplay.showFirmwareUpdateFailed(); | ||
} else { | ||
Serial.println("Error: Firmware update: failed"); | ||
} | ||
|
||
delay(2500); | ||
break; | ||
} | ||
case OtaState::OTA_STATE_SKIP: { | ||
if (ag->isOne()) { | ||
oledDisplay.showFirmwareUpdateSkipped(); | ||
} else { | ||
Serial.println("Firmware update: Skipped"); | ||
} | ||
|
||
delay(2500); | ||
break; | ||
} | ||
case OtaState::OTA_STATE_UP_TO_DATE: { | ||
if (ag->isOne()) { | ||
oledDisplay.showFirmwareUpdateUpToDate(); | ||
} else { | ||
Serial.println("Firmware update: up to date"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Propose to rephrase to |
||
} | ||
|
||
delay(2500); | ||
break; | ||
} | ||
case OtaState::OTA_STATE_PROCESSING: { | ||
if (ag->isOne()) { | ||
oledDisplay.showNewFirmwareUpdating(String(processing)); | ||
oledDisplay.showFirmwareUpdateProgress(processing); | ||
} else { | ||
Serial.println("Firmware update: " + String(processing) + String("%")); | ||
} | ||
|
@@ -546,13 +568,14 @@ static void displayExecuteOta(OtaState state, String msg, int processing) { | |
while (i != 0) { | ||
i = i - 1; | ||
if (ag->isOne()) { | ||
oledDisplay.showNewFirmwareSuccess(String(i)); | ||
oledDisplay.showFirmwareUpdateSuccess(i); | ||
} else { | ||
Serial.println("Rebooting... " + String(i)); | ||
} | ||
|
||
delay(1000); | ||
} | ||
oledDisplay.setBrightness(0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Curious to know, what happens without this line? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This like will be clear all display content while reboot device. If not the display still Show "Firmware update success" while rebooting |
||
esp_restart(); | ||
} | ||
break; | ||
|
@@ -884,7 +907,7 @@ static void configUpdateHandle() { | |
fwNewVersion = configuration.newFirmwareVersion(); | ||
if (fwNewVersion.length()) { | ||
bool doOta = false; | ||
if (measurements.otaBootCount == 0) { | ||
if (measurements.otaBootCount < 0) { | ||
doOta = true; | ||
Serial.println("First OTA"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the message is misleading, the device might have gone through several OTA updates when we arrive here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's indicate first OTA check. If it's zero and process failed, retry will call for 3-4 times (Because we check cloud configure each 15sec). < 0 should help, that mean the otaBootCount is invalid, after first check it's set to bootCount |
||
} else { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -330,7 +330,7 @@ void OledDisplay::setBrightness(int percent) { | |
} | ||
} | ||
|
||
void OledDisplay::showNewFirmwareVersion(String version) { | ||
void OledDisplay::showFirmwareUpdateVersion(String version) { | ||
if (isDisplayOff) { | ||
return; | ||
} | ||
|
@@ -344,7 +344,7 @@ void OledDisplay::showNewFirmwareVersion(String version) { | |
} while (DISP()->nextPage()); | ||
} | ||
|
||
void OledDisplay::showNewFirmwareUpdating(String percent) { | ||
void OledDisplay::showFirmwareUpdateProgress(int percent) { | ||
if (isDisplayOff) { | ||
return; | ||
} | ||
|
@@ -353,11 +353,11 @@ void OledDisplay::showNewFirmwareUpdating(String percent) { | |
do { | ||
DISP()->setFont(u8g2_font_t0_16_tf); | ||
setCentralText(20, "Firmware Update"); | ||
setCentralText(50, String("Updating... ") + percent + String("%")); | ||
setCentralText(50, String("Updating... ") + String(percent) + String("%")); | ||
} while (DISP()->nextPage()); | ||
} | ||
|
||
void OledDisplay::showNewFirmwareSuccess(String count) { | ||
void OledDisplay::showFirmwareUpdateSuccess(int count) { | ||
if (isDisplayOff) { | ||
return; | ||
} | ||
|
@@ -367,11 +367,11 @@ void OledDisplay::showNewFirmwareSuccess(String count) { | |
DISP()->setFont(u8g2_font_t0_16_tf); | ||
setCentralText(20, "Firmware Update"); | ||
setCentralText(40, "Success"); | ||
setCentralText(60, String("Rebooting... ") + count); | ||
setCentralText(60, String("Rebooting... ") + String(count)); | ||
} while (DISP()->nextPage()); | ||
} | ||
|
||
void OledDisplay::showNewFirmwareFailed(void) { | ||
void OledDisplay::showFirmwareUpdateFailed(void) { | ||
if (isDisplayOff) { | ||
return; | ||
} | ||
|
@@ -380,8 +380,34 @@ void OledDisplay::showNewFirmwareFailed(void) { | |
do { | ||
DISP()->setFont(u8g2_font_t0_16_tf); | ||
setCentralText(20, "Firmware Update"); | ||
setCentralText(40, "Failed"); | ||
setCentralText(60, String("Retry after 24h")); | ||
setCentralText(40, "fail, will retry"); | ||
// setCentralText(60, "will retry"); | ||
} while (DISP()->nextPage()); | ||
} | ||
|
||
void OledDisplay::showFirmwareUpdateSkipped(void) { | ||
if (isDisplayOff) { | ||
return; | ||
} | ||
|
||
DISP()->firstPage(); | ||
do { | ||
DISP()->setFont(u8g2_font_t0_16_tf); | ||
setCentralText(20, "Firmware Update"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Propose to rephrase to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If it's fit for a line we should reduce the font size. |
||
setCentralText(40, "skipped"); | ||
} while (DISP()->nextPage()); | ||
} | ||
|
||
void OledDisplay::showFirmwareUpdateUpToDate(void) { | ||
if (isDisplayOff) { | ||
return; | ||
} | ||
|
||
DISP()->firstPage(); | ||
do { | ||
DISP()->setFont(u8g2_font_t0_16_tf); | ||
setCentralText(20, "Firmware Update"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The term Update is redundant this way, propose to make it a sentence and say Firmware |
||
setCentralText(40, "up to date"); | ||
} while (DISP()->nextPage()); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Propose to rephrase to
Firmware update skipped