mirror of
https://git.mirrors.martin98.com/https://github.com/luc-github/ESP3D.git
synced 2025-08-12 20:59:00 +08:00
Clean code
This commit is contained in:
parent
9f6a7c0b91
commit
1697f68f10
@ -1132,6 +1132,7 @@ bool COMMAND::execute_command(int cmd,String cmd_params, tpipe output, level_aut
|
|||||||
if (!plain)BRIDGE::print(F("\"}"), output);
|
if (!plain)BRIDGE::print(F("\"}"), output);
|
||||||
}
|
}
|
||||||
if (!plain)BRIDGE::print(F("]}"), output);
|
if (!plain)BRIDGE::print(F("]}"), output);
|
||||||
|
else BRIDGE::print(F("\n"), output);
|
||||||
WiFi.scanDelete();
|
WiFi.scanDelete();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -1506,8 +1507,8 @@ if (CONFIG::GetFirmwareTarget() == SMOOTHIEWARE) {
|
|||||||
void COMMAND::read_buffer_serial(uint8_t *b, size_t len)
|
void COMMAND::read_buffer_serial(uint8_t *b, size_t len)
|
||||||
{
|
{
|
||||||
for (long i = 0; i< len; i++) {
|
for (long i = 0; i< len; i++) {
|
||||||
read_buffer_serial(*b);
|
read_buffer_serial(b[i]);
|
||||||
*b++;
|
//*b++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ HardwareSerial Serial2(2);
|
|||||||
uint8_t CONFIG::FirmwareTarget = UNKNOWN_FW;
|
uint8_t CONFIG::FirmwareTarget = UNKNOWN_FW;
|
||||||
|
|
||||||
bool CONFIG::SetFirmwareTarget(uint8_t fw){
|
bool CONFIG::SetFirmwareTarget(uint8_t fw){
|
||||||
if ( fw >= 0 && fw <= MAX_FW_ID) {
|
if ( fw <= MAX_FW_ID) {
|
||||||
FirmwareTarget = fw;
|
FirmwareTarget = fw;
|
||||||
return true;
|
return true;
|
||||||
} else return false;
|
} else return false;
|
||||||
@ -748,7 +748,7 @@ bool CONFIG::isHostnameValid(const char * hostname)
|
|||||||
bool CONFIG::isSSIDValid(const char * ssid)
|
bool CONFIG::isSSIDValid(const char * ssid)
|
||||||
{
|
{
|
||||||
//limited size
|
//limited size
|
||||||
char c;
|
//char c;
|
||||||
if (strlen(ssid)>MAX_SSID_LENGTH || strlen(ssid)<MIN_SSID_LENGTH) {
|
if (strlen(ssid)>MAX_SSID_LENGTH || strlen(ssid)<MIN_SSID_LENGTH) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -766,9 +766,12 @@ bool CONFIG::isSSIDValid(const char * ssid)
|
|||||||
bool CONFIG::isPasswordValid(const char * password)
|
bool CONFIG::isPasswordValid(const char * password)
|
||||||
{
|
{
|
||||||
//limited size
|
//limited size
|
||||||
if ((strlen(password)>MAX_PASSWORD_LENGTH)|| (strlen(password)<MIN_PASSWORD_LENGTH)) {
|
if (strlen(password)>MAX_PASSWORD_LENGTH) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
#if MIN_PASSWORD_LENGTH > 0
|
||||||
|
if (strlen(password)<MIN_PASSWORD_LENGTH)) return false;
|
||||||
|
#endif
|
||||||
//no space allowed
|
//no space allowed
|
||||||
for (int i=0; i < strlen(password); i++)
|
for (int i=0; i < strlen(password); i++)
|
||||||
if (password[i] == ' ') {
|
if (password[i] == ' ') {
|
||||||
@ -1038,7 +1041,7 @@ bool CONFIG::check_update_presence( ){
|
|||||||
count = 0;
|
count = 0;
|
||||||
String current_buffer;
|
String current_buffer;
|
||||||
String current_line;
|
String current_line;
|
||||||
int pos;
|
//int pos;
|
||||||
int temp_counter = 0;
|
int temp_counter = 0;
|
||||||
|
|
||||||
//pickup the list
|
//pickup the list
|
||||||
@ -1057,7 +1060,7 @@ bool CONFIG::check_update_presence( ){
|
|||||||
while (current_buffer.indexOf("\n") !=-1) {
|
while (current_buffer.indexOf("\n") !=-1) {
|
||||||
//remove the possible "\r"
|
//remove the possible "\r"
|
||||||
current_buffer.replace("\r","");
|
current_buffer.replace("\r","");
|
||||||
pos = current_buffer.indexOf("\n");
|
//pos = current_buffer.indexOf("\n");
|
||||||
//get line
|
//get line
|
||||||
current_line = current_buffer.substring(0,current_buffer.indexOf("\n"));
|
current_line = current_buffer.substring(0,current_buffer.indexOf("\n"));
|
||||||
//if line is command ack - just exit so save the time out period
|
//if line is command ack - just exit so save the time out period
|
||||||
@ -1070,7 +1073,6 @@ bool CONFIG::check_update_presence( ){
|
|||||||
if (current_line.indexOf("busy:") > -1 || current_line.indexOf("T:") > -1 || current_line.indexOf("B:") > -1) {
|
if (current_line.indexOf("busy:") > -1 || current_line.indexOf("T:") > -1 || current_line.indexOf("B:") > -1) {
|
||||||
temp_counter++;
|
temp_counter++;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
}
|
}
|
||||||
if (temp_counter > 5) {
|
if (temp_counter > 5) {
|
||||||
break;
|
break;
|
||||||
@ -1456,9 +1458,9 @@ void CONFIG::print_config(tpipe output, bool plaintext)
|
|||||||
#endif
|
#endif
|
||||||
if (!plaintext)BRIDGE::print(F("\"phy_mode\":\""), output);
|
if (!plaintext)BRIDGE::print(F("\"phy_mode\":\""), output);
|
||||||
else BRIDGE::print(F("Phy Mode: "), output);
|
else BRIDGE::print(F("Phy Mode: "), output);
|
||||||
if (PhyMode == WIFI_PHY_MODE_11G )BRIDGE::print(F("11g"), output);
|
if (PhyMode == (WIFI_PHY_MODE_11G))BRIDGE::print(F("11g"), output);
|
||||||
else if (PhyMode == WIFI_PHY_MODE_11B )BRIDGE::print(F("11b"), output);
|
else if (PhyMode == (WIFI_PHY_MODE_11B))BRIDGE::print(F("11b"), output);
|
||||||
else if (PhyMode == WIFI_PHY_MODE_11N )BRIDGE::print(F("11n"), output);
|
else if (PhyMode == (WIFI_PHY_MODE_11N))BRIDGE::print(F("11n"), output);
|
||||||
else BRIDGE::print(F("???"), output);
|
else BRIDGE::print(F("???"), output);
|
||||||
if (!plaintext)BRIDGE::print(F("\","), output);
|
if (!plaintext)BRIDGE::print(F("\","), output);
|
||||||
else BRIDGE::print(F("\n"), output);
|
else BRIDGE::print(F("\n"), output);
|
||||||
|
@ -299,7 +299,7 @@ const char DEFAULT_USER_LOGIN [] PROGMEM = "user";
|
|||||||
const char DEFAULT_TIME_SERVER1 [] PROGMEM = "time.nist.gov";
|
const char DEFAULT_TIME_SERVER1 [] PROGMEM = "time.nist.gov";
|
||||||
const char DEFAULT_TIME_SERVER2 [] PROGMEM = "0.pool.ntp.org";
|
const char DEFAULT_TIME_SERVER2 [] PROGMEM = "0.pool.ntp.org";
|
||||||
const char DEFAULT_TIME_SERVER3 [] PROGMEM = "1.pool.ntp.org";
|
const char DEFAULT_TIME_SERVER3 [] PROGMEM = "1.pool.ntp.org";
|
||||||
#define DEFAULT_TIME_ZONE 1
|
#define DEFAULT_TIME_ZONE 0
|
||||||
#define DEFAULT_TIME_DST 0
|
#define DEFAULT_TIME_DST 0
|
||||||
#define DEFAULT_PRIMARY_SD 1
|
#define DEFAULT_PRIMARY_SD 1
|
||||||
#define DEFAULT_SECONDARY_SD 2
|
#define DEFAULT_SECONDARY_SD 2
|
||||||
@ -425,7 +425,6 @@ public:
|
|||||||
static char * mac2str(uint8_t mac [WL_MAC_ADDR_LENGTH]);
|
static char * mac2str(uint8_t mac [WL_MAC_ADDR_LENGTH]);
|
||||||
static byte split_ip (const char * ptr,byte * part);
|
static byte split_ip (const char * ptr,byte * part);
|
||||||
static void esp_restart();
|
static void esp_restart();
|
||||||
static void flashfromSD(const char * Filename, int flashtype);
|
|
||||||
private:
|
private:
|
||||||
static uint8_t FirmwareTarget;
|
static uint8_t FirmwareTarget;
|
||||||
};
|
};
|
||||||
|
@ -93,7 +93,7 @@ void handle_web_interface_status()
|
|||||||
// static const char NO_TEMP_LINE[] PROGMEM = "\"temperature\":\"0\",\"target\":\"0\",\"active\":\"0\"";
|
// static const char NO_TEMP_LINE[] PROGMEM = "\"temperature\":\"0\",\"target\":\"0\",\"active\":\"0\"";
|
||||||
//we do not care if need authentication - just reset counter
|
//we do not care if need authentication - just reset counter
|
||||||
web_interface->is_authenticated();
|
web_interface->is_authenticated();
|
||||||
int tagpos,tagpos2;
|
//int tagpos,tagpos2;
|
||||||
String buffer2send;
|
String buffer2send;
|
||||||
String value;
|
String value;
|
||||||
//start JSON answer
|
//start JSON answer
|
||||||
@ -1307,7 +1307,7 @@ void handle_web_command()
|
|||||||
count = 0;
|
count = 0;
|
||||||
String current_buffer;
|
String current_buffer;
|
||||||
String current_line;
|
String current_line;
|
||||||
int pos;
|
//int pos;
|
||||||
int temp_counter = 0;
|
int temp_counter = 0;
|
||||||
String tmp;
|
String tmp;
|
||||||
bool datasent = false;
|
bool datasent = false;
|
||||||
@ -1327,7 +1327,7 @@ void handle_web_command()
|
|||||||
while (current_buffer.indexOf("\n") !=-1) {
|
while (current_buffer.indexOf("\n") !=-1) {
|
||||||
//remove the possible "\r"
|
//remove the possible "\r"
|
||||||
current_buffer.replace("\r","");
|
current_buffer.replace("\r","");
|
||||||
pos = current_buffer.indexOf("\n");
|
//pos = current_buffer.indexOf("\n");
|
||||||
//get line
|
//get line
|
||||||
current_line = current_buffer.substring(0,current_buffer.indexOf("\n"));
|
current_line = current_buffer.substring(0,current_buffer.indexOf("\n"));
|
||||||
//if line is command ack - just exit so save the time out period
|
//if line is command ack - just exit so save the time out period
|
||||||
@ -1430,7 +1430,7 @@ void handle_web_command_silent()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
String cmd = "";
|
String cmd = "";
|
||||||
int count ;
|
//int count ;
|
||||||
if (web_interface->web_server.hasArg("plain") || web_interface->web_server.hasArg("commandText")) {
|
if (web_interface->web_server.hasArg("plain") || web_interface->web_server.hasArg("commandText")) {
|
||||||
if (web_interface->web_server.hasArg("plain")) {
|
if (web_interface->web_server.hasArg("plain")) {
|
||||||
cmd = web_interface->web_server.arg("plain");
|
cmd = web_interface->web_server.arg("plain");
|
||||||
|
@ -350,11 +350,10 @@ LOG("Set phy mode\r\n")
|
|||||||
//setup station mode
|
//setup station mode
|
||||||
WiFi.mode(WIFI_STA);
|
WiFi.mode(WIFI_STA);
|
||||||
delay(100);
|
delay(100);
|
||||||
WiFi.begin(sbuf, pwd);
|
|
||||||
delay(100);
|
|
||||||
#ifdef ARDUINO_ARCH_ESP8266
|
#ifdef ARDUINO_ARCH_ESP8266
|
||||||
WiFi.setPhyMode((WiFiPhyMode_t)bflag);
|
WiFi.setPhyMode((WiFiPhyMode_t)bflag);
|
||||||
#endif
|
#endif
|
||||||
|
WiFi.begin(sbuf, pwd);
|
||||||
delay(100);
|
delay(100);
|
||||||
byte i=0;
|
byte i=0;
|
||||||
//try to connect
|
//try to connect
|
||||||
|
Loading…
x
Reference in New Issue
Block a user