Skip to content

Commit c842725

Browse files
committed
Merge branch 'bugfix/pm_coex_minor_things' into 'master'
Bugfix/pm coex minor things See merge request idf/esp-idf!2180
2 parents 1a302cb + e72f7e7 commit c842725

File tree

10 files changed

+150
-66
lines changed

10 files changed

+150
-66
lines changed

.gitlab-ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ build_template_app:
9898
- make all V=1
9999
# Check if there are any stray printf/ets_printf references in WiFi libs
100100
- cd ../components/esp32/lib
101-
- test $(ls *.a|awk '{if ($1 != "libcoexist.a") print $1}' | xargs xtensa-esp32-elf-nm | grep -w printf | wc -l) -eq 0
102-
- test $(ls *.a|awk '{if ($1 != "libcoexist.a") print $1}' | xargs xtensa-esp32-elf-nm | grep -w ets_printf | wc -l) -eq 0
101+
- test $(xtensa-esp32-elf-nm *.a | grep -w printf | wc -l) -eq 0
102+
- test $(xtensa-esp32-elf-nm *.a | grep -w ets_printf | wc -l) -eq 0
103103

104104

105105
.build_template: &build_template

components/esp32/coexist.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright 2018-2018 Espressif Systems (Shanghai) PTE LTD
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#include "esp_coexist.h"
16+
#include "coexist_internal.h"
17+
18+
const char *esp_coex_version_get(void)
19+
{
20+
return coex_version_get();
21+
}
22+
23+
esp_err_t esp_coex_preference_set(esp_coex_prefer_t prefer)
24+
{
25+
return coex_preference_set((coex_prefer_t)prefer);
26+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
// Copyright 2018-2018 Espressif Systems (Shanghai) PTE LTD
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#ifndef __COEXIST_INTERNAL_H__
16+
#define __COEXIST_INTERNAL_H__
17+
18+
#include <stdbool.h>
19+
20+
#ifdef __cplusplus
21+
extern "C" {
22+
#endif
23+
24+
typedef enum {
25+
COEX_PREFER_WIFI = 0,
26+
COEX_PREFER_BT,
27+
COEX_PREFER_BALANCE,
28+
COEX_PREFER_NUM,
29+
} coex_prefer_t;
30+
31+
/**
32+
* @brief Init software coexist
33+
* extern function for internal use.
34+
*
35+
* @return Init ok or failed.
36+
*/
37+
esp_err_t coex_init(void);
38+
39+
/**
40+
* @brief De-init software coexist
41+
* extern function for internal use.
42+
*/
43+
void coex_deinit(void);
44+
45+
/**
46+
* @brief Pause software coexist
47+
* extern function for internal use.
48+
*/
49+
void coex_pause(void);
50+
51+
/**
52+
* @brief Resume software coexist
53+
* extern function for internal use.
54+
*/
55+
void coex_resume(void);
56+
57+
/**
58+
* @brief Get software coexist version string
59+
* extern function for internal use.
60+
* @return : version string
61+
*/
62+
const char *coex_version_get(void);
63+
64+
/**
65+
* @brief Coexist performance preference set from libbt.a
66+
* extern function for internal use.
67+
*
68+
* @param prefer : the prefer enumeration value
69+
* @return : ESP_OK - success, other - failed
70+
*/
71+
esp_err_t coex_preference_set(coex_prefer_t prefer);
72+
73+
#ifdef __cplusplus
74+
}
75+
#endif
76+
77+
#endif /* __COEXIST_INTERNAL_H__ */
Lines changed: 17 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
1+
// Copyright 2015-2018 Espressif Systems (Shanghai) PTE LTD
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -12,70 +12,32 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
#ifndef __ESP_COEXIST_H__
16+
#define __ESP_COEXIST_H__
17+
1518
#include <stdbool.h>
19+
#include "esp_err.h"
1620

1721
#ifdef __cplusplus
1822
extern "C" {
1923
#endif
2024

21-
typedef enum {
22-
COEX_PREFER_WIFI = 0,
23-
COEX_PREFER_BT,
24-
COEX_PREFER_BALANCE,
25-
COEX_PREFER_NUM,
26-
} coex_prefer_t;
27-
28-
/**
29-
* @brief Init software coexist
30-
* extern function for internal use.
31-
*
32-
* @return Init ok or failed.
33-
*/
34-
esp_err_t coex_init(void);
35-
3625
/**
37-
* @brief De-init software coexist
38-
* extern function for internal use.
26+
* @brief coex prefer value
3927
*/
40-
void coex_deinit(void);
41-
42-
/**
43-
* @brief Pause software coexist
44-
* extern function for internal use.
45-
*/
46-
void coex_pause(void);
47-
48-
/**
49-
* @brief Resume software coexist
50-
* extern function for internal use.
51-
*/
52-
void coex_resume(void);
53-
54-
/**
55-
* @brief Get software coexist version string
56-
* extern function for internal use.
57-
* @return : version string
58-
*/
59-
const char *coex_version_get(void);
60-
61-
/**
62-
* @brief Coexist performance preference set from libbt.a
63-
* extern function for internal use.
64-
*
65-
* @param prefer : the prefer enumeration value
66-
* @return : ESP_OK - success, other - failed
67-
*/
68-
esp_err_t coex_preference_set(coex_prefer_t prefer);
28+
typedef enum {
29+
ESP_COEX_PREFER_WIFI = 0, /*!< Prefer to WiFi, WiFi will have more opportunity to use RF */
30+
ESP_COEX_PREFER_BT, /*!< Prefer to bluetooth, bluetooth will have more opportunity to use RF */
31+
ESP_COEX_PREFER_BALANCE, /*!< Do balance of WiFi and bluetooth */
32+
ESP_COEX_PREFER_NUM, /*!< Prefer value numbers */
33+
} esp_coex_prefer_t;
6934

7035
/**
7136
* @brief Get software coexist version string
7237
*
7338
* @return : version string
7439
*/
75-
static inline const char *esp_coex_version_get(void)
76-
{
77-
return coex_version_get();
78-
}
40+
const char *esp_coex_version_get(void);
7941

8042
/**
8143
* @brief Set coexist preference of performance
@@ -87,11 +49,11 @@ static inline const char *esp_coex_version_get(void)
8749
* @param prefer : the prefer enumeration value
8850
* @return : ESP_OK - success, other - failed
8951
*/
90-
static inline esp_err_t esp_coex_preference_set(coex_prefer_t prefer)
91-
{
92-
return coex_preference_set(prefer);
93-
}
52+
esp_err_t esp_coex_preference_set(esp_coex_prefer_t prefer);
9453

9554
#ifdef __cplusplus
9655
}
9756
#endif
57+
58+
59+
#endif /* __ESP_COEXIST_H__ */

components/esp32/lib

components/esp32/lib_printf.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,12 @@ int net80211_printf(const char* format, ...)
128128
va_end(arg);
129129
return res;
130130
}
131+
132+
int coexist_printf(const char* format, ...)
133+
{
134+
va_list arg;
135+
va_start(arg, format);
136+
int res = lib_printf("coexist", format, arg);
137+
va_end(arg);
138+
return res;
139+
}

