@libertas-ai/types 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/index.d.ts +1380 -0
- package/package.json +11 -0
package/index.d.ts
ADDED
|
@@ -0,0 +1,1380 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Libertas OS API is intended to be used by
|
|
3
|
+
* Libertas application developers.
|
|
4
|
+
*
|
|
5
|
+
* Libertas OS is running on top of Libertas Hub.
|
|
6
|
+
* End-users create tasks as instances of applications.
|
|
7
|
+
*
|
|
8
|
+
* The API comprises the major components below:
|
|
9
|
+
* - Device access API
|
|
10
|
+
* - Time and timers
|
|
11
|
+
* - Persistent database
|
|
12
|
+
* - Messaging
|
|
13
|
+
* - Miscellanies
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* A timer object.
|
|
18
|
+
*
|
|
19
|
+
* @see {@link libertasTimerNewInterval}
|
|
20
|
+
* @see {@link libertasTimerNewDeadline}
|
|
21
|
+
* @see {@link libertasTimerUpdate}
|
|
22
|
+
* @see {@link libertasTimerCancel}
|
|
23
|
+
*
|
|
24
|
+
*/
|
|
25
|
+
declare class LibertasTimer {
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* A logical device endpoint.
|
|
30
|
+
*
|
|
31
|
+
* @see {@link libertasDeviceReadReq}
|
|
32
|
+
* @see {@link libertasDeviceWriteReq}
|
|
33
|
+
* @see {@link libertasDeviceCommandReq}
|
|
34
|
+
* @see {@link libertasAppSubscribeReq}
|
|
35
|
+
* @see {@link libertasSetOnDevice}
|
|
36
|
+
*/
|
|
37
|
+
declare type LibertasDevice = number;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* A WiFi or Ethernet device.
|
|
41
|
+
*
|
|
42
|
+
* @see {@link libertasNetConnectDevice}
|
|
43
|
+
*
|
|
44
|
+
*/
|
|
45
|
+
declare type LibertasLanDevice = number;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* A virtual device. The behaviors of the device are managed by application code.
|
|
49
|
+
*
|
|
50
|
+
* Virtual devices interact with the user during the runtime of Thing-App tasks.
|
|
51
|
+
*
|
|
52
|
+
* @see [Virtual Device API](/doc/developers_doc/virtual_device_api/)
|
|
53
|
+
* @see {@link libertasVirtualDeviceCommandRsp}
|
|
54
|
+
* @see {@link libertasVirtualDeviceWriteRsp}
|
|
55
|
+
* @see {@link libertasVirtualDeviceUpdateEvents}
|
|
56
|
+
* @see {@link libertasVirtualDeviceAttributesChanged}
|
|
57
|
+
* @see {@link libertasVirtualDeviceAttributesRsp}
|
|
58
|
+
* @see {@link libertasSetOnVirtualDevice}
|
|
59
|
+
*/
|
|
60
|
+
declare type LibertasVirtualDevice = number;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* The Date and Time data type. Usually seconds from Unix epoch time. Note the time is always in UTC, but it is presented to the end-user in local time on the UI.
|
|
64
|
+
*/
|
|
65
|
+
declare type LibertasDateTime = number;
|
|
66
|
+
/**
|
|
67
|
+
* The 24-hour time data type, usually with seconds precision.
|
|
68
|
+
*/
|
|
69
|
+
declare type LibertasTimeOnly = number;
|
|
70
|
+
/**
|
|
71
|
+
* User data type. Base type is an integer of a user ID or user group ID.
|
|
72
|
+
*
|
|
73
|
+
* @see {@link libertasMessageText}
|
|
74
|
+
*/
|
|
75
|
+
declare type LibertasUser = number;
|
|
76
|
+
/**
|
|
77
|
+
* Action data type. This type combines a device and device actions (command or attribute set) and is serialized to a string.
|
|
78
|
+
*/
|
|
79
|
+
declare type LibertasAction = number;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Specialized virtual device for agent/tool interactions.
|
|
83
|
+
* Data schema must be predefined and published by the server developer.
|
|
84
|
+
*/
|
|
85
|
+
declare type LibertasAgentTool = LibertasVirtualDevice;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* A handle to an indexed database table.
|
|
89
|
+
*/
|
|
90
|
+
declare type LibertasDataStore = number;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Used to send broadcast data report in {@link libertasAgentToolSendResponse}. It should be 0xffffffff.
|
|
94
|
+
*/
|
|
95
|
+
declare const enum LibertasPeer {
|
|
96
|
+
Broadcast = 0xffffffff,
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* This action code is passed to the device and virtual device callback functions.
|
|
101
|
+
*
|
|
102
|
+
* Based on the Matter interaction action code. Libertas added the {@link LibertasDeviceAction.ReadResponse} code to complete the logic.
|
|
103
|
+
*
|
|
104
|
+
* @see {@link LibertasDeviceCallback}
|
|
105
|
+
* @see {@link LibertasVirtualDeviceCallback}
|
|
106
|
+
*
|
|
107
|
+
*/
|
|
108
|
+
declare const enum LibertasDeviceAction {
|
|
109
|
+
StatusResponse = 0x01,
|
|
110
|
+
ReadRequest = 0x02,
|
|
111
|
+
SubscribeRequest = 0x03,
|
|
112
|
+
SubscribeResponse = 0x04,
|
|
113
|
+
ReportData = 0x05,
|
|
114
|
+
WriteRequest = 0x06,
|
|
115
|
+
WriteResponse = 0x07,
|
|
116
|
+
InvokeCommandRequest = 0x08,
|
|
117
|
+
InvokeCommandResponse = 0x09,
|
|
118
|
+
ReadResponse = 0x40, /** Added by Libertas */
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Represents an App's access permissions to a cluster of a {@link LibertasDevice}.
|
|
123
|
+
*
|
|
124
|
+
* @see {@link LibertasDeviceClusterAccess}
|
|
125
|
+
* @see {@link libertasDeviceGetClusterAccess}
|
|
126
|
+
*/
|
|
127
|
+
declare enum LibertasAppAccess {
|
|
128
|
+
Read = 0x01,
|
|
129
|
+
Write = 0x02,
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Used with Matter events.
|
|
134
|
+
*/
|
|
135
|
+
declare enum MatterPriority {
|
|
136
|
+
Debug = 0,
|
|
137
|
+
Info = 1,
|
|
138
|
+
Critical = 2,
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Used with Matter events.
|
|
143
|
+
*/
|
|
144
|
+
declare enum MatterTimestampType {
|
|
145
|
+
System = 0,
|
|
146
|
+
Epoch = 1,
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Message level.
|
|
151
|
+
* @see [Severity Level](https://librehome.com/doc/developers_doc/notification_api/#severity-level).
|
|
152
|
+
*/
|
|
153
|
+
declare enum LibertasMessageLevel {
|
|
154
|
+
DEBUG = 1,
|
|
155
|
+
INFO = 2,
|
|
156
|
+
ALERT_LOW = 3,
|
|
157
|
+
ALERT_GUARDED = 4,
|
|
158
|
+
ALERT_ELEVATED = 5,
|
|
159
|
+
ALERT_HIGH = 6,
|
|
160
|
+
ALERT_SEVERE = 7,
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* A value of the Matter data model, which Libertas adopts.
|
|
165
|
+
* The value can be the value of an attribute or a field of a command or event.
|
|
166
|
+
* Note that a command or event must be a LibertasStruct, which could be empty.
|
|
167
|
+
*
|
|
168
|
+
* @see {@link LibertasStruct}
|
|
169
|
+
*/
|
|
170
|
+
declare type LibertasValue = number | boolean | string | BigInt | Uint8Array | LibertasValue[] | LibertasStruct | undefined;
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* A LibertasStruct can be a LibertasValue. A command or event must be a LibertasStruct, which could be empty.
|
|
174
|
+
*
|
|
175
|
+
* @see {@link LibertasValue}
|
|
176
|
+
* @see {@link LibertasCommand}
|
|
177
|
+
* @see {@link LibertasEvent}
|
|
178
|
+
*/
|
|
179
|
+
declare type LibertasStruct = Map<number, LibertasValue>;
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* A collection of attributes within a cluster as attribute id/value pairs.
|
|
183
|
+
*
|
|
184
|
+
* @see {@link LibertasClusterAttributes}
|
|
185
|
+
* @see {@link LibertasClusterReport}
|
|
186
|
+
*/
|
|
187
|
+
declare type LibertasAttributes = Map<number, LibertasValue>;
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* A map of ID/status code pairs. The ID can be an attribute ID, command ID, or event ID.
|
|
191
|
+
*
|
|
192
|
+
* @see {@link LibertasClusterWriteRsp}
|
|
193
|
+
* @see {@link LibertasClusterReport}
|
|
194
|
+
*/
|
|
195
|
+
declare type LibertasIdStatus = Map<number, number>;
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* A map of cluster ID and a {@link LibertasAppAccess}.
|
|
199
|
+
*
|
|
200
|
+
* @see {@link libertasDeviceGetClusterAccess}
|
|
201
|
+
*/
|
|
202
|
+
declare type LibertasDeviceClusterAccess = Map<number, number>;
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* A tuple representing a Matter event.
|
|
206
|
+
*
|
|
207
|
+
* @see {@link LibertasClusterReport}
|
|
208
|
+
* @see {@link libertasVirtualDeviceUpdateEvents}
|
|
209
|
+
*/
|
|
210
|
+
declare type LibertasEvent = [cluster: number, eventNo: number, priority: MatterPriority, timestamp: number, timestampType: MatterTimestampType, eventId: number, eventData?: LibertasStruct];
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* A map of event IDs and "urgent" flags.
|
|
214
|
+
*
|
|
215
|
+
* @remarks Use {@link libertasMakeIterable} to use LibertasClusterEventSubscription in a "for...of" loop.
|
|
216
|
+
*
|
|
217
|
+
*/
|
|
218
|
+
declare type LibertasClusterEventSubscription = Map<number, boolean>;
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* A tuple representing a Matter command.
|
|
222
|
+
*
|
|
223
|
+
* @see {@link LibertasCommandRsp}
|
|
224
|
+
* @see {@link LibertasVirtualDeviceReq}
|
|
225
|
+
* @see {@link libertasSetOnDevice}
|
|
226
|
+
* @see {@link libertasDeviceCommandReq}
|
|
227
|
+
* @see {@link libertasVirtualDeviceCommandRsp}
|
|
228
|
+
*/
|
|
229
|
+
declare type LibertasCommand = [cluster: number, id: number, data?: LibertasStruct];
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* A tuple representing a collection of attributes (id/value pairs) of a cluster.
|
|
233
|
+
*/
|
|
234
|
+
declare type LibertasClusterAttributes = [cluster: number, attributes: LibertasAttributes];
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* A tuple representing a read request from a Thing-App task.
|
|
238
|
+
*
|
|
239
|
+
* @see {@link LibertasVirtualDeviceReq}
|
|
240
|
+
* @see {@link libertasDeviceReadReq}
|
|
241
|
+
* @see {@link libertasVirtualDeviceAttributesChanged}
|
|
242
|
+
*
|
|
243
|
+
* @remarks
|
|
244
|
+
* The subscribe request is slightly different than {@link LibertasClusterSubscribeReq} in that an event id can be set as "urgent" in subscription.
|
|
245
|
+
*
|
|
246
|
+
* We currently do not support read by array index. We think it is a bad design. We may add that support in the future if there is a real need.
|
|
247
|
+
*/
|
|
248
|
+
declare type LibertasClusterReadReq = [cluster: number, attributes: number[], events?: number[] ];
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Represents a cluster subscription request of a device.
|
|
252
|
+
*
|
|
253
|
+
* @see {@link LibertasClusterEventSubscription}
|
|
254
|
+
* @see {@link LibertasDeviceSubscribeReq}
|
|
255
|
+
* @see {@link libertasAppSubscribeReq}
|
|
256
|
+
* @see {@link libertasSetOnDevice}
|
|
257
|
+
*
|
|
258
|
+
* @remarks
|
|
259
|
+
* The subscribe request is different than {@link LibertasClusterReadReq} in that an event ID can be set as "urgent."
|
|
260
|
+
* The minInterval and maxInterval are in seconds.
|
|
261
|
+
*
|
|
262
|
+
* The effective minInterval and maxInterval may differ due to the varying requirements of multiple agents and device settings.
|
|
263
|
+
*
|
|
264
|
+
* The maxInterval affects the report timeout. The underlying Libertas OS performs timeout detection. The Thing-App task can keep idling until a report or error occurs.
|
|
265
|
+
*/
|
|
266
|
+
declare type LibertasClusterSubscribeReq = [cluster: number, minInterval: number, maxInterval: number, attributes: number[], events?: LibertasClusterEventSubscription ];
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Represents a subscription request for a logical device. `eventMin` is required if an event subscription is included.
|
|
270
|
+
*
|
|
271
|
+
* @see {@link LibertasDevice}
|
|
272
|
+
* @see {@link LibertasClusterSubscribeReq}
|
|
273
|
+
* @see {@link libertasAppSubscribeReq}
|
|
274
|
+
*
|
|
275
|
+
* @remarks We currently do not support subscribe by array index. We think it is a bad design. We may add that support in the future if there is a real need.
|
|
276
|
+
*/
|
|
277
|
+
declare type LibertasDeviceSubscribeReq = [device: LibertasDevice, clusterSubRequests: LibertasClusterSubscribeReq[], eventMin?: number ];
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* A command response. The response may be a status code or a command, depending on the data model's design.
|
|
281
|
+
* If an error occurs, the response will include the error status code. Applications may use runtime type checking to
|
|
282
|
+
* find out the type of the response.
|
|
283
|
+
*
|
|
284
|
+
* @see {@link LibertasCommand}
|
|
285
|
+
* @see {@link libertasDeviceCommandReq}
|
|
286
|
+
* @see {@link libertasVirtualDeviceCommandRsp}
|
|
287
|
+
*/
|
|
288
|
+
declare type LibertasCommandRsp = number | LibertasCommand;
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Represents a "write response." The key is cluster.
|
|
292
|
+
*
|
|
293
|
+
* @remarks The original write request may be split into multiple requests to the destination. In that case, multiple "write responses" will be received.
|
|
294
|
+
*/
|
|
295
|
+
declare type LibertasClusterWriteRsp = Map<number, LibertasIdStatus>;
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* Represents cluster report data, part of a device or virtual device report.
|
|
299
|
+
*
|
|
300
|
+
* @see {@link LibertasAttributes}
|
|
301
|
+
* @see {@link LibertasIdStatus}
|
|
302
|
+
* @see {@link LibertasEvent}
|
|
303
|
+
* @see {@link LibertasDeviceRsp}
|
|
304
|
+
* @see {@link libertasDeviceReadReq}
|
|
305
|
+
* @see {@link libertasVirtualDeviceAttributesRsp}
|
|
306
|
+
*
|
|
307
|
+
* @remarks attributeStatus must contain the status code of every requested ID. Status code 0 represents a success; otherwise, it is an error. If a status code 0 is present on an ID but the ID is not in the attributes table, a "null" value shall be assumed (this is important for the Lua VM because Lua cannot have a nil value in a table).
|
|
308
|
+
*
|
|
309
|
+
* A virtual device's failure to include all IDs in the attribute status will result in unknown behavior.
|
|
310
|
+
*/
|
|
311
|
+
declare type LibertasClusterReport = [cluster: number, attributes: LibertasAttributes, attributeStatus: LibertasIdStatus, events?: LibertasEvent[], eventStatus?: LibertasIdStatus];
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* A request to a virtual device. It can be one of three types, depending on the context.
|
|
315
|
+
*
|
|
316
|
+
* @see {@link LibertasClusterReadReq}
|
|
317
|
+
* @see {@link LibertasClusterAttributes}
|
|
318
|
+
* @see {@link LibertasCommand}
|
|
319
|
+
* @see {@link LibertasVirtualDeviceCallback}
|
|
320
|
+
* @see {@link libertasSetOnVirtualDevice}
|
|
321
|
+
*/
|
|
322
|
+
declare type LibertasVirtualDeviceReq = LibertasClusterReadReq[] | LibertasClusterAttributes[] | LibertasCommand;
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* All possible responses. A status response is a number.
|
|
326
|
+
*
|
|
327
|
+
* @see {@link LibertasCommandRsp}
|
|
328
|
+
* @see {@link LibertasClusterWriteRsp}
|
|
329
|
+
* @see {@link LibertasClusterReport}
|
|
330
|
+
* @see {@link LibertasDeviceCallback}
|
|
331
|
+
* @see {@link libertasSetOnDevice}
|
|
332
|
+
*/
|
|
333
|
+
declare type LibertasDeviceRsp = LibertasCommandRsp | LibertasClusterWriteRsp[] | LibertasClusterReport[] | number;
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* The signature of a device callback function.
|
|
337
|
+
*
|
|
338
|
+
* @param device A {@link LibertasDevice}.
|
|
339
|
+
* @param action The {@link LibertasDeviceAction}. Note Libertas added a {@link LibertasDeviceAction.ReadResponse} action.
|
|
340
|
+
* @param data The response data. It's a union type. The value shall be cast to a type decided by action.
|
|
341
|
+
* @param tag The arbitrary data passed to {@link libertasSetOnDevice} with the callback instance.
|
|
342
|
+
* @param ref The reference number of the original request. It is not available if the data is a subscription report.
|
|
343
|
+
*
|
|
344
|
+
* @see {@link LibertasDeviceRsp}
|
|
345
|
+
* @see {@link libertasSetOnDevice}
|
|
346
|
+
*
|
|
347
|
+
* @remarks For a "status response," if the ref is defined, the status refers to a status against a request; otherwise, it represents the device status (Timeout).
|
|
348
|
+
* Subscription reports have no ref number associated.
|
|
349
|
+
*/
|
|
350
|
+
declare type LibertasDeviceCallback = (device: LibertasDevice, action: LibertasDeviceAction, data: LibertasDeviceRsp, tag?: any, ref?: number) => void;
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* Possible interactions of an agent tool connection.
|
|
354
|
+
*/
|
|
355
|
+
declare const enum LibertasAgentToolAction {
|
|
356
|
+
/// Agent/tool subscription request opcode.
|
|
357
|
+
SubscriptionRequest = 3,
|
|
358
|
+
/// Agent/tool data message opcode.
|
|
359
|
+
ReportData = 5,
|
|
360
|
+
/// Agent/tool request opcode (expects response).
|
|
361
|
+
Request = 8,
|
|
362
|
+
/// Agent/tool response opcode.
|
|
363
|
+
Response = 9,
|
|
364
|
+
/// Agent/tool peer down notification opcode.
|
|
365
|
+
PeerDown = 20,
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* The signature of a virtual device I/O callback function.
|
|
370
|
+
*
|
|
371
|
+
* @param device A {@link LibertasDevice}.
|
|
372
|
+
* @param ref The reference number of the original request. See remarks.
|
|
373
|
+
* @param action The {@link LibertasDeviceAction}. See remarks
|
|
374
|
+
* @param data The request data. It's a union type. The value shall be cast to a type decided by action.
|
|
375
|
+
* @param tag The arbitrary data passed to {@link libertasSetOnVirtualDevice} with the callback instance.
|
|
376
|
+
* @param peer Uniquely identifies a peer as subscription ID. See remarks.
|
|
377
|
+
*
|
|
378
|
+
* @see {@link libertasSetOnVirtualDevice}
|
|
379
|
+
*
|
|
380
|
+
* @remarks The callback is used to notify the virtual device of a request. Each request has an internally assigned ref number by the engine.
|
|
381
|
+
* The ref number must be passed back in the corresponding response.
|
|
382
|
+
*
|
|
383
|
+
* Valid actions:
|
|
384
|
+
* {@link LibertasDeviceAction.ReadRequest}, {@link LibertasDeviceAction.SubscribeRequest}, and {@link LibertasDeviceAction.ReportData} all request attribute data. {@link LibertasDeviceAction.ReadRequest}
|
|
385
|
+
* is a one-time read. {@link LibertasDeviceAction.SubscribeRequest} is an initial subscribe request. {@link LibertasDeviceAction.ReportData} is for
|
|
386
|
+
* continuous subscription data report. Combined with `peer`, the Thing-App can keep track of current subscribers. The Thing-App can also keep the last subscription related request time to
|
|
387
|
+
* calculate interval duration for more flexible subscrption delivery. A virtual device may even respond more data than requested if the common dirty-marking algorithm is not adequate.
|
|
388
|
+
*/
|
|
389
|
+
|
|
390
|
+
declare type LibertasVirtualDeviceCallback = (device: LibertasVirtualDevice, ref: number, action: LibertasDeviceAction, data: LibertasVirtualDeviceReq, tag?: any, peer?: number) => void;
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* Callback of an agent tool connection.
|
|
394
|
+
* @param device A LibertasAgentTool client or server.
|
|
395
|
+
* @param action interaction action.
|
|
396
|
+
* @param peer The peer that protocol from which message comes.
|
|
397
|
+
* @param tag The arbitrary data passed to {@link libertasSetOnAgentTool} with the callback instance.
|
|
398
|
+
* @param data The protocol message, or undefined if `action` is `PeerDown`.
|
|
399
|
+
* @param ref The transaction Id. May be undefined if this is unsolicited `ReportData`.
|
|
400
|
+
*/
|
|
401
|
+
declare type LibertasAgentToolCallback<T> = (device: LibertasAgentTool, action: LibertasAgentToolAction, peer: number, tag: any, data?: T, ref?: number) => void;
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* Set a callback function to receive responses and reports to a device.
|
|
405
|
+
*
|
|
406
|
+
* @param device A {@link LibertasDevice}.
|
|
407
|
+
* @param func The callback function.
|
|
408
|
+
* @param tag A developer-defined value that will be passed to the callback function.
|
|
409
|
+
*
|
|
410
|
+
* @see {@link LibertasDeviceCallback}
|
|
411
|
+
* @see {@link libertasDeviceReadReq}
|
|
412
|
+
* @see {@link libertasDeviceWriteReq}
|
|
413
|
+
* @see {@link libertasDeviceCommandReq}
|
|
414
|
+
* @see {@link libertasAppSubscribeReq}
|
|
415
|
+
*/
|
|
416
|
+
declare function libertasSetOnDevice(device: LibertasDevice, func: LibertasDeviceCallback, tag?: any): void;
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* Obtain the cluster-access map of a device. This API is used to get basic information about a device.
|
|
420
|
+
* A LibertasDevice may support multiple types of devices with varying capabilities (clusters). This API returns
|
|
421
|
+
* the device's actual supported clusters and their App access rights.
|
|
422
|
+
*
|
|
423
|
+
* Cluster access data is part of the App's static data and is returned without querying the "Descriptor" cluster from the device.
|
|
424
|
+
*
|
|
425
|
+
* @param device A {@link LibertasDevice}.
|
|
426
|
+
* @returns A {@link LibertasDeviceClusterAccess}.
|
|
427
|
+
*
|
|
428
|
+
*/
|
|
429
|
+
declare function libertasDeviceGetClusterAccess(device: LibertasDevice) : LibertasDeviceClusterAccess;
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* Send an asynchronous read request to the device.
|
|
433
|
+
*
|
|
434
|
+
* @param device A {@link LibertasDevice}.
|
|
435
|
+
* @param requests An array of {@link LibertasClusterReadReq} representing attributes and events for specified clusters.
|
|
436
|
+
* @param eventMin Must present if events are requested.
|
|
437
|
+
* @returns A reference number passed back in {@link LibertasDeviceRsp} of {@link LibertasDeviceCallback} callback.
|
|
438
|
+
*
|
|
439
|
+
* @see {@link libertasDeviceGetClusterAccess}
|
|
440
|
+
* @see {@link LibertasClusterReadReq}
|
|
441
|
+
* @see {@link libertasSetOnDevice}
|
|
442
|
+
*
|
|
443
|
+
* @remarks
|
|
444
|
+
* Use {@link libertasSetOnDevice} to set up the callback function. The callback shall be called later with ReadRsp.
|
|
445
|
+
*
|
|
446
|
+
* The callback will be triggered asynchronously with a {@link LibertasClusterReport}[] array and the reference number.
|
|
447
|
+
*
|
|
448
|
+
* IMPORTANT! The read request may be responded to with more than one response. Multiple read requests may be pooled into one single response.
|
|
449
|
+
*
|
|
450
|
+
*/
|
|
451
|
+
declare function libertasDeviceReadReq(device: LibertasDevice, requests: LibertasClusterReadReq[], eventMin?: number) : number;
|
|
452
|
+
|
|
453
|
+
/**
|
|
454
|
+
* Send an asynchronous write request to the device.
|
|
455
|
+
*
|
|
456
|
+
* @param device A {@link LibertasDevice}.
|
|
457
|
+
* @param requests An array of {@link LibertasClusterAttributes}.
|
|
458
|
+
* @returns The reference number of this request.
|
|
459
|
+
*
|
|
460
|
+
* @see {@link libertasDeviceGetClusterAccess}
|
|
461
|
+
* @see {@link LibertasClusterAttributes}
|
|
462
|
+
* @see {@link LibertasClusterWriteRsp}
|
|
463
|
+
* @see {@link libertasSetOnDevice}
|
|
464
|
+
*
|
|
465
|
+
* @remarks
|
|
466
|
+
* Use {@link libertasSetOnDevice} to set up the callback function for the response.
|
|
467
|
+
*
|
|
468
|
+
* The callback will be triggered asynchronously with a {@link LibertasClusterWriteRsp}[] array and the reference number.
|
|
469
|
+
*
|
|
470
|
+
* IMPORTANT! If the task sends another WriteReq before the previous WriteReq is responded to, the previous one may be discarded by Libertas OS.
|
|
471
|
+
* As a general rule, a task shall always wait for the response to the previous interaction before sending another one or only expect the
|
|
472
|
+
* response to the latest request.
|
|
473
|
+
*
|
|
474
|
+
* The request may never reach the recipient if, for example, there is a network problem. In that case, a
|
|
475
|
+
* {@link LibertasDeviceAction.StatusResponse} with a {@link Matter.Status.Timeout} will be received from the callback registered with
|
|
476
|
+
* {@link libertasSetOnDevice}.
|
|
477
|
+
*
|
|
478
|
+
* The Thing-App task shall not assume that it is the only process that sends requests. Other agents
|
|
479
|
+
* may also send requests. A task can only receive {@link LibertasClusterWriteRsp} to its written requests.
|
|
480
|
+
*
|
|
481
|
+
* To receive all changes to an attribute, use {@link libertasAppSubscribeReq}.
|
|
482
|
+
*
|
|
483
|
+
*/
|
|
484
|
+
declare function libertasDeviceWriteReq(device: LibertasDevice, requests: LibertasClusterAttributes[]) : number;
|
|
485
|
+
|
|
486
|
+
/**
|
|
487
|
+
* Send an asynchronous command request to the device.
|
|
488
|
+
*
|
|
489
|
+
* @param device A {@link LibertasDevice}.
|
|
490
|
+
* @param request The {@link LibertasCommand}.
|
|
491
|
+
* @returns The reference number of this request.
|
|
492
|
+
*
|
|
493
|
+
* @see {@link libertasDeviceGetClusterAccess}
|
|
494
|
+
* @see {@link LibertasCommandRsp}
|
|
495
|
+
* @see {@link libertasSetOnDevice}
|
|
496
|
+
*
|
|
497
|
+
* @remarks
|
|
498
|
+
* Use {@link libertasSetOnDevice} to set up the callback function for the response.
|
|
499
|
+
*
|
|
500
|
+
* The callback will be triggered asynchronously with a {@link LibertasCommandRsp} and the reference number.
|
|
501
|
+
*
|
|
502
|
+
* IMPORTANT! If the task sends another command before the previous one is responded to, the previous one may be discarded by Libertas OS.
|
|
503
|
+
* As a general rule, a task shall always wait for the response to the previous interaction before sending another one or only expect the
|
|
504
|
+
* response to the latest request.
|
|
505
|
+
*
|
|
506
|
+
* If the task keeps sending commands while a previous command has not received a response, some commands will be
|
|
507
|
+
* automatically dropped because the Libertas engine can tell that only the last command matters.
|
|
508
|
+
*
|
|
509
|
+
* The request may never reach the recipient if, for example, there is a network problem. In that case, a
|
|
510
|
+
* {@link LibertasDeviceAction.StatusResponse} with a {@link Matter.Status.Timeout} will be received from the callback registered with
|
|
511
|
+
* {@link libertasSetOnDevice}.
|
|
512
|
+
*
|
|
513
|
+
* The Thing-App task shall not assume that it is the only process that sends requests. Other agents
|
|
514
|
+
* may also send requests. A task can only receive the {@link LibertasCommandRsp} to its command requests.
|
|
515
|
+
*
|
|
516
|
+
* To receive all changes to an attribute, use {@link libertasAppSubscribeReq}.
|
|
517
|
+
*/
|
|
518
|
+
declare function libertasDeviceCommandReq(device: LibertasDevice, request: LibertasCommand) : number;
|
|
519
|
+
|
|
520
|
+
/**
|
|
521
|
+
* Send a subscription request.
|
|
522
|
+
*
|
|
523
|
+
* @param requests An array of {@link LibertasDeviceSubscribeReq}.
|
|
524
|
+
*
|
|
525
|
+
* @see {@link libertasDeviceGetClusterAccess}
|
|
526
|
+
* @see {@link LibertasDeviceSubscribeReq}
|
|
527
|
+
* @see {@link LibertasClusterReport}
|
|
528
|
+
* @see {@link LibertasDeviceRsp}
|
|
529
|
+
* @see {@link libertasSetOnDevice}
|
|
530
|
+
*
|
|
531
|
+
* @remarks
|
|
532
|
+
* An app only sends out one subscription request. The App must collect the list of all devices that require subscriptions and send them out all at once.
|
|
533
|
+
*
|
|
534
|
+
* Because the Thing-App shares subscriptions with the host and possibly other Thing-Apps, the following behaviors may be observed:
|
|
535
|
+
*
|
|
536
|
+
* 1. The first few data reports may be in response to ReadRequest.
|
|
537
|
+
* 2. The data reports may contain attributes and events that are not subscribed to by this Thing-App.
|
|
538
|
+
* 3. Libertas-OS will handle errors, including timeout. A StatusResponse report will be generated in case of errors.
|
|
539
|
+
*
|
|
540
|
+
* The report data will be passed to the callback function {@link LibertasDeviceCallback} registered with {@link libertasSetOnDevice}.
|
|
541
|
+
*/
|
|
542
|
+
declare function libertasAppSubscribeReq(requests: LibertasDeviceSubscribeReq[]) : void;
|
|
543
|
+
|
|
544
|
+
/**
|
|
545
|
+
* Notify the Libertas Thing-App engine that some attributes have changed values.
|
|
546
|
+
* @param device A {@link LibertasVirtualDevice}.
|
|
547
|
+
* @param attributes The list of cluster attribute IDs. We reuse the {@link LibertasClusterReadReq} structure to hold the required data.
|
|
548
|
+
* Note that the event field is always undefined because Libertas OS handles the event reports.
|
|
549
|
+
* @param peer The subscription ID, which can be inferred from the peer in earlier {@link LibertasVirtualDeviceCallback}. Usually it should be undefined, unless
|
|
550
|
+
* the Thing-App needs to manage data report for each individual subscriber.
|
|
551
|
+
*
|
|
552
|
+
* @remarks The Thing-App engine is responsible for reporting each subscription based on the subscribed attributes, events, and minimum/maximum intervals.
|
|
553
|
+
* Even if the virtual device reported the changes, the report may not be generated immediately if the minimum interval has not been reached.
|
|
554
|
+
* Also, when the Libertas Thing-App engine decides to generate a report, it will send a {@link LibertasDeviceAction.ReadRequest} or
|
|
555
|
+
* {@link LibertasDeviceAction.SubscribeRequest} with an array of {@link LibertasClusterReadReq} for the up-to-date values of the specified
|
|
556
|
+
* attributes and expect a response from {@link libertasVirtualDeviceAttributesRsp} call. If this value is defined, the notification will
|
|
557
|
+
* only be delivered to a single subscriber.
|
|
558
|
+
*/
|
|
559
|
+
declare function libertasVirtualDeviceAttributesChanged(device: LibertasVirtualDevice, attributes: LibertasClusterReadReq[], peer?: number) : void;
|
|
560
|
+
|
|
561
|
+
/**
|
|
562
|
+
* Update new events.
|
|
563
|
+
* @param device A {@link LibertasVirtualDevice}.
|
|
564
|
+
* @param events An array of {@link LibertasEvent}.
|
|
565
|
+
*
|
|
566
|
+
* @remarks Libertas OS manages the event reporting. The eventNo field shall be set to 0 and will be ignored. Libertas OS will automatically assign a consecutive number.
|
|
567
|
+
*/
|
|
568
|
+
declare function libertasVirtualDeviceUpdateEvents(device: LibertasVirtualDevice, events: LibertasEvent[]) : void;
|
|
569
|
+
|
|
570
|
+
/**
|
|
571
|
+
* Update attributes unsolicited, or in response to a ReadRequest or SubscribeRequest.
|
|
572
|
+
* @param device A {@link LibertasVirtualDevice}.
|
|
573
|
+
* @param ref The ref number of the request.
|
|
574
|
+
* @param attributes An array of {@link LibertasClusterReport}. Note that the events and eventStatus are undefined. Use {@link libertasVirtualDeviceUpdateEvents} to write events.
|
|
575
|
+
*
|
|
576
|
+
* @remarks
|
|
577
|
+
* The framework will maintain a cache of all attributes.
|
|
578
|
+
*
|
|
579
|
+
* If a ref number is present, a read response or a report in response to this referenced request will be immediately sent out;
|
|
580
|
+
* otherwise the Libertas OS engine will decide when to send out the subscription reports.
|
|
581
|
+
*/
|
|
582
|
+
declare function libertasVirtualDeviceAttributesRsp(device: LibertasVirtualDevice, ref: number, attributes: LibertasClusterReport[]) : void;
|
|
583
|
+
|
|
584
|
+
/**
|
|
585
|
+
* Send out command responses.
|
|
586
|
+
* @param device A {@link LibertasVirtualDevice}.
|
|
587
|
+
* @param ref The ref number of the request.
|
|
588
|
+
* @param rsp A {@link LibertasCommandRsp}.
|
|
589
|
+
*/
|
|
590
|
+
declare function libertasVirtualDeviceCommandRsp(device: LibertasVirtualDevice, ref: number, rsp: LibertasCommandRsp) : void;
|
|
591
|
+
|
|
592
|
+
/**
|
|
593
|
+
* Send out write response.
|
|
594
|
+
* @param device A {@link LibertasVirtualDevice}.
|
|
595
|
+
* @param ref The ref number of the request.
|
|
596
|
+
* @param responses An array of {@link LibertasClusterWriteRsp}.
|
|
597
|
+
*/
|
|
598
|
+
declare function libertasVirtualDeviceWriteRsp(device: LibertasVirtualDevice, ref: number, responses: LibertasClusterWriteRsp[]) : void;
|
|
599
|
+
|
|
600
|
+
/**
|
|
601
|
+
* Send out an error status code against an incoming request.
|
|
602
|
+
* @param device A {@link LibertasVirtualDevice}.
|
|
603
|
+
* @param ref The ref number of the request.
|
|
604
|
+
* @param status A {@link Matter.Status}.
|
|
605
|
+
*/
|
|
606
|
+
declare function libertasVirtualDeviceStatusRsp(device: LibertasVirtualDevice, ref: number, status: number) : void;
|
|
607
|
+
|
|
608
|
+
/**
|
|
609
|
+
* Listen to a virtual device events.
|
|
610
|
+
* @param device A {@link LibertasVirtualDevice}.
|
|
611
|
+
* @param func A {@link LibertasVirtualDeviceCallback} function.
|
|
612
|
+
* @param tag Developer defined data that will be passed to callback function.
|
|
613
|
+
*/
|
|
614
|
+
declare function libertasSetOnVirtualDevice(device: LibertasVirtualDevice, func: LibertasVirtualDeviceCallback, tag?: any): void;
|
|
615
|
+
|
|
616
|
+
/**
|
|
617
|
+
* Sends a request or subscribeRequest message to an agent tool.
|
|
618
|
+
*
|
|
619
|
+
* @param device The target {@link LibertasAgentTool}.
|
|
620
|
+
* @param action The interaction action, such as {@link LibertasAgentToolAction.Request} or {@link LibertasAgentToolAction.SubscriptionRequest}.
|
|
621
|
+
* @param message The message payload to send.
|
|
622
|
+
*
|
|
623
|
+
* @returns A transaction ID that can be used to track the request and match it with a future response.
|
|
624
|
+
*/
|
|
625
|
+
declare function libertasAgentToolSendRequest<T>(device: LibertasAgentTool, action: LibertasAgentToolAction, message: T): number;
|
|
626
|
+
|
|
627
|
+
/**
|
|
628
|
+
* Sends a response to an agent tool for a previously received request.
|
|
629
|
+
*
|
|
630
|
+
* @param device The target {@link LibertasAgentTool}.
|
|
631
|
+
* @param action The interaction action, typically {@link LibertasAgentToolAction.Response} or {@link LibertasAgentToolAction.ReportData}.
|
|
632
|
+
* @param message The message payload containing the response data.
|
|
633
|
+
* @param dest The request peer Id. It could be {@link LibertasPeer.Broadcast} for {@link LibertasAgentToolAction.ReportData}.
|
|
634
|
+
* @param transId The transaction ID (ref) from the original request being responded to.
|
|
635
|
+
*/
|
|
636
|
+
declare function libertasAgentToolSendResponse<T>(device: LibertasAgentTool, action: LibertasAgentToolAction, message: T, dest: number, transId: number): void;
|
|
637
|
+
|
|
638
|
+
/**
|
|
639
|
+
* Agent tool message callback.
|
|
640
|
+
* @param device A {@link LibertasAgentTool}.
|
|
641
|
+
* @param func Callback function.
|
|
642
|
+
* @param tag Developer defined data that will be passed to callback function.
|
|
643
|
+
*/
|
|
644
|
+
declare function libertasSetOnAgentTool<T>(device: LibertasAgentTool, func: LibertasAgentToolCallback<T>, tag?: any): void;
|
|
645
|
+
|
|
646
|
+
/**
|
|
647
|
+
* The signature of timer callback function.
|
|
648
|
+
*
|
|
649
|
+
* @param timer A timer returned from {@link libertasTimerNewInterval} or {@link libertasTimerNewDeadline}.
|
|
650
|
+
* @param now Current time ticks in microseconds. It will start to lose precision after about 285 years from Linux epoch.
|
|
651
|
+
* @param tag A context object passed when creating the timer.
|
|
652
|
+
*
|
|
653
|
+
* @see {@link libertasTimerNewInterval}
|
|
654
|
+
* @see {@link libertasTimerNewDeadline}
|
|
655
|
+
* @see {@link libertasTimerUpdate}
|
|
656
|
+
*/
|
|
657
|
+
declare type LibertasTimerCallback = (timer: LibertasTimer, now: number, tag: any) => void;
|
|
658
|
+
|
|
659
|
+
/**
|
|
660
|
+
* Create a new interval timer.
|
|
661
|
+
*
|
|
662
|
+
* @param timeout Positive timeout in microseconds using the monotonic timer source. If the timeout is 0, the timer is "put on hold"; use {@link libertasTimerUpdate} later to reschedule the timer.
|
|
663
|
+
* @param func Callback function.
|
|
664
|
+
* @param tag Developer-defined tag value to be passed over to the callback function.
|
|
665
|
+
*
|
|
666
|
+
* @returns A new timer object.
|
|
667
|
+
*
|
|
668
|
+
* @remarks
|
|
669
|
+
* Timer is always a one-off. When the timeout is reached, the callback is called, and the timer is then automatically canceled as if
|
|
670
|
+
* {@link libertasTimerCancel} is called.
|
|
671
|
+
*
|
|
672
|
+
* Both active timers and canceled timers can be reused by calling {@link libertasTimerUpdate}. Always try to
|
|
673
|
+
* reuse instead of creating new timers.
|
|
674
|
+
*
|
|
675
|
+
* The Timer API is a reactive API. Timers are driven by {@link libertasWaitReactive}. Never mix imperative and reactive APIs within the same thread.
|
|
676
|
+
*
|
|
677
|
+
* @see {@link libertasTimerCancel}
|
|
678
|
+
* @see {@link libertasTimerUpdate}
|
|
679
|
+
*/
|
|
680
|
+
declare function libertasTimerNewInterval(timeout: number, func: LibertasTimerCallback, tag?: any): LibertasTimer;
|
|
681
|
+
|
|
682
|
+
/**
|
|
683
|
+
* Create a new deadline timer.
|
|
684
|
+
*
|
|
685
|
+
* @param timeout Positive timeout in microseconds in UTC time. If the timeout is 0, the timer is "put on hold"; use {@link libertasTimerUpdate} later to reschedule the timer.
|
|
686
|
+
* @param func Callback function.
|
|
687
|
+
* @param tag Developer-defined tag value to be passed over to the callback function.
|
|
688
|
+
*
|
|
689
|
+
* @returns A new timer object.
|
|
690
|
+
*
|
|
691
|
+
* @remarks
|
|
692
|
+
* Timer is always a one-off. When the timeout is reached, the callback is called, and the timer is then automatically canceled as if
|
|
693
|
+
* {@link libertasTimerCancel} is called.
|
|
694
|
+
*
|
|
695
|
+
* Both active timers and canceled timers can be reused by calling {@link libertasTimerUpdate}. Always try to
|
|
696
|
+
* reuse instead of creating new timers.
|
|
697
|
+
*
|
|
698
|
+
* The Timer API is a reactive API. Timers are driven by {@link libertasWaitReactive}. Never mix imperative and reactive APIs within the same thread.
|
|
699
|
+
*
|
|
700
|
+
* @see {@link libertasTimerCancel}
|
|
701
|
+
* @see {@link libertasTimerUpdate}
|
|
702
|
+
*/
|
|
703
|
+
declare function libertasTimerNewDeadline(timeout: number, func: LibertasTimerCallback, tag?: any): LibertasTimer;
|
|
704
|
+
|
|
705
|
+
/**
|
|
706
|
+
* Cancels a timer so it won't be triggered..
|
|
707
|
+
*
|
|
708
|
+
* @param timer A {@link LibertasTimer} created with {@link libertasTimerNewInterval} or {@link libertasTimerNewDeadline}.
|
|
709
|
+
*
|
|
710
|
+
* @remarks
|
|
711
|
+
* Timer is always a one-off. When the timeout is reached, the callback is called, and the timer is then automatically canceled as if
|
|
712
|
+
* {@link libertasTimerCancel} is called.
|
|
713
|
+
*
|
|
714
|
+
* Both active timers and canceled timers can be reused by calling {@link libertasTimerUpdate}. Always try to
|
|
715
|
+
* reuse instead of creating new timers. Use {@link libertasTimerDestroy} to completely destroy a timer.
|
|
716
|
+
*
|
|
717
|
+
* The Timer API is a reactive API. Timers are driven by {@link libertasWaitReactive}. Never mix imperative and reactive APIs within the same thread.
|
|
718
|
+
*
|
|
719
|
+
* @see {@link libertasTimerNewInterval}
|
|
720
|
+
* @see {@link libertasTimerNewDeadline}
|
|
721
|
+
* @see {@link libertasTimerUpdate}
|
|
722
|
+
*/
|
|
723
|
+
declare function libertasTimerCancel(timer: LibertasTimer): void;
|
|
724
|
+
|
|
725
|
+
/**
|
|
726
|
+
* Destroy a timer and releases all related resources.
|
|
727
|
+
* @param timer A {@link LibertasTimer} created with {@link libertasTimerNewInterval} or {@link libertasTimerNewDeadline}.
|
|
728
|
+
*
|
|
729
|
+
* The timer cannot be used after this call.
|
|
730
|
+
*/
|
|
731
|
+
declare function libertasTimerDestroy(timer: LibertasTimer): void;
|
|
732
|
+
|
|
733
|
+
/**
|
|
734
|
+
* Reset and update a timer.
|
|
735
|
+
*
|
|
736
|
+
* @param timer A {@link LibertasTimer} created with {@link libertasTimerNewInterval} or {@link libertasTimerNewDeadline}.
|
|
737
|
+
* @param timeout Positive timeout in microseconds. The value is monotonic system ticks or UTC time, depending on the type of timer.
|
|
738
|
+
* @param func Optional. If present, replace the callback function of an old-timer.
|
|
739
|
+
* @param tag Optional. If present, replace the tag object of an old-timer.
|
|
740
|
+
*
|
|
741
|
+
* @see {@link libertasTimerNewInterval}
|
|
742
|
+
* @see {@link libertasTimerNewDeadline}
|
|
743
|
+
* @see {@link LibertasTimerCallback}
|
|
744
|
+
* @see {@link libertasTimerCancel}
|
|
745
|
+
*
|
|
746
|
+
* @remarks Arguments func and tag will not be reset to undefined or null. If arguments are undefined, original values will be kept.
|
|
747
|
+
*
|
|
748
|
+
* Timer is always a one-off. When the timeout is reached, the callback is called, and the timer is then automatically canceled as if
|
|
749
|
+
* {@link libertasTimerCancel} is called.
|
|
750
|
+
*
|
|
751
|
+
* Both active timers and canceled timers can be reused by calling {@link libertasTimerUpdate}. Always try to
|
|
752
|
+
* reuse instead of creating new timers.
|
|
753
|
+
*
|
|
754
|
+
* The Timer API is a reactive API. Timers are driven by {@link libertasWaitReactive}. Never mix imperative and reactive APIs within the same thread.
|
|
755
|
+
*/
|
|
756
|
+
declare function libertasTimerUpdate(timer: LibertasTimer, timeout: number, func?: LibertasTimerCallback, tag?: any): void
|
|
757
|
+
|
|
758
|
+
/**
|
|
759
|
+
* Trigger a user defined action. Users can define action with a client UI tool during Thing-App task creation.
|
|
760
|
+
* @param action A {@link LibertasAction}.
|
|
761
|
+
*/
|
|
762
|
+
declare function libertasTriggerAction(action: LibertasAction): void;
|
|
763
|
+
|
|
764
|
+
/**
|
|
765
|
+
* Notification severity levels.
|
|
766
|
+
*
|
|
767
|
+
* - `Debug`: Debugging info.
|
|
768
|
+
* - `Info`: General info.
|
|
769
|
+
* - `AlertLow`: Low-priority alerts.
|
|
770
|
+
* - `AlertGuarded`: Guarded alerts.
|
|
771
|
+
* - `AlertElevated`: Elevated alerts.
|
|
772
|
+
* - `AlertHigh`: High alerts.
|
|
773
|
+
* - `AlertSevere`: Severe alerts.
|
|
774
|
+
*/
|
|
775
|
+
declare const enum NotificationImportance {
|
|
776
|
+
Debug = 0,
|
|
777
|
+
Info = 1,
|
|
778
|
+
AlertLow = 2,
|
|
779
|
+
AlertGuarded = 3,
|
|
780
|
+
AlertElevated = 4,
|
|
781
|
+
AlertHigh = 5,
|
|
782
|
+
AlertSevere = 6,
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
/**
|
|
786
|
+
* Notification argument variant tags.
|
|
787
|
+
*/
|
|
788
|
+
declare const enum NotificationArgTag {
|
|
789
|
+
/**
|
|
790
|
+
* A literal string argument included in the message as-is, without being
|
|
791
|
+
* treated as a resource string. This can be used to include specific text that
|
|
792
|
+
* does not need to be localized or looked up from resources.
|
|
793
|
+
*/
|
|
794
|
+
LiteralText = 0,
|
|
795
|
+
/**
|
|
796
|
+
* A Libertas system object, such as a device, user, or other entity within the
|
|
797
|
+
* system. The value is expected to be a 32-bit unsigned integer identifier.
|
|
798
|
+
*
|
|
799
|
+
* The application task must have access permission to the object in order to
|
|
800
|
+
* include it as an argument in the message.
|
|
801
|
+
*/
|
|
802
|
+
Object = 1,
|
|
803
|
+
/**
|
|
804
|
+
* A boolean value, true or false, included as an argument in a message.
|
|
805
|
+
*/
|
|
806
|
+
Boolean = 2,
|
|
807
|
+
/**
|
|
808
|
+
* A signed integer value included as an argument in a message.
|
|
809
|
+
*
|
|
810
|
+
* This can convey counts, measurements, or other integer-based data that can
|
|
811
|
+
* be positive or negative.
|
|
812
|
+
*/
|
|
813
|
+
Signed = 3,
|
|
814
|
+
/**
|
|
815
|
+
* An unsigned integer value included as an argument in a message.
|
|
816
|
+
*
|
|
817
|
+
* This can convey non-negative numerical information such as counts, sizes, or
|
|
818
|
+
* other unsigned integer-based data.
|
|
819
|
+
*/
|
|
820
|
+
Unsigned = 4,
|
|
821
|
+
/**
|
|
822
|
+
* A single-precision floating-point value included as an argument in a
|
|
823
|
+
* message.
|
|
824
|
+
*/
|
|
825
|
+
Float = 5,
|
|
826
|
+
/**
|
|
827
|
+
* A double-precision floating-point value included as an argument in a
|
|
828
|
+
* message.
|
|
829
|
+
*/
|
|
830
|
+
Double = 6,
|
|
831
|
+
/**
|
|
832
|
+
* A signed integer value with a specific unit type.
|
|
833
|
+
*
|
|
834
|
+
* This can represent measurements or other data with a unit of measurement,
|
|
835
|
+
* such as temperature, distance, or another relevant unit.
|
|
836
|
+
*/
|
|
837
|
+
UnitSigned = 7,
|
|
838
|
+
/**
|
|
839
|
+
* An unsigned integer value with a specific unit type.
|
|
840
|
+
*
|
|
841
|
+
* This can represent measurements or other non-negative data with a unit of
|
|
842
|
+
* measurement, such as file sizes, speeds, or another relevant unit.
|
|
843
|
+
*/
|
|
844
|
+
UnitUnsigned = 8,
|
|
845
|
+
/**
|
|
846
|
+
* A single-precision floating-point value with a specific unit type.
|
|
847
|
+
*/
|
|
848
|
+
UnitFloat = 9,
|
|
849
|
+
/**
|
|
850
|
+
* A double-precision floating-point value with a specific unit type.
|
|
851
|
+
*/
|
|
852
|
+
UnitDouble = 10,
|
|
853
|
+
/**
|
|
854
|
+
* A resource string argument.
|
|
855
|
+
*
|
|
856
|
+
* This is included in the message as a reference to a resource string rather
|
|
857
|
+
* than as literal text. This allows the text to be localized or looked up from
|
|
858
|
+
* resources based on the user's language or other context.
|
|
859
|
+
*/
|
|
860
|
+
ResourceText = 11,
|
|
861
|
+
/**
|
|
862
|
+
* A plural value used for pluralization.
|
|
863
|
+
*
|
|
864
|
+
* This is typically used with resource string templates that have plural
|
|
865
|
+
* forms. The value determines which plural form of the resource string should
|
|
866
|
+
* be used when generating the final message.
|
|
867
|
+
*/
|
|
868
|
+
Plural = 12,
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
/**
|
|
872
|
+
* Arguments for notification templates.
|
|
873
|
+
*
|
|
874
|
+
* Supports various data types for message formatting.
|
|
875
|
+
*
|
|
876
|
+
* The rendering of the message follows a "printf" style and is based on the
|
|
877
|
+
* resource string template and the provided arguments. This type supports
|
|
878
|
+
* literal text, resource text, objects, boolean values, numerical values, and
|
|
879
|
+
* unit values with specific unit types.
|
|
880
|
+
*
|
|
881
|
+
* These arguments allow messages to be rich in content and convey a wide range
|
|
882
|
+
* of information to users or other parts of the system when sending
|
|
883
|
+
* notifications through the Libertas system.
|
|
884
|
+
*
|
|
885
|
+
* This type is also used as an argument in name templates to provide
|
|
886
|
+
* predictable yet flexible names for database names and data fields, making
|
|
887
|
+
* Libertas apps fully self-describing.
|
|
888
|
+
*/
|
|
889
|
+
declare type NotificationArgument =
|
|
890
|
+
| { type: NotificationArgTag.LiteralText; value: string }
|
|
891
|
+
| { type: NotificationArgTag.Object; value: number }
|
|
892
|
+
| { type: NotificationArgTag.Boolean; value: boolean }
|
|
893
|
+
| { type: NotificationArgTag.Signed; value: bigint }
|
|
894
|
+
| { type: NotificationArgTag.Unsigned; value: bigint }
|
|
895
|
+
| { type: NotificationArgTag.Float; value: number }
|
|
896
|
+
| { type: NotificationArgTag.Double; value: number }
|
|
897
|
+
| { type: NotificationArgTag.UnitSigned; unit_type: string; value: bigint }
|
|
898
|
+
| { type: NotificationArgTag.UnitUnsigned; unit_type: string; value: bigint }
|
|
899
|
+
| { type: NotificationArgTag.UnitFloat; unit_type: string; value: number }
|
|
900
|
+
| { type: NotificationArgTag.UnitDouble; unit_type: string; value: number }
|
|
901
|
+
| { type: NotificationArgTag.ResourceText; value: string }
|
|
902
|
+
| { type: NotificationArgTag.Plural; value: bigint };
|
|
903
|
+
|
|
904
|
+
/**
|
|
905
|
+
* Sends a templated notification to recipients.
|
|
906
|
+
*
|
|
907
|
+
* @param recipients - List of recipient IDs.
|
|
908
|
+
* @param level - Message severity.
|
|
909
|
+
* @param resource_name - Template resource name.
|
|
910
|
+
* @param args - Template arguments.
|
|
911
|
+
* @param source - Optional source ID. If omitted, the current task ID is used.
|
|
912
|
+
*
|
|
913
|
+
* @throws On size limits or permission violations.
|
|
914
|
+
*/
|
|
915
|
+
declare function libertas_NotificationSend(recipients: number[], level: NotificationImportance, resource_name: string, args: NotificationArgument[], source?: number): void;
|
|
916
|
+
|
|
917
|
+
/**
|
|
918
|
+
* Sends a literal text notification.
|
|
919
|
+
*
|
|
920
|
+
* @param recipients - List of recipient IDs.
|
|
921
|
+
* @param level - Message severity.
|
|
922
|
+
* @param text - Message content.
|
|
923
|
+
* @param source - Optional source ID. If omitted, the current task ID is used.
|
|
924
|
+
*
|
|
925
|
+
* @throws On size limits or permission violations.
|
|
926
|
+
*/
|
|
927
|
+
declare function libertas_NotificationSendLiteral(recipients: number[], level: NotificationImportance, text: string, source?: number): void;
|
|
928
|
+
|
|
929
|
+
/**
|
|
930
|
+
* Data name with resource and arguments.
|
|
931
|
+
* Used for identifying standalone and indexed data in the database.
|
|
932
|
+
* printf-style localized templates shall be supplied in App documents to render the resource name into natural language with arguments.
|
|
933
|
+
*/
|
|
934
|
+
declare interface DataName {
|
|
935
|
+
resourceName: string;
|
|
936
|
+
arguments: NotificationArgument[];
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
declare const enum IndexDirection {
|
|
940
|
+
Above,
|
|
941
|
+
Below,
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
/**
|
|
945
|
+
* Statistics for opened indexed data.
|
|
946
|
+
*
|
|
947
|
+
* Contains handle, record count, and index range.
|
|
948
|
+
*
|
|
949
|
+
* If `count` is `0`, then `minIndex` and `maxIndex` are undefined. Otherwise,
|
|
950
|
+
* valid indices are in the range `[minIndex, maxIndex]`.
|
|
951
|
+
*/
|
|
952
|
+
declare interface IndexedDataStat {
|
|
953
|
+
/** Database handle. */
|
|
954
|
+
handle: LibertasDataStore;
|
|
955
|
+
|
|
956
|
+
/** Number of records in the indexed data store. */
|
|
957
|
+
count: bigint;
|
|
958
|
+
|
|
959
|
+
/** Minimum record index. Undefined when `count` is `0`. */
|
|
960
|
+
minIndex: bigint;
|
|
961
|
+
|
|
962
|
+
/** Maximum record index. Undefined when `count` is `0`. */
|
|
963
|
+
maxIndex: bigint;
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
/**
|
|
967
|
+
* Indexed data record with index and decoded data.
|
|
968
|
+
*/
|
|
969
|
+
declare interface IndexedData<T> {
|
|
970
|
+
/** Record index. */
|
|
971
|
+
index: bigint;
|
|
972
|
+
|
|
973
|
+
/** Decoded record data. */
|
|
974
|
+
data: T;
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
/**
|
|
978
|
+
* Returns all standalone data names.
|
|
979
|
+
*
|
|
980
|
+
* @returns Data names with resource names and arguments.
|
|
981
|
+
*/
|
|
982
|
+
declare function libertasDataGetNames(): DataName[];
|
|
983
|
+
|
|
984
|
+
/**
|
|
985
|
+
* Returns all indexed data names.
|
|
986
|
+
*
|
|
987
|
+
* @returns Indexed data names.
|
|
988
|
+
*/
|
|
989
|
+
declare function libertasDataGetIndexedNames(): DataName[];
|
|
990
|
+
|
|
991
|
+
/**
|
|
992
|
+
* Removes standalone data by resource name and arguments.
|
|
993
|
+
*
|
|
994
|
+
* @param resourceName - Resource name of the standalone data to remove.
|
|
995
|
+
* @param arguments_ - Resource arguments identifying the standalone data.
|
|
996
|
+
*/
|
|
997
|
+
declare function libertasDataRemove(
|
|
998
|
+
resourceName: string,
|
|
999
|
+
arguments_: readonly NotificationArgument[],
|
|
1000
|
+
): void;
|
|
1001
|
+
|
|
1002
|
+
/**
|
|
1003
|
+
* Removes a piece of indexed data from the indexed database.
|
|
1004
|
+
*
|
|
1005
|
+
* The data to remove is identified by the resource name and arguments. The
|
|
1006
|
+
* resource name and arguments are encoded in Avro format and sent to the device
|
|
1007
|
+
* to perform the removal. After this function is called, the specified indexed
|
|
1008
|
+
* data will no longer be available in the indexed database.
|
|
1009
|
+
*
|
|
1010
|
+
* Note that indexed data is different from standalone data in that it is
|
|
1011
|
+
* organized by an index value, which allows for efficient querying based on
|
|
1012
|
+
* that index.
|
|
1013
|
+
*
|
|
1014
|
+
* When you remove indexed data using this function, you are removing all
|
|
1015
|
+
* records that match the specified resource name and arguments, regardless of
|
|
1016
|
+
* their index values.
|
|
1017
|
+
*
|
|
1018
|
+
* @param resourceName - Resource name of the indexed data to remove, such as
|
|
1019
|
+
* `"player_score_history"` or `"enemy_spawn_events"`.
|
|
1020
|
+
* @param arguments_ - Arguments that further specify the indexed data to
|
|
1021
|
+
* remove. The specific arguments needed depend on how the indexed data was
|
|
1022
|
+
* originally written to the database.
|
|
1023
|
+
*/
|
|
1024
|
+
declare function libertasDataRemoveIndexed(
|
|
1025
|
+
resourceName: string,
|
|
1026
|
+
arguments_: readonly NotificationArgument[],
|
|
1027
|
+
): void;
|
|
1028
|
+
|
|
1029
|
+
/**
|
|
1030
|
+
* Removes indexed records in the given index range.
|
|
1031
|
+
*
|
|
1032
|
+
* @param db - Database handle. See `libertasDataOpenIndexed` for obtaining the
|
|
1033
|
+
* handle.
|
|
1034
|
+
* @param indexLo - Lower index bound, inclusive.
|
|
1035
|
+
* @param indexHi - Upper index bound, inclusive.
|
|
1036
|
+
*/
|
|
1037
|
+
declare function libertasDataRemoveIndexedRecords(
|
|
1038
|
+
db: LibertasDataStore,
|
|
1039
|
+
indexLo: number | bigint,
|
|
1040
|
+
indexHi: number | bigint,
|
|
1041
|
+
): void;
|
|
1042
|
+
|
|
1043
|
+
/**
|
|
1044
|
+
* Opens indexed data and returns its handle with stats.
|
|
1045
|
+
*
|
|
1046
|
+
* @param resourceName - Resource identifier.
|
|
1047
|
+
* @param arguments_ - Resource arguments.
|
|
1048
|
+
*
|
|
1049
|
+
* @returns Indexed data stats with handle, count, and index range. If `count`
|
|
1050
|
+
* is `0`, then `minIndex` and `maxIndex` are undefined.
|
|
1051
|
+
*
|
|
1052
|
+
* @throws If the indexed data cannot be opened.
|
|
1053
|
+
*/
|
|
1054
|
+
declare function libertasDataOpenIndexed(
|
|
1055
|
+
resourceName: string,
|
|
1056
|
+
arguments_: readonly NotificationArgument[],
|
|
1057
|
+
): IndexedDataStat;
|
|
1058
|
+
|
|
1059
|
+
/**
|
|
1060
|
+
* Writes data to the standalone database.
|
|
1061
|
+
*
|
|
1062
|
+
* @param resourceName - Resource identifier.
|
|
1063
|
+
* @param arguments_ - Resource arguments.
|
|
1064
|
+
* @param data - Encodable data.
|
|
1065
|
+
*/
|
|
1066
|
+
declare function libertasDataWrite(
|
|
1067
|
+
resourceName: string,
|
|
1068
|
+
arguments_: readonly NotificationArgument[],
|
|
1069
|
+
data: any,
|
|
1070
|
+
): void;
|
|
1071
|
+
|
|
1072
|
+
/**
|
|
1073
|
+
* Writes indexed data.
|
|
1074
|
+
*
|
|
1075
|
+
* @param db - Database handle. See `libertasDataOpenIndexed` for obtaining the
|
|
1076
|
+
* handle.
|
|
1077
|
+
* @param index - Record index.
|
|
1078
|
+
* @param data - Encodable data.
|
|
1079
|
+
*/
|
|
1080
|
+
declare function libertasDataWriteIndexed(
|
|
1081
|
+
db: LibertasDataStore,
|
|
1082
|
+
index: number | bigint,
|
|
1083
|
+
data: any,
|
|
1084
|
+
): void ;
|
|
1085
|
+
|
|
1086
|
+
/**
|
|
1087
|
+
* Reads standalone data.
|
|
1088
|
+
*
|
|
1089
|
+
* @typeParam T - Decoded data type.
|
|
1090
|
+
*
|
|
1091
|
+
* @param resourceName - Resource identifier.
|
|
1092
|
+
* @param arguments_ - Resource arguments.
|
|
1093
|
+
*
|
|
1094
|
+
* @returns Decoded data, or `undefined` if not found.
|
|
1095
|
+
*/
|
|
1096
|
+
declare function libertasDataRead<T> (
|
|
1097
|
+
resourceName: string,
|
|
1098
|
+
arguments_: readonly NotificationArgument[]
|
|
1099
|
+
): T | undefined;
|
|
1100
|
+
|
|
1101
|
+
/**
|
|
1102
|
+
* Reads an indexed data range.
|
|
1103
|
+
*
|
|
1104
|
+
* @typeParam T - Decoded data type.
|
|
1105
|
+
*
|
|
1106
|
+
* @param db - Database handle. See `libertasDataOpenIndexed` for obtaining the
|
|
1107
|
+
* handle.
|
|
1108
|
+
* @param index - Starting index.
|
|
1109
|
+
* @param direction - Read direction.
|
|
1110
|
+
* @param maxN - Maximum number of records to read.
|
|
1111
|
+
*
|
|
1112
|
+
* @returns Decoded indexed records.
|
|
1113
|
+
*/
|
|
1114
|
+
declare function libertasDataReadIndexedRange<T> (
|
|
1115
|
+
db: LibertasDataStore,
|
|
1116
|
+
index: bigint,
|
|
1117
|
+
direction: IndexDirection,
|
|
1118
|
+
maxN: number,
|
|
1119
|
+
): IndexedData<T>[];
|
|
1120
|
+
|
|
1121
|
+
/**
|
|
1122
|
+
* Reads a single indexed data record.
|
|
1123
|
+
*
|
|
1124
|
+
* @typeParam T - Decoded data type.
|
|
1125
|
+
*
|
|
1126
|
+
* @param db - Database handle. See `libertasDataOpenIndexed` for obtaining the
|
|
1127
|
+
* handle.
|
|
1128
|
+
* @param index - Record index.
|
|
1129
|
+
*
|
|
1130
|
+
* @returns Decoded record, or `undefined` if not found.
|
|
1131
|
+
*/
|
|
1132
|
+
declare function libertasDataReadIndexed<T>(
|
|
1133
|
+
db: LibertasDataStore,
|
|
1134
|
+
index: number | bigint,
|
|
1135
|
+
): T | undefined;
|
|
1136
|
+
|
|
1137
|
+
/**
|
|
1138
|
+
* Log levels
|
|
1139
|
+
*/
|
|
1140
|
+
declare const enum LibertasLogLevel {
|
|
1141
|
+
TRACE,
|
|
1142
|
+
DEBUG,
|
|
1143
|
+
INFO,
|
|
1144
|
+
WARN,
|
|
1145
|
+
ERROR,
|
|
1146
|
+
FATAL,
|
|
1147
|
+
}
|
|
1148
|
+
|
|
1149
|
+
/**
|
|
1150
|
+
* Write a message to system log.
|
|
1151
|
+
* @param level Log level.
|
|
1152
|
+
* @param message A text message.
|
|
1153
|
+
*
|
|
1154
|
+
* @remarks The log source is the name of the Thing-App task.
|
|
1155
|
+
*/
|
|
1156
|
+
declare function libertasLog(level: LibertasLogLevel, message: string): void;
|
|
1157
|
+
|
|
1158
|
+
declare namespace Libertas {
|
|
1159
|
+
/**
|
|
1160
|
+
* The device type constants. Compatible with the Zigbee protocol with Libertas-specific additions.
|
|
1161
|
+
*/
|
|
1162
|
+
export enum DeviceType {
|
|
1163
|
+
NA = 0xFFFF,
|
|
1164
|
+
ANY = 0xFFFF,
|
|
1165
|
+
// LIBERTAS
|
|
1166
|
+
TASK = 0xF000,
|
|
1167
|
+
PROXIMITY_SENSOR = 0xF001,
|
|
1168
|
+
GEN_MULTISTATE = 0xF002,
|
|
1169
|
+
SPRINKLER_CONTROLLER = 0xF003,
|
|
1170
|
+
}
|
|
1171
|
+
|
|
1172
|
+
/**
|
|
1173
|
+
* The Libertas cluster constants. Compatible with the Zigbee protocol with Libertas-specific additions.
|
|
1174
|
+
*
|
|
1175
|
+
* Clusters are a group of commands and attributes that define what a device can do. Think of clusters as a group of actions by function. A device can support multiple clusters to do a whole variety of tasks.
|
|
1176
|
+
*
|
|
1177
|
+
* In another word, Clusters specify the capabilities of a device.
|
|
1178
|
+
*
|
|
1179
|
+
*/
|
|
1180
|
+
export enum LibertasClusterId {
|
|
1181
|
+
// General Clusters
|
|
1182
|
+
INVALID = 0xFFFF,
|
|
1183
|
+
// Clusters
|
|
1184
|
+
LIBERTAS_SWITCH_CONFIG = 0xFC00,
|
|
1185
|
+
LIBERTAS_SWITCH_LINKABLE = 0xFC01,
|
|
1186
|
+
LIBERTAS_LEVEL_CONFIG = 0xFC02,
|
|
1187
|
+
LIBERTAS_LEVEL_DISPLAY = 0xFC03,
|
|
1188
|
+
LIBERTAS_BACKLIGHT_LEVEL = 0xFC04,
|
|
1189
|
+
LIBERTAS_BACKLIGHT_CONFIG = 0xFC05,
|
|
1190
|
+
LIBERTAS_ONOFF_CONFIG = 0xFC06,
|
|
1191
|
+
LIBERTAS_GEN_SENSOR = 0xFC07,
|
|
1192
|
+
LIBERTAS_FLASH_MEMORY = 0xFC10,
|
|
1193
|
+
LIBERTAS_UI = 0xFC20,
|
|
1194
|
+
LIBERTAS_REMOTE = 0xFC30,
|
|
1195
|
+
LIBERTAS_THERMOSTAT = 0xFC40,
|
|
1196
|
+
LIBERTAS_THERMOSTAT_HEAT = 0xFC41,
|
|
1197
|
+
LIBERTAS_THERMOSTAT_COOL = 0xFC42,
|
|
1198
|
+
LIBERTAS_THERMOSTAT_AUX = 0xFC43,
|
|
1199
|
+
LIBERTAS_PROXIMITY = 0xFC50,
|
|
1200
|
+
LIBERTAS_SPRINKLER_CONFIG = 0xFC60,
|
|
1201
|
+
LIBERTAS_HUB = 0xFC70,
|
|
1202
|
+
LIBERTAS_APP = 0xFC80,
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
/**
|
|
1206
|
+
* Attributes are a set of properties within a Cluster.
|
|
1207
|
+
*
|
|
1208
|
+
* Each attribute is identified by an ID (16-bit integer), along with a predefined data type.
|
|
1209
|
+
*
|
|
1210
|
+
*/
|
|
1211
|
+
export enum LibertasAttrId {
|
|
1212
|
+
LIBERTAS_HVAC_THERMOSTAT_LOCAL_HUMIDITY = 0x8000,
|
|
1213
|
+
LIBERTAS_HVAC_THERMOSTAT_LOCAL_HUMIDITY_CALIBRATION = 0x8001,
|
|
1214
|
+
LIBERTAS_HVAC_THERMOSTAT_HUMIDITY_LOW = 0x8002,
|
|
1215
|
+
LIBERTAS_HVAC_THERMOSTAT_HUMIDITY_HIGH = 0x8003,
|
|
1216
|
+
LIBERTAS_HVAC_THERMOSTAT_HEAT_USES_AUX = 0x8004,
|
|
1217
|
+
|
|
1218
|
+
// Power CFG
|
|
1219
|
+
LIBERTAS_POWER_CFG_BATTERY_VOLTAGE = 0x8020,
|
|
1220
|
+
|
|
1221
|
+
// Required
|
|
1222
|
+
LIBERTAS_SWITCH_LINKED_TO = 0x0000,
|
|
1223
|
+
|
|
1224
|
+
// In qwha_switch.h
|
|
1225
|
+
// qwha_switch_type_t
|
|
1226
|
+
LIBERTAS_SWITCH_TYPE = 0x0000,
|
|
1227
|
+
LIBERTAS_SWITCH_CLUSTER = 0x0001,
|
|
1228
|
+
LIBERTAS_SWITCH_PRESS_DELAY = 0x0002,
|
|
1229
|
+
LIBERTAS_SWITCH_ACTION_COMMANDS_1 = 0x0003,
|
|
1230
|
+
LIBERTAS_SWITCH_ACTION_COMMANDS_2 = 0x0004,
|
|
1231
|
+
LIBERTAS_SWITCH_LOAD_DEVICE = 0x0005,
|
|
1232
|
+
|
|
1233
|
+
// ZCL_CLUSTER_ID_LIBERTAS_LEVEL_CONFIG
|
|
1234
|
+
LIBERTAS_LEVEL_MAX = 0x0000,
|
|
1235
|
+
LIBERTAS_LEVEL_MIN = 0x0001,
|
|
1236
|
+
LIBERTAS_LEVEL_STEP_ONLY = 0x0002,
|
|
1237
|
+
LIBERTAS_LEVEL_STEP_SINGLE = 0x0003,
|
|
1238
|
+
LIBERTAS_LEVEL_STEP_REPEAT = 0x0004,
|
|
1239
|
+
LIBERTAS_LEVEL_STEP_INTERVAL = 0x0005,
|
|
1240
|
+
// ZCL_CLUSTER_ID_LIBERTAS_LEVEL_DISPLAY
|
|
1241
|
+
LIBERTAS_LEVEL_DISPLAY_OFFSET = 0x0000,
|
|
1242
|
+
LIBERTAS_LEVEL_DISPLAY_SCALE = 0x0001,
|
|
1243
|
+
LIBERTAS_LEVEL_DISPLAY_DIGITS = 0x0002,
|
|
1244
|
+
LIBERTAS_LEVEL_DISPLAY_FLAGS = 0x0003,
|
|
1245
|
+
// ZCL_CLUSTER_ID_LIBERTAS_BACKLIGHT
|
|
1246
|
+
LIBERTAS_BACKLIGHT_LEVEL = 0x0000,
|
|
1247
|
+
LIBERTAS_BACKLIGHT_ON_PATTERN = 0x0001,
|
|
1248
|
+
LIBERTAS_BACKLIGHT_OFF_PATTERN = 0x0002,
|
|
1249
|
+
LIBERTAS_BACKLIGHT_ANI_PATTERN = 0x0003,
|
|
1250
|
+
// ZCL_CLUSTER_ID_LIBERTAS_REMOTE
|
|
1251
|
+
LIBERTAS_REMOTE_BUTTON_CONFIG = 0x0000,
|
|
1252
|
+
// ZCL_CLUSTER_ID_LIBERTAS_ONOFF_CONFIG
|
|
1253
|
+
LIBERTAS_ONOFF_DEFAULT_ON_TIME = 0x0000,
|
|
1254
|
+
LIBERTAS_ONOFF_DEFAULT_OFF_WAIT_TIME = 0x0001,
|
|
1255
|
+
LIBERTAS_ONOFF_TIME_INTERVAL = 0x0002,
|
|
1256
|
+
|
|
1257
|
+
// ZCL_CLUSTER_ID_LIBERTAS_THERMOSTAT
|
|
1258
|
+
LIBERTAS_THERMOSTAT_COOL_HVAC_UNIT_ID = 0x0000,
|
|
1259
|
+
LIBERTAS_THERMOSTAT_HEAT_HVAC_UNIT_ID = 0x0001,
|
|
1260
|
+
LIBERTAS_THERMOSTAT_COOL_TYPE = 0x0002,
|
|
1261
|
+
LIBERTAS_THERMOSTAT_HEAT_TYPE = 0x0003,
|
|
1262
|
+
LIBERTAS_THERMOSTAT_AUX_HEAT_TYPE = 0x0004,
|
|
1263
|
+
LIBERTAS_THERMOSTAT_COOL_STAGES = 0x0005,
|
|
1264
|
+
LIBERTAS_THERMOSTAT_HEAT_STAGES = 0x0006,
|
|
1265
|
+
LIBERTAS_THERMOSTAT_AUX_HEAT_STAGES = 0x0007,
|
|
1266
|
+
LIBERTAS_THERMOSTAT_FAN_STAGES = 0x0008,
|
|
1267
|
+
LIBERTAS_THERMOSTAT_HEAT_PUMP_OB_ON_COOL = 0x0009,
|
|
1268
|
+
LIBERTAS_THERMOSTAT_FAN_USAGE = 0x000A,
|
|
1269
|
+
LIBERTAS_THERMOSTAT_ACC_TYPE = 0x000B,
|
|
1270
|
+
LIBERTAS_THERMOSTAT_ACC_EXT_POWER = 0x000C,
|
|
1271
|
+
|
|
1272
|
+
// Cool or heat parameters
|
|
1273
|
+
LIBERTAS_THERMOSTAT_MIN_OFF_TIME = 0x0010,
|
|
1274
|
+
LIBERTAS_THERMOSTAT_MIN_ON_TIME = 0x0011,
|
|
1275
|
+
LIBERTAS_THERMOSTAT_MAINTENANCE_BAND = 0x0012,
|
|
1276
|
+
LIBERTAS_THERMOSTAT_DISSIPATION_TIME = 0x0013,
|
|
1277
|
+
LIBERTAS_THERMOSTAT_STAGE1_TEMP_DELTA = 0x0014,
|
|
1278
|
+
LIBERTAS_THERMOSTAT_STAGE1_MAX_RUNTIME = 0x0015,
|
|
1279
|
+
LIBERTAS_THERMOSTAT_STAGE2_TEMP_DELTA = 0x0016,
|
|
1280
|
+
LIBERTAS_THERMOSTAT_STAGE2_MAX_RUNTIME = 0x0017,
|
|
1281
|
+
LIBERTAS_THERMOSTAT_STAGE3_TEMP_DELTA = 0x0018,
|
|
1282
|
+
|
|
1283
|
+
//LIBERTAS_HUB
|
|
1284
|
+
|
|
1285
|
+
/**
|
|
1286
|
+
* Minimum state of a multi-state device, for {@link LibertasClusterId.LIBERTAS_HUB}.
|
|
1287
|
+
*
|
|
1288
|
+
* @remarks This attribute can be generated by a virtual device driver App. Date type is int16.
|
|
1289
|
+
*/
|
|
1290
|
+
LIBERTAS_MULTISTATE_MIN = 0x0004, // int16
|
|
1291
|
+
/**
|
|
1292
|
+
* Maximum state of a multi-state device, for {@link LibertasClusterId.LIBERTAS_HUB}.
|
|
1293
|
+
*
|
|
1294
|
+
* @remarks This attribute can be generated by a virtual device driver App. Date type is int16.
|
|
1295
|
+
*/
|
|
1296
|
+
LIBERTAS_MULTISTATE_MAX = 0x0005, // int16
|
|
1297
|
+
/**
|
|
1298
|
+
* Constrains valid values of a multi-state device, for {@link LibertasClusterId.LIBERTAS_HUB}.
|
|
1299
|
+
*/
|
|
1300
|
+
LIBERTAS_MULTISTATE_VALUES = 0x0006, // int16 array
|
|
1301
|
+
/**
|
|
1302
|
+
* Name of states of a multi-state device, for {@link LibertasClusterId.LIBERTAS_HUB}.
|
|
1303
|
+
*/
|
|
1304
|
+
LIBERTAS_MULTISTATE_NAMES = 0x0007, // string array
|
|
1305
|
+
}
|
|
1306
|
+
|
|
1307
|
+
/**
|
|
1308
|
+
* A logical device can be either load or non-load device.
|
|
1309
|
+
*
|
|
1310
|
+
* For example, a "dummy" button is a non-load device because it can only be used to control other devices by sending control signals.
|
|
1311
|
+
*
|
|
1312
|
+
* Sensors are considered "load" devices.
|
|
1313
|
+
*
|
|
1314
|
+
* @remarks
|
|
1315
|
+
* Only load devices are allowed within an IoT App. Non-load buttons are managed internally by the system through end-user device group linking.
|
|
1316
|
+
*
|
|
1317
|
+
* As an exception, virtual devices can be either load or non-load type because it makes sense to emulate a non-load device (such as a button) with app code and expose the virtual device to the system.
|
|
1318
|
+
*
|
|
1319
|
+
*/
|
|
1320
|
+
export enum LibertasDeviceLoadType {
|
|
1321
|
+
LOAD_NON = 0,
|
|
1322
|
+
LOAD = 1,
|
|
1323
|
+
LOAD_ANY = 2,
|
|
1324
|
+
}
|
|
1325
|
+
}
|
|
1326
|
+
|
|
1327
|
+
declare namespace Matter {
|
|
1328
|
+
/**
|
|
1329
|
+
* Interaction model status codes.
|
|
1330
|
+
*/
|
|
1331
|
+
export enum Status {
|
|
1332
|
+
Success = 0x0,
|
|
1333
|
+
Failure = 0x01,
|
|
1334
|
+
InvalidSubscription = 0x7d,
|
|
1335
|
+
UnsupportedAccess = 0x7e,
|
|
1336
|
+
UnsupportedEndpoint = 0x7f,
|
|
1337
|
+
InvalidAction = 0x80,
|
|
1338
|
+
UnsupportedCommand = 0x81,
|
|
1339
|
+
Deprecated82 = 0x82,
|
|
1340
|
+
Deprecated83 = 0x83,
|
|
1341
|
+
Deprecated84 = 0x84,
|
|
1342
|
+
InvalidCommand = 0x85,
|
|
1343
|
+
UnsupportedAttribute = 0x86,
|
|
1344
|
+
ConstraintError = 0x87,
|
|
1345
|
+
UnsupportedWrite = 0x88,
|
|
1346
|
+
ResourceExhausted = 0x89,
|
|
1347
|
+
Deprecated8a = 0x8a,
|
|
1348
|
+
NotFound = 0x8b,
|
|
1349
|
+
UnreportableAttribute = 0x8c,
|
|
1350
|
+
InvalidDataType = 0x8d,
|
|
1351
|
+
Deprecated8e = 0x8e,
|
|
1352
|
+
UnsupportedRead = 0x8f,
|
|
1353
|
+
Deprecated90 = 0x90,
|
|
1354
|
+
Deprecated91 = 0x91,
|
|
1355
|
+
DataVersionMismatch = 0x92,
|
|
1356
|
+
Deprecated93 = 0x93,
|
|
1357
|
+
Timeout = 0x94,
|
|
1358
|
+
Reserved95 = 0x95,
|
|
1359
|
+
Reserved96 = 0x96,
|
|
1360
|
+
Reserved97 = 0x97,
|
|
1361
|
+
Reserved98 = 0x98,
|
|
1362
|
+
Reserved99 = 0x99,
|
|
1363
|
+
Reserved9a = 0x9a,
|
|
1364
|
+
Busy = 0x9c,
|
|
1365
|
+
Deprecatedc0 = 0xc0,
|
|
1366
|
+
Deprecatedc1 = 0xc1,
|
|
1367
|
+
Deprecatedc2 = 0xc2,
|
|
1368
|
+
UnsupportedCluster = 0xc3,
|
|
1369
|
+
Deprecatedc4 = 0xc4,
|
|
1370
|
+
NoUpstreamSubscription = 0xc5,
|
|
1371
|
+
NeedsTimedInteraction = 0xc6,
|
|
1372
|
+
UnsupportedEvent = 0xc7,
|
|
1373
|
+
PathsExhausted = 0xc8,
|
|
1374
|
+
TimedRequestMismatch = 0xc9,
|
|
1375
|
+
FailsafeRequired = 0xca,
|
|
1376
|
+
InvalidInState = 0xcb,
|
|
1377
|
+
NoCommandResponse = 0xcc,
|
|
1378
|
+
WriteIgnored = 0xF0, // non-spec error code and use only internally
|
|
1379
|
+
}
|
|
1380
|
+
}
|