ota-hub-reactjs 0.0.16 → 0.0.19

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.
@@ -13,6 +13,10 @@ export type DeviceConnectionState = {
13
13
  uuid: string;
14
14
  deviceMac?: string;
15
15
  name: string;
16
+ /**
17
+ * Default device send helper.
18
+ * This is a utility function which may better be replaced with transport specific send functions (e.g. MQTT has publish, Serial has write etc.)
19
+ */
16
20
  send: (data: string | Uint8Array) => void | Promise<void>;
17
21
  onReceive?: (data: string | Uint8Array) => void;
18
22
  onConnect?: () => void | Promise<void>;
@@ -29,8 +33,10 @@ export type DeviceWhispererProps<T extends DeviceConnectionState> = {
29
33
  createInitialConnectionState?: (uuid: string) => Partial<T>;
30
34
  };
31
35
  export declare function MultiDeviceWhisperer<T extends DeviceConnectionState>({ createInitialConnectionState, }?: DeviceWhispererProps<T>): {
36
+ focussedConnection: string | undefined;
37
+ setFocussedConnection: import("react").Dispatch<import("react").SetStateAction<string | undefined>>;
32
38
  connections: T[];
33
- addConnection: ({ uuid, propCreator }: AddConnectionProps<T>) => Promise<string>;
39
+ addConnection: ({ uuid, propCreator, }: AddConnectionProps<T>) => Promise<string>;
34
40
  removeConnection: (uuid: string) => void;
35
41
  connect: (_uuid: string) => void;
36
42
  disconnect: (_uuid: string) => void;
@@ -1,6 +1,5 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
2
  import { useEffect, useRef, useState } from "react";
3
- ;
4
3
  // Initial, generic state for the generic device
5
4
  export function createDefaultInitialDeviceState(uuid, props) {
6
5
  return {
@@ -11,7 +10,7 @@ export function createDefaultInitialDeviceState(uuid, props) {
11
10
  logs: [],
12
11
  readBufferLeftover: "",
13
12
  readBufferLeftoverAsBytes: new Uint8Array([]),
14
- ...props
13
+ ...props,
15
14
  };
16
15
  }
17
16
  /* One Device Whisperer is used for all like-devices, such as all Serial with Protobuf.
@@ -21,6 +20,7 @@ export function MultiDeviceWhisperer({ createInitialConnectionState = createDefa
21
20
  const [connections, setConnections] = useState([]);
22
21
  const connectionsRef = useRef(new Map());
23
22
  const [isReady, setIsReady] = useState(false);
23
+ const [focussedConnection, setFocussedConnection] = useState();
24
24
  // ---------- GET ----------
25
25
  const getConnection = (uuid) => connectionsRef.current.get(uuid);
26
26
  // ---------- UPDATE ----------
@@ -44,13 +44,13 @@ export function MultiDeviceWhisperer({ createInitialConnectionState = createDefa
44
44
  }));
45
45
  };
46
46
  // ---------- ADD ----------
47
- const addConnection = async ({ uuid, propCreator }) => {
47
+ const addConnection = async ({ uuid, propCreator, }) => {
48
48
  uuid = uuid ?? `unnamed_device_${connectionsRef.current.size}`;
49
49
  const props = propCreator?.(uuid);
50
50
  const newConnection = {
51
51
  ...createDefaultInitialDeviceState(uuid),
52
52
  ...createInitialConnectionState(uuid),
53
- ...props
53
+ ...props,
54
54
  };
55
55
  connectionsRef.current.set(uuid, newConnection);
56
56
  setConnections(Array.from(connectionsRef.current.values()));
@@ -67,6 +67,8 @@ export function MultiDeviceWhisperer({ createInitialConnectionState = createDefa
67
67
  setConnections(Array.from(connectionsRef.current.values()));
68
68
  }, []);
69
69
  return {
70
+ focussedConnection,
71
+ setFocussedConnection,
70
72
  connections,
71
73
  addConnection,
72
74
  removeConnection,
@@ -79,6 +81,6 @@ export function MultiDeviceWhisperer({ createInitialConnectionState = createDefa
79
81
  appendLog,
80
82
  isReady,
81
83
  setIsReady,
82
- createInitialConnectionState
84
+ createInitialConnectionState,
83
85
  };
84
86
  }
@@ -16,9 +16,11 @@ export type ProtobufDeviceWhispererProps<AppLayer extends DeviceConnectionState,
16
16
  expectLength?: boolean;
17
17
  };
18
18
  export declare function ProtobufMultiDeviceWhisperer<AppLayer extends DeviceConnectionState, Topic extends string | number, MessageRX = any, MessageTX = any>({ transportLayer, encodeRX, decodeTX, messageTypeField, rxTopicHandlerMap, HEADER, }: ProtobufDeviceWhispererProps<AppLayer, Topic, MessageRX, MessageTX>): {
19
- addConnection: ({ uuid, propCreator }: AddConnectionProps<AppLayer>) => Promise<string>;
19
+ addConnection: ({ uuid, propCreator, }: AddConnectionProps<AppLayer>) => Promise<string>;
20
20
  sendProtobuf: (uuid: string, message: MessageTX) => void;
21
21
  protoBufOnReceiveHandler: (uuid: string, data: string | Uint8Array) => void;
22
+ focussedConnection: string | undefined;
23
+ setFocussedConnection: import("react").Dispatch<import("react").SetStateAction<string | undefined>>;
22
24
  connections: AppLayer[];
23
25
  removeConnection: (uuid: string) => void;
24
26
  connect: (_uuid: string) => void;
@@ -10,7 +10,7 @@ export function ProtobufMultiDeviceWhisperer({ transportLayer, encodeRX, decodeT
10
10
  const length = payload.length;
11
11
  const header = new Uint8Array([
12
12
  (length >> 8) & 0xff, // Most significant byte first
13
- length & 0xff // Least significant byte second
13
+ length & 0xff, // Least significant byte second
14
14
  ]);
15
15
  return concatUint8Arrays(header, payload);
16
16
  };
@@ -55,9 +55,7 @@ export function ProtobufMultiDeviceWhisperer({ transportLayer, encodeRX, decodeT
55
55
  // --- Inbound buffering ---
56
56
  const buffers = {};
57
57
  const protoBufOnReceiveHandler = (uuid, data) => {
58
- const bytes = typeof data === "string"
59
- ? new TextEncoder().encode(data)
60
- : data;
58
+ const bytes = typeof data === "string" ? new TextEncoder().encode(data) : data;
61
59
  buffers[uuid] = concatUint8Arrays(buffers[uuid] || new Uint8Array(), bytes);
62
60
  let buffer = buffers[uuid];
63
61
  while (buffer.length > 0) {
@@ -73,14 +71,14 @@ export function ProtobufMultiDeviceWhisperer({ transportLayer, encodeRX, decodeT
73
71
  catch (err) {
74
72
  transportLayer.appendLog(uuid, {
75
73
  level: 0,
76
- message: `[!] Error in handler for topic "${topic}": ${err}`
74
+ message: `[!] Error in handler for topic "${topic}": ${err}`,
77
75
  });
78
76
  }
79
77
  }
80
78
  else {
81
79
  transportLayer.appendLog(uuid, {
82
80
  level: 1,
83
- message: `[!] Unknown Protobuf topic: "${topic}"`
81
+ message: `[!] Unknown Protobuf topic: "${topic}"`,
84
82
  });
85
83
  }
86
84
  buffer = buffers[uuid];
@@ -97,7 +95,7 @@ export function ProtobufMultiDeviceWhisperer({ transportLayer, encodeRX, decodeT
97
95
  if (text) {
98
96
  transportLayer.appendLog(uuid, {
99
97
  level: 2,
100
- message: text
98
+ message: text,
101
99
  });
102
100
  }
103
101
  continue;
@@ -108,11 +106,11 @@ export function ProtobufMultiDeviceWhisperer({ transportLayer, encodeRX, decodeT
108
106
  buffers[uuid] = buffer;
109
107
  const preview = Array.from(garbage)
110
108
  .slice(0, 16)
111
- .map(b => b.toString(16).padStart(2, '0'))
112
- .join(' ');
109
+ .map((b) => b.toString(16).padStart(2, "0"))
110
+ .join(" ");
113
111
  transportLayer.appendLog(uuid, {
114
112
  level: 1,
115
- message: `[!] Skipped invalid bytes before Protobuf header: ${preview}... (${garbage.length} bytes)`
113
+ message: `[!] Skipped invalid bytes before Protobuf header: ${preview}... (${garbage.length} bytes)`,
116
114
  });
117
115
  continue;
118
116
  }
@@ -121,22 +119,22 @@ export function ProtobufMultiDeviceWhisperer({ transportLayer, encodeRX, decodeT
121
119
  buffers[uuid] = buffer;
122
120
  };
123
121
  // --- Override addConnection to wrap onReceive ---
124
- const addConnection = async ({ uuid, propCreator }) => {
122
+ const addConnection = async ({ uuid, propCreator, }) => {
125
123
  return await transportLayer.addConnection({
126
124
  uuid,
127
125
  propCreator: (id) => {
128
126
  const props = propCreator?.(id);
129
127
  return {
130
128
  onReceive: (data) => protoBufOnReceiveHandler(id, data),
131
- ...props
129
+ ...props,
132
130
  };
133
- }
131
+ },
134
132
  });
135
133
  };
136
134
  return {
137
135
  ...transportLayer,
138
136
  addConnection,
139
137
  sendProtobuf,
140
- protoBufOnReceiveHandler
138
+ protoBufOnReceiveHandler,
141
139
  };
142
140
  }
@@ -18,7 +18,7 @@ export type FlashFirmwareProps = {
18
18
  export declare function ESP32MultiDeviceWhisperer<AppOrMessageLayer extends ESP32ConnectionState>({ releasePortByDefault, ...props }?: {
19
19
  releasePortByDefault: boolean;
20
20
  } & DeviceWhispererProps<AppOrMessageLayer>): {
21
- addConnection: ({ uuid, propCreator }: AddConnectionProps<AppOrMessageLayer>) => Promise<string>;
21
+ addConnection: ({ uuid, propCreator, }: AddConnectionProps<AppOrMessageLayer>) => Promise<string>;
22
22
  removeConnection: (uuid: string) => Promise<void>;
23
23
  connect: (uuid: string, baudrate?: number, restart_on_connect?: boolean) => Promise<void>;
24
24
  disconnect: (uuid: string, timeout?: number) => Promise<void>;
@@ -27,6 +27,8 @@ export declare function ESP32MultiDeviceWhisperer<AppOrMessageLayer extends ESP3
27
27
  blob: Blob;
28
28
  address: number;
29
29
  }[]) => Promise<void>;
30
+ focussedConnection: string | undefined;
31
+ setFocussedConnection: import("react").Dispatch<import("react").SetStateAction<string | undefined>>;
30
32
  connections: AppOrMessageLayer[];
31
33
  updateConnection: (uuid: string, updater: (c: AppOrMessageLayer) => AppOrMessageLayer) => void;
32
34
  updateConnectionName: (uuid: string, name: string) => void;
@@ -1,12 +1,10 @@
1
1
  import { useEffect } from "react";
2
2
  import { ESPLoader, Transport } from "esptool-js";
3
- import { MultiDeviceWhisperer } from "../base/device-whisperer.js";
3
+ import { MultiDeviceWhisperer, } from "../base/device-whisperer.js";
4
4
  export function ESP32MultiDeviceWhisperer({ releasePortByDefault, ...props } = { releasePortByDefault: true }) {
5
5
  const base = MultiDeviceWhisperer(props);
6
6
  const defaultOnReceive = (uuid, data) => {
7
- const text = typeof data === "string"
8
- ? data
9
- : new TextDecoder().decode(data);
7
+ const text = typeof data === "string" ? data : new TextDecoder().decode(data);
10
8
  const trimmed = text.trim();
11
9
  if (!trimmed)
12
10
  return;
@@ -45,7 +43,6 @@ export function ESP32MultiDeviceWhisperer({ releasePortByDefault, ...props } = {
45
43
  console.log("Kack!");
46
44
  return;
47
45
  }
48
- ;
49
46
  const { value, done } = await reader.next();
50
47
  if (done || !value)
51
48
  break;
@@ -54,7 +51,7 @@ export function ESP32MultiDeviceWhisperer({ releasePortByDefault, ...props } = {
54
51
  const b = bytes[i];
55
52
  if (inSlipFrame) {
56
53
  // SLIP decoding
57
- if (b === 0xC0) {
54
+ if (b === 0xc0) {
58
55
  if (slipBuffer.length > 0) {
59
56
  // complete SLIP frame received
60
57
  const payload = new Uint8Array(slipBuffer);
@@ -75,10 +72,10 @@ export function ESP32MultiDeviceWhisperer({ releasePortByDefault, ...props } = {
75
72
  escapeNext = false;
76
73
  }
77
74
  else if (escapeNext) {
78
- if (b === 0xDC)
79
- slipBuffer.push(0xC0);
80
- else if (b === 0xDD)
81
- slipBuffer.push(0xDB);
75
+ if (b === 0xdc)
76
+ slipBuffer.push(0xc0);
77
+ else if (b === 0xdd)
78
+ slipBuffer.push(0xdb);
82
79
  else {
83
80
  // protocol violation: discard frame
84
81
  slipBuffer = [];
@@ -86,7 +83,7 @@ export function ESP32MultiDeviceWhisperer({ releasePortByDefault, ...props } = {
86
83
  }
87
84
  escapeNext = false;
88
85
  }
89
- else if (b === 0xDB) {
86
+ else if (b === 0xdb) {
90
87
  escapeNext = true;
91
88
  }
92
89
  else {
@@ -94,7 +91,7 @@ export function ESP32MultiDeviceWhisperer({ releasePortByDefault, ...props } = {
94
91
  }
95
92
  continue;
96
93
  }
97
- if (b === 0xC0 && conn.slipReadWrite) {
94
+ if (b === 0xc0 && conn.slipReadWrite) {
98
95
  // start of a SLIP frame
99
96
  inSlipFrame = true;
100
97
  slipBuffer = [];
@@ -102,7 +99,9 @@ export function ESP32MultiDeviceWhisperer({ releasePortByDefault, ...props } = {
102
99
  continue;
103
100
  }
104
101
  // treat as normal text (correctly)
105
- readBuffer += textDecoder.decode(new Uint8Array([b]), { stream: true });
102
+ readBuffer += textDecoder.decode(new Uint8Array([b]), {
103
+ stream: true,
104
+ });
106
105
  // check for newline
107
106
  let newlineIndex;
108
107
  while ((newlineIndex = readBuffer.indexOf("\n")) >= 0) {
@@ -149,11 +148,10 @@ export function ESP32MultiDeviceWhisperer({ releasePortByDefault, ...props } = {
149
148
  let port = conn?.port;
150
149
  if (!port) {
151
150
  port = await navigator.serial.requestPort({
152
- filters: [{ usbVendorId: 0x303a }]
151
+ filters: [{ usbVendorId: 0x303a }],
153
152
  });
154
153
  base.updateConnection(uuid, (c) => ({ ...c, port }));
155
154
  }
156
- ;
157
155
  base.updateConnection(uuid, (c) => ({ ...c, isConnecting: true }));
158
156
  const use_baudrate = baudrate ?? conn.baudrate ?? 115200;
159
157
  const transport = new Transport(port, false, false);
@@ -161,7 +159,7 @@ export function ESP32MultiDeviceWhisperer({ releasePortByDefault, ...props } = {
161
159
  const esploader = new ESPLoader({
162
160
  transport,
163
161
  baudrate: use_baudrate,
164
- enableTracing: false
162
+ enableTracing: false,
165
163
  });
166
164
  try {
167
165
  await esploader.main();
@@ -170,7 +168,6 @@ export function ESP32MultiDeviceWhisperer({ releasePortByDefault, ...props } = {
170
168
  console.log("failed to esploader.main()", e);
171
169
  return;
172
170
  }
173
- ;
174
171
  try {
175
172
  const mac = await esploader.chip.readMac(esploader);
176
173
  console.log("Mac from device:", mac);
@@ -182,7 +179,6 @@ export function ESP32MultiDeviceWhisperer({ releasePortByDefault, ...props } = {
182
179
  if (restart_on_connect) {
183
180
  await restartDevice(uuid, transport);
184
181
  }
185
- ;
186
182
  base.updateConnection(uuid, (c) => ({
187
183
  ...c,
188
184
  transport,
@@ -192,7 +188,7 @@ export function ESP32MultiDeviceWhisperer({ releasePortByDefault, ...props } = {
192
188
  }));
193
189
  base.appendLog(uuid, {
194
190
  level: 2,
195
- message: "[✓] Serial connected"
191
+ message: "[✓] Serial connected",
196
192
  });
197
193
  await conn.onConnect?.();
198
194
  await readLoop(uuid, transport);
@@ -201,11 +197,11 @@ export function ESP32MultiDeviceWhisperer({ releasePortByDefault, ...props } = {
201
197
  base.updateConnection(uuid, (c) => ({
202
198
  ...c,
203
199
  isConnected: false,
204
- isConnecting: false
200
+ isConnecting: false,
205
201
  }));
206
202
  base.appendLog(uuid, {
207
203
  level: 0,
208
- message: `[x] Serial connection error: ${err?.message || "Unknown error"}`
204
+ message: `[x] Serial connection error: ${err?.message || "Unknown error"}`,
209
205
  });
210
206
  await disconnect(uuid);
211
207
  }
@@ -235,24 +231,47 @@ export function ESP32MultiDeviceWhisperer({ releasePortByDefault, ...props } = {
235
231
  }));
236
232
  await conn?.onDisconnect?.();
237
233
  };
238
- const addConnection = async ({ uuid, propCreator }) => {
234
+ const addConnection = async ({ uuid, propCreator, }) => {
239
235
  const port = await navigator.serial.requestPort({
240
- filters: [{ usbVendorId: 0x303a }]
236
+ filters: [{ usbVendorId: 0x303a }],
241
237
  });
238
+ let deviceId = uuid;
239
+ // If no UUID provided, try to read the MAC address before registering the connection
240
+ if (!uuid) {
241
+ // 1. Interrogate the port for the MAC address BEFORE registering the connection
242
+ try {
243
+ const tempTransport = new Transport(port, false, false);
244
+ const tempLoader = new ESPLoader({
245
+ transport: tempTransport,
246
+ baudrate: 115200,
247
+ enableTracing: false,
248
+ });
249
+ await tempLoader.main();
250
+ const mac = await tempLoader.chip.readMac(tempLoader);
251
+ if (mac) {
252
+ deviceId = mac; // Swap 'unnamed_device_0' for the actual MAC
253
+ }
254
+ // Disconnect to release the port so connect() can start fresh
255
+ await tempTransport.disconnect();
256
+ }
257
+ catch (e) {
258
+ console.warn("Failed to pre-fetch MAC address. Falling back to default UUID.", e);
259
+ }
260
+ }
261
+ // 2. Register the connection using the real MAC address
242
262
  const return_uuid = await base.addConnection({
243
- uuid,
263
+ uuid: deviceId,
244
264
  propCreator: (id) => {
245
265
  const props = propCreator?.(id);
246
266
  return {
247
267
  send: (d) => defaultSend(id, d),
248
268
  onReceive: (d) => defaultOnReceive(id, d),
249
269
  port,
250
- // Initial connection state
251
270
  ...base.createInitialConnectionState(id),
252
- // From props
253
- ...props
271
+ deviceMac: deviceId, // Lock it in immediately
272
+ ...props,
254
273
  };
255
- }
274
+ },
256
275
  });
257
276
  const conn = base.getConnection(return_uuid);
258
277
  if (conn?.autoConnect)
@@ -264,11 +283,10 @@ export function ESP32MultiDeviceWhisperer({ releasePortByDefault, ...props } = {
264
283
  await disconnect(uuid);
265
284
  }
266
285
  catch (e) { }
267
- ;
268
286
  base.removeConnection(uuid);
269
287
  };
270
288
  const reconnectAll = async (...connectionProps) => {
271
- const connectionIds = base.connections.map(c => c.uuid);
289
+ const connectionIds = base.connections.map((c) => c.uuid);
272
290
  await Promise.all(connectionIds.map(async (id) => {
273
291
  const c = base.getConnection(id);
274
292
  if (!c)
@@ -284,14 +302,19 @@ export function ESP32MultiDeviceWhisperer({ releasePortByDefault, ...props } = {
284
302
  if (!conn || !conn.port || assetsToFlash.length === 0)
285
303
  return;
286
304
  await disconnect(uuid);
287
- base.updateConnection(uuid, (c) => ({ ...c, isFlashing: true, flashProgress: 0, flashError: undefined }));
305
+ base.updateConnection(uuid, (c) => ({
306
+ ...c,
307
+ isFlashing: true,
308
+ flashProgress: 0,
309
+ flashError: undefined,
310
+ }));
288
311
  try {
289
312
  // --- Connect ONCE ---
290
313
  const transport = new Transport(conn.port, true);
291
314
  const esploader = new ESPLoader({
292
315
  transport,
293
316
  baudrate: 921600,
294
- enableTracing: false
317
+ enableTracing: false,
295
318
  });
296
319
  try {
297
320
  await esploader.main();
@@ -300,7 +323,6 @@ export function ESP32MultiDeviceWhisperer({ releasePortByDefault, ...props } = {
300
323
  console.log("failed to esploader.main()", e);
301
324
  return;
302
325
  }
303
- ;
304
326
  // --- Prepare an ARRAY of files for the library ---
305
327
  const fileArray = await Promise.all(assetsToFlash.map(async ({ blob, address }) => {
306
328
  const arrayBuffer = await blob.arrayBuffer();
@@ -320,7 +342,10 @@ export function ESP32MultiDeviceWhisperer({ releasePortByDefault, ...props } = {
320
342
  // You can enhance progress reporting to show which file is being flashed
321
343
  const progress = (written / total) * 100;
322
344
  console.log(`Flashing file ${fileIndex + 1}/${fileArray.length}: ${progress.toFixed(1)}%`);
323
- base.updateConnection(uuid, (c) => ({ ...c, flashProgress: progress }));
345
+ base.updateConnection(uuid, (c) => ({
346
+ ...c,
347
+ flashProgress: progress,
348
+ }));
324
349
  },
325
350
  };
326
351
  // --- Call writeFlash ONCE with all files ---
@@ -331,7 +356,6 @@ export function ESP32MultiDeviceWhisperer({ releasePortByDefault, ...props } = {
331
356
  catch (e) {
332
357
  console.log("failed to esploader.writeFlash", e);
333
358
  }
334
- ;
335
359
  // --- Disconnect ---
336
360
  await esploader.after();
337
361
  try {
@@ -343,7 +367,11 @@ export function ESP32MultiDeviceWhisperer({ releasePortByDefault, ...props } = {
343
367
  await conn.port?.writable?.close();
344
368
  await conn.port?.close();
345
369
  }
346
- base.updateConnection(uuid, (c) => ({ ...c, isFlashing: false, flashProgress: 100 }));
370
+ base.updateConnection(uuid, (c) => ({
371
+ ...c,
372
+ isFlashing: false,
373
+ flashProgress: 100,
374
+ }));
347
375
  }
348
376
  catch (e) {
349
377
  console.error(`[${uuid}] Flashing failed:`, e);
@@ -364,6 +392,6 @@ export function ESP32MultiDeviceWhisperer({ releasePortByDefault, ...props } = {
364
392
  connect,
365
393
  disconnect,
366
394
  reconnectAll,
367
- handleFlashFirmware
395
+ handleFlashFirmware,
368
396
  };
369
397
  }
@@ -1,10 +1,21 @@
1
1
  import { DeviceConnectionState, AddConnectionProps, DeviceWhispererProps } from "../base/device-whisperer.js";
2
+ type MQTTPayload = string | Uint8Array | ArrayBuffer;
3
+ type MQTTTopicCallback = (payload: MQTTPayload, topic: string) => void;
2
4
  export type MQTTConnectionState = DeviceConnectionState & {
5
+ /**
6
+ * Publishes a payload to any explicit MQTT topic.
7
+ */
8
+ publish?: (topic: string, payload: MQTTPayload) => void | Promise<void>;
9
+ /**
10
+ * Subscribes a callback for a specific topic. Returns an unsubscribe function.
11
+ */
12
+ subscribeCallbackToTopic?: (topic: string, callback: MQTTTopicCallback) => () => void;
3
13
  pingFunction?: (props?: any) => void;
4
14
  touchHeartbeat?: () => void;
5
15
  };
6
- export declare function MQTTMultiDeviceWhisperer<AppOrMessageLayer extends MQTTConnectionState>({ serverUrl, uuidFromMessage, subTopicFromUuid, pubTopicFromUuid, serverPort, clientId, username, password, serverAutoConnect, serverConnectOn, ...props }: {
7
- serverUrl: string;
16
+ export declare function MQTTMultiDeviceWhisperer<AppOrMessageLayer extends MQTTConnectionState>({ serverUrl, serverUrlFnc, uuidFromMessage, subTopicFromUuid, pubTopicFromUuid, serverPort, clientId, username, password, serverAutoConnect, serverConnectOn, enableWatchdog, ...props }: {
17
+ serverUrl?: string;
18
+ serverUrlFnc?: () => Promise<string> | string;
8
19
  uuidFromMessage: (topic: string, payload: Buffer<ArrayBufferLike>) => string;
9
20
  subTopicFromUuid?: (uuid: string) => string;
10
21
  pubTopicFromUuid?: (uuid: string) => string;
@@ -14,13 +25,16 @@ export declare function MQTTMultiDeviceWhisperer<AppOrMessageLayer extends MQTTC
14
25
  password?: string;
15
26
  serverAutoConnect?: boolean;
16
27
  serverConnectOn?: boolean;
28
+ enableWatchdog?: boolean;
17
29
  } & DeviceWhispererProps<AppOrMessageLayer>): {
18
- addConnection: ({ uuid, propCreator }: AddConnectionProps<AppOrMessageLayer>) => Promise<string | undefined>;
30
+ addConnection: ({ uuid, propCreator, }: AddConnectionProps<AppOrMessageLayer>) => Promise<string>;
19
31
  removeConnection: (uuid: string) => Promise<void>;
20
32
  connect: (uuid: string) => Promise<void>;
21
33
  disconnect: (uuid: string) => Promise<void>;
22
34
  reconnectAll: () => Promise<void>;
23
- connectToMQTTServer: () => (() => void) | undefined;
35
+ connectToMQTTServer: () => Promise<void>;
36
+ focussedConnection: string | undefined;
37
+ setFocussedConnection: import("react").Dispatch<import("react").SetStateAction<string | undefined>>;
24
38
  connections: AppOrMessageLayer[];
25
39
  updateConnection: (uuid: string, updater: (c: AppOrMessageLayer) => AppOrMessageLayer) => void;
26
40
  updateConnectionName: (uuid: string, name: string) => void;
@@ -30,3 +44,4 @@ export declare function MQTTMultiDeviceWhisperer<AppOrMessageLayer extends MQTTC
30
44
  setIsReady: import("react").Dispatch<import("react").SetStateAction<boolean>>;
31
45
  createInitialConnectionState: (uuid: string) => Partial<AppOrMessageLayer>;
32
46
  };
47
+ export {};