fix(example): Add better WPS logging (#9999)
* fix(example): Add better WPS logging Provides a better log of what went wrong when using WPS * ci(pre-commit): Apply automatic fixes --------- Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
This commit is contained in:
parent
0ab2c58b6c
commit
874e2a1a1b
1 changed files with 15 additions and 23 deletions
|
|
@ -20,35 +20,28 @@ Pranav Cherukupalli <cherukupallip@gmail.com>
|
||||||
Change the definition of the WPS mode
|
Change the definition of the WPS mode
|
||||||
from WPS_TYPE_PBC to WPS_TYPE_PIN in
|
from WPS_TYPE_PBC to WPS_TYPE_PIN in
|
||||||
the case that you are using pin type
|
the case that you are using pin type
|
||||||
WPS
|
WPS (pin is 00000000)
|
||||||
*/
|
*/
|
||||||
#define ESP_WPS_MODE WPS_TYPE_PBC
|
#define ESP_WPS_MODE WPS_TYPE_PBC
|
||||||
#define ESP_MANUFACTURER "ESPRESSIF"
|
|
||||||
#define ESP_MODEL_NUMBER "ESP32"
|
|
||||||
#define ESP_MODEL_NAME "ESPRESSIF IOT"
|
|
||||||
#define ESP_DEVICE_NAME "ESP STATION"
|
|
||||||
|
|
||||||
static esp_wps_config_t config;
|
|
||||||
|
|
||||||
void wpsInitConfig() {
|
|
||||||
config.wps_type = ESP_WPS_MODE;
|
|
||||||
strcpy(config.factory_info.manufacturer, ESP_MANUFACTURER);
|
|
||||||
strcpy(config.factory_info.model_number, ESP_MODEL_NUMBER);
|
|
||||||
strcpy(config.factory_info.model_name, ESP_MODEL_NAME);
|
|
||||||
strcpy(config.factory_info.device_name, ESP_DEVICE_NAME);
|
|
||||||
}
|
|
||||||
|
|
||||||
void wpsStart() {
|
void wpsStart() {
|
||||||
if (esp_wifi_wps_enable(&config)) {
|
esp_wps_config_t config = WPS_CONFIG_INIT_DEFAULT(ESP_WPS_MODE);
|
||||||
Serial.println("WPS Enable Failed");
|
esp_err_t err = esp_wifi_wps_enable(&config);
|
||||||
} else if (esp_wifi_wps_start(0)) {
|
if (err != ESP_OK) {
|
||||||
Serial.println("WPS Start Failed");
|
Serial.printf("WPS Enable Failed: 0x%x: %s\n", err, esp_err_to_name(err));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
err = esp_wifi_wps_start(0);
|
||||||
|
if (err != ESP_OK) {
|
||||||
|
Serial.printf("WPS Start Failed: 0x%x: %s\n", err, esp_err_to_name(err));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wpsStop() {
|
void wpsStop() {
|
||||||
if (esp_wifi_wps_disable()) {
|
esp_err_t err = esp_wifi_wps_disable();
|
||||||
Serial.println("WPS Disable Failed");
|
if (err != ESP_OK) {
|
||||||
|
Serial.printf("WPS Disable Failed: 0x%x: %s\n", err, esp_err_to_name(err));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -102,7 +95,6 @@ void setup() {
|
||||||
WiFi.onEvent(WiFiEvent); // Will call WiFiEvent() from another thread.
|
WiFi.onEvent(WiFiEvent); // Will call WiFiEvent() from another thread.
|
||||||
WiFi.mode(WIFI_MODE_STA);
|
WiFi.mode(WIFI_MODE_STA);
|
||||||
Serial.println("Starting WPS");
|
Serial.println("Starting WPS");
|
||||||
wpsInitConfig();
|
|
||||||
wpsStart();
|
wpsStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue