ESP8266 Developer Zone The Official ESP8266 Forum 2017-09-23T17:29:20+08:00 https://bbs.espressif.com:443/feed.php?f=7&t=3129 2017-09-23T17:29:20+08:00 2017-09-23T17:29:20+08:00 https://bbs.espressif.com:443/viewtopic.php?t=3129&p=15952#p15952 <![CDATA[Re: WPS (Wi-Fi Protected Setup) in SDK]]> Statistics: Posted by dalbert — Sat Sep 23, 2017 5:29 pm


]]>
2017-07-22T20:58:47+08:00 2017-07-22T20:58:47+08:00 https://bbs.espressif.com:443/viewtopic.php?t=3129&p=14757#p14757 <![CDATA[Re: WPS (Wi-Fi Protected Setup) in SDK]]> Access Points tested and failing with ESP8266 WPS: AT&T/Pace 5268AC and Asus TM-AC1900

(tested with SDK version: 1.5.3(aec24ac9)

Statistics: Posted by dalbert — Sat Jul 22, 2017 8:58 pm


]]>
2017-07-22T20:01:24+08:00 2017-07-22T20:01:24+08:00 https://bbs.espressif.com:443/viewtopic.php?t=3129&p=14755#p14755 <![CDATA[Re: WPS (Wi-Fi Protected Setup) in SDK]]> Statistics: Posted by dalbert — Sat Jul 22, 2017 8:01 pm


]]>
2016-11-29T14:23:48+08:00 2016-11-29T14:23:48+08:00 https://bbs.espressif.com:443/viewtopic.php?t=3129&p=10711#p10711 <![CDATA[Re: WPS (Wi-Fi Protected Setup) in SDK]]>

Can you provide the model of your router? And the encryption used(WPA, WPA2, TKIP/AES...).


Asus rt-ac51u Dual Band. Encryption - WPA2(AES)


My next step now is to try triggering WPS from my main microcontroller which is connected to ESP.

Statistics: Posted by russus — Tue Nov 29, 2016 2:23 pm


]]>
2016-11-29T01:56:53+08:00 2016-11-29T01:56:53+08:00 https://bbs.espressif.com:443/viewtopic.php?t=3129&p=10700#p10700 <![CDATA[Re: WPS (Wi-Fi Protected Setup) in SDK]]> Can you provide the model of your router? And the encryption used(WPA, WPA2, TKIP/AES...).

-Sheers

Statistics: Posted by gjump — Tue Nov 29, 2016 1:56 am


]]>
2016-11-29T01:45:20+08:00 2016-11-29T01:45:20+08:00 https://bbs.espressif.com:443/viewtopic.php?t=3129&p=10699#p10699 <![CDATA[Re: WPS (Wi-Fi Protected Setup) in SDK]]>
I can't express enough how much I appreciate your time and efforts in explaining this. It became crystal clear and finally worked :) !!!

I thought of the role of key_init_single(...) in a very wrong way. It seemed to me that it somehow emulates a physical push.

Well, I am very new to this stuff. I hope you can forgive me ;)

Statistics: Posted by russus — Tue Nov 29, 2016 1:45 am


]]>
2016-11-29T00:58:59+08:00 2016-11-29T00:58:59+08:00 https://bbs.espressif.com:443/viewtopic.php?t=3129&p=10698#p10698 <![CDATA[Re: WPS (Wi-Fi Protected Setup) in SDK]]>

Code:

single_key = key_init_single(WPS_KEY_IO_NUM, WPS_KEY_IO_MUX, WPS_KEY_IO_FUNC,
                                          NULL, user_wps_key_short_press);

This functions set the "user_wps_key_short_press" to be called when you press the GPIO13 (can be any GPIO, just need to be redefined).
So, the logic is, you press the WPS key in your router, then press the WPS key(GPIO13 in that case) on ESP, this triggers the WPS functions inside the user_wps_key_short_press, as you can see:

Code:

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();
}


In my case, that I don't have any button attached to my ESP, I'm calling the function "user_wps_key_short_press" via a timer, 3 seconds after the board init.

This is done using this code(i've removed the lines that doesn't belong to WPS functionality)

Code:



static void ICACHE_FLASH_ATTR ledtimer_func(void *arg)
{
  os_timer_disarm(&ledtimer);
  console_printf("LEDtimer %d\n\r",ledout++);
  if(ledout<2) // If seconds passed < 2, reload the timer
    {
      os_timer_setfn(&ledtimer, (os_timer_func_t *)ledtimer_func, NULL);
      os_timer_arm(&ledtimer, 1000, 0);
    }
  else user_wps_key_short_press(); // Else, call the WPS functions
}


