flash works when not in EXE
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -37,3 +37,4 @@ dependencies.lock
|
|||||||
|
|
||||||
managed_components
|
managed_components
|
||||||
components
|
components
|
||||||
|
output
|
||||||
@@ -3,14 +3,27 @@
|
|||||||
|
|
||||||
block_cipher = None
|
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(
|
a = Analysis(
|
||||||
['web_flasher.py'],
|
['web_flasher.py'],
|
||||||
pathex=[],
|
pathex=[],
|
||||||
binaries=[],
|
binaries=[],
|
||||||
datas=[
|
datas=datas_list,
|
||||||
('templates', 'templates'),
|
|
||||||
('static', 'static'),
|
|
||||||
],
|
|
||||||
hiddenimports=[
|
hiddenimports=[
|
||||||
'serial.tools.list_ports',
|
'serial.tools.list_ports',
|
||||||
'flask',
|
'flask',
|
||||||
@@ -19,6 +32,10 @@ a = Analysis(
|
|||||||
'flask_socketio',
|
'flask_socketio',
|
||||||
'socketio',
|
'socketio',
|
||||||
'engineio.async_drivers.threading',
|
'engineio.async_drivers.threading',
|
||||||
|
'esptool',
|
||||||
|
'esptool.cmds',
|
||||||
|
'esptool.loader',
|
||||||
|
'esptool.util',
|
||||||
],
|
],
|
||||||
hookspath=[],
|
hookspath=[],
|
||||||
hooksconfig={},
|
hooksconfig={},
|
||||||
|
|||||||
@@ -298,7 +298,7 @@
|
|||||||
<p class="subtitle">Firmware Flasher</p>
|
<p class="subtitle">Firmware Flasher</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<form id="flashForm">
|
<form id="flashForm" onsubmit="return false;">
|
||||||
<div class="port-section">
|
<div class="port-section">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="port">Serial Port</label>
|
<label for="port">Serial Port</label>
|
||||||
@@ -444,6 +444,8 @@
|
|||||||
|
|
||||||
document.getElementById('flashForm').addEventListener('submit', async (e) => {
|
document.getElementById('flashForm').addEventListener('submit', async (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
e.stopImmediatePropagation();
|
||||||
|
|
||||||
const flashBtn = document.getElementById('flashBtn');
|
const flashBtn = document.getElementById('flashBtn');
|
||||||
const progressBar = document.getElementById('progressBar');
|
const progressBar = document.getElementById('progressBar');
|
||||||
|
|||||||
@@ -579,16 +579,11 @@ static void filter_inquiry_scan_result(esp_bt_gap_cb_param_t *param)
|
|||||||
// Add to device list for GUI
|
// Add to device list for GUI
|
||||||
add_device_to_list(param->disc_res.bda, (char *)s_peer_bdname, false, rssi);
|
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);
|
bda_str, s_peer_bdname);
|
||||||
|
|
||||||
// Don't automatically connect to discovered devices - just save them to NVS
|
// Don't automatically connect - just continue discovering more devices
|
||||||
// The old code would set s_a2d_state = APP_AV_STATE_DISCOVERED and connect
|
// User will manually select a device from the menu to 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();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -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 */
|
/* when discovery state changed, this event comes */
|
||||||
case ESP_BT_GAP_DISC_STATE_CHANGED_EVT: {
|
case ESP_BT_GAP_DISC_STATE_CHANGED_EVT: {
|
||||||
if (param->disc_st_chg.state == ESP_BT_GAP_DISCOVERY_STOPPED) {
|
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) {
|
if (s_a2d_state == APP_AV_STATE_DISCOVERED) {
|
||||||
s_a2d_state = APP_AV_STATE_CONNECTING;
|
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);
|
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);
|
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) {
|
} else if (param->disc_st_chg.state == ESP_BT_GAP_DISCOVERY_STARTED) {
|
||||||
ESP_LOGI(BT_AV_TAG, "Discovery started.");
|
ESP_LOGI(BT_AV_TAG, "Discovery started.");
|
||||||
|
s_device_list.discovery_active = true;
|
||||||
}
|
}
|
||||||
break;
|
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
|
// Print list of saved devices from NVS
|
||||||
bt_debug_print_known_devices();
|
bt_debug_print_known_devices();
|
||||||
|
|
||||||
// Try to connect to all known devices sequentially
|
// Try to connect to known devices automatically (those we've connected to before)
|
||||||
esp_err_t connect_ret = bt_try_connect_all_known_devices();
|
esp_err_t connect_ret = bt_try_connect_known_devices();
|
||||||
if (connect_ret != ESP_OK) {
|
if (connect_ret != ESP_OK) {
|
||||||
// No known devices found, start discovery to find new devices
|
// No known devices found - stay in unconnected state
|
||||||
ESP_LOGI(BT_AV_TAG, "No known devices found, starting discovery...");
|
// Don't start discovery automatically - user must do it from menu
|
||||||
s_a2d_state = APP_AV_STATE_DISCOVERING;
|
ESP_LOGI(BT_AV_TAG, "No previously connected devices found. User can discover devices from menu.");
|
||||||
esp_bt_gap_start_discovery(ESP_BT_INQ_MODE_GENERAL_INQUIRY, 10, 0);
|
s_a2d_state = APP_AV_STATE_UNCONNECTED;
|
||||||
} else {
|
} 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 */
|
/* 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:
|
case ESP_A2D_MEDIA_CTRL_ACK_EVT:
|
||||||
break;
|
break;
|
||||||
case BT_APP_HEART_BEAT_EVT: {
|
case BT_APP_HEART_BEAT_EVT: {
|
||||||
// Try to connect to known devices, or start discovery if none available
|
// Don't automatically try to reconnect - wait for user to select device
|
||||||
esp_err_t connect_ret = bt_try_connect_all_known_devices();
|
// from the menu
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ESP_A2D_REPORT_SNK_DELAY_VALUE_EVT: {
|
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
|
// Update connection timestamp for this device
|
||||||
system_updateConnectionTimestamp(s_peer_bda);
|
system_updateConnectionTimestamp(s_peer_bda);
|
||||||
} else if (a2d->conn_stat.state == ESP_A2D_CONNECTION_STATE_DISCONNECTED) {
|
} else if (a2d->conn_stat.state == ESP_A2D_CONNECTION_STATE_DISCONNECTED) {
|
||||||
ESP_LOGI(BT_AV_TAG, "Connection failed, trying next device...");
|
ESP_LOGI(BT_AV_TAG, "Connection failed.");
|
||||||
// Try next known device before giving up
|
// If device was previously connected (known device), don't retry automatically
|
||||||
esp_err_t next_ret = bt_try_next_known_device();
|
// User can manually reconnect from menu
|
||||||
if (next_ret != ESP_OK) {
|
s_a2d_state = APP_AV_STATE_UNCONNECTED;
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
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.
|
* when connecting lasts more than 2 heart beat intervals.
|
||||||
*/
|
*/
|
||||||
if (++s_connecting_intv >= 2) {
|
if (++s_connecting_intv >= 2) {
|
||||||
ESP_LOGI(BT_AV_TAG, "Connection timeout, trying next device...");
|
ESP_LOGI(BT_AV_TAG, "Connection timeout.");
|
||||||
// Try next known device before giving up
|
// Return to unconnected state - don't retry automatically
|
||||||
esp_err_t next_ret = bt_try_next_known_device();
|
// User can manually reconnect from menu
|
||||||
if (next_ret != ESP_OK) {
|
|
||||||
// No more devices to try, go to unconnected state
|
|
||||||
s_a2d_state = APP_AV_STATE_UNCONNECTED;
|
s_a2d_state = APP_AV_STATE_UNCONNECTED;
|
||||||
}
|
|
||||||
s_connecting_intv = 0;
|
s_connecting_intv = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
2888
sdkconfig.old
Normal file
2888
sdkconfig.old
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user