Code refactoring + indentation

Thanks @treepleks
This commit is contained in:
Luc 2016-01-19 16:37:49 +08:00
parent 326ef1c261
commit 60326f3aba
3 changed files with 18 additions and 6 deletions

View File

@ -64,10 +64,10 @@ class WEBINTERFACE_CLASS
bool AddAuthIP(auth_ip * item); bool AddAuthIP(auth_ip * item);
bool ResetAuthIP(IPAddress ip,const char * sessionID); bool ResetAuthIP(IPAddress ip,const char * sessionID);
uint8_t _upload_status; uint8_t _upload_status;
private: private:
auth_ip * _head; auth_ip * _head;
uint8_t _nb_ip; uint8_t _nb_ip;
}; };
extern WEBINTERFACE_CLASS * web_interface; extern WEBINTERFACE_CLASS * web_interface;

View File

@ -72,6 +72,7 @@ byte WIFI_CONFIG::split_ip (const char * ptr,byte * part)
part[3]=0; part[3]=0;
return 0; return 0;
} }
char pstart [16]; char pstart [16];
char * ptr2; char * ptr2;
strcpy(pstart,ptr); strcpy(pstart,ptr);
@ -122,6 +123,7 @@ void WIFI_CONFIG::Safe_Setup()
dnsServer.stop(); dnsServer.stop();
delay(100); delay(100);
#endif #endif
WiFi.disconnect(); WiFi.disconnect();
//setup Soft AP //setup Soft AP
WiFi.mode(WIFI_AP); WiFi.mode(WIFI_AP);
@ -146,6 +148,7 @@ bool WIFI_CONFIG::Setup()
int wstatus; int wstatus;
IPAddress currentIP; IPAddress currentIP;
byte bflag=0; byte bflag=0;
//set the sleep mode //set the sleep mode
if (!CONFIG::read_byte(EP_SLEEP_MODE, &bflag )) if (!CONFIG::read_byte(EP_SLEEP_MODE, &bflag ))
{ {
@ -208,11 +211,19 @@ bool WIFI_CONFIG::Setup()
while (WiFi.status() != WL_CONNECTED && i<40) { while (WiFi.status() != WL_CONNECTED && i<40) {
switch(WiFi.status()) switch(WiFi.status())
{ {
case 1:Serial.println(F("M117 No SSID found!")); case 1:
Serial.print(FPSTR(M117_));
Serial.println(F("No SSID found!"));
break; break;
case 4:Serial.println(F("M117 No Connection!"));
case 4:
Serial.print(FPSTR(M117_));
Serial.println(F("No Connection!"));
break; break;
default: Serial.println(F("M117 Connecting..."));
default:
Serial.print(FPSTR(M117_));
Serial.println(F("Connecting..."));
break; break;
} }
delay(500); delay(500);
@ -221,6 +232,7 @@ bool WIFI_CONFIG::Setup()
if (WiFi.status() != WL_CONNECTED) return false; if (WiFi.status() != WL_CONNECTED) return false;
WiFi.hostname(hostname); WiFi.hostname(hostname);
} }
//DHCP or Static IP ? //DHCP or Static IP ?
if (!CONFIG::read_byte(EP_IP_MODE, &bflag )) return false; if (!CONFIG::read_byte(EP_IP_MODE, &bflag )) return false;
if (bflag==STATIC_IP_MODE) if (bflag==STATIC_IP_MODE)
@ -242,7 +254,8 @@ bool WIFI_CONFIG::Setup()
#ifdef MDNS_FEATURE #ifdef MDNS_FEATURE
// Set up mDNS responder: // Set up mDNS responder:
if (!mdns.begin(hostname)) { if (!mdns.begin(hostname)) {
Serial.println(F("M117 Error with mDNS!")); Serial.print(FPSTR(M117_));
Serial.println(F("Error with mDNS!"));
delay(1000); delay(1000);
} }
#endif #endif

View File

@ -50,7 +50,6 @@ class WIFI_CONFIG
const char * get_hostname(); const char * get_hostname();
private: private:
char _hostname[33]; char _hostname[33];
}; };
extern WIFI_CONFIG wifi_config; extern WIFI_CONFIG wifi_config;