1
0
mirror of https://github.com/s00500/ESPUI.git synced 2024-11-21 22:50:55 +00:00

Add Port Option

Signed-off-by: Lukas Bachschwell <lukas@lbsfilm.at>
This commit is contained in:
Lukas Bachschwell 2021-10-29 19:20:20 +02:00
parent 6b3056ab31
commit aa03c1683d
Signed by: lbsadmin
GPG Key ID: CCC6AA87CC8DF425
2 changed files with 58 additions and 64 deletions

View File

@ -32,7 +32,6 @@ void listDir(const char* dirname, uint8_t levels)
File root = LittleFS.open(dirname);
#endif
if (!root)
{
#if defined(DEBUG_ESPUI)
@ -122,7 +121,7 @@ void ESPUIClass::list()
return;
}
#else
if (!LittleFS.begin())
if (!LittleFS.begin())
{
Serial.println(F("LittleFS Mount Failed"));
return;
@ -147,7 +146,7 @@ if (!LittleFS.begin())
void deleteFile(const char* path)
{
#if defined(ESP32)
#if defined(ESP32)
bool exists = SPIFFS.exists(path);
#else
bool exists = LittleFS.exists(path);
@ -381,8 +380,7 @@ void onWsEvent(
{
switch (type)
{
case WS_EVT_DISCONNECT:
{
case WS_EVT_DISCONNECT: {
#if defined(DEBUG_ESPUI)
if (ESPUI.verbosity)
{
@ -393,8 +391,7 @@ void onWsEvent(
break;
}
case WS_EVT_PONG:
{
case WS_EVT_PONG: {
#if defined(DEBUG_ESPUI)
if (ESPUI.verbosity)
{
@ -405,8 +402,7 @@ void onWsEvent(
break;
}
case WS_EVT_ERROR:
{
case WS_EVT_ERROR: {
#if defined(DEBUG_ESPUI)
if (ESPUI.verbosity)
{
@ -417,8 +413,7 @@ void onWsEvent(
break;
}
case WS_EVT_CONNECT:
{
case WS_EVT_CONNECT: {
#if defined(DEBUG_ESPUI)
if (ESPUI.verbosity)
{
@ -438,8 +433,7 @@ void onWsEvent(
}
break;
case WS_EVT_DATA:
{
case WS_EVT_DATA: {
String msg = "";
msg.reserve(len + 1);
@ -889,7 +883,7 @@ void ESPUIClass::updateGauge(uint16_t id, int number, int clientId)
updateControlValue(id, String(number), clientId);
}
void ESPUIClass::clearGraph(uint16_t id, int clientId) {}
void ESPUIClass::clearGraph(uint16_t id, int clientId) { }
void ESPUIClass::addGraphPoint(uint16_t id, int nValue, int clientId)
{
@ -1037,7 +1031,7 @@ void ESPUIClass::jsonReload()
this->ws->textAll(json);
}
void ESPUIClass::beginSPIFFS(const char* _title, const char* username, const char* password)
void ESPUIClass::beginSPIFFS(const char* _title, const char* username, const char* password, uint16_t port)
{
ui_title = _title;
this->basicAuthUsername = username;
@ -1052,7 +1046,7 @@ void ESPUIClass::beginSPIFFS(const char* _title, const char* username, const cha
basicAuth = true;
}
server = new AsyncWebServer(80);
server = new AsyncWebServer(port);
ws = new AsyncWebSocket("/ws");
#if defined(ESP32)
@ -1144,7 +1138,7 @@ void ESPUIClass::beginSPIFFS(const char* _title, const char* username, const cha
#endif
}
void ESPUIClass::begin(const char* _title, const char* username, const char* password)
void ESPUIClass::begin(const char* _title, const char* username, const char* password, uint16_t port)
{
basicAuthUsername = username;
basicAuthPassword = password;
@ -1160,7 +1154,7 @@ void ESPUIClass::begin(const char* _title, const char* username, const char* pas
ui_title = _title;
server = new AsyncWebServer(80);
server = new AsyncWebServer(port);
ws = new AsyncWebSocket("/ws");
ws->onEvent(onWsEvent);

View File

@ -215,10 +215,10 @@ public:
bool sliderContinuous;
void setVerbosity(Verbosity verbosity);
void begin(const char* _title, const char* username = nullptr,
const char* password = nullptr); // Setup server and page in Memorymode
void beginSPIFFS(const char* _title, const char* username = nullptr,
const char* password = nullptr); // Setup server and page in SPIFFSmode
void begin(const char* _title, const char* username = nullptr, const char* password = nullptr,
uint16_t port = 80); // Setup server and page in Memorymode
void beginSPIFFS(const char* _title, const char* username = nullptr, const char* password = nullptr,
uint16_t port = 80); // Setup server and page in SPIFFSmode
void prepareFileSystem(); // Initially preps the filesystem and loads a lot of
// stuff into SPIFFS