@@ -2786,9 +2786,16 @@ bool BlinkerMQTT::checkInit()
2786
2786
BLINKER_LOG (BLINKER_F (" IP Address: " ));
2787
2787
BLINKER_LOG (WiFi.localIP ());
2788
2788
_isWiFiInit = true ;
2789
- _connectTime = 0 ;
2789
+ _connectTime = 0 ;
2790
+ char loadssid[BLINKER_SSID_SIZE];
2791
+ char loadpswd[BLINKER_PSWD_SIZE];
2792
+
2793
+ memcpy (loadssid, WiFi.SSID ().c_str (), BLINKER_SSID_SIZE);
2794
+ memcpy (loadpswd, WiFi.psk ().c_str (), BLINKER_PSWD_SIZE);
2790
2795
2791
2796
EEPROM.begin (BLINKER_EEP_SIZE);
2797
+ EEPROM.put (BLINKER_EEP_ADDR_SSID, loadssid);
2798
+ EEPROM.put (BLINKER_EEP_ADDR_PSWD, loadpswd);
2792
2799
EEPROM.put (BLINKER_EEP_ADDR_WLAN_CHECK, ok);
2793
2800
EEPROM.commit ();
2794
2801
EEPROM.end ();
@@ -2855,8 +2862,15 @@ bool BlinkerMQTT::checkInit()
2855
2862
_connectTime = 0 ;
2856
2863
2857
2864
// begin();
2865
+ char loadssid[BLINKER_SSID_SIZE];
2866
+ char loadpswd[BLINKER_PSWD_SIZE];
2867
+
2868
+ memcpy (loadssid, WiFi.SSID ().c_str (), BLINKER_SSID_SIZE);
2869
+ memcpy (loadpswd, WiFi.psk ().c_str (), BLINKER_PSWD_SIZE);
2858
2870
2859
2871
EEPROM.begin (BLINKER_EEP_SIZE);
2872
+ EEPROM.put (BLINKER_EEP_ADDR_SSID, loadssid);
2873
+ EEPROM.put (BLINKER_EEP_ADDR_PSWD, loadpswd);
2860
2874
EEPROM.put (BLINKER_EEP_ADDR_WLAN_CHECK, ok);
2861
2875
EEPROM.commit ();
2862
2876
EEPROM.end ();
@@ -3018,26 +3032,44 @@ bool BlinkerMQTT::autoInit()
3018
3032
3019
3033
if (checkConfig ())
3020
3034
{
3021
- #ifdef ESP8266
3022
- // struct station_config conf;
3023
- softap_config conf;
3024
- // wifi_station_get_config_default(&conf);
3025
- wifi_softap_get_config (&conf);
3026
- WiFi.begin (reinterpret_cast <char *>(conf.ssid ), reinterpret_cast <char *>(conf.password ));
3027
- #elif defined(ESP32)
3028
- wifi_config_t conf;
3029
- esp_wifi_get_config (WIFI_IF_STA, &conf);
3030
- WiFi.begin (reinterpret_cast <char *>(conf.sta .ssid ), reinterpret_cast <char *>(conf.sta .password ));
3031
- #endif
3035
+ // #ifdef ESP8266
3036
+ // // struct station_config conf;
3037
+ // softap_config conf;
3038
+ // // wifi_station_get_config_default(&conf);
3039
+ // wifi_softap_get_config(&conf);
3040
+ // WiFi.begin(reinterpret_cast<char*>(conf.ssid), reinterpret_cast<char*>(conf.password));
3041
+ // #elif defined(ESP32)
3042
+ // wifi_config_t conf;
3043
+ // esp_wifi_get_config(WIFI_IF_STA, &conf);
3044
+ // WiFi.begin(reinterpret_cast<char*>(conf.sta.ssid), reinterpret_cast<char*>(conf.sta.password));
3045
+ // #endif
3032
3046
// WiFi.begin(WiFi.SSID(), WiFi.psk());
3047
+
3048
+ char loadssid[BLINKER_SSID_SIZE];
3049
+ char loadpswd[BLINKER_PSWD_SIZE];
3050
+
3051
+ EEPROM.begin (BLINKER_EEP_SIZE);
3052
+ EEPROM.get (BLINKER_EEP_ADDR_SSID, loadssid);
3053
+ EEPROM.get (BLINKER_EEP_ADDR_PSWD, loadpswd);
3054
+ // char ok[2 + 1];
3055
+ // EEPROM.get(EEP_ADDR_WIFI_CFG + BLINKER_SSID_SIZE + BLINKER_PSWD_SIZE, ok);
3056
+ EEPROM.commit ();
3057
+ EEPROM.end ();
3058
+
3059
+ // strcpy(_ssid, loadssid);
3060
+ // strcpy(_pswd, loadpswd);
3061
+
3062
+ BLINKER_LOG (BLINKER_F (" SSID: " ), loadssid, BLINKER_F (" PASWD: " ), loadpswd);
3033
3063
::delay (500 );
3034
3064
3065
+ WiFi.begin (loadssid, loadpswd);
3066
+
3035
3067
// BLINKER_LOG(BLINKER_F("Waiting for WiFi "),
3036
3068
// BLINKER_WIFI_AUTO_INIT_TIMEOUT / 1000,
3037
3069
// BLINKER_F("s, will enter SMARTCONFIG or "),
3038
3070
// BLINKER_F("APCONFIG while WiFi not connect!"));
3039
3071
3040
- BLINKER_LOG (BLINKER_F (" Connecting to WiFi: " ), WiFi. SSID () );
3072
+ BLINKER_LOG (BLINKER_F (" Connecting to WiFi: " ), loadssid );
3041
3073
3042
3074
#if defined(BLINKER_APCONFIG_V2)
3043
3075
char _auth[BLINKER_AUTHKEY_SIZE];
0 commit comments