void ICACHE_FLASH_ATTR
user_init(void)
{
   UARTInit(BIT_RATE_115200);
   console_printf("Hello world!\r\n");
   wifi_set_opmode(STATION_MODE);
   wifi_station_set_reconnect_policy(0); // To avoid using the previous saved credentials
   wifi_station_set_auto_connect(0); // To avoid using the previous saved credentials
   
   
   os_timer_disarm(&ledtimer);
   os_timer_setfn(&ledtimer, (os_timer_func_t *)ledtimer_func, NULL);
   os_timer_arm(&ledtimer, 1000, 0);
}


Explanation
I've a timer (ledtimer) attached to a callback function(ledtimer_func) that is called every second, once this function is called it checks the counter (ledout), if its <2 the timer is rearmed to be called again in 1 second. When ledout is >2 the rearming procedure isn't executed and "user_wps_key_short_press" is called, then triggering the WPS functions inside it.
But again, this code exists just because I don't have a button attached to my ESP, and as far as I've tested, you can't call the WPS functions right after you setup the module in STATION mode, you need to wait a little (not sure how long, I randomly picked 3s).

-Sheers

Statistics: Posted by gjump — Tue Nov 29, 2016 12:58 am


]]>
2016-11-28T22:01:11+08:00 2016-11-28T22:01:11+08:00 https://bbs.espressif.com:443/viewtopic.php?t=3129&p=10696#p10696 <![CDATA[Re: WPS (Wi-Fi Protected Setup) in SDK]]>

Maybe you can give a shot using another router

I'll definitely try another router when I get a chance. Honestly, I doubt that is the problem.

I added some print statements to the related functions.

Code:

LOCAL void ICACHE_FLASH_ATTR
user_wps_status_cb(int status)
{
   os_printf("\n\rwps_status_cb\n\r");
   switch (status) {
      case WPS_CB_ST_SUCCESS:
         wifi_wps_disable();
         wifi_station_connect();
         break;
      case WPS_CB_ST_FAILED:
      case WPS_CB_ST_TIMEOUT:
         wifi_wps_start();
         break;
   }
}


Code:

LOCAL void ICACHE_FLASH_ATTR
user_wps_key_short_press(void)
{
   os_printf("\n\rkey_short_press\n\r");
   wifi_wps_disable();
   wifi_wps_enable(WPS_TYPE_PBC);
   wifi_set_wps_cb(user_wps_status_cb);
   wifi_wps_start();
}


The output is similar to the one without. It makes me think that nothing is being called from user_main() during execution.

Can you please post your user_main if possible ? How do you introduce the delay?


I'm just calling the function via timer(~3s after boot), cause I don't have any buttons attached to my ESP

Can you elaborate on this a little bit. I feel I am missing something cricual because I dont understand the role of gpio13. It is a software WPS, why do you need buttons attached to your ESP ?

Statistics: Posted by russus — Mon Nov 28, 2016 10:01 pm


]]>
2016-11-28T21:12:30+08:00 2016-11-28T21:12:30+08:00 https://bbs.espressif.com:443/viewtopic.php?t=3129&p=10694#p10694 <![CDATA[Re: WPS (Wi-Fi Protected Setup) in SDK]]>

11:04:12.384> wifi_wps_enable
11:04:12.384> wps scan
11:04:12.384> build public key start
11:04:16.440> build public key finish
11:04:17.937> wps discover [Teste]
11:04:17.937> scandone
11:04:17.937> WPS: neg start
11:04:18.065> scandone
11:04:18.936> state: 0 -> 2 (b0)
11:04:18.936> state: 2 -> 3 (0)
11:04:19.027> state: 3 -> 5 (10)
11:04:19.027> add 0
11:04:19.027> aid 1
11:04:19.027> cnt
11:04:20.496> process pubkey start
11:04:25.366> process pubkey finish
11:04:25.426> WPS: key[senhateste]
11:04:25.426> wps finished
11:04:25.426> state: 5 -> 2 (1a0)
11:04:25.426> rm 0
11:04:26.425> >>WPS OK!!<<wifi_wps_disable
11:04:26.425> state: 2 -> 0 (0)
11:04:26.524> scandone
11:04:27.548> state: 0 -> 2 (b0)
11:04:27.548> state: 2 -> 3 (0)
11:04:27.548> state: 3 -> 5 (10)
11:04:27.548> add 0
11:04:27.548> aid 1
11:04:27.548> cnt
11:04:27.781>
11:04:27.781> connected with Teste, channel 11


Maybe you can give a shot using another router. I know that the AT firmware works, but who knows. I'm going to check if WPS works with the "not working" router using AT firmware.
But as I said, the code was supposed to work with any router.
And I'm still waiting for someone from Espressif to post something.

-sheers

Statistics: Posted by gjump — Mon Nov 28, 2016 9:12 pm


]]>
2016-11-28T14:28:24+08:00 2016-11-28T14:28:24+08:00 https://bbs.espressif.com:443/viewtopic.php?t=3129&p=10693#p10693 <![CDATA[Re: WPS (Wi-Fi Protected Setup) in SDK]]>
I understood that the router could be an obstacle. This was the reason behind trying the AT firmware in my case. Since it worked fine, I assumed that the router is not an issue here. Was I correct to make this conclusion?

