1
0
mirror of https://github.com/s00500/ESPUI.git synced 2024-11-24 17:30: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)
@ -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);
@ -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