[GH-ISSUE #924] Add helper getters for esp stored ssid and password #781

Closed
opened 2026-02-28 01:27:01 +03:00 by kerem · 5 comments
Owner

Originally created by @tablatronix on GitHub (Aug 12, 2019).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/924

I already added one for SSID, add one for getting password from stuct.

Originally created by @tablatronix on GitHub (Aug 12, 2019). Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/924 I already added one for SSID, add one for getting password from stuct.
kerem 2026-02-28 01:27:01 +03:00
Author
Owner

@wvsbsp commented on GitHub (Aug 12, 2019):

Thanks a lot!

<!-- gh-comment-id:520547099 --> @wvsbsp commented on GitHub (Aug 12, 2019): Thanks a lot!
Author
Owner

@tablatronix commented on GitHub (Aug 13, 2019):

ESP8266

struct station_config {
    uint8 ssid[32];
    uint8 password[64];
    uint8 bssid_set;    // Note: If bssid_set is 1, station will just connect to the router
                        // with both ssid[] and bssid[] matched. Please check about this.
    uint8 bssid[6];
    wifi_fast_scan_threshold_t threshold;
#ifdef NONOSDK3V0
    bool open_and_wep_mode_disable; // Can connect to open/wep router by default.
#endif
};

bool wifi_station_get_config(struct station_config *config);
bool wifi_station_get_config_default(struct station_config *config); // persistent
<!-- gh-comment-id:520937096 --> @tablatronix commented on GitHub (Aug 13, 2019): ## ESP8266 ```C++ struct station_config { uint8 ssid[32]; uint8 password[64]; uint8 bssid_set; // Note: If bssid_set is 1, station will just connect to the router // with both ssid[] and bssid[] matched. Please check about this. uint8 bssid[6]; wifi_fast_scan_threshold_t threshold; #ifdef NONOSDK3V0 bool open_and_wep_mode_disable; // Can connect to open/wep router by default. #endif }; bool wifi_station_get_config(struct station_config *config); bool wifi_station_get_config_default(struct station_config *config); // persistent ```
Author
Owner

@tablatronix commented on GitHub (Sep 11, 2019):

Adds public methods

    // helper to get saved ssid, if persistent get stored, else get current if connected
    String        getWiFiPass(bool persistent = false);
    // helper to get saved password, if persistent get stored, else get current if connected
    String        getWiFiSSID(bool persistent = false);

adds private methods
String WiFi_psk(bool persistent = false) ;

UNTESTED / Needs testing

ESP8266

    • getWiFiSSID(true)
        • Not connected
        • Connected to default
        • Connected to current
    • getWiFiSSID(false)
        • Not connected
        • Connected to default
        • Connected to current
    • getWiFiPass(true)
        • Not connected
        • Connected to default
        • Connected to current
    • getWiFiPass(false)
        • Not connected
        • Connected to default
        • Connected to current

ESP32

_esp32 is different, it typically only returns info if wifi is init, so some of these will be empty strings or persistent will be ignored

    • getWiFiSSID(true)
        • Not connected
        • Connected to default
        • Connected to current
    • getWiFiSSID(false)
        • Not connected
        • Connected to default
        • Connected to current
    • getWiFipass(true)
        • Not connected
        • Connected to default (same as current)
        • Connected to current
    • getWiFipass(false)
        • Not connected
        • Connected to default (same as current)
        • Connected to current
<!-- gh-comment-id:530474782 --> @tablatronix commented on GitHub (Sep 11, 2019): Adds public methods ```c++ // helper to get saved ssid, if persistent get stored, else get current if connected String getWiFiPass(bool persistent = false); // helper to get saved password, if persistent get stored, else get current if connected String getWiFiSSID(bool persistent = false); ``` adds private methods ` String WiFi_psk(bool persistent = false) ;` **UNTESTED / Needs testing** ## ESP8266 - - [ ] getWiFiSSID(true) - - [ ] Not connected - - [ ] Connected to default - - [ ] Connected to current - - [ ] getWiFiSSID(false) - - [ ] Not connected - - [ ] Connected to default - - [ ] Connected to current - - [ ] getWiFiPass(true) - - [ ] Not connected - - [ ] Connected to default - - [ ] Connected to current - - [ ] getWiFiPass(false) - - [ ] Not connected - - [ ] Connected to default - - [ ] Connected to current ## ESP32 _esp32 is different, it typically only returns info if wifi is init, so some of these will be empty strings or persistent will be ignored - - [ ] getWiFiSSID(true) - - [ ] Not connected - - [ ] Connected to default - - [ ] Connected to current - - [ ] getWiFiSSID(false) - - [ ] Not connected - - [ ] Connected to default - - [ ] Connected to current - - [ ] getWiFipass(true) - - [ ] Not connected - - [x] Connected to default (**same as current**) - - [ ] Connected to current - - [ ] getWiFipass(false) - - [ ] Not connected - - [x] Connected to default (**same as current**) - - [ ] Connected to current
Author
Owner

@wvsbsp commented on GitHub (Sep 22, 2019):

I tried it in two different projects, seems do do the trick.
The only thing is, that i'm not quite shure what the argument true/false is making with the result.

<!-- gh-comment-id:533904727 --> @wvsbsp commented on GitHub (Sep 22, 2019): I tried it in two different projects, seems do do the trick. The only thing is, that i'm not quite shure what the argument true/false is making with the result.
Author
Owner

@tablatronix commented on GitHub (Sep 22, 2019):

One reads the default flash one reads from current config, esp32 might not matter but esp8266 will give you different configs if you disable persistent and connect to a different ssid than the default it has saved, normally you would leave it blank and get default autoconnect settings, but its there for testing as esp32 might not return anything if not connected, but it looks like some stuff was added to help wifi init and check status

<!-- gh-comment-id:533912231 --> @tablatronix commented on GitHub (Sep 22, 2019): One reads the default flash one reads from current config, esp32 might not matter but esp8266 will give you different configs if you disable persistent and connect to a different ssid than the default it has saved, normally you would leave it blank and get default autoconnect settings, but its there for testing as esp32 might not return anything if not connected, but it looks like some stuff was added to help wifi init and check status
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/WiFiManager#781
No description provided.