<commit_before>#include <ESP8266mDNS.h>
#include <ESP8266WebServer.h>
#include <ArduinoOTA.h>
#include <FS.h>
#include "Pcd8544.h"
#include "config.h"
#include "wifi_sta_pass.h"

#define WIFI_AP_SSID "ESPdust"
#define WIFI_AP_PASS "<PASSWORD>"

extern pcd8544::Pcd8544 display;
extern struct Configuration config;

ESP8266WebServer server(80);

static void on_root(void)
{
    File file = SPIFFS.open("/index.html", "r");
    if (!file) {
        server.send(200, "text/plain", "No index.html!");
        return;
    }

    String s = file.readString();
    s.replace("{wifi_staip}", WiFi.localIP().toString());
    s.replace("{wifi_stassid}", config.wifi_ssid);
    s.replace("{wifi_stapass}", config.wifi_pass);
    s.replace("{wifi_apip}", WiFi.softAPIP().toString().c_str());

    server.send(200, "text/html", s.c_str());
}

void setup_setup(void)
{
    display.clear();
    display.setCursor(0, 0);
    display.println("WIFI");

    WiFi.mode(WIFI_AP_STA);

    WiFi.softAP(WIFI_AP_SSID, WIFI_AP_PASS);
    display.println(WiFi.softAPIP().toString().c_str());

    WiFi.begin(WIFI_STA_SSID, WIFI_STA_PASS);
    while (WiFi.waitForConnectResult() != WL_CONNECTED) {
        display.println("Wifi Connection Failed!");
    }

    display.println(WiFi.localIP().toString().c_str());

    server.on("/", on_root);

    ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
        display.setCursor(0, 5);
        display.println(String(progress / (total / 100)).c_str());
    });
    ArduinoOTA.begin();

    server.begin();

    SPIFFS.begin();<commit_msg>setup_mode: use WIFI SSID and password from config file<commit_after>#include <ESP8266mDNS.h>
#include <ESP8266WebServer.h>
#include <ArduinoOTA.h>
#include <FS.h>
#include "Pcd8544.h"
#include "config.h"

#define WIFI_AP_SSID "ESPdust"
#define WIFI_AP_PASS "<PASSWORD>"

extern pcd8544::Pcd8544 display;
extern struct Configuration config;

ESP8266WebServer server(80);

static void on_root(void)
{
    File file = SPIFFS.open("/index.html", "r");
    if (!file) {
        server.send(200, "text/plain", "No index.html!");
        return;
    }

    String s = file.readString();
    s.replace("{wifi_staip}", WiFi.localIP().toString());
    s.replace("{wifi_stassid}", config.wifi_ssid);
    s.replace("{wifi_stapass}", config.wifi_pass);
    s.replace("{wifi_apip}", WiFi.softAPIP().toString().c_str());

    server.send(200, "text/html", s.c_str());
}

void setup_setup(void)
{
    display.clear();
    display.setCursor(0, 0);
    display.println("WIFI");

    WiFi.mode(WIFI_AP_STA);

    WiFi.softAP(WIFI_AP_SSID, WIFI_AP_PASS);
    display.println(WiFi.softAPIP().toString().c_str());

    WiFi.begin(config.wifi_ssid, config.wifi_pass);
    while (WiFi.waitForConnectResult() != WL_CONNECTED) {
        display.println("Wifi Connection Failed!");
    }

    display.println(WiFi.localIP().toString().c_str());

    server.on("/", on_root);

    ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
        display.setCursor(0, 5);
        display.println(String(progress / (total / 100)).c_str());
    });
    ArduinoOTA.begin();

    server.begin();

    SPIFFS.begin();
{'fraction_non_alphanumeric': 0.1723920579892846, 'fraction_numerical': 0.02458241411913016, 'mean_word_length': 3.9749216300940438, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1311765', 'n_tokens_mistral': 1257, 'n_tokens_neox': 1177, 'n_words': 189}