kamiyaowl/wfh_monitor

#49 config.getReadPtr<char>(GlobalConfigKeys::ApSs...

Closed this issue · 1 comments

#49 config.getReadPtr(GlobalConfigKeys::ApSsid);

const char* ssid = "ssid"; //TODO: #49 config.getReadPtr<char>(GlobalConfigKeys::ApSsid);

        }
    }
}

static void setupWifi(void) {
    // 前回動いていた場合、一旦切断
    lcd.printf("[INFO] reset wifi module.\n");
    wifi.mode(WIFI_STA);
    wifi.disconnect();
    delay(FixedConfig::WaitForPorMs);

    // WiFi使わなければSkip
    bool useWifi = GlobalConfigDefaultValues::UseWiFi;
    config.read(GlobalConfigKeys::UseWiFi, useWifi);
    if (!useWifi) {
        lcd.printf("[INFO] skip AP Connection.\n");
        return;
    }

    // Wifi開始
    const char* ssid   = "ssid"; //TODO: #49 config.getReadPtr<char>(GlobalConfigKeys::ApSsid);
    const char* pass   = "pass"; //TODO: #49 config.getReadPtr<char>(GlobalConfigKeys::ApPassWord);
    uint32_t timeoutMs = GlobalConfigDefaultValues::ApTimeoutMs;
    config.read(GlobalConfigKeys::ApTimeoutMs, timeoutMs);

    lcd.printf("[INFO] connect to %s.\n", ssid);
    wifi.begin(ssid, pass);

    const uint32_t startMillis = millis();
    while (wifi.status() != WL_CONNECTED) {
        lcd.print(".");
        delay(FixedConfig::WaitForPorMs);
        // timeout
        const uint32_t elapsedMs = millis() - startMillis;
        if (elapsedMs > timeoutMs) {
            lcd.printf("\n[ERROR] timeout.\n");
            break;
        }
    }

    const bool isConnected = (wifi.status() == WL_CONNECTED);
    if (!isConnected) {
        lcd.printf("[ERROR] Error.\n");
        return;
    }

    lcd.printf("\n[INFO] done.");
    lcd.println(wifi.localIP());
}

static void setupRtos(void) {
    lcd.printf("[INFO] setup RTOS config\n");
    vSetErrorLed(FixedConfig::ErrorLedPinNum, FixedConfig::ErrorLedState);

51db967c09e5fe67c7b4cbbddbaff2a0e7fb1599