Skip to content

Commit 1697f68

Browse files
committed
Clean code
1 parent 9f6a7c0 commit 1697f68

File tree

5 files changed

+21
-20
lines changed

5 files changed

+21
-20
lines changed

esp3d/command.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,6 +1132,7 @@ bool COMMAND::execute_command(int cmd,String cmd_params, tpipe output, level_aut
11321132
if (!plain)BRIDGE::print(F("\"}"), output);
11331133
}
11341134
if (!plain)BRIDGE::print(F("]}"), output);
1135+
else BRIDGE::print(F("\n"), output);
11351136
WiFi.scanDelete();
11361137
}
11371138
break;
@@ -1506,8 +1507,8 @@ if (CONFIG::GetFirmwareTarget() == SMOOTHIEWARE) {
15061507
void COMMAND::read_buffer_serial(uint8_t *b, size_t len)
15071508
{
15081509
for (long i = 0; i< len; i++) {
1509-
read_buffer_serial(*b);
1510-
*b++;
1510+
read_buffer_serial(b[i]);
1511+
//*b++;
15111512
}
15121513
}
15131514

esp3d/config.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ HardwareSerial Serial2(2);
4343
uint8_t CONFIG::FirmwareTarget = UNKNOWN_FW;
4444

4545
bool CONFIG::SetFirmwareTarget(uint8_t fw){
46-
if ( fw >= 0 && fw <= MAX_FW_ID) {
46+
if ( fw <= MAX_FW_ID) {
4747
FirmwareTarget = fw;
4848
return true;
4949
} else return false;
@@ -748,7 +748,7 @@ bool CONFIG::isHostnameValid(const char * hostname)
748748
bool CONFIG::isSSIDValid(const char * ssid)
749749
{
750750
//limited size
751-
char c;
751+
//char c;
752752
if (strlen(ssid)>MAX_SSID_LENGTH || strlen(ssid)<MIN_SSID_LENGTH) {
753753
return false;
754754
}
@@ -766,9 +766,12 @@ bool CONFIG::isSSIDValid(const char * ssid)
766766
bool CONFIG::isPasswordValid(const char * password)
767767
{
768768
//limited size
769-
if ((strlen(password)>MAX_PASSWORD_LENGTH)|| (strlen(password)<MIN_PASSWORD_LENGTH)) {
769+
if (strlen(password)>MAX_PASSWORD_LENGTH) {
770770
return false;
771771
}
772+
#if MIN_PASSWORD_LENGTH > 0
773+
if (strlen(password)<MIN_PASSWORD_LENGTH)) return false;
774+
#endif
772775
//no space allowed
773776
for (int i=0; i < strlen(password); i++)
774777
if (password[i] == ' ') {
@@ -1038,7 +1041,7 @@ bool CONFIG::check_update_presence( ){
10381041
count = 0;
10391042
String current_buffer;
10401043
String current_line;
1041-
int pos;
1044+
//int pos;
10421045
int temp_counter = 0;
10431046

10441047
//pickup the list
@@ -1057,7 +1060,7 @@ bool CONFIG::check_update_presence( ){
10571060
while (current_buffer.indexOf("\n") !=-1) {
10581061
//remove the possible "\r"
10591062
current_buffer.replace("\r","");
1060-
pos = current_buffer.indexOf("\n");
1063+
//pos = current_buffer.indexOf("\n");
10611064
//get line
10621065
current_line = current_buffer.substring(0,current_buffer.indexOf("\n"));
10631066
//if line is command ack - just exit so save the time out period
@@ -1070,7 +1073,6 @@ bool CONFIG::check_update_presence( ){
10701073
if (current_line.indexOf("busy:") > -1 || current_line.indexOf("T:") > -1 || current_line.indexOf("B:") > -1) {
10711074
temp_counter++;
10721075
} else {
1073-
10741076
}
10751077
if (temp_counter > 5) {
10761078
break;
@@ -1456,9 +1458,9 @@ void CONFIG::print_config(tpipe output, bool plaintext)
14561458
#endif
14571459
if (!plaintext)BRIDGE::print(F("\"phy_mode\":\""), output);
14581460
else BRIDGE::print(F("Phy Mode: "), output);
1459-
if (PhyMode == WIFI_PHY_MODE_11G )BRIDGE::print(F("11g"), output);
1460-
else if (PhyMode == WIFI_PHY_MODE_11B )BRIDGE::print(F("11b"), output);
1461-
else if (PhyMode == WIFI_PHY_MODE_11N )BRIDGE::print(F("11n"), output);
1461+
if (PhyMode == (WIFI_PHY_MODE_11G))BRIDGE::print(F("11g"), output);
1462+
else if (PhyMode == (WIFI_PHY_MODE_11B))BRIDGE::print(F("11b"), output);
1463+
else if (PhyMode == (WIFI_PHY_MODE_11N))BRIDGE::print(F("11n"), output);
14621464
else BRIDGE::print(F("???"), output);
14631465
if (!plaintext)BRIDGE::print(F("\","), output);
14641466
else BRIDGE::print(F("\n"), output);

esp3d/config.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ const char DEFAULT_USER_LOGIN [] PROGMEM = "user";
299299
const char DEFAULT_TIME_SERVER1 [] PROGMEM = "time.nist.gov";
300300
const char DEFAULT_TIME_SERVER2 [] PROGMEM = "0.pool.ntp.org";
301301
const char DEFAULT_TIME_SERVER3 [] PROGMEM = "1.pool.ntp.org";
302-
#define DEFAULT_TIME_ZONE 1
302+
#define DEFAULT_TIME_ZONE 0
303303
#define DEFAULT_TIME_DST 0
304304
#define DEFAULT_PRIMARY_SD 1
305305
#define DEFAULT_SECONDARY_SD 2
@@ -425,7 +425,6 @@ class CONFIG
425425
static char * mac2str(uint8_t mac [WL_MAC_ADDR_LENGTH]);
426426
static byte split_ip (const char * ptr,byte * part);
427427
static void esp_restart();
428-
static void flashfromSD(const char * Filename, int flashtype);
429428
private:
430429
static uint8_t FirmwareTarget;
431430
};

esp3d/webinterface.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ void handle_web_interface_status()
9393
// static const char NO_TEMP_LINE[] PROGMEM = "\"temperature\":\"0\",\"target\":\"0\",\"active\":\"0\"";
9494
//we do not care if need authentication - just reset counter
9595
web_interface->is_authenticated();
96-
int tagpos,tagpos2;
96+
//int tagpos,tagpos2;
9797
String buffer2send;
9898
String value;
9999
//start JSON answer
@@ -1307,7 +1307,7 @@ void handle_web_command()
13071307
count = 0;
13081308
String current_buffer;
13091309
String current_line;
1310-
int pos;
1310+
//int pos;
13111311
int temp_counter = 0;
13121312
String tmp;
13131313
bool datasent = false;
@@ -1327,7 +1327,7 @@ void handle_web_command()
13271327
while (current_buffer.indexOf("\n") !=-1) {
13281328
//remove the possible "\r"
13291329
current_buffer.replace("\r","");
1330-
pos = current_buffer.indexOf("\n");
1330+
//pos = current_buffer.indexOf("\n");
13311331
//get line
13321332
current_line = current_buffer.substring(0,current_buffer.indexOf("\n"));
13331333
//if line is command ack - just exit so save the time out period
@@ -1430,7 +1430,7 @@ void handle_web_command_silent()
14301430
}
14311431
#endif
14321432
String cmd = "";
1433-
int count ;
1433+
//int count ;
14341434
if (web_interface->web_server.hasArg("plain") || web_interface->web_server.hasArg("commandText")) {
14351435
if (web_interface->web_server.hasArg("plain")) {
14361436
cmd = web_interface->web_server.arg("plain");

esp3d/wificonf.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ bool WIFI_CONFIG::Setup(bool force_ap)
229229
LOG("Disable STA\r\n")
230230
WiFi.enableSTA(false);
231231
delay(100);
232-
LOG("Set phy mode\r\n")
232+
LOG("Set phy mode\r\n")
233233
//setup PHY_MODE
234234
if (!CONFIG::read_byte(EP_AP_PHY_MODE, &bflag )) {
235235
return false;
@@ -350,11 +350,10 @@ LOG("Set phy mode\r\n")
350350
//setup station mode
351351
WiFi.mode(WIFI_STA);
352352
delay(100);
353-
WiFi.begin(sbuf, pwd);
354-
delay(100);
355353
#ifdef ARDUINO_ARCH_ESP8266
356354
WiFi.setPhyMode((WiFiPhyMode_t)bflag);
357355
#endif
356+
WiFi.begin(sbuf, pwd);
358357
delay(100);
359358
byte i=0;
360359
//try to connect

0 commit comments

Comments
 (0)