Files
ESP8266_RTOS_SDK/examples/wifi/wps/main/user_main.c
Wu Jian Gang c4faded08f feat(examples): remove the use of user_rf_cal_sector_set in examples
rf cal data now stored in nvs if needed
2018-07-09 17:16:53 +08:00

57 lines
1.2 KiB
C

/* WPS example
This example code is in the Public Domain (or CC0 licensed, at your option.)
Unless required by applicable law or agreed to in writing, this
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "esp_sta.h"
#include "esp_system.h"
#include "esp_wps.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
static void user_wps_status_cb(int status)
{
printf("scan status %d\n", 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;
}
}
static void user_wps_start(void)
{
wifi_wps_disable();
wifi_wps_enable(WPS_TYPE_PBC);
wifi_set_wps_cb(user_wps_status_cb);
wifi_wps_start();
}
static void wps_task(void* pvParameters)
{
wifi_set_opmode(STATION_MODE);
user_wps_start();
vTaskDelete(NULL);
}
void user_init(void)
{
xTaskCreate(wps_task, "wps_task", 1024, NULL, 4, NULL);
}