Skip to content

Commit

Permalink
Sync with esp3d 2b1
Browse files Browse the repository at this point in the history
  • Loading branch information
luc-github committed Jan 21, 2025
1 parent b266010 commit 536181b
Show file tree
Hide file tree
Showing 79 changed files with 6,146 additions and 2,990 deletions.
2,178 changes: 1,137 additions & 1,041 deletions embedded/package-lock.json

Large diffs are not rendered by default.

25 changes: 20 additions & 5 deletions embedded/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,8 @@ function processFWJson(text) {
}

if (json.WebUpdate == "Enabled") firmware.classList.remove("hide");
hostpath = json.HostPath;
if (typeof json.HostPath != "undefined") hostpath = json.HostPath;
console.log("HostPath: " + hostpath);
if (json.WiFiMode && json.WebSocketIP) {
if (isLimitedEnvironment(json.WiFiMode)) {
let address =
Expand Down Expand Up @@ -404,7 +405,9 @@ function startSocket(ip, port, sync) {
msg += String.fromCharCode(bytes[i]);
if (bytes[i] == 10 || bytes[i] == 13) {
wsMsg += msg;
consoleContentUpdate(wsMsg);
if (!wsMsg.startsWith("ESP3D says: command forwarded")) {
consoleContentUpdate(wsMsg);
}
wsMsg = "";
msg = "";
}
Expand Down Expand Up @@ -534,6 +537,13 @@ function dirIcon(plus = false) {
}
function dispatchFileStatus(jsonresponse) {
let json;
let currentpath = currentPath;
if (!currentpath.endsWith("/")) currentpath += "/";
currentpath += hostpath;
if (!currentpath.endsWith("/")) currentpath += "/";
let currentpath2 = currentpath.replaceAll("//", "/");
currentpath = currentpath2;
console.log("currentpath: " + currentpath);
let eventslisteners = [];
let showESP3Dbutton = false;
try {
Expand Down Expand Up @@ -606,7 +616,7 @@ function dispatchFileStatus(jsonresponse) {
for (let i1 = 0; i1 < json.files.length; i1++) {
if (String(json.files[i1].size) != "-1") {
if (
currentPath == hostpath &&
currentPath == "/" &&
(json.files[i1].name == "index.html.gz" ||
json.files[i1].name == "index.html")
) {
Expand Down Expand Up @@ -660,12 +670,12 @@ function dispatchFileStatus(jsonresponse) {
let url = new URL(
"http://" +
window.location.host +
currentPath +
"/" +
currentpath +
eventslisteners[i].target
);
window.open(url, "_blank");
});

break;
case "filedel":
document
Expand Down Expand Up @@ -768,6 +778,11 @@ function uploadFiles() {
formData.append("path", currentPath);
let currentpath = currentPath;
if (!currentpath.endsWith("/")) currentpath += "/";
currentpath += hostpath;
if (!currentpath.endsWith("/")) currentpath += "/";
let currentpath2 = currentpath.replaceAll("//", "/");
currentpath = currentpath2;
console.log(currentpath);
for (let i3 = 0; i3 < files.length; i3++) {
let file = files[i3];
let arg = currentpath + file.name + "S";
Expand Down
2 changes: 1 addition & 1 deletion embedded/src/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function initMenus() {
});

document.getElementById("hlpLink").addEventListener("click", function () {
window.open("https://github.com/luc-github/ESP3DLib/wiki", "_blank");
window.open("https://esp3d.io/ESP3DLib/Version_3.X/documentation/", "_blank");
});
}

Expand Down
45 changes: 32 additions & 13 deletions src/core/commands/ESP0.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,11 @@ const char* help[] = {
"[ESP100](SSID) - display/set STA SSID",
"[ESP101](Password) - set STA password",
#endif // WIFI_FEATURE
#if defined(WIFI_FEATURE) || defined(ETH_FEATURE)
#if defined(WIFI_FEATURE)
"[ESP102](Mode) - display/set STA IP mode (DHCP/STATIC)",
"[ESP103](IP=xxxx MSK=xxxx GW=xxxx) - display/set STA IP/Mask/GW",
#endif // WIFI_FEATURE || ETH_FEATURE
#if defined(WIFI_FEATURE) || defined(BLUETOOTH_FEATURE) || defined(ETH_FEATURE)
"[ESP104](State) - display/set sta fallback mode which can be BT, SETUP, "
"OFF",
#endif // WIFI_FEATURE || BLUETOOTH_FEATURE || ETH_FEATURE
#if defined(WIFI_FEATURE)
"[ESP105](SSID) - display/set AP SSID",
"[ESP106](Password) - set AP password",
"[ESP107](IP) - display/set AP IP",
Expand All @@ -53,6 +49,11 @@ const char* help[] = {
"[ESP115](State) - display/set immediate Network state which can be ON, "
"OFF",
#endif // WIFI_FEATURE || ETH_FEATURE || BT_FEATURE
#if defined(ETH_FEATURE)
"[ESP116](Mode) - display/set ETH STA IP mode (DHCP/STATIC)",
"[ESP117](IP=xxxx MSK=xxxx GW=xxxx) - display/set ETH STA IP/Mask/GW",
"[ESP118](State) - display/set eth sta fallback mode which can be BT, Off",
#endif // ETH_FEATURE
#if defined(HTTP_FEATURE)
"[ESP120](State) - display/set HTTP state which can be ON, OFF",
"[ESP121](Port) - display/set HTTP port ",
Expand Down Expand Up @@ -116,6 +117,10 @@ const char* help[] = {
"[ESP250]F=(frequency) D=(duration) - play sound on buzzer",
#endif // BUZZER_DEVICE
"[ESP290](delay in ms) - do a pause",
#if defined(ESP_LUA_INTERPRETER_FEATURE)
"[ESP300]<filename> - execute Lua script",
"[ESP301]action=<PAUSE/RESUME/ABORT> - query and control ESP300 execution",
#endif // ESP_LUA_INTERPRETER_FEATURE
"[ESP400] - display ESP3D settings in JSON",
"[ESP401]P=(position) T=(type) V=(value) - Set specific setting",
#ifdef SD_UPDATE_FEATURE
Expand All @@ -138,7 +143,7 @@ const char* help[] = {
#endif // AUTHENTICATION_FEATURE
#if defined(NOTIFICATION_FEATURE)
"[ESP600](message) - send notification",
"[ESP610]type=(NONE/PUSHOVER/EMAIL/LINE/TELEGRAM/IFTTT/HOMEASSISTANT) "
"[ESP610]type=(NONE/PUSHOVER/EMAIL/LINE/TELEGRAM/IFTTT/HOMEASSISTANT/WHATSAPP) "
"(T1=xxx) (T2=xxx) "
"(TS=xxx) - display/set Notification settings",
"[ESP620]URL=http://XXXXXX - send GET notification",
Expand Down Expand Up @@ -174,13 +179,19 @@ const char* help[] = {
"[ESP900](ENABLE/DISABLE) - display/set serial state",
"[ESP901]<BAUD RATE> - display/set serial baud rate",
#endif // COMMUNICATION_PROTOCOL != SOCKET_SERIAL
#if defined(USB_SERIAL_FEATURE)
"[ESP902]<BAUD RATE> - display/set USB Serial baud rate",
#endif // defined(USB_SERIAL_FEATURE)
#ifdef BUZZER_DEVICE
"[ESP910](ENABLE/DISABLE) - display/set buzzer state",
#endif // BUZZER_DEVICE
#if defined(ESP_SERIAL_BRIDGE_OUTPUT)
"[ESP930](ENABLE/DISABLE/CLOSE) - display/set serial bridge state",
"[ESP931]<BAUD RATE> - display/set serial bridge baud rate",
#endif // defined(ESP_SERIAL_BRIDGE_OUTPUT)
#if defined(USB_SERIAL_FEATURE)
"[ESP950]<SERIAL/USB> - display/set client output",
#endif // defined(USB_SERIAL_FEATURE)
#if defined(ARDUINO_ARCH_ESP32) && \
(CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32S2 || \
CONFIG_IDF_TARGET_ESP32C3)
Expand All @@ -192,13 +203,9 @@ const uint cmdlist[] = {
#if defined(WIFI_FEATURE)
100, 101,
#endif // WIFI_FEATURE
#if defined(WIFI_FEATURE) || defined(ETH_FEATURE)
#if defined(WIFI_FEATURE)
102, 103,
#endif // WIFI_FEATURE || ETH_FEATURE
#if defined(WIFI_FEATURE) || defined(BLUETOOTH_FEATURE) || defined(ETH_FEATURE)
104,
#endif // WIFI_FEATURE || BLUETOOTH_FEATURE || ETH_FEATURE
#if defined(WIFI_FEATURE)
105, 106, 107, 108,
#endif // WIFI_FEATURE
#if defined(WIFI_FEATURE) || defined(BLUETOOTH_FEATURE) || defined(ETH_FEATURE)
Expand All @@ -210,6 +217,9 @@ const uint cmdlist[] = {
#if defined(WIFI_FEATURE) || defined(ETH_FEATURE) || defined(BT_FEATURE)
112, 114, 115,
#endif // WIFI_FEATURE || ETH_FEATURE || BT_FEATURE
#if defined(ETH_FEATURE)
116, 117, 118,
#endif // ETH_FEATURE
#if defined(HTTP_FEATURE)
120, 121,
#endif // HTTP_FEATURE
Expand Down Expand Up @@ -257,7 +267,11 @@ const uint cmdlist[] = {
#ifdef BUZZER_DEVICE
250,
#endif // BUZZER_DEVICE
290, 400, 401,
290,
#if defined(ESP_LUA_INTERPRETER_FEATURE)
300, 301,
#endif // ESP_LUA_INTERPRETER_FEATURE
400, 401,
#ifdef SD_UPDATE_FEATURE
402,
#endif // SD_UPDATE_FEATURE
Expand Down Expand Up @@ -296,13 +310,18 @@ const uint cmdlist[] = {
#if COMMUNICATION_PROTOCOL != SOCKET_SERIAL
900, 901,
#endif // COMMUNICATION_PROTOCOL != SOCKET_SERIAL
#if defined(USB_SERIAL_FEATURE)
902,
#endif // defined(USB_SERIAL_FEATURE)
#ifdef BUZZER_DEVICE
910,

#endif // BUZZER_DEVICE
#if defined(ESP_SERIAL_BRIDGE_OUTPUT)
930, 931,
#endif // defined(ESP_SERIAL_BRIDGE_OUTPUT)
#if defined(USB_SERIAL_FEATURE)
950,
#endif // defined(USB_SERIAL_FEATURE)
#if defined(ARDUINO_ARCH_ESP32) && \
(CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32S2 || \
CONFIG_IDF_TARGET_ESP32C3)
Expand Down
7 changes: 2 additions & 5 deletions src/core/commands/ESP102.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,14 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "../../include/esp3d_config.h"
#if defined(WIFI_FEATURE) || defined(ETH_FEATURE)
#if defined(WIFI_FEATURE)
#include "../../modules/network/netconfig.h"
#include "../esp3d_commands.h"
#include "../esp3d_settings.h"

#if defined(WIFI_FEATURE)
#include "../../modules/wifi/wificonfig.h"
#endif // WIFI_FEATURE
#if defined(ETH_FEATURE)
#include "../../modules/ethernet/ethconfig.h"
#endif // ETH_FEATURE
#include "../../modules/authentication/authentication_service.h"
#define COMMAND_ID 102
// Change STA IP mode (DHCP/STATIC)
Expand Down Expand Up @@ -97,4 +94,4 @@ void ESP3DCommands::ESP102(int cmd_params_pos, ESP3DMessage* msg) {
}
}

#endif // WIFI_FEATURE || ETH_FEATURE
#endif // WIFI_FEATURE
7 changes: 2 additions & 5 deletions src/core/commands/ESP103.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,14 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "../../include/esp3d_config.h"
#if defined(WIFI_FEATURE) || defined(ETH_FEATURE)
#if defined(WIFI_FEATURE)
#include "../../modules/network/netconfig.h"
#include "../esp3d_commands.h"
#include "../esp3d_settings.h"

#if defined(WIFI_FEATURE)
#include "../../modules/wifi/wificonfig.h"
#endif // WIFI_FEATURE
#if defined(ETH_FEATURE)
#include "../../modules/ethernet/ethconfig.h"
#endif // ETH_FEATURE
#include "../../modules/authentication/authentication_service.h"
#define COMMAND_ID 103
// Change STA IP/Mask/GW
Expand Down Expand Up @@ -121,4 +118,4 @@ void ESP3DCommands::ESP103(int cmd_params_pos, ESP3DMessage* msg) {
}
}

#endif // WIFI_FEATURE || ETH_FEATURE
#endif // WIFI_FEATURE
12 changes: 1 addition & 11 deletions src/core/commands/ESP104.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "../../include/esp3d_config.h"
#if defined(WIFI_FEATURE) || defined(BLUETOOTH_FEATURE) || defined(ETH_FEATURE)
#if defined(WIFI_FEATURE)
#include "../../modules/authentication/authentication_service.h"
#include "../../modules/network/netconfig.h"
#include "../esp3d_commands.h"
Expand Down Expand Up @@ -54,11 +54,6 @@ void ESP3DCommands::ESP104(int cmd_params_pos, ESP3DMessage* msg) {
ok_msg = "BT";
} else
#endif // BLUETOOTH_FEATURE
#if defined(WIFI_FEATURE)
if (byteValue == (uint8_t)ESP_AP_SETUP) {
ok_msg = "CONFIG";
} else
#endif // WIFI_FEATURE
if (byteValue == (uint8_t)ESP_NO_NETWORK) {
ok_msg = "OFF";
} else {
Expand All @@ -76,11 +71,6 @@ void ESP3DCommands::ESP104(int cmd_params_pos, ESP3DMessage* msg) {
byteValue = (uint8_t)ESP_BT;
} else
#endif // BLUETOOTH_FEATURE
#if defined(WIFI_FEATURE)
if (tmpstr == "CONFIG") {
byteValue = (uint8_t)ESP_AP_SETUP;
} else
#endif // WIFI_FEATURE
if (tmpstr == "OFF") {
byteValue = (uint8_t)ESP_NO_NETWORK;
} else {
Expand Down
94 changes: 94 additions & 0 deletions src/core/commands/ESP116.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/*
ESP116.cpp - ESP3D command class
Copyright (c) 2014 Luc Lebosse. All rights reserved.
This code is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with This code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "../../include/esp3d_config.h"
#if defined(ETH_FEATURE)
#include "../../modules/network/netconfig.h"
#include "../esp3d_commands.h"
#include "../esp3d_settings.h"
#include "../../modules/ethernet/ethconfig.h"
#include "../../modules/authentication/authentication_service.h"
#define COMMAND_ID 116
// Change ETH STA IP mode (DHCP/STATIC)
//[ESP116]<mode>[json=no] [pwd=<admin password>]
void ESP3DCommands::ESP116(int cmd_params_pos, ESP3DMessage* msg) {
ESP3DClientType target = msg->origin;
ESP3DRequest requestId = msg->request_id;
(void)requestId;
msg->target = target;
msg->origin = ESP3DClientType::command;
bool hasError = false;
String error_msg = "Invalid parameters";
String ok_msg = "ok";
bool json = hasTag(msg, cmd_params_pos, "json");
String tmpstr;
uint8_t byteValue = (uint8_t)-1;
#if defined(AUTHENTICATION_FEATURE)
if (msg->authentication_level == ESP3DAuthenticationLevel::guest) {
msg->authentication_level = ESP3DAuthenticationLevel::not_authenticated;
dispatchAuthenticationError(msg, COMMAND_ID, json);
return;
}
#endif // AUTHENTICATION_FEATURE
tmpstr = get_clean_param(msg, cmd_params_pos);
if (tmpstr.length() == 0) {
byteValue = ESP3DSettings::readByte(ESP_ETH_STA_IP_MODE);
if (byteValue == static_cast<uint8_t>(DHCP_MODE)) {
ok_msg = "DHCP";
} else if (byteValue == static_cast<uint8_t>(STATIC_IP_MODE)) {
ok_msg = "STATIC";
} else {
ok_msg = "Unknown:" + String(byteValue);
}
} else {
#if defined(AUTHENTICATION_FEATURE)
if (msg->authentication_level != ESP3DAuthenticationLevel::admin) {
dispatchAuthenticationError(msg, COMMAND_ID, json);
return;
}
#endif // AUTHENTICATION_FEATURE
if (tmpstr == "DHCP") {
byteValue = static_cast<uint8_t>(DHCP_MODE);
} else if (tmpstr == "STATIC") {
byteValue = static_cast<uint8_t>(STATIC_IP_MODE);
} else {
byteValue = (uint8_t)-1; // unknow flag so put outof range value
}
esp3d_log("got %s param for a value of %d, is valid %d", tmpstr.c_str(),
byteValue,
ESP3DSettings::isValidByteSetting(byteValue, ESP_ETH_STA_IP_MODE));
if (ESP3DSettings::isValidByteSetting(byteValue, ESP_ETH_STA_IP_MODE)) {
esp3d_log("Value %d is valid", byteValue);
if (!ESP3DSettings::writeByte(ESP_ETH_STA_IP_MODE, byteValue)) {
hasError = true;
error_msg = "Set value failed";
}
} else {
hasError = true;
error_msg = "Invalid parameter";
}
}

if (!dispatchAnswer(msg, COMMAND_ID, json, hasError,
hasError ? error_msg.c_str() : ok_msg.c_str())) {
esp3d_log_e("Error sending response to clients");
}
}

#endif // ETH_FEATURE
Loading

0 comments on commit 536181b

Please sign in to comment.