Stop Bluetooth before TFT upload

Helps with:
- #1983
- #1946
- #1815
This commit is contained in:
Edward Firmo
2024-04-17 09:39:38 +02:00
parent a6f62a053c
commit acf96d4f30
2 changed files with 83 additions and 60 deletions

View File

@@ -179,6 +179,14 @@ script:
then:
- switch.turn_on: screen_power
- delay: 5s
- lambda: if (id(tft_is_valid)) disp1->goto_page("home");
- delay: 2s
- script.execute: open_upload_dialog
- script.wait: open_upload_dialog
- wait_until:
condition:
- lambda: return (current_page->state == "confirm");
timeout: 2s
# Then start the upload
- lambda: |-
static const char *const TAG = "addon_upload_tft.script.upload_tft";
@@ -195,7 +203,31 @@ script:
ESP_LOGD(TAG, " Upload URL: %s", url.c_str());
disp1->set_tft_url(url.c_str());
- lambda: if (id(tft_is_valid)) disp1->goto_page("home");
#ifdef USE_ESP32_BLE_CLIENT
ble_tracker->dump_config();
ESP_LOGD(TAG, "Disable BLE");
#ifdef USE_BLUETOOTH_PROXY
ESP_LOGD(TAG, " Bluetooth proxy: %s", ble_proxy->has_active() ? "Active" : "Passive");
while (ble_proxy->has_active() and ble_proxy->get_bluetooth_connections_limit() != ble_proxy->get_bluetooth_connections_free()) {
ESP_LOGD(TAG, " BT proxy connections: %i of %i", int(ble_proxy->get_bluetooth_connections_limit() - ble_proxy->get_bluetooth_connections_free()), int(ble_proxy->get_bluetooth_connections_limit()));
if (ble_proxy->has_active()) {
ESP_LOGD(TAG, " BT proxy set passive mode...");
ble_proxy->set_active(false);
}
vTaskDelay(pdMS_TO_TICKS(1000));
App.feed_wdt();
}
#endif // USE_BLUETOOTH_PROXY
ESP_LOGD(TAG, " Stopping BLE Tracker scan...");
ble_tracker->stop_scan();
ESP_LOGD(TAG, " Disabling BLE Tracker scan...");
ble_tracker->set_scan_active(false);
ESP_LOGD(TAG, " Disabling BLE...");
ble_tracker->get_parent()->disable();
ble_tracker->dump_config();
#endif // USE_ESP32_BLE_CLIENT
- lambda: if (id(tft_is_valid) and current_page->state != "confirm") disp1->goto_page("home");
- delay: 2s
- script.execute: open_upload_dialog
- script.wait: open_upload_dialog