mirror of
				https://github.com/esp8266/Arduino.git
				synced 2025-11-03 14:33:37 +03:00 
			
		
		
		
	This example serves a "hello world" on a WLAN and a SoftAP at the same time. The SoftAP allow you to configure WLAN parameters at run time. They are not setup in the sketch but saved on EEPROM. This is a captive portal because through the softAP it will redirect any http request to http://192.168.4.1/, served by the ESP8266 itself
		
			
				
	
	
		
			28 lines
		
	
	
		
			707 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			28 lines
		
	
	
		
			707 B
		
	
	
	
		
			C++
		
	
	
	
	
	
/** Load WLAN credentials from EEPROM */
 | 
						|
void loadCredentials() {
 | 
						|
  EEPROM.begin(512);
 | 
						|
  EEPROM.get(0, ssid);
 | 
						|
  EEPROM.get(0+sizeof(ssid), password);
 | 
						|
  char ok[2+1];
 | 
						|
  EEPROM.get(0+sizeof(ssid)+sizeof(password), ok);
 | 
						|
  EEPROM.end();
 | 
						|
  if (String(ok) != String("OK")) {
 | 
						|
    ssid[0] = 0;
 | 
						|
    password[0] = 0;
 | 
						|
  }
 | 
						|
  Serial.println("Recovered credentials:");
 | 
						|
  Serial.println(ssid);
 | 
						|
  Serial.println(strlen(password)>0?"********":"<no password>");
 | 
						|
}
 | 
						|
 | 
						|
/** Store WLAN credentials to EEPROM */
 | 
						|
void saveCredentials() {
 | 
						|
  EEPROM.begin(512);
 | 
						|
  EEPROM.put(0, ssid);
 | 
						|
  EEPROM.put(0+sizeof(ssid), password);
 | 
						|
  char ok[2+1] = "OK";
 | 
						|
  EEPROM.put(0+sizeof(ssid)+sizeof(password), ok);
 | 
						|
  EEPROM.commit();
 | 
						|
  EEPROM.end();
 | 
						|
}
 |