flash works when not in EXE

This commit is contained in:
Brent Perteet
2025-10-25 11:29:53 -05:00
parent bca2f6ea9c
commit fe69dc6f19
5 changed files with 2942 additions and 57 deletions

1
.gitignore vendored
View File

@@ -37,3 +37,4 @@ dependencies.lock
managed_components
components
output

View File

@@ -3,14 +3,27 @@
block_cipher = None
import os
import sys
# Hardcode the venv esptool path since PyInstaller might run from different env
esptool_dir = os.path.join(os.path.dirname(SPECPATH), 'venv', 'Lib', 'site-packages', 'esptool')
# Build datas list - include all esptool data files
datas_list = [
('templates', 'templates'),
('static', 'static'),
]
# Add esptool targets directory (includes stub_flasher JSON files)
if os.path.exists(os.path.join(esptool_dir, 'targets')):
datas_list.append((os.path.join(esptool_dir, 'targets'), 'esptool/targets'))
a = Analysis(
['web_flasher.py'],
pathex=[],
binaries=[],
datas=[
('templates', 'templates'),
('static', 'static'),
],
datas=datas_list,
hiddenimports=[
'serial.tools.list_ports',
'flask',
@@ -19,6 +32,10 @@ a = Analysis(
'flask_socketio',
'socketio',
'engineio.async_drivers.threading',
'esptool',
'esptool.cmds',
'esptool.loader',
'esptool.util',
],
hookspath=[],
hooksconfig={},

View File

@@ -298,7 +298,7 @@
<p class="subtitle">Firmware Flasher</p>
</div>
<form id="flashForm">
<form id="flashForm" onsubmit="return false;">
<div class="port-section">
<div class="form-group">
<label for="port">Serial Port</label>
@@ -444,6 +444,8 @@
document.getElementById('flashForm').addEventListener('submit', async (e) => {
e.preventDefault();
e.stopPropagation();
e.stopImmediatePropagation();
const flashBtn = document.getElementById('flashBtn');
const progressBar = document.getElementById('progressBar');

View File

@@ -579,16 +579,11 @@ static void filter_inquiry_scan_result(esp_bt_gap_cb_param_t *param)
// Add to device list for GUI
add_device_to_list(param->disc_res.bda, (char *)s_peer_bdname, false, rssi);
ESP_LOGI(BT_AV_TAG, "Found audio device, address %s, name %s (saved to NVS, not connecting)",
ESP_LOGI(BT_AV_TAG, "Found audio device, address %s, name %s (added to list)",
bda_str, s_peer_bdname);
// Don't automatically connect to discovered devices - just save them to NVS
// The old code would set s_a2d_state = APP_AV_STATE_DISCOVERED and connect
// Now we just continue discovery to find more devices
s_a2d_state = APP_AV_STATE_DISCOVERED;
memcpy(s_peer_bda, param->disc_res.bda, ESP_BD_ADDR_LEN);
ESP_LOGI(BT_AV_TAG, "Cancel device discovery ...");
esp_bt_gap_cancel_discovery();
// Don't automatically connect - just continue discovering more devices
// User will manually select a device from the menu to connect
}
}
@@ -605,20 +600,18 @@ static void bt_app_gap_cb(esp_bt_gap_cb_event_t event, esp_bt_gap_cb_param_t *pa
/* when discovery state changed, this event comes */
case ESP_BT_GAP_DISC_STATE_CHANGED_EVT: {
if (param->disc_st_chg.state == ESP_BT_GAP_DISCOVERY_STOPPED) {
ESP_LOGI(BT_AV_TAG, "Device discovery stopped.");
s_device_list.discovery_active = false;
// Don't automatically connect - wait for user selection
// Only connect if we're in DISCOVERED state (manually triggered by bt_connect_device)
if (s_a2d_state == APP_AV_STATE_DISCOVERED) {
s_a2d_state = APP_AV_STATE_CONNECTING;
ESP_LOGI(BT_AV_TAG, "Device discovery stopped.");
ESP_LOGI(BT_AV_TAG, "a2dp connecting to peer: %s", s_peer_bdname);
/* connect source to peer device specified by Bluetooth Device Address */
esp_a2d_source_connect(s_peer_bda);
} else {
/* not discovered, continue to discover */
ESP_LOGI(BT_AV_TAG, "Device discovery failed, continue to discover...");
s_a2d_state = APP_AV_STATE_UNCONNECTED;
//esp_bt_gap_start_discovery(ESP_BT_INQ_MODE_GENERAL_INQUIRY, 10, 0);
}
} else if (param->disc_st_chg.state == ESP_BT_GAP_DISCOVERY_STARTED) {
ESP_LOGI(BT_AV_TAG, "Discovery started.");
s_device_list.discovery_active = true;
}
break;
}
@@ -717,15 +710,15 @@ static void bt_av_hdl_stack_evt(uint16_t event, void *p_param)
// Print list of saved devices from NVS
bt_debug_print_known_devices();
// Try to connect to all known devices sequentially
esp_err_t connect_ret = bt_try_connect_all_known_devices();
// Try to connect to known devices automatically (those we've connected to before)
esp_err_t connect_ret = bt_try_connect_known_devices();
if (connect_ret != ESP_OK) {
// No known devices found, start discovery to find new devices
ESP_LOGI(BT_AV_TAG, "No known devices found, starting discovery...");
s_a2d_state = APP_AV_STATE_DISCOVERING;
esp_bt_gap_start_discovery(ESP_BT_INQ_MODE_GENERAL_INQUIRY, 10, 0);
// No known devices found - stay in unconnected state
// Don't start discovery automatically - user must do it from menu
ESP_LOGI(BT_AV_TAG, "No previously connected devices found. User can discover devices from menu.");
s_a2d_state = APP_AV_STATE_UNCONNECTED;
} else {
ESP_LOGI(BT_AV_TAG, "Attempting to connect to known devices...");
ESP_LOGI(BT_AV_TAG, "Attempting to connect to previously connected device...");
}
/* create and start heart beat timer */
@@ -1082,15 +1075,8 @@ static void bt_app_av_state_unconnected_hdlr(uint16_t event, void *param)
case ESP_A2D_MEDIA_CTRL_ACK_EVT:
break;
case BT_APP_HEART_BEAT_EVT: {
// Try to connect to known devices, or start discovery if none available
esp_err_t connect_ret = bt_try_connect_all_known_devices();
if (connect_ret != ESP_OK) {
// No known devices, start discovery
ESP_LOGI(BT_AV_TAG, "No known devices available, starting discovery...");
s_a2d_state = APP_AV_STATE_DISCOVERING;
esp_bt_gap_start_discovery(ESP_BT_INQ_MODE_GENERAL_INQUIRY, 10, 0);
}
// Don't automatically try to reconnect - wait for user to select device
// from the menu
break;
}
case ESP_A2D_REPORT_SNK_DELAY_VALUE_EVT: {
@@ -1121,16 +1107,10 @@ static void bt_app_av_state_connecting_hdlr(uint16_t event, void *param)
// Update connection timestamp for this device
system_updateConnectionTimestamp(s_peer_bda);
} else if (a2d->conn_stat.state == ESP_A2D_CONNECTION_STATE_DISCONNECTED) {
ESP_LOGI(BT_AV_TAG, "Connection failed, trying next device...");
// Try next known device before giving up
esp_err_t next_ret = bt_try_next_known_device();
if (next_ret != ESP_OK) {
// No more devices to try, go to unconnected state
//s_a2d_state = APP_AV_STATE_UNCONNECTED;
ESP_LOGI(BT_AV_TAG, "No known devices available, starting discovery...");
s_a2d_state = APP_AV_STATE_DISCOVERING;
esp_bt_gap_start_discovery(ESP_BT_INQ_MODE_GENERAL_INQUIRY, 10, 0);
}
ESP_LOGI(BT_AV_TAG, "Connection failed.");
// If device was previously connected (known device), don't retry automatically
// User can manually reconnect from menu
s_a2d_state = APP_AV_STATE_UNCONNECTED;
}
break;
}
@@ -1144,13 +1124,10 @@ static void bt_app_av_state_connecting_hdlr(uint16_t event, void *param)
* when connecting lasts more than 2 heart beat intervals.
*/
if (++s_connecting_intv >= 2) {
ESP_LOGI(BT_AV_TAG, "Connection timeout, trying next device...");
// Try next known device before giving up
esp_err_t next_ret = bt_try_next_known_device();
if (next_ret != ESP_OK) {
// No more devices to try, go to unconnected state
ESP_LOGI(BT_AV_TAG, "Connection timeout.");
// Return to unconnected state - don't retry automatically
// User can manually reconnect from menu
s_a2d_state = APP_AV_STATE_UNCONNECTED;
}
s_connecting_intv = 0;
}
break;

2888
sdkconfig.old Normal file

File diff suppressed because it is too large Load Diff