mirror of
https://git.mirrors.martin98.com/https://github.com/luc-github/ESP3D.git
synced 2025-06-06 02:36:49 +08:00
Add command for hostname
Fix possible buffer overload when using serial command add missing flags in config report
This commit is contained in:
parent
a7059bce51
commit
014839f953
@ -52,8 +52,14 @@ void COMMAND::execute_command(int cmd,String cmd_params)
|
||||
Serial.println("\nOk");
|
||||
}
|
||||
break;
|
||||
case 102:
|
||||
if(!CONFIG::write_string(EP_HOSTNAME,cmd_params.c_str())) {
|
||||
Serial.println("\nError");
|
||||
} else {
|
||||
Serial.println("\nOk");
|
||||
}
|
||||
break;
|
||||
case 103:
|
||||
|
||||
if (cmd_params=="STA") {
|
||||
mode = CLIENT_MODE;
|
||||
} else {
|
||||
@ -90,6 +96,17 @@ void COMMAND::execute_command(int cmd,String cmd_params)
|
||||
Serial.print("\r\n");
|
||||
}
|
||||
break;
|
||||
case 112: {
|
||||
String shost ;
|
||||
if (!CONFIG::read_string(EP_HOSTNAME, shost , MAX_HOSTNAME_LENGTH)) {
|
||||
shost=wifi_config.get_default_hostname();
|
||||
}
|
||||
Serial.print("\n\r");
|
||||
Serial.print(cmd_params);
|
||||
Serial.println(shost);
|
||||
Serial.print("\r\n");
|
||||
}
|
||||
break;
|
||||
case 444:
|
||||
if (cmd_params=="RESET") {
|
||||
CONFIG::reset_config();
|
||||
|
@ -118,9 +118,25 @@ bool CONFIG::write_string(int pos, const __FlashStringHelper *str)
|
||||
bool CONFIG::write_string(int pos, const char * byte_buffer)
|
||||
{
|
||||
int size_buffer;
|
||||
int maxsize = EEPROM_SIZE;
|
||||
size_buffer= strlen(byte_buffer);
|
||||
//check if parameters are acceptable
|
||||
if (size_buffer==0 || pos+size_buffer+1 > EEPROM_SIZE || byte_buffer== NULL) {
|
||||
switch (pos)
|
||||
{
|
||||
case EP_SSID:
|
||||
maxsize = MAX_SSID_LENGTH;
|
||||
break;
|
||||
case EP_PASSWORD:
|
||||
maxsize = MAX_PASSWORD_LENGTH;
|
||||
break;
|
||||
case EP_HOSTNAME:
|
||||
maxsize = MAX_HOSTNAME_LENGTH;
|
||||
break;
|
||||
default:
|
||||
maxsize = EEPROM_SIZE;
|
||||
break;
|
||||
}
|
||||
if (size_buffer==0 || pos+size_buffer+1 > EEPROM_SIZE || size_buffer > maxsize || byte_buffer== NULL) {
|
||||
return false;
|
||||
}
|
||||
//copy the value(s)
|
||||
@ -443,6 +459,12 @@ void CONFIG::print_config()
|
||||
Serial.println(F("Enabled"));
|
||||
#else
|
||||
Serial.println(F("Disabled"));
|
||||
#endif
|
||||
Serial.print(F("NetBios: "));
|
||||
#ifdef NETBIOS_FEATURE
|
||||
Serial.println(F("Enabled"));
|
||||
#else
|
||||
Serial.println(F("Disabled"));
|
||||
#endif
|
||||
Serial.print(F("mDNS: "));
|
||||
#ifdef MDNS_FEATURE
|
||||
@ -480,6 +502,17 @@ void CONFIG::print_config()
|
||||
#else
|
||||
Serial.println(F("???"));
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_ESP3D
|
||||
Serial.print(F("Debug Enabled :"));
|
||||
#ifdef DEBUG_OUTPUT_SPIFFS
|
||||
Serial.println(F("SPIFFS"));
|
||||
#endif
|
||||
#ifdef DEBUG_OUTPUT_SD
|
||||
Serial.println(F("SD"));
|
||||
#endif
|
||||
#ifdef DEBUG_OUTPUT_SERIAL
|
||||
Serial.println(F("serial"));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user