mirror of
https://git.mirrors.martin98.com/https://github.com/luc-github/ESP3D.git
synced 2025-08-20 14:39:15 +08:00
Fix DNS missing setting in static mode
This commit is contained in:
parent
5e4f438745
commit
d56a936543
@ -11,8 +11,8 @@ Note:
|
||||
* Set/Get STA IP mode (DHCP/STATIC)
|
||||
[ESP102]<mode>pwd=<admin password>
|
||||
|
||||
* Set/Get STA IP/Mask/GW
|
||||
[ESP103]IP=<IP> MSK=<IP> GW=<IP> pwd=<admin password>
|
||||
* Set/Get STA IP/Mask/GW/DNS
|
||||
[ESP103]IP=<IP> MSK=<IP> GW=<IP> DNS=<IP> pwd=<admin password>
|
||||
|
||||
* Set/Get AP SSID
|
||||
[ESP105]<SSID>pwd=<admin password>
|
||||
|
@ -23,6 +23,9 @@ STA_GW = 192.168.0.1
|
||||
#STA static mask
|
||||
STA_MSK = 255.255.255.0
|
||||
|
||||
#STA static dns
|
||||
STA_DNS = 192.168.0.1
|
||||
|
||||
#AP SSID string of 32 chars max
|
||||
AP_SSID = myssid
|
||||
|
||||
|
@ -53,6 +53,8 @@ bool Commands::ESP103(const char* cmd_params, level_authenticate_type auth_type,
|
||||
res += Settings_ESP3D::read_IP_String(ESP_STA_GATEWAY_VALUE);
|
||||
res += ", MSK:";
|
||||
res += Settings_ESP3D::read_IP_String(ESP_STA_MASK_VALUE);
|
||||
res += ", DNS:";
|
||||
res += Settings_ESP3D::read_IP_String(ESP_STA_DNS_VALUE);
|
||||
output->printMSG (res.c_str());
|
||||
} else { //set
|
||||
#ifdef AUTHENTICATION_FEATURE
|
||||
@ -65,6 +67,7 @@ bool Commands::ESP103(const char* cmd_params, level_authenticate_type auth_type,
|
||||
String IP = get_param (cmd_params, "IP=");
|
||||
String GW = get_param (cmd_params, "GW=");
|
||||
String MSK = get_param (cmd_params, "MSK=");
|
||||
String DNS = get_param (cmd_params, "DNS=");
|
||||
if ( !NetConfig::isValidIP(IP.c_str())) {
|
||||
output->printERROR ("Incorrect IP!");
|
||||
return false;
|
||||
@ -77,8 +80,13 @@ bool Commands::ESP103(const char* cmd_params, level_authenticate_type auth_type,
|
||||
output->printERROR ("Incorrect mask!");
|
||||
return false;
|
||||
}
|
||||
if ( !NetConfig::isValidIP(DNS.c_str())) {
|
||||
output->printERROR ("Incorrect dns!");
|
||||
return false;
|
||||
}
|
||||
if ( !Settings_ESP3D::write_IP_String(ESP_STA_IP_VALUE, IP.c_str()) ||
|
||||
!Settings_ESP3D::write_IP_String(ESP_STA_GATEWAY_VALUE, GW.c_str()) ||
|
||||
!Settings_ESP3D::write_IP_String(ESP_STA_DNS_VALUE, DNS.c_str()) ||
|
||||
!Settings_ESP3D::write_IP_String(ESP_STA_MASK_VALUE, MSK.c_str())) {
|
||||
output->printERROR ("Set failed!");
|
||||
response = false;
|
||||
|
@ -123,6 +123,13 @@ bool Commands::ESP400(const char* cmd_params, level_authenticate_type auth_type,
|
||||
output->print ("\",\"T\":\"A\",\"V\":\"");
|
||||
output->print (Settings_ESP3D::read_IP_String(ESP_STA_MASK_VALUE));
|
||||
output->print ("\",\"H\":\"msk\"}");
|
||||
|
||||
//STA static DNS
|
||||
output->print (",{\"F\":\"network/sta\",\"P\":\"");
|
||||
output->print (ESP_STA_DNS_VALUE);
|
||||
output->print ("\",\"T\":\"A\",\"V\":\"");
|
||||
output->print (Settings_ESP3D::read_IP_String(ESP_STA_DNS_VALUE));
|
||||
output->print ("\",\"H\":\"dns\"}");
|
||||
#endif //WIFI_FEATURE || ETH_FEATURE
|
||||
#if defined(WIFI_FEATURE)
|
||||
//AP SSID network/ap
|
||||
|
@ -168,6 +168,7 @@ const char DEFAULT_SETTINGS_VERSION [] = "ESP3D";
|
||||
const uint8_t DEFAULT_IP_VALUE[] = {192, 168, 0, 1};
|
||||
const uint8_t DEFAULT_MASK_VALUE[] = {255, 255, 255, 0};
|
||||
#define DEFAULT_GATEWAY_VALUE DEFAULT_IP_VALUE
|
||||
#define DEFAULT_DNS_VALUE DEFAULT_GATEWAY_VALUE
|
||||
const uint8_t DEFAULT_ADDRESS_VALUE[] = {0, 0, 0, 0};
|
||||
#endif //WIFI_FEATURE || ETH_FEATURE
|
||||
|
||||
@ -393,6 +394,9 @@ uint32_t Settings_ESP3D::get_default_int32_value(int pos)
|
||||
case ESP_STA_GATEWAY_VALUE:
|
||||
res = IPAddress(DEFAULT_GATEWAY_VALUE);
|
||||
break;
|
||||
case ESP_STA_DNS_VALUE:
|
||||
res = IPAddress(DEFAULT_DNS_VALUE);
|
||||
break;
|
||||
#endif //WIFI_FEATURE || ETH_FEATURE
|
||||
#ifdef FTP_FEATURE
|
||||
case ESP_FTP_CTRL_PORT:
|
||||
@ -1064,6 +1068,8 @@ bool Settings_ESP3D::reset(bool networkonly)
|
||||
Settings_ESP3D::write_IP(ESP_STA_GATEWAY_VALUE, Settings_ESP3D::get_default_IP_value(ESP_STA_GATEWAY_VALUE));
|
||||
//STA static Mask
|
||||
Settings_ESP3D::write_IP(ESP_STA_MASK_VALUE, Settings_ESP3D::get_default_IP_value(ESP_STA_MASK_VALUE));
|
||||
//STA static DNS
|
||||
Settings_ESP3D::write_IP(ESP_STA_DNS_VALUE, Settings_ESP3D::get_default_IP_value(ESP_STA_DNS_VALUE));
|
||||
#endif //WIFI_FEATURE || ETH_FEATURE
|
||||
if (networkonly) {
|
||||
return true;
|
||||
|
@ -104,6 +104,8 @@
|
||||
#define ESP_VERBOSE_BOOT 1023 //1 byte = flag
|
||||
#define ESP_WEBDAV_ON 1024 //1 byte = flag
|
||||
#define ESP_WEBDAV_PORT 1025 //4 bytes= int
|
||||
#define ESP_STA_DNS_VALUE 1029 //4 bytes= int
|
||||
|
||||
|
||||
//Hidden password
|
||||
#define HIDDEN_PASSWORD "********"
|
||||
|
@ -22,7 +22,7 @@
|
||||
#define _VERSION_ESP3D_H
|
||||
|
||||
//version and sources location
|
||||
#define FW_VERSION "3.0.0.a88"
|
||||
#define FW_VERSION "3.0.0.a89"
|
||||
#define REPOSITORY "https://github.com/luc-github/ESP3D/tree/3.0"
|
||||
|
||||
#endif //_VERSION_ESP3D_H
|
||||
|
@ -40,8 +40,9 @@ bool EthConfig::StartSTA()
|
||||
int32_t IP = Settings_ESP3D::read_IP(ESP_STA_IP_VALUE);
|
||||
int32_t GW = Settings_ESP3D::read_IP(ESP_STA_GATEWAY_VALUE);
|
||||
int32_t MK = Settings_ESP3D::read_IP(ESP_STA_MASK_VALUE);
|
||||
IPAddress ip(IP), mask(MK), gateway(GW);
|
||||
res = ETH.config(ip, gateway,mask);
|
||||
int32_t DNS = Settings_ESP3D::read_IP(ESP_STA_DNS_VALUE);
|
||||
IPAddress ip(IP), mask(MK), gateway(GW), dns(DNS);
|
||||
res = ETH.config(ip, gateway,mask,dns);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
@ -81,12 +81,14 @@ const uint16_t ServstringKeysPos[] = {
|
||||
const char * IPKeysVal[] = {"STA_IP",
|
||||
"STA_GW",
|
||||
"STA_MSK",
|
||||
"STA_DNS",
|
||||
"AP_IP"
|
||||
} ;
|
||||
|
||||
const uint16_t IPKeysPos[] = {ESP_STA_IP_VALUE,
|
||||
ESP_STA_MASK_VALUE,
|
||||
ESP_STA_GATEWAY_VALUE,
|
||||
ESP_STA_DNS_VALUE
|
||||
ESP_AP_IP_VALUE
|
||||
} ;
|
||||
|
||||
|
@ -194,8 +194,9 @@ bool WiFiConfig::StartSTA()
|
||||
int32_t IP = Settings_ESP3D::read_IP(ESP_STA_IP_VALUE);
|
||||
int32_t GW = Settings_ESP3D::read_IP(ESP_STA_GATEWAY_VALUE);
|
||||
int32_t MK = Settings_ESP3D::read_IP(ESP_STA_MASK_VALUE);
|
||||
IPAddress ip(IP), mask(MK), gateway(GW);
|
||||
WiFi.config(ip, gateway,mask);
|
||||
int32_t DNS = Settings_ESP3D::read_IP(ESP_STA_DNS_VALUE);
|
||||
IPAddress ip(IP), mask(MK), gateway(GW), dns(DNS);
|
||||
WiFi.config(ip, gateway,mask,dns);
|
||||
}
|
||||
ESP3DOutput output(ESP_ALL_CLIENTS);
|
||||
if (Settings_ESP3D::isVerboseBoot()) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user