@@ -20,35 +20,28 @@ Pranav Cherukupalli <cherukupallip@gmail.com>
20
20
Change the definition of the WPS mode
21
21
from WPS_TYPE_PBC to WPS_TYPE_PIN in
22
22
the case that you are using pin type
23
- WPS
23
+ WPS (pin is 00000000)
24
24
*/
25
25
#define ESP_WPS_MODE WPS_TYPE_PBC
26
- #define ESP_MANUFACTURER " ESPRESSIF"
27
- #define ESP_MODEL_NUMBER " ESP32"
28
- #define ESP_MODEL_NAME " ESPRESSIF IOT"
29
- #define ESP_DEVICE_NAME " ESP STATION"
30
-
31
- static esp_wps_config_t config;
32
-
33
- void wpsInitConfig () {
34
- config.wps_type = ESP_WPS_MODE;
35
- strcpy (config.factory_info .manufacturer , ESP_MANUFACTURER);
36
- strcpy (config.factory_info .model_number , ESP_MODEL_NUMBER);
37
- strcpy (config.factory_info .model_name , ESP_MODEL_NAME);
38
- strcpy (config.factory_info .device_name , ESP_DEVICE_NAME);
39
- }
40
26
41
27
void wpsStart () {
42
- if (esp_wifi_wps_enable (&config)) {
43
- Serial.println (" WPS Enable Failed" );
44
- } else if (esp_wifi_wps_start (0 )) {
45
- Serial.println (" WPS Start Failed" );
28
+ esp_wps_config_t config = WPS_CONFIG_INIT_DEFAULT (ESP_WPS_MODE);
29
+ esp_err_t err = esp_wifi_wps_enable (&config);
30
+ if (err != ESP_OK) {
31
+ Serial.printf (" WPS Enable Failed: 0x%x: %s\n " , err, esp_err_to_name (err));
32
+ return ;
33
+ }
34
+
35
+ err = esp_wifi_wps_start (0 );
36
+ if (err != ESP_OK) {
37
+ Serial.printf (" WPS Start Failed: 0x%x: %s\n " , err, esp_err_to_name (err));
46
38
}
47
39
}
48
40
49
41
void wpsStop () {
50
- if (esp_wifi_wps_disable ()) {
51
- Serial.println (" WPS Disable Failed" );
42
+ esp_err_t err = esp_wifi_wps_disable ();
43
+ if (err != ESP_OK) {
44
+ Serial.printf (" WPS Disable Failed: 0x%x: %s\n " , err, esp_err_to_name (err));
52
45
}
53
46
}
54
47
@@ -102,7 +95,6 @@ void setup() {
102
95
WiFi.onEvent (WiFiEvent); // Will call WiFiEvent() from another thread.
103
96
WiFi.mode (WIFI_MODE_STA);
104
97
Serial.println (" Starting WPS" );
105
- wpsInitConfig ();
106
98
wpsStart ();
107
99
}
108
100
0 commit comments