@@ -30,9 +30,6 @@ class Serial extends EventTarget {
30
30
virtual : this . _virtual ,
31
31
} ;
32
32
33
- // Initialize with default protocol
34
- this . selectProtocol ( false ) ;
35
-
36
33
// Forward events from all protocols to the Serial class
37
34
this . _setupEventForwarding ( ) ;
38
35
}
@@ -114,59 +111,28 @@ class Serial extends EventTarget {
114
111
}
115
112
116
113
/**
117
- * Selects the appropriate protocol based on port path or CONFIGURATOR settings
114
+ * Selects the appropriate protocol based on port path
118
115
* @param {string|null } portPath - Optional port path to determine protocol
119
116
* @param {boolean } forceDisconnect - Whether to force disconnect from current protocol
120
117
*/
121
118
selectProtocol ( portPath = null , forceDisconnect = true ) {
122
- // Determine which protocol to use based on port path first, then fall back to CONFIGURATOR
119
+ // Determine which protocol to use based on port path
123
120
let newProtocol ;
124
121
125
122
if ( portPath ) {
126
123
// Select protocol based on port path
127
124
if ( portPath === "virtual" ) {
128
125
console . log ( `${ this . logHead } Using virtual protocol (based on port path)` ) ;
129
126
newProtocol = this . _virtual ;
130
- // Update CONFIGURATOR flags for consistency
131
- CONFIGURATOR . virtualMode = true ;
132
- CONFIGURATOR . bluetoothMode = false ;
133
- CONFIGURATOR . manualMode = false ;
134
127
} else if ( portPath === "manual" ) {
135
128
console . log ( `${ this . logHead } Using websocket protocol (based on port path)` ) ;
136
129
newProtocol = this . _websocket ;
137
- // Update CONFIGURATOR flags for consistency
138
- CONFIGURATOR . virtualMode = false ;
139
- CONFIGURATOR . bluetoothMode = false ;
140
- CONFIGURATOR . manualMode = true ;
141
130
} else if ( portPath . startsWith ( "bluetooth" ) ) {
142
131
console . log ( `${ this . logHead } Using bluetooth protocol (based on port path: ${ portPath } )` ) ;
143
132
newProtocol = this . _bluetooth ;
144
- // Update CONFIGURATOR flags for consistency
145
- CONFIGURATOR . virtualMode = false ;
146
- CONFIGURATOR . bluetoothMode = true ;
147
- CONFIGURATOR . manualMode = false ;
148
133
} else {
149
134
console . log ( `${ this . logHead } Using web serial protocol (based on port path: ${ portPath } )` ) ;
150
135
newProtocol = this . _webSerial ;
151
- // Update CONFIGURATOR flags for consistency
152
- CONFIGURATOR . virtualMode = false ;
153
- CONFIGURATOR . bluetoothMode = false ;
154
- CONFIGURATOR . manualMode = false ;
155
- }
156
- } else {
157
- // Fall back to CONFIGURATOR flags if no port path is provided
158
- if ( CONFIGURATOR . virtualMode ) {
159
- console . log ( `${ this . logHead } Using virtual protocol (based on CONFIGURATOR flags)` ) ;
160
- newProtocol = this . _virtual ;
161
- } else if ( CONFIGURATOR . manualMode ) {
162
- console . log ( `${ this . logHead } Using websocket protocol (based on CONFIGURATOR flags)` ) ;
163
- newProtocol = this . _websocket ;
164
- } else if ( CONFIGURATOR . bluetoothMode ) {
165
- console . log ( `${ this . logHead } Using bluetooth protocol (based on CONFIGURATOR flags)` ) ;
166
- newProtocol = this . _bluetooth ;
167
- } else {
168
- console . log ( `${ this . logHead } Using web serial protocol (based on CONFIGURATOR flags)` ) ;
169
- newProtocol = this . _webSerial ;
170
136
}
171
137
}
172
138
@@ -184,8 +150,6 @@ class Serial extends EventTarget {
184
150
// Set new protocol
185
151
this . _protocol = newProtocol ;
186
152
console . log ( `${ this . logHead } Protocol switched successfully to:` , this . _protocol ) ;
187
- } else {
188
- console . log ( `${ this . logHead } Same protocol selected, no switch needed` ) ;
189
153
}
190
154
191
155
return this . _protocol ;
@@ -251,8 +215,6 @@ class Serial extends EventTarget {
251
215
return false ;
252
216
}
253
217
254
- console . log ( `${ this . logHead } Disconnecting from current protocol` , this . _protocol ) ;
255
-
256
218
try {
257
219
// Handle case where we're already disconnected
258
220
if ( ! this . _protocol . connected ) {
0 commit comments