mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
wps_ps: add license
This commit is contained in:
parent
a845f211e3
commit
0765355a4e
@ -1,9 +1,17 @@
|
|||||||
/* Power save Example
|
/* Power save Example
|
||||||
* this example shows how to use power save mode
|
|
||||||
*
|
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
||||||
* set a router or a AP using the same SSID&PASSWORD as configuration of this example.
|
|
||||||
* start esp32 and when it connected to AP it will enter power save mode
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
this example shows how to use power save mode
|
||||||
|
set a router or a AP using the same SSID&PASSWORD as configuration of this example.
|
||||||
|
start esp32 and when it connected to AP it will enter power save mode
|
||||||
|
*/
|
||||||
#include "freertos/FreeRTOS.h"
|
#include "freertos/FreeRTOS.h"
|
||||||
#include "freertos/event_groups.h"
|
#include "freertos/event_groups.h"
|
||||||
#include "esp_wifi.h"
|
#include "esp_wifi.h"
|
||||||
@ -16,11 +24,12 @@
|
|||||||
|
|
||||||
#if CONFIG_POWER_SAVE_MODEM
|
#if CONFIG_POWER_SAVE_MODEM
|
||||||
#define DEFAULT_PS_MODE WIFI_PS_MODEM
|
#define DEFAULT_PS_MODE WIFI_PS_MODEM
|
||||||
//#elif CONFIG_POWER_SAVE_NONE
|
#elif CONFIG_POWER_SAVE_NONE
|
||||||
//#define DEFAULT_PS_MODE WIFI_PS_NONE
|
#define DEFAULT_PS_MODE WIFI_PS_NONE
|
||||||
#else
|
#else
|
||||||
#define DEFAULT_PS_MODE WIFI_PS_NONE
|
#define DEFAULT_PS_MODE WIFI_PS_NONE
|
||||||
#endif
|
#endif /*CONFIG_POWER_SAVE_MODEM*/
|
||||||
|
|
||||||
|
|
||||||
static const char *TAG = "power_save";
|
static const char *TAG = "power_save";
|
||||||
|
|
||||||
|
@ -1,9 +1,19 @@
|
|||||||
/* WiFi Connection Example using WPS
|
/* WiFi Connection Example using WPS
|
||||||
*
|
|
||||||
* WPS_TYPE_PBC: Start esp32 and it will enter wps PBC mode. Then push the button of wps on router down. The esp32 will connected to the router.
|
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
||||||
*
|
|
||||||
* WPS_TYPE_PIN: Start esp32, You'll see PIN code which is a eight-digit number showing on COM. Enter the PIN code in router and then the esp32 will connected to router.
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
Showing how to use WPS.
|
||||||
|
|
||||||
|
WPS_TYPE_PBC: Start esp32 and it will enter wps PBC mode. Then push the button of wps on router down. The esp32 will connected to the router.
|
||||||
|
WPS_TYPE_PIN: Start esp32, You'll see PIN code which is a eight-digit number showing on COM. Enter the PIN code in router and then the esp32 will connected to router.
|
||||||
|
*/
|
||||||
|
|
||||||
#include "freertos/FreeRTOS.h"
|
#include "freertos/FreeRTOS.h"
|
||||||
#include "freertos/event_groups.h"
|
#include "freertos/event_groups.h"
|
||||||
#include "esp_wifi.h"
|
#include "esp_wifi.h"
|
||||||
@ -19,7 +29,8 @@
|
|||||||
#define WPS_TEST_MODE WPS_TYPE_PIN
|
#define WPS_TEST_MODE WPS_TYPE_PIN
|
||||||
#else
|
#else
|
||||||
#define WPS_TEST_MODE WPS_TYPE_DISABLE
|
#define WPS_TEST_MODE WPS_TYPE_DISABLE
|
||||||
#endif
|
#endif /*CONFIG_EXAMPLE_WPS_TYPE_PBC*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef PIN2STR
|
#ifndef PIN2STR
|
||||||
#define PIN2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5], (a)[6], (a)[7]
|
#define PIN2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5], (a)[6], (a)[7]
|
||||||
@ -47,7 +58,7 @@ static esp_err_t event_handler(void *ctx, system_event_t *event)
|
|||||||
break;
|
break;
|
||||||
case SYSTEM_EVENT_STA_WPS_ER_SUCCESS:
|
case SYSTEM_EVENT_STA_WPS_ER_SUCCESS:
|
||||||
/*point: the function esp_wifi_wps_start() only get ssid & password
|
/*point: the function esp_wifi_wps_start() only get ssid & password
|
||||||
* and we suggest you call the function esp_wifi_connect() here
|
* so call the function esp_wifi_connect() here
|
||||||
* */
|
* */
|
||||||
ESP_LOGI(TAG, "SYSTEM_EVENT_STA_WPS_ER_SUCCESS");
|
ESP_LOGI(TAG, "SYSTEM_EVENT_STA_WPS_ER_SUCCESS");
|
||||||
ESP_ERROR_CHECK(esp_wifi_wps_disable());
|
ESP_ERROR_CHECK(esp_wifi_wps_disable());
|
||||||
@ -89,7 +100,6 @@ static void start_wps(void)
|
|||||||
ESP_ERROR_CHECK(esp_wifi_start());
|
ESP_ERROR_CHECK(esp_wifi_start());
|
||||||
|
|
||||||
ESP_LOGI(TAG, "start wps...");
|
ESP_LOGI(TAG, "start wps...");
|
||||||
//ESP_ERROR_CHECK(esp_wifi_wps_enable(WPS_TYPE_PBC));
|
|
||||||
ESP_ERROR_CHECK(esp_wifi_wps_enable(WPS_TEST_MODE));
|
ESP_ERROR_CHECK(esp_wifi_wps_enable(WPS_TEST_MODE));
|
||||||
ESP_ERROR_CHECK(esp_wifi_wps_start(0));
|
ESP_ERROR_CHECK(esp_wifi_wps_start(0));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user