Skip to content

Commit 3bb05c9

Browse files
committed
Update ESP32SSDP library to access started state and ethernet fix
Add SSDP ad mDNS to ESP420 report| Add waiting loop to get the ethernet IP in DHCP in STA mode to be sure network services start with proper IP Change debug log to verbose log Bump version
1 parent d6a58d5 commit 3bb05c9

File tree

24 files changed

+83
-42
lines changed

24 files changed

+83
-42
lines changed

.github/ci/prepare-libs.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ shopt -s globstar
66
ls $HOME
77
# Make sure we are inside the github workspace
88
cd $GITHUB_WORKSPACE
9-
cp -r ./libraries/ESP32SSDP-2.0.2 $HOME/arduino_ide/libraries/
9+
cp -r ./libraries/ESP32SSDP-2.0.3 $HOME/arduino_ide/libraries/
1010
cp -r ./libraries/arduinoWebSockets-2.6.1 $HOME/arduino_ide/libraries/
1111
cp -r ./libraries/DHT_sensor_library_for_ESPx-1.0.6 $HOME/arduino_ide/libraries/
1212
cp -r ./libraries/esp8266-oled-ssd1306-4.3.0 $HOME/arduino_ide/libraries/

esp3d/configuration.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@
126126
/* Use Ethernet
127127
* Enable ethernet communications
128128
*/
129-
//#define ETH_FEATURE
129+
#define ETH_FEATURE
130130

131131
// Ethernet type (Check ETH.h eth_phy_type_t)
132132
// TYPE_ETH_PHY_LAN8720
@@ -137,7 +137,7 @@
137137
// TYPE_ETH_PHY_KSZ8041
138138
// TYPE_ETH_PHY_KSZ8081
139139
// TYPE_ETH_PHY_W5500
140-
//#define ESP3D_ETH_PHY_TYPE TYPE_ETH_PHY_W5500
140+
#define ESP3D_ETH_PHY_TYPE TYPE_ETH_PHY_W5500
141141

142142
// Ethernet board Clock mode
143143
// MODE_ETH_CLOCK_GPIO0_IN
@@ -153,15 +153,15 @@
153153
// These are the pins for the W5500 chip using SPI
154154
#define ETHERNET_SPI_USE_SPI 1
155155
#define ETHERNET_SPI_USE_SPI2 0
156-
#define ETH_SPI_SCK 8
156+
#define ETH_SPI_SCK 18
157157
#define ETH_SPI_MISO 23
158158
#define ETH_SPI_MOSI 19
159159
#define ETH_PHY_CS 5
160-
#define ETH_PHY_IRQ 33
160+
#define ETH_PHY_IRQ -1
161161
#define ETH_PHY_RST 4
162162

163163
// Address of ethernet board
164-
#define ESP3D_ETH_PHY_ADDR 0
164+
#define ESP3D_ETH_PHY_ADDR 1
165165

166166
/* Use Bluetooth
167167
* Enable serial bluetooth communications
@@ -372,15 +372,15 @@
372372
/* Enable global filesystem
373373
* Allows to access to all filesystems from same location
374374
*/
375-
#define GLOBAL_FILESYSTEM_FEATURE
375+
//#define GLOBAL_FILESYSTEM_FEATURE
376376

377377
/* WebDav access
378378
* Use WebDav to access to your filesystem
379379
* FS_ROOT //mount all FS, need GLOBAL_FILESYSTEM_FEATURE
380380
* FS_FLASH //mount Flash FS
381381
* FS_SD mount SD FS
382382
*/
383-
#define WEBDAV_FEATURE FS_ROOT
383+
//#define WEBDAV_FEATURE FS_ROOT
384384

385385
/* FTP access
386386
* Use FTP to access to your filesystem (1 connection only)
@@ -463,8 +463,8 @@
463463
* Wire address of display
464464
*/
465465
#define DISPLAY_I2C_ADDR 0x3c
466-
//#define ESP_SDA_PIN 21
467-
//#define ESP_SCL_PIN 22
466+
#define ESP_SDA_PIN 21
467+
#define ESP_SCL_PIN 22
468468

