Skip to content
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

Updates to get OTA to work again #746

Merged
merged 4 commits into from
Mar 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions ESPixelStick/src/EFUpdate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ void EFUpdate::begin() {
_state = State::HEADER;
_loc = 0;
_error = EFUPDATE_ERROR_OK;
Update.onProgress(
[this] (size_t progress, size_t total)
{
LOG_PORT.println(String("\033[Fprogress: ") + String(progress));
}
);
// DEBUG_END;
}

Expand All @@ -71,7 +77,7 @@ bool EFUpdate::process(uint8_t *data, uint32_t len) {
_loc = 0;
_state = State::RECORD;
} else {
// DEBUG_V ();
logcon ("FAIL: EFUPDATE_ERROR_SIG");
_state = State::FAIL;
_error = EFUPDATE_ERROR_SIG;
}
Expand All @@ -89,10 +95,10 @@ bool EFUpdate::process(uint8_t *data, uint32_t len) {
// DEBUG_V (String("_record.type: ") + uint32_t(_record.type));
// DEBUG_V (String("_record.size: ") + _record.size);
if (_record.type == RecordType::SKETCH_IMAGE) {
logcon ("Starting Sketch Image");
logcon ("Starting Sketch Image Update\n");
// Begin sketch update
if (!Update.begin(_record.size, U_FLASH)) {
// DEBUG_V ("Update.begin FAIL");
logcon ("Update.begin FAIL");
_state = State::FAIL;
_error = Update.getError();
} else {
Expand All @@ -104,14 +110,14 @@ bool EFUpdate::process(uint8_t *data, uint32_t len) {
#endif
// DEBUG_V ();
} else if (_record.type == RecordType::FS_IMAGE) {
logcon ("Starting FS IMAGE");
// Begin file system update
logcon ("Starting update of FS IMAGE\n");
// DEBUG_V("Begin file system update");
#ifdef ARDUINO_ARCH_ESP8266
LittleFS.end();
#endif
// DEBUG_V ();
if (!Update.begin(_record.size, U_SPIFFS)) {
// DEBUG_V ("begin U_SPIFFS failed");
logcon ("begin U_SPIFFS failed");
_state = State::FAIL;
_error = Update.getError();
// DEBUG_V ();
Expand Down Expand Up @@ -157,7 +163,7 @@ bool EFUpdate::process(uint8_t *data, uint32_t len) {
break;

case State::FAIL:
// DEBUG_V ("FAIL");
// DEBUG_V ("Enter FAIL state");
index = len;
ConfigChanged = false;
break;
Expand Down
32 changes: 11 additions & 21 deletions ESPixelStick/src/WebMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ void c_WebMgr::init ()
RequestReboot(100000);;
},
[](AsyncWebServerRequest* request, String filename, uint32_t index, uint8_t* data, uint32_t len, bool final)
{WebMgr.FirmwareUpload (request, filename, index, data, len, final); }).setFilter (ON_STA_FILTER);
{WebMgr.FirmwareUpload (request, filename, index, data, len, final); }); //.setFilter (ON_STA_FILTER);

// URL's needed for FPP Connect fseq uploading and querying
webServer.on ("/fpp", HTTP_GET,
Expand Down Expand Up @@ -710,15 +710,11 @@ void c_WebMgr::FirmwareUpload (AsyncWebServerRequest* request,

do // once
{
// make sure we are in AP mode
if (0 == WiFi.softAPgetStationNum ())
{
// DEBUG_V("Not in AP Mode");

// we are not talking to a station so we are not in AP mode
// break;
}
// DEBUG_V ("In AP Mode");
// DEBUG_V (String (" file: '") + filename + "'");
// DEBUG_V (String ("index: ") + String (index));
// DEBUG_V (String (" data: 0x") + String (uint32_t(data), HEX));
// DEBUG_V (String (" len: ") + String (len));
// DEBUG_V (String ("final: ") + String (final));

// is the first message in the upload?
if (0 == index)
Expand All @@ -733,30 +729,24 @@ void c_WebMgr::FirmwareUpload (AsyncWebServerRequest* request,
}

// DEBUG_V ("Sending data to efupdate");
// DEBUG_V (String ("data: 0x") + String (uint32(data), HEX));
// DEBUG_V (String (" len: ") + String (len));

if (!efupdate.process (data, len))
{
logcon (String(CN_stars) + F (" UPDATE ERROR: ") + String (efupdate.getError ()));
}
efupdate.process (data, len);
// DEBUG_V ("Packet has been processed");

if (efupdate.hasError ())
{
// DEBUG_V ("efupdate.hasError");
logcon (String(CN_stars) + F (" UPDATE ERROR: ") + String (efupdate.getError ()));
DEBUG_V ("efupdate.hasError");
request->send (200, CN_textSLASHplain, (String (F ("Update Error: ")) + String (efupdate.getError ()).c_str()));
break;
}
// DEBUG_V ("No Error");
// DEBUG_V ("No EFUpdate Error");

if (final)
{
request->send (200, CN_textSLASHplain, (String ( F ("Update Finished: ")) + String (efupdate.getError ())).c_str());
logcon (F ("Upload Finished."));
logcon (F ("Upload Finished. Rebooting"));
efupdate.end ();
// LittleFS.begin ();

RequestReboot(100000);;
}

Expand Down
18 changes: 13 additions & 5 deletions ESPixelStick/src/network/WiFiDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
#endif // __has_include("secrets.h")

#if !defined(SECRETS_SSID)
# define SECRETS_SSID "DEFAULT_SSID_NOT_SET"
# define SECRETS_SSID DEFAULT_SSID_NOT_SET
#endif // SECRETS_SSID
#if !defined(SECRETS_PASS)
# define SECRETS_PASS "DEFAULT_PASSPHRASE_NOT_SET"
Expand Down Expand Up @@ -753,11 +753,19 @@ void fsm_WiFi_state_ConnectingUsingDefaults::Init ()
// DEBUG_START;

// DEBUG_V (String ("this: ") + String (uint32_t (this), HEX));
pWiFiDriver->SetFsmState (this);
pWiFiDriver->AnnounceState ();
pWiFiDriver->GetFsmTimer().StartTimer(1000 * pWiFiDriver->Get_sta_timeout ());

pWiFiDriver->connectWifi (default_ssid, default_passphrase);
if(!default_ssid.equals(DEFAULT_SSID_NOT_SET))
{
pWiFiDriver->SetFsmState (this);
pWiFiDriver->AnnounceState ();
pWiFiDriver->GetFsmTimer().StartTimer(1000 * pWiFiDriver->Get_sta_timeout ());
pWiFiDriver->connectWifi (default_ssid, default_passphrase);
}
else
{
// no defauult ssid was set at compile time. Just move on to AP mode
fsm_WiFi_state_ConnectingAsAP_imp.Init ();
}
// pWiFiDriver->displayFsmState ();

// DEBUG_END;
Expand Down
2 changes: 1 addition & 1 deletion ESPixelStick/src/network/WiFiDriver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class c_WiFiDriver
void Enable ();

private:

#define DEFAULT_SSID_NOT_SET "DEFAULT_SSID_NOT_SET"
int ValidateConfig ();

#ifdef ARDUINO_ARCH_ESP8266
Expand Down
8 changes: 5 additions & 3 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ lib_ignore =
; https://docs.platformio.org/en/latest/platforms/espressif8266.html ;
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;
[esp8266]
; platform = espressif8266 @ 4.2.1 ; Arduino Core v3.0.2
platform = espressif8266 @ 4.0.1 ; Arduino Core v3.0.2
board_build.f_cpu = 160000000L
board_build.filesystem = littlefs
Expand Down Expand Up @@ -106,10 +107,11 @@ extends = esp32
build_flags = ${esp32.build_flags} -mtext-section-literals
; platform = https://github.com/platformio/platform-espressif32.git#48c4226e5240c873dae6b28adbb93ad8ca582b5d
; platform = https://github.com/platformio/platform-espressif32.git#eb7eba4 ; unstable 6.3.2
platform = https://github.com/platformio/platform-espressif32.git#8100ac5 ; works 6.3.1
platform_packages =
; platform = https://github.com/platformio/platform-espressif32.git#8100ac5 ; works 6.3.1
platform = https://github.com/platformio/platform-espressif32.git#b0a7f56bcde9fa332b40111b1423482d8f7cbc77 ; 6.5.0
; platform_packages =
; framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#2.0.11 ; uses a lot of ram
framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#2.0.3 ;
; framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#2.0.3 ;
; framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#2.0.2 ; runs real slow
; framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#2.0.1 ; Has general issues
; framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#2.0.0 ; SD card not stable on cam card
Expand Down