Compare commits

..

No commits in common. "318fd4c7a08272dda347b56a127cd47fe33b40b7" and "e74ac77f583b83dd2a0326a304bb5b685c641bad" have entirely different histories.

23 changed files with 2055 additions and 1921 deletions

View file

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

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) # 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-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-2-orange.svg?style=flat-square)](#contributors-) [![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END --> <!-- ALL-CONTRIBUTORS-BADGE:END -->
<img src="https://github.com/luc-github/ESP3D/blob/3.0/images/Screen/logo2.png"> <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 Firmware for ESP8266/ESP8285 and ESP32 (original, pico, S2, S3, C3, C6) used with 3D printer/Sand-Table and CNC
@ -131,7 +131,6 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<tbody> <tbody>
<tr> <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/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> </tr>
</tbody> </tbody>
</table> </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_h
#define favicon_size 344 #define favicon_size 344
const unsigned char favicon[344] PROGMEM = { const unsigned char favicon[344] PROGMEM = {
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xb5, 0x94, 0x31, 0x4b, 0xc3, 0x50, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0xb5, 0x94, 0x31, 0x4b, 0xc3, 0x50,
0x14, 0x85, 0x4f, 0x63, 0xc1, 0x5a, 0x0b, 0x06, 0x91, 0x4e, 0x52, 0x3a, 0x44, 0x10, 0x27, 0x31, 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, 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, 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"> <meta name="msapplication-navbutton-color" content="#5755d9">
<!-- iOS Safari --> <!-- iOS Safari -->
<meta name="apple-mobile-web-app-status-bar-style" content="#5755d9"> <meta name="apple-mobile-web-app-status-bar-style" content="#5755d9">
<title>SD WIFI Pro</title> <title>Document</title>
</head> </head>
<body> <body>
<div> <div>
@ -29,12 +29,33 @@
<div id="MSGLimited"></div> <div id="MSGLimited"></div>
<div id="MSG"></div> <div id="MSG"></div>
</center> </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="fileSystem" class="panel hide">
<div id="fileSystemHeader" class="panel-header">SD Card</div> <div id="fileSystemHeader" class="panel-header">FileSystem</div>
<div id="fileSystemBody" class="panel-body no-footer"> <div id="fileSystemBody" class="panel-body no-footer">
<div class="controlBar"> <div class="controlBar">
<input class="hide" type="file" value="" id="files" multiple /> <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="refresh">Refresh</button>
<button class="btn" id="createdir" title="Create directory">+</button> <button class="btn" id="createdir" title="Create directory">+</button>
<button class="btn" id="uploadFiles" title="upload files">+</button> <button class="btn" id="uploadFiles" title="upload files">+</button>
@ -58,29 +79,6 @@
</div> </div>
</div> </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="firmware" class="panel hide">
<div id="firmwareHeader" class="panel-header">Firmware update</div> <div id="firmwareHeader" class="panel-header">Firmware update</div>
<div id="firmwareBody" class="panel-body no-footer"> <div id="firmwareBody" class="panel-body no-footer">

View file

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

View file

@ -19,12 +19,6 @@
*/ */
#ifndef _CONFIGURATION_H #ifndef _CONFIGURATION_H
#define _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 /* Setup station as default, use AP mode first if not done
* Note: need both defined to enable it * Note: need both defined to enable it
* Uncomment and edit them to define * Uncomment and edit them to define
@ -41,6 +35,19 @@
#include "myconfig.h" #include "myconfig.h"
#endif #endif
#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
/************************************ /************************************
* *
@ -52,15 +59,36 @@
/* Serial Communication protocol /* Serial Communication protocol
* RAW_SERIAL // Basic serial protocol, without data change * RAW_SERIAL // Basic serial protocol, without data change
* MKS_SERIAL // MakerBase communication protocol * MKS_SERIAL // This is a MakerBase communication protocol, used with MKS
* printers and TFT, it encapsulated data in a custom protocol
*/ */
#define COMMUNICATION_PROTOCOL RAW_SERIAL #define COMMUNICATION_PROTOCOL RAW_SERIAL
/* Main Serial port /* Main Serial port / Ouptut
* USE_SERIAL_0 / USE_SERIAL_1 / USE_SERIAL_2 * 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
#define ESP_SERIAL_OUTPUT USE_SERIAL_0 #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 /* Serial buffer size
* Maximum size of the serial buffer * Maximum size of the serial buffer
*/ */
@ -70,9 +98,16 @@
* *
* Target firmware * Target firmware
* *
* Not used - this is a standalone SD WiFi device * Targeted firmware that ESP3D will communicate with
* *
************************************/ ************************************/
/* Target firmware (default UNKNOWN_FW can be changed later in settings)
* UNKNOWN_FW
* GRBL
* MARLIN
* SMOOTHIEWARE
* REPETIER
*/
#define DEFAULT_FW UNKNOWN_FW #define DEFAULT_FW UNKNOWN_FW
/************************************ /************************************
@ -88,6 +123,51 @@
*/ */
#define WIFI_FEATURE #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 * Channels of ESP3D
@ -101,10 +181,19 @@
*/ */
#define HTTP_FEATURE #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 /* Use Websocket server
* Enable websocket communications * Enable websocket communications
*/ */
#define WS_DATA_FEATURE // #define WS_DATA_FEATURE
// Enable notifications // Enable notifications
// Allows to send notifications to the user // Allows to send notifications to the user
@ -118,7 +207,7 @@
/* Notification title message /* Notification title message
* The title of notification * The title of notification
*/ */
#define ESP_NOTIFICATION_TITLE "SD WIFI Pro Notification" #define ESP_NOTIFICATION_TITLE "ESP3D Notification"
/************************************ /************************************
* *
@ -151,20 +240,30 @@
* *
************************************/ ************************************/
/* Model name */ /* Model name
#define ESP_MODEL_NAME "SD_WIFI_PRO" * Modele name of device
*/
#define ESP_MODEL_NAME "ESP Board"
/* Model number */ /* Model number
#define ESP_MODEL_NUMBER "SWP 1.0" * Modele number of device
*/
#define ESP_MODEL_NUMBER "ESP3D 3.0"
/* Model url */ /* Model url
#define ESP_MODEL_URL "https://github.com/FYSETC/SD-WIFI-PRO" * Modele url of device
*/
#define ESP_MODEL_URL "https://www.espressif.com/en/products/devkits"
/* Manufacturer name */ /* Manufacturer name
#define ESP_MANUFACTURER_NAME "FYSETC" * Manufacturer name of device
*/
#define ESP_MANUFACTURER_NAME "Espressif Systems"
/* Manufacturer url */ /* Manufacturer url
#define ESP_MANUFACTURER_URL "https://www.fysetc.com" * Manufacturer url of device
*/
#define ESP_MANUFACTURER_URL "https://www.espressif.com"
/************************************ /************************************
* *
@ -175,6 +274,7 @@
************************************/ ************************************/
/* File system type used by ESP3D /* File system type used by ESP3D
* Type of file system used by ESP3D to store files
* ESP_SPIFFS_FILESYSTEM (Deprecated) * ESP_SPIFFS_FILESYSTEM (Deprecated)
* ESP_FAT_FILESYSTEM (ESP32 only with large partitions) * ESP_FAT_FILESYSTEM (ESP32 only with large partitions)
* ESP_LITTLEFS_FILESYSTEM (Default) * ESP_LITTLEFS_FILESYSTEM (Default)
@ -190,47 +290,76 @@
* *
* SD filesystem * SD filesystem
* *
* Filesystem on SD card - SDIO 4-bit shared mode * Filesystem on SD card
* *
************************************/ ************************************/
/* SD card connection /* SD card connection
* ESP_SHARED_SD: both host and ESP share the SD card * 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
*/ */
#define SD_DEVICE_CONNECTION ESP_SHARED_SD //#define SD_DEVICE_CONNECTION ESP_NOT_SHARED_SD
/* SD card library /* SD card library
* ESP_SDIO: ESP32 SDMMC (4-bit mode) * ESP_SD_NATIVE //esp32 / esp8266
* ESP_SDIO //esp32 only
* ESP_SDFAT2 //esp8266 / esp32
*/ */
#define SD_DEVICE ESP_SDIO //#define SD_DEVICE ESP_SDFAT2
/* SDIO bit mode
* SD_FOUR_BIT_MODE for maximum throughput // #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
*/ */
#define SDIO_BIT_MODE SD_FOUR_BIT_MODE //#define SDIO_BIT_MODE SD_ONE_BIT_MODE
/* Enable date/time on files */ /* Enable date/time on files
#define SD_TIMESTAMP_FEATURE * Set date/time on files using SNTP or last webui connection
*/
// #define SD_TIMESTAMP_FEATURE
/************************************ /************************************
* *
* SD card pins (SDIO mode for SD WIFI Pro) * SD card pins
* *
************************************/ ************************************/
/* SD shared flag pin /* SD card detect pin
* Active LOW to claim SD for ESP * The pin used to detect SD card
*/ */
#define ESP_FLAG_SHARED_SD_PIN 26 // #define ESP_SD_DETECT_PIN 4
#define ESP_FLAG_SHARED_SD_VALUE 0
/* SDIO pins (standard ESP32 SDMMC pins) */ /* SD card detect pin value
#define ESP_SDIO_CLK_PIN 14 * State of SD card detect pin when card is present
#define ESP_SDIO_CMD_PIN 15 */
#define ESP_SDIO_D0_PIN 2 // #define ESP_SD_DETECT_VALUE 0
#define ESP_SDIO_D1_PIN 4
#define ESP_SDIO_D2_PIN 12 /* SD shared flag pin
#define ESP_SDIO_D3_PIN 13 * The pin used to enable SD card for ESP board
*/
// #define ESP_FLAG_SHARED_SD_PIN -1
/* 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
/************************************ /************************************
* *
@ -243,17 +372,42 @@
/* Enable global filesystem /* Enable global filesystem
* Allows to access to all filesystems from same location * Allows to access to all filesystems from same location
*/ */
#define GLOBAL_FILESYSTEM_FEATURE //#define GLOBAL_FILESYSTEM_FEATURE
/* WebDav access /* WebDav access
* FS_ROOT / FS_FLASH / FS_SD * 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
*/ */
#define WEBDAV_FEATURE FS_SD //#define WEBDAV_FEATURE FS_ROOT
/* FTP access (1 connection only) /* FTP access
* FS_ROOT / FS_FLASH / FS_SD * 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
*/ */
#define FTP_FEATURE 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
/************************************ /************************************
* *
@ -263,20 +417,227 @@
* *
************************************/ ************************************/
/* Enable OTA
* Over The Air Update (OTA)
*/
// #define OTA_FEATURE
/* Enable Web Update /* Enable Web Update
* Update firmware using WebUI, need 4MB of flash * Update firmware using WebUI, need 4MB of flash
*/ */
#define WEB_UPDATE_FEATURE #define WEB_UPDATE_FEATURE
/* Disable serial forwarding to external device /* Enable SD card Update
* No printer/CNC connected - this is a standalone SD WiFi device. * Update firmware and settings using file on SDCard
* Non-ESP commands are dropped instead of forwarded to serial.
*/ */
#define NO_SERIAL_FORWARD // #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
/* Settings location /* Settings location
* SETTINGS_IN_EEPROM //ESP8266/ESP32 * SETTINGS_IN_EEPROM //ESP8266/ESP32
* SETTINGS_IN_PREFERENCES //ESP32 only * SETTINGS_IN_PREFERENCES //ESP32 only
* Location where ESP3D will save settings
*/ */
#define ESP_SAVE_SETTINGS SETTINGS_IN_EEPROM #define ESP_SAVE_SETTINGS SETTINGS_IN_EEPROM
@ -287,8 +648,13 @@
************************************/ ************************************/
// Enable log mode // Enable log mode
// LOG_OUTPUT_SERIAL0 / LOG_OUTPUT_SERIAL1 / LOG_OUTPUT_SERIAL2 // Do not do this when connected to printer !!!
// LOG_OUTPUT_TELNET / LOG_OUTPUT_WEBSOCKET // be noted all upload may failed if enabled
// LOG_OUTPUT_SERIAL0
// LOG_OUTPUT_SERIAL1
// LOG_OUTPUT_SERIAL2
// LOG_OUTPUT_TELNET
// LOG_OUTPUT_WEBSOCKET
// #define ESP_LOG_FEATURE LOG_OUTPUT_SERIAL0 // #define ESP_LOG_FEATURE LOG_OUTPUT_SERIAL0
// #define ESP3D_LOG_LEVEL LOG_LEVEL_DEBUG // #define ESP3D_LOG_LEVEL LOG_LEVEL_DEBUG
@ -315,11 +681,16 @@
#define TIMESTAMP_FEATURE #define TIMESTAMP_FEATURE
#endif // SD_TIMESTAMP_FEATURE || FILESYSTEM_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 defined(CAMERA_DEVICE)
#if CAMERA_DEVICE == CAMERA_MODEL_ESP32_CAM_BOARD || \ #if CAMERA_DEVICE == CAMERA_MODEL_ESP32_CAM_BOARD || \
CAMERA_DEVICE == CAMERA_MODEL_ESP32S2_CAM_BOARD CAMERA_DEVICE == CAMERA_MODEL_ESP32S2_CAM_BOARD
#define USE_BOARD_HEARDER 1 #define USE_BOARD_HEARDER 1
#endif #endif // CAMERA_DEVICE==CAMERA_MODEL_ESP32_CAM_BOARD ||
// CAMERA_DEVICE==CAMERA_MODEL_ESP32S2_CAM_BOARD
#endif // CAMERA_DEVICE #endif // CAMERA_DEVICE
#if !defined(WIFI_FEATURE) && !defined(ETH_FEATURE) #if !defined(WIFI_FEATURE) && !defined(ETH_FEATURE)

View file

@ -25,10 +25,8 @@
#include "../esp3d_settings.h" #include "../esp3d_settings.h"
#define COMMAND_ID 200 #define COMMAND_ID 200
// Get/Set SD Card Status // Get SD Card Status
//[ESP200] json=<YES/NO> <RELEASESD> <GRABSD> <REFRESH> pwd=<user/admin password> //[ESP200] json=<YES/NO> <RELEASESD> <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) { void ESP3DCommands::ESP200(int cmd_params_pos, ESP3DMessage* msg) {
ESP3DClientType target = msg->origin; ESP3DClientType target = msg->origin;
ESP3DRequest requestId = msg->request_id; ESP3DRequest requestId = msg->request_id;
@ -41,9 +39,6 @@ void ESP3DCommands::ESP200(int cmd_params_pos, ESP3DMessage* msg) {
bool releasesd = hasTag(msg, cmd_params_pos, "RELEASESD"); bool releasesd = hasTag(msg, cmd_params_pos, "RELEASESD");
bool refreshsd = hasTag(msg, cmd_params_pos, "REFRESH"); bool refreshsd = hasTag(msg, cmd_params_pos, "REFRESH");
bool json = hasTag(msg, cmd_params_pos, "json"); 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; String tmpstr;
#if defined(AUTHENTICATION_FEATURE) #if defined(AUTHENTICATION_FEATURE)
if (msg->authentication_level == ESP3DAuthenticationLevel::guest) { if (msg->authentication_level == ESP3DAuthenticationLevel::guest) {
@ -52,66 +47,26 @@ void ESP3DCommands::ESP200(int cmd_params_pos, ESP3DMessage* msg) {
return; return;
} }
#endif // AUTHENTICATION_FEATURE #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 (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(); ESP_SD::releaseFS();
ok_msg = "SD card released"; ok_msg = "SD card released";
#endif // SD_DEVICE_CONNECTION == ESP_SHARED_SD
} }
if (!releasesd if (!ESP_SD::accessFS()) {
#if SD_DEVICE_CONNECTION == ESP_SHARED_SD if (ESP_SD::getState() == ESP_SDCARD_BUSY) {
&& !grabsd ok_msg = "Busy";
#endif
) {
if (!ESP_SD::accessFS()) {
if (ESP_SD::getState() == ESP_SDCARD_BUSY) {
ok_msg = "Busy";
} else {
ok_msg = "Not available";
}
} else { } else {
int8_t state = ESP_SD::getState(true); ok_msg = "Not available";
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();
} }
} else {
int8_t state = ESP_SD::getState(true);
if (state == ESP_SDCARD_IDLE) {
ok_msg = "SD card ok";
if (refreshsd) {
ESP_SD::refreshStats(true);
}
}
ESP_SD::releaseFS();
} }
if (!dispatchAnswer(msg, COMMAND_ID, json, hasError, if (!dispatchAnswer(msg, COMMAND_ID, json, hasError,

View file

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

View file

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

View file

@ -125,6 +125,49 @@ 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() { void esp3d_network_log_init() {
#if ESP_LOG_FEATURE == LOG_OUTPUT_TELNET #if ESP_LOG_FEATURE == LOG_OUTPUT_TELNET
@ -152,51 +195,3 @@ void esp3d_network_log_end() {
} }
#endif // ESP_LOG_FEATURE #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,14 +22,13 @@
#include "../include/esp3d_config.h" #include "../include/esp3d_config.h"
#include "../include/esp3d_defines.h" #include "../include/esp3d_defines.h"
extern void esp3d_log_init();
#if defined(ESP_LOG_FEATURE) #if defined(ESP_LOG_FEATURE)
extern void esp3d_logf(uint8_t level, const char* format, ...); extern void esp3d_logf(uint8_t level, const char* format, ...);
extern void esp3d_network_log_init(); extern void esp3d_network_log_init();
extern void esp3d_network_log_handle(); extern void esp3d_network_log_handle();
extern void esp3d_network_log_end(); extern void esp3d_network_log_end();
extern void esp3d_log_init();
#if !defined(ESP3D_LOG_LEVEL) && defined(ESP_DEBUG_FEATURE) #if !defined(ESP3D_LOG_LEVEL) && defined(ESP_DEBUG_FEATURE)
#error "ESP3D_LOG_LEVEL is not defined, please define it in configuration.h" #error "ESP3D_LOG_LEVEL is not defined, please define it in configuration.h"
@ -76,7 +75,7 @@ extern void esp3d_network_log_end();
#define esp3d_log_d(format, ...) #define esp3d_log_d(format, ...)
#define esp3d_log(format, ...) #define esp3d_log(format, ...)
#undef ESP3D_LOG_LEVEL #undef ESP3D_LOG_LEVEL
#define ESP3D_LOG_INIT_FN esp3d_log_init(); //to desactivate idf log extensively #define ESP3D_LOG_INIT_FN
#define ESP3D_LOG_NETWORK_INIT_FN #define ESP3D_LOG_NETWORK_INIT_FN
#define ESP3D_LOG_NETWORK_HANDLE_FN #define ESP3D_LOG_NETWORK_HANDLE_FN
#define ESP3D_LOG_NETWORK_END_FN #define ESP3D_LOG_NETWORK_END_FN

View file

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

View file

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

View file

@ -31,7 +31,6 @@
#if SD_DEVICE_CONNECTION == ESP_SHARED_SD #if SD_DEVICE_CONNECTION == ESP_SHARED_SD
bool ESP_SD::_enabled = false; bool ESP_SD::_enabled = false;
bool ESP_SD::_manualHold = false;
#if SD_CARD_TYPE == ESP_FYSETC_WIFI_PRO_SDCARD #if SD_CARD_TYPE == ESP_FYSETC_WIFI_PRO_SDCARD
#include <SPI.h> #include <SPI.h>
#endif // SD_CARD_TYPE == ESP_FYSETC_WIFI_PRO_SDCARD #endif // SD_CARD_TYPE == ESP_FYSETC_WIFI_PRO_SDCARD
@ -95,41 +94,6 @@ bool ESP_SD::disableSharedSD() {
ESP3DHal::wait(100); ESP3DHal::wait(100);
return true; 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 #endif // SD_DEVICE_CONNECTION == ESP_SHARED_SD
bool ESP_SD::_started = false; bool ESP_SD::_started = false;
@ -155,11 +119,7 @@ bool ESP_SD::accessFS(uint8_t FS) {
return false; return false;
} }
#if SD_DEVICE_CONNECTION == ESP_SHARED_SD #if SD_DEVICE_CONNECTION == ESP_SHARED_SD
if (_manualHold && _enabled) { if (ESP_SD::enableSharedSD()) {
// 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"); esp3d_log("Access shared SD ok");
res = true; res = true;
} else { } else {
@ -191,11 +151,6 @@ void ESP_SD::releaseFS(uint8_t FS) {
esp3d_log("Release SD"); esp3d_log("Release SD");
setState(ESP_SDCARD_IDLE); setState(ESP_SDCARD_IDLE);
#if SD_DEVICE_CONNECTION == ESP_SHARED_SD #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; _enabled = false;
#if defined(ESP_FLAG_SHARED_SD_PIN) && ESP_FLAG_SHARED_SD_PIN != -1 #if defined(ESP_FLAG_SHARED_SD_PIN) && ESP_FLAG_SHARED_SD_PIN != -1
if (ESP_SD::disableSharedSD()) { if (ESP_SD::disableSharedSD()) {

View file

@ -91,15 +91,11 @@ class ESP_SD {
static bool enableSharedSD(); static bool enableSharedSD();
static bool disableSharedSD(); static bool disableSharedSD();
static bool isEnabled() { return _enabled; } static bool isEnabled() { return _enabled; }
static bool grabSD();
static bool releaseGrab();
static bool isManualHold() { return _manualHold; }
#endif // SD_DEVICE_CONNECTION == ESP_SHARED_SD #endif // SD_DEVICE_CONNECTION == ESP_SHARED_SD
private: private:
static bool _started; static bool _started;
#if SD_DEVICE_CONNECTION == ESP_SHARED_SD #if SD_DEVICE_CONNECTION == ESP_SHARED_SD
static bool _enabled; static bool _enabled;
static bool _manualHold;
#endif // SD_DEVICE_CONNECTION == ESP_SHARED_SD #endif // SD_DEVICE_CONNECTION == ESP_SHARED_SD
static uint8_t _state; static uint8_t _state;
static uint8_t _spi_speed_divider; 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_h
#define favicon_size 344 #define favicon_size 344
const unsigned char favicon[344] PROGMEM = { const unsigned char favicon[344] PROGMEM = {
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xb5, 0x94, 0x31, 0x4b, 0xc3, 0x50, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0xb5, 0x94, 0x31, 0x4b, 0xc3, 0x50,
0x14, 0x85, 0x4f, 0x63, 0xc1, 0x5a, 0x0b, 0x06, 0x91, 0x4e, 0x52, 0x3a, 0x44, 0x10, 0x27, 0x31, 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, 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, 0x80, 0xbf, 0xa0, 0x63, 0x56, 0x1d, 0x1d, 0x9c, 0xa4, 0x74, 0x15, 0x1c, 0xc4, 0x4d, 0x90, 0x0e,

View file

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

View file

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

View file

View file

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

View file

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