From 5bdf9e093fd898b84c209dd7e143f923c82f3071 Mon Sep 17 00:00:00 2001 From: me-no-dev Date: Tue, 9 Jul 2024 12:51:27 +0300 Subject: [PATCH 1/2] fix(example): Add better WPS logging Provides a better log of what went wrong when using WPS --- libraries/WiFi/examples/WPS/WPS.ino | 36 +++++++++++------------------ 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/libraries/WiFi/examples/WPS/WPS.ino b/libraries/WiFi/examples/WPS/WPS.ino index 194aac0119d..1590af22d88 100644 --- a/libraries/WiFi/examples/WPS/WPS.ino +++ b/libraries/WiFi/examples/WPS/WPS.ino @@ -20,35 +20,28 @@ Pranav Cherukupalli Change the definition of the WPS mode from WPS_TYPE_PBC to WPS_TYPE_PIN in the case that you are using pin type -WPS +WPS (pin is 00000000) */ #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() { - if (esp_wifi_wps_enable(&config)) { - Serial.println("WPS Enable Failed"); - } else if (esp_wifi_wps_start(0)) { - Serial.println("WPS Start Failed"); + esp_wps_config_t config = WPS_CONFIG_INIT_DEFAULT(ESP_WPS_MODE); + esp_err_t err = esp_wifi_wps_enable(&config); + if (err != ESP_OK) { + 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() { - if (esp_wifi_wps_disable()) { - Serial.println("WPS Disable Failed"); + esp_err_t err = esp_wifi_wps_disable(); + 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.mode(WIFI_MODE_STA); Serial.println("Starting WPS"); - wpsInitConfig(); wpsStart(); } From 8f04425d49ae6381732d1a7aa4d8c84a49939006 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Wed, 10 Jul 2024 10:51:36 +0000 Subject: [PATCH 2/2] ci(pre-commit): Apply automatic fixes --- libraries/WiFi/examples/WPS/WPS.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/WiFi/examples/WPS/WPS.ino b/libraries/WiFi/examples/WPS/WPS.ino index 1590af22d88..1a6cc6114ee 100644 --- a/libraries/WiFi/examples/WPS/WPS.ino +++ b/libraries/WiFi/examples/WPS/WPS.ino @@ -22,7 +22,7 @@ from WPS_TYPE_PBC to WPS_TYPE_PIN in the case that you are using pin type WPS (pin is 00000000) */ -#define ESP_WPS_MODE WPS_TYPE_PBC +#define ESP_WPS_MODE WPS_TYPE_PBC void wpsStart() { esp_wps_config_t config = WPS_CONFIG_INIT_DEFAULT(ESP_WPS_MODE);