Add description

main
Jarda 2023-08-21 15:29:08 +02:00
parent 93e0abe9bc
commit 7e23e437d6
1 changed files with 169 additions and 161 deletions

View File

@ -1,3 +1,9 @@
/* Webserver reads from SD text file test for LaskaKit ESPlan
* After boot connect to http://esplan.local or to IP adress of ESP32 (for example 192.168.0.98)
* Email:podpora@laskakit.cz
* Web:laskakit.cz
*/
#include <Arduino.h>
#include <WiFi.h>
#include <ETH.h>
@ -8,7 +14,7 @@
#include <FS.h>
#include "page.h"
const char *host = "esplan"; // Connect to http://ESPlan.local
const char *host = "esplan"; // Connect to http://esplan.local
// SD card defines
#define SCK 14
@ -31,10 +37,11 @@ static bool eth_connected = false;
void WiFiEvent(WiFiEvent_t event)
{
switch (event) {
switch (event)
{
case ARDUINO_EVENT_ETH_START:
Serial.println("ETH Started");
//set eth hostname here
// set eth hostname here
ETH.setHostname("esplan");
break;
case ARDUINO_EVENT_ETH_CONNECTED:
@ -45,7 +52,8 @@ void WiFiEvent(WiFiEvent_t event)
Serial.print(ETH.macAddress());
Serial.print(", IPv4: ");
Serial.print(ETH.localIP());
if (ETH.fullDuplex()) {
if (ETH.fullDuplex())
{
Serial.print(", FULL_DUPLEX");
}
Serial.print(", ");
@ -84,13 +92,13 @@ void readFile(fs::FS &fs, const char *path)
while (file.available())
{
text[i] = file.read();
if(text[i++] == '\n')
if (text[i++] == '\n')
{
Serial.print(text);
sprintf(out, "<p>%s</p>", text);
server.sendContent(out);
memset(text, 0, 99*sizeof(*text));
memset(out, 0, 99*sizeof(*out));
memset(text, 0, 99 * sizeof(*text));
memset(out, 0, 99 * sizeof(*out));
i = 0;
}
}
@ -236,7 +244,7 @@ void setup()
void loop()
{
if(eth_connected)
if (eth_connected)
{
server.handleClient();
}