-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Description
Hardware:
Board: ESP32 Core Dev Module, Generic Modules, and ESP32-VROOM
Core Installation/update date: I do git update weekly, this update 2/10/18
IDE name: Arduino IDE, 1.8.5
Flash Frequency: 80Mhz
Upload Speed: 921600
Description:
I may have found what is failing, but not sure how to fix this.
Note the print statements between "SmartConfig done." and "Waiting for WiFi".
Verbose Log shows SSID: myplace was passed but appears not to be saving. This is reproduced on 4 different boards.
Reading NVR the password is stored correctly but SSID does not seem to be saved, more so its blank.
This seems to be the fault resulting in connection failure.
Like others; the "Waiting for WiFi" loop never exits with AUTH_FAIL.
Note i added 2 extra log statements to the _smartConfigCallback() for better info
log_d("bssid_set: %d", sta_conf->bssid_set);
log_d("BSSID: %x", sta_conf->bssid);
BASIC demo sketch with just a few prints added (indented)
#include "WiFi.h"
void setup() {
Serial.begin(115200);
WiFi.mode(WIFI_AP_STA);
WiFi.beginSmartConfig();
Serial.println("Waiting for SmartConfig.");
while (!WiFi.smartConfigDone()) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("SmartConfig done.");
Serial.print( "\n\tREADING NVR\n");
Serial.printf( "\tSSID = %s\n" , WiFi.SSID().c_str() );
Serial.printf( "\tPSK = %s\n\n" , WiFi.psk().c_str() );
Serial.println("Waiting for WiFi");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.print("WiFi Connected.\nIP Address: ");
Serial.println(WiFi.localIP());
}
void loop() {
}
=== Verbose Log ==============
ets Jun 8 2016 00:22:57
rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:956
load:0x40078000,len:0
load:0x40078000,len:11904
entry 0x40078a3c
[D][WiFiGeneric.cpp:265] _eventCallback(): Event: 13 - AP_STOP
[D][WiFiGeneric.cpp:265] _eventCallback(): Event: 14 - AP_STACONNECTED
[D][WiFiGeneric.cpp:265] _eventCallback(): Event: 14 - AP_STACONNECTED
Waiting for SmartConfig.
.........[D][WiFiSTA.cpp:621] _smartConfigCallback(): Status: FIND_CHANNEL
...............[D][WiFiSTA.cpp:621] _smartConfigCallback(): Status: GETTING_SSID_PSWD
[D][WiFiSTA.cpp:624] _smartConfigCallback(): Type: ESPTOUCH
.....[D][WiFiSTA.cpp:621] _smartConfigCallback(): Status: LINK
[D][WiFiSTA.cpp:627] _smartConfigCallback(): SSID: myplace
[D][WiFiSTA.cpp:629] _smartConfigCallback(): bssid_set: 131
.
SmartConfig done.
READING NVR
SSID =
PSK = J************e
Waiting for WiFi
....[D][WiFiGeneric.cpp:265] _eventCallback(): Event: 5 - STA_DISCONNECTED
[W][WiFiGeneric.cpp:270] _eventCallback(): Reason: 201 - AUTH_FAIL
..........................
My modified WiFiSTAClass::_smartConfigCallback( )
void WiFiSTAClass::_smartConfigCallback(uint32_t st, void* result) {
smartconfig_status_t status = (smartconfig_status_t) st;
log_d("Status: %s", sc_status_strings[st % 5]);
if (status == SC_STATUS_GETTING_SSID_PSWD) {
smartconfig_type_t * type = (smartconfig_type_t *)result;
log_d("Type: %s", sc_type_strings[*type % 3]);
} else if (status == SC_STATUS_LINK) {
wifi_sta_config_t *sta_conf = reinterpret_cast<wifi_sta_config_t *>(result);
log_d("SSID: %s", (char *)(sta_conf->ssid));
log_d("bssid_set: %d", sta_conf->bssid_set);
log_d("BSSID: %x", sta_conf->bssid);
esp_wifi_set_config(WIFI_IF_STA, (wifi_config_t *)sta_conf);
esp_wifi_connect();
_smartConfigDone = true;
} else if (status == SC_STATUS_LINK_OVER) {
if(result){
ip4_addr_t * ip = (ip4_addr_t *)result;
log_d("Sender IP: " IPSTR, IP2STR(ip));
}
WiFi.stopSmartConfig();
}
}