diff --git a/data/root.js b/data/root.js index 98c99dd..256062b 100644 --- a/data/root.js +++ b/data/root.js @@ -18,7 +18,7 @@ function add_user(ip, mac) async function update_user_list() { - const res = await fetch("http://192.168.4.1/user_list", { + const res = await fetch("/user_list", { method: "GET" }); diff --git a/data/settings.js b/data/settings.js index 582b5a4..c966386 100644 --- a/data/settings.js +++ b/data/settings.js @@ -3,7 +3,7 @@ async function ap_update() const ssid = document.querySelector('#ap-ssid'); const pass = document.querySelector('#ap-password'); - const response = await fetch("http://192.168.4.1/settings/ap_update", { + const response = await fetch("/settings/ap_update", { method: "POST", headers: { 'Content-Type': 'application/json;charset=utf-8' @@ -19,7 +19,7 @@ async function sta_update() const ssid = document.querySelector('#sta-ssid'); const pass = document.querySelector('#sta-password'); - const response = await fetch("http://192.168.4.1/settings/sta_update", { + const response = await fetch("/settings/sta_update", { method: "POST", headers: { 'Content-Type': 'application/json;charset=utf-8' @@ -41,7 +41,7 @@ async function admin_update() return; } - const res = await fetch("http://192.168.4.1/settings/admin_update", { + const res = await fetch("/settings/admin_update", { method: "POST", headers:{ 'Content-Type': 'application/json;charset=utf-8' @@ -57,7 +57,7 @@ async function set_conn_out() { const checkbox = document.getElementById('connection-out'); - const response = await fetch("http://192.168.4.1/settings/set_conn_out", { + const response = await fetch("/settings/set_conn_out", { method: "POST", headers: { 'Content-Type': 'application/json;charset=utf-8' @@ -72,7 +72,7 @@ async function set_conn_out() async function init() { try { - const res = await fetch("http://192.168.4.1/settings/is_conn_out", { + const res = await fetch("h/settings/is_conn_out", { method: "GET" }); diff --git a/src/Settings.h b/src/Settings.h index 8a4e6db..da6b50c 100644 --- a/src/Settings.h +++ b/src/Settings.h @@ -5,11 +5,17 @@ class Settings { + // Параметры STA String MODEM_SSID, MODEM_PASS; + // Параметры AP String AP_SSID, AP_PASS; + // Админка String ADMIN_LOGIN, ADMIN_PASS; + // Настройки сети IPAddress IP, GATEWAY, MASK; + // Частота и кол-во попыток подключения к STA unsigned int DELAY, CNT_RETRY; + // Нужно ли подключаться к STA bool CONN_TO_OUT; void save(); diff --git a/src/WebServer.h b/src/WebServer.h index f7f8850..1fd943f 100644 --- a/src/WebServer.h +++ b/src/WebServer.h @@ -16,17 +16,24 @@ class WebServer void js_settings_call(); void css_settings_call(); + // Установить параметры сети AP void ap_update(); + // Установить параметры Сети STA void sta_update(); + // Смена пароля администратора void admin_update(); + // Возвращает флаг IS_CONN_TO_OUT из настроек void is_conn_out(); + // Установить значение IS_CONN_TO_OUT в настройках void set_conn_out(); + // Получить список пользователей void get_user_list(); public: WebServer(Settings& settings, int port = 80); + // Обработка http запросов (вызывать в loop) void tick(); }; \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 8846e88..17aeca8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -8,6 +8,7 @@ Settings settings; WebServer server(settings); +// Проверка доступности внешней сети bool CheckSSID(String ssid) { bool isFind = false; @@ -25,6 +26,10 @@ bool CheckSSID(String ssid) return isFind; } +/* + * Подключение к внешней сети + * WiFi должеи быть в режиме WIFI_STA или WIFI_AP_STA + */ void conn_out() { if (CheckSSID(settings.getModemSSID()))