You can chat about native SDK questions and issues here.

User avatar
By gjump
#58588 I'm trying to implement WPS on ESP8266 SDK 1.5, ESP12E module.
The SDK documentation does't provide a lot of information about how WPS works and the example included does't seems to work as well.

Here's the code I'm runnig:
Code: Select allLOCAL void ICACHE_FLASH_ATTR
user_wps_status_cb(int status)
{
   switch (status) {
      case WPS_CB_ST_SUCCESS:
   console_printf(">>WPS OK!!<<");
         wifi_wps_disable();
         wifi_station_connect();
         wifi_station_dhcpc_start();
         wifi_station_set_auto_connect(1);
         break;
      case WPS_CB_ST_FAILED:
      case WPS_CB_ST_TIMEOUT:
   console_printf(">>WPS NOK!!<<");
         break;
   }
}

void user_init(void)
{
  struct station_config stationConf;
  wifi_set_opmode(STATION_MODE);
  UARTInit(BIT_RATE_115200);
  console_printf("Hello world!\r\n");
  os_printf("SDK version: %s \n", system_get_sdk_version());
  system_set_os_print(1);

  wifi_station_set_auto_connect(0);

  wifi_wps_disable();
  wifi_wps_enable(WPS_TYPE_PBC);
  wifi_set_wps_cb(user_wps_status_cb);
  wifi_wps_start();


}


The terminal output is this:
Hello world!
SDK version: 1.5.0
wifi_wps_enable
mode : sta(18:fe:34:d2:df:a2)
add if0


And that's it, I don't get anything more. The callback function isn't called as well.

Anyone got the WPS feature to work?

Regards,
User avatar
By gjump
#58622 Got some steps further a working code, since I'm not using a push button to start the WPS, I just called the function during the code init, but I found that a delay should be inserted before the WPS functions call. I setup a timer to fire e seconds after the boot and now I got something else, but It now timeouts after it started the negotiations
wifi_wps_enable
wps scan
build public key start
build public key finish
scandone
wps discover [MyWiFi SSID]
scandone
WPS: neg start
scandone
state: 0 -> 2 (b0)
state: 2 -> 0 (2)
>>WPS NOK - timeout!!<<


and sometimes it reaches state 3
wifi_wps_enable
wps scan
build public key start
build public key finish
scandone
wps discover [MyWiFi SSID]]
scandone
WPS: neg start
scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 0 (19)
>>WPS NOK - timeout!!<<
User avatar
By gjump
#58727 Well, I think I've found a "solution", I'm now using a different router and the same code works like a charm, pressed the WPS button and 10 seconds later it connected. Tested both routers with a PC and the WPS function worked, but only one worked with ESP8266, tried different encryption (WPA/WPA2, TKIP and AES) everything works for only one router. So... Maybe is the WPS functions fault.


Sheers!