Skip to content

Commit b5f992a

Browse files
example: add example for beacon sample feature
1 parent c00d092 commit b5f992a

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

examples/wifi/power_save/main/Kconfig.projbuild

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,4 +145,8 @@ menu "Example Configuration"
145145
default 26 if EXAMPLE_MIN_CPU_FREQ_26M
146146
default 13 if EXAMPLE_MIN_CPU_FREQ_13M
147147

148+
config EXAMPLE_POWER_SAVE_RESAMPLE
149+
bool "Resample beacon when beacon loss is unstable"
150+
depends on ESP_WIFI_SLP_SAMPLE_BEACON_FEATURE
151+
148152
endmenu

examples/wifi/power_save/main/power_save.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ static void event_handler(void* arg, esp_event_base_t event_base,
5858
} else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_GOT_IP) {
5959
ip_event_got_ip_t* event = (ip_event_got_ip_t*) event_data;
6060
ESP_LOGI(TAG, "got ip: " IPSTR, IP2STR(&event->ip_info.ip));
61+
} else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_BEACON_OFFSET_UNSTABLE) {
62+
wifi_event_sta_beacon_offset_unstable_t* event = (wifi_event_sta_beacon_offset_unstable_t*)event_data;
63+
ESP_LOGI(TAG, "unstable sample, beacon success rate: %.4f", event->beacon_success_rate);
64+
#if CONFIG_EXAMPLE_POWER_SAVE_RESAMPLE
65+
esp_wifi_beacon_offset_sample_beacon();
66+
#endif
6167
}
6268
}
6369

0 commit comments

Comments
 (0)