1
0
Fork 0
mirror of https://github.com/betaflight/betaflight-configurator.git synced 2025-07-24 00:35:26 +03:00

Add websocket support and fix port override (#4187)

* Add websocket support

* remove waitforconnection
This commit is contained in:
Mark Haslinghuis 2024-10-03 20:03:06 +02:00 committed by GitHub
parent 6908b7efb8
commit 36ccc26acc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 182 additions and 17 deletions

View file

@ -107,7 +107,6 @@ function connectDisconnect() {
GUI.configuration_loaded = false;
const baudRate = PortHandler.portPicker.selectedBauds;
const selectedPort = portName;
if (!isConnected) {
// prevent connection when we do not have permission
@ -124,6 +123,7 @@ function connectDisconnect() {
CONFIGURATOR.virtualMode = selectedPort === 'virtual';
CONFIGURATOR.bluetoothMode = selectedPort.startsWith('bluetooth');
CONFIGURATOR.manualMode = selectedPort === 'manual';
if (CONFIGURATOR.virtualMode) {
CONFIGURATOR.virtualApiVersion = PortHandler.portPicker.virtualMspVersion;
@ -131,6 +131,16 @@ function connectDisconnect() {
// Hack to get virtual working on the web
serial = serialShim();
serial.connect(onOpenVirtual);
} else if (selectedPort === 'manual') {
serial = serialShim();
// Explicitly disconnect the event listeners before attaching the new ones.
serial.removeEventListener('connect', connectHandler);
serial.addEventListener('connect', connectHandler);
serial.removeEventListener('disconnect', disconnectHandler);
serial.addEventListener('disconnect', disconnectHandler);
serial.connect(portName, { baudRate });
} else {
CONFIGURATOR.virtualMode = false;
serial = serialShim();