mirror of
https://git.mirrors.martin98.com/https://github.com/luc-github/ESP3D.git
synced 2025-08-11 17:59:10 +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);
|
||||
else BRIDGE::print(F("\n"), output);
|
||||
WiFi.scanDelete();
|
||||
}
|
||||
break;
|
||||
@ -1506,8 +1507,8 @@ if (CONFIG::GetFirmwareTarget() == SMOOTHIEWARE) {
|
||||
void COMMAND::read_buffer_serial(uint8_t *b, size_t len)
|
||||
{
|
||||
for (long i = 0; i< len; i++) {
|
||||
read_buffer_serial(*b);
|
||||
*b++;
|
||||
read_buffer_serial(b[i]);
|
||||
//*b++;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ HardwareSerial Serial2(2);
|
||||
uint8_t CONFIG::FirmwareTarget = UNKNOWN_FW;
|
||||
|
||||
bool CONFIG::SetFirmwareTarget(uint8_t fw){
|
||||
if ( fw >= 0 && fw <= MAX_FW_ID) {
|
||||
if ( fw <= MAX_FW_ID) {
|
||||
FirmwareTarget = fw;
|
||||
return true;
|
||||
} else return false;
|
||||
@ -748,7 +748,7 @@ bool CONFIG::isHostnameValid(const char * hostname)
|
||||
bool CONFIG::isSSIDValid(const char * ssid)
|
||||
{
|
||||
//limited size
|
||||
char c;
|
||||
//char c;
|
||||
if (strlen(ssid)>MAX_SSID_LENGTH || strlen(ssid)<MIN_SSID_LENGTH) {
|
||||
return false;
|
||||
}
|
||||
@ -766,9 +766,12 @@ bool CONFIG::isSSIDValid(const char * ssid)
|
||||
bool CONFIG::isPasswordValid(const char * password)
|
||||
{
|
||||
//limited size
|
||||
if ((strlen(password)>MAX_PASSWORD_LENGTH)|| (strlen(password)<MIN_PASSWORD_LENGTH)) {
|
||||
if (strlen(password)>MAX_PASSWORD_LENGTH) {
|
||||
return false;
|
||||
}
|
||||
#if MIN_PASSWORD_LENGTH > 0
|
||||
if (strlen(password)<MIN_PASSWORD_LENGTH)) return false;
|
||||
#endif
|
||||
//no space allowed
|
||||
for (int i=0; i < strlen(password); i++)
|
||||
if (password[i] == ' ') {
|
||||
@ -1038,7 +1041,7 @@ bool CONFIG::check_update_presence( ){
|
||||
count = 0;
|
||||
String current_buffer;
|
||||
String current_line;
|
||||
int pos;
|
||||
//int pos;
|
||||
int temp_counter = 0;
|
||||
|
||||
//pickup the list
|
||||
@ -1057,7 +1060,7 @@ bool CONFIG::check_update_presence( ){
|
||||
while (current_buffer.indexOf("\n") !=-1) {
|
||||
//remove the possible "\r"
|
||||
current_buffer.replace("\r","");
|
||||
pos = current_buffer.indexOf("\n");
|
||||
//pos = current_buffer.indexOf("\n");
|
||||
//get line
|
||||
current_line = current_buffer.substring(0,current_buffer.indexOf("\n"));
|
||||
//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) {
|
||||
temp_counter++;
|
||||
} else {
|
||||
|
||||
}
|
||||
if (temp_counter > 5) {
|
||||
break;
|
||||
@ -1456,9 +1458,9 @@ void CONFIG::print_config(tpipe output, bool plaintext)
|
||||
#endif
|
||||
if (!plaintext)BRIDGE::print(F("\"phy_mode\":\""), output);
|
||||
else BRIDGE::print(F("Phy Mode: "), 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_11N )BRIDGE::print(F("11n"), 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_11N))BRIDGE::print(F("11n"), output);
|
||||
else BRIDGE::print(F("???"), output);
|
||||
if (!plaintext)BRIDGE::print(F("\","), 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_SERVER2 [] PROGMEM = "0.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_PRIMARY_SD 1
|
||||
#define DEFAULT_SECONDARY_SD 2
|
||||
@ -425,7 +425,6 @@ public:
|
||||
static char * mac2str(uint8_t mac [WL_MAC_ADDR_LENGTH]);
|
||||
static byte split_ip (const char * ptr,byte * part);
|
||||
static void esp_restart();
|
||||
static void flashfromSD(const char * Filename, int flashtype);
|
||||
private:
|
||||
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\"";
|
||||
//we do not care if need authentication - just reset counter
|
||||
web_interface->is_authenticated();
|
||||
int tagpos,tagpos2;
|
||||
//int tagpos,tagpos2;
|
||||
String buffer2send;
|
||||
String value;
|
||||
//start JSON answer
|
||||
@ -1307,7 +1307,7 @@ void handle_web_command()
|
||||
count = 0;
|
||||
String current_buffer;
|
||||
String current_line;
|
||||
int pos;
|
||||
//int pos;
|
||||
int temp_counter = 0;
|
||||
String tmp;
|
||||
bool datasent = false;
|
||||
@ -1327,7 +1327,7 @@ void handle_web_command()
|
||||
while (current_buffer.indexOf("\n") !=-1) {
|
||||
//remove the possible "\r"
|
||||
current_buffer.replace("\r","");
|
||||
pos = current_buffer.indexOf("\n");
|
||||
//pos = current_buffer.indexOf("\n");
|
||||
//get line
|
||||
current_line = current_buffer.substring(0,current_buffer.indexOf("\n"));
|
||||
//if line is command ack - just exit so save the time out period
|
||||
@ -1430,7 +1430,7 @@ void handle_web_command_silent()
|
||||
}
|
||||
#endif
|
||||
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")) {
|
||||
cmd = web_interface->web_server.arg("plain");
|
||||
|
@ -229,7 +229,7 @@ bool WIFI_CONFIG::Setup(bool force_ap)
|
||||
LOG("Disable STA\r\n")
|
||||
WiFi.enableSTA(false);
|
||||
delay(100);
|
||||
LOG("Set phy mode\r\n")
|
||||
LOG("Set phy mode\r\n")
|
||||
//setup PHY_MODE
|
||||
if (!CONFIG::read_byte(EP_AP_PHY_MODE, &bflag )) {
|
||||
return false;
|
||||
@ -350,11 +350,10 @@ LOG("Set phy mode\r\n")
|
||||
//setup station mode
|
||||
WiFi.mode(WIFI_STA);
|
||||
delay(100);
|
||||
WiFi.begin(sbuf, pwd);
|
||||
delay(100);
|
||||
#ifdef ARDUINO_ARCH_ESP8266
|
||||
WiFi.setPhyMode((WiFiPhyMode_t)bflag);
|
||||
#endif
|
||||
WiFi.begin(sbuf, pwd);
|
||||
delay(100);
|
||||
byte i=0;
|
||||
//try to connect
|
||||
|
Loading…
x
Reference in New Issue
Block a user