469469
/* Display reset pin
470470
* The pin used to reset the screen (optional)

esp3d/src/core/commands/ESP420.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@
8181
#if defined(AUTHENTICATION_FEATURE)
8282
#include "../../modules/authentication/authentication_service.h"
8383
#endif // AUTHENTICATION_FEATURE
84+
#if defined(SSDP_FEATURE)
85+
#include <ESP32SSDP.h>
86+
#endif // SSDP_FEATURE
87+
#if defined(MDNS_FEATURE)
88+
#include "../../modules/mDNS/mDNS.h"
89+
#endif // MDNS_FEATURE
8490

8591
#if defined(USB_SERIAL_FEATURE)
8692
#include "../../modules/usb-serial/usb_serial_service.h"
@@ -304,6 +310,21 @@ void ESP3DCommands::ESP420(int cmd_params_pos, ESP3DMessage* msg) {
304310
false)) {
305311
return;
306312
}
313+
#if defined (SSDP_FEATURE)
314+
// SSDP enabled
315+
tmpstr = SSDP.started() ? "ON (" + String(SSDP.localIP().toString()) + ")" : "OFF";
316+
if (!dispatchIdValue(json, "SSDP", tmpstr.c_str(), target, requestId, false)) {
317+
return;
318+
}
319+
#endif // SSDP_FEATURE
320+
321+
#if defined (MDNS_FEATURE)
322+
// MDNS enabled
323+
tmpstr = esp3d_mDNS.started() ? "ON" : "OFF";
324+
if (!dispatchIdValue(json, "MDNS", tmpstr.c_str(), target, requestId, false)) {
325+
return;
326+
}
327+
#endif // MDNS_FEATURE
307328

308329
#if defined(HTTP_FEATURE)
309330
if (HTTP_Server::started()) {

esp3d/src/core/esp3d_commands.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1227,7 +1227,7 @@ bool ESP3DCommands::dispatch(ESP3DMessage *msg, uint8_t *sbuf, size_t len) {
12271227
// check is need \n at the end of the command
12281228
if (msg->type == ESP3DMessageType::unique ||
12291229
msg->type == ESP3DMessageType::tail) {
1230-
esp3d_log_d("unique or tail message :*%s*", (char *)sbuf);
1230+
esp3d_log("unique or tail message :*%s*", (char *)sbuf);
12311231
if (!formatCommand((char *)sbuf, len)) {
12321232
esp3d_log("format command failed");
12331233
String tmpstr = "";
@@ -1244,7 +1244,7 @@ bool ESP3DCommands::dispatch(ESP3DMessage *msg, uint8_t *sbuf, size_t len) {
12441244
return false;
12451245
}
12461246
} else {
1247-
esp3d_log_d("format command success, no need to update");
1247+
esp3d_log("format command success, no need to update");
12481248
if (!esp3d_message_manager.setDataContent(msg, sbuf, len)) {
12491249
esp3d_log_e("set data content failed");
12501250
esp3d_message_manager.deleteMsg(msg);
@@ -1254,7 +1254,7 @@ bool ESP3DCommands::dispatch(ESP3DMessage *msg, uint8_t *sbuf, size_t len) {
12541254
} else {
12551255
esp3d_log("not unique or tail message");
12561256
if (msg->type == ESP3DMessageType::realtimecmd){
1257-
esp3d_log_d("realtime command");
1257+
esp3d_log("realtime command");
12581258
}
12591259
if (!esp3d_message_manager.setDataContent(msg, sbuf, len)) {
12601260
esp3d_log_e("set data content failed");

esp3d/src/include/esp3d_version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#define _VERSION_ESP3D_H
2323

2424
// version and sources location
25-
#define FW_VERSION "3.0.0.a246"
25+
#define FW_VERSION "3.0.0.a247"
2626
#define REPOSITORY "https://github.com/luc-github/ESP3D/tree/3.0"
2727

2828
#endif //_VERSION_ESP3D_H

esp3d/src/modules/ethernet/ethconfig.cpp

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
#endif // ETHERNET_SPI_USE_SPI
3636
#if ETHERNET_SPI_USE_SPI2
3737
#define ETH_SPI SPI2
38-
#endif // ETHERNET_SPI_USE_SPI2
38+
#endif // ETHERNET_SPI_USE_SPI2
3939
#ifndef ETH_SPI
4040
#define ETH_SPI SPI
4141
#endif // ETH_SPI
@@ -102,9 +102,9 @@ bool EthConfig::begin(int8_t& espMode) {
102102
phytype = ETH_PHY_KSZ8081;
103103
}
104104
esp3d_log("ETH PHY Type %d", phytype);
105-
_started = ETH.begin(phytype, ESP3D_ETH_PHY_ADDR,
106-
ESP3D_ETH_PHY_POWER_PIN, ESP3D_ETH_PHY_MDC_PIN,
107-
ESP3D_ETH_PHY_MDIO_PIN, ESP3D_ETH_CLK_MODE_PIN);
105+
_started = ETH.begin(phytype, ESP3D_ETH_PHY_ADDR, ESP3D_ETH_PHY_POWER_PIN,
106+
ESP3D_ETH_PHY_MDC_PIN, ESP3D_ETH_PHY_MDIO_PIN,
107+
ESP3D_ETH_CLK_MODE_PIN);
108108
#endif // ESP3D_ETH_PHY_TYPE == TYPE_ETH_PHY_TLK110 || ESP3D_ETH_PHY_TYPE ==
109109
// TYPE_ETH_PHY_RTL8201 || ESP3D_ETH_PHY_TYPE == TYPE_ETH_PHY_DP83848 ||
110110
// ESP3D_ETH_PHY_TYPE == TYPE_ETH_PHY_KSZ8041 || ESP3D_ETH_PHY_TYPE ==
@@ -113,7 +113,7 @@ bool EthConfig::begin(int8_t& espMode) {
113113
esp3d_log("ETH spi PHY Type %d", ESP3D_ETH_PHY_TYPE);
114114
ETH_SPI.begin(ETH_SPI_SCK, ETH_SPI_MISO, ETH_SPI_MOSI);
115115
_started = ETH.begin(ETH_PHY_W5500, ESP3D_ETH_PHY_ADDR, ETH_PHY_CS,
116-
ETH_PHY_IRQ, ETH_PHY_RST, ETH_SPI);
116+
ETH_PHY_IRQ, ETH_PHY_RST, ETH_SPI);
117117
#endif // ESP3D_ETH_PHY_TYPE == TYPE_ETH_PHY_W5500
118118

119119
if (_started) {
@@ -155,16 +155,34 @@ bool EthConfig::begin(int8_t& espMode) {
155155
ESP3DClientType::system,
156156
ESP3DAuthenticationLevel::admin);
157157
}
158+
158159
res = true;
159160
}
160161
}
161-
// Static IP or DHCP client ?
162-
if ((ESP3DSettings::readByte(ESP_ETH_STA_IP_MODE) != DHCP_MODE)) {
163-
esp3d_log("Show IP");
164-
esp3d_commands.dispatch(ETH.localIP().toString().c_str(),
165-
ESP3DClientType::all_clients, no_id,
166-
ESP3DMessageType::unique, ESP3DClientType::system,
167-
ESP3DAuthenticationLevel::admin);
162+
if (res) {
163+
// Static IP or DHCP client ?
164+
if ((ESP3DSettings::readByte(ESP_ETH_STA_IP_MODE) == DHCP_MODE)) {
165+
uint64_t start = millis();
166+
String ip = ETH.localIP().toString();
167+
esp3d_log("IP");
168+
esp3d_log("Waiting for IP");
169+
while (millis() - start < 10000 && ip == "0.0.0.0") {
170+
ip = ETH.localIP().toString();
171+
ESP3DHal::wait(100);
172+
}
173+
if (ip != "0.0.0.0") {
174+
esp3d_log("Show IP");
175+
esp3d_commands.dispatch(
176+
ETH.localIP().toString().c_str(), ESP3DClientType::all_clients,
177+
no_id, ESP3DMessageType::unique, ESP3DClientType::system,
178+
ESP3DAuthenticationLevel::admin);
179+
} else {
180+
esp3d_log_e("Failed to get IP");
181+
res = false;
182+
}
183+
}
184+
} else {
185+
esp3d_log_e("Failed starting ethernet");
168186
}
169187

170188
return res;

esp3d/src/modules/http/handlers/handle-command.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,33 +46,33 @@ void HTTP_Server::handle_web_command() {
4646
bool isRealTimeCommand = false;
4747
if (_webserver->hasArg("cmd")) {
4848
cmd = _webserver->arg("cmd");
49-
esp3d_log_d("Command is %s", cmd.c_str());
49+
esp3d_log("Command is %s", cmd.c_str());
5050
if (!cmd.endsWith("\n")) {
51-
esp3d_log_d("Command is not ending with \\n");
51+
esp3d_log("Command is not ending with \\n");
5252
if (ESP3DSettings::GetFirmwareTarget() == GRBL || ESP3DSettings::GetFirmwareTarget() == GRBLHAL) {
5353
uint len = cmd.length();
5454
if (!((len == 1 && esp3d_string::isRealTimeCommand(cmd[0])) ||
5555
(len == 2 && esp3d_string::isRealTimeCommand(cmd[1])))) {
5656
cmd += "\n";
57-
esp3d_log_d("Command is not realtime, adding \\n");
57+
esp3d_log("Command is not realtime, adding \\n");
5858
} else { // no need \n for realtime command
59-
esp3d_log_d("Command is realtime, no need to add \\n");
59+
esp3d_log("Command is realtime, no need to add \\n");
6060
isRealTimeCommand = true;
6161
// remove the 0XC2 that should not be there
6262
if (len == 2 && esp3d_string::isRealTimeCommand(cmd[1]) && cmd[1] == 0xC2) {
6363
cmd[0] = cmd[1];
6464
cmd[1] = 0x0;
65-
esp3d_log_d("Command is realtime, removing 0xC2");
65+
esp3d_log("Command is realtime, removing 0xC2");
6666
}
6767
}
6868
} else {
69-
esp3d_log_d("Command is not realtime, adding \\n");
69+
esp3d_log("Command is not realtime, adding \\n");
7070
cmd += "\n"; // need to validate command
7171
}
7272
} else {
73-
esp3d_log_d("Command is ending with \\n");
73+
esp3d_log("Command is ending with \\n");
7474
}
75-
esp3d_log_d("Message type is %s for %s", isRealTimeCommand ? "realtimecmd" : "unique", cmd.c_str());
75+
esp3d_log("Message type is %s for %s", isRealTimeCommand ? "realtimecmd" : "unique", cmd.c_str());
7676
if (esp3d_commands.is_esp_command((uint8_t *)cmd.c_str(), cmd.length())) {
7777
ESP3DMessage *msg = esp3d_message_manager.newMsg(
7878
ESP3DClientType::http, esp3d_commands.getOutputClient(),

info.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"version": "3.0.0.a246"
2+
"version": "3.0.0.a247"
33
}
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)