Step 1 - Find the name of the namespace in partition "nvs"
Code: Select all
nvs_iterator_t it = NULL;
esp_err_t err = nvs_entry_find("nvs", NULL, NVS_TYPE_ANY, &it);
while(err == ESP_OK) {
nvs_entry_info_t info;
nvs_entry_info(it, &info); // Can omit error check if parameters are guaranteed to be non-NULL
printf("key '%s', type '%d', namespace '%s' \n", info.key, info.type, info.namespace_name);
err = nvs_entry_next(&it);
}
nvs_release_iterator(it);
- key 'ap.sndchan', type '1', namespace 'nvs.net80211'
key 'opmode', type '1', namespace 'nvs.net80211'
key 'cal_data', type '66', namespace 'phy'
key 'cal_mac', type '66', namespace 'phy'
key 'cal_version', type '4', namespace 'phy'
key 'sta.ssid', type '66', namespace 'nvs.net80211'
key 'sta.pswd', type '66', namespace 'nvs.net80211'
key 'bssid.set', type '1', namespace 'nvs.net80211'
key 'sta.lis_intval', type '2', namespace 'nvs.net80211'
key 'sta.scan_method', type '1', namespace 'nvs.net80211'
key 'sta.sort_method', type '1', namespace 'nvs.net80211'
key 'sta.minrssi', type '17', namespace 'nvs.net80211'
key 'sta.minauth', type '1', namespace 'nvs.net80211'
key 'sta.apsw', type '66', namespace 'nvs.net80211'
key 'sta.pmf_e', type '1', namespace 'nvs.net80211'
key 'sta.pmf_r', type '1', namespace 'nvs.net80211'
key 'sta.rrm_e', type '1', namespace 'nvs.net80211'
key 'sta.btm_e', type '1', namespace 'nvs.net80211'
key 'sta.mbo_e', type '1', namespace 'nvs.net80211'
key 'sta.ft', type '1', namespace 'nvs.net80211'
key 'sta.owe', type '1', namespace 'nvs.net80211'
key 'sta.bss_retry', type '1', namespace 'nvs.net80211'
key 'sta.trans_d', type '1', namespace 'nvs.net80211'
key 'sta.sae_h2e', type '1', namespace 'nvs.net80211'
key 'sta.sae_pk_mode', type '1', namespace 'nvs.net80211'
key 'sta.sae_h2e_id', type '66', namespace 'nvs.net80211'
key 'sta.chan', type '1', namespace 'nvs.net80211'
key 'sta.apinfo', type '66', namespace 'nvs.net80211'
Key "sta.ssid" is associated with namespace name "nvs.net80211". So I used this in function nvs_open:
nvs_handle_t my_handle;
err = nvs_open("nvs.net80211", NVS_READWRITE, &my_handle);
if (err != ESP_OK) {
printf("Error (%s) opening NVS handle!\n", esp_err_to_name(err));
} else {
printf("Done\n");
Step 3:
Try to get the value associated with key "sta.ssid" (type 66, which is associated with NVS_TYPE_BLOB). So I use the nvs_get_blob function:
Code: Select all
printf("Opening Non-Volatile Storage (NVS) handle... ");
nvs_handle_t my_handle;
err = nvs_open("nvs.net80211", NVS_READWRITE, &my_handle);
if (err!= ESP_OK) {
printf("Error (%s) opening NVS handle!\n", esp_err_to_name(err));
} else {
printf("Done\n");
}
size_t size_ssid;
nvs_get_blob(my_handle, "sta.apinfo", NULL, &size_ssid);
char* ssid = malloc(size_ssid);
nvs_get_blob(my_handle, "sta.ssid", ssid, &size_ssid);
printf("Value of ssid: %s\n", ssid);
Now if i run similar code to get the value of sta.pswd, I get the right value. Why is it that sta.ssid gives me a blank result when I'm able to connect to the ssid successfully after a successful wifi provisioning process?Opening Non-Volatile Storage (NVS) handle... Done
Value of ssid: