divoom-timesgate-sdk 0.1.0
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.
- package/LICENSE +21 -0
- package/README.md +371 -0
- package/dist/common-D8oHDNi6.d.cts +54 -0
- package/dist/common-D8oHDNi6.d.ts +54 -0
- package/dist/image/index.cjs +515 -0
- package/dist/image/index.cjs.map +1 -0
- package/dist/image/index.d.cts +279 -0
- package/dist/image/index.d.ts +279 -0
- package/dist/image/index.js +498 -0
- package/dist/image/index.js.map +1 -0
- package/dist/index.cjs +1021 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +921 -0
- package/dist/index.d.ts +921 -0
- package/dist/index.js +991 -0
- package/dist/index.js.map +1 -0
- package/package.json +87 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,921 @@
|
|
|
1
|
+
import { F as FetchLike, D as DivoomBaseResponse, P as PanelIndex, a as DivoomCommandRequest, L as LcdArray } from './common-D8oHDNi6.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The HTTP transport that every command flows through. It builds the request
|
|
5
|
+
* URL, injects the `LocalToken`, enforces timeouts, retries transient failures
|
|
6
|
+
* with exponential backoff, and maps failures onto the SDK's typed
|
|
7
|
+
* {@link DivoomError | error hierarchy}.
|
|
8
|
+
*
|
|
9
|
+
* @packageDocumentation
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/** Configuration for the {@link HttpTransport}. */
|
|
13
|
+
interface TransportOptions {
|
|
14
|
+
/** The device's IP address or hostname, e.g. `"192.168.1.50"`. */
|
|
15
|
+
host: string;
|
|
16
|
+
/** TCP port. Defaults to `80` (hardware version 400). */
|
|
17
|
+
port?: number;
|
|
18
|
+
/** Request path. Defaults to `"/post"` (hardware version 400). */
|
|
19
|
+
path?: string;
|
|
20
|
+
/** URL scheme. Defaults to `"http"`. */
|
|
21
|
+
protocol?: 'http' | 'https';
|
|
22
|
+
/**
|
|
23
|
+
* The device's local authentication token, read from the Divoom app
|
|
24
|
+
* (device → Settings). Injected into every request body. Defaults to `0`,
|
|
25
|
+
* which is accepted by read-only commands but rejected by commands that
|
|
26
|
+
* require authentication (e.g. `Channel/SetBrightness`).
|
|
27
|
+
*/
|
|
28
|
+
localToken?: number;
|
|
29
|
+
/** Per-request timeout in milliseconds. Defaults to `8000`. */
|
|
30
|
+
timeoutMs?: number;
|
|
31
|
+
/** Number of automatic retries for transient failures. Defaults to `2`. */
|
|
32
|
+
retries?: number;
|
|
33
|
+
/** Base backoff delay in milliseconds (doubled each retry). Defaults to `300`. */
|
|
34
|
+
retryDelayMs?: number;
|
|
35
|
+
/** A custom `fetch` implementation. Defaults to the global `fetch`. */
|
|
36
|
+
fetch?: FetchLike;
|
|
37
|
+
/** Extra HTTP headers to send with every request. */
|
|
38
|
+
headers?: Record<string, string>;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Low-level HTTP transport. Most users interact with the high-level
|
|
42
|
+
* {@link TimesGateClient} instead, but the transport is exported for advanced
|
|
43
|
+
* scenarios and testing.
|
|
44
|
+
*/
|
|
45
|
+
declare class HttpTransport {
|
|
46
|
+
/** The fully-resolved endpoint URL every request is POSTed to. */
|
|
47
|
+
readonly endpoint: string;
|
|
48
|
+
private readonly localToken;
|
|
49
|
+
private readonly timeoutMs;
|
|
50
|
+
private readonly retries;
|
|
51
|
+
private readonly retryDelayMs;
|
|
52
|
+
private readonly fetchImpl;
|
|
53
|
+
private readonly headers;
|
|
54
|
+
constructor(options: TransportOptions);
|
|
55
|
+
/**
|
|
56
|
+
* Sends a command payload to the device and returns the parsed response.
|
|
57
|
+
*
|
|
58
|
+
* The configured `LocalToken` is merged in automatically (an explicit
|
|
59
|
+
* `LocalToken` on the payload wins). Transient network errors, timeouts, and
|
|
60
|
+
* 5xx responses are retried with exponential backoff; device-level errors and
|
|
61
|
+
* 4xx responses are thrown immediately.
|
|
62
|
+
*
|
|
63
|
+
* @typeParam TResponse - The expected response shape.
|
|
64
|
+
* @throws {@link DivoomTimeoutError} when the request exceeds the timeout.
|
|
65
|
+
* @throws {@link DivoomHttpError} on a non-2xx HTTP status.
|
|
66
|
+
* @throws {@link DivoomDeviceError} when the device reports a non-zero `error_code`.
|
|
67
|
+
* @throws {@link DivoomConnectionError} when the device cannot be reached.
|
|
68
|
+
*/
|
|
69
|
+
send<TResponse extends DivoomBaseResponse = DivoomBaseResponse>(payload: {
|
|
70
|
+
Command: string;
|
|
71
|
+
} & Record<string, unknown>): Promise<TResponse>;
|
|
72
|
+
private attempt;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Animation & on-device text commands: play stored Divoom GIFs, stream GIF URLs
|
|
77
|
+
* (uniformly or per-panel), overlay scrolling text, and compose data-rich item
|
|
78
|
+
* lists.
|
|
79
|
+
*
|
|
80
|
+
* @packageDocumentation
|
|
81
|
+
*/
|
|
82
|
+
|
|
83
|
+
/** Text scroll direction. */
|
|
84
|
+
type TextDirection = 'left' | 'right';
|
|
85
|
+
/** Horizontal text alignment. */
|
|
86
|
+
type TextAlign = 'left' | 'center' | 'right';
|
|
87
|
+
/** Options for {@link AnimationCommands.sendText} (`Draw/SendHttpText`). */
|
|
88
|
+
interface SendTextOptions {
|
|
89
|
+
/** Unique text id (reused id replaces the text). Must be < 20. Defaults to `1`. */
|
|
90
|
+
textId?: number;
|
|
91
|
+
/** X start position. Defaults to `0`. */
|
|
92
|
+
x?: number;
|
|
93
|
+
/** Y start position. Defaults to `40`. */
|
|
94
|
+
y?: number;
|
|
95
|
+
/** Scroll direction. Defaults to `"left"`. */
|
|
96
|
+
direction?: TextDirection;
|
|
97
|
+
/** App animation font, 0–7. Defaults to `4`. */
|
|
98
|
+
font?: number;
|
|
99
|
+
/** Text area width in points (16–64). Defaults to `56`. */
|
|
100
|
+
width?: number;
|
|
101
|
+
/** Scroll speed: ms per step. Defaults to `100`. */
|
|
102
|
+
speed?: number;
|
|
103
|
+
/** Hex color, e.g. `"#FFFF00"`. Defaults to `"#FFFFFF"`. */
|
|
104
|
+
color?: string;
|
|
105
|
+
/** Horizontal alignment. Defaults to `"left"`. */
|
|
106
|
+
align?: TextAlign;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* A single element in a {@link AnimationCommands.sendItemList} composition.
|
|
110
|
+
* Field names/casing match the device protocol verbatim (including the
|
|
111
|
+
* misspelled `Textheight`).
|
|
112
|
+
*/
|
|
113
|
+
interface DisplayItem {
|
|
114
|
+
/** Unique id for in-place replacement (max 40). */
|
|
115
|
+
TextId: number;
|
|
116
|
+
/** Display type: 1–21 = data fields, 22 = static text, 23 = URL text. */
|
|
117
|
+
type: number;
|
|
118
|
+
/** Horizontal start position. */
|
|
119
|
+
x: number;
|
|
120
|
+
/** Vertical start position. */
|
|
121
|
+
y: number;
|
|
122
|
+
/** Scroll direction: `0` = left, `1` = right. */
|
|
123
|
+
dir?: number;
|
|
124
|
+
/** Font id from {@link DivoomCloudClient.getFontList}. */
|
|
125
|
+
font?: number;
|
|
126
|
+
/** Text area width in pixels. */
|
|
127
|
+
TextWidth?: number;
|
|
128
|
+
/** Text area height in pixels (protocol spelling). */
|
|
129
|
+
Textheight?: number;
|
|
130
|
+
/** Text (type 22) or URL (type 23); UTF-8, max 512 chars. */
|
|
131
|
+
TextString?: string;
|
|
132
|
+
/** Scroll speed in ms per step. */
|
|
133
|
+
speed?: number;
|
|
134
|
+
/** Hex color, e.g. `"#FFFF00"`. */
|
|
135
|
+
color?: string;
|
|
136
|
+
/** Refresh interval in seconds (type 23). */
|
|
137
|
+
update_time?: number;
|
|
138
|
+
/** Alignment: `1` = left, `2` = center, `3` = right (firmware ≥ 90102). */
|
|
139
|
+
align?: number;
|
|
140
|
+
}
|
|
141
|
+
/** Options for {@link AnimationCommands.sendItemList}. */
|
|
142
|
+
interface SendItemListOptions {
|
|
143
|
+
/** `true` (default) replaces all items; `false` appends. */
|
|
144
|
+
replace?: boolean;
|
|
145
|
+
/** Optional background GIF URL for the panel. */
|
|
146
|
+
backgroundGif?: string;
|
|
147
|
+
}
|
|
148
|
+
/** Animation & on-device text commands. Access via {@link TimesGateClient.animation}. */
|
|
149
|
+
declare class AnimationCommands {
|
|
150
|
+
private readonly transport;
|
|
151
|
+
constructor(transport: HttpTransport);
|
|
152
|
+
/**
|
|
153
|
+
* Plays a stored Divoom GIF (by `FileId`) on the given panels
|
|
154
|
+
* (`Draw/SendRemote`). Obtain `fileId` from
|
|
155
|
+
* {@link DivoomCloudClient.getLikedImages} or
|
|
156
|
+
* {@link DivoomCloudClient.getUploadedImages}.
|
|
157
|
+
*/
|
|
158
|
+
playStoredGif(panels: PanelIndex[], fileId: string): Promise<DivoomBaseResponse>;
|
|
159
|
+
/**
|
|
160
|
+
* Plays one or more GIF URLs on the given panels (`Device/PlayGif`).
|
|
161
|
+
*
|
|
162
|
+
* @param urls - Up to 10 GIF URLs (dimensions 16/32/64/128).
|
|
163
|
+
*/
|
|
164
|
+
playGifUrls(panels: PanelIndex[], urls: string[]): Promise<DivoomBaseResponse>;
|
|
165
|
+
/**
|
|
166
|
+
* Plays a distinct list of GIF URLs on each panel (`Device/PlayGifLCDs`).
|
|
167
|
+
*
|
|
168
|
+
* @param perPanel - GIF URL lists keyed by panel index (0–4).
|
|
169
|
+
*
|
|
170
|
+
* @example
|
|
171
|
+
* ```ts
|
|
172
|
+
* await client.animation.playGifPerPanel({
|
|
173
|
+
* 0: ['http://f.divoom-gz.com/Kirby.gif'],
|
|
174
|
+
* 1: ['http://f.divoom-gz.com/loz.gif'],
|
|
175
|
+
* });
|
|
176
|
+
* ```
|
|
177
|
+
*/
|
|
178
|
+
playGifPerPanel(perPanel: Partial<Record<PanelIndex, string[]>>): Promise<DivoomBaseResponse>;
|
|
179
|
+
/**
|
|
180
|
+
* Overlays a single scrolling/aligned text string on a panel
|
|
181
|
+
* (`Draw/SendHttpText`).
|
|
182
|
+
*
|
|
183
|
+
* @param panel - Panel index 0–4.
|
|
184
|
+
* @param text - UTF-8 string (< 512 chars).
|
|
185
|
+
*/
|
|
186
|
+
sendText(panel: PanelIndex, text: string, options?: SendTextOptions): Promise<DivoomBaseResponse>;
|
|
187
|
+
/**
|
|
188
|
+
* Composes a panel from a list of display items — static text, live data
|
|
189
|
+
* fields, and URL-backed text — over an optional background GIF
|
|
190
|
+
* (`Draw/SendHttpItemList`).
|
|
191
|
+
*
|
|
192
|
+
* @param panel - Panel index 0–4.
|
|
193
|
+
* @param items - The display elements to render.
|
|
194
|
+
*/
|
|
195
|
+
sendItemList(panel: PanelIndex, items: DisplayItem[], options?: SendItemListOptions): Promise<DivoomBaseResponse>;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Batch-execution commands: run several commands in one request, or have the
|
|
200
|
+
* device fetch a command list from a URL. Requires firmware ≥ 90102.
|
|
201
|
+
*
|
|
202
|
+
* @packageDocumentation
|
|
203
|
+
*/
|
|
204
|
+
|
|
205
|
+
/** Batch-execution commands. Access via {@link TimesGateClient.batch}. */
|
|
206
|
+
declare class BatchCommands {
|
|
207
|
+
private readonly transport;
|
|
208
|
+
constructor(transport: HttpTransport);
|
|
209
|
+
/**
|
|
210
|
+
* Runs multiple commands in sequence in a single request (`Draw/CommandList`).
|
|
211
|
+
*
|
|
212
|
+
* @example
|
|
213
|
+
* ```ts
|
|
214
|
+
* await client.batch.run([
|
|
215
|
+
* { Command: 'Channel/SetBrightness', Brightness: 100 },
|
|
216
|
+
* { Command: 'Channel/OnOffScreen', OnOff: 1 },
|
|
217
|
+
* ]);
|
|
218
|
+
* ```
|
|
219
|
+
*/
|
|
220
|
+
run(commands: DivoomCommandRequest[]): Promise<DivoomBaseResponse>;
|
|
221
|
+
/**
|
|
222
|
+
* Tells the device to fetch and execute a command-array file from a URL
|
|
223
|
+
* (`Draw/UseHTTPCommandSource`).
|
|
224
|
+
*/
|
|
225
|
+
useCommandSource(commandUrl: string): Promise<DivoomBaseResponse>;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Dial / channel-control commands (device-side). These switch what each panel
|
|
230
|
+
* displays — a single "whole" dial spanning all five panels, or independent
|
|
231
|
+
* per-panel sub-dials and visualizers.
|
|
232
|
+
*
|
|
233
|
+
* Discovering the `ClockId` / `LcdIndependence` values these methods need is a
|
|
234
|
+
* cloud operation — see {@link DivoomCloudClient}.
|
|
235
|
+
*
|
|
236
|
+
* @packageDocumentation
|
|
237
|
+
*/
|
|
238
|
+
|
|
239
|
+
/** Channel/dial display mode. `whole` spans all panels; `independent` is per-panel. */
|
|
240
|
+
type ChannelMode = 'whole' | 'independent';
|
|
241
|
+
/** Response from {@link DialCommands.getIndex} (`Channel/GetIndex`). */
|
|
242
|
+
interface GetIndexResponse extends DivoomBaseResponse {
|
|
243
|
+
/**
|
|
244
|
+
* The currently-selected channel index. On Pixoo-class devices:
|
|
245
|
+
* `0` = Faces/Clock, `1` = Cloud, `2` = Visualizer/EQ, `3` = Custom.
|
|
246
|
+
*/
|
|
247
|
+
SelectIndex: number;
|
|
248
|
+
}
|
|
249
|
+
/** Dial-control commands. Access via {@link TimesGateClient.dial}. */
|
|
250
|
+
declare class DialCommands {
|
|
251
|
+
private readonly transport;
|
|
252
|
+
constructor(transport: HttpTransport);
|
|
253
|
+
/**
|
|
254
|
+
* Selects a "whole" dial that spans all five panels
|
|
255
|
+
* (`Channel/Set5LcdWholeClockId`).
|
|
256
|
+
*
|
|
257
|
+
* @param clockId - A whole-dial id from
|
|
258
|
+
* {@link DivoomCloudClient.getWholeDialList}.
|
|
259
|
+
*/
|
|
260
|
+
selectWholeDial(clockId: number): Promise<DivoomBaseResponse>;
|
|
261
|
+
/**
|
|
262
|
+
* Switches between whole and independent dial modes
|
|
263
|
+
* (`Channel/Set5LcdChannelType`).
|
|
264
|
+
*
|
|
265
|
+
* @param mode - `"whole"` (one dial across all panels) or `"independent"`.
|
|
266
|
+
* @param lcdIndependence - Required for `"independent"` mode; the group id from
|
|
267
|
+
* {@link DivoomCloudClient.getChannelInfo}.
|
|
268
|
+
*/
|
|
269
|
+
setChannelMode(mode: ChannelMode, lcdIndependence?: number): Promise<DivoomBaseResponse>;
|
|
270
|
+
/**
|
|
271
|
+
* Selects a sub-dial for a single panel (`Channel/SetClockSelectId`).
|
|
272
|
+
*
|
|
273
|
+
* @param panel - Panel index 0–4.
|
|
274
|
+
* @param clockId - A sub-dial id from {@link DivoomCloudClient.getDialList}.
|
|
275
|
+
* @param lcdIndependence - The group id from {@link DivoomCloudClient.getChannelInfo}.
|
|
276
|
+
*/
|
|
277
|
+
selectSubDial(panel: PanelIndex, clockId: number, lcdIndependence: number): Promise<DivoomBaseResponse>;
|
|
278
|
+
/**
|
|
279
|
+
* Selects a sub-visualizer (EQ) component for a panel
|
|
280
|
+
* (`Channel/SetEqPosition`).
|
|
281
|
+
*
|
|
282
|
+
* @param panel - Panel index 0–4.
|
|
283
|
+
* @param eqPosition - Visualizer index, starting at 0.
|
|
284
|
+
* @param lcdIndependence - The group id from {@link DivoomCloudClient.getChannelInfo}.
|
|
285
|
+
*/
|
|
286
|
+
selectVisualizer(panel: PanelIndex, eqPosition: number, lcdIndependence: number): Promise<DivoomBaseResponse>;
|
|
287
|
+
/** Reads the currently-selected channel index (`Channel/GetIndex`). */
|
|
288
|
+
getIndex(): Promise<GetIndexResponse>;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* The image pipeline: push base64-encoded frames to panels (`Draw/SendHttpGif`),
|
|
293
|
+
* manage the device's frame cache (`Draw/ResetHttpGifId`), and query the current
|
|
294
|
+
* PicID (`Draw/GetHttpGifId`).
|
|
295
|
+
*
|
|
296
|
+
* PicIDs must strictly increase or the device caches a stale frame; this class
|
|
297
|
+
* manages them automatically while still letting you override when needed.
|
|
298
|
+
*
|
|
299
|
+
* @packageDocumentation
|
|
300
|
+
*/
|
|
301
|
+
|
|
302
|
+
/** The raw `Draw/SendHttpGif` payload (minus `Command`), for full manual control. */
|
|
303
|
+
interface SendHttpGifRequest {
|
|
304
|
+
/** 5-element panel mask (`1` = draw, `0` = skip). */
|
|
305
|
+
LcdArray: LcdArray;
|
|
306
|
+
/** Total frame count in the animation (must be < 60). */
|
|
307
|
+
PicNum: number;
|
|
308
|
+
/** Frame pixel dimension. The Times Gate accepts `128`. */
|
|
309
|
+
PicWidth: number;
|
|
310
|
+
/** Zero-based frame index (`0`…`PicNum-1`). */
|
|
311
|
+
PicOffset: number;
|
|
312
|
+
/** Unique, strictly-increasing animation id. */
|
|
313
|
+
PicID: number;
|
|
314
|
+
/** Per-frame playback duration, in milliseconds. */
|
|
315
|
+
PicSpeed: number;
|
|
316
|
+
/** Base64-encoded JPEG/PNG frame data. */
|
|
317
|
+
PicData: string;
|
|
318
|
+
}
|
|
319
|
+
/** Options for {@link DrawCommands.sendImage} / {@link DrawCommands.sendImageToPanels}. */
|
|
320
|
+
interface SendImageOptions {
|
|
321
|
+
/** Frame pixel dimension. Defaults to `128`. */
|
|
322
|
+
picWidth?: number;
|
|
323
|
+
/** Playback duration in ms (irrelevant for a single still). Defaults to `1000`. */
|
|
324
|
+
picSpeed?: number;
|
|
325
|
+
/** Override the auto-generated PicID. */
|
|
326
|
+
picId?: number;
|
|
327
|
+
}
|
|
328
|
+
/** Options for {@link DrawCommands.sendAnimation}. */
|
|
329
|
+
interface SendAnimationOptions {
|
|
330
|
+
/** Frame pixel dimension. Defaults to `128`. */
|
|
331
|
+
picWidth?: number;
|
|
332
|
+
/** Per-frame duration in ms. Defaults to `100`. */
|
|
333
|
+
picSpeed?: number;
|
|
334
|
+
/** Override the auto-generated PicID (shared by every frame). */
|
|
335
|
+
picId?: number;
|
|
336
|
+
}
|
|
337
|
+
/** Response from {@link DrawCommands.getPicId} (`Draw/GetHttpGifId`). */
|
|
338
|
+
interface GetPicIdResponse extends DivoomBaseResponse {
|
|
339
|
+
/** The device's current picture/animation id. */
|
|
340
|
+
PicId: number;
|
|
341
|
+
}
|
|
342
|
+
/** Image-pipeline commands. Access via {@link TimesGateClient.draw}. */
|
|
343
|
+
declare class DrawCommands {
|
|
344
|
+
private readonly transport;
|
|
345
|
+
private readonly picIds;
|
|
346
|
+
constructor(transport: HttpTransport, picIdSeed?: number);
|
|
347
|
+
/**
|
|
348
|
+
* Pushes a single still image to one panel.
|
|
349
|
+
*
|
|
350
|
+
* @param panel - Panel index 0–4.
|
|
351
|
+
* @param picData - Base64-encoded JPEG/PNG (e.g. {@link EncodedFrame.data}).
|
|
352
|
+
*
|
|
353
|
+
* @example
|
|
354
|
+
* ```ts
|
|
355
|
+
* import { encodePanel } from 'divoom-timesgate-sdk/image';
|
|
356
|
+
* const frame = await encodePanel('./cover.jpg');
|
|
357
|
+
* await client.draw.sendImage(0, frame.data);
|
|
358
|
+
* ```
|
|
359
|
+
*/
|
|
360
|
+
sendImage(panel: PanelIndex, picData: string, options?: SendImageOptions): Promise<DivoomBaseResponse>;
|
|
361
|
+
/**
|
|
362
|
+
* Pushes the same still image to several panels at once.
|
|
363
|
+
*
|
|
364
|
+
* @param panels - Panel indices to target.
|
|
365
|
+
* @param picData - Base64-encoded JPEG/PNG.
|
|
366
|
+
*/
|
|
367
|
+
sendImageToPanels(panels: PanelIndex[], picData: string, options?: SendImageOptions): Promise<DivoomBaseResponse>;
|
|
368
|
+
/**
|
|
369
|
+
* Pushes a multi-frame animation to one or more panels. Each frame is sent as
|
|
370
|
+
* a separate `Draw/SendHttpGif` request sharing one PicID, per the protocol.
|
|
371
|
+
*
|
|
372
|
+
* @param panels - Panel indices to target.
|
|
373
|
+
* @param frames - Base64-encoded frames, in order (1–59 frames).
|
|
374
|
+
* @returns One response per frame.
|
|
375
|
+
*/
|
|
376
|
+
sendAnimation(panels: PanelIndex[], frames: string[], options?: SendAnimationOptions): Promise<DivoomBaseResponse[]>;
|
|
377
|
+
/** Sends a fully-specified `Draw/SendHttpGif` frame — maximum control. */
|
|
378
|
+
sendFrame(request: SendHttpGifRequest): Promise<DivoomBaseResponse>;
|
|
379
|
+
/** Clears the device's image cache and resets the PicID counter (`Draw/ResetHttpGifId`). */
|
|
380
|
+
resetCache(): Promise<DivoomBaseResponse>;
|
|
381
|
+
/** Reads the device's current PicID (`Draw/GetHttpGifId`). */
|
|
382
|
+
getPicId(): Promise<number>;
|
|
383
|
+
/** Returns the next locally-generated, strictly-increasing PicID. */
|
|
384
|
+
nextPicId(panel?: PanelIndex): number;
|
|
385
|
+
private pushStill;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* System-setting commands: brightness, screen power, time, time zone, weather
|
|
390
|
+
* location, display modes, and the device's current configuration/weather.
|
|
391
|
+
*
|
|
392
|
+
* @packageDocumentation
|
|
393
|
+
*/
|
|
394
|
+
|
|
395
|
+
/** Temperature unit for {@link SystemCommands.setTemperatureMode}. */
|
|
396
|
+
type TemperatureUnit = 'celsius' | 'fahrenheit';
|
|
397
|
+
/** Response from {@link SystemCommands.getAllConfig} (`Channel/GetAllConf`). */
|
|
398
|
+
interface GetAllConfigResponse extends DivoomBaseResponse {
|
|
399
|
+
/** System brightness, 0–100. */
|
|
400
|
+
Brightness: number;
|
|
401
|
+
/** `1` if the device rotates between faces and GIFs. */
|
|
402
|
+
RotationFlag: number;
|
|
403
|
+
/** The configured date format, e.g. `"YYYY-MM-DD"`. */
|
|
404
|
+
DateFormat: string;
|
|
405
|
+
/** `1` for 24-hour clock, `0` for 12-hour. */
|
|
406
|
+
Time24Flag: number;
|
|
407
|
+
/** `0` for Celsius, `1` for Fahrenheit. */
|
|
408
|
+
TemperatureMode: number;
|
|
409
|
+
/** `1` if mirror mode is enabled. */
|
|
410
|
+
MirrorFlag: number;
|
|
411
|
+
/** `1` if the screen is on. */
|
|
412
|
+
LightSwitch: number;
|
|
413
|
+
}
|
|
414
|
+
/** Response from {@link SystemCommands.getDeviceTime} (`Device/GetDeviceTime`). */
|
|
415
|
+
interface GetDeviceTimeResponse extends DivoomBaseResponse {
|
|
416
|
+
/** Device time as a UTC epoch (seconds). */
|
|
417
|
+
UTCTime: number;
|
|
418
|
+
/** Device local time, e.g. `"2022-03-14 03:40:28"`. */
|
|
419
|
+
LocalTime: string;
|
|
420
|
+
}
|
|
421
|
+
/** Response from {@link SystemCommands.getWeather} (`Device/GetWeatherInfo`). */
|
|
422
|
+
interface GetWeatherResponse extends DivoomBaseResponse {
|
|
423
|
+
/** Condition text, e.g. `"Sunny"`, `"Cloudy"`. */
|
|
424
|
+
Weather: string;
|
|
425
|
+
/** Current temperature, in the device's configured unit. */
|
|
426
|
+
CurTemp: number;
|
|
427
|
+
/** Minimum temperature. */
|
|
428
|
+
MinTemp: number;
|
|
429
|
+
/** Maximum temperature. */
|
|
430
|
+
MaxTemp: number;
|
|
431
|
+
/** Atmospheric pressure (hPa). */
|
|
432
|
+
Pressure: number;
|
|
433
|
+
/** Relative humidity (%). */
|
|
434
|
+
Humidity: number;
|
|
435
|
+
/** Visibility (metres). */
|
|
436
|
+
Visibility: number;
|
|
437
|
+
/** Wind speed (m/s). */
|
|
438
|
+
WindSpeed: number;
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* System-setting commands. Access via {@link TimesGateClient.system}.
|
|
442
|
+
*
|
|
443
|
+
* @remarks Several of these settings (temperature mode, mirror mode, hour mode)
|
|
444
|
+
* are not persisted by the device and reset on power-off.
|
|
445
|
+
*/
|
|
446
|
+
declare class SystemCommands {
|
|
447
|
+
private readonly transport;
|
|
448
|
+
constructor(transport: HttpTransport);
|
|
449
|
+
/** Sets the LCD brightness (`Channel/SetBrightness`). @param brightness 0–100. */
|
|
450
|
+
setBrightness(brightness: number): Promise<DivoomBaseResponse>;
|
|
451
|
+
/** Reads every device setting (`Channel/GetAllConf`). */
|
|
452
|
+
getAllConfig(): Promise<GetAllConfigResponse>;
|
|
453
|
+
/** Turns the screen on or off (`Channel/OnOffScreen`). */
|
|
454
|
+
setScreen(on: boolean): Promise<DivoomBaseResponse>;
|
|
455
|
+
/**
|
|
456
|
+
* Sets the weather location (`Sys/LogAndLat`). Coordinates drive the on-device
|
|
457
|
+
* weather readout.
|
|
458
|
+
*/
|
|
459
|
+
setWeatherLocation(longitude: number | string, latitude: number | string): Promise<DivoomBaseResponse>;
|
|
460
|
+
/** Sets the time zone (`Sys/TimeZone`). @param timeZone e.g. `"GMT-5"`. */
|
|
461
|
+
setTimeZone(timeZone: string): Promise<DivoomBaseResponse>;
|
|
462
|
+
/**
|
|
463
|
+
* Sets the system clock (`Device/SetUTC`).
|
|
464
|
+
*
|
|
465
|
+
* @param time - A `Date` or a UTC epoch in **seconds**.
|
|
466
|
+
*/
|
|
467
|
+
setSystemTime(time: Date | number): Promise<DivoomBaseResponse>;
|
|
468
|
+
/** Reads the device's UTC and local time (`Device/GetDeviceTime`). */
|
|
469
|
+
getDeviceTime(): Promise<GetDeviceTimeResponse>;
|
|
470
|
+
/** Sets the temperature unit (`Device/SetDisTempMode`). */
|
|
471
|
+
setTemperatureMode(unit: TemperatureUnit): Promise<DivoomBaseResponse>;
|
|
472
|
+
/** Enables or disables mirror mode (`Device/SetMirrorMode`). */
|
|
473
|
+
setMirrorMode(enabled: boolean): Promise<DivoomBaseResponse>;
|
|
474
|
+
/** Selects 24-hour (`true`) or 12-hour (`false`) clock (`Device/SetTime24Flag`). */
|
|
475
|
+
setHourMode(use24Hour: boolean): Promise<DivoomBaseResponse>;
|
|
476
|
+
/** Reads the current on-device weather (`Device/GetWeatherInfo`). */
|
|
477
|
+
getWeather(): Promise<GetWeatherResponse>;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
/**
|
|
481
|
+
* Built-in tool commands: countdown timer, stopwatch, scoreboard, noise meter,
|
|
482
|
+
* and the buzzer.
|
|
483
|
+
*
|
|
484
|
+
* @packageDocumentation
|
|
485
|
+
*/
|
|
486
|
+
|
|
487
|
+
/** Stopwatch action for {@link ToolCommands.setStopwatch}. */
|
|
488
|
+
type StopwatchAction = 'start' | 'stop' | 'reset';
|
|
489
|
+
/** Options for {@link ToolCommands.playBuzzer}. */
|
|
490
|
+
interface BuzzerOptions {
|
|
491
|
+
/** On-time per cycle, in milliseconds. Defaults to `500`. */
|
|
492
|
+
activeMs?: number;
|
|
493
|
+
/** Off-time per cycle, in milliseconds. Defaults to `500`. */
|
|
494
|
+
offMs?: number;
|
|
495
|
+
/** Total duration to buzz, in milliseconds. Defaults to `1000`. */
|
|
496
|
+
totalMs?: number;
|
|
497
|
+
}
|
|
498
|
+
/** Built-in tool commands. Access via {@link TimesGateClient.tool}. */
|
|
499
|
+
declare class ToolCommands {
|
|
500
|
+
private readonly transport;
|
|
501
|
+
constructor(transport: HttpTransport);
|
|
502
|
+
/**
|
|
503
|
+
* Starts or stops a countdown timer (`Tools/SetTimer`).
|
|
504
|
+
*
|
|
505
|
+
* @param minutes - Countdown minutes (0–99).
|
|
506
|
+
* @param seconds - Countdown seconds (0–59).
|
|
507
|
+
* @param start - `true` to start, `false` to stop. Defaults to `true`.
|
|
508
|
+
*/
|
|
509
|
+
setCountdown(minutes: number, seconds: number, start?: boolean): Promise<DivoomBaseResponse>;
|
|
510
|
+
/** Controls the stopwatch (`Tools/SetStopWatch`). */
|
|
511
|
+
setStopwatch(action: StopwatchAction): Promise<DivoomBaseResponse>;
|
|
512
|
+
/**
|
|
513
|
+
* Sets the scoreboard (`Tools/SetScoreBoard`).
|
|
514
|
+
*
|
|
515
|
+
* @param redScore - Red team score (0–999).
|
|
516
|
+
* @param blueScore - Blue team score (0–999).
|
|
517
|
+
*/
|
|
518
|
+
setScoreboard(redScore: number, blueScore: number): Promise<DivoomBaseResponse>;
|
|
519
|
+
/** Starts or stops the noise meter (`Tools/SetNoiseStatus`). */
|
|
520
|
+
setNoiseMeter(start: boolean): Promise<DivoomBaseResponse>;
|
|
521
|
+
/**
|
|
522
|
+
* Plays the buzzer (`Device/PlayBuzzer`). Requires firmware ≥ 90109.
|
|
523
|
+
*
|
|
524
|
+
* @example
|
|
525
|
+
* ```ts
|
|
526
|
+
* await client.tool.playBuzzer({ activeMs: 200, offMs: 100, totalMs: 900 });
|
|
527
|
+
* ```
|
|
528
|
+
*/
|
|
529
|
+
playBuzzer(options?: BuzzerOptions): Promise<DivoomBaseResponse>;
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
/**
|
|
533
|
+
* The high-level {@link TimesGateClient} — one object that exposes every
|
|
534
|
+
* device-side command, grouped by area, over a single configured transport.
|
|
535
|
+
*
|
|
536
|
+
* @packageDocumentation
|
|
537
|
+
*/
|
|
538
|
+
|
|
539
|
+
/** Options for constructing a {@link TimesGateClient}. */
|
|
540
|
+
interface TimesGateClientOptions extends TransportOptions {
|
|
541
|
+
/**
|
|
542
|
+
* Optional seed for the PicID generator used by {@link TimesGateClient.draw}.
|
|
543
|
+
* Mostly useful for deterministic tests.
|
|
544
|
+
*/
|
|
545
|
+
picIdSeed?: number;
|
|
546
|
+
}
|
|
547
|
+
/**
|
|
548
|
+
* The main entry point for controlling a Times Gate on your local network.
|
|
549
|
+
*
|
|
550
|
+
* @example
|
|
551
|
+
* ```ts
|
|
552
|
+
* import { TimesGateClient } from 'divoom-timesgate-sdk';
|
|
553
|
+
*
|
|
554
|
+
* const client = new TimesGateClient({
|
|
555
|
+
* host: '192.168.1.50',
|
|
556
|
+
* localToken: 229930, // from the Divoom app → device → Settings
|
|
557
|
+
* });
|
|
558
|
+
*
|
|
559
|
+
* if (await client.ping()) {
|
|
560
|
+
* await client.system.setBrightness(80);
|
|
561
|
+
* }
|
|
562
|
+
* ```
|
|
563
|
+
*/
|
|
564
|
+
declare class TimesGateClient {
|
|
565
|
+
/** The underlying HTTP transport. */
|
|
566
|
+
readonly transport: HttpTransport;
|
|
567
|
+
/** System settings: brightness, screen, time, weather, display modes. */
|
|
568
|
+
readonly system: SystemCommands;
|
|
569
|
+
/** Dial/channel control: whole vs independent dials, sub-dials, visualizers. */
|
|
570
|
+
readonly dial: DialCommands;
|
|
571
|
+
/** Built-in tools: countdown, stopwatch, scoreboard, noise meter, buzzer. */
|
|
572
|
+
readonly tool: ToolCommands;
|
|
573
|
+
/** The image pipeline: push frames/animations, manage the device cache. */
|
|
574
|
+
readonly draw: DrawCommands;
|
|
575
|
+
/** Animations & text: stored GIFs, GIF URLs, text overlays, item lists. */
|
|
576
|
+
readonly animation: AnimationCommands;
|
|
577
|
+
/** Batch execution: run multiple commands or a remote command list. */
|
|
578
|
+
readonly batch: BatchCommands;
|
|
579
|
+
constructor(options: TimesGateClientOptions);
|
|
580
|
+
/** The resolved endpoint URL this client talks to. */
|
|
581
|
+
get endpoint(): string;
|
|
582
|
+
/**
|
|
583
|
+
* Sends a raw command payload — an escape hatch for commands the typed API
|
|
584
|
+
* doesn't cover yet. The configured `LocalToken` is still injected.
|
|
585
|
+
*/
|
|
586
|
+
send<TResponse extends DivoomBaseResponse = DivoomBaseResponse>(payload: {
|
|
587
|
+
Command: string;
|
|
588
|
+
} & Record<string, unknown>): Promise<TResponse>;
|
|
589
|
+
/**
|
|
590
|
+
* Checks whether the device is reachable by issuing `Channel/GetIndex`.
|
|
591
|
+
* Returns `false` instead of throwing on failure.
|
|
592
|
+
*/
|
|
593
|
+
ping(): Promise<boolean>;
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
/**
|
|
597
|
+
* The Divoom **cloud** API client (`app.divoom-gz.com`). These endpoints don't
|
|
598
|
+
* touch your device directly — they discover the `ClockId`, `FileId`, and font
|
|
599
|
+
* ids you then feed to on-device {@link DialCommands} / {@link AnimationCommands}.
|
|
600
|
+
*
|
|
601
|
+
* Cloud responses use `ReturnCode` (0 = success) rather than `error_code`.
|
|
602
|
+
*
|
|
603
|
+
* @packageDocumentation
|
|
604
|
+
*/
|
|
605
|
+
|
|
606
|
+
/** Default Divoom cloud base URL. */
|
|
607
|
+
declare const DEFAULT_CLOUD_BASE_URL = "https://app.divoom-gz.com";
|
|
608
|
+
/** Base shape of every Divoom cloud response. */
|
|
609
|
+
interface CloudResponse {
|
|
610
|
+
/** `0` indicates success. */
|
|
611
|
+
ReturnCode: number;
|
|
612
|
+
/** Human-readable status message. */
|
|
613
|
+
ReturnMessage?: string;
|
|
614
|
+
[key: string]: unknown;
|
|
615
|
+
}
|
|
616
|
+
/** Configuration for {@link DivoomCloudClient} and {@link cloudPost}. */
|
|
617
|
+
interface CloudClientOptions {
|
|
618
|
+
/** Cloud base URL. Defaults to {@link DEFAULT_CLOUD_BASE_URL}. */
|
|
619
|
+
baseUrl?: string;
|
|
620
|
+
/** Custom `fetch`. Defaults to the global `fetch`. */
|
|
621
|
+
fetch?: FetchLike;
|
|
622
|
+
/** Per-request timeout in ms. Defaults to `10000`. */
|
|
623
|
+
timeoutMs?: number;
|
|
624
|
+
/** Retry count for transient failures. Defaults to `2`. */
|
|
625
|
+
retries?: number;
|
|
626
|
+
/** Base backoff in ms (doubled per retry). Defaults to `300`. */
|
|
627
|
+
retryDelayMs?: number;
|
|
628
|
+
/** Extra HTTP headers. */
|
|
629
|
+
headers?: Record<string, string>;
|
|
630
|
+
}
|
|
631
|
+
/** A liked/uploaded image entry. */
|
|
632
|
+
interface CloudImage {
|
|
633
|
+
/** Display name. */
|
|
634
|
+
FileName: string;
|
|
635
|
+
/** File identifier — pass to {@link AnimationCommands.playStoredGif}. */
|
|
636
|
+
FileId: string;
|
|
637
|
+
}
|
|
638
|
+
/** A sub-dial entry from {@link DivoomCloudClient.getDialList}. */
|
|
639
|
+
interface SubDial {
|
|
640
|
+
/** Dial identifier. */
|
|
641
|
+
ClockId: number;
|
|
642
|
+
/** Display name. */
|
|
643
|
+
Name: string;
|
|
644
|
+
}
|
|
645
|
+
/** A whole-dial entry from {@link DivoomCloudClient.getWholeDialList}. */
|
|
646
|
+
interface WholeDial {
|
|
647
|
+
/** Dial identifier. */
|
|
648
|
+
ClockId: number;
|
|
649
|
+
/** Display name. */
|
|
650
|
+
ClockName: string;
|
|
651
|
+
/** Description. */
|
|
652
|
+
ClockExPlain: string;
|
|
653
|
+
}
|
|
654
|
+
/** A font entry from {@link DivoomCloudClient.getFontList}. */
|
|
655
|
+
interface CloudFont {
|
|
656
|
+
/** Font id — use as `font` in {@link DisplayItem}. */
|
|
657
|
+
id: number;
|
|
658
|
+
/** Font name. */
|
|
659
|
+
name: string;
|
|
660
|
+
/** Glyph width. */
|
|
661
|
+
width: string;
|
|
662
|
+
/** Glyph height. */
|
|
663
|
+
high: string;
|
|
664
|
+
/** Included character set. */
|
|
665
|
+
charset: string;
|
|
666
|
+
/** `0` = scrolls when too wide, `1` = no scroll. */
|
|
667
|
+
type: number;
|
|
668
|
+
}
|
|
669
|
+
/** An independent dial group from {@link DivoomCloudClient.getChannelInfo}. */
|
|
670
|
+
interface IndependentDialGroup {
|
|
671
|
+
/** Group display name. */
|
|
672
|
+
IndependenceName: string;
|
|
673
|
+
/** Group id — used as `lcdIndependence` in {@link DialCommands}. */
|
|
674
|
+
LcdIndependence: number;
|
|
675
|
+
/** Per-panel clock ids. */
|
|
676
|
+
LcdList: Array<{
|
|
677
|
+
LcdClockId: number;
|
|
678
|
+
}>;
|
|
679
|
+
}
|
|
680
|
+
/** Response from {@link DivoomCloudClient.getDialTypes}. */
|
|
681
|
+
interface DialTypesResponse extends CloudResponse {
|
|
682
|
+
/** Available sub-dial category names. */
|
|
683
|
+
DialTypeList: string[];
|
|
684
|
+
}
|
|
685
|
+
/** Response from {@link DivoomCloudClient.getDialList}. */
|
|
686
|
+
interface DialListResponse extends CloudResponse {
|
|
687
|
+
/** Total available dials in this category. */
|
|
688
|
+
TotalNum: number;
|
|
689
|
+
/** This page of sub-dials (30 per page). */
|
|
690
|
+
DialList: SubDial[];
|
|
691
|
+
}
|
|
692
|
+
/** Response from {@link DivoomCloudClient.getWholeDialList}. */
|
|
693
|
+
interface WholeDialListResponse extends CloudResponse {
|
|
694
|
+
/** Total available whole dials. */
|
|
695
|
+
TotalNum: number;
|
|
696
|
+
/** This page of whole dials (30 per page). */
|
|
697
|
+
ClockList: WholeDial[];
|
|
698
|
+
}
|
|
699
|
+
/** Response from {@link DivoomCloudClient.getChannelInfo}. */
|
|
700
|
+
interface ChannelInfoResponse extends CloudResponse {
|
|
701
|
+
/** Current mode: `0` = whole, `1` = independent. */
|
|
702
|
+
ChannelType: number;
|
|
703
|
+
/** Selected independent group id. */
|
|
704
|
+
LcdIndependence: number;
|
|
705
|
+
/** Selected whole-dial id. */
|
|
706
|
+
ClockId: number;
|
|
707
|
+
/** All independent dial groups. */
|
|
708
|
+
LcdIndependenceList: IndependentDialGroup[];
|
|
709
|
+
/** The device id. */
|
|
710
|
+
DeviceId: number;
|
|
711
|
+
}
|
|
712
|
+
/** Response from {@link DivoomCloudClient.getLikedImages} / {@link DivoomCloudClient.getUploadedImages}. */
|
|
713
|
+
interface ImageListResponse extends CloudResponse {
|
|
714
|
+
/** The returned images. */
|
|
715
|
+
ImgList: CloudImage[];
|
|
716
|
+
}
|
|
717
|
+
/** Response from {@link DivoomCloudClient.getFontList}. */
|
|
718
|
+
interface FontListResponse extends CloudResponse {
|
|
719
|
+
/** Available fonts. */
|
|
720
|
+
FontList: CloudFont[];
|
|
721
|
+
}
|
|
722
|
+
/**
|
|
723
|
+
* POSTs JSON to a Divoom cloud URL with timeout, retry, and `ReturnCode`
|
|
724
|
+
* checking. Exported for advanced use (e.g. {@link discoverDevices}).
|
|
725
|
+
*/
|
|
726
|
+
declare function cloudPost<T extends CloudResponse>(url: string, body: Record<string, unknown>, options?: CloudClientOptions): Promise<T>;
|
|
727
|
+
/** Client for the Divoom cloud discovery APIs. */
|
|
728
|
+
declare class DivoomCloudClient {
|
|
729
|
+
private readonly baseUrl;
|
|
730
|
+
private readonly options;
|
|
731
|
+
constructor(options?: CloudClientOptions);
|
|
732
|
+
private post;
|
|
733
|
+
/** Lists sub-dial category names (`Channel/GetDialType`). */
|
|
734
|
+
getDialTypes(): Promise<DialTypesResponse>;
|
|
735
|
+
/** Lists sub-dials in a category, paged 30 at a time (`Channel/GetDialList`). */
|
|
736
|
+
getDialList(dialType: string, page?: number, deviceType?: string): Promise<DialListResponse>;
|
|
737
|
+
/** Lists whole (5-panel) dials, paged (`Channel/Get5LcdClockListForCommon`). */
|
|
738
|
+
getWholeDialList(page?: number): Promise<WholeDialListResponse>;
|
|
739
|
+
/** Gets channel info incl. independent dial groups (`Channel/Get5LcdInfoV2`). */
|
|
740
|
+
getChannelInfo(deviceId: number, deviceType?: string): Promise<ChannelInfoResponse>;
|
|
741
|
+
/** Lists the account's liked images (`Device/GetImgLikeList`). */
|
|
742
|
+
getLikedImages(deviceId: number, deviceMac: string, page?: number): Promise<ImageListResponse>;
|
|
743
|
+
/** Lists the account's uploaded images (`Device/GetImgUploadList`). */
|
|
744
|
+
getUploadedImages(deviceId: number, deviceMac: string, page?: number): Promise<ImageListResponse>;
|
|
745
|
+
/** Lists fonts usable in {@link AnimationCommands.sendItemList} (`Device/GetTimeDialFontList`). */
|
|
746
|
+
getFontList(): Promise<FontListResponse>;
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
/**
|
|
750
|
+
* LAN device discovery. Divoom's cloud reports every device bound to the
|
|
751
|
+
* caller's public IP, which is how you find a Times Gate's local IP address
|
|
752
|
+
* without scanning the network yourself.
|
|
753
|
+
*
|
|
754
|
+
* @packageDocumentation
|
|
755
|
+
*/
|
|
756
|
+
|
|
757
|
+
/** A device returned by {@link discoverDevices}. */
|
|
758
|
+
interface DiscoveredDevice {
|
|
759
|
+
/** Friendly device name, e.g. `"Times Gate"`. */
|
|
760
|
+
name: string;
|
|
761
|
+
/** Divoom device id. */
|
|
762
|
+
id: number;
|
|
763
|
+
/** The device's private (LAN) IP — use this as the client `host`. */
|
|
764
|
+
ip: string;
|
|
765
|
+
/** The device's MAC address. */
|
|
766
|
+
mac: string;
|
|
767
|
+
}
|
|
768
|
+
/**
|
|
769
|
+
* Discovers Divoom devices on the same network as this machine.
|
|
770
|
+
*
|
|
771
|
+
* @example
|
|
772
|
+
* ```ts
|
|
773
|
+
* const devices = await discoverDevices();
|
|
774
|
+
* const gate = devices.find((d) => d.name.includes('Times Gate'));
|
|
775
|
+
* const client = new TimesGateClient({ host: gate!.ip, localToken: 229930 });
|
|
776
|
+
* ```
|
|
777
|
+
*
|
|
778
|
+
* @remarks Requires outbound internet access (the lookup goes through Divoom's
|
|
779
|
+
* cloud). It returns devices seen from your public IP, so it won't work across
|
|
780
|
+
* different networks or some VPNs.
|
|
781
|
+
*/
|
|
782
|
+
declare function discoverDevices(options?: CloudClientOptions): Promise<DiscoveredDevice[]>;
|
|
783
|
+
|
|
784
|
+
/**
|
|
785
|
+
* Error hierarchy for the Divoom Times Gate SDK.
|
|
786
|
+
*
|
|
787
|
+
* Every error thrown by the SDK extends {@link DivoomError}, so you can catch
|
|
788
|
+
* the whole family with a single `instanceof DivoomError` check, or narrow to a
|
|
789
|
+
* specific subclass when you need to react differently (e.g. retry on a
|
|
790
|
+
* timeout, but surface a validation mistake to the user).
|
|
791
|
+
*
|
|
792
|
+
* @packageDocumentation
|
|
793
|
+
*/
|
|
794
|
+
/** Base class for every error thrown by the SDK. */
|
|
795
|
+
declare class DivoomError extends Error {
|
|
796
|
+
constructor(message: string, options?: {
|
|
797
|
+
cause?: unknown;
|
|
798
|
+
});
|
|
799
|
+
}
|
|
800
|
+
/** Thrown when arguments fail validation before a request is ever sent. */
|
|
801
|
+
declare class DivoomValidationError extends DivoomError {
|
|
802
|
+
constructor(message: string);
|
|
803
|
+
}
|
|
804
|
+
/** Thrown when the device cannot be reached (DNS, connection refused, etc.). */
|
|
805
|
+
declare class DivoomConnectionError extends DivoomError {
|
|
806
|
+
constructor(message: string, options?: {
|
|
807
|
+
cause?: unknown;
|
|
808
|
+
});
|
|
809
|
+
}
|
|
810
|
+
/** Thrown when a request does not complete within the configured timeout. */
|
|
811
|
+
declare class DivoomTimeoutError extends DivoomError {
|
|
812
|
+
/** The command that timed out. */
|
|
813
|
+
readonly command: string;
|
|
814
|
+
/** The timeout budget, in milliseconds, that was exceeded. */
|
|
815
|
+
readonly timeoutMs: number;
|
|
816
|
+
constructor(command: string, timeoutMs: number);
|
|
817
|
+
}
|
|
818
|
+
/** Thrown when the device responds with a non-2xx HTTP status. */
|
|
819
|
+
declare class DivoomHttpError extends DivoomError {
|
|
820
|
+
/** The HTTP status code returned by the device. */
|
|
821
|
+
readonly status: number;
|
|
822
|
+
/** The command that produced the error. */
|
|
823
|
+
readonly command: string;
|
|
824
|
+
/** The full request URL. */
|
|
825
|
+
readonly url: string;
|
|
826
|
+
constructor(status: number, command: string, url: string);
|
|
827
|
+
}
|
|
828
|
+
/**
|
|
829
|
+
* Thrown when a Divoom **cloud** API (`app.divoom-gz.com`) reports a non-zero
|
|
830
|
+
* `ReturnCode`.
|
|
831
|
+
*/
|
|
832
|
+
declare class DivoomCloudError extends DivoomError {
|
|
833
|
+
/** The non-zero `ReturnCode` reported by the cloud API. */
|
|
834
|
+
readonly returnCode: number;
|
|
835
|
+
/** The cloud endpoint path that failed. */
|
|
836
|
+
readonly endpoint: string;
|
|
837
|
+
/** The `ReturnMessage`, when provided. */
|
|
838
|
+
readonly returnMessage?: string;
|
|
839
|
+
constructor(returnCode: number, endpoint: string, returnMessage?: string);
|
|
840
|
+
}
|
|
841
|
+
/**
|
|
842
|
+
* Thrown when the device accepts the request but reports a non-zero
|
|
843
|
+
* `error_code` in the response body.
|
|
844
|
+
*/
|
|
845
|
+
declare class DivoomDeviceError extends DivoomError {
|
|
846
|
+
/** The non-zero `error_code` reported by the device. */
|
|
847
|
+
readonly errorCode: number;
|
|
848
|
+
/** The command that was rejected. */
|
|
849
|
+
readonly command: string;
|
|
850
|
+
/** The raw response body returned by the device. */
|
|
851
|
+
readonly response: unknown;
|
|
852
|
+
constructor(errorCode: number, command: string, response: unknown);
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
/**
|
|
856
|
+
* Device-level constants for the Divoom Times Gate.
|
|
857
|
+
*
|
|
858
|
+
* @packageDocumentation
|
|
859
|
+
*/
|
|
860
|
+
/** The Times Gate has five individually-addressable LCD panels. */
|
|
861
|
+
declare const PANEL_COUNT = 5;
|
|
862
|
+
/** Each panel renders a square {@link PANEL_SIZE}×{@link PANEL_SIZE} image. */
|
|
863
|
+
declare const PANEL_SIZE = 128;
|
|
864
|
+
/** Default HTTP port for hardware version 400 devices. */
|
|
865
|
+
declare const DEFAULT_PORT = 80;
|
|
866
|
+
/** Default request path for hardware version 400 devices (`http://IP:80/post`). */
|
|
867
|
+
declare const DEFAULT_PATH = "/post";
|
|
868
|
+
/** HTTP port for hardware version 402 devices. */
|
|
869
|
+
declare const HARDWARE_402_PORT = 9000;
|
|
870
|
+
/** Request path for hardware version 402 devices (`http://IP:9000/divoom_api`). */
|
|
871
|
+
declare const HARDWARE_402_PATH = "/divoom_api";
|
|
872
|
+
/**
|
|
873
|
+
* Divoom's cloud endpoint that returns every Divoom device currently visible
|
|
874
|
+
* on the same LAN as the caller. Used by {@link discoverDevices}.
|
|
875
|
+
*/
|
|
876
|
+
declare const LAN_DISCOVERY_URL = "https://app.divoom-gz.com/Device/ReturnSameLANDevice";
|
|
877
|
+
|
|
878
|
+
/**
|
|
879
|
+
* Small, dependency-free helpers shared across the SDK: argument validation,
|
|
880
|
+
* panel-mask construction, and a monotonic PicID generator.
|
|
881
|
+
*
|
|
882
|
+
* @packageDocumentation
|
|
883
|
+
*/
|
|
884
|
+
|
|
885
|
+
/**
|
|
886
|
+
* Builds a panel selection mask for a single panel.
|
|
887
|
+
*
|
|
888
|
+
* @example
|
|
889
|
+
* ```ts
|
|
890
|
+
* panelToLcdArray(2); // → [0, 0, 1, 0, 0]
|
|
891
|
+
* ```
|
|
892
|
+
*/
|
|
893
|
+
declare function panelToLcdArray(panel: PanelIndex): LcdArray;
|
|
894
|
+
/**
|
|
895
|
+
* Builds a panel selection mask from a set of panels.
|
|
896
|
+
*
|
|
897
|
+
* @example
|
|
898
|
+
* ```ts
|
|
899
|
+
* panelsToLcdArray([0, 4]); // → [1, 0, 0, 0, 1]
|
|
900
|
+
* ```
|
|
901
|
+
*/
|
|
902
|
+
declare function panelsToLcdArray(panels: Iterable<PanelIndex>): LcdArray;
|
|
903
|
+
/**
|
|
904
|
+
* Generates strictly-increasing PicIDs for image uploads. The Times Gate caches
|
|
905
|
+
* frames by ID, so every pushed frame needs a fresh, monotonically growing ID.
|
|
906
|
+
*
|
|
907
|
+
* Uniqueness within a single generator comes from the `+10` step taken on every
|
|
908
|
+
* `next()` call; the per-panel offset only spaces consecutive IDs apart and is
|
|
909
|
+
* not what prevents collisions. The generator is seeded from the current time in
|
|
910
|
+
* seconds, so two *separate* generators created within the same second can
|
|
911
|
+
* produce overlapping IDs — share one generator if you need cross-instance
|
|
912
|
+
* uniqueness (or seed from the device via `Draw/GetHttpGifId`).
|
|
913
|
+
*/
|
|
914
|
+
declare class PicIdGenerator {
|
|
915
|
+
private base;
|
|
916
|
+
constructor(seed?: number);
|
|
917
|
+
/** Returns the next unique PicID for the given panel. */
|
|
918
|
+
next(panel?: number): number;
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
export { AnimationCommands, BatchCommands, type BuzzerOptions, type ChannelInfoResponse, type ChannelMode, type CloudClientOptions, type CloudFont, type CloudImage, type CloudResponse, DEFAULT_CLOUD_BASE_URL, DEFAULT_PATH, DEFAULT_PORT, DialCommands, type DialListResponse, type DialTypesResponse, type DiscoveredDevice, type DisplayItem, DivoomBaseResponse, DivoomCloudClient, DivoomCloudError, DivoomCommandRequest, DivoomConnectionError, DivoomDeviceError, DivoomError, DivoomHttpError, DivoomTimeoutError, DivoomValidationError, DrawCommands, FetchLike, type FontListResponse, type GetAllConfigResponse, type GetDeviceTimeResponse, type GetIndexResponse, type GetPicIdResponse, type GetWeatherResponse, HARDWARE_402_PATH, HARDWARE_402_PORT, HttpTransport, type ImageListResponse, type IndependentDialGroup, LAN_DISCOVERY_URL, LcdArray, PANEL_COUNT, PANEL_SIZE, PanelIndex, PicIdGenerator, type SendAnimationOptions, type SendHttpGifRequest, type SendImageOptions, type SendItemListOptions, type SendTextOptions, type StopwatchAction, type SubDial, SystemCommands, type TemperatureUnit, type TextAlign, type TextDirection, TimesGateClient, type TimesGateClientOptions, ToolCommands, type TransportOptions, type WholeDial, type WholeDialListResponse, cloudPost, discoverDevices, panelToLcdArray, panelsToLcdArray };
|