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

WiFi events and delay(0) during write SPIFFS #2042

Merged
merged 3 commits into from
Nov 11, 2018
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
2 changes: 1 addition & 1 deletion src/ESPEasy.ino
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ void loop()
WiFiConnectRelaxed();
wifiSetupConnect = false;
}
if (wifiStatus != ESPEASY_WIFI_SERVICES_INITIALIZED) {
if (wifiStatus != ESPEASY_WIFI_SERVICES_INITIALIZED || unprocessedWifiEvents()) {
// WiFi connection is not yet available, so introduce some extra delays to
// help the background tasks managing wifi connections
delay(1);
Expand Down
9 changes: 7 additions & 2 deletions src/ESPEasyStorage.ino
Original file line number Diff line number Diff line change
Expand Up @@ -596,9 +596,14 @@ String SaveToFile(char* fname, int index, byte* memAddress, int datasize)
{
SPIFFS_CHECK(f.write(*pointerToByteToSave), fname);
pointerToByteToSave++;
if (timeOutReached(timer)) {
if (x % 256 == 0) {
// one page written, do some background tasks
timer = millis() + 50;
delay(0);
}
if (timeOutReached(timer) ) {
timer += 50;
delay(1);
delay(0);
}
}
f.close();
Expand Down
7 changes: 6 additions & 1 deletion src/ESPEasyWifi.ino
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@

#define WIFI_AP_OFF_TIMER_DURATION 60000 // in milliSeconds

bool unprocessedWifiEvents() {
if (processedConnect && processedGetIP && processedDisconnect) return false;
return true;
}

//********************************************************************************
// Functions to process the data gathered from the events.
// These functions are called from Setup() or Loop() and thus may call delay() or yield()
Expand Down Expand Up @@ -488,7 +493,7 @@ bool prepareWiFi() {
}
setSTA(true);
char hostname[40];
strncpy(hostname, WifiGetHostname().c_str(), sizeof(hostname));
safe_strncpy(hostname, WifiGetHostname().c_str(), sizeof(hostname));
#if defined(ESP8266)
wifi_station_set_hostname(hostname);
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/Misc.ino
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ String formatGpioName_output_optional(const String& label) {
}

// RX/TX are the only signals which are crossed, so they must be labelled like this:
// "GPIO <-- RX" and "GPIO <-- TX"
// "GPIO <-- TX" and "GPIO --> RX"
String formatGpioName_TX(bool optional) {
return formatGpioName("RX", gpio_output, optional);
}
Expand Down