components/esp32/phy_init.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
#include "freertos/portmacro.h"
3737
#include "phy.h"
3838
#include "phy_init_data.h"
39-
#include "esp_coexist.h"
39+
#include "coexist_internal.h"
4040
#include "driver/periph_ctrl.h"
4141

4242

docs/en/api-guides/wifi.rst

100644100755
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,11 +1201,11 @@ By default, all Wi-Fi management frames are processed by the Wi-Fi driver, and t
12011201

12021202
ESP32 Wi-Fi Power-saving Mode
12031203
-----------------------------------
1204-
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.
1204+
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.
12051205

1206-
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.
1206+
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.
12071207

1208-
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.
1208+
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.
12091209

12101210
ESP32 Wi-Fi Connect Crypto
12111211
-----------------------------------

examples/wifi/power_save/README.md

100644100755
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
This example shows how to use power save mode of wifi.
44

5-
Power save mode only works in sta mode.
5+
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.
66

77
* No power save: This is default mode. And the esp32 will work with full power.
88

9-
* 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.
9+
* 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.
10+
11+
* 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.
1012

1113
* others: not supported yet.

examples/wifi/power_save/main/Kconfig.projbuild

100644100755
Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,21 @@ config WIFI_LISTEN_INTERVAL
1616
int "WiFi listen interval"
1717
default 3
1818
help
19-
WiFi listen interval for station to receive beacon from AP.
19+
Interval for station to listen to beacon from AP. The unit of listen interval is one beacon interval.
20+
For example, if beacon interval is 100 ms and listen interval is 3, the interval for station to listen
21+
to beacon is 300 ms.
2022

2123
choice POWER_SAVE_MODE
2224
prompt "power save mode"
2325
default POWER_SAVE_MIN_MODEM
2426
help
25-
Power save mode for the esp32 to use.
27+
Power save mode for the esp32 to use. Modem sleep mode includes minimum and maximum power save modes.
28+
In minimum power save mode, station wakes up every DTIM to receive beacon. Broadcast data will not be
29+
lost because it is transmitted after DTIM. However, it can not save much more power if DTIM is short
30+
for DTIM is determined by AP.
31+
In maximum power save mode, station wakes up every listen interval to receive beacon. Broadcast data
32+
may be lost because station may be in sleep state at DTIM time. If listen interval is longer, more power
33+
is saved but broadcast data is more easy to lose.
2634

2735
config POWER_SAVE_NONE
2836
bool "none"

0 commit comments

Comments
 (0)