ota-hub-reactjs 0.0.10 → 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -137,20 +137,13 @@ export function ESP32MultiDeviceWhisperer({ ...props } = {}) {
137
137
  level: 0,
138
138
  message: `[!] Read loop error: ${e}`,
139
139
  });
140
- await disconnect(uuid);
141
140
  }
142
141
  finally {
143
- base.updateConnection(uuid, (c) => ({
144
- ...c,
145
- transport: null,
146
- isConnected: false,
147
- isConnecting: false,
148
- autoConnect: false,
149
- }));
150
142
  base.appendLog(uuid, {
151
143
  level: 0,
152
144
  message: "[!] Serial disconnected",
153
145
  });
146
+ await disconnect(uuid);
154
147
  }
155
148
  };
156
149
  const restartDevice = async (uuid, default_transport) => {
@@ -168,15 +161,19 @@ export function ESP32MultiDeviceWhisperer({ ...props } = {}) {
168
161
  };
169
162
  const connect = async (uuid, baudrate, restart_on_connect = true) => {
170
163
  const conn = base.getConnection(uuid);
171
- if (!conn?.port)
164
+ if (!conn)
172
165
  return;
173
- if (!conn?.transport) {
174
- await disconnect(uuid);
166
+ let port = conn?.port;
167
+ if (!port) {
168
+ port = await navigator.serial.requestPort({
169
+ filters: [{ usbVendorId: 0x303a }]
170
+ });
171
+ base.updateConnection(uuid, (c) => ({ ...c, port }));
175
172
  }
176
173
  ;
177
174
  base.updateConnection(uuid, (c) => ({ ...c, isConnecting: true }));
178
175
  const use_baudrate = baudrate ?? conn.baudrate ?? 115200;
179
- const transport = new Transport(conn.port, false, false);
176
+ const transport = new Transport(port, false, false);
180
177
  try {
181
178
  const esploader = new ESPLoader({
182
179
  transport,
@@ -247,6 +244,7 @@ export function ESP32MultiDeviceWhisperer({ ...props } = {}) {
247
244
  // Always clear the transport and reset connection state
248
245
  base.updateConnection(uuid, (c) => ({
249
246
  ...c,
247
+ port: null,
250
248
  transport: null,
251
249
  isConnected: false,
252
250
  isConnecting: false,
@@ -292,7 +290,7 @@ export function ESP32MultiDeviceWhisperer({ ...props } = {}) {
292
290
  const conn = base.getConnection(uuid);
293
291
  if (!conn || !conn.port || assetsToFlash.length === 0)
294
292
  return;
295
- await base.disconnect(uuid);
293
+ await disconnect(uuid);
296
294
  base.updateConnection(uuid, (c) => ({ ...c, isFlashing: true, flashProgress: 0, flashError: undefined }));
297
295
  try {
298
296
  // --- Connect ONCE ---
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ota-hub-reactjs",
3
- "version": "0.0.10",
3
+ "version": "0.0.11",
4
4
  "description": "ReactJS tools for building web apps to flash MCU devices such as esp32, brought to you by OTA Hub.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",