The output from running the SDK's code is below. No sign of WPS whatsoever

Code:

load 0x40100000, len 29052, room 16
tail 12
chksum 0xcb
ho 0 tail 12 room 4
load 0x3ffe8000, len 1932, room 12
tail 0
chksum 0x64
load 0x3ffe8790, len 1816, room 8
tail 0
chksum 0x91
csum 0x91
rf cal sector: 123
rf[112] : 00
rf[113] : 00
rf[114] : 01

SDK ver: 2.0.0(656edbf) compiled @ Jul 19 2016 17:58:40
phy ver: 1055, pp ver: 10.2

mode : sta(18:fe:34:a3:25:31)
add if0


Am I understanding correctly that the code that comes with SDK works out of the box for you?

Statistics: Posted by russus — Mon Nov 28, 2016 2:28 pm


]]>
2016-11-27T09:13:35+08:00 2016-11-27T09:13:35+08:00 https://bbs.espressif.com:443/viewtopic.php?t=3129&p=10679#p10679 <![CDATA[Re: WPS (Wi-Fi Protected Setup) in SDK]]> It would be very nice to hear something from Espressif staff now.

Sheers!

Statistics: Posted by gjump — Sun Nov 27, 2016 9:13 am


]]>
2016-11-26T02:00:44+08:00 2016-11-26T02:00:44+08:00 https://bbs.espressif.com:443/viewtopic.php?t=3129&p=10670#p10670 <![CDATA[Re: WPS (Wi-Fi Protected Setup) in SDK]]> Statistics: Posted by gjump — Sat Nov 26, 2016 2:00 am


]]>
2016-11-26T01:05:38+08:00 2016-11-26T01:05:38+08:00 https://bbs.espressif.com:443/viewtopic.php?t=3129&p=10669#p10669 <![CDATA[Re: WPS (Wi-Fi Protected Setup) in SDK]]> Statistics: Posted by gjump — Sat Nov 26, 2016 1:05 am


]]>
2016-11-25T13:39:01+08:00 2016-11-25T13:39:01+08:00 https://bbs.espressif.com:443/viewtopic.php?t=3129&p=10656#p10656 <![CDATA[Re: WPS (Wi-Fi Protected Setup) in SDK]]> Statistics: Posted by russus — Fri Nov 25, 2016 1:39 pm


]]>
2016-11-24T06:29:35+08:00 2016-11-24T06:29:35+08:00 https://bbs.espressif.com:443/viewtopic.php?t=3129&p=10628#p10628 <![CDATA[Re: WPS (Wi-Fi Protected Setup) in SDK]]>

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


I'm using the ESP12E module.

The callback function is never called. I left the code running for 10min just to be sure.

Statistics: Posted by gjump — Thu Nov 24, 2016 6:29 am


]]>
2016-11-23T19:07:00+08:00 2016-11-23T19:07:00+08:00 https://bbs.espressif.com:443/viewtopic.php?t=3129&p=10623#p10623 <![CDATA[WPS (Wi-Fi Protected Setup) in SDK]]>
I really really need help here. The code is given below. Can someone explain me the role of key_init_single and why GPIO 13 is used? Do we need to toggle it somehow for WPS to start working?

Code:

#include "osapi.h"
#include "user_interface.h"
 
#include "driver/key.h"
 
#define WPS_KEY_NUM        1
 
#define WPS_KEY_IO_MUX     PERIPHS_IO_MUX_MTCK_U
#define WPS_KEY_IO_NUM     13
#define WPS_KEY_IO_FUNC    FUNC_GPIO13
 
LOCAL struct keys_param keys;
LOCAL struct single_key_param *single_key;
 
LOCAL void ICACHE_FLASH_ATTR
user_wps_status_cb(int status)
{
    switch (status) {
        case WPS_CB_ST_SUCCESS:
            wifi_wps_disable();
            wifi_station_connect();
            break;
        case WPS_CB_ST_FAILED:
        case WPS_CB_ST_TIMEOUT:
            wifi_wps_start();
            break;
    }
}
 
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();
}
 
void ICACHE_FLASH_ATTR
user_rf_pre_init(void)
{
}
 
void ICACHE_FLASH_ATTR
user_init(void)
{
    single_key = key_init_single(WPS_KEY_IO_NUM, WPS_KEY_IO_MUX, WPS_KEY_IO_FUNC,
                                            NULL, user_wps_key_short_press);
 
    keys.key_num = WPS_KEY_NUM;
    keys.single_key = &single_key;
 
    key_init(&keys);
 
    wifi_set_opmode(STATION_MODE);
}

Statistics: Posted by russus — Wed Nov 23, 2016 7:07 pm


]]>