diff --git a/lib/esp32FOTA/src/esp32fota.cpp b/lib/esp32FOTA/src/esp32fota.cpp index 51b8c7b..dd0b118 100644 --- a/lib/esp32FOTA/src/esp32fota.cpp +++ b/lib/esp32FOTA/src/esp32fota.cpp @@ -25,10 +25,11 @@ extern void forceBootInit(); #define USE_QUEUE -esp32FOTA::esp32FOTA(String firwmareType, int firwmareVersion) +esp32FOTA::esp32FOTA(String firwmareType, int firwmareVersion, bool isBeta) { _firwmareType = firwmareType; _firwmareVersion = firwmareVersion; + _bIsBeta = isBeta; useDeviceID = false; // _endCallback = NULL; _queue = xQueueCreate(1, 256); @@ -254,6 +255,7 @@ esp32FOTA::execHTTPcheck() delete[] JSONMessage; Serial.println("Parsing failed"); delay(5000); + http.end(); //Free the resources return false; } @@ -273,23 +275,43 @@ esp32FOTA::execHTTPcheck() delete[] JSONMessage; - if (plversion > _firwmareVersion && fwtype == _firwmareType) - { - _newVersion = plversion; - return true; + if(fwtype == _firwmareType) { + if(_bIsBeta) { // if beta version being used, check for equal version number + if (plversion >= _firwmareVersion) + { + _newVersion = plversion; + http.end(); //Free the resources + return true; + } + } + else { + if (plversion > _firwmareVersion) + { + _newVersion = plversion; + http.end(); //Free the resources + return true; + } + } } - else - { - _newVersion = 0; - return false; - } - + _newVersion = 0; + + // if (plversion > _firwmareVersion && fwtype == _firwmareType) + // { + // _newVersion = plversion; + // return true; + // } + // else + // { + // _newVersion = 0; + // return false; + // } + } else { Serial.println("Error on HTTP request"); - return false; + // return false; } http.end(); //Free the resources @@ -454,16 +476,35 @@ esp32FOTA::decodeResponse(char* resp) _bin = plbin; - if (plversion > _firwmareVersion && fwtype == _firwmareType) - { - _newVersion = plversion; - return true; - } - else - { - _newVersion = 0; - return false; + if(fwtype == _firwmareType) { + if(_bIsBeta) { // if beta version being used, check for equal version number + if (plversion >= _firwmareVersion) + { + _newVersion = plversion; + return true; + } + } + else { + if (plversion > _firwmareVersion) + { + _newVersion = plversion; + return true; + } + } } + _newVersion = 0; + return false; + + // if (plversion > _firwmareVersion && fwtype == _firwmareType) + // { + // _newVersion = plversion; + // return true; + // } + // else + // { + // _newVersion = 0; + // return false; + // } } void diff --git a/lib/esp32FOTA/src/esp32fota.h b/lib/esp32FOTA/src/esp32fota.h index b6bdbca..a51c9f1 100644 --- a/lib/esp32FOTA/src/esp32fota.h +++ b/lib/esp32FOTA/src/esp32fota.h @@ -26,7 +26,7 @@ struct sFOTAqueue{ class esp32FOTA { public: - esp32FOTA(String firwmareType, int firwmareVersion); + esp32FOTA(String firwmareType, int firwmareVersion, bool isBeta); void execOTA(); bool execHTTPcheck(); bool useDeviceID; @@ -50,6 +50,7 @@ private: String _firwmareType; int _firwmareVersion; int _newVersion; + bool _bIsBeta; String _checkURL; String _host; String _bin; diff --git a/src/Afterburner.cpp b/src/Afterburner.cpp index afe0580..3cf6e00 100644 --- a/src/Afterburner.cpp +++ b/src/Afterburner.cpp @@ -134,7 +134,7 @@ const int FirmwareRevision = 32; const int FirmwareSubRevision = 1; -const int FirmwareMinorRevision = ; +const int FirmwareMinorRevision = 1; // used for beta version - zero for releases const char* FirmwareDate = "19 Jun 2020"; /* @@ -1174,9 +1174,12 @@ bool getGPIOout(int channel) #endif } -float getVersion() +float getVersion(bool betarevision) { - return float(FirmwareRevision) * 0.1f + float(FirmwareSubRevision) * .001f; + if(betarevision) + return float(FirmwareMinorRevision); + else + return float(FirmwareRevision) * 0.1f + float(FirmwareSubRevision) * .001f; } const char* getVersionStr(bool beta) { diff --git a/src/OLED/433MHzScreen.cpp b/src/OLED/433MHzScreen.cpp index aef18c0..fceff14 100644 --- a/src/OLED/433MHzScreen.cpp +++ b/src/OLED/433MHzScreen.cpp @@ -46,14 +46,13 @@ C433MHzScreen::C433MHzScreen(C128x64_OLED& display, CScreenManager& mgr) : CUIEd _initUI(); } -bool +void C433MHzScreen::onSelect() { CScreen::onSelect(); _initUI(); pair433MHz = true; UHFremote.getCodes(_rawCodes); - return true; } void diff --git a/src/OLED/433MHzScreen.h b/src/OLED/433MHzScreen.h index 8c5bd41..954fa06 100644 --- a/src/OLED/433MHzScreen.h +++ b/src/OLED/433MHzScreen.h @@ -44,7 +44,7 @@ class C433MHzScreen : public CUIEditScreen { uint8_t _repeatCount; public: C433MHzScreen(C128x64_OLED& display, CScreenManager& mgr); - bool onSelect(); + void onSelect(); void onExit(); bool show(); bool animate(); diff --git a/src/OLED/VersionInfoScreen.cpp b/src/OLED/VersionInfoScreen.cpp index 3c9d839..844b464 100644 --- a/src/OLED/VersionInfoScreen.cpp +++ b/src/OLED/VersionInfoScreen.cpp @@ -156,26 +156,22 @@ CVersionInfoScreen::animate() // show ascending up arrow if firmware update is available on web server _animateCount++; WRAPUPPERLIMIT(_animateCount, 3, 0); -/* int ypos = 11 + 16 - 7 - _animateCount; - _display.fillRect(0, 11, 10, 21, BLACK); - _display.drawBitmap(2, ypos, WifiOutIconInfo.pBitmap, WifiOutIconInfo.width, 7, WHITE); // upload arrow - from web to afterburner - _display.fillRect(1, 12, 7, 2, WHITE); // top bar - _drawBitmap(0, 11+17, WWWIconInfo); // www icon*/ int newVer = isUpdateAvailable(); if((_animateCount & 0x02) && newVer) { - char msg[32]; - int major = (int)(newVer * 0.01); - int minor = newVer - major*100; - float prtMajor = major * 0.1; - sprintf(msg, "V%.1f.%d", prtMajor, minor); - _printMenuText(128, 15, msg, false, eRightJustify); + _display.setTextColor(WHITE); _drawBitmap(118, 24, UpdateIconInfo); } else { - _display.fillRect(82, 15, 46, 7, BLACK); + _display.setTextColor(BLACK); _display.fillRect(118, 24, 9, 10, BLACK); } + char msg[32]; + int major = (int)(newVer * 0.01); + int minor = newVer - major*100; + float prtMajor = major * 0.1; + sprintf(msg, "V%.1f.%d", prtMajor, minor); + _printMenuText(128, 15, msg, false, eRightJustify); } return true; } diff --git a/src/Utility/helpers.h b/src/Utility/helpers.h index 1b14b7a..d7e6141 100644 --- a/src/Utility/helpers.h +++ b/src/Utility/helpers.h @@ -49,7 +49,7 @@ extern bool hasHtrData(); extern int getBlueWireStat(); extern int getSmartError(); extern bool isCyclicStopStartActive(); -extern float getVersion(); +extern float getVersion(bool betarevision = false); const char* getVersionStr(bool beta=false); extern const char* getVersionDate(); extern int getBoardRevision(); diff --git a/src/WiFi/BTCota.cpp b/src/WiFi/BTCota.cpp index 74ffc47..26a47d8 100644 --- a/src/WiFi/BTCota.cpp +++ b/src/WiFi/BTCota.cpp @@ -38,7 +38,7 @@ bool CheckFirmwareCRC(int filesize); void onSuccess(); void onWebProgress(size_t progress, size_t total); -esp32FOTA FOTA("afterburner-fota-http", int(getVersion()*1000)); +esp32FOTA FOTA("afterburner-fota-http", int(getVersion()*1000), getVersion(true) != 0 ? true : false); unsigned long FOTAtime = millis() + 60000; // initial check in a minutes time int FOTAauth = 0;