Merge branch 'bugfix/pm_coex_minor_things' into 'master'

Bugfix/pm coex minor things

See merge request idf/esp-idf!2180
This commit is contained in:
Jiang Jiang Jian 2018-04-04 17:54:40 +08:00
commit c842725be0
10 changed files with 151 additions and 67 deletions

View file

@ -98,8 +98,8 @@ build_template_app:
- make all V=1
# Check if there are any stray printf/ets_printf references in WiFi libs
- cd ../components/esp32/lib
- test $(ls *.a|awk '{if ($1 != "libcoexist.a") print $1}' | xargs xtensa-esp32-elf-nm | grep -w printf | wc -l) -eq 0
- test $(ls *.a|awk '{if ($1 != "libcoexist.a") print $1}' | xargs xtensa-esp32-elf-nm | grep -w ets_printf | wc -l) -eq 0
- test $(xtensa-esp32-elf-nm *.a | grep -w printf | wc -l) -eq 0
- test $(xtensa-esp32-elf-nm *.a | grep -w ets_printf | wc -l) -eq 0
.build_template: &build_template

View file

@ -0,0 +1,26 @@
// Copyright 2018-2018 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "esp_coexist.h"
#include "coexist_internal.h"
const char *esp_coex_version_get(void)
{
return coex_version_get();
}
esp_err_t esp_coex_preference_set(esp_coex_prefer_t prefer)
{
return coex_preference_set((coex_prefer_t)prefer);
}

View file

@ -0,0 +1,77 @@
// Copyright 2018-2018 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef __COEXIST_INTERNAL_H__
#define __COEXIST_INTERNAL_H__
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
COEX_PREFER_WIFI = 0,
COEX_PREFER_BT,
COEX_PREFER_BALANCE,
COEX_PREFER_NUM,
} coex_prefer_t;
/**
* @brief Init software coexist
* extern function for internal use.
*
* @return Init ok or failed.
*/
esp_err_t coex_init(void);
/**
* @brief De-init software coexist
* extern function for internal use.
*/
void coex_deinit(void);
/**
* @brief Pause software coexist
* extern function for internal use.
*/
void coex_pause(void);
/**
* @brief Resume software coexist
* extern function for internal use.
*/
void coex_resume(void);
/**
* @brief Get software coexist version string
* extern function for internal use.
* @return : version string
*/
const char *coex_version_get(void);
/**
* @brief Coexist performance preference set from libbt.a
* extern function for internal use.
*
* @param prefer : the prefer enumeration value
* @return : ESP_OK - success, other - failed
*/
esp_err_t coex_preference_set(coex_prefer_t prefer);
#ifdef __cplusplus
}
#endif
#endif /* __COEXIST_INTERNAL_H__ */

View file

@ -1,4 +1,4 @@
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
// Copyright 2015-2018 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -12,70 +12,32 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef __ESP_COEXIST_H__
#define __ESP_COEXIST_H__
#include <stdbool.h>
#include "esp_err.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief coex prefer value
*/
typedef enum {
COEX_PREFER_WIFI = 0,
COEX_PREFER_BT,
COEX_PREFER_BALANCE,
COEX_PREFER_NUM,
} coex_prefer_t;
/**
* @brief Init software coexist
* extern function for internal use.
*
* @return Init ok or failed.
*/
esp_err_t coex_init(void);
/**
* @brief De-init software coexist
* extern function for internal use.
*/
void coex_deinit(void);
/**
* @brief Pause software coexist
* extern function for internal use.
*/
void coex_pause(void);
/**
* @brief Resume software coexist
* extern function for internal use.
*/
void coex_resume(void);
/**
* @brief Get software coexist version string
* extern function for internal use.
* @return : version string
*/
const char *coex_version_get(void);
/**
* @brief Coexist performance preference set from libbt.a
* extern function for internal use.
*
* @param prefer : the prefer enumeration value
* @return : ESP_OK - success, other - failed
*/
esp_err_t coex_preference_set(coex_prefer_t prefer);
ESP_COEX_PREFER_WIFI = 0, /*!< Prefer to WiFi, WiFi will have more opportunity to use RF */
ESP_COEX_PREFER_BT, /*!< Prefer to bluetooth, bluetooth will have more opportunity to use RF */
ESP_COEX_PREFER_BALANCE, /*!< Do balance of WiFi and bluetooth */
ESP_COEX_PREFER_NUM, /*!< Prefer value numbers */
} esp_coex_prefer_t;
/**
* @brief Get software coexist version string
*
* @return : version string
*/
static inline const char *esp_coex_version_get(void)
{
return coex_version_get();
}
const char *esp_coex_version_get(void);
/**
* @brief Set coexist preference of performance
@ -87,11 +49,11 @@ static inline const char *esp_coex_version_get(void)
* @param prefer : the prefer enumeration value
* @return : ESP_OK - success, other - failed
*/
static inline esp_err_t esp_coex_preference_set(coex_prefer_t prefer)
{
return coex_preference_set(prefer);
}
esp_err_t esp_coex_preference_set(esp_coex_prefer_t prefer);
#ifdef __cplusplus
}
#endif
#endif /* __ESP_COEXIST_H__ */

@ -1 +1 @@
Subproject commit 608bf369c66c33c15b0cc198e573e421c7103e1f
Subproject commit 152e29aa93a3d3f95fd6ed53a924a92c98fcc13c

View file

@ -128,3 +128,12 @@ int net80211_printf(const char* format, ...)
va_end(arg);
return res;
}
int coexist_printf(const char* format, ...)
{
va_list arg;
va_start(arg, format);
int res = lib_printf("coexist", format, arg);
va_end(arg);
return res;
}

