Compare commits

..

10 commits

Author SHA1 Message Date
318fd4c7a0 web stuff
Some checks are pending
build-ci / build (push) Waiting to run
2026-04-04 17:41:10 -03:00
afe9e9d389 disable serial for 3d 2026-04-04 17:04:18 -03:00
d6ed8bdcc2 hobart changes 2026-04-04 16:38:32 -03:00
allcontributors[bot]
6132284030
docs: add Binch3000 as a contributor for bug (#1129)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

---------

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2026-03-19 09:32:17 +08:00
Luc
b425508f7c Fix compilation on eth if no wifi due to typo thanks @Binch3000 2026-03-19 08:39:34 +08:00
Luc
83baa7ddee Update info.json 2026-03-18 12:07:46 +08:00
Luc
7cbfca75d2 Fix W55000 Comnpilation 2026-03-18 10:42:41 +08:00
Luc
aba6ecba63 Update platformio.ini
Fix platformio warning for colorize
2026-03-18 10:23:51 +08:00
Luc
72843a6847 Disable idf log errors 2026-03-18 10:23:16 +08:00
Luc
c75c8d08c4 Rename license file name due to github API rules 2026-03-10 21:43:03 +08:00
23 changed files with 1920 additions and 2054 deletions

View file

@ -16,6 +16,15 @@
"bug",
"code"
]
},
{
"login": "Binch3000",
"name": "Binch3000",
"avatar_url": "https://avatars.githubusercontent.com/u/168651837?v=4",
"profile": "https://github.com/Binch3000",
"contributions": [
"bug"
]
}
],
"contributorsPerLine": 7,

View file

View file

