this code is part of mass product device.
Chip is Wroom32 with Arduino
I have problem to connect at my home.
SSID and PASSW are correct.
Output Debug is
Where is the problem?STATO WIFI= DISCONNECTED wait=1007
.
.
.
STATO WIFI= DISCONNECTED wait=9998
TIMEOUT!
SYSTEM_EVENT_STA_DISCONNECTED
What do for debug?
Please reply me because is important…
Thanks
Code: Select all
#include <WiFi.h>
#include <WiFiAP.h>
String _SSID_STA ="mySSID";
String _PASSW_STA ="MyPassword";
String _WIFI_MAC ="";
String _WIFI_IP ="";
#define TIMEOUT_WIFI_GOT_IP 10000
#define WIFI_IDLE_STATUS 0
#define WIFI_NO_SSID_AVAIL 1
#define WIFI_SCAN_COMPLETED 2
#define WIFI_CONNECTED 3
#define WIFI_CONNECT_FAILED 4
#define WIFI_CONNECTION_LOST 5
#define WIFI_DISCONNECTED 6
//...............................................................................................
//...............................................................................................
void setup() {
Serial.begin(115200);
delay(1000);
Serial.println("---------------");
Serial.println("---TEST WIFI---");
Serial.println("---------------");
Serial.print("SSID STA="); Serial.println(_SSID_STA);
Serial.print("PASS STA="); Serial.println(_PASSW_STA);
Serial.println("--------------------------");
WiFi.mode(WIFI_MODE_STA);
WiFi.onEvent(WiFiEvent);
WiFi.begin(_SSID_STA.c_str() , _PASSW_STA.c_str());
long timeout_got_ip_station=millis();
while (WiFi.status() != WIFI_CONNECTED) {
if ( (millis() - timeout_got_ip_station) > TIMEOUT_WIFI_GOT_IP )
{
Serial.println("TIMEOUT!");
break;
}
else
{
long wait= millis() - timeout_got_ip_station;
if ( WiFi.status()== WIFI_IDLE_STATUS ) {Serial.print("STATO WIFI= IDLE wait="); Serial.println(wait); }
if ( WiFi.status()== WIFI_NO_SSID_AVAIL ) {Serial.print("STATO WIFI= NO SSID AVAIBLE wait="); Serial.println(wait);}
if ( WiFi.status()== WIFI_SCAN_COMPLETED ) {Serial.print("STATO WIFI= SCAN COMPLETE wait="); Serial.println(wait); }
if ( WiFi.status()== WIFI_CONNECTED ) {Serial.print("STATO WIFI= CONNECTED wait="); Serial.println(wait); }
if ( WiFi.status()== WIFI_CONNECT_FAILED ) {Serial.print("STATO WIFI= CONNECTION FAILED wait="); Serial.println(wait);}
if ( WiFi.status()== WIFI_CONNECTION_LOST ) {Serial.print("STATO WIFI= CONNECTION LOST wait=");Serial.println(wait); }
if ( WiFi.status()== WIFI_DISCONNECTED ) {Serial.print("STATO WIFI= DISCONNECTED wait="); Serial.println(wait);}
}
}
}//setup
//...............................................................................................
//...............................................................................................
//...............................................................................................
//...............................................................................................
void loop() {
}
//...............................................................................................
//...............................................................................................
//...............................................................................................
//WiFi Event
//...............................................................................................
void WiFiEvent(WiFiEvent_t event){
switch(event) {
case SYSTEM_EVENT_STA_GOT_IP:
Serial.println("SYSTEM_EVENT_STA_GOT_IP");
_WIFI_MAC = (String) WiFi.macAddress();
_WIFI_IP = (String) WiFi.localIP().toString();
Serial.print("WIFI MAC= ");Serial.println(_WIFI_MAC);
Serial.print("WIFI IP= ");Serial.println(_WIFI_IP);
break;
case SYSTEM_EVENT_STA_DISCONNECTED:
Serial.println("SYSTEM_EVENT_STA_DISCONNECTED");
break;
case SYSTEM_EVENT_WIFI_READY:
Serial.println("SYSTEM_EVENT_WIFI_READY");
break;
case SYSTEM_EVENT_SCAN_DONE:
Serial.println("SYSTEM_EVENT_SCAN_DONE");
break;
case SYSTEM_EVENT_STA_START:
Serial.println("SYSTEM_EVENT_STA_START");
break;
case SYSTEM_EVENT_STA_STOP:
Serial.println("SYSTEM_EVENT_STA_STOP");
break;
case SYSTEM_EVENT_STA_CONNECTED:
Serial.println("SYSTEM_EVENT_STA_CONNECTED");
break;
case SYSTEM_EVENT_STA_AUTHMODE_CHANGE:
Serial.println("SYSTEM_EVENT_STA_AUTHMODE_CHANGE");
break;
case SYSTEM_EVENT_STA_LOST_IP:
Serial.println("SYSTEM_EVENT_STA_LOST_IP");
break;
case SYSTEM_EVENT_STA_WPS_ER_SUCCESS:
break;
case SYSTEM_EVENT_STA_WPS_ER_FAILED:
break;
case SYSTEM_EVENT_STA_WPS_ER_TIMEOUT:
break;
case SYSTEM_EVENT_STA_WPS_ER_PIN:
break;
case SYSTEM_EVENT_AP_START:
break;
case SYSTEM_EVENT_AP_STOP:
break;
case SYSTEM_EVENT_AP_STADISCONNECTED:
break;
case SYSTEM_EVENT_AP_STACONNECTED:
break;
case SYSTEM_EVENT_AP_STAIPASSIGNED:
break;
case SYSTEM_EVENT_AP_PROBEREQRECVED:
break;
case SYSTEM_EVENT_GOT_IP6:
break;
case SYSTEM_EVENT_ETH_START:
break;
case SYSTEM_EVENT_ETH_STOP:
break;
case SYSTEM_EVENT_ETH_CONNECTED:
break;
case SYSTEM_EVENT_ETH_DISCONNECTED:
break;
case SYSTEM_EVENT_ETH_GOT_IP:
break;
case SYSTEM_EVENT_MAX:
break;
}
}