View file

@ -36,7 +36,7 @@
#include "freertos/portmacro.h"
#include "phy.h"
#include "phy_init_data.h"
#include "esp_coexist.h"
#include "coexist_internal.h"
#include "driver/periph_ctrl.h"

6
docs/en/api-guides/wifi.rst Normal file → Executable file
View file

@ -1201,11 +1201,11 @@ By default, all Wi-Fi management frames are processed by the Wi-Fi driver, and t
ESP32 Wi-Fi Power-saving Mode
-----------------------------------
Currently, ESP32 Wi-Fi supports the Modem-sleep mode which refers to the legacy power-saving mode in the IEEE 802.11 protocol. Modem-sleep mode works in Station-only mode and the station must connect to the AP first. If the Modem-sleep mode is enabled, station will switch between active and doze state periodically. In doze state, RF, PHY and BB are turned off in order to reduce power consumption. Station can keep connection with AP in modem-sleep mode.
Currently, ESP32 Wi-Fi supports the Modem-sleep mode which refers to the legacy power-saving mode in the IEEE 802.11 protocol. Modem-sleep mode works in Station-only mode and the station must connect to the AP first. If the Modem-sleep mode is enabled, station will switch between active and sleep state periodically. In sleep state, RF, PHY and BB are turned off in order to reduce power consumption. Station can keep connection with AP in modem-sleep mode.
Modem-sleep mode includes minimum and maximum power save modes. In minimum power save mode, station wakes up every DTIM to receive beacon. Broadcast data will not be lost because it is transmitted after DTIM. However, it can not save much more power if DTIM is short for DTIM is determined by AP. In maximum power save mode, station wakes up every listen interval to receive beacon. Broadcast data may be lost because station may be in doze state at DTIM time. If listen interval is longer, more power is saved but broadcast data is more easy to lose. Listen interval can be configured by calling API esp_wifi_set_config() before connecting to AP.
Modem-sleep mode includes minimum and maximum power save modes. In minimum power save mode, station wakes up every DTIM to receive beacon. Broadcast data will not be lost because it is transmitted after DTIM. However, it can not save much more power if DTIM is short for DTIM is determined by AP. In maximum power save mode, station wakes up every listen interval to receive beacon. Broadcast data may be lost because station may be in sleep state at DTIM time. If listen interval is longer, more power is saved but broadcast data is more easy to lose. Listen interval can be configured by calling API :cpp:func:`esp_wifi_set_config` before connecting to AP.
Call esp_wifi_set_ps(WIFI_PS_MIN_MODEM) to enable Modem-sleep minimum power save mode or esp_wifi_set_ps(WIFI_PS_MAX_MODEM) to enable Modem-sleep maximum power save mode after calling esp_wifi_init(). When station connects to AP, Modem-sleep will start. When station disconnects from AP, Modem-sleep will stop.
Call ``esp_wifi_set_ps(WIFI_PS_MIN_MODEM)`` to enable Modem-sleep minimum power save mode or ``esp_wifi_set_ps(WIFI_PS_MAX_MODEM)`` to enable Modem-sleep maximum power save mode after calling :cpp:func:`esp_wifi_init`. When station connects to AP, Modem-sleep will start. When station disconnects from AP, Modem-sleep will stop.
ESP32 Wi-Fi Connect Crypto
-----------------------------------

6
examples/wifi/power_save/README.md Normal file → Executable file
View file

@ -2,10 +2,12 @@
This example shows how to use power save mode of wifi.
Power save mode only works in sta mode.
Power save mode only works in station mode. If the modem sleep mode is enabled, station will switch between active and sleep state periodically after connecting to AP successfully. In sleep state, RF, PHY and BB are turned off in order to reduce power consumption. Station can keep connection with AP in modem sleep mode.
* No power save: This is default mode. And the esp32 will work with full power.
* modem sleep: If you set power save mode as modem sleep, 10s later after connecting to AP, esp32 will wake up and sleep(turn off RF and PHY) periodically.
* Minimum modem sleep: In minimum modem sleep mode, station wakes up every DTIM to receive beacon. Broadcast data will not be lost because it is transmitted after DTIM. However, it can not save much more power if DTIM is short for DTIM is determined by AP.
* Maximum modem sleep: In maximum modem sleep mode, station wakes up every listen interval to receive beacon. Broadcast data may be lost because station may be in sleep state at DTIM time. If listen interval is longer, more power is saved but broadcast data is more easy to lose.
* others: not supported yet.

12
examples/wifi/power_save/main/Kconfig.projbuild Normal file → Executable file
View file

@ -16,13 +16,21 @@ config WIFI_LISTEN_INTERVAL
int "WiFi listen interval"
default 3
help
WiFi listen interval for station to receive beacon from AP.
Interval for station to listen to beacon from AP. The unit of listen interval is one beacon interval.
For example, if beacon interval is 100 ms and listen interval is 3, the interval for station to listen
to beacon is 300 ms.
choice POWER_SAVE_MODE
prompt "power save mode"
default POWER_SAVE_MIN_MODEM
help
Power save mode for the esp32 to use.
Power save mode for the esp32 to use. Modem sleep mode includes minimum and maximum power save modes.
In minimum power save mode, station wakes up every DTIM to receive beacon. Broadcast data will not be
lost because it is transmitted after DTIM. However, it can not save much more power if DTIM is short
for DTIM is determined by AP.
In maximum power save mode, station wakes up every listen interval to receive beacon. Broadcast data
may be lost because station may be in sleep state at DTIM time. If listen interval is longer, more power
is saved but broadcast data is more easy to lose.
config POWER_SAVE_NONE
bool "none"