Skip to content

Commit 0bb9116

Browse files
committed
c6 wifi power save mode test
1 parent 17b1a38 commit 0bb9116

File tree

4 files changed

+41
-1
lines changed

4 files changed

+41
-1
lines changed

config/esp32/components/chip/CMakeLists.txt

+7-1
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,13 @@ if(CONFIG_BT_ENABLED)
434434
if((target_name STREQUAL "esp32h2") OR (target_name STREQUAL "esp32c2") OR (target_name STREQUAL "esp32c6"))
435435
idf_component_get_property(bt_dir bt COMPONENT_DIR)
436436
list(APPEND chip_libraries $<TARGET_FILE:${bt_lib}>)
437-
list(APPEND chip_libraries "${bt_dir}/controller/lib_${target_name}/${target_name}-bt-lib/libble_app.a")
437+
if (EXISTS ${bt_dir}/controller/lib_${target_name}/${target_name}-bt-lib/libble_app.a)
438+
list(APPEND chip_libraries "${bt_dir}/controller/lib_${target_name}/${target_name}-bt-lib/libble_app.a")
439+
message("c6 bt lib in chip_library: ${bt_dir}/controller/lib_${target_name}/${target_name}-bt-lib/libble_app.a")
440+
elseif(EXISTS ${bt_dir}/controller/lib_${target_name}/${target_name}-bt-lib/${target_name}/libble_app.a)
441+
list(APPEND chip_libraries "${bt_dir}/controller/lib_${target_name}/${target_name}-bt-lib/${target_name}/libble_app.a")
442+
message("c6/c61 bt lib in chip_library: ${bt_dir}/controller/lib_${target_name}/${target_name}-bt-lib/${target_name}/libble_app.a")
443+
endif()
438444
else()
439445
list(APPEND chip_libraries $<TARGET_FILE:${bt_lib}> -lbtdm_app)
440446
endif()

src/platform/ESP32/ConnectivityManagerImpl_WiFi.cpp

+16
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,18 @@ using namespace ::chip::Inet;
4848
using namespace ::chip::System;
4949
using chip::DeviceLayer::Internal::ESP32Utils;
5050

51+
#define DEFAULT_BEACON_TIMEOUT CONFIG_EXAMPLE_WIFI_BEACON_TIMEOUT
52+
53+
#if CONFIG_EXAMPLE_POWER_SAVE_MIN_MODEM
54+
#define DEFAULT_PS_MODE WIFI_PS_MIN_MODEM
55+
#elif CONFIG_EXAMPLE_POWER_SAVE_MAX_MODEM
56+
#define DEFAULT_PS_MODE WIFI_PS_MAX_MODEM
57+
#elif CONFIG_EXAMPLE_POWER_SAVE_NONE
58+
#define DEFAULT_PS_MODE WIFI_PS_NONE
59+
#else
60+
#define DEFAULT_PS_MODE WIFI_PS_NONE
61+
#endif /*CONFIG_POWER_SAVE_MODEM*/
62+
5163
namespace chip {
5264
namespace DeviceLayer {
5365

@@ -640,6 +652,10 @@ void ConnectivityManagerImpl::DriveStationState()
640652
now >= mLastStationConnectFailTime + mWiFiStationReconnectInterval)
641653
{
642654
ChipLogProgress(DeviceLayer, "Attempting to connect WiFi station interface");
655+
esp_wifi_set_inactive_time(WIFI_IF_STA, 24);
656+
esp_wifi_set_ps(WIFI_PS_MAX_MODEM);
657+
658+
printf("esp_wifi_connect()\r\n");
643659
esp_err_t err = esp_wifi_connect();
644660
if (err != ESP_OK)
645661
{

src/platform/ESP32/ESP32Utils.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ CHIP_ERROR ESP32Utils::StartWiFiLayer(void)
112112
ChipLogProgress(DeviceLayer, "Starting ESP WiFi layer");
113113

114114
err = esp_wifi_start();
115+
printf("esp_wifi_start\r\n");
115116
if (err != ESP_OK)
116117
{
117118
ChipLogError(DeviceLayer, "esp_wifi_start() failed: %s", esp_err_to_name(err));

src/platform/ESP32/NetworkCommissioningDriver.cpp

+17
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,19 @@ constexpr char kWiFiCredentialsKeyName[] = "wifi-pass";
3838
static uint8_t WiFiSSIDStr[DeviceLayer::Internal::kMaxWiFiSSIDLength];
3939
} // namespace
4040

41+
#define DEFAULT_LISTEN_INTERVAL (20)
42+
// #define DEFAULT_BEACON_TIMEOUT CONFIG_EXAMPLE_WIFI_BEACON_TIMEOUT
43+
44+
// #if CONFIG_EXAMPLE_POWER_SAVE_MIN_MODEM
45+
// #define DEFAULT_PS_MODE WIFI_PS_MIN_MODEM
46+
// #elif CONFIG_EXAMPLE_POWER_SAVE_MAX_MODEM
47+
// #define DEFAULT_PS_MODE WIFI_PS_MAX_MODEM
48+
// #elif CONFIG_EXAMPLE_POWER_SAVE_NONE
49+
// #define DEFAULT_PS_MODE WIFI_PS_NONE
50+
// #else
51+
// #define DEFAULT_PS_MODE WIFI_PS_NONE
52+
// #endif /*CONFIG_POWER_SAVE_MODEM*/
53+
4154
BitFlags<WiFiSecurityBitmap> ConvertSecurityType(wifi_auth_mode_t authMode)
4255
{
4356
BitFlags<WiFiSecurityBitmap> securityType;
@@ -224,8 +237,12 @@ CHIP_ERROR ESPWiFiDriver::ConnectWiFiNetwork(const char * ssid, uint8_t ssidLen,
224237
memcpy(wifiConfig.sta.ssid, ssid, std::min(ssidLen, static_cast<uint8_t>(sizeof(wifiConfig.sta.ssid))));
225238
memcpy(wifiConfig.sta.password, key, std::min(keyLen, static_cast<uint8_t>(sizeof(wifiConfig.sta.password))));
226239

240+
wifiConfig.sta.listen_interval = 20;
227241
// Configure the ESP WiFi interface.
228242
esp_err_t err = esp_wifi_set_config(WIFI_IF_STA, &wifiConfig);
243+
// esp_wifi_set_inactive_time(WIFI_IF_STA, DEFAULT_BEACON_TIMEOUT);
244+
// esp_wifi_set_ps(DEFAULT_PS_MODE);
245+
229246
if (err != ESP_OK)
230247
{
231248
ChipLogError(DeviceLayer, "esp_wifi_set_config() failed: %s", esp_err_to_name(err));

0 commit comments

Comments
 (0)