@ -1,6 +1,6 @@
# ESP3D 3.0 ![ESP3D](https://img.shields.io/badge/dynamic/json?label=ESP3D&query=$.version&url=https://raw.githubusercontent.com/luc-github/ESP3D/refs/heads/3.0/info.json)
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors-)
[![All Contributors](https://img.shields.io/badge/all_contributors-2-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END -->
<img src="https://github.com/luc-github/ESP3D/blob/3.0/images/Screen/logo2.png">
Firmware for ESP8266/ESP8285 and ESP32 (original, pico, S2, S3, C3, C6) used with 3D printer/Sand-Table and CNC
@ -131,6 +131,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<tbody>
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/BerranRemzi"><img src="https://avatars.githubusercontent.com/u/11856339?v=4?s=100" width="100px;" alt="Berran Remzi"/><br /><sub><b>Berran Remzi</b></sub></a><br /><a href="https://github.com/luc-github/ESP3D/issues?q=author%3ABerranRemzi" title="Bug reports">🐛</a> <a href="https://github.com/luc-github/ESP3D/commits?author=BerranRemzi" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/Binch3000"><img src="https://avatars.githubusercontent.com/u/168651837?v=4?s=100" width="100px;" alt="Binch3000"/><br /><sub><b>Binch3000</b></sub></a><br /><a href="https://github.com/luc-github/ESP3D/issues?q=author%3ABinch3000" title="Bug reports">🐛</a></td>
</tr>
</tbody>
</table>

1468
embedded/dist/embedded.h vendored

File diff suppressed because it is too large Load diff

View file

@ -22,7 +22,7 @@
#define __favicon_h
#define favicon_size 344
const unsigned char favicon[344] PROGMEM = {
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0xb5, 0x94, 0x31, 0x4b, 0xc3, 0x50,
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xb5, 0x94, 0x31, 0x4b, 0xc3, 0x50,
0x14, 0x85, 0x4f, 0x63, 0xc1, 0x5a, 0x0b, 0x06, 0x91, 0x4e, 0x52, 0x3a, 0x44, 0x10, 0x27, 0x31,
0x45, 0xdc, 0xec, 0xd4, 0xdf, 0x21, 0x99, 0x44, 0x1c, 0x44, 0x74, 0x17, 0x9c, 0x8a, 0x73, 0x7f,
0x80, 0xbf, 0xa0, 0x63, 0x56, 0x1d, 0x1d, 0x9c, 0xa4, 0x74, 0x15, 0x1c, 0xc4, 0x4d, 0x90, 0x0e,

View file

@ -10,7 +10,7 @@
<meta name="msapplication-navbutton-color" content="#5755d9">
<!-- iOS Safari -->
<meta name="apple-mobile-web-app-status-bar-style" content="#5755d9">
<title>Document</title>
<title>SD WIFI Pro</title>
</head>
<body>
<div>
@ -29,33 +29,12 @@
<div id="MSGLimited"></div>
<div id="MSG"></div>
</center>
<div id="consolePanel" class="panel hide">
<div id="consoleHeader" class="panel-header">Terminal</div>
<div id="consoleBody" class="panel-body no-footer">
<div class="controlBar">
<input
class="formControl"
spellcheck="false"
autocorrect="off"
autocomplete="off"
type="text"
value=""
id="customCmdTxt"
/>
<button class="btn" id="cmdBtn">Send</button>
<div class="controlBar">
<input type="checkbox" id="monitor_enable_autoscroll" checked />
<label for="monitor_enable_autoscroll">Autoscroll</label>
</div>
</div>
<pre id="consoleContent"></pre>
</div>
</div>
<div id="fileSystem" class="panel hide">
<div id="fileSystemHeader" class="panel-header">FileSystem</div>
<div id="fileSystemHeader" class="panel-header">SD Card</div>
<div id="fileSystemBody" class="panel-body no-footer">
<div class="controlBar">
<input class="hide" type="file" value="" id="files" multiple />
<button class="btn" id="sdToggle" title="Connect/disconnect SD card">SD: --</button>
<button class="btn" id="refresh">Refresh</button>
<button class="btn" id="createdir" title="Create directory">+</button>
<button class="btn" id="uploadFiles" title="upload files">+</button>
@ -79,6 +58,29 @@
</div>
</div>
</div>
<div id="consolePanel" class="panel hide">
<div id="consoleHeader" class="panel-header">Console</div>
<div id="consoleBody" class="panel-body no-footer">
<div class="controlBar">
<input
class="formControl"
spellcheck="false"
autocorrect="off"
autocomplete="off"
type="text"
value=""
id="customCmdTxt"
placeholder="[ESP200] ..."
/>
<button class="btn" id="cmdBtn">Send</button>
<div class="controlBar">
<input type="checkbox" id="monitor_enable_autoscroll" checked />
<label for="monitor_enable_autoscroll">Autoscroll</label>
</div>
</div>
<pre id="consoleContent"></pre>
</div>
</div>
<div id="firmware" class="panel hide">
<div id="firmwareHeader" class="panel-header">Firmware update</div>
<div id="firmwareBody" class="panel-body no-footer">

View file

@ -22,6 +22,7 @@ let filesButton;
let firmwareButton;
let refreshButton;
let createDirButton;
let sdToggleButton;
let message;
let messageLimited;
let websocketStarted = false;
@ -40,8 +41,9 @@ let loginLink;
let loginModal;
let loginUser = "";
let loginMsg;
let fspath = "/files";
let fspath = "/sdfiles";
let hostpath = "/";
let sdGrabbed = false;
window.onload = function () {
consolePanel = document.getElementById("consolePanel");
@ -214,10 +216,72 @@ window.onload = function () {
SendFileCommand("createdir", filename.trim());
}
});
// SD card manual toggle button
sdToggleButton = document.getElementById("sdToggle");
sdToggleButton.addEventListener("click", function () {
if (sdGrabbed) {
sdRelease();
} else {
sdGrab();
}
});
getFWData();
initMenus();
};
function sdGrab() {
let url = new URL("http://" + window.location.host + "/command");
url.searchParams.append("cmd", "[ESP200]GRABSD json=YES");
httpGet(url, function (text) {
let json;
try {
json = JSON.parse(text);
} catch (e) {
consoleContentUpdate(text + "\n");
return;
}
if (json.status == "ok") {
sdGrabbed = true;
updateSdToggleButton();
SendFileCommand("list", "all");
} else {
ErrorMSG("Failed to grab SD: " + (json.data || "unknown error"));
}
consoleContentUpdate(JSON.stringify(json, null, " ") + "\n");
});
}
function sdRelease() {
let url = new URL("http://" + window.location.host + "/command");
url.searchParams.append("cmd", "[ESP200]RELEASESD json=YES");
httpGet(url, function (text) {
let json;
try {
json = JSON.parse(text);
} catch (e) {
consoleContentUpdate(text + "\n");
return;
}
sdGrabbed = false;
updateSdToggleButton();
document.getElementById("fileList").innerHTML = "";
filecontentFooter.innerHTML = "SD released to host";
consoleContentUpdate(JSON.stringify(json, null, " ") + "\n");
});
}
function updateSdToggleButton() {
if (sdGrabbed) {
sdToggleButton.innerHTML = "SD: Connected";
sdToggleButton.style.backgroundColor = "#32b643";
} else {
sdToggleButton.innerHTML = "SD: Disconnected";
sdToggleButton.style.backgroundColor = "#e85600";
}
}
function handle401() {
loginModal.classList.remove("hide");
loginLink.classList.remove("hide");
@ -255,19 +319,16 @@ function getPCTime() {
function isLimitedEnvironment(wifiMode) {
let sitesList = [
"clients3.google.com", //Android Captive Portal Detection
"clients3.google.com",
"connectivitycheck.",
//Apple iPhone, iPad with iOS 6 Captive Portal Detection
"apple.com",
".akamaitechnologies.com",
//Apple iPhone, iPad with iOS 7, 8, 9 and recent versions of OS X
"www.appleiphonecell.com",
"www.itools.info",
"www.ibook.info",
"www.airport.us",
"www.thinkdifferent.us",
".akamaiedge.net",
//Windows
".msftncsi.com",
"microsoft.com",
];
@ -339,14 +400,19 @@ function processFWJson(text) {
window.open(url);
});
consolePanel.classList.remove("hide");
// Determine filesystem path - prefer SD card
if (json.SDConnection && json.SDConnection != "none") {
fspath = "/sdfiles";
} else if (json.FlashFileSystem && json.FlashFileSystem != "none") {
fspath = "/files";
}
if (
(json.FlashFileSystem && json.FlashFileSystem != "none") ||
(json.SDConnection && json.SDConnection != "none")
) {
fileSystem.classList.remove("hide");
if (json.FlashFileSystem && json.FlashFileSystem == "none") {
fspath = "/sdfiles";
}
}
if (json.WebUpdate == "Enabled") firmware.classList.remove("hide");
@ -366,8 +432,11 @@ function processFWJson(text) {
}
}
if (json.Hostname) document.title = json.Hostname;
// Auto-grab SD on load so file listing works immediately
sdGrab();
startSocket(json.WebSocketIP, json.WebSocketPort, json.WebCommunication);
SendFileCommand("list", "all");
}
function startSocket(ip, port, sync) {
@ -385,8 +454,6 @@ function startSocket(ip, port, sync) {
};
wsSource.onclose = function (e) {
websocketStarted = false;
//seems sometimes it disconnect so wait 3s and reconnect
//if it is not a log off
if (!logOff)
setTimeout(() => {
startSocket(ip, port, sync);
@ -398,16 +465,13 @@ function startSocket(ip, port, sync) {
};
wsSource.onmessage = function (e) {
let msg = "";
//bin
if (e.data instanceof ArrayBuffer) {
let bytes = new Uint8Array(e.data);
for (let i = 0; i < bytes.length; i++) {
msg += String.fromCharCode(bytes[i]);
if (bytes[i] == 10 || bytes[i] == 13) {
wsMsg += msg;
if (!wsMsg.startsWith("ESP3D says: command forwarded")) {
consoleContentUpdate(wsMsg);
}
wsMsg = "";
msg = "";
}
@ -470,7 +534,6 @@ function uploadError(msg, nb) {
} else if (uploadType == 2) {
prgupdatetext.innerHTML = status;
}
//location.reload();
}
function ErrorMSG(msg) {
@ -548,7 +611,6 @@ function dispatchFileStatus(jsonresponse) {
let showESP3Dbutton = false;
try {
json = JSON.parse(jsonresponse);
//ugly but code is smaller
filecontentFooter.innerHTML =
"<span>Status: " +
json.status +
@ -757,7 +819,6 @@ function httpGet(url, processfn) {
}
function compareStrings(a, b) {
// case-insensitive comparison
a = a.toLowerCase();
b = b.toLowerCase();
return a < b ? -1 : a > b ? 1 : 0;
@ -786,15 +847,12 @@ function uploadFiles() {
for (let i3 = 0; i3 < files.length; i3++) {
let file = files[i3];
let arg = currentpath + file.name + "S";
//append file size first to check updload is complete
formData.append(arg, file.size);
formData.append("myfiles", file, currentpath + file.name);
}
xmlhttpupload = new XMLHttpRequest();
xmlhttpupload.open("POST", fspath, true);
//progress upload event
xmlhttpupload.upload.addEventListener("progress", updateProgress, false);
//progress function
function updateProgress(oEvent) {
if (oEvent.lengthComputable) {
let percentComplete = (oEvent.loaded / oEvent.total) * 100;
@ -802,7 +860,6 @@ function uploadFiles() {
prgfiletext.innerHTML =
"Uploading ..." + percentComplete.toFixed(0) + "%";
} else {
// Impossible because size is unknown
console.log("oops");
}
}
@ -816,7 +873,7 @@ function uploadFiles() {
filesInput.value = "";
if (xmlhttpupload.status === 200) {
dispatchFileStatus(xmlhttpupload.responseText);
} else if (xmlhttp.status == 401) {
} else if (xmlhttpupload.status == 401) {
handle401();
} else uploadError("Error", xmlhttpupload.status);
};
@ -840,15 +897,12 @@ function uploadFirmware() {
for (let i3 = 0; i3 < files.length; i3++) {
let file = files[i3];
let arg = currentpath + file.name + "S";
//append file size first to check updload is complete
formData.append(arg, file.size);
formData.append("myfiles", file, currentpath + file.name);
}
xmlhttpupload = new XMLHttpRequest();
xmlhttpupload.open("POST", "/updatefw", true);
//progress upload event
xmlhttpupload.upload.addEventListener("progress", updateProgress, false);
//progress function
function updateProgress(oEvent) {
if (oEvent.lengthComputable) {
let percentComplete = (oEvent.loaded / oEvent.total) * 100;
@ -856,7 +910,6 @@ function uploadFirmware() {
prgupdatetext.innerHTML =
"Uploading ..." + percentComplete.toFixed(0) + "%";
} else {
// Impossible because size is unknown
console.log("oops");
}
}
@ -879,7 +932,7 @@ function uploadFirmware() {
InfoMSG("<br/>Restarting... please wait " + restartTime + "s");
if (restartTime == 0) location.reload();
}, 1000);
} else if (xmlhttp.status == 401) {
} else if (xmlhttpupload.status == 401) {
handle401();
} else uploadError("Error", xmlhttpupload.status);
};

View file

@ -19,6 +19,12 @@
*/
#ifndef _CONFIGURATION_H
#define _CONFIGURATION_H
// ============================================================================
// SD WIFI Pro (FYSETC) configuration
// ESP32 / 4MB flash / SDIO 4-bit shared SD
// ============================================================================
/* Setup station as default, use AP mode first if not done
* Note: need both defined to enable it
* Uncomment and edit them to define
@ -35,19 +41,6 @@
#include "myconfig.h"
#endif
#endif
/************************************
*
* ESP32 C3 -patch
*
* Uncomment only if your ESP32 C3 board cannot start
*
************************************/
// Possible values
// WIFI_POWER_5dBm
// WIFI_POWER_8_5dBm
// WIFI_POWER_15dBm
// #define ESP32_WIFI_TX_POWER WIFI_POWER_15dBm
/************************************
*
@ -59,36 +52,15 @@
/* Serial Communication protocol
* RAW_SERIAL // Basic serial protocol, without data change
* MKS_SERIAL // This is a MakerBase communication protocol, used with MKS
* printers and TFT, it encapsulated data in a custom protocol
* MKS_SERIAL // MakerBase communication protocol
*/
#define COMMUNICATION_PROTOCOL RAW_SERIAL
/* Main Serial port / Ouptut
* which serial ESP use to communicate to printer (ESP32 has 3 serials
* available, ESP8266 only 2) USE_SERIAL_0 //for ESP8266/32, also used by
* bootloader output, so consider to make it quiet USE_SERIAL_1 //for ESP8266/32
* USE_SERIAL_2 //for ESP32 Only
/* Main Serial port
* USE_SERIAL_0 / USE_SERIAL_1 / USE_SERIAL_2
*/
// Main serial port
#define ESP_SERIAL_OUTPUT USE_SERIAL_0
/* Optional Output
* Instead of Serial, you can use USB Serial
* USB_SERIAL_FEATURE on ESP32 S2/S3 Only
*/
//#define USB_SERIAL_FEATURE
/* Bridge Serial port (deprecated on esp8266 as second serial is)
* which serial ESP use to bridge to another device (ESP32 has 3 serials
* available, ESP8266 only 2) USE_SERIAL_0 //for ESP8266/32, also used by
* bootloader output, so consider to make it quiet USE_SERIAL_1 //for ESP8266/32
* USE_SERIAL_2 //for ESP32 Only\
* Comment if not used
*/
// #define ESP_SERIAL_BRIDGE_OUTPUT USE_SERIAL_1
/* Serial buffer size
* Maximum size of the serial buffer
*/
@ -98,16 +70,9 @@
*
* Target firmware
*
* Targeted firmware that ESP3D will communicate with
* Not used - this is a standalone SD WiFi device
*
************************************/
/* Target firmware (default UNKNOWN_FW can be changed later in settings)
* UNKNOWN_FW
* GRBL
* MARLIN
* SMOOTHIEWARE
* REPETIER
*/
#define DEFAULT_FW UNKNOWN_FW
/************************************
@ -123,51 +88,6 @@
*/
#define WIFI_FEATURE
/* Use Ethernet
* Enable ethernet communications
*/
// #define ETH_FEATURE
// Ethernet type (Check ETH.h eth_phy_type_t)
// TYPE_ETH_PHY_LAN8720
// TYPE_ETH_PHY_TLK110
// TYPE_ETH_PHY_RTL8201
// TYPE_ETH_PHY_DP83848
// TYPE_ETH_PHY_DM9051
// TYPE_ETH_PHY_KSZ8041
// TYPE_ETH_PHY_KSZ8081
// TYPE_ETH_PHY_W5500
#define ESP3D_ETH_PHY_TYPE TYPE_ETH_PHY_W5500
// Ethernet board Clock mode
// MODE_ETH_CLOCK_GPIO0_IN
// MODE_ETH_CLOCK_GPIO0_OUT
// MODE_ETH_CLOCK_GPIO16_OUT
// MODE_ETH_CLOCK_GPIO17_OUT
//#define ESP3D_ETH_CLK_MODE MODE_ETH_CLOCK_GPIO0_IN
// Pins of ethernet board
//#define ESP3D_ETH_PHY_POWER_PIN 16
//#define ESP3D_ETH_PHY_MDC_PIN 23
//#define ESP3D_ETH_PHY_MDIO_PIN 18
// These are the pins for the W5500 chip using SPI
#define ETHERNET_SPI_USE_SPI 1
#define ETHERNET_SPI_USE_SPI2 0
#define ETH_SPI_SCK 18
#define ETH_SPI_MISO 23
#define ETH_SPI_MOSI 19
#define ETH_PHY_CS 5
#define ETH_PHY_IRQ -1
#define ETH_PHY_RST 4
// Address of ethernet board
#define ESP3D_ETH_PHY_ADDR 1
/* Use Bluetooth
* Enable serial bluetooth communications
*/
//#define BLUETOOTH_FEATURE
/************************************
*
* Channels of ESP3D
@ -181,19 +101,10 @@
*/
#define HTTP_FEATURE
/* Use telnet server
* Enable telnet light (raw tcp) communications
*/
#define TELNET_FEATURE
/* Disable telnet welcome message
*/
#define DISABLE_TELNET_WELCOME_MESSAGE
/* Use Websocket server
* Enable websocket communications
*/
// #define WS_DATA_FEATURE
#define WS_DATA_FEATURE
// Enable notifications
// Allows to send notifications to the user
@ -207,7 +118,7 @@
/* Notification title message
* The title of notification
*/
#define ESP_NOTIFICATION_TITLE "ESP3D Notification"
#define ESP_NOTIFICATION_TITLE "SD WIFI Pro Notification"
/************************************
*
@ -240,30 +151,20 @@
*
************************************/
/* Model name
* Modele name of device
*/
#define ESP_MODEL_NAME "ESP Board"
/* Model name */
#define ESP_MODEL_NAME "SD_WIFI_PRO"
/* Model number
* Modele number of device
*/
#define ESP_MODEL_NUMBER "ESP3D 3.0"
/* Model number */
#define ESP_MODEL_NUMBER "SWP 1.0"
/* Model url
* Modele url of device
*/
#define ESP_MODEL_URL "https://www.espressif.com/en/products/devkits"
/* Model url */
#define ESP_MODEL_URL "https://github.com/FYSETC/SD-WIFI-PRO"
/* Manufacturer name
* Manufacturer name of device
*/
#define ESP_MANUFACTURER_NAME "Espressif Systems"
/* Manufacturer name */
#define ESP_MANUFACTURER_NAME "FYSETC"
/* Manufacturer url
* Manufacturer url of device
*/
#define ESP_MANUFACTURER_URL "https://www.espressif.com"
/* Manufacturer url */
#define ESP_MANUFACTURER_URL "https://www.fysetc.com"
/************************************
*
@ -274,7 +175,6 @@
************************************/
/* File system type used by ESP3D
* Type of file system used by ESP3D to store files
* ESP_SPIFFS_FILESYSTEM (Deprecated)
* ESP_FAT_FILESYSTEM (ESP32 only with large partitions)
* ESP_LITTLEFS_FILESYSTEM (Default)
@ -290,76 +190,47 @@
*
* SD filesystem
*
* Filesystem on SD card
* Filesystem on SD card - SDIO 4-bit shared mode
*
************************************/
/* SD card connection
* ESP_NO_SD //(default)
* ESP_NOT_SHARED_SD //Only your ESP board is connected to SDCard
* ESP_SHARED_SD //Printer SD Card is also connected to ESP3D
* Does your system has SD card and how it is connected to your ESP3D
* ESP_SHARED_SD: both host and ESP share the SD card
*/
//#define SD_DEVICE_CONNECTION ESP_NOT_SHARED_SD
#define SD_DEVICE_CONNECTION ESP_SHARED_SD
/* SD card library
* ESP_SD_NATIVE //esp32 / esp8266
* ESP_SDIO //esp32 only
* ESP_SDFAT2 //esp8266 / esp32
* ESP_SDIO: ESP32 SDMMC (4-bit mode)
*/
//#define SD_DEVICE ESP_SDFAT2
#define SD_DEVICE ESP_SDIO
// #define SD_CARD_TYPE ESP_FYSETC_WIFI_PRO_SDCARD
/* Sdio bit mode
* Mode used by SDIO library 1 bit / 4bits
* SD_ONE_BIT_MODE
* SD_FOUR_BIT_MODE
/* SDIO bit mode
* SD_FOUR_BIT_MODE for maximum throughput
*/
//#define SDIO_BIT_MODE SD_ONE_BIT_MODE
#define SDIO_BIT_MODE SD_FOUR_BIT_MODE
/* Enable date/time on files
* Set date/time on files using SNTP or last webui connection
*/
// #define SD_TIMESTAMP_FEATURE
/* Enable date/time on files */
#define SD_TIMESTAMP_FEATURE
/************************************
*
* SD card pins
* SD card pins (SDIO mode for SD WIFI Pro)
*
************************************/
/* SD card detect pin
* The pin used to detect SD card
*/
// #define ESP_SD_DETECT_PIN 4
/* SD card detect pin value
* State of SD card detect pin when card is present
*/
// #define ESP_SD_DETECT_VALUE 0
/* SD shared flag pin
* The pin used to enable SD card for ESP board
* Active LOW to claim SD for ESP
*/
// #define ESP_FLAG_SHARED_SD_PIN -1
#define ESP_FLAG_SHARED_SD_PIN 26
#define ESP_FLAG_SHARED_SD_VALUE 0
/* SD shared flag pin value
* State of SD card shared pin for ESP board
*/
// #define ESP_FLAG_SHARED_SD_VALUE 0
/* SD card CS pin
* The pin used to select SD card in SPI mode
*/
//#define ESP_SD_CS_PIN 21
//#define ESP_SD_MISO_PIN 8
//#define ESP_SD_MOSI_PIN 9
//#define ESP_SD_SCK_PIN 7
//#define ESP_SDIO_CMD_PIN 38
//#define ESP_SDIO_D0_PIN 40
//#define ESP_SDIO_CLK_PIN 39
/* SDIO pins (standard ESP32 SDMMC pins) */
#define ESP_SDIO_CLK_PIN 14
#define ESP_SDIO_CMD_PIN 15
#define ESP_SDIO_D0_PIN 2
#define ESP_SDIO_D1_PIN 4
#define ESP_SDIO_D2_PIN 12
#define ESP_SDIO_D3_PIN 13
/************************************
*
@ -372,42 +243,17 @@
/* Enable global filesystem
* Allows to access to all filesystems from same location
*/
//#define GLOBAL_FILESYSTEM_FEATURE
#define GLOBAL_FILESYSTEM_FEATURE
/* WebDav access
* Use WebDav to access to your filesystem
* FS_ROOT //mount all FS, need GLOBAL_FILESYSTEM_FEATURE
* FS_FLASH //mount Flash FS
* FS_SD mount SD FS
* FS_ROOT / FS_FLASH / FS_SD
*/
//#define WEBDAV_FEATURE FS_ROOT
#define WEBDAV_FEATURE FS_SD
/* FTP access
* Use FTP to access to your filesystem (1 connection only)
* FS_ROOT //mount all FS, need GLOBAL_FILESYSTEM_FEATURE
* FS_FLASH //mount Flash FS
* FS_SD //mount SD FS
/* FTP access (1 connection only)
* FS_ROOT / FS_FLASH / FS_SD
*/
// #define FTP_FEATURE FS_ROOT
/************************************
*
* Reset ESP3D
*
* Reset ESP3D settings
*
************************************/
/* Enable pin reset feature
* Use a pin to reset ESP3D settings
*/
// #define PIN_RESET_FEATURE
/* Reset pin
* The pin used to reset ESP3D setting if set to low for more than 1 second at
* start
*/
//#define ESP3D_RESET_PIN 0
#define FTP_FEATURE FS_SD
/************************************
*
@ -417,227 +263,20 @@
*
************************************/
/* Enable OTA
* Over The Air Update (OTA)
*/
// #define OTA_FEATURE
/* Enable Web Update
* Update firmware using WebUI, need 4MB of flash
*/
#define WEB_UPDATE_FEATURE
/* Enable SD card Update
* Update firmware and settings using file on SDCard
/* Disable serial forwarding to external device
* No printer/CNC connected - this is a standalone SD WiFi device.
* Non-ESP commands are dropped instead of forwarded to serial.
*/
// #define SD_UPDATE_FEATURE
/************************************
*
* Display settings
*
* Rendering screens
*
************************************/
/* Printer screen
* If your printer has a display
*/
//#define PRINTER_HAS_DISPLAY
/* ESP3D screen
* Screen connected to ESP board
* OLED I2C SSD1306 128X64
* OLED_I2C_SSDSH1106_132X64
* TFT_SPI_ST7789_240X240
* TFT_SPI_ST7789_135X240
*/
//#define DISPLAY_DEVICE OLED_I2C_SSD1306_128X64
/* Flip screen
* Flip/rotate screen
*/
// #define DISPLAY_FLIP_VERTICALY
/* Display i2C address
* Wire address of display
*/
#define DISPLAY_I2C_ADDR 0x3c
#define ESP_SDA_PIN 21
#define ESP_SCL_PIN 22
/* Display reset pin
* The pin used to reset the screen (optional)
*/
// #define DISPLAY_I2C_PIN_RST 22
/* TFT led pin
* The pin used for the backlight
*/
// #define DISPLAY_LED_PIN -1
/************************************
*
* Audio settings
*
* Buzzer feature
*
************************************/
/* Enable buzzer
* Your esp board has a passive buzzer
*/
// #define BUZZER_DEVICE
/* Buzzer pin
* The pin used for the passive buzzer
*/
// #define ESP3D_BUZZER_PIN 33
/************************************
*
* Sensor settings
*
* Sensor feature
*
************************************/
//#define SENSOR_DEVICE BMP280_DEVICE
// Sensor i2C address
// Wire address of sensor
#define SENSOR_ADDR 0x76
// Unit
// C
// Unit of the sensor result
#define SENSOR__UNIT "C"
/* Sensor pin
* The pin used for the sensor
*/
// #define ESP3D_SENSOR_PIN 34
/* Sensor Unit
* Unit of the sensor result
*/
// #define SENSOR__UNIT "C"
/************************************
*
* Camera settings
*
* Connected camera
*
************************************/
/* Camera type
* CAMERA_MODEL_CUSTOM //Edit the pins in include/pins.h
* CAMERA_MODEL_ESP_EYE
* CAMERA_MODEL_M5STACK_PSRAM
* CAMERA_MODEL_M5STACK_V2_PSRAM
* CAMERA_MODEL_M5STACK_WIDE
* CAMERA_MODEL_AI_THINKER //ESP32-CAM
* CAMERA_MODEL_WROVER_KIT
* CAMERA_MODEL_ESP32_CAM_BOARD
* CAMERA_MODEL_ESP32S2_CAM_BOARD
* CAMERA_MODEL_ESP32S3_CAM_LCD
* CAMERA_MODEL_ESP32S3_EYE
* CAMERA_MODEL_XIAO_ESP32S3
* Camera connected to ESP board, only ones with PSRAM are supported
*/
// #define CAMERA_DEVICE CAMERA_MODEL_XIAO_ESP32S3
/* Flip vertically
* Flip camera vertically
*/
// #define CAMERA_DEVICE_FLIP_VERTICALY
/* Flip horizontally
* Flip camera horizontally
*/
// #define CAMERA_DEVICE_FLIP_HORIZONTALY
/************************************
*
* Levels of security
*
* How commands are allowed to be sent to ESP3D
*
************************************/
/* Enable serial commands
* Allow commands to be sent to ESP3D via serial port
*/
#define SERIAL_COMMAND_FEATURE
/* Allow remote access by enabling cross origin access
* check https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
* this should be enabled only in specific cases
* like show the camera in web page different than device web server
* /if you do not know what is that then better left it commented
* Allow to show the camera in web page different than device web server
*/
// #define ESP_ACCESS_CONTROL_ALLOW_ORIGIN
/* Enable authentication
* Force usage of authentication for commands
*/
// #define AUTHENTICATION_FEATURE
/************************************
*
* Additional features
*
* Extra settings
*
************************************/
/* Enable direct control pin
* Controls pins using [ESP201]
*/
#define DIRECT_PIN_FEATURE
/************************************
*
* Scripting settings
*
* Scripting on ESP3D
*
************************************/
/* Enable Autostart
* Commands to run on startup
* Separate commands with ';' or use file
*/
// #define ESP_AUTOSTART_SCRIPT "[ESP300]/FS/init.lua\n"
// #define ESP_AUTOSTART_SCRIPT "M117 Mounting SD;M21"
// #define ESP_AUTOSTART_SCRIPT_FILE "autoscript.gco"
/* Enable lua interpreter
* Allow to use lua interpreter on ESP3D on ESP32/S2/S3/C3 only
*/
//#define ESP_LUA_INTERPRETER_FEATURE
/* Hook when got IP
* Commands to run on event
* Separate commands with ';'
*/
#define ESP_GOT_IP_HOOK "[ESP212]IP:%ESP_IP%"
/* Hook when got date time
* Commands to run on event
* Separate commands with ';'
*/
#define ESP_GOT_DATE_TIME_HOOK "[ESP212]DATE:%ESP_DATETIME%"
/* Gcode Host Feature
* This feature allows to process Gcode files like macros.
*/
#define GCODE_HOST_FEATURE
#define NO_SERIAL_FORWARD
/* Settings location
* SETTINGS_IN_EEPROM //ESP8266/ESP32
* SETTINGS_IN_PREFERENCES //ESP32 only
* Location where ESP3D will save settings
*/
#define ESP_SAVE_SETTINGS SETTINGS_IN_EEPROM
@ -648,13 +287,8 @@
************************************/
// Enable log mode
// Do not do this when connected to printer !!!
// be noted all upload may failed if enabled
// LOG_OUTPUT_SERIAL0
// LOG_OUTPUT_SERIAL1
// LOG_OUTPUT_SERIAL2
// LOG_OUTPUT_TELNET
// LOG_OUTPUT_WEBSOCKET
// LOG_OUTPUT_SERIAL0 / LOG_OUTPUT_SERIAL1 / LOG_OUTPUT_SERIAL2
// LOG_OUTPUT_TELNET / LOG_OUTPUT_WEBSOCKET
// #define ESP_LOG_FEATURE LOG_OUTPUT_SERIAL0
// #define ESP3D_LOG_LEVEL LOG_LEVEL_DEBUG
@ -681,16 +315,11 @@
#define TIMESTAMP_FEATURE
#endif // SD_TIMESTAMP_FEATURE || FILESYSTEM_TIMESTAMP_FEATURE
#if defined(PRINTER_HAS_DISPLAY)
#define HAS_SERIAL_DISPLAY ""
#endif // PRINTER_HAS_DISPLAY
#if defined(CAMERA_DEVICE)
#if CAMERA_DEVICE == CAMERA_MODEL_ESP32_CAM_BOARD || \
CAMERA_DEVICE == CAMERA_MODEL_ESP32S2_CAM_BOARD
#define USE_BOARD_HEARDER 1
#endif // CAMERA_DEVICE==CAMERA_MODEL_ESP32_CAM_BOARD ||
// CAMERA_DEVICE==CAMERA_MODEL_ESP32S2_CAM_BOARD
#endif
#endif // CAMERA_DEVICE
#if !defined(WIFI_FEATURE) && !defined(ETH_FEATURE)

View file

@ -25,8 +25,10 @@
#include "../esp3d_settings.h"
#define COMMAND_ID 200
// Get SD Card Status
//[ESP200] json=<YES/NO> <RELEASESD> <REFRESH> pwd=<user/admin password>
// Get/Set SD Card Status
//[ESP200] json=<YES/NO> <RELEASESD> <GRABSD> <REFRESH> pwd=<user/admin password>
// GRABSD: take SD for ESP and hold it (manual mode, skips per-operation cycling)
// RELEASESD: release SD back to host (exits manual hold if active)
void ESP3DCommands::ESP200(int cmd_params_pos, ESP3DMessage* msg) {
ESP3DClientType target = msg->origin;
ESP3DRequest requestId = msg->request_id;
@ -39,6 +41,9 @@ void ESP3DCommands::ESP200(int cmd_params_pos, ESP3DMessage* msg) {
bool releasesd = hasTag(msg, cmd_params_pos, "RELEASESD");
bool refreshsd = hasTag(msg, cmd_params_pos, "REFRESH");
bool json = hasTag(msg, cmd_params_pos, "json");
#if SD_DEVICE_CONNECTION == ESP_SHARED_SD
bool grabsd = hasTag(msg, cmd_params_pos, "GRABSD");
#endif // SD_DEVICE_CONNECTION == ESP_SHARED_SD
String tmpstr;
#if defined(AUTHENTICATION_FEATURE)
if (msg->authentication_level == ESP3DAuthenticationLevel::guest) {
@ -47,11 +52,45 @@ void ESP3DCommands::ESP200(int cmd_params_pos, ESP3DMessage* msg) {
return;
}
#endif // AUTHENTICATION_FEATURE
#if SD_DEVICE_CONNECTION == ESP_SHARED_SD
// GRABSD: claim SD for ESP and enter manual hold mode
if (grabsd) {
if (ESP_SD::grabSD()) {
ok_msg = "SD grabbed (manual hold)";
} else {
hasError = true;
error_msg = "Failed to grab SD";
}
if (!dispatchAnswer(msg, COMMAND_ID, json, hasError,
hasError ? error_msg.c_str() : ok_msg.c_str())) {
esp3d_log_e("Error sending response to clients");
}
return;
}
#endif // SD_DEVICE_CONNECTION == ESP_SHARED_SD
if (releasesd) {
#if SD_DEVICE_CONNECTION == ESP_SHARED_SD
// If in manual hold, release the grab first
if (ESP_SD::isManualHold()) {
ESP_SD::releaseGrab();
ok_msg = "SD released (manual hold ended)";
} else {
ESP_SD::releaseFS();
ok_msg = "SD card released";
}
#else
ESP_SD::releaseFS();
ok_msg = "SD card released";
#endif // SD_DEVICE_CONNECTION == ESP_SHARED_SD
}
if (!releasesd
#if SD_DEVICE_CONNECTION == ESP_SHARED_SD
&& !grabsd
#endif
) {
if (!ESP_SD::accessFS()) {
if (ESP_SD::getState() == ESP_SDCARD_BUSY) {
ok_msg = "Busy";
@ -62,12 +101,18 @@ void ESP3DCommands::ESP200(int cmd_params_pos, ESP3DMessage* msg) {
int8_t state = ESP_SD::getState(true);
if (state == ESP_SDCARD_IDLE) {
ok_msg = "SD card ok";
#if SD_DEVICE_CONNECTION == ESP_SHARED_SD
if (ESP_SD::isManualHold()) {
ok_msg += " (manual hold)";
}
#endif
if (refreshsd) {
ESP_SD::refreshStats(true);
}
}
ESP_SD::releaseFS();
}
}
if (!dispatchAnswer(msg, COMMAND_ID, json, hasError,
hasError ? error_msg.c_str() : ok_msg.c_str())) {

View file

@ -30,9 +30,11 @@
#include "esp3d_settings.h"
#include "esp3d_commands.h"
#if !defined(NO_SERIAL_FORWARD)
#if COMMUNICATION_PROTOCOL != SOCKET_SERIAL || ESP_SERIAL_BRIDGE_OUTPUT
#include "../modules/serial/serial_service.h"
#endif // COMMUNICATION_PROTOCOL != SOCKET_SERIAL
#endif // !NO_SERIAL_FORWARD
#if COMMUNICATION_PROTOCOL == SOCKET_SERIAL
#include "../modules/serial2socket/serial2socket.h"
#endif // COMMUNICATION_PROTOCOL ==SOCKET_SERIAL
@ -119,8 +121,8 @@ bool Esp3D::begin() {
#endif // USB_SERIAL_FEATURE
// BT do not start automaticaly so should be OK
#if !defined(NO_SERIAL_FORWARD)
#if COMMUNICATION_PROTOCOL == RAW_SERIAL || COMMUNICATION_PROTOCOL == MKS_SERIAL
// Serial service
if (!esp3d_serial_service.begin(ESP_SERIAL_OUTPUT)) {
esp3d_log_e("Error with serial service");
@ -128,6 +130,7 @@ bool Esp3D::begin() {
}
#endif // COMMUNICATION_PROTOCOL == RAW_SERIAL || COMMUNICATION_PROTOCOL ==
// MKS_SERIAL
#endif // !NO_SERIAL_FORWARD
// Serial bridge
#if defined(ESP_SERIAL_BRIDGE_OUTPUT)
if (!serial_bridge_service.begin(ESP_SERIAL_BRIDGE_OUTPUT)) {
@ -183,10 +186,12 @@ void Esp3D::handle() {
#if defined(USB_SERIAL_FEATURE)
esp3d_usb_serial_service.handle();
#endif // USB_SERIAL_FEATURE
#if !defined(NO_SERIAL_FORWARD)
#if COMMUNICATION_PROTOCOL == RAW_SERIAL || COMMUNICATION_PROTOCOL == MKS_SERIAL
esp3d_serial_service.handle();
#endif // COMMUNICATION_PROTOCOL == RAW_SERIAL || COMMUNICATION_PROTOCOL ==
// MKS_SERIAL
#endif // !NO_SERIAL_FORWARD
#if defined(ESP_SERIAL_BRIDGE_OUTPUT)
serial_bridge_service.handle();
#endif // ESP_SERIAL_BRIDGE_OUTPUT
@ -228,16 +233,19 @@ bool Esp3D::end() {
#if defined(USB_SERIAL_FEATURE)
esp3d_usb_serial_service.end();
#endif // USB_SERIAL_FEATURE
#if !defined(NO_SERIAL_FORWARD)
#if COMMUNICATION_PROTOCOL == RAW_SERIAL || COMMUNICATION_PROTOCOL == MKS_SERIAL
esp3d_serial_service.end();
#endif // COMMUNICATION_PROTOCOL == RAW_SERIAL || COMMUNICATION_PROTOCOL ==
// MKS_SERIAL
#endif // !NO_SERIAL_FORWARD
return true;
}
// Reset ESP3D settings
bool Esp3D::reset() {
bool resetOk = true;
#if !defined(NO_SERIAL_FORWARD)
#if COMMUNICATION_PROTOCOL == RAW_SERIAL || COMMUNICATION_PROTOCOL == MKS_SERIAL
if (!esp3d_serial_service.reset()) {
resetOk = false;
@ -245,6 +253,7 @@ bool Esp3D::reset() {
}
#endif // COMMUNICATION_PROTOCOL == RAW_SERIAL || COMMUNICATION_PROTOCOL ==
// MKS_SERIAL
#endif // !NO_SERIAL_FORWARD
#if defined(ESP_SERIAL_BRIDGE_OUTPUT)
if (!serial_bridge_service.reset()) {
resetOk = false;
@ -268,6 +277,7 @@ void Esp3D::restart_now() {
digitalWrite(ESP3D_ETH_PHY_POWER_PIN, LOW);
#endif // ESP3D_ETH_PHY_POWER_PIN
esp3d_log("Restarting");
#if !defined(NO_SERIAL_FORWARD)
#if COMMUNICATION_PROTOCOL == RAW_SERIAL || COMMUNICATION_PROTOCOL == MKS_SERIAL
if (!esp3d_serial_service.started()) {
esp3d_serial_service.begin(ESP_SERIAL_OUTPUT);
@ -275,13 +285,16 @@ void Esp3D::restart_now() {
esp3d_serial_service.flush();
#endif // COMMUNICATION_PROTOCOL == RAW_SERIAL || COMMUNICATION_PROTOCOL ==
// MKS_SERIAL
#endif // !NO_SERIAL_FORWARD
#if defined(FILESYSTEM_FEATURE)
ESP_FileSystem::end();
#endif // FILESYSTEM_FEATURE
#if !defined(NO_SERIAL_FORWARD)
#if (COMMUNICATION_PROTOCOL == RAW_SERIAL || COMMUNICATION_PROTOCOL == MKS_SERIAL) & defined(ARDUINO_ARCH_ESP8266)
esp3d_serial_service.swap();
#endif // COMMUNICATION_PROTOCOL == RAW_SERIAL || COMMUNICATION_PROTOCOL ==
// MKS_SERIAL
#endif // !NO_SERIAL_FORWARD
ESP.restart();
while (1) {
delay(1);

View file

@ -52,7 +52,9 @@ const char *esp3dmsgstr[] = {"head", "core", "tail", "unique"};
#include "../modules/mks/mks_service.h"
#endif // COMMUNICATION_PROTOCOL == MKS_SERIAL
#if !defined(NO_SERIAL_FORWARD)
#include "../modules/serial/serial_service.h"
#endif // !NO_SERIAL_FORWARD
#if defined(TELNET_FEATURE)
#include "../modules/telnet/telnet_server.h"
@ -94,15 +96,15 @@ ESP3DCommands esp3d_commands;
ESP3DCommands::ESP3DCommands() {
//Need to sync with setting part
#if COMMUNICATION_PROTOCOL == RAW_SERIAL
#if defined(NO_SERIAL_FORWARD)
_output_client = ESP3DClientType::no_client;
#elif COMMUNICATION_PROTOCOL == RAW_SERIAL
_output_client = ESP3DClientType::serial;
#endif // COMMUNICATION_PROTOCOL == RAW_SERIAL
#if COMMUNICATION_PROTOCOL == MKS_SERIAL
#elif COMMUNICATION_PROTOCOL == MKS_SERIAL
_output_client = ESP3DClientType::mks_serial;
#endif // COMMUNICATION_PROTOCOL == MKS_SERIAL
#if COMMUNICATION_PROTOCOL == SOCKET_SERIAL
#elif COMMUNICATION_PROTOCOL == SOCKET_SERIAL
_output_client = ESP3DClientType::socket_serial;
#endif //
#endif
}
ESP3DCommands::~ESP3DCommands() {}
@ -478,7 +480,7 @@ void ESP3DCommands::execute_internal_command(int cmd, int cmd_params_pos,
// Change ETH STA IP mode (DHCP/STATIC)
//[ESP116]<mode>pwd=<admin password>
case 116:
ESP102(cmd_params_pos, msg);
ESP116(cmd_params_pos, msg);
break;
// Change ETH STA IP/Mask/GW
//[ESP117]IP=<IP> MSK=<IP> GW=<IP> pwd=<admin password>
@ -821,7 +823,7 @@ void ESP3DCommands::execute_internal_command(int cmd, int cmd_params_pos,
ESP800(cmd_params_pos, msg);
break;
#if COMMUNICATION_PROTOCOL != SOCKET_SERIAL
#if COMMUNICATION_PROTOCOL != SOCKET_SERIAL && !defined(NO_SERIAL_FORWARD)
// Get state / Set Enable / Disable Serial Communication
//[ESP900]<ENABLE/DISABLE>
case 900:
@ -832,7 +834,7 @@ void ESP3DCommands::execute_internal_command(int cmd, int cmd_params_pos,
case 901:
ESP901(cmd_params_pos, msg);
break;
#endif // COMMUNICATION_PROTOCOL != SOCKET_SERIAL
#endif // COMMUNICATION_PROTOCOL != SOCKET_SERIAL && !NO_SERIAL_FORWARD
#if defined(USB_SERIAL_FEATURE)
// Get / Set USB Serial Baud Rate
//[ESP902]<BAUD RATE> json=<no> pwd=<admin/user password>
@ -1211,8 +1213,14 @@ void ESP3DCommands::process(ESP3DMessage *msg) {
return;
}
lastIsESP3D = false;
#if defined(NO_SERIAL_FORWARD)
// No printer connected - drop non-ESP commands
esp3d_log("Dropping non-ESP command (no serial forward)");
esp3d_message_manager.deleteMsg(msg);
#else
esp3d_log("Dispatch message: %s", msg->data);
dispatch(msg);
#endif // NO_SERIAL_FORWARD
}
}
bool ESP3DCommands::dispatch(ESP3DMessage *msg, const char *sbuf) {
@ -1326,6 +1334,7 @@ bool ESP3DCommands::dispatch(ESP3DMessage *msg) {
esp3d_log("No client message");
esp3d_message_manager.deleteMsg(msg);
break;
#if !defined(NO_SERIAL_FORWARD)
#if COMMUNICATION_PROTOCOL == RAW_SERIAL
case ESP3DClientType::serial:
esp3d_log("Serial message");
@ -1344,6 +1353,7 @@ bool ESP3DCommands::dispatch(ESP3DMessage *msg) {
break;
#endif // USB_SERIAL_FEATURE
#endif // COMMUNICATION_PROTOCOL == RAW_SERIAL
#endif // !NO_SERIAL_FORWARD
#if COMMUNICATION_PROTOCOL == SOCKET_SERIAL
case ESP3DClientType::echo_serial:

View file

@ -125,49 +125,6 @@ void esp3d_logf(uint8_t level, const char* format, ...) {
}
}
void esp3d_log_init() {
#if defined(ARDUINO_ARCH_ESP32)
#if !defined(SHOW_ESP_LOG)
esp_log_level_set("wifi", ESP_LOG_NONE);
esp_log_level_set("sdmmc", ESP_LOG_NONE);
esp_log_level_set("vfs_fat_sdmmc", ESP_LOG_NONE);
esp_log_level_set("sdmmc_periph", ESP_LOG_NONE);
esp_log_level_set("sdmmc_req", ESP_LOG_NONE);
esp_log_level_set("sdmmc_common", ESP_LOG_NONE);
esp_log_level_set("fatfs", ESP_LOG_NONE);
esp_log_level_set("sdspi", ESP_LOG_NONE);
esp_log_level_set("sd_diskio", ESP_LOG_NONE);
esp_log_level_set("vfs_fat", ESP_LOG_NONE);
esp_log_level_set("esp_littlefs", ESP_LOG_NONE);
esp_log_level_set("task_wdt", ESP_LOG_NONE);
esp_log_level_set("camera", ESP_LOG_NONE);
esp_log_level_set("sccb", ESP_LOG_NONE);
esp_log_level_set("ov2640", ESP_LOG_NONE);
esp_log_level_set("esp_eth", ESP_LOG_NONE);
esp_log_level_set("emac", ESP_LOG_NONE);
esp_log_level_set("phy", ESP_LOG_NONE);
#endif // !defined(SHOW_ESP_LOG)
#endif // ARDUINO_ARCH_ESP32
#if (ESP_LOG_FEATURE == LOG_OUTPUT_SERIAL0) || \
(ESP_LOG_FEATURE == LOG_OUTPUT_SERIAL1) || \
(ESP_LOG_FEATURE == LOG_OUTPUT_SERIAL2)
#ifdef ARDUINO_ARCH_ESP8266
LOG_OUTPUT_SERIAL.begin(LOG_ESP3D_BAUDRATE, SERIAL_8N1, SERIAL_FULL,
(ESP_LOG_TX_PIN == -1) ? 1 : ESP_LOG_TX_PIN);
#if ESP_LOG_RX_PIN != -1
LOG_OUTPUT_SERIAL
.pins((ESP_LOG_TX_PIN == -1) ? 1 : ESP_LOG_TX_PIN, ESP_LOG_RX_PIN)
#endif // ESP_LOG_RX_PIN != -1
#endif // ARDUINO_ARCH_ESP8266
#if defined(ARDUINO_ARCH_ESP32)
LOG_OUTPUT_SERIAL.begin(LOG_ESP3D_BAUDRATE, SERIAL_8N1,
ESP_LOG_RX_PIN, ESP_LOG_TX_PIN);
#endif // ARDUINO_ARCH_ESP32
#endif // (ESP_LOG_FEATURE == LOG_OUTPUT_SERIAL0) || (ESP_LOG_FEATURE ==
// LOG_OUTPUT_SERIAL1)||(ESP_LOG_FEATURE == LOG_OUTPUT_SERIAL2)
}
void esp3d_network_log_init() {
#if ESP_LOG_FEATURE == LOG_OUTPUT_TELNET
@ -195,3 +152,51 @@ void esp3d_network_log_end() {
}
#endif // ESP_LOG_FEATURE
void esp3d_log_init() {
#if defined(ARDUINO_ARCH_ESP32)
#if !defined(SHOW_ESP_LOG)
esp_log_level_set("wifi", ESP_LOG_NONE);
esp_log_level_set("sdmmc", ESP_LOG_NONE);
esp_log_level_set("vfs_fat_sdmmc", ESP_LOG_NONE);
esp_log_level_set("sdmmc_periph", ESP_LOG_NONE);
esp_log_level_set("sdmmc_req", ESP_LOG_NONE);
esp_log_level_set("sdmmc_common", ESP_LOG_NONE);
esp_log_level_set("fatfs", ESP_LOG_NONE);
esp_log_level_set("sdspi", ESP_LOG_NONE);
esp_log_level_set("sd_diskio", ESP_LOG_NONE);
esp_log_level_set("vfs_fat", ESP_LOG_NONE);
esp_log_level_set("esp_littlefs", ESP_LOG_NONE);
esp_log_level_set("task_wdt", ESP_LOG_NONE);
esp_log_level_set("camera", ESP_LOG_NONE);
esp_log_level_set("sccb", ESP_LOG_NONE);
esp_log_level_set("ov2640", ESP_LOG_NONE);
esp_log_level_set("esp_eth", ESP_LOG_NONE);
esp_log_level_set("emac", ESP_LOG_NONE);
esp_log_level_set("phy", ESP_LOG_NONE);
#endif // !defined(SHOW_ESP_LOG)
#endif // ARDUINO_ARCH_ESP32
#if defined(ESP_LOG_FEATURE)
#if (ESP_LOG_FEATURE == LOG_OUTPUT_SERIAL0) || \
(ESP_LOG_FEATURE == LOG_OUTPUT_SERIAL1) || \
(ESP_LOG_FEATURE == LOG_OUTPUT_SERIAL2)
#ifdef ARDUINO_ARCH_ESP8266
LOG_OUTPUT_SERIAL.begin(LOG_ESP3D_BAUDRATE, SERIAL_8N1, SERIAL_FULL,
(ESP_LOG_TX_PIN == -1) ? 1 : ESP_LOG_TX_PIN);
#if ESP_LOG_RX_PIN != -1
LOG_OUTPUT_SERIAL
.pins((ESP_LOG_TX_PIN == -1) ? 1 : ESP_LOG_TX_PIN, ESP_LOG_RX_PIN)
#endif // ESP_LOG_RX_PIN != -1
#endif // ARDUINO_ARCH_ESP8266
#if defined(ARDUINO_ARCH_ESP32)
LOG_OUTPUT_SERIAL.begin(LOG_ESP3D_BAUDRATE, SERIAL_8N1,
ESP_LOG_RX_PIN, ESP_LOG_TX_PIN);
#endif // ARDUINO_ARCH_ESP32
#endif // (ESP_LOG_FEATURE == LOG_OUTPUT_SERIAL0) || (ESP_LOG_FEATURE ==
// LOG_OUTPUT_SERIAL1)||(ESP_LOG_FEATURE == LOG_OUTPUT_SERIAL2)
#endif // ESP_LOG_FEATURE
}

View file

@ -22,13 +22,14 @@
#include "../include/esp3d_config.h"
#include "../include/esp3d_defines.h"
extern void esp3d_log_init();
#if defined(ESP_LOG_FEATURE)
extern void esp3d_logf(uint8_t level, const char* format, ...);
extern void esp3d_network_log_init();
extern void esp3d_network_log_handle();
extern void esp3d_network_log_end();
extern void esp3d_log_init();
#if !defined(ESP3D_LOG_LEVEL) && defined(ESP_DEBUG_FEATURE)
#error "ESP3D_LOG_LEVEL is not defined, please define it in configuration.h"
@ -75,7 +76,7 @@ extern void esp3d_log_init();
#define esp3d_log_d(format, ...)
#define esp3d_log(format, ...)
#undef ESP3D_LOG_LEVEL
#define ESP3D_LOG_INIT_FN
#define ESP3D_LOG_INIT_FN esp3d_log_init(); //to desactivate idf log extensively
#define ESP3D_LOG_NETWORK_INIT_FN
#define ESP3D_LOG_NETWORK_HANDLE_FN
#define ESP3D_LOG_NETWORK_END_FN

View file

@ -22,7 +22,7 @@
#define _VERSION_ESP3D_H
// version and sources location
#define FW_VERSION "3.0.2"
#define FW_VERSION "3.0.3"
#define REPOSITORY "https://github.com/luc-github/ESP3D/tree/3.0"
#endif //_VERSION_ESP3D_H

View file

@ -30,16 +30,6 @@
#include "../../core/esp3d_string.h"
#include "../network/netconfig.h"
#include "ethconfig.h"
#ifdef ETHERNET_SPI_USE_SPI
#define ETH_SPI SPI
#endif // ETHERNET_SPI_USE_SPI
#if ETHERNET_SPI_USE_SPI2
#define ETH_SPI SPI2
#endif // ETHERNET_SPI_USE_SPI2
#ifndef ETH_SPI
#define ETH_SPI SPI
#endif // ETH_SPI
#
#if defined(GCODE_HOST_FEATURE)
#include "../gcode_host/gcode_host.h"
@ -109,11 +99,20 @@ bool EthConfig::begin(int8_t& espMode) {
// TYPE_ETH_PHY_RTL8201 || ESP3D_ETH_PHY_TYPE == TYPE_ETH_PHY_DP83848 ||
// ESP3D_ETH_PHY_TYPE == TYPE_ETH_PHY_KSZ8041 || ESP3D_ETH_PHY_TYPE ==
// TYPE_ETH_PHY_KSZ8081
#if ESP3D_ETH_PHY_TYPE == TYPE_ETH_PHY_W5500
esp3d_log("ETH spi PHY Type %d", ESP3D_ETH_PHY_TYPE);
ETH_SPI.begin(ETH_SPI_SCK, ETH_SPI_MISO, ETH_SPI_MOSI);
#if defined(ETHERNET_SPI_USE_SPI) && (ETHERNET_SPI_USE_SPI == 1)
esp3d_log("ETH spi PHY Type %d using SPI", ESP3D_ETH_PHY_TYPE);
SPI.begin(ETH_SPI_SCK, ETH_SPI_MISO, ETH_SPI_MOSI);
_started = ETH.begin(ETH_PHY_W5500, ESP3D_ETH_PHY_ADDR, ETH_PHY_CS,
ETH_PHY_IRQ, ETH_PHY_RST, ETH_SPI);
ETH_PHY_IRQ, ETH_PHY_RST, SPI);
#endif // defined(ETHERNET_SPI_USE_SPI) && (ETHERNET_SPI_USE_SPI == 1)
#if defined(ETHERNET_SPI_USE_SPI2) && (ETHERNET_SPI_USE_SPI2 == 1)
esp3d_log("ETH spi PHY Type %d using SPI2", ESP3D_ETH_PHY_TYPE);
_started = ETH.begin(ETH_PHY_W5500, ESP3D_ETH_PHY_ADDR, ETH_PHY_CS,
ETH_PHY_IRQ, ETH_PHY_RST, SPI3_HOST,ETH_SPI_SCK, ETH_SPI_MISO, ETH_SPI_MOSI);
#endif // defined(ETHERNET_SPI_USE_SPI2) && (ETHERNET_SPI_USE_SPI2 == 1)
#endif // ESP3D_ETH_PHY_TYPE == TYPE_ETH_PHY_W5500
if (_started) {

View file

@ -31,6 +31,7 @@
#if SD_DEVICE_CONNECTION == ESP_SHARED_SD
bool ESP_SD::_enabled = false;
bool ESP_SD::_manualHold = false;
#if SD_CARD_TYPE == ESP_FYSETC_WIFI_PRO_SDCARD
#include <SPI.h>
#endif // SD_CARD_TYPE == ESP_FYSETC_WIFI_PRO_SDCARD
@ -94,6 +95,41 @@ bool ESP_SD::disableSharedSD() {
ESP3DHal::wait(100);
return true;
}
// Manual hold: grab SD for ESP and keep it until explicitly released.
// This allows multiple file operations without cycling the shared SD bus.
bool ESP_SD::grabSD() {
if (_manualHold && _enabled) {
return true; // already grabbed
}
if (!enableSharedSD()) {
return false;
}
_manualHold = true;
esp3d_log("SD grabbed for manual hold");
return true;
}
bool ESP_SD::releaseGrab() {
if (!_manualHold) {
return true; // nothing to release
}
// Make sure no operation is in progress
if (_state == ESP_SDCARD_BUSY) {
esp3d_log_e("Cannot release grab while SD is busy");
return false;
}
_manualHold = false;
_enabled = false;
#if defined(ESP_FLAG_SHARED_SD_PIN) && ESP_FLAG_SHARED_SD_PIN != -1
disableSharedSD();
#endif // ESP_FLAG_SHARED_SD_PIN
#if defined(ESP3DLIB_ENV)
card.mount();
#endif // ESP3DLIB_ENV
esp3d_log("SD manual hold released");
return true;
}
#endif // SD_DEVICE_CONNECTION == ESP_SHARED_SD
bool ESP_SD::_started = false;
@ -119,7 +155,11 @@ bool ESP_SD::accessFS(uint8_t FS) {
return false;
}
#if SD_DEVICE_CONNECTION == ESP_SHARED_SD
if (ESP_SD::enableSharedSD()) {
if (_manualHold && _enabled) {
// Manual hold mode: SD already claimed for ESP, skip enable cycle
esp3d_log("Access shared SD ok (manual hold)");
res = true;
} else if (ESP_SD::enableSharedSD()) {
esp3d_log("Access shared SD ok");
res = true;
} else {
@ -151,6 +191,11 @@ void ESP_SD::releaseFS(uint8_t FS) {
esp3d_log("Release SD");
setState(ESP_SDCARD_IDLE);
#if SD_DEVICE_CONNECTION == ESP_SHARED_SD
if (_manualHold) {
// Manual hold mode: keep SD claimed for ESP, don't release bus
esp3d_log("Release SD (manual hold, keeping bus)");
return;
}
_enabled = false;
#if defined(ESP_FLAG_SHARED_SD_PIN) && ESP_FLAG_SHARED_SD_PIN != -1
if (ESP_SD::disableSharedSD()) {

View file

@ -91,11 +91,15 @@ class ESP_SD {
static bool enableSharedSD();
static bool disableSharedSD();
static bool isEnabled() { return _enabled; }
static bool grabSD();
static bool releaseGrab();
static bool isManualHold() { return _manualHold; }
#endif // SD_DEVICE_CONNECTION == ESP_SHARED_SD
private:
static bool _started;
#if SD_DEVICE_CONNECTION == ESP_SHARED_SD
static bool _enabled;
static bool _manualHold;
#endif // SD_DEVICE_CONNECTION == ESP_SHARED_SD
static uint8_t _state;
static uint8_t _spi_speed_divider;

File diff suppressed because it is too large Load diff

View file

@ -22,7 +22,7 @@
#define __favicon_h
#define favicon_size 344
const unsigned char favicon[344] PROGMEM = {
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0xb5, 0x94, 0x31, 0x4b, 0xc3, 0x50,
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xb5, 0x94, 0x31, 0x4b, 0xc3, 0x50,
0x14, 0x85, 0x4f, 0x63, 0xc1, 0x5a, 0x0b, 0x06, 0x91, 0x4e, 0x52, 0x3a, 0x44, 0x10, 0x27, 0x31,
0x45, 0xdc, 0xec, 0xd4, 0xdf, 0x21, 0x99, 0x44, 0x1c, 0x44, 0x74, 0x17, 0x9c, 0x8a, 0x73, 0x7f,
0x80, 0xbf, 0xa0, 0x63, 0x56, 0x1d, 0x1d, 0x9c, 0xa4, 0x74, 0x15, 0x1c, 0xc4, 0x4d, 0x90, 0x0e,

View file

@ -48,29 +48,24 @@ void HTTP_Server::handle_web_command() {
cmd = _webserver->arg("cmd");
esp3d_log("Command is %s", cmd.c_str());
if (!cmd.endsWith("\n")) {
esp3d_log("Command is not ending with \\n");
#if !defined(NO_SERIAL_FORWARD)
if (ESP3DSettings::GetFirmwareTarget() == GRBL || ESP3DSettings::GetFirmwareTarget() == GRBLHAL) {
uint len = cmd.length();
if (!((len == 1 && esp3d_string::isRealTimeCommand(cmd[0])) ||
(len == 2 && esp3d_string::isRealTimeCommand(cmd[1])))) {
cmd += "\n";
esp3d_log("Command is not realtime, adding \\n");
} else { // no need \n for realtime command
esp3d_log("Command is realtime, no need to add \\n");
} else {
isRealTimeCommand = true;
// remove the 0XC2 that should not be there
if (len == 2 && esp3d_string::isRealTimeCommand(cmd[1]) && cmd[1] == 0xC2) {
cmd[0] = cmd[1];
cmd[1] = 0x0;
esp3d_log("Command is realtime, removing 0xC2");
}
}
} else {
esp3d_log("Command is not realtime, adding \\n");
cmd += "\n"; // need to validate command
} else
#endif // !NO_SERIAL_FORWARD
{
cmd += "\n";
}
} else {
esp3d_log("Command is ending with \\n");
}
esp3d_log("Message type is %s for %s", isRealTimeCommand ? "realtimecmd" : "unique", cmd.c_str());
if (esp3d_commands.is_esp_command((uint8_t *)cmd.c_str(), cmd.length())) {
@ -86,6 +81,11 @@ void HTTP_Server::handle_web_command() {
esp3d_log_e("Cannot create message");
}
} else {
#if defined(NO_SERIAL_FORWARD)
// No printer connected - drop non-ESP commands
HTTP_Server::set_http_headers();
_webserver->send(200, "text/plain", "No serial target configured");
#else
HTTP_Server::set_http_headers();
// the command is not ESP3D so it will be forwarded to the output client
// no need to wait to answer then
@ -93,6 +93,7 @@ void HTTP_Server::handle_web_command() {
esp3d_commands.dispatch(cmd.c_str(), esp3d_commands.getOutputClient(),
no_id, isRealTimeCommand ? ESP3DMessageType::realtimecmd :ESP3DMessageType::unique,
ESP3DClientType::http, auth_level);
#endif // NO_SERIAL_FORWARD
}
} else if (_webserver->hasArg("ping")) {
_webserver->send(200);

View file

@ -171,16 +171,18 @@ void HTTP_Server::SDFileupload() {
#ifdef ESP_BENCHMARK_FEATURE
bench_transfered += upload.currentSize;
#endif // ESP_BENCHMARK_FEATURE
// Feed watchdog before SD write to prevent WDT reset on large files
ESP3DHal::wait(0);
// update websocket every 2000 ms
if (millis() - last_WS_update > 2000) {
websocket_terminal_server.handle();
last_WS_update = millis();
}
// no error so write post date
// no error so write post data
int writeddatanb = fsUploadFile.write(upload.buf, upload.currentSize);
if (upload.currentSize != (size_t)writeddatanb) {
// we have a problem set flag UPLOAD_STATUS_FAILED
esp3d_log_e("File write failed du to mismatch size %d vs %d",
esp3d_log_e("File write failed due to mismatch size %d vs %d",
writeddatanb, upload.currentSize);
_upload_status = UPLOAD_STATUS_FAILED;
pushError(ESP_ERROR_FILE_WRITE, "File write failed");
@ -255,6 +257,6 @@ void HTTP_Server::SDFileupload() {
Serial2Socket.pause(false);
#endif // ESP3DLIB_ENV && COMMUNICATION_PROTOCOL == SOCKET_SERIAL
}
ESP3DHal::wait(5);
ESP3DHal::wait(1);
}
#endif // HTTP_FEATURE && SD_DEVICE

View file

@ -1,4 +1,4 @@
{
"version": "3.0.1",
"devt": "3.0.2"
"version": "3.0.2",
"devt": "3.0.3"
}

View file

@ -14,10 +14,29 @@ build_dir = .pioenvs
lib_dir = libraries
libdeps_dir = .piolibdeps
data_dir = esp3d/data
default_envs = esp32dev
default_envs = sd_wifi_pro
; FYSETC SD WIFI Pro - ESP32 / SDIO 4-bit / Shared SD / OLED
[env:sd_wifi_pro]
platform = https://github.com/pioarduino/platform-espressif32/releases/download/51.03.04/platform-espressif32.zip
board = esp32dev
framework = arduino
monitor_speed = 115200
monitor_echo = yes
monitor_filters = send_on_enter, direct, esp32_exception_decoder
build_flags =
-DCORE_DEBUG_LEVEL=0
-DHTTP_UPLOAD_BUFLEN=4096
board_build.partitions = min_spiffs.csv
upload_speed = 460800
extra_scripts = pre:platformIO/extra_script.py
lib_ignore =
TFT_eSPI
esp32-usb-serial
[env:esp32dev]
; Arduino core 3.0.4 - IDF 5.1.4
platform = https://github.com/pioarduino/platform-espressif32/releases/download/51.03.04/platform-espressif32.zip
@ -25,7 +44,7 @@ board = esp32dev
framework = arduino
monitor_speed = 115200
monitor_echo = yes
monitor_filters = send_on_enter, colorize, esp32_exception_decoder
monitor_filters = send_on_enter, direct, esp32_exception_decoder
; set frequency to 240MHz
;board_build.f_cpu = 240000000L
; set frequency to 80MHz
@ -52,7 +71,7 @@ board = esp32dev
framework = arduino
monitor_speed = 115200
monitor_echo = yes
monitor_filters = send_on_enter, colorize, esp32_exception_decoder
monitor_filters = send_on_enter, direct, esp32_exception_decoder
; set frequency to 240MHz
;board_build.f_cpu = 240000000L
; set frequency to 80MHz
@ -76,7 +95,7 @@ board = esp32dev
framework = arduino
monitor_speed = 115200
monitor_echo = yes
monitor_filters = send_on_enter, colorize, esp32_exception_decoder
monitor_filters = send_on_enter, direct, esp32_exception_decoder
; set frequency to 240MHz
;board_build.f_cpu = 240000000L
; set frequency to 80MHz
@ -103,7 +122,7 @@ board = esp32dev
framework = arduino
monitor_speed = 115200
monitor_echo = yes
monitor_filters = send_on_enter, colorize, esp32_exception_decoder
monitor_filters = send_on_enter, direct, esp32_exception_decoder
; set frequency to 240MHz
;board_build.f_cpu = 240000000L
; set frequency to 80MHz
@ -150,7 +169,7 @@ board = esp32dev
framework = arduino
monitor_speed = 115200
monitor_echo = yes
monitor_filters = send_on_enter, colorize, esp32_exception_decoder
monitor_filters = send_on_enter, direct, esp32_exception_decoder
; set frequency to 240MHz
;board_build.f_cpu = 240000000L
; set frequency to 80MHz
@ -198,7 +217,7 @@ board = esp32-s2-saola-1
framework = arduino
monitor_speed = 115200
monitor_echo = yes
monitor_filters = send_on_enter, colorize, esp32_exception_decoder
monitor_filters = send_on_enter, direct, esp32_exception_decoder
board_build.f_cpu = 240000000L
board_build.mcu = esp32s2
board_build.variant = esp32s2
@ -223,7 +242,7 @@ board = esp32-s3-devkitc-1
framework = arduino
monitor_speed = 115200
monitor_echo = yes
monitor_filters = send_on_enter, colorize, esp32_exception_decoder
monitor_filters = send_on_enter, direct, esp32_exception_decoder
board_build.f_cpu = 240000000L
board_build.mcu = esp32s3
board_build.variant = esp32s3
@ -251,7 +270,7 @@ board_build.f_flash = 80000000L
board_build.flash_mode = qio
monitor_speed = 115200
monitor_echo = yes
monitor_filters = send_on_enter, colorize, esp32_exception_decoder
monitor_filters = send_on_enter, direct, esp32_exception_decoder
build_flags = -DCORE_DEBUG_LEVEL=0 -DCONFIG_IDF_TARGET_ESP32C3=1
;on 4MB flash use
;board_build.partitions = min_spiffs.csv
@ -275,7 +294,7 @@ board_build.f_flash = 80000000L
board_build.flash_mode = qio
monitor_speed = 115200
monitor_echo = yes
monitor_filters = send_on_enter, colorize, esp32_exception_decoder
monitor_filters = send_on_enter, direct, esp32_exception_decoder
build_flags = -DCORE_DEBUG_LEVEL=0 -DCONFIG_IDF_TARGET_ESP32C6=1
;on 4MB flash use
;board_build.partitions = min_spiffs.csv
@ -295,7 +314,7 @@ board = esp12e
framework = arduino
monitor_speed = 115200
monitor_echo = yes
monitor_filters = send_on_enter, colorize, esp8266_exception_decoder
monitor_filters = send_on_enter, direct, esp8266_exception_decoder
; set frequency to 160MHz
board_build.f_cpu = 160000000L
; set frequency to 40MHz
@ -322,7 +341,7 @@ board = esp12e
framework = arduino
monitor_speed = 115200
monitor_echo = yes
monitor_filters = send_on_enter, colorize, esp8266_exception_decoder
monitor_filters = send_on_enter, direct, esp8266_exception_decoder
; set frequency to 160MHz
board_build.f_cpu = 160000000L
; set frequency to 40MHz
@ -349,7 +368,7 @@ board = esp8285
framework = arduino
monitor_speed = 115200
monitor_echo = yes
monitor_filters = send_on_enter, colorize, esp8266_exception_decoder
monitor_filters = send_on_enter, direct, esp8266_exception_decoder
; set frequency to 160MHz
board_build.f_cpu = 160000000L
; set frequency to 40MHz