Hi, I’m trying to develop a single application to scan wifi access points.
I used the example program as start point. And it worked fine in my PlatformIO in Mac (High Sierra).
I’ve tried to use the same project in a Windows machine. It build fine, but when I try to run, I got this error:
ESP_ERROR_CHECK failed: esp_err_t 0x1110 (ESP_ERR_NVS_NEW_VERSION_FOUND) at 0x400d0a36
file: "src/main.c" line 16
func: wifiInit
expression: nvs_flash_init()
Backtrace: 0x4008d567:0x3ffcbc40 0x4008dad0:0x3ffcbc60 0x400d0a36:0x3ffcbc80 0x400d0ad2:0x3ffcbd40 0x400d0c78:0x3ffcc400
I had already deleted the folder: %HOMEPATH%\.platformio\packages\framework-espidf
before build to download a new set of files.
But without success.
See below my entire code and the platformio.ini file:
#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_event_loop.h"
#include "esp_wifi.h"
#include "esp_log.h"
#include "nvs_flash.h"
#define MAX_APs 20
static esp_err_t event_handler(void * ctx, system_event_t *event) {
return ESP_OK;
}
void wifiInit() {
ESP_ERROR_CHECK(nvs_flash_init());
tcpip_adapter_init();
ESP_ERROR_CHECK(esp_event_loop_init(event_handler, NULL));
wifi_init_config_t wifi_config = WIFI_INIT_CONFIG_DEFAULT();
ESP_ERROR_CHECK(esp_wifi_init(&wifi_config));
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA));
ESP_ERROR_CHECK(esp_wifi_start());
}
static char *getAuthModeName(wifi_auth_mode_t auth_mode)
{
char *names[] = {"OPEN", "WEP", "WPA PSK", "WPA2 PSK", "WPA WPA2 PSK", "MAX"};
return names[auth_mode];
}
void app_main()
{
wifiInit();
wifi_scan_config_t scan_config = {
.ssid = 0,
.bssid = 0,
.channel = 0,
.show_hidden = true
};
ESP_ERROR_CHECK(esp_wifi_scan_start(&scan_config, true));
wifi_ap_record_t wifi_records[MAX_APs];
uint16_t maxRecods = MAX_APs;
ESP_ERROR_CHECK(esp_wifi_scan_get_ap_records(&maxRecods, wifi_records));
printf("Found %d access points:\n", maxRecods);
printf("\n");
printf(" SSID | Channel | RSSI | Auth Mode | MAC ADDRESS |\n");
printf("----------------------------------------------------------------|-------------------|\n");
for (int i = 0; i < maxRecods; i++)
printf("%32s | %7d | %4d | %12s| %02x:%02x:%02x:%02x:%02x:%02x\n", (char *)wifi_records[i].ssid, wifi_records[i].primary, wifi_records[i].rssi, getAuthModeName(wifi_records[i].authmode),
wifi_records[i].bssid[0], wifi_records[i].bssid[1], wifi_records[i].bssid[2], wifi_records[i].bssid[3], wifi_records[i].bssid[4], wifi_records[i].bssid[5]);
printf("-------------------------------------------------------------------------------------\n");
}
platformio.ini
[env:wemosbat]
platform = espressif32
board = wemosbat
framework = espidf
monitor_speed = 115200