Skip to content

Commit 536181b

Browse files
committed
Sync with esp3d 2b1
1 parent b266010 commit 536181b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+6146
-2990
lines changed

embedded/package-lock.json

Lines changed: 1137 additions & 1041 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

embedded/src/index.js

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,8 @@ function processFWJson(text) {
350350
}
351351

352352
if (json.WebUpdate == "Enabled") firmware.classList.remove("hide");
353-
hostpath = json.HostPath;
353+
if (typeof json.HostPath != "undefined") hostpath = json.HostPath;
354+
console.log("HostPath: " + hostpath);
354355
if (json.WiFiMode && json.WebSocketIP) {
355356
if (isLimitedEnvironment(json.WiFiMode)) {
356357
let address =
@@ -404,7 +405,9 @@ function startSocket(ip, port, sync) {
404405
msg += String.fromCharCode(bytes[i]);
405406
if (bytes[i] == 10 || bytes[i] == 13) {
406407
wsMsg += msg;
407-
consoleContentUpdate(wsMsg);
408+
if (!wsMsg.startsWith("ESP3D says: command forwarded")) {
409+
consoleContentUpdate(wsMsg);
410+
}
408411
wsMsg = "";
409412
msg = "";
410413
}
@@ -534,6 +537,13 @@ function dirIcon(plus = false) {
534537
}
535538
function dispatchFileStatus(jsonresponse) {
536539
let json;
540+
let currentpath = currentPath;
541+
if (!currentpath.endsWith("/")) currentpath += "/";
542+
currentpath += hostpath;
543+
if (!currentpath.endsWith("/")) currentpath += "/";
544+
let currentpath2 = currentpath.replaceAll("//", "/");
545+
currentpath = currentpath2;
546+
console.log("currentpath: " + currentpath);
537547
let eventslisteners = [];
538548
let showESP3Dbutton = false;
539549
try {
@@ -606,7 +616,7 @@ function dispatchFileStatus(jsonresponse) {
606616
for (let i1 = 0; i1 < json.files.length; i1++) {
607617
if (String(json.files[i1].size) != "-1") {
608618
if (
609-
currentPath == hostpath &&
619+
currentPath == "/" &&
610620
(json.files[i1].name == "index.html.gz" ||
611621
json.files[i1].name == "index.html")
612622
) {
@@ -660,12 +670,12 @@ function dispatchFileStatus(jsonresponse) {
660670
let url = new URL(
661671
"http://" +
662672
window.location.host +
663-
currentPath +
664-
"/" +
673+
currentpath +
665674
eventslisteners[i].target
666675
);
667676
window.open(url, "_blank");
668677
});
678+
669679
break;
670680
case "filedel":
671681
document
@@ -768,6 +778,11 @@ function uploadFiles() {
768778
formData.append("path", currentPath);
769779
let currentpath = currentPath;
770780
if (!currentpath.endsWith("/")) currentpath += "/";
781+
currentpath += hostpath;
782+
if (!currentpath.endsWith("/")) currentpath += "/";
783+
let currentpath2 = currentpath.replaceAll("//", "/");
784+
currentpath = currentpath2;
785+
console.log(currentpath);
771786
for (let i3 = 0; i3 < files.length; i3++) {
772787
let file = files[i3];
773788
let arg = currentpath + file.name + "S";

embedded/src/menu.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function initMenus() {
1111
});
1212

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

src/core/commands/ESP0.cpp

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,11 @@ const char* help[] = {
2626
"[ESP100](SSID) - display/set STA SSID",
2727
"[ESP101](Password) - set STA password",
2828
#endif // WIFI_FEATURE
29-
#if defined(WIFI_FEATURE) || defined(ETH_FEATURE)
29+
#if defined(WIFI_FEATURE)
3030
"[ESP102](Mode) - display/set STA IP mode (DHCP/STATIC)",
3131
"[ESP103](IP=xxxx MSK=xxxx GW=xxxx) - display/set STA IP/Mask/GW",
32-
#endif // WIFI_FEATURE || ETH_FEATURE
33-
#if defined(WIFI_FEATURE) || defined(BLUETOOTH_FEATURE) || defined(ETH_FEATURE)
3432
"[ESP104](State) - display/set sta fallback mode which can be BT, SETUP, "
3533
"OFF",
36-
#endif // WIFI_FEATURE || BLUETOOTH_FEATURE || ETH_FEATURE
37-
#if defined(WIFI_FEATURE)
3834
"[ESP105](SSID) - display/set AP SSID",
3935
"[ESP106](Password) - set AP password",
4036
"[ESP107](IP) - display/set AP IP",
@@ -53,6 +49,11 @@ const char* help[] = {
5349
"[ESP115](State) - display/set immediate Network state which can be ON, "
5450
"OFF",
5551
#endif // WIFI_FEATURE || ETH_FEATURE || BT_FEATURE
52+
#if defined(ETH_FEATURE)
53+
"[ESP116](Mode) - display/set ETH STA IP mode (DHCP/STATIC)",
54+
"[ESP117](IP=xxxx MSK=xxxx GW=xxxx) - display/set ETH STA IP/Mask/GW",
55+
"[ESP118](State) - display/set eth sta fallback mode which can be BT, Off",
56+
#endif // ETH_FEATURE
5657
#if defined(HTTP_FEATURE)
5758
"[ESP120](State) - display/set HTTP state which can be ON, OFF",
5859
"[ESP121](Port) - display/set HTTP port ",
@@ -116,6 +117,10 @@ const char* help[] = {
116117
"[ESP250]F=(frequency) D=(duration) - play sound on buzzer",
117118
#endif // BUZZER_DEVICE
118119
"[ESP290](delay in ms) - do a pause",
120+
#if defined(ESP_LUA_INTERPRETER_FEATURE)
121+
"[ESP300]<filename> - execute Lua script",
122+
"[ESP301]action=<PAUSE/RESUME/ABORT> - query and control ESP300 execution",
123+
#endif // ESP_LUA_INTERPRETER_FEATURE
119124
"[ESP400] - display ESP3D settings in JSON",
120125
"[ESP401]P=(position) T=(type) V=(value) - Set specific setting",
121126
#ifdef SD_UPDATE_FEATURE
@@ -138,7 +143,7 @@ const char* help[] = {
138143
#endif // AUTHENTICATION_FEATURE
139144
#if defined(NOTIFICATION_FEATURE)
140145
"[ESP600](message) - send notification",
141-
"[ESP610]type=(NONE/PUSHOVER/EMAIL/LINE/TELEGRAM/IFTTT/HOMEASSISTANT) "
146+
"[ESP610]type=(NONE/PUSHOVER/EMAIL/LINE/TELEGRAM/IFTTT/HOMEASSISTANT/WHATSAPP) "
142147
"(T1=xxx) (T2=xxx) "
143148
"(TS=xxx) - display/set Notification settings",
144149
"[ESP620]URL=http://XXXXXX - send GET notification",
@@ -174,13 +179,19 @@ const char* help[] = {
174179
"[ESP900](ENABLE/DISABLE) - display/set serial state",
175180
"[ESP901]<BAUD RATE> - display/set serial baud rate",
176181
#endif // COMMUNICATION_PROTOCOL != SOCKET_SERIAL
182+
#if defined(USB_SERIAL_FEATURE)
183+
"[ESP902]<BAUD RATE> - display/set USB Serial baud rate",
184+
#endif // defined(USB_SERIAL_FEATURE)
177185
#ifdef BUZZER_DEVICE
178186
"[ESP910](ENABLE/DISABLE) - display/set buzzer state",
179187
#endif // BUZZER_DEVICE
180188
#if defined(ESP_SERIAL_BRIDGE_OUTPUT)
181189
"[ESP930](ENABLE/DISABLE/CLOSE) - display/set serial bridge state",
182190
"[ESP931]<BAUD RATE> - display/set serial bridge baud rate",
183191
#endif // defined(ESP_SERIAL_BRIDGE_OUTPUT)
192+
#if defined(USB_SERIAL_FEATURE)
193+
"[ESP950]<SERIAL/USB> - display/set client output",
194+
#endif // defined(USB_SERIAL_FEATURE)
184195
#if defined(ARDUINO_ARCH_ESP32) && \
185196
(CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32S2 || \
186197
CONFIG_IDF_TARGET_ESP32C3)
@@ -192,13 +203,9 @@ const uint cmdlist[] = {
192203
#if defined(WIFI_FEATURE)
193204
100, 101,
194205
#endif // WIFI_FEATURE
195-
#if defined(WIFI_FEATURE) || defined(ETH_FEATURE)
206+
#if defined(WIFI_FEATURE)
196207
102, 103,
197-
#endif // WIFI_FEATURE || ETH_FEATURE
198-
#if defined(WIFI_FEATURE) || defined(BLUETOOTH_FEATURE) || defined(ETH_FEATURE)
199208
104,
200-
#endif // WIFI_FEATURE || BLUETOOTH_FEATURE || ETH_FEATURE
201-
#if defined(WIFI_FEATURE)
202209
105, 106, 107, 108,
203210
#endif // WIFI_FEATURE
204211
#if defined(WIFI_FEATURE) || defined(BLUETOOTH_FEATURE) || defined(ETH_FEATURE)
@@ -210,6 +217,9 @@ const uint cmdlist[] = {
210217
#if defined(WIFI_FEATURE) || defined(ETH_FEATURE) || defined(BT_FEATURE)
211218
112, 114, 115,
212219
#endif // WIFI_FEATURE || ETH_FEATURE || BT_FEATURE
220+
#if defined(ETH_FEATURE)
221+
116, 117, 118,
222+
#endif // ETH_FEATURE
213223
#if defined(HTTP_FEATURE)
214224
120, 121,
215225
#endif // HTTP_FEATURE
@@ -257,7 +267,11 @@ const uint cmdlist[] = {
257267
#ifdef BUZZER_DEVICE
258268
250,
259269
#endif // BUZZER_DEVICE
260-
290, 400, 401,
270+
290,
271+
#if defined(ESP_LUA_INTERPRETER_FEATURE)
272+
300, 301,
273+
#endif // ESP_LUA_INTERPRETER_FEATURE
274+
400, 401,
261275
#ifdef SD_UPDATE_FEATURE
262276
402,
263277
#endif // SD_UPDATE_FEATURE
@@ -296,13 +310,18 @@ const uint cmdlist[] = {
296310
#if COMMUNICATION_PROTOCOL != SOCKET_SERIAL
297311
900, 901,
298312
#endif // COMMUNICATION_PROTOCOL != SOCKET_SERIAL
313+
#if defined(USB_SERIAL_FEATURE)
314+
902,
315+
#endif // defined(USB_SERIAL_FEATURE)
299316
#ifdef BUZZER_DEVICE
300317
910,
301-
302318
#endif // BUZZER_DEVICE
303319
#if defined(ESP_SERIAL_BRIDGE_OUTPUT)
304320
930, 931,
305321
#endif // defined(ESP_SERIAL_BRIDGE_OUTPUT)
322+
#if defined(USB_SERIAL_FEATURE)
323+
950,
324+
#endif // defined(USB_SERIAL_FEATURE)
306325
#if defined(ARDUINO_ARCH_ESP32) && \
307326
(CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32S2 || \
308327
CONFIG_IDF_TARGET_ESP32C3)

src/core/commands/ESP102.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,14 @@
1818
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1919
*/
2020
#include "../../include/esp3d_config.h"
21-
#if defined(WIFI_FEATURE) || defined(ETH_FEATURE)
21+
#if defined(WIFI_FEATURE)
2222
#include "../../modules/network/netconfig.h"
2323
#include "../esp3d_commands.h"
2424
#include "../esp3d_settings.h"
2525

2626
#if defined(WIFI_FEATURE)
2727
#include "../../modules/wifi/wificonfig.h"
2828
#endif // WIFI_FEATURE
29-
#if defined(ETH_FEATURE)
30-
#include "../../modules/ethernet/ethconfig.h"
31-
#endif // ETH_FEATURE
3229
#include "../../modules/authentication/authentication_service.h"
3330
#define COMMAND_ID 102
3431
// Change STA IP mode (DHCP/STATIC)
@@ -97,4 +94,4 @@ void ESP3DCommands::ESP102(int cmd_params_pos, ESP3DMessage* msg) {
9794
}
9895
}
9996

100-
#endif // WIFI_FEATURE || ETH_FEATURE
97+
#endif // WIFI_FEATURE

src/core/commands/ESP103.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,14 @@
1818
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1919
*/
2020
#include "../../include/esp3d_config.h"
21-
#if defined(WIFI_FEATURE) || defined(ETH_FEATURE)
21+
#if defined(WIFI_FEATURE)
2222
#include "../../modules/network/netconfig.h"
2323
#include "../esp3d_commands.h"
2424
#include "../esp3d_settings.h"
2525

2626
#if defined(WIFI_FEATURE)
2727
#include "../../modules/wifi/wificonfig.h"
2828
#endif // WIFI_FEATURE
29-
#if defined(ETH_FEATURE)
30-
#include "../../modules/ethernet/ethconfig.h"
31-
#endif // ETH_FEATURE
3229
#include "../../modules/authentication/authentication_service.h"
3330
#define COMMAND_ID 103
3431
// Change STA IP/Mask/GW
@@ -121,4 +118,4 @@ void ESP3DCommands::ESP103(int cmd_params_pos, ESP3DMessage* msg) {
121118
}
122119
}
123120

124-
#endif // WIFI_FEATURE || ETH_FEATURE
121+
#endif // WIFI_FEATURE

src/core/commands/ESP104.cpp

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1919
*/
2020
#include "../../include/esp3d_config.h"
21-
#if defined(WIFI_FEATURE) || defined(BLUETOOTH_FEATURE) || defined(ETH_FEATURE)
21+
#if defined(WIFI_FEATURE)
2222
#include "../../modules/authentication/authentication_service.h"
2323
#include "../../modules/network/netconfig.h"
2424
#include "../esp3d_commands.h"
@@ -54,11 +54,6 @@ void ESP3DCommands::ESP104(int cmd_params_pos, ESP3DMessage* msg) {
5454
ok_msg = "BT";
5555
} else
5656
#endif // BLUETOOTH_FEATURE
57-
#if defined(WIFI_FEATURE)
58-
if (byteValue == (uint8_t)ESP_AP_SETUP) {
59-
ok_msg = "CONFIG";
60-
} else
61-
#endif // WIFI_FEATURE
6257
if (byteValue == (uint8_t)ESP_NO_NETWORK) {
6358
ok_msg = "OFF";
6459
} else {
@@ -76,11 +71,6 @@ void ESP3DCommands::ESP104(int cmd_params_pos, ESP3DMessage* msg) {
7671
byteValue = (uint8_t)ESP_BT;
7772
} else
7873
#endif // BLUETOOTH_FEATURE
79-
#if defined(WIFI_FEATURE)
80-
if (tmpstr == "CONFIG") {
81-
byteValue = (uint8_t)ESP_AP_SETUP;
82-
} else
83-
#endif // WIFI_FEATURE
8474
if (tmpstr == "OFF") {
8575
byteValue = (uint8_t)ESP_NO_NETWORK;
8676
} else {

src/core/commands/ESP116.cpp

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
/*
2+
ESP116.cpp - ESP3D command class
3+
4+
Copyright (c) 2014 Luc Lebosse. All rights reserved.
5+
6+
This code is free software; you can redistribute it and/or
7+
modify it under the terms of the GNU Lesser General Public
8+
License as published by the Free Software Foundation; either
9+
version 2.1 of the License, or (at your option) any later version.
10+
11+
This code is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
Lesser General Public License for more details.
15+
16+
You should have received a copy of the GNU Lesser General Public
17+
License along with This code; if not, write to the Free Software
18+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19+
*/
20+
#include "../../include/esp3d_config.h"
21+
#if defined(ETH_FEATURE)
22+
#include "../../modules/network/netconfig.h"
23+
#include "../esp3d_commands.h"
24+
#include "../esp3d_settings.h"
25+
#include "../../modules/ethernet/ethconfig.h"
26+
#include "../../modules/authentication/authentication_service.h"
27+
#define COMMAND_ID 116
28+
// Change ETH STA IP mode (DHCP/STATIC)
29+
//[ESP116]<mode>[json=no] [pwd=<admin password>]
30+
void ESP3DCommands::ESP116(int cmd_params_pos, ESP3DMessage* msg) {
31+
ESP3DClientType target = msg->origin;
32+
ESP3DRequest requestId = msg->request_id;
33+
(void)requestId;
34+
msg->target = target;
35+
msg->origin = ESP3DClientType::command;
36+
bool hasError = false;
37+
String error_msg = "Invalid parameters";
38+
String ok_msg = "ok";
39+
bool json = hasTag(msg, cmd_params_pos, "json");
40+
String tmpstr;
41+
uint8_t byteValue = (uint8_t)-1;
42+
#if defined(AUTHENTICATION_FEATURE)
43+
if (msg->authentication_level == ESP3DAuthenticationLevel::guest) {
44+
msg->authentication_level = ESP3DAuthenticationLevel::not_authenticated;
45+
dispatchAuthenticationError(msg, COMMAND_ID, json);
46+
return;
47+
}
48+
#endif // AUTHENTICATION_FEATURE
49+
tmpstr = get_clean_param(msg, cmd_params_pos);
50+
if (tmpstr.length() == 0) {
51+
byteValue = ESP3DSettings::readByte(ESP_ETH_STA_IP_MODE);
52+
if (byteValue == static_cast<uint8_t>(DHCP_MODE)) {
53+
ok_msg = "DHCP";
54+
} else if (byteValue == static_cast<uint8_t>(STATIC_IP_MODE)) {
55+
ok_msg = "STATIC";
56+
} else {
57+
ok_msg = "Unknown:" + String(byteValue);
58+
}
59+
} else {
60+
#if defined(AUTHENTICATION_FEATURE)
61+
if (msg->authentication_level != ESP3DAuthenticationLevel::admin) {
62+
dispatchAuthenticationError(msg, COMMAND_ID, json);
63+
return;
64+
}
65+
#endif // AUTHENTICATION_FEATURE
66+
if (tmpstr == "DHCP") {
67+
byteValue = static_cast<uint8_t>(DHCP_MODE);
68+
} else if (tmpstr == "STATIC") {
69+
byteValue = static_cast<uint8_t>(STATIC_IP_MODE);
70+
} else {
71+
byteValue = (uint8_t)-1; // unknow flag so put outof range value
72+
}
73+
esp3d_log("got %s param for a value of %d, is valid %d", tmpstr.c_str(),
74+
byteValue,
75+
ESP3DSettings::isValidByteSetting(byteValue, ESP_ETH_STA_IP_MODE));
76+
if (ESP3DSettings::isValidByteSetting(byteValue, ESP_ETH_STA_IP_MODE)) {
77+
esp3d_log("Value %d is valid", byteValue);
78+
if (!ESP3DSettings::writeByte(ESP_ETH_STA_IP_MODE, byteValue)) {
79+
hasError = true;
80+
error_msg = "Set value failed";
81+
}
82+
} else {
83+
hasError = true;
84+
error_msg = "Invalid parameter";
85+
}
86+
}
87+
88+
if (!dispatchAnswer(msg, COMMAND_ID, json, hasError,
89+
hasError ? error_msg.c_str() : ok_msg.c_str())) {
90+
esp3d_log_e("Error sending response to clients");
91+
}
92+
}
93+
94+
#endif // ETH_FEATURE

0 commit comments

Comments
 (0)