Fixed the issue where Ethernet static IP cannot be set. (#1080)

This commit is contained in:
E2D 2025-03-12 15:00:40 +08:00 committed by GitHub
parent 750ef32921
commit a57850afd6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 5 deletions

View File

@ -137,10 +137,10 @@ typedef uint ESP3DSettingIndex;
#define ESP_SERIAL_BRIDGE_BAUD 1225 // 4 bytes= int
#define ESP_TIME_ZONE 1229 // 7 bytes 6+1 = string
#define ESP_ETH_STA_IP_VALUE 1237 // 4 bytes xxx.xxx.xxx.xxx
#define ESP_ETH_STA_MASK_VALUE 1240 // 4 bytes xxx.xxx.xxx.xxx
#define ESP_ETH_STA_GATEWAY_VALUE 1244 // 4 bytes xxx.xxx.xxx.xxx
#define ESP_ETH_STA_DNS_VALUE 1248 // 4 bytes xxx.xxx.xxx.xxx
#define ESP_USB_SERIAL_BAUD_RATE 1252 // 4 bytes= int
#define ESP_ETH_STA_MASK_VALUE 1241 // 4 bytes xxx.xxx.xxx.xxx
#define ESP_ETH_STA_GATEWAY_VALUE 1245 // 4 bytes xxx.xxx.xxx.xxx
#define ESP_ETH_STA_DNS_VALUE 1249 // 4 bytes xxx.xxx.xxx.xxx
#define ESP_USB_SERIAL_BAUD_RATE 1253 // 4 bytes= int
// Hidden password
#define HIDDEN_PASSWORD "********"

View File

@ -161,7 +161,14 @@ bool EthConfig::begin(int8_t& espMode) {
}
if (res) {
// Static IP or DHCP client ?
if ((ESP3DSettings::readByte(ESP_ETH_STA_IP_MODE) == DHCP_MODE)) {
if ((ESP3DSettings::readByte(ESP_ETH_STA_IP_MODE) != DHCP_MODE)) {
int32_t IP = ESP3DSettings::read_IP(ESP_ETH_STA_IP_VALUE);
int32_t GW = ESP3DSettings::read_IP(ESP_ETH_STA_GATEWAY_VALUE);
int32_t MK = ESP3DSettings::read_IP(ESP_ETH_STA_MASK_VALUE);
int32_t DNS = ESP3DSettings::read_IP(ESP_ETH_STA_DNS_VALUE);
IPAddress ip(IP), mask(MK), gateway(GW), dns(DNS);
ETH.config(ip, gateway, mask, dns);
} else {
uint64_t start = millis();
String ip = ETH.localIP().toString();
esp3d_log("IP");