Browse Source

fix ESP32 build

pull/425/head^2
lumapu 2 years ago
parent
commit
da04d3ff73
  1. 38
      src/config/settings.h
  2. 29
      src/wifi/ahoywifi.cpp

38
src/config/settings.h

@ -107,15 +107,21 @@ class settings {
DPRINTLN(DBG_INFO, F("Initializing FS ..")); DPRINTLN(DBG_INFO, F("Initializing FS .."));
mValid = false; mValid = false;
#if !defined(ESP32)
LittleFSConfig cfg; LittleFSConfig cfg;
cfg.setAutoFormat(false); cfg.setAutoFormat(false);
LittleFS.setConfig(cfg); LittleFS.setConfig(cfg);
#define LITTLFS_TRUE
if(!LittleFS.begin()) { #define LITTLFS_FALSE
#else
#define LITTLFS_TRUE true
#define LITTLFS_FALSE false
#endif
if(!LittleFS.begin(LITTLFS_FALSE)) {
DPRINTLN(DBG_INFO, F(".. format ..")); DPRINTLN(DBG_INFO, F(".. format .."));
LittleFS.format(); LittleFS.format();
if(LittleFS.begin()) if(LittleFS.begin(LITTLFS_TRUE))
DPRINTLN(DBG_INFO, F(".. success")); DPRINTLN(DBG_INFO, F(".. success"));
else else
DPRINTLN(DBG_INFO, F(".. failed")); DPRINTLN(DBG_INFO, F(".. failed"));
@ -142,13 +148,17 @@ class settings {
} }
void getInfo(uint32_t *used, uint32_t *size) { void getInfo(uint32_t *used, uint32_t *size) {
FSInfo info; #if !defined(ESP32)
LittleFS.info(info); FSInfo info;
*used = info.usedBytes; LittleFS.info(info);
*size = info.totalBytes; *used = info.usedBytes;
*size = info.totalBytes;
DPRINTLN(DBG_INFO, F("-- FILESYSTEM INFO --"));
DPRINTLN(DBG_INFO, String(info.usedBytes) + F(" of ") + String(info.totalBytes) + F(" used")); DPRINTLN(DBG_INFO, F("-- FILESYSTEM INFO --"));
DPRINTLN(DBG_INFO, String(info.usedBytes) + F(" of ") + String(info.totalBytes) + F(" used"));
#else
DPRINTLN(DBG_WARN, F("not supported by ESP32"));
#endif
} }
void readSettings(void) { void readSettings(void) {

29
src/wifi/ahoywifi.cpp

@ -87,8 +87,11 @@ bool ahoywifi::loop(void) {
DPRINTLN(DBG_INFO, String(cnt) + F(" client connected (no timeout)")); DPRINTLN(DBG_INFO, String(cnt) + F(" client connected (no timeout)"));
mNextTryTs = (millis() + (WIFI_AP_ACTIVE_TIME * 1000)); mNextTryTs = (millis() + (WIFI_AP_ACTIVE_TIME * 1000));
} }
else else {
DPRINTLN(DBG_INFO, F("AP will be closed in ") + String((mNextTryTs - mApLastTick) / 1000) + F(" seconds")); DBGPRINT(F("AP will be closed in "));
DBGPRINT(String((mNextTryTs - mApLastTick) / 1000));
DBGPRINTLN(F(" seconds"));
}
} }
} }
#endif #endif
@ -110,12 +113,14 @@ void ahoywifi::setupAp(const char *ssid, const char *pwd) {
DPRINTLN(DBG_VERBOSE, F("app::setupAp")); DPRINTLN(DBG_VERBOSE, F("app::setupAp"));
IPAddress apIp(192, 168, 4, 1); IPAddress apIp(192, 168, 4, 1);
DPRINTLN(DBG_INFO, F("\n---------\nAP MODE\nSSID: ") DBGPRINT(F("\n---------\nAP MODE\nSSID: "));
+ String(ssid) + F("\nPWD: ") DBGPRINTLN(ssid);
+ String(pwd) + F("\nActive for: ") DBGPRINT(F("PWD: "));
+ String(WIFI_AP_ACTIVE_TIME) + F(" seconds") DBGPRINTLN(pwd);
+ F("\n---------\n")); DBGPRINT(F("\nActive for: "));
DPRINTLN(DBG_DEBUG, String(mNextTryTs)); DBGPRINT(String(WIFI_AP_ACTIVE_TIME));
DBGPRINTLN(F(" seconds"));
DBGPRINTLN(F("\n---------\n"));
WiFi.mode(WIFI_AP); WiFi.mode(WIFI_AP);
WiFi.softAPConfig(apIp, apIp, IPAddress(255, 255, 255, 0)); WiFi.softAPConfig(apIp, apIp, IPAddress(255, 255, 255, 0));
@ -153,13 +158,15 @@ bool ahoywifi::setupStation(uint32_t timeout) {
WiFi.hostname(mConfig->sys.deviceName); WiFi.hostname(mConfig->sys.deviceName);
delay(2000); delay(2000);
DPRINTLN(DBG_INFO, F("connect to network '") + String(mConfig->sys.stationSsid) + F("' ...")); DBGPRINT(F("connect to network '"));
DBGPRINT(mConfig->sys.stationSsid);
DBGPRINTLN(F("' ..."));
while (WiFi.status() != WL_CONNECTED) { while (WiFi.status() != WL_CONNECTED) {
delay(100); delay(100);
if(cnt % 40 == 0) if(cnt % 40 == 0)
Serial.println("."); DBGPRINTLN(".");
else else
Serial.print("."); DBGPRINT(".");
if(timeout > 0) { // limit == 0 -> no limit if(timeout > 0) { // limit == 0 -> no limit
if(--cnt <= 0) { if(--cnt <= 0) {

Loading…
Cancel
Save