LOCAL void ICACHE_FLASH_ATTR user_wps_key_short_press(void) { wifi_wps_disable(); wifi_wps_enable(WPS_TYPE_PBC); wifi_set_wps_cb(user_wps_status_cb); wifi_wps_start(); }
bool ESP8266WiFiClass::beginWPSConfig(void) { _useClientMode = true; if(_useApMode) { // turn on AP+STA mode mode(WIFI_AP_STA); } else { // turn on STA mode mode(WIFI_STA); } disconnect(); DEBUGV("wps begin\n"); if(!wifi_wps_disable()) { DEBUGV("wps disable faild\n"); return false; } // so far only WPS_TYPE_PBC is supported (SDK 1.2.0) if(!wifi_wps_enable(WPS_TYPE_PBC)) { DEBUGV("wps enable faild\n"); return false; } if(!wifi_set_wps_cb(&wifi_wps_status_cb)) { DEBUGV("wps cb faild\n"); return false; } if(!wifi_wps_start()) { DEBUGV("wps start faild\n"); return false; } esp_yield(); // will return here when wifi_wps_status_cb fires return true; }
// WPS Status callback // - use callback to signal success // - restart up to 10 times // - slow blink (0,5Hz) if no success -> restart necessary void wpsStatus(int status) { if (status == WPS_CB_ST_SUCCESS) { Serial.println("WPS config successful"); wifi_wps_disable(); WifiStation.connect(); blinkTimer->stop(); if (connectDelegate) connectDelegate(); } else { wifi_wps_disable(); wpsRepeatCounter--; if (wpsRepeatCounter>0) { Serial.print("WPS repeat"); wifi_wps_enable(WPS_TYPE_PBC); wifi_set_wps_cb(&wpsStatus); wpsTimer->initializeMs(15000,TimerDelegate(&wpsStart)).startOnce(); } else { wifi_wps_disable(); blinkTimer->initializeMs(1000, wpsBlinkIndicator).start(); wpsTimer->stop(); } } }
/** * WPS config * so far only WPS_TYPE_PBC is supported (SDK 1.2.0) * @return ok */ bool ESP8266WiFiSTAClass::beginWPSConfig(void) { if(!WiFi.enableSTA(true)) { // enable STA failed return false; } disconnect(); DEBUGV("wps begin\n"); if(!wifi_wps_disable()) { DEBUGV("wps disable failed\n"); return false; } // so far only WPS_TYPE_PBC is supported (SDK 1.2.0) if(!wifi_wps_enable(WPS_TYPE_PBC)) { DEBUGV("wps enable failed\n"); return false; } if(!wifi_set_wps_cb((wps_st_cb_t) &wifi_wps_status_cb)) { DEBUGV("wps cb failed\n"); return false; } if(!wifi_wps_start()) { DEBUGV("wps start failed\n"); return false; } esp_yield(); // will return here when wifi_wps_status_cb fires return true; }
// initialize WPS and start pairing void wpsConnect() { wifi_wps_enable(WPS_TYPE_PBC); wifi_set_wps_cb(&wpsStatus); wpsStart(); }