diff --git a/.github/ci/prepare-libs.sh b/.github/ci/prepare-libs.sh index e5c713f5f..d9713d875 100644 --- a/.github/ci/prepare-libs.sh +++ b/.github/ci/prepare-libs.sh @@ -6,7 +6,7 @@ shopt -s globstar ls $HOME # Make sure we are inside the github workspace cd $GITHUB_WORKSPACE -cp -r ./libraries/ESP32SSDP-2.0.2 $HOME/arduino_ide/libraries/ +cp -r ./libraries/ESP32SSDP-2.0.3 $HOME/arduino_ide/libraries/ cp -r ./libraries/arduinoWebSockets-2.6.1 $HOME/arduino_ide/libraries/ cp -r ./libraries/DHT_sensor_library_for_ESPx-1.0.6 $HOME/arduino_ide/libraries/ cp -r ./libraries/esp8266-oled-ssd1306-4.3.0 $HOME/arduino_ide/libraries/ diff --git a/esp3d/configuration.h b/esp3d/configuration.h index 0b429f24d..f6e40b7e0 100644 --- a/esp3d/configuration.h +++ b/esp3d/configuration.h @@ -126,7 +126,7 @@ /* Use Ethernet * Enable ethernet communications */ -//#define ETH_FEATURE +#define ETH_FEATURE // Ethernet type (Check ETH.h eth_phy_type_t) // TYPE_ETH_PHY_LAN8720 @@ -137,7 +137,7 @@ // TYPE_ETH_PHY_KSZ8041 // TYPE_ETH_PHY_KSZ8081 // TYPE_ETH_PHY_W5500 -//#define ESP3D_ETH_PHY_TYPE TYPE_ETH_PHY_W5500 +#define ESP3D_ETH_PHY_TYPE TYPE_ETH_PHY_W5500 // Ethernet board Clock mode // MODE_ETH_CLOCK_GPIO0_IN @@ -153,15 +153,15 @@ // 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 8 +#define ETH_SPI_SCK 18 #define ETH_SPI_MISO 23 #define ETH_SPI_MOSI 19 #define ETH_PHY_CS 5 -#define ETH_PHY_IRQ 33 +#define ETH_PHY_IRQ -1 #define ETH_PHY_RST 4 // Address of ethernet board -#define ESP3D_ETH_PHY_ADDR 0 +#define ESP3D_ETH_PHY_ADDR 1 /* Use Bluetooth * Enable serial bluetooth communications @@ -372,7 +372,7 @@ /* 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 @@ -380,7 +380,7 @@ * FS_FLASH //mount Flash FS * FS_SD mount SD FS */ -#define WEBDAV_FEATURE FS_ROOT +//#define WEBDAV_FEATURE FS_ROOT /* FTP access * Use FTP to access to your filesystem (1 connection only) @@ -463,8 +463,8 @@ * Wire address of display */ #define DISPLAY_I2C_ADDR 0x3c - //#define ESP_SDA_PIN 21 - //#define ESP_SCL_PIN 22 + #define ESP_SDA_PIN 21 + #define ESP_SCL_PIN 22 /* Display reset pin * The pin used to reset the screen (optional) diff --git a/esp3d/src/core/commands/ESP420.cpp b/esp3d/src/core/commands/ESP420.cpp index 701e871ff..b3ac1c4ae 100644 --- a/esp3d/src/core/commands/ESP420.cpp +++ b/esp3d/src/core/commands/ESP420.cpp @@ -81,6 +81,12 @@ #if defined(AUTHENTICATION_FEATURE) #include "../../modules/authentication/authentication_service.h" #endif // AUTHENTICATION_FEATURE +#if defined(SSDP_FEATURE) +#include +#endif // SSDP_FEATURE +#if defined(MDNS_FEATURE) +#include "../../modules/mDNS/mDNS.h" +#endif // MDNS_FEATURE #if defined(USB_SERIAL_FEATURE) #include "../../modules/usb-serial/usb_serial_service.h" @@ -304,6 +310,21 @@ void ESP3DCommands::ESP420(int cmd_params_pos, ESP3DMessage* msg) { false)) { return; } + #if defined (SSDP_FEATURE) + // SSDP enabled + tmpstr = SSDP.started() ? "ON (" + String(SSDP.localIP().toString()) + ")" : "OFF"; + if (!dispatchIdValue(json, "SSDP", tmpstr.c_str(), target, requestId, false)) { + return; + } + #endif // SSDP_FEATURE + + #if defined (MDNS_FEATURE) + // MDNS enabled + tmpstr = esp3d_mDNS.started() ? "ON" : "OFF"; + if (!dispatchIdValue(json, "MDNS", tmpstr.c_str(), target, requestId, false)) { + return; + } + #endif // MDNS_FEATURE #if defined(HTTP_FEATURE) if (HTTP_Server::started()) { diff --git a/esp3d/src/core/esp3d_commands.cpp b/esp3d/src/core/esp3d_commands.cpp index 80d0ab94e..e50068a89 100644 --- a/esp3d/src/core/esp3d_commands.cpp +++ b/esp3d/src/core/esp3d_commands.cpp @@ -1227,7 +1227,7 @@ bool ESP3DCommands::dispatch(ESP3DMessage *msg, uint8_t *sbuf, size_t len) { // check is need \n at the end of the command if (msg->type == ESP3DMessageType::unique || msg->type == ESP3DMessageType::tail) { - esp3d_log_d("unique or tail message :*%s*", (char *)sbuf); + esp3d_log("unique or tail message :*%s*", (char *)sbuf); if (!formatCommand((char *)sbuf, len)) { esp3d_log("format command failed"); String tmpstr = ""; @@ -1244,7 +1244,7 @@ bool ESP3DCommands::dispatch(ESP3DMessage *msg, uint8_t *sbuf, size_t len) { return false; } } else { - esp3d_log_d("format command success, no need to update"); + esp3d_log("format command success, no need to update"); if (!esp3d_message_manager.setDataContent(msg, sbuf, len)) { esp3d_log_e("set data content failed"); esp3d_message_manager.deleteMsg(msg); @@ -1254,7 +1254,7 @@ bool ESP3DCommands::dispatch(ESP3DMessage *msg, uint8_t *sbuf, size_t len) { } else { esp3d_log("not unique or tail message"); if (msg->type == ESP3DMessageType::realtimecmd){ - esp3d_log_d("realtime command"); + esp3d_log("realtime command"); } if (!esp3d_message_manager.setDataContent(msg, sbuf, len)) { esp3d_log_e("set data content failed"); diff --git a/esp3d/src/include/esp3d_version.h b/esp3d/src/include/esp3d_version.h index 2b51fb3a1..e561326ce 100644 --- a/esp3d/src/include/esp3d_version.h +++ b/esp3d/src/include/esp3d_version.h @@ -22,7 +22,7 @@ #define _VERSION_ESP3D_H // version and sources location -#define FW_VERSION "3.0.0.a246" +#define FW_VERSION "3.0.0.a247" #define REPOSITORY "https://github.com/luc-github/ESP3D/tree/3.0" #endif //_VERSION_ESP3D_H diff --git a/esp3d/src/modules/ethernet/ethconfig.cpp b/esp3d/src/modules/ethernet/ethconfig.cpp index e7959872f..03def7904 100644 --- a/esp3d/src/modules/ethernet/ethconfig.cpp +++ b/esp3d/src/modules/ethernet/ethconfig.cpp @@ -35,7 +35,7 @@ #endif // ETHERNET_SPI_USE_SPI #if ETHERNET_SPI_USE_SPI2 #define ETH_SPI SPI2 -#endif // ETHERNET_SPI_USE_SPI2 +#endif // ETHERNET_SPI_USE_SPI2 #ifndef ETH_SPI #define ETH_SPI SPI #endif // ETH_SPI @@ -102,9 +102,9 @@ bool EthConfig::begin(int8_t& espMode) { phytype = ETH_PHY_KSZ8081; } esp3d_log("ETH PHY Type %d", phytype); - _started = ETH.begin(phytype, ESP3D_ETH_PHY_ADDR, - ESP3D_ETH_PHY_POWER_PIN, ESP3D_ETH_PHY_MDC_PIN, - ESP3D_ETH_PHY_MDIO_PIN, ESP3D_ETH_CLK_MODE_PIN); + _started = ETH.begin(phytype, ESP3D_ETH_PHY_ADDR, ESP3D_ETH_PHY_POWER_PIN, + ESP3D_ETH_PHY_MDC_PIN, ESP3D_ETH_PHY_MDIO_PIN, + ESP3D_ETH_CLK_MODE_PIN); #endif // ESP3D_ETH_PHY_TYPE == TYPE_ETH_PHY_TLK110 || ESP3D_ETH_PHY_TYPE == // TYPE_ETH_PHY_RTL8201 || ESP3D_ETH_PHY_TYPE == TYPE_ETH_PHY_DP83848 || // ESP3D_ETH_PHY_TYPE == TYPE_ETH_PHY_KSZ8041 || ESP3D_ETH_PHY_TYPE == @@ -113,7 +113,7 @@ bool EthConfig::begin(int8_t& espMode) { esp3d_log("ETH spi PHY Type %d", ESP3D_ETH_PHY_TYPE); ETH_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, ETH_SPI); #endif // ESP3D_ETH_PHY_TYPE == TYPE_ETH_PHY_W5500 if (_started) { @@ -155,16 +155,34 @@ bool EthConfig::begin(int8_t& espMode) { ESP3DClientType::system, ESP3DAuthenticationLevel::admin); } + res = true; } } - // Static IP or DHCP client ? - if ((ESP3DSettings::readByte(ESP_ETH_STA_IP_MODE) != DHCP_MODE)) { - esp3d_log("Show IP"); - esp3d_commands.dispatch(ETH.localIP().toString().c_str(), - ESP3DClientType::all_clients, no_id, - ESP3DMessageType::unique, ESP3DClientType::system, - ESP3DAuthenticationLevel::admin); + if (res) { + // Static IP or DHCP client ? + if ((ESP3DSettings::readByte(ESP_ETH_STA_IP_MODE) == DHCP_MODE)) { + uint64_t start = millis(); + String ip = ETH.localIP().toString(); + esp3d_log("IP"); + esp3d_log("Waiting for IP"); + while (millis() - start < 10000 && ip == "0.0.0.0") { + ip = ETH.localIP().toString(); + ESP3DHal::wait(100); + } + if (ip != "0.0.0.0") { + esp3d_log("Show IP"); + esp3d_commands.dispatch( + ETH.localIP().toString().c_str(), ESP3DClientType::all_clients, + no_id, ESP3DMessageType::unique, ESP3DClientType::system, + ESP3DAuthenticationLevel::admin); + } else { + esp3d_log_e("Failed to get IP"); + res = false; + } + } + } else { + esp3d_log_e("Failed starting ethernet"); } return res; diff --git a/esp3d/src/modules/http/handlers/handle-command.cpp b/esp3d/src/modules/http/handlers/handle-command.cpp index 2b94b1af3..580694b39 100644 --- a/esp3d/src/modules/http/handlers/handle-command.cpp +++ b/esp3d/src/modules/http/handlers/handle-command.cpp @@ -46,33 +46,33 @@ void HTTP_Server::handle_web_command() { bool isRealTimeCommand = false; if (_webserver->hasArg("cmd")) { cmd = _webserver->arg("cmd"); - esp3d_log_d("Command is %s", cmd.c_str()); + esp3d_log("Command is %s", cmd.c_str()); if (!cmd.endsWith("\n")) { - esp3d_log_d("Command is not ending with \\n"); + esp3d_log("Command is not ending with \\n"); 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_d("Command is not realtime, adding \\n"); + esp3d_log("Command is not realtime, adding \\n"); } else { // no need \n for realtime command - esp3d_log_d("Command is realtime, no need to add \\n"); + esp3d_log("Command is realtime, no need to add \\n"); 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_d("Command is realtime, removing 0xC2"); + esp3d_log("Command is realtime, removing 0xC2"); } } } else { - esp3d_log_d("Command is not realtime, adding \\n"); + esp3d_log("Command is not realtime, adding \\n"); cmd += "\n"; // need to validate command } } else { - esp3d_log_d("Command is ending with \\n"); + esp3d_log("Command is ending with \\n"); } - esp3d_log_d("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())) { ESP3DMessage *msg = esp3d_message_manager.newMsg( ESP3DClientType::http, esp3d_commands.getOutputClient(), diff --git a/info.json b/info.json index 56059ec64..2e93cfc1d 100644 --- a/info.json +++ b/info.json @@ -1,3 +1,3 @@ { - "version": "3.0.0.a246" + "version": "3.0.0.a247" } \ No newline at end of file diff --git a/libraries/ESP32SSDP-2.0.2/.all-contributorsrc b/libraries/ESP32SSDP-2.0.3/.all-contributorsrc similarity index 100% rename from libraries/ESP32SSDP-2.0.2/.all-contributorsrc rename to libraries/ESP32SSDP-2.0.3/.all-contributorsrc diff --git a/libraries/ESP32SSDP-2.0.2/.astylerc b/libraries/ESP32SSDP-2.0.3/.astylerc similarity index 100% rename from libraries/ESP32SSDP-2.0.2/.astylerc rename to libraries/ESP32SSDP-2.0.3/.astylerc diff --git a/libraries/ESP32SSDP-2.0.2/.gitignore b/libraries/ESP32SSDP-2.0.3/.gitignore similarity index 100% rename from libraries/ESP32SSDP-2.0.2/.gitignore rename to libraries/ESP32SSDP-2.0.3/.gitignore diff --git a/libraries/ESP32SSDP-2.0.2/LICENSE b/libraries/ESP32SSDP-2.0.3/LICENSE similarity index 100% rename from libraries/ESP32SSDP-2.0.2/LICENSE rename to libraries/ESP32SSDP-2.0.3/LICENSE diff --git a/libraries/ESP32SSDP-2.0.2/README.md b/libraries/ESP32SSDP-2.0.3/README.md similarity index 100% rename from libraries/ESP32SSDP-2.0.2/README.md rename to libraries/ESP32SSDP-2.0.3/README.md diff --git a/libraries/ESP32SSDP-2.0.2/examples/SSDP/Readme.md b/libraries/ESP32SSDP-2.0.3/examples/SSDP/Readme.md similarity index 100% rename from libraries/ESP32SSDP-2.0.2/examples/SSDP/Readme.md rename to libraries/ESP32SSDP-2.0.3/examples/SSDP/Readme.md diff --git a/libraries/ESP32SSDP-2.0.2/examples/SSDP/SSDP.ino b/libraries/ESP32SSDP-2.0.3/examples/SSDP/SSDP.ino similarity index 100% rename from libraries/ESP32SSDP-2.0.2/examples/SSDP/SSDP.ino rename to libraries/ESP32SSDP-2.0.3/examples/SSDP/SSDP.ino diff --git a/libraries/ESP32SSDP-2.0.2/examples/SSDPAsyncWebserver/Readme.md b/libraries/ESP32SSDP-2.0.3/examples/SSDPAsyncWebserver/Readme.md similarity index 100% rename from libraries/ESP32SSDP-2.0.2/examples/SSDPAsyncWebserver/Readme.md rename to libraries/ESP32SSDP-2.0.3/examples/SSDPAsyncWebserver/Readme.md diff --git a/libraries/ESP32SSDP-2.0.2/examples/SSDPAsyncWebserver/SSDPAsyncWebserver.ino b/libraries/ESP32SSDP-2.0.3/examples/SSDPAsyncWebserver/SSDPAsyncWebserver.ino similarity index 100% rename from libraries/ESP32SSDP-2.0.2/examples/SSDPAsyncWebserver/SSDPAsyncWebserver.ino rename to libraries/ESP32SSDP-2.0.3/examples/SSDPAsyncWebserver/SSDPAsyncWebserver.ino diff --git a/libraries/ESP32SSDP-2.0.2/keywords.txt b/libraries/ESP32SSDP-2.0.3/keywords.txt similarity index 100% rename from libraries/ESP32SSDP-2.0.2/keywords.txt rename to libraries/ESP32SSDP-2.0.3/keywords.txt diff --git a/libraries/ESP32SSDP-2.0.2/library.properties b/libraries/ESP32SSDP-2.0.3/library.properties similarity index 93% rename from libraries/ESP32SSDP-2.0.2/library.properties rename to libraries/ESP32SSDP-2.0.3/library.properties index 4cf7928d4..fb86d2ecb 100644 --- a/libraries/ESP32SSDP-2.0.2/library.properties +++ b/libraries/ESP32SSDP-2.0.3/library.properties @@ -1,5 +1,5 @@ name=ESP32SSDP -version=2.0.2 +version=2.0.3 author=Me-No-Dev maintainer=luc-github sentence=Simple SSDP library for ESP32 diff --git a/libraries/ESP32SSDP-2.0.2/set_style.bat b/libraries/ESP32SSDP-2.0.3/set_style.bat similarity index 100% rename from libraries/ESP32SSDP-2.0.2/set_style.bat rename to libraries/ESP32SSDP-2.0.3/set_style.bat diff --git a/libraries/ESP32SSDP-2.0.2/src/ESP32SSDP.cpp b/libraries/ESP32SSDP-2.0.3/src/ESP32SSDP.cpp similarity index 99% rename from libraries/ESP32SSDP-2.0.2/src/ESP32SSDP.cpp rename to libraries/ESP32SSDP-2.0.3/src/ESP32SSDP.cpp index 0f3163bde..968194d10 100644 --- a/libraries/ESP32SSDP-2.0.2/src/ESP32SSDP.cpp +++ b/libraries/ESP32SSDP-2.0.3/src/ESP32SSDP.cpp @@ -144,6 +144,7 @@ SSDPClass::SSDPClass() : _replySlots{NULL}, _respondToAddr{0, 0, 0, 0} { SSDPClass::~SSDPClass() { end(); } void SSDPClass::end() { + _started = false; if (_schema) { free(_schema); _schema = nullptr; @@ -175,17 +176,16 @@ IPAddress SSDPClass::localIP() { // Arduino ESP32 3.x board version esp_netif_ip_info_t ip; if (WiFi.getMode() == WIFI_STA) { - if (esp_netif_get_ip_info(get_esp_interface_netif(ESP_IF_WIFI_STA), &ip)) { + if (esp_netif_get_ip_info(get_esp_interface_netif(ESP_IF_WIFI_STA), &ip)!=ESP_OK) { return IPAddress(); } } else if (WiFi.getMode() == WIFI_OFF) { - if (esp_netif_get_ip_info(get_esp_interface_netif(ESP_IF_ETH), &ip)) { + if (esp_netif_get_ip_info(esp_netif_get_handle_from_ifkey("ETH_DEF"), &ip)!=ESP_OK) { return IPAddress(); } } #endif - return IPAddress(ip.ip.addr); } @@ -230,7 +230,7 @@ bool SSDPClass::begin() { #endif return false; } - + _started = true; return true; } diff --git a/libraries/ESP32SSDP-2.0.2/src/ESP32SSDP.h b/libraries/ESP32SSDP-2.0.3/src/ESP32SSDP.h similarity index 98% rename from libraries/ESP32SSDP-2.0.2/src/ESP32SSDP.h rename to libraries/ESP32SSDP-2.0.3/src/ESP32SSDP.h index 2dca83fa1..90a229633 100644 --- a/libraries/ESP32SSDP-2.0.2/src/ESP32SSDP.h +++ b/libraries/ESP32SSDP-2.0.3/src/ESP32SSDP.h @@ -63,6 +63,7 @@ class SSDPClass { bool begin(); void end(); + bool started() { return _started; } const char* getSchema(); @@ -105,13 +106,13 @@ class SSDPClass { void setUUID(const char* uuid, bool rootonly = true); void setServices(const char* services) { _services = services; } void setIcons(const char* icons) { _icons = icons; } - + IPAddress localIP(); protected: typedef enum { NONE, SEARCH, NOTIFY } ssdp_method_t; void _onPacket(AsyncUDPPacket& packet); void _send(ssdp_method_t method); - IPAddress localIP(); + uint16_t _port; uint32_t _ttl; uint32_t _interval; @@ -122,6 +123,7 @@ class SSDPClass { bool _pending; bool _stmatch; + bool _started; short _delay; unsigned long _process_time; unsigned long _notify_time; diff --git a/libraries/ESP32SSDP-2.0.2/test/platformio.ini b/libraries/ESP32SSDP-2.0.3/test/platformio.ini similarity index 100% rename from libraries/ESP32SSDP-2.0.2/test/platformio.ini rename to libraries/ESP32SSDP-2.0.3/test/platformio.ini diff --git a/libraries/ESP32SSDP-2.0.2/tools/format_sources.py b/libraries/ESP32SSDP-2.0.3/tools/format_sources.py similarity index 100% rename from libraries/ESP32SSDP-2.0.2/tools/format_sources.py rename to libraries/ESP32SSDP-2.0.3/tools/format_sources.py