void WiFiConnector::loop() { if (_initialised == false) { if (millis() % 1000 == 0) { DEBUG_PRINTLN("DEBUG: not initialized."); } return; } if (_wifi->_connected == false) { if (_user_on_connecting) { _user_on_connecting((void*) "CONNECTING..."); DEBUG_PRINTLN("DEBUG: CONNECTING.."); } } }
void WiFiConnector::_connect() { _retries = 0; WiFi.begin(_ssid.c_str(), _password.c_str()); this->counter = 0; while ((WiFi.status() != WL_CONNECTED)) { if (_user_on_connecting != NULL) { static char buf[20]; if (WiFi.status() == WL_CONNECT_FAILED) { strcpy(buf, "(4) WL_CONNECT_FAILED"); } else if (WiFi.status() == WL_NO_SSID_AVAIL) { strcpy(buf, "(0) WL_NO_SSID_AVAIL"); } else if (WiFi.status() == WL_IDLE_STATUS) { strcpy(buf, "(1) WL_IDLE_STATUS"); WIFI_DEBUG_PRINTLN("FORCE ENTER SMART CONFIG"); enter_smartconfig_mode(); } else if (WiFi.status() == WL_DISCONNECTED) { strcpy(buf, "(6) WL_DISCONNECTED"); } else { strcpy(buf, "CODE: !"); itoa(WiFi.status(), buf+6, 10); buf[7] = '\0'; } ++this->counter; _user_on_connecting((void*) buf); } WIFI_DEBUG_PRINT(WiFi.status()); WIFI_DEBUG_PRINTLN(" "); _retries++; this->smartconfig_check(SMART_CONFIG_PIN); yield(); } if (_user_on_connected != NULL) { _user_on_connected("class: WIFI connected."); } }