mirror of
https://github.com/lumapu/ahoy.git
synced 2025-05-25 14:56:11 +02:00
fix ESP32 build
This commit is contained in:
parent
72652f5a2c
commit
da04d3ff73
2 changed files with 40 additions and 23 deletions
|
@ -107,15 +107,21 @@ class settings {
|
|||
DPRINTLN(DBG_INFO, F("Initializing FS .."));
|
||||
|
||||
mValid = false;
|
||||
|
||||
#if !defined(ESP32)
|
||||
LittleFSConfig cfg;
|
||||
cfg.setAutoFormat(false);
|
||||
LittleFS.setConfig(cfg);
|
||||
#define LITTLFS_TRUE
|
||||
#define LITTLFS_FALSE
|
||||
#else
|
||||
#define LITTLFS_TRUE true
|
||||
#define LITTLFS_FALSE false
|
||||
#endif
|
||||
|
||||
if(!LittleFS.begin()) {
|
||||
if(!LittleFS.begin(LITTLFS_FALSE)) {
|
||||
DPRINTLN(DBG_INFO, F(".. format .."));
|
||||
LittleFS.format();
|
||||
if(LittleFS.begin())
|
||||
if(LittleFS.begin(LITTLFS_TRUE))
|
||||
DPRINTLN(DBG_INFO, F(".. success"));
|
||||
else
|
||||
DPRINTLN(DBG_INFO, F(".. failed"));
|
||||
|
@ -142,6 +148,7 @@ class settings {
|
|||
}
|
||||
|
||||
void getInfo(uint32_t *used, uint32_t *size) {
|
||||
#if !defined(ESP32)
|
||||
FSInfo info;
|
||||
LittleFS.info(info);
|
||||
*used = info.usedBytes;
|
||||
|
@ -149,6 +156,9 @@ class settings {
|
|||
|
||||
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) {
|
||||
|
|
|
@ -87,8 +87,11 @@ bool ahoywifi::loop(void) {
|
|||
DPRINTLN(DBG_INFO, String(cnt) + F(" client connected (no timeout)"));
|
||||
mNextTryTs = (millis() + (WIFI_AP_ACTIVE_TIME * 1000));
|
||||
}
|
||||
else
|
||||
DPRINTLN(DBG_INFO, F("AP will be closed in ") + String((mNextTryTs - mApLastTick) / 1000) + F(" seconds"));
|
||||
else {
|
||||
DBGPRINT(F("AP will be closed in "));
|
||||
DBGPRINT(String((mNextTryTs - mApLastTick) / 1000));
|
||||
DBGPRINTLN(F(" seconds"));
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -110,12 +113,14 @@ void ahoywifi::setupAp(const char *ssid, const char *pwd) {
|
|||
DPRINTLN(DBG_VERBOSE, F("app::setupAp"));
|
||||
IPAddress apIp(192, 168, 4, 1);
|
||||
|
||||
DPRINTLN(DBG_INFO, F("\n---------\nAP MODE\nSSID: ")
|
||||
+ String(ssid) + F("\nPWD: ")
|
||||
+ String(pwd) + F("\nActive for: ")
|
||||
+ String(WIFI_AP_ACTIVE_TIME) + F(" seconds")
|
||||
+ F("\n---------\n"));
|
||||
DPRINTLN(DBG_DEBUG, String(mNextTryTs));
|
||||
DBGPRINT(F("\n---------\nAP MODE\nSSID: "));
|
||||
DBGPRINTLN(ssid);
|
||||
DBGPRINT(F("PWD: "));
|
||||
DBGPRINTLN(pwd);
|
||||
DBGPRINT(F("\nActive for: "));
|
||||
DBGPRINT(String(WIFI_AP_ACTIVE_TIME));
|
||||
DBGPRINTLN(F(" seconds"));
|
||||
DBGPRINTLN(F("\n---------\n"));
|
||||
|
||||
WiFi.mode(WIFI_AP);
|
||||
WiFi.softAPConfig(apIp, apIp, IPAddress(255, 255, 255, 0));
|
||||
|
@ -153,13 +158,15 @@ bool ahoywifi::setupStation(uint32_t timeout) {
|
|||
WiFi.hostname(mConfig->sys.deviceName);
|
||||
|
||||
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) {
|
||||
delay(100);
|
||||
if(cnt % 40 == 0)
|
||||
Serial.println(".");
|
||||
DBGPRINTLN(".");
|
||||
else
|
||||
Serial.print(".");
|
||||
DBGPRINT(".");
|
||||
|
||||
if(timeout > 0) { // limit == 0 -> no limit
|
||||
if(--cnt <= 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue