Skip to content

Commit 8f5d4cd

Browse files
committed
Merge branch 'fix/bt_check_during_ota' into 'master'
esp_rmaker_ota: Disable wifi power save only if BT controller is idle See merge request app-frameworks/esp-rainmaker!276
2 parents abc00d3 + b4c2bc7 commit 8f5d4cd

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

components/esp_rainmaker/src/ota/esp_rmaker_ota.c

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
#include <esp_https_ota.h>
2222
#include <esp_wifi_types.h>
2323
#include <esp_wifi.h>
24+
#if CONFIG_BT_ENABLED
25+
#include <esp_bt.h>
26+
#endif /* CONFIG_BT_ENABLED */
2427

2528
#include <esp_rmaker_utils.h>
2629
#include "esp_rmaker_ota_internal.h"
@@ -159,7 +162,7 @@ static esp_err_t esp_rmaker_ota_default_cb(esp_rmaker_ota_handle_t ota_handle, e
159162

160163
esp_rmaker_ota_report_status(ota_handle, OTA_STATUS_IN_PROGRESS, "Starting OTA Upgrade");
161164

162-
/* Using a warning just to highlight the message */
165+
/* Using a warning just to highlight the message */
163166
ESP_LOGW(TAG, "Starting OTA. This may take time.");
164167
esp_https_ota_handle_t https_ota_handle = NULL;
165168
esp_err_t err = esp_https_ota_begin(&ota_config, &https_ota_handle);
@@ -174,9 +177,15 @@ static esp_err_t esp_rmaker_ota_default_cb(esp_rmaker_ota_handle_t ota_handle, e
174177
*/
175178
wifi_ps_type_t ps_type;
176179
esp_wifi_get_ps(&ps_type);
177-
/* Disable Wi-Fi power save to speed up OTA
178-
*/
180+
/* Disable Wi-Fi power save to speed up OTA, iff BT is controller is idle/disabled.
181+
* Co-ex requirement, device panics otherwise.*/
182+
#if CONFIG_BT_ENABLED
183+
if (esp_bt_controller_get_status() == ESP_BT_CONTROLLER_STATUS_IDLE) {
184+
esp_wifi_set_ps(WIFI_PS_NONE);
185+
}
186+
#else
179187
esp_wifi_set_ps(WIFI_PS_NONE);
188+
#endif /* CONFIG_BT_ENABLED */
180189

181190
esp_app_desc_t app_desc;
182191
err = esp_https_ota_get_img_desc(https_ota_handle, &app_desc);
@@ -222,8 +231,15 @@ static esp_err_t esp_rmaker_ota_default_cb(esp_rmaker_ota_handle_t ota_handle, e
222231
} else {
223232
esp_rmaker_ota_report_status(ota_handle, OTA_STATUS_IN_PROGRESS, "Firmware Image download complete");
224233
}
234+
225235
ota_end:
236+
#ifdef CONFIG_BT_ENABLED
237+
if (esp_bt_controller_get_status() == ESP_BT_CONTROLLER_STATUS_IDLE) {
238+
esp_wifi_set_ps(ps_type);
239+
}
240+
#else
226241
esp_wifi_set_ps(ps_type);
242+
#endif /* CONFIG_BT_ENABLED */
227243
ota_finish_err = esp_https_ota_finish(https_ota_handle);
228244
if ((err == ESP_OK) && (ota_finish_err == ESP_OK)) {
229245
ESP_LOGI(TAG, "OTA upgrade successful. Rebooting in %d seconds...", OTA_REBOOT_TIMER_SEC);

0 commit comments

Comments
 (0)