Initial commit
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
#include <SPIFFS.h>
|
||||
#include <WiFi.h>
|
||||
#include <WebServer.h>
|
||||
|
||||
const char* ssid = "Box-gut-2.4G";
|
||||
const char* password = "Rut@b@g@93";
|
||||
|
||||
WebServer server(80);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
connectToWiFi();
|
||||
setupSPIFFS();
|
||||
setupWebServer();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
server.handleClient();
|
||||
}
|
||||
|
||||
void connectToWiFi() {
|
||||
WiFi.begin(ssid, password);
|
||||
|
||||
Serial.print("Connexion en cours au réseau Wi-Fi...");
|
||||
while (WiFi.status() != WL_CONNECTED) {
|
||||
delay(1000);
|
||||
Serial.print(".");
|
||||
}
|
||||
Serial.println("\nConnecté au réseau Wi-Fi");
|
||||
}
|
||||
|
||||
void setupSPIFFS() {
|
||||
if (SPIFFS.begin()) {
|
||||
Serial.println("Système de fichiers SPIFFS monté avec succès");
|
||||
} else {
|
||||
Serial.println("Erreur lors du montage du système de fichiers SPIFFS");
|
||||
}
|
||||
}
|
||||
|
||||
void setupWebServer() {
|
||||
server.onNotFound(handleNotFound);
|
||||
server.begin();
|
||||
|
||||
Serial.println("Serveur Web démarré");
|
||||
Serial.print("Adresse IP actuelle: ");
|
||||
Serial.println(WiFi.localIP());
|
||||
}
|
||||
|
||||
void handleNotFound() {
|
||||
String uri = server.uri();
|
||||
int request = uri.indexOf("/");
|
||||
String message = uri.substring(request + 1);
|
||||
|
||||
if (message.length() == 0) {
|
||||
message = "index";
|
||||
}
|
||||
|
||||
if (request != -1) {
|
||||
serveFile(message);
|
||||
}
|
||||
}
|
||||
|
||||
void serveFile(const String& fileName) {
|
||||
File file = SPIFFS.open("/" + fileName + ".html", "r");
|
||||
if (file) {
|
||||
server.streamFile(file, "text/html");
|
||||
file.close();
|
||||
} else {
|
||||
server.send(404, "text/plain", "Fichier " + fileName + " non trouvé");
|
||||
Serial.print("Not found");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>ESP32-S3 Web Server</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Bienvenue sur le serveur web de l'ESP32-S3</h1>
|
||||
<p>Ceci est une page de test.</p>
|
||||
<p>Vous pouvez personnaliser cette page comme vous le souhaitez.</p>
|
||||
</body>
|
||||
</html>
|
||||
13
Ecran Lilygot-T-RGB/Code tests/connection_wifi/debug.cfg
Normal file
13
Ecran Lilygot-T-RGB/Code tests/connection_wifi/debug.cfg
Normal file
@@ -0,0 +1,13 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
#
|
||||
# Example OpenOCD configuration file for ESP32-C3 connected via builtin USB-JTAG adapter.
|
||||
#
|
||||
# For example, OpenOCD can be started for ESP32-C3 debugging on
|
||||
#
|
||||
# openocd -f board/esp32c3-builtin.cfg
|
||||
#
|
||||
|
||||
# Source the JTAG interface configuration file
|
||||
source [find interface/esp_usb_jtag.cfg]
|
||||
# Source the ESP32-C3 configuration file
|
||||
source [find target/esp32c3.cfg]
|
||||
36098
Ecran Lilygot-T-RGB/Code tests/connection_wifi/debug.svd
Normal file
36098
Ecran Lilygot-T-RGB/Code tests/connection_wifi/debug.svd
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"name":"Arduino on ESP32-C3",
|
||||
"toolchainPrefix":"riscv32-esp-elf",
|
||||
"svdFile":"debug.svd",
|
||||
"request":"attach",
|
||||
"serverArgs":[
|
||||
"-d3"
|
||||
],
|
||||
"overrideAttachCommands":[
|
||||
"set remote hardware-watchpoint-limit 8",
|
||||
"monitor reset",
|
||||
"monitor halt",
|
||||
"monitor gdb_sync",
|
||||
"thb setup"
|
||||
],
|
||||
"overrideRestartCommands":[
|
||||
"monitor reset",
|
||||
"monitor halt",
|
||||
"monitor gdb_sync",
|
||||
"thb setup"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user