Add description
parent
93e0abe9bc
commit
7e23e437d6
|
|
@ -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 <Arduino.h>
|
||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
#include <ETH.h>
|
#include <ETH.h>
|
||||||
|
|
@ -8,7 +14,7 @@
|
||||||
#include <FS.h>
|
#include <FS.h>
|
||||||
#include "page.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
|
// SD card defines
|
||||||
#define SCK 14
|
#define SCK 14
|
||||||
|
|
@ -31,10 +37,11 @@ static bool eth_connected = false;
|
||||||
|
|
||||||
void WiFiEvent(WiFiEvent_t event)
|
void WiFiEvent(WiFiEvent_t event)
|
||||||
{
|
{
|
||||||
switch (event) {
|
switch (event)
|
||||||
|
{
|
||||||
case ARDUINO_EVENT_ETH_START:
|
case ARDUINO_EVENT_ETH_START:
|
||||||
Serial.println("ETH Started");
|
Serial.println("ETH Started");
|
||||||
//set eth hostname here
|
// set eth hostname here
|
||||||
ETH.setHostname("esplan");
|
ETH.setHostname("esplan");
|
||||||
break;
|
break;
|
||||||
case ARDUINO_EVENT_ETH_CONNECTED:
|
case ARDUINO_EVENT_ETH_CONNECTED:
|
||||||
|
|
@ -45,7 +52,8 @@ void WiFiEvent(WiFiEvent_t event)
|
||||||
Serial.print(ETH.macAddress());
|
Serial.print(ETH.macAddress());
|
||||||
Serial.print(", IPv4: ");
|
Serial.print(", IPv4: ");
|
||||||
Serial.print(ETH.localIP());
|
Serial.print(ETH.localIP());
|
||||||
if (ETH.fullDuplex()) {
|
if (ETH.fullDuplex())
|
||||||
|
{
|
||||||
Serial.print(", FULL_DUPLEX");
|
Serial.print(", FULL_DUPLEX");
|
||||||
}
|
}
|
||||||
Serial.print(", ");
|
Serial.print(", ");
|
||||||
|
|
@ -84,13 +92,13 @@ void readFile(fs::FS &fs, const char *path)
|
||||||
while (file.available())
|
while (file.available())
|
||||||
{
|
{
|
||||||
text[i] = file.read();
|
text[i] = file.read();
|
||||||
if(text[i++] == '\n')
|
if (text[i++] == '\n')
|
||||||
{
|
{
|
||||||
Serial.print(text);
|
Serial.print(text);
|
||||||
sprintf(out, "<p>%s</p>", text);
|
sprintf(out, "<p>%s</p>", text);
|
||||||
server.sendContent(out);
|
server.sendContent(out);
|
||||||
memset(text, 0, 99*sizeof(*text));
|
memset(text, 0, 99 * sizeof(*text));
|
||||||
memset(out, 0, 99*sizeof(*out));
|
memset(out, 0, 99 * sizeof(*out));
|
||||||
i = 0;
|
i = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -236,7 +244,7 @@ void setup()
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
if(eth_connected)
|
if (eth_connected)
|
||||||
{
|
{
|
||||||
server.handleClient();
|
server.handleClient();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue