mirror of
https://github.com/Genaker/LoraSA.git
synced 2026-03-28 17:42:59 +01:00
Add HTML server
This commit is contained in:
40
data/index.html
Normal file
40
data/index.html
Normal file
@@ -0,0 +1,40 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>ESP Wi-Fi Manager</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="icon" href="data:,">
|
||||
<link rel="stylesheet" type="text/css" href="style.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="topnav">
|
||||
<h1>LORA SA ESP32 CONFIG</h1>
|
||||
</div>
|
||||
<div class="content">
|
||||
<div class="card-grid">
|
||||
<div class="card">
|
||||
<form action="/" method="POST">
|
||||
<p>
|
||||
<label for="ssid">SSID</label>
|
||||
<input type="text" id="ssid" name="ssid"><br>
|
||||
<label for="pass">Password</label>
|
||||
<input type="text" id="pass" name="pass"><br>
|
||||
<label for="ip">IP Address</label>
|
||||
<input type="text" id="ip" name="ip" value="192.168.1.200"><br>
|
||||
<label for="gateway">Gateway Address</label>
|
||||
<input type="text" id="gateway" name="gateway" value="192.168.1.1"><br>
|
||||
<label for="fstart">FREQ START</label>
|
||||
<input type="text" id="fstart" name="fstart" value="800"><br>
|
||||
<label for="fend">FREQ END</label>
|
||||
<input type="text" id="fend" name="fend" value="960"><br>
|
||||
<input type="submit" value="Submit">
|
||||
</p>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
118
data/style.css
Normal file
118
data/style.css
Normal file
@@ -0,0 +1,118 @@
|
||||
html {
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
display: inline-block;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 1.8rem;
|
||||
color: white;
|
||||
}
|
||||
|
||||
p {
|
||||
font-size: 1.4rem;
|
||||
}
|
||||
|
||||
.topnav {
|
||||
overflow: hidden;
|
||||
background-color: #0A1128;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.content {
|
||||
padding: 5%;
|
||||
}
|
||||
|
||||
.card-grid {
|
||||
max-width: 800px;
|
||||
margin: 0 auto;
|
||||
display: grid;
|
||||
grid-gap: 2rem;
|
||||
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
|
||||
}
|
||||
|
||||
.card {
|
||||
background-color: white;
|
||||
box-shadow: 2px 2px 12px 1px rgba(140, 140, 140, .5);
|
||||
}
|
||||
|
||||
.card-title {
|
||||
font-size: 1.2rem;
|
||||
font-weight: bold;
|
||||
color: #034078
|
||||
}
|
||||
|
||||
input[type=submit] {
|
||||
border: none;
|
||||
color: #FEFCFB;
|
||||
background-color: #034078;
|
||||
padding: 15px 15px;
|
||||
text-align: center;
|
||||
text-decoration: none;
|
||||
display: inline-block;
|
||||
font-size: 16px;
|
||||
width: 100px;
|
||||
margin-right: 10px;
|
||||
border-radius: 4px;
|
||||
transition-duration: 0.4s;
|
||||
}
|
||||
|
||||
input[type=submit]:hover {
|
||||
background-color: #1282A2;
|
||||
}
|
||||
|
||||
input[type=text],
|
||||
input[type=number],
|
||||
select {
|
||||
width: 50%;
|
||||
padding: 12px 20px;
|
||||
margin: 18px;
|
||||
display: inline-block;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 4px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
label {
|
||||
font-size: 1.2rem;
|
||||
}
|
||||
|
||||
.value {
|
||||
font-size: 1.2rem;
|
||||
color: #1282A2;
|
||||
}
|
||||
|
||||
.state {
|
||||
font-size: 1.2rem;
|
||||
color: #1282A2;
|
||||
}
|
||||
|
||||
button {
|
||||
border: none;
|
||||
color: #FEFCFB;
|
||||
padding: 15px 32px;
|
||||
text-align: center;
|
||||
font-size: 16px;
|
||||
width: 100px;
|
||||
border-radius: 4px;
|
||||
transition-duration: 0.4s;
|
||||
}
|
||||
|
||||
.button-on {
|
||||
background-color: #034078;
|
||||
}
|
||||
|
||||
.button-on:hover {
|
||||
background-color: #1282A2;
|
||||
}
|
||||
|
||||
.button-off {
|
||||
background-color: #858585;
|
||||
}
|
||||
|
||||
.button-off:hover {
|
||||
background-color: #252524;
|
||||
}
|
||||
0
data/text.txt
Normal file
0
data/text.txt
Normal file
43
include/File.h
Normal file
43
include/File.h
Normal file
@@ -0,0 +1,43 @@
|
||||
#include "FS.h"
|
||||
#include <LittleFS.h>
|
||||
|
||||
String readFile(fs::FS &fs, const char *path)
|
||||
{
|
||||
Serial.printf("Reading file: %s\r\n", path);
|
||||
|
||||
File file = fs.open(path);
|
||||
if (!file || file.isDirectory())
|
||||
{
|
||||
Serial.println("- failed to open file for reading");
|
||||
return String("");
|
||||
}
|
||||
String content;
|
||||
Serial.println("- read from file:");
|
||||
while (file.available())
|
||||
{
|
||||
content = file.readStringUntil('\n');
|
||||
}
|
||||
file.close();
|
||||
return content;
|
||||
}
|
||||
|
||||
void writeFile(fs::FS &fs, const char *path, const char *message)
|
||||
{
|
||||
Serial.printf("Writing file: %s\r\n", path);
|
||||
|
||||
File file = fs.open(path, FILE_WRITE);
|
||||
if (!file)
|
||||
{
|
||||
Serial.println("- failed to open file for writing");
|
||||
return;
|
||||
}
|
||||
if (file.print(message))
|
||||
{
|
||||
Serial.println("- file written");
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.println("- write failed");
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
@@ -26,12 +26,15 @@ framework = arduino
|
||||
upload_speed = 921600
|
||||
monitor_speed = 115200
|
||||
board_build.f_cpu = 240000000
|
||||
board_build.filesystem = littlefs
|
||||
lib_deps =
|
||||
ropg/Heltec_ESP32_LoRa_v3@^0.9.1
|
||||
bblanchon/ArduinoJson@^7.2.0
|
||||
ESP Async WebServer
|
||||
build_flags =
|
||||
-DHELTEC_POWER_BUTTON
|
||||
-DHELTEC
|
||||
|
||||
|
||||
[env:heltec_wifi_lora_32_V3_433]
|
||||
platform = espressif32
|
||||
|
||||
19
src/main.cpp
19
src/main.cpp
@@ -27,9 +27,18 @@
|
||||
#ifdef HELTEC
|
||||
#include <ArduinoJson.h>
|
||||
#endif
|
||||
#include "FS.h"
|
||||
#include <AsyncTCP.h>
|
||||
#include <ESPAsyncWebServer.h>
|
||||
#include <File.h>
|
||||
#include <LittleFS.h>
|
||||
#include <freertos/FreeRTOS.h>
|
||||
#include <freertos/task.h>
|
||||
|
||||
#include "WIFI_SERVER.h"
|
||||
|
||||
#define FORMAT_LITTLEFS_IF_FAILED true
|
||||
|
||||
// #define OSD_ENABLED true
|
||||
// #define WIFI_SCANNING_ENABLED true
|
||||
// #define BT_SCANNING_ENABLED true
|
||||
@@ -548,6 +557,7 @@ void drone_sound_alarm(void *arg, Event &e);
|
||||
|
||||
void setup(void)
|
||||
{
|
||||
|
||||
#ifdef LILYGO
|
||||
setupBoards(); // true for disable U8g2 display library
|
||||
delay(500);
|
||||
@@ -580,6 +590,7 @@ void setup(void)
|
||||
pinMode(BUZZER_PIN, OUTPUT);
|
||||
pinMode(REB_PIN, OUTPUT);
|
||||
heltec_setup();
|
||||
serverStart();
|
||||
#ifdef JOYSTICK_ENABLED
|
||||
calibrate_joy();
|
||||
pinMode(JOY_BTN_PIN, INPUT_PULLUP);
|
||||
@@ -600,6 +611,14 @@ void setup(void)
|
||||
}
|
||||
|
||||
init_radio();
|
||||
|
||||
if (!LittleFS.begin(FORMAT_LITTLEFS_IF_FAILED))
|
||||
{
|
||||
Serial.println("LittleFS Mount Failed");
|
||||
}
|
||||
|
||||
// writeFile(LittleFS, "/text.txt", "{WIFI:{name:\"sdfsdf\", Password:\"sdfsdf\"}");
|
||||
Serial.println(readFile(LittleFS, "/text.txt"));
|
||||
#ifndef LILYGO
|
||||
vbat = heltec_vbat();
|
||||
both.printf("V battery: %.2fV (%d%%)\n", vbat, heltec_battery_percent(vbat));
|
||||
|
||||
Reference in New Issue
Block a user