Skip to content

Commit

Permalink
Merge pull request #464 from doudar/Update_fixes
Browse files Browse the repository at this point in the history
Fixed OTA Updates
  • Loading branch information
doudar committed Apr 24, 2023
2 parents 5df02f0 + 406fec1 commit d4a83dc
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 25 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Simplified Platform Packages to work better with newest version of PlatformIO.
- Fixed broken images in wiki.
- Valid files displayed on OTA page.
- Increased heap for more reliable OTA updates.
### Hardware
- tweaks to echelon bike mount
- Revised an old shifter cover for more options.
Expand Down
2 changes: 1 addition & 1 deletion include/SS2KLog.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#define LOG_HANDLER_TAG "Log_Handler"

#ifndef DEBUG_LOG_BUFFER_SIZE
#define DEBUG_LOG_BUFFER_SIZE 2000
#define DEBUG_LOG_BUFFER_SIZE 600
#endif

#ifndef DEBUG_FILE_CHARS_PER_LINE
Expand Down
2 changes: 1 addition & 1 deletion src/BLE_Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ void SpinBLEClient::checkBLEReconnect() {
if (scan) {
if (!NimBLEDevice::getScan()->isScanning()) {
spinBLEClient.scanProcess(BLE_RECONNECT_SCAN_DURATION);
Serial.println("scan");
//Serial.println("scan");
}
}
}
Expand Down
30 changes: 15 additions & 15 deletions src/HTTP_Server_Basic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -745,22 +745,22 @@ void HTTP_Server::FirmwareUpdate() {

//////// Update Firmware /////////
SS2K_LOG(HTTP_SERVER_LOG_TAG, "Updating Firmware...Please Wait");
if ((availableVer > currentVer) && (userConfig.getAutoUpdate())) {
t_httpUpdate_return ret = httpUpdate.update(client, userConfig.getFirmwareUpdateURL() + String(FW_BINFILE));
switch (ret) {
case HTTP_UPDATE_FAILED:
SS2K_LOG(HTTP_SERVER_LOG_TAG, "HTTP_UPDATE_FAILED Error %d : %s", httpUpdate.getLastError(), httpUpdate.getLastErrorString().c_str());
break;

case HTTP_UPDATE_NO_UPDATES:
SS2K_LOG(HTTP_SERVER_LOG_TAG, "HTTP_UPDATE_NO_UPDATES");
break;

case HTTP_UPDATE_OK:
SS2K_LOG(HTTP_SERVER_LOG_TAG, "HTTP_UPDATE_OK");
break;
if (((availableVer > currentVer) || updateAnyway) && (userConfig.getAutoUpdate())) {
t_httpUpdate_return ret = httpUpdate.update(client, userConfig.getFirmwareUpdateURL() + String(FW_BINFILE));
switch (ret) {
case HTTP_UPDATE_FAILED:
SS2K_LOG(HTTP_SERVER_LOG_TAG, "HTTP_UPDATE_FAILED Error %d : %s", httpUpdate.getLastError(), httpUpdate.getLastErrorString().c_str());
break;

case HTTP_UPDATE_NO_UPDATES:
SS2K_LOG(HTTP_SERVER_LOG_TAG, "HTTP_UPDATE_NO_UPDATES");
break;

case HTTP_UPDATE_OK:
SS2K_LOG(HTTP_SERVER_LOG_TAG, "HTTP_UPDATE_OK");
break;
}
}
}
} else { // don't update
SS2K_LOG(HTTP_SERVER_LOG_TAG, " - Current Version: %s", FIRMWARE_VERSION);
}
Expand Down
15 changes: 7 additions & 8 deletions src/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ void setup() {
userPWC.printFile();
userPWC.saveToLittleFS();

// Check for firmware update. It's important that this stays before BLE &
// HTTP setup because otherwise they use too much traffic and the device
// fails to update which really sucks when it corrupts your settings.
startWifi();
httpServer.FirmwareUpdate();

pinMode(currentBoard.shiftUpPin, INPUT_PULLUP); // Push-Button with input Pullup
pinMode(currentBoard.shiftDownPin, INPUT_PULLUP); // Push-Button with input Pullup
pinMode(LED_PIN, OUTPUT);
Expand Down Expand Up @@ -152,18 +158,11 @@ void setup() {

digitalWrite(LED_PIN, HIGH);

startWifi();

// Configure and Initialize Logger
logHandler.addAppender(&webSocketAppender);
logHandler.addAppender(&udpAppender);
logHandler.initialize();

// Check for firmware update. It's important that this stays before BLE &
// HTTP setup because otherwise they use too much traffic and the device
// fails to update which really sucks when it corrupts your settings.

httpServer.FirmwareUpdate();
ss2k.startTasks();
httpServer.start();

Expand Down Expand Up @@ -202,7 +201,7 @@ void SS2K::maintenanceLoop(void *pvParameters) {
}

if ((millis() - intervalTimer) > 2003) { // add check here for when to restart WiFi
// maybe if in STA mode and 8.8.8.8 no ping return?
// maybe if in STA mode and 8.8.8.8 no ping return?
// ss2k.restartWifi();
logHandler.writeLogs();
webSocketAppender.Loop();
Expand Down

0 comments on commit d4a83dc

Please sign in to comment.