mini_program_gizwits_sdk 3.4.0-beta → 3.4.0-beta.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/dist/index.d.ts +6 -1008
- package/dist/index.js +8 -1
- package/dist/src/GizLog.d.ts +18 -0
- package/dist/src/errorCode.d.ts +5 -0
- package/dist/src/globalData.d.ts +2 -0
- package/dist/src/handler/EventListener.d.ts +9 -0
- package/dist/src/handler/ble.d.ts +149 -0
- package/dist/src/handler/lan.d.ts +93 -0
- package/dist/src/handler/socket.d.ts +139 -0
- package/dist/src/openApiRequest.d.ts +7 -0
- package/dist/src/productConfigFileManage.d.ts +13 -0
- package/dist/src/protocol/Bind.d.ts +7 -0
- package/dist/src/protocol/DataPoint.d.ts +68 -0
- package/dist/src/protocol/DeviceInfo.d.ts +11 -0
- package/dist/src/protocol/DiscoverUdp.d.ts +17 -0
- package/dist/src/protocol/GetDeviceStatus.d.ts +5 -0
- package/dist/src/protocol/Login.d.ts +12 -0
- package/dist/src/protocol/Ntp.d.ts +5 -0
- package/dist/src/protocol/OTA/CheckCanOTA.d.ts +10 -0
- package/dist/src/protocol/OTA/PreOTA.d.ts +6 -0
- package/dist/src/protocol/OffLineData.d.ts +23 -0
- package/dist/src/protocol/ProtocolBase.d.ts +11 -0
- package/dist/src/protocol/Reset.d.ts +8 -0
- package/dist/src/protocol/SetReset.d.ts +7 -0
- package/dist/src/protocol/WifiConfig.d.ts +6 -0
- package/dist/src/protocol/tool.d.ts +12 -0
- package/dist/src/randomCode.d.ts +7 -0
- package/dist/src/request.d.ts +1 -0
- package/dist/src/sdk.d.ts +224 -0
- package/dist/src/sentry.d.ts +2 -0
- package/dist/src/services/devices.d.ts +63 -0
- package/dist/src/services/login.d.ts +8 -0
- package/dist/src/services/ota.d.ts +9 -0
- package/dist/src/services/tool.d.ts +4 -0
- package/dist/src/services/uploadP0.d.ts +13 -0
- package/dist/src/sleep.d.ts +2 -0
- package/dist/src/utils.d.ts +50 -0
- package/dist/src/wechatApi.d.ts +39 -0
- package/dist/src/wifiConfig/ConfigBase.d.ts +26 -0
- package/dist/src/wifiConfig/ap.d.ts +21 -0
- package/dist/src/wifiConfig/ble.d.ts +44 -0
- package/package.json +1 -1
- package/src/handler/ble.ts +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,1008 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
declare module 'mini_program_gizwits_sdk/src/GizLog' {
|
|
10
|
-
export type TLogType = 'debug' | 'info' | 'warn' | 'error';
|
|
11
|
-
class Log {
|
|
12
|
-
logMap: {
|
|
13
|
-
id: string;
|
|
14
|
-
}[];
|
|
15
|
-
console: Console;
|
|
16
|
-
debug: (...data: any[]) => void;
|
|
17
|
-
info: (...data: any[]) => void;
|
|
18
|
-
log: (...data: any[]) => void;
|
|
19
|
-
warn: (...data: any[]) => void;
|
|
20
|
-
error: (info: string, error: Error) => void;
|
|
21
|
-
setLogLevel: (type: TLogType) => {
|
|
22
|
-
success: boolean;
|
|
23
|
-
err: IError;
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
const _default: Log;
|
|
27
|
-
export default _default;
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
declare module 'mini_program_gizwits_sdk/src/errorCode' {
|
|
31
|
-
interface IErrorCode {
|
|
32
|
-
[key: string]: IError;
|
|
33
|
-
}
|
|
34
|
-
const errorCode: IErrorCode;
|
|
35
|
-
export default errorCode;
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
declare module 'mini_program_gizwits_sdk/src/globalData' {
|
|
39
|
-
export function setGlobalData(key: any, value: any): void;
|
|
40
|
-
export function getGlobalData(key: any): any;
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
declare module 'mini_program_gizwits_sdk/src/handler/EventListener' {
|
|
44
|
-
export default class EventListener<T> {
|
|
45
|
-
listenerMap: any;
|
|
46
|
-
addEventListener: <K extends keyof T>(type: K, func: T[K]) => Promise<{
|
|
47
|
-
success: boolean;
|
|
48
|
-
}>;
|
|
49
|
-
removeEventListener: <K extends keyof T>(type: K, func: T[K]) => {
|
|
50
|
-
success: boolean;
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
declare module 'mini_program_gizwits_sdk/src/handler/ble' {
|
|
56
|
-
import { wrapErrorInfo } from 'mini_program_gizwits_sdk/src/utils';
|
|
57
|
-
import EventListener from 'mini_program_gizwits_sdk/src/handler/EventListener';
|
|
58
|
-
type GizBleDeviceListotifications = (devices: IDevice[]) => void;
|
|
59
|
-
type GizBleDeviceDataNotifications = (curDevice: WechatMiniprogram.OnBLECharacteristicValueChangeCallbackResult, hexString: string) => void;
|
|
60
|
-
type GizBleErrorNotifications = (err: {
|
|
61
|
-
errCode: number;
|
|
62
|
-
errMsg: string;
|
|
63
|
-
}) => void;
|
|
64
|
-
export interface TBleHandleEvent {
|
|
65
|
-
GizBleDeviceData: GizBleDeviceDataNotifications;
|
|
66
|
-
GizBleDeviceList: GizBleDeviceListotifications;
|
|
67
|
-
GizBleError: GizBleErrorNotifications;
|
|
68
|
-
}
|
|
69
|
-
export interface GizwitsWxBlueToothDevice extends WechatMiniprogram.BlueToothDevice {
|
|
70
|
-
communicationType: 'BLE_BROADCAST' | 'BLE';
|
|
71
|
-
}
|
|
72
|
-
interface BleHandleParams {
|
|
73
|
-
serviceUUIDSuffix: string;
|
|
74
|
-
characteristicUUIDSuffix: string;
|
|
75
|
-
}
|
|
76
|
-
export interface IStartScanResult {
|
|
77
|
-
scanList: IDevice[];
|
|
78
|
-
err?: ReturnType<typeof wrapErrorInfo>;
|
|
79
|
-
}
|
|
80
|
-
export type OnScanDevice = (scanList: IDevice[]) => void;
|
|
81
|
-
interface ConnectDevice {
|
|
82
|
-
deviceId?: string;
|
|
83
|
-
serviceId?: string;
|
|
84
|
-
characteristicId?: string;
|
|
85
|
-
errMsg?: string;
|
|
86
|
-
}
|
|
87
|
-
interface ConstructorParams {
|
|
88
|
-
pks: string[];
|
|
89
|
-
bleHandleParams?: BleHandleParams;
|
|
90
|
-
offlineThreshold?: number;
|
|
91
|
-
}
|
|
92
|
-
export class BleHandle extends EventListener<TBleHandleEvent> {
|
|
93
|
-
private serviceUUIDSuffix;
|
|
94
|
-
connectedList: ConnectDevice[];
|
|
95
|
-
private connectingDevId;
|
|
96
|
-
pks: string[];
|
|
97
|
-
private listenDevOfflineTimer;
|
|
98
|
-
private boradcastTimer;
|
|
99
|
-
private boradcastDataCache;
|
|
100
|
-
private baseServices;
|
|
101
|
-
private tmpBleData;
|
|
102
|
-
private tmpDataNum;
|
|
103
|
-
private disableScanFlag;
|
|
104
|
-
private peripheralServer;
|
|
105
|
-
private isActive;
|
|
106
|
-
private isInitSuccess;
|
|
107
|
-
private isRunInit;
|
|
108
|
-
private _offlineThreshold;
|
|
109
|
-
set offlineThreshold(value: any);
|
|
110
|
-
get offlineThreshold(): any;
|
|
111
|
-
scanList: IDevice[];
|
|
112
|
-
constructor({ pks, bleHandleParams, offlineThreshold, }: ConstructorParams);
|
|
113
|
-
private onBluetoothAdapterStateChange;
|
|
114
|
-
private onAppShow;
|
|
115
|
-
private onAppHide;
|
|
116
|
-
private listenDevOffline;
|
|
117
|
-
private openBluetoothAdapter;
|
|
118
|
-
private handleOnBLECharacteristicValueChange;
|
|
119
|
-
private notiDeviceDataToSdk;
|
|
120
|
-
private notifyError;
|
|
121
|
-
private notifyDevices;
|
|
122
|
-
private listenConnection;
|
|
123
|
-
private init;
|
|
124
|
-
checkPermission: () => Promise<{
|
|
125
|
-
data: {
|
|
126
|
-
discovering: boolean;
|
|
127
|
-
};
|
|
128
|
-
err: {
|
|
129
|
-
errorCode: string;
|
|
130
|
-
errorMessage: string;
|
|
131
|
-
};
|
|
132
|
-
success: boolean;
|
|
133
|
-
}>;
|
|
134
|
-
private getBluetoothAdapterState;
|
|
135
|
-
getDeviceStatus: (deviceId: string, productKey: string, gwDid?: string, attrNames?: string[]) => Promise<import("mini_program_gizwits_sdk/src/wechatApi").IWechatResult | {
|
|
136
|
-
success: boolean;
|
|
137
|
-
message: string;
|
|
138
|
-
} | {
|
|
139
|
-
success: boolean;
|
|
140
|
-
}>;
|
|
141
|
-
private updateDevice;
|
|
142
|
-
private updateCtime;
|
|
143
|
-
private checkDeviceIsChange;
|
|
144
|
-
private handleBluetoothDeviceFound;
|
|
145
|
-
startScan: (onScanDevice: OnScanDevice, delay?: number, services?: string[]) => Promise<IStartScanResult>;
|
|
146
|
-
stopScan: () => Promise<any>;
|
|
147
|
-
disableScan: () => Promise<WechatMiniprogram.BluetoothError>;
|
|
148
|
-
enableScan: () => void;
|
|
149
|
-
connectDevice: (deviceId: string) => Promise<{
|
|
150
|
-
success: boolean;
|
|
151
|
-
message: any;
|
|
152
|
-
}>;
|
|
153
|
-
private handleBindReq;
|
|
154
|
-
private handleLoginReq;
|
|
155
|
-
watchBleDevice: (deviceId: any, func: any) => Promise<{
|
|
156
|
-
success: boolean;
|
|
157
|
-
message: string;
|
|
158
|
-
}>;
|
|
159
|
-
writeBoradcast: (bleDeviceID: string, value: number[]) => Promise<{
|
|
160
|
-
success: boolean;
|
|
161
|
-
message: string;
|
|
162
|
-
} | {
|
|
163
|
-
success: boolean;
|
|
164
|
-
message?: undefined;
|
|
165
|
-
}>;
|
|
166
|
-
write: (bleDeviceID: string, value: ArrayBuffer) => Promise<import("mini_program_gizwits_sdk/src/wechatApi").IWechatResult | {
|
|
167
|
-
success: boolean;
|
|
168
|
-
message: string;
|
|
169
|
-
}>;
|
|
170
|
-
disConnectDevice: (deviceId: string) => Promise<{
|
|
171
|
-
err: string;
|
|
172
|
-
success: boolean;
|
|
173
|
-
}>;
|
|
174
|
-
private removeDevById;
|
|
175
|
-
private getTargetDevice;
|
|
176
|
-
destory: () => void;
|
|
177
|
-
}
|
|
178
|
-
export {};
|
|
179
|
-
|
|
180
|
-
}
|
|
181
|
-
declare module 'mini_program_gizwits_sdk/src/handler/lan' {
|
|
182
|
-
import DiscoverUDP from "mini_program_gizwits_sdk/src/protocol/DiscoverUDP";
|
|
183
|
-
import { IResult } from "mini_program_gizwits_sdk/src/sdk";
|
|
184
|
-
import EventListener from "mini_program_gizwits_sdk/src/handler/EventListener";
|
|
185
|
-
interface ConnectDevice {
|
|
186
|
-
mac: string;
|
|
187
|
-
productKey: string;
|
|
188
|
-
socketHandle: TCPHandler;
|
|
189
|
-
}
|
|
190
|
-
interface ILanDevice extends IDevice {
|
|
191
|
-
expandData: DiscoverUDP;
|
|
192
|
-
ip: string;
|
|
193
|
-
}
|
|
194
|
-
type GizLanDeviceListNotifications = (devices: IDevice[]) => void;
|
|
195
|
-
type GizLanDeviceDataNotifications = (mac: string, data: string) => void;
|
|
196
|
-
export interface TLanHandleEvent {
|
|
197
|
-
GizLanDeviceList: GizLanDeviceListNotifications;
|
|
198
|
-
GizLanDeviceData: GizLanDeviceDataNotifications;
|
|
199
|
-
}
|
|
200
|
-
export class LanHandle extends EventListener<TLanHandleEvent> {
|
|
201
|
-
connectedList: ConnectDevice[];
|
|
202
|
-
pks: string[];
|
|
203
|
-
scanList: ILanDevice[];
|
|
204
|
-
private boradcastTimer;
|
|
205
|
-
private UDPSocket;
|
|
206
|
-
private deviceUDPPort;
|
|
207
|
-
private appUDPPort;
|
|
208
|
-
private offlineThreshold;
|
|
209
|
-
private isActive;
|
|
210
|
-
private listenDevOfflineTimer;
|
|
211
|
-
constructor({ pks }: {
|
|
212
|
-
pks: any;
|
|
213
|
-
});
|
|
214
|
-
init: () => void;
|
|
215
|
-
private onAppShow;
|
|
216
|
-
private onAppHide;
|
|
217
|
-
private listenDevOffline;
|
|
218
|
-
private notifyDevices;
|
|
219
|
-
private notifyDeviceData;
|
|
220
|
-
isSameDevice: (deviceA: IDevice, deviceB: IDevice) => boolean;
|
|
221
|
-
disConnectDevice: (target: IDevice) => {
|
|
222
|
-
success: boolean;
|
|
223
|
-
err?: undefined;
|
|
224
|
-
} | {
|
|
225
|
-
success: boolean;
|
|
226
|
-
err: any;
|
|
227
|
-
};
|
|
228
|
-
onData: (mac: string, hexString: string) => void;
|
|
229
|
-
connectDevice: (device: any) => Promise<IResult<any>>;
|
|
230
|
-
onError: (err: any) => void;
|
|
231
|
-
isMatchPk: (pk: any) => boolean;
|
|
232
|
-
onMessage: (res: WechatMiniprogram.UDPSocketOnMessageCallbackResult) => void;
|
|
233
|
-
onDeviceClose: ({ productKey, mac }: {
|
|
234
|
-
productKey: any;
|
|
235
|
-
mac: any;
|
|
236
|
-
}) => void;
|
|
237
|
-
write: (device: IDevice, value: ArrayBuffer) => Promise<{
|
|
238
|
-
success: boolean;
|
|
239
|
-
} | {
|
|
240
|
-
success: boolean;
|
|
241
|
-
message: string;
|
|
242
|
-
}>;
|
|
243
|
-
updateDevice: (updateDevice: DiscoverUDP, ip: string) => void;
|
|
244
|
-
sendBoradCast: () => void;
|
|
245
|
-
private startDiscover;
|
|
246
|
-
destory: () => void;
|
|
247
|
-
}
|
|
248
|
-
interface ITCPHandlerProps {
|
|
249
|
-
ip: string;
|
|
250
|
-
mac: string;
|
|
251
|
-
productKey: string;
|
|
252
|
-
onClose: (ip: any) => void;
|
|
253
|
-
onData: (mac: string, data: string) => void;
|
|
254
|
-
}
|
|
255
|
-
class TCPHandler {
|
|
256
|
-
private deviceTCPPort;
|
|
257
|
-
private ip;
|
|
258
|
-
private productKey;
|
|
259
|
-
private mac;
|
|
260
|
-
private tcpHandler;
|
|
261
|
-
private onData;
|
|
262
|
-
private onCloseListener;
|
|
263
|
-
constructor({ ip, onClose, mac, productKey, onData }: ITCPHandlerProps);
|
|
264
|
-
connect: () => Promise<IResult<any>>;
|
|
265
|
-
write: (data: ArrayBuffer) => {
|
|
266
|
-
success: boolean;
|
|
267
|
-
};
|
|
268
|
-
onMessage: (message: any) => void;
|
|
269
|
-
onError: () => void;
|
|
270
|
-
onClose: () => void;
|
|
271
|
-
initListener: () => void;
|
|
272
|
-
destory: () => void;
|
|
273
|
-
}
|
|
274
|
-
export {};
|
|
275
|
-
|
|
276
|
-
}
|
|
277
|
-
declare module 'mini_program_gizwits_sdk/src/handler/socket' {
|
|
278
|
-
interface IRespError {
|
|
279
|
-
err?: IError;
|
|
280
|
-
}
|
|
281
|
-
interface IWriteRes {
|
|
282
|
-
success: boolean;
|
|
283
|
-
message: string;
|
|
284
|
-
}
|
|
285
|
-
interface ICommonProps {
|
|
286
|
-
appID: string;
|
|
287
|
-
token: string;
|
|
288
|
-
uid: string;
|
|
289
|
-
}
|
|
290
|
-
interface IGWSProps extends ICommonProps {
|
|
291
|
-
limitSocketNum?: boolean;
|
|
292
|
-
}
|
|
293
|
-
export default class GizwitsWS {
|
|
294
|
-
appID: string;
|
|
295
|
-
token: string;
|
|
296
|
-
uid: string;
|
|
297
|
-
_maxSocketNum: number;
|
|
298
|
-
_bindingDevices: {
|
|
299
|
-
[did: string]: IDevice;
|
|
300
|
-
} | null;
|
|
301
|
-
_connections: {
|
|
302
|
-
[wsInfo: string]: Connection;
|
|
303
|
-
};
|
|
304
|
-
_onDeviceStatusChanged?: IOnDeviceStatusChanged;
|
|
305
|
-
_onSocketStatusChanged?: IOnSocketStatusChanged;
|
|
306
|
-
_onBindingChanged?: IEmptyFn;
|
|
307
|
-
constructor({ appID, token, uid, limitSocketNum, }: IGWSProps);
|
|
308
|
-
init(): Promise<IError>;
|
|
309
|
-
updateToken: ({ token, uid }: {
|
|
310
|
-
token: any;
|
|
311
|
-
uid: any;
|
|
312
|
-
}) => void;
|
|
313
|
-
_getDevice: (did: string) => IError | IDevice;
|
|
314
|
-
_getConnect: (device: IDevice) => Connection;
|
|
315
|
-
_getDeviceAndConnect: (did: string) => IError | [IDevice, Connection];
|
|
316
|
-
connectDevice: (device: IDevice) => {
|
|
317
|
-
success: boolean;
|
|
318
|
-
errorCode: IError;
|
|
319
|
-
} | {
|
|
320
|
-
success: boolean;
|
|
321
|
-
errorCode?: undefined;
|
|
322
|
-
};
|
|
323
|
-
disConnectDevice: (device: IDevice) => {
|
|
324
|
-
success: boolean;
|
|
325
|
-
};
|
|
326
|
-
connect: (did: string) => IError;
|
|
327
|
-
send: (device: IDevice, raw: number[]) => Promise<IWriteRes> | {
|
|
328
|
-
success: boolean;
|
|
329
|
-
};
|
|
330
|
-
writeData: (device: IDevice, attrs: ICommonObj) => Promise<IWriteRes> | {
|
|
331
|
-
success: boolean;
|
|
332
|
-
};
|
|
333
|
-
write: (did: string, attrs: ICommonObj) => IError | Promise<IWriteRes>;
|
|
334
|
-
readStatus: (device: IDevice, names?: string[]) => {
|
|
335
|
-
success: boolean;
|
|
336
|
-
};
|
|
337
|
-
read: (did: string, names?: string[]) => IError | Promise<IWriteRes>;
|
|
338
|
-
destory: () => void;
|
|
339
|
-
subscribeDeviceStatus: (cb: IOnDeviceStatusChanged) => void;
|
|
340
|
-
subscribeBindingChanged: (cb: IEmptyFn) => void;
|
|
341
|
-
subscribeSocketStatus: (cb: IOnSocketStatusChanged) => void;
|
|
342
|
-
_handleDeviceStatusChanged: IOnDeviceStatusChanged;
|
|
343
|
-
_handleBindingChanged: () => void;
|
|
344
|
-
_handleSocketStatusChanged: IOnSocketStatusChanged;
|
|
345
|
-
_getBindingList: (limit?: number, skip?: number, cacheList?: IDevice[]) => Promise<IDevice[] | IRespError>;
|
|
346
|
-
_getWebsocketConnInfo: (device: any) => string;
|
|
347
|
-
}
|
|
348
|
-
interface IConnectProps extends ICommonProps {
|
|
349
|
-
wsInfo: string;
|
|
350
|
-
onDeviceStatusChanged?: IOnDeviceStatusChanged;
|
|
351
|
-
onBindingChanged?: IEmptyFn;
|
|
352
|
-
onSocketStatusChanged?: IOnSocketStatusChanged;
|
|
353
|
-
}
|
|
354
|
-
export class Connection {
|
|
355
|
-
ready: boolean;
|
|
356
|
-
appID: string;
|
|
357
|
-
token: string;
|
|
358
|
-
uid: string;
|
|
359
|
-
commType: string;
|
|
360
|
-
_heartbeatInterval: number;
|
|
361
|
-
_keepaliveTime: number;
|
|
362
|
-
_loginIntveral: number;
|
|
363
|
-
autoSubscribe: boolean;
|
|
364
|
-
_wsUrl: string;
|
|
365
|
-
_websocket: WechatMiniprogram.SocketTask | null;
|
|
366
|
-
_heartbeatTimerId?: any;
|
|
367
|
-
_loginFailedTimes: number;
|
|
368
|
-
_subDids: Set<string>;
|
|
369
|
-
_socketRespHandleMap: {
|
|
370
|
-
[cmd: string]: (resp?: any) => void;
|
|
371
|
-
};
|
|
372
|
-
_onDeviceStatusChanged?: IOnDeviceStatusChanged;
|
|
373
|
-
_onBindingChanged?: IEmptyFn;
|
|
374
|
-
_onSocketStatusChanged?: IOnSocketStatusChanged;
|
|
375
|
-
_waitSends: object[];
|
|
376
|
-
_checkConnectTimerId?: any;
|
|
377
|
-
_needReportLoginSuccess: boolean;
|
|
378
|
-
constructor({ appID, token, uid, wsInfo, onDeviceStatusChanged, onBindingChanged, onSocketStatusChanged, }: IConnectProps);
|
|
379
|
-
destory: () => void;
|
|
380
|
-
_networkChange: (res: WechatMiniprogram.OnNetworkStatusChangeCallbackResult) => Promise<void>;
|
|
381
|
-
_appShow: () => Promise<void>;
|
|
382
|
-
_addSubDid: (did: any) => void;
|
|
383
|
-
_removeSubDid: (did: any) => void;
|
|
384
|
-
_connectWS: () => void;
|
|
385
|
-
_subDevices: (dids: string[]) => void;
|
|
386
|
-
_unSubDevices: (dids: string[]) => void;
|
|
387
|
-
_isControlByOpenApi: (data: Record<string, any>) => boolean;
|
|
388
|
-
_controlByOpenApi: (data: Record<string, any>) => Promise<{
|
|
389
|
-
message: string;
|
|
390
|
-
success: boolean;
|
|
391
|
-
data?: unknown;
|
|
392
|
-
err?: IError;
|
|
393
|
-
}>;
|
|
394
|
-
_send: (data: Record<string, any>, forced?: boolean) => Promise<IWriteRes>;
|
|
395
|
-
close: () => void;
|
|
396
|
-
handleClose: (res: {
|
|
397
|
-
code: number;
|
|
398
|
-
reason: string;
|
|
399
|
-
}) => void;
|
|
400
|
-
handleOpen: () => void;
|
|
401
|
-
handleMessage: ({ data }: {
|
|
402
|
-
data: string | ArrayBuffer;
|
|
403
|
-
}) => void;
|
|
404
|
-
handleError: (err: {
|
|
405
|
-
errMsg: string;
|
|
406
|
-
}) => void;
|
|
407
|
-
_login: () => void;
|
|
408
|
-
_tryLoginAgain: () => void;
|
|
409
|
-
_startPing: () => void;
|
|
410
|
-
_stopPing: () => void;
|
|
411
|
-
pongResp: () => void;
|
|
412
|
-
_loginResp: (data: any) => void;
|
|
413
|
-
_consumeWaitSends: () => void;
|
|
414
|
-
_handleSocketStatusChanged: (enabled: boolean) => void;
|
|
415
|
-
_subscribeResp: (data: any) => void;
|
|
416
|
-
_onlineResp: (data: {
|
|
417
|
-
did: string;
|
|
418
|
-
online: boolean;
|
|
419
|
-
}) => void;
|
|
420
|
-
_rawChangedResp: (data: IDeviceRawStatusChangedProps) => void;
|
|
421
|
-
_statusChangedResp: (data: IDeviceStatusChangedProps) => void;
|
|
422
|
-
_isSub: (did: string) => boolean;
|
|
423
|
-
_invalidMsgResp: (data: any) => void;
|
|
424
|
-
_bindingChangedResp: (data: any) => void;
|
|
425
|
-
}
|
|
426
|
-
export {};
|
|
427
|
-
|
|
428
|
-
}
|
|
429
|
-
declare module 'mini_program_gizwits_sdk/src/openApiRequest' {
|
|
430
|
-
export interface IServiceResult<T> {
|
|
431
|
-
success: boolean;
|
|
432
|
-
data?: T;
|
|
433
|
-
err?: IError;
|
|
434
|
-
}
|
|
435
|
-
const openApiRequest: <T>(url: string, options: any, needToken?: boolean) => Promise<IServiceResult<T>>;
|
|
436
|
-
export default openApiRequest;
|
|
437
|
-
|
|
438
|
-
}
|
|
439
|
-
declare module 'mini_program_gizwits_sdk/src/productConfigFileManage' {
|
|
440
|
-
import { IDataPointConfig } from 'mini_program_gizwits_sdk/src/protocol/dataPoint';
|
|
441
|
-
interface IData {
|
|
442
|
-
[key: string]: IDataPointConfig;
|
|
443
|
-
}
|
|
444
|
-
class ProductConfigFileManage {
|
|
445
|
-
data: IData;
|
|
446
|
-
key: string;
|
|
447
|
-
init: () => Promise<void>;
|
|
448
|
-
getConfigFile: (pk: string) => Promise<IDataPointConfig>;
|
|
449
|
-
getAttrItem: (pk: string, key: string) => Promise<import("mini_program_gizwits_sdk/src/protocol/dataPoint").IDataPointAttr>;
|
|
450
|
-
}
|
|
451
|
-
const productConfigFileManage: ProductConfigFileManage;
|
|
452
|
-
export default productConfigFileManage;
|
|
453
|
-
|
|
454
|
-
}
|
|
455
|
-
declare module 'mini_program_gizwits_sdk/src/protocol/Bind' {
|
|
456
|
-
import ProtocolBase from "mini_program_gizwits_sdk/src/protocol/ProtocolBase";
|
|
457
|
-
class Bind extends ProtocolBase {
|
|
458
|
-
passcode: string;
|
|
459
|
-
constructor(data: number[]);
|
|
460
|
-
static pack: () => number[];
|
|
461
|
-
}
|
|
462
|
-
export default Bind;
|
|
463
|
-
|
|
464
|
-
}
|
|
465
|
-
declare module 'mini_program_gizwits_sdk/src/protocol/DiscoverUDP' {
|
|
466
|
-
import ProtocolBase from "mini_program_gizwits_sdk/src/protocol/ProtocolBase";
|
|
467
|
-
type TDecodeType = 'ASCII' | 'HEX';
|
|
468
|
-
class DiscoverUDP extends ProtocolBase {
|
|
469
|
-
did: string;
|
|
470
|
-
mac: string;
|
|
471
|
-
productKey: string;
|
|
472
|
-
deviceType: number;
|
|
473
|
-
apiUrl: string;
|
|
474
|
-
protocolVersion: string;
|
|
475
|
-
mcuVersion: string;
|
|
476
|
-
moduleVersion: string;
|
|
477
|
-
constructor(data: number[]);
|
|
478
|
-
parseEndChat: (index: any, key: any) => any;
|
|
479
|
-
baseParse: (index: any, key: any, type?: TDecodeType) => any;
|
|
480
|
-
static pack: () => Uint8Array;
|
|
481
|
-
}
|
|
482
|
-
export default DiscoverUDP;
|
|
483
|
-
|
|
484
|
-
}
|
|
485
|
-
declare module 'mini_program_gizwits_sdk/src/protocol/GetDeviceStatus' {
|
|
486
|
-
import ProtocolBase from "mini_program_gizwits_sdk/src/protocol/ProtocolBase";
|
|
487
|
-
class GetDeviceStatus extends ProtocolBase {
|
|
488
|
-
static pack: (productKey: string, gwDid?: string, attrNames?: string[]) => Promise<number[]>;
|
|
489
|
-
}
|
|
490
|
-
export default GetDeviceStatus;
|
|
491
|
-
|
|
492
|
-
}
|
|
493
|
-
declare module 'mini_program_gizwits_sdk/src/protocol/Login' {
|
|
494
|
-
import ProtocolBase from "mini_program_gizwits_sdk/src/protocol/ProtocolBase";
|
|
495
|
-
interface IPackParame {
|
|
496
|
-
passcode: string;
|
|
497
|
-
}
|
|
498
|
-
class Login extends ProtocolBase {
|
|
499
|
-
result: boolean;
|
|
500
|
-
didLength: number;
|
|
501
|
-
did: string;
|
|
502
|
-
constructor(data: number[]);
|
|
503
|
-
static pack: ({ passcode }: IPackParame) => number[];
|
|
504
|
-
}
|
|
505
|
-
export default Login;
|
|
506
|
-
|
|
507
|
-
}
|
|
508
|
-
declare module 'mini_program_gizwits_sdk/src/protocol/Ntp' {
|
|
509
|
-
import ProtocolBase from "mini_program_gizwits_sdk/src/protocol/ProtocolBase";
|
|
510
|
-
class Ntp extends ProtocolBase {
|
|
511
|
-
static pack: () => number[];
|
|
512
|
-
}
|
|
513
|
-
export default Ntp;
|
|
514
|
-
|
|
515
|
-
}
|
|
516
|
-
declare module 'mini_program_gizwits_sdk/src/protocol/OffLineData' {
|
|
517
|
-
import ProtocolBase from "mini_program_gizwits_sdk/src/protocol/ProtocolBase";
|
|
518
|
-
export class RequestSync extends ProtocolBase {
|
|
519
|
-
state: number;
|
|
520
|
-
len: number;
|
|
521
|
-
constructor(data: number[]);
|
|
522
|
-
static pack: () => number[];
|
|
523
|
-
}
|
|
524
|
-
export class SyncPackage extends ProtocolBase {
|
|
525
|
-
id: number;
|
|
526
|
-
timestemp: number;
|
|
527
|
-
payloadLen: number;
|
|
528
|
-
payload: number[];
|
|
529
|
-
constructor(data: number[]);
|
|
530
|
-
static pack: (id: number) => number[];
|
|
531
|
-
}
|
|
532
|
-
export class DeletePackage extends ProtocolBase {
|
|
533
|
-
static pack: (id: number) => number[];
|
|
534
|
-
}
|
|
535
|
-
export class CancelSync extends ProtocolBase {
|
|
536
|
-
state: number;
|
|
537
|
-
constructor(data: number[]);
|
|
538
|
-
static pack: () => number[];
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
}
|
|
542
|
-
declare module 'mini_program_gizwits_sdk/src/protocol/ProtocolBase' {
|
|
543
|
-
class ProtocolBase {
|
|
544
|
-
header: string;
|
|
545
|
-
len: number;
|
|
546
|
-
flag: number[];
|
|
547
|
-
cmd: string;
|
|
548
|
-
content: number[];
|
|
549
|
-
constructor(data?: number[]);
|
|
550
|
-
static decodeLen: (arr: any) => number;
|
|
551
|
-
formatP0: (data: any) => void;
|
|
552
|
-
}
|
|
553
|
-
export default ProtocolBase;
|
|
554
|
-
|
|
555
|
-
}
|
|
556
|
-
declare module 'mini_program_gizwits_sdk/src/protocol/Reset' {
|
|
557
|
-
import ProtocolBase from "mini_program_gizwits_sdk/src/protocol/ProtocolBase";
|
|
558
|
-
type IStatus = 0 | 1;
|
|
559
|
-
class Reset extends ProtocolBase {
|
|
560
|
-
status: IStatus;
|
|
561
|
-
constructor(data: number[]);
|
|
562
|
-
static pack: () => number[];
|
|
563
|
-
}
|
|
564
|
-
export default Reset;
|
|
565
|
-
|
|
566
|
-
}
|
|
567
|
-
declare module 'mini_program_gizwits_sdk/src/protocol/SetReset' {
|
|
568
|
-
import ProtocolBase from "mini_program_gizwits_sdk/src/protocol/ProtocolBase";
|
|
569
|
-
type IStatus = 0 | 1;
|
|
570
|
-
class SetReset extends ProtocolBase {
|
|
571
|
-
status: IStatus;
|
|
572
|
-
static pack: (status: 0 | 1) => number[];
|
|
573
|
-
}
|
|
574
|
-
export default SetReset;
|
|
575
|
-
|
|
576
|
-
}
|
|
577
|
-
declare module 'mini_program_gizwits_sdk/src/protocol/WifiConfig' {
|
|
578
|
-
import ProtocolBase from "mini_program_gizwits_sdk/src/protocol/ProtocolBase";
|
|
579
|
-
class WifiConfig extends ProtocolBase {
|
|
580
|
-
constructor(data: number[]);
|
|
581
|
-
static pack: (ssid: string, password: string) => Uint8Array;
|
|
582
|
-
}
|
|
583
|
-
export default WifiConfig;
|
|
584
|
-
|
|
585
|
-
}
|
|
586
|
-
declare module 'mini_program_gizwits_sdk/src/protocol/dataPoint' {
|
|
587
|
-
export interface IDataPointConfig {
|
|
588
|
-
name: string;
|
|
589
|
-
protocolType: 'var_len' | 'standard';
|
|
590
|
-
entities: IDataPointEntitie[];
|
|
591
|
-
}
|
|
592
|
-
interface IDataPointEntitie {
|
|
593
|
-
display_name: string;
|
|
594
|
-
attrs: IDataPointAttr[];
|
|
595
|
-
}
|
|
596
|
-
interface IDataPointPosition {
|
|
597
|
-
byte_offset: number;
|
|
598
|
-
unit: 'bit' | 'byte';
|
|
599
|
-
len: number;
|
|
600
|
-
bit_offset: number;
|
|
601
|
-
}
|
|
602
|
-
type TDataType = 'bool' | 'uint8' | 'uint16' | 'uint32' | 'binary' | 'enum' | 'number';
|
|
603
|
-
interface IUnitSpec {
|
|
604
|
-
addition: number;
|
|
605
|
-
max: number;
|
|
606
|
-
ratio: number;
|
|
607
|
-
min: number;
|
|
608
|
-
}
|
|
609
|
-
type TDataOptionType = 'status_writable' | 'status_readonly' | 'alert' | 'fault' | 'ALL';
|
|
610
|
-
export interface IDataPointAttr {
|
|
611
|
-
display_name: string;
|
|
612
|
-
uint_spec: IUnitSpec;
|
|
613
|
-
name: string;
|
|
614
|
-
data_type: TDataType;
|
|
615
|
-
position: IDataPointPosition;
|
|
616
|
-
type: TDataOptionType;
|
|
617
|
-
id: number;
|
|
618
|
-
enum: string[];
|
|
619
|
-
desc: string;
|
|
620
|
-
}
|
|
621
|
-
interface IRawData {
|
|
622
|
-
header: string;
|
|
623
|
-
len: string;
|
|
624
|
-
flag: string;
|
|
625
|
-
cmd: string;
|
|
626
|
-
sn: string;
|
|
627
|
-
action: string;
|
|
628
|
-
payload: string;
|
|
629
|
-
}
|
|
630
|
-
type messageType = 'APP2DEV' | 'DEV2APP' | 'UNKNOW';
|
|
631
|
-
const unpack: (data: number[], pk: string) => Promise<{
|
|
632
|
-
kvData: {};
|
|
633
|
-
rawData: IRawData;
|
|
634
|
-
message: string;
|
|
635
|
-
messageType: messageType;
|
|
636
|
-
}>;
|
|
637
|
-
const pack: (data: object, pk: string) => Promise<{
|
|
638
|
-
data: number[];
|
|
639
|
-
raw: {
|
|
640
|
-
header: number[];
|
|
641
|
-
flag: number[];
|
|
642
|
-
len: number[];
|
|
643
|
-
headerCmd: number[];
|
|
644
|
-
sn: number[];
|
|
645
|
-
cmd: number[];
|
|
646
|
-
};
|
|
647
|
-
}>;
|
|
648
|
-
const padBoradcastData: (data: number[]) => string;
|
|
649
|
-
type TargetType = 'int' | 'string';
|
|
650
|
-
const formatEnum: (attrs: any, pk: string, targetType: TargetType) => Promise<any>;
|
|
651
|
-
type BTargetType = 'string' | 'object';
|
|
652
|
-
const formatBinary: (attrs: any, pk: string, targetType: BTargetType) => Promise<any>;
|
|
653
|
-
export { pack, unpack, padBoradcastData, formatEnum, formatBinary };
|
|
654
|
-
|
|
655
|
-
}
|
|
656
|
-
declare module 'mini_program_gizwits_sdk/src/protocol/tool' {
|
|
657
|
-
const checkHeader: (data: any) => number | false;
|
|
658
|
-
export const completeBlock: (cmd: string) => number[];
|
|
659
|
-
const getProtocolLen: (data: any) => number;
|
|
660
|
-
function arrayToString(arr: number[]): string;
|
|
661
|
-
const fillString: (string: string, num: number, foot?: boolean) => string;
|
|
662
|
-
const string2Bytes: (str: string) => number[];
|
|
663
|
-
const hexStrint2byte: (str: string) => number[];
|
|
664
|
-
const formatCode: (str: any) => number[];
|
|
665
|
-
const formatCodesFromStr: (str: string) => number[][];
|
|
666
|
-
const arrayToUint8: (config: number[]) => Uint8Array;
|
|
667
|
-
export { checkHeader, getProtocolLen, arrayToString, fillString, string2Bytes, hexStrint2byte, formatCodesFromStr, formatCode, arrayToUint8 };
|
|
668
|
-
|
|
669
|
-
}
|
|
670
|
-
declare module 'mini_program_gizwits_sdk/src/randomCode' {
|
|
671
|
-
interface IGetRandomCodes {
|
|
672
|
-
SSID: string;
|
|
673
|
-
password: string;
|
|
674
|
-
pks: string[];
|
|
675
|
-
}
|
|
676
|
-
const getRandomCodes: ({ SSID, password, pks }: IGetRandomCodes) => string[];
|
|
677
|
-
export default getRandomCodes;
|
|
678
|
-
|
|
679
|
-
}
|
|
680
|
-
declare module 'mini_program_gizwits_sdk/src/request' {
|
|
681
|
-
export default function request<T>(url: string, options: any): Promise<T>;
|
|
682
|
-
|
|
683
|
-
}
|
|
684
|
-
declare module 'mini_program_gizwits_sdk/src/sdk' {
|
|
685
|
-
import { TLogType } from 'mini_program_gizwits_sdk/src/GizLog';
|
|
686
|
-
interface SyncCallBackParams {
|
|
687
|
-
event: TSyncEvnet;
|
|
688
|
-
currentNum?: number;
|
|
689
|
-
totalNum?: number;
|
|
690
|
-
message?: string;
|
|
691
|
-
}
|
|
692
|
-
type TSyncEvnet = 'SYNC_START' | 'SYNC_END' | 'SYNC_FAIL' | 'SYNC_CANCEL' | 'SYNC_PROGRESS';
|
|
693
|
-
export type SyncCallBack = (data: SyncCallBackParams) => void;
|
|
694
|
-
export interface ISDKResult<T> {
|
|
695
|
-
data?: T;
|
|
696
|
-
err?: IError;
|
|
697
|
-
message?: string;
|
|
698
|
-
success: boolean;
|
|
699
|
-
}
|
|
700
|
-
export interface ISetCommonDeviceOnboardingDeployProps {
|
|
701
|
-
ssid: string;
|
|
702
|
-
password: string;
|
|
703
|
-
timeout: number;
|
|
704
|
-
isBind?: boolean;
|
|
705
|
-
mode?: 0 | 3;
|
|
706
|
-
softAPSSIDPrefix?: string;
|
|
707
|
-
}
|
|
708
|
-
export interface ISetDeviceOnboardingDeployProps extends ISetCommonDeviceOnboardingDeployProps {
|
|
709
|
-
softAPSSIDPrefix: string;
|
|
710
|
-
}
|
|
711
|
-
export interface IRandomCodesResult {
|
|
712
|
-
random_code: string;
|
|
713
|
-
product_key: string;
|
|
714
|
-
mac: string;
|
|
715
|
-
did: string;
|
|
716
|
-
user_id: string;
|
|
717
|
-
timestamp: number;
|
|
718
|
-
type: string;
|
|
719
|
-
wifi_soft_ver: string;
|
|
720
|
-
lan_proto_ver: string;
|
|
721
|
-
}
|
|
722
|
-
interface IDeviceStatusNoti {
|
|
723
|
-
device: IDevice;
|
|
724
|
-
connectType: TConnectType;
|
|
725
|
-
}
|
|
726
|
-
interface IDeviceAttrsNoti {
|
|
727
|
-
device: IDevice;
|
|
728
|
-
data: object;
|
|
729
|
-
}
|
|
730
|
-
export interface TListenerType {
|
|
731
|
-
GizDeviceListNotifications: TDeviceListNotifications;
|
|
732
|
-
GizDeviceStatusNotifications: TDeviceStatusNotifications;
|
|
733
|
-
GizDeviceAttrsNotifications: TDeviceAttrsNotifications;
|
|
734
|
-
onScanListChange: OnScanListChange;
|
|
735
|
-
onBleHandleError: OnBleHandleError;
|
|
736
|
-
}
|
|
737
|
-
type TDeviceListNotifications = (devices: IDevice[]) => void;
|
|
738
|
-
type TDeviceStatusNotifications = (data: IDeviceStatusNoti) => void;
|
|
739
|
-
type TDeviceAttrsNotifications = (data: IDeviceAttrsNoti) => void;
|
|
740
|
-
type OnScanListChange = (devices: IDevice[]) => void;
|
|
741
|
-
type OnBleHandleError = (error: IError) => void;
|
|
742
|
-
export interface IResult<T> {
|
|
743
|
-
success: boolean;
|
|
744
|
-
data?: T;
|
|
745
|
-
err?: IError;
|
|
746
|
-
}
|
|
747
|
-
interface ICloudServiceInfo {
|
|
748
|
-
openAPIInfo: string;
|
|
749
|
-
}
|
|
750
|
-
export type TimeoutHandle = ReturnType<typeof setTimeout> | null;
|
|
751
|
-
export type IntervalHandle = ReturnType<typeof setInterval> | null;
|
|
752
|
-
export interface IProductInfo {
|
|
753
|
-
productKey: string;
|
|
754
|
-
productSecret: string;
|
|
755
|
-
}
|
|
756
|
-
interface GizwitsSdkOption {
|
|
757
|
-
appID: string;
|
|
758
|
-
appSecret: string;
|
|
759
|
-
productInfo: IProductInfo[];
|
|
760
|
-
cloudServiceInfo?: ICloudServiceInfo;
|
|
761
|
-
token?: string;
|
|
762
|
-
uid?: string;
|
|
763
|
-
offlineThreshold?: number;
|
|
764
|
-
}
|
|
765
|
-
class GizwitsMiniSDK {
|
|
766
|
-
private listenerMap;
|
|
767
|
-
private keepScanTimer;
|
|
768
|
-
private _deviceList;
|
|
769
|
-
private get deviceList();
|
|
770
|
-
private set deviceList(value);
|
|
771
|
-
private get allDevices();
|
|
772
|
-
private productInfo;
|
|
773
|
-
private currentWifiConfigHandle;
|
|
774
|
-
private _gizSocket;
|
|
775
|
-
private syncDataCallBack?;
|
|
776
|
-
constructor(props: GizwitsSdkOption);
|
|
777
|
-
private get socketHandle();
|
|
778
|
-
private init;
|
|
779
|
-
reInit(props: GizwitsSdkOption): void;
|
|
780
|
-
get specialProductKeys(): string[];
|
|
781
|
-
get specialProductKeySecrets(): string[];
|
|
782
|
-
private handleSocketDeviceData;
|
|
783
|
-
private handleSocketStatus;
|
|
784
|
-
private notiDeviceList;
|
|
785
|
-
setDeviceMeta: <K extends "mac" | "name" | "remark" | "did" | "productKey" | "bleWorkStatus" | "isBind" | "rootDeviceId" | "bleDeviceID" | "passcode" | "connectType" | "isOnline" | "isLanOnline" | "isBleOnline" | "host" | "wss_port" | "ctime">(curDev: IDevice, key: K, value: IDevice[K], force?: boolean) => void;
|
|
786
|
-
static getVersion: () => {
|
|
787
|
-
success: boolean;
|
|
788
|
-
data: string;
|
|
789
|
-
};
|
|
790
|
-
private getTargetDevice;
|
|
791
|
-
write: (device: IDevice, attrs: object) => Promise<{
|
|
792
|
-
success: boolean;
|
|
793
|
-
}>;
|
|
794
|
-
writeRaw: (device: IDevice, data: number[]) => Promise<{
|
|
795
|
-
success: boolean;
|
|
796
|
-
}>;
|
|
797
|
-
getDeviceStatus: (device: IDevice, attrNames?: string[]) => Promise<{
|
|
798
|
-
success: boolean;
|
|
799
|
-
} | {
|
|
800
|
-
success: boolean;
|
|
801
|
-
message: string;
|
|
802
|
-
}>;
|
|
803
|
-
subscribe: (device: IDevice, connectType?: TConnectType, _autoGetDeviceStatus?: boolean) => Promise<{
|
|
804
|
-
success: boolean;
|
|
805
|
-
errorCode: IError;
|
|
806
|
-
} | {
|
|
807
|
-
success: boolean;
|
|
808
|
-
message: string;
|
|
809
|
-
} | {
|
|
810
|
-
success: boolean;
|
|
811
|
-
message?: undefined;
|
|
812
|
-
}>;
|
|
813
|
-
unSubscribe: (device: IDevice) => Promise<{
|
|
814
|
-
success: boolean;
|
|
815
|
-
}>;
|
|
816
|
-
private setDomain;
|
|
817
|
-
getBindingList: () => Promise<import("mini_program_gizwits_sdk/src/openApiRequest").IServiceResult<IDevice[]>>;
|
|
818
|
-
getDevices: () => Promise<ISDKResult<IDevice[]>>;
|
|
819
|
-
setLogLevel: (level: TLogType) => {
|
|
820
|
-
success: boolean;
|
|
821
|
-
err: IError;
|
|
822
|
-
};
|
|
823
|
-
renameDevice: (device: IDevice, name: string) => Promise<import("mini_program_gizwits_sdk/src/openApiRequest").IServiceResult<import("./services/devices").IRenamePropsReturn> | {
|
|
824
|
-
success: boolean;
|
|
825
|
-
message: string;
|
|
826
|
-
}>;
|
|
827
|
-
removeEventListener: <K extends "GizDeviceListNotifications" | "GizDeviceStatusNotifications" | "GizDeviceAttrsNotifications" | "onScanListChange" | "onBleHandleError">(type: K, func: TListenerType[K]) => {
|
|
828
|
-
success: boolean;
|
|
829
|
-
};
|
|
830
|
-
addEventListener: <K extends "GizDeviceListNotifications" | "GizDeviceStatusNotifications" | "GizDeviceAttrsNotifications" | "onScanListChange" | "onBleHandleError">(type: K, func: TListenerType[K]) => Promise<{
|
|
831
|
-
success: boolean;
|
|
832
|
-
}>;
|
|
833
|
-
destory: () => void;
|
|
834
|
-
}
|
|
835
|
-
export default GizwitsMiniSDK;
|
|
836
|
-
|
|
837
|
-
}
|
|
838
|
-
declare module 'mini_program_gizwits_sdk/src/sentry' {
|
|
839
|
-
const sentry: (err: any, needGetNetwork?: boolean) => void;
|
|
840
|
-
export default sentry;
|
|
841
|
-
|
|
842
|
-
}
|
|
843
|
-
declare module 'mini_program_gizwits_sdk/src/services/devices' {
|
|
844
|
-
import { IServiceResult } from 'mini_program_gizwits_sdk/src/openApiRequest';
|
|
845
|
-
export interface IOpenApiDevice {
|
|
846
|
-
product_key: string;
|
|
847
|
-
did: string;
|
|
848
|
-
mac: string;
|
|
849
|
-
passcode: string;
|
|
850
|
-
is_online: boolean;
|
|
851
|
-
host: string;
|
|
852
|
-
port: string;
|
|
853
|
-
port_s: string;
|
|
854
|
-
ws_port: number;
|
|
855
|
-
wss_port: number;
|
|
856
|
-
dev_alias: string;
|
|
857
|
-
remark: string;
|
|
858
|
-
type: 'normal' | 'center_control' | 'sub_dev';
|
|
859
|
-
}
|
|
860
|
-
export const getBindingList: () => Promise<IServiceResult<IDevice[]>>;
|
|
861
|
-
interface IRenameProps {
|
|
862
|
-
name?: string;
|
|
863
|
-
did: string;
|
|
864
|
-
remark?: string;
|
|
865
|
-
}
|
|
866
|
-
export interface IRenamePropsReturn {
|
|
867
|
-
remark: string;
|
|
868
|
-
dev_alias: string;
|
|
869
|
-
}
|
|
870
|
-
export function editBindInfo({ name, remark, did, }: IRenameProps): Promise<IServiceResult<IRenamePropsReturn>>;
|
|
871
|
-
export function controlDevice(data: {
|
|
872
|
-
did: string;
|
|
873
|
-
raw: number[];
|
|
874
|
-
attrs: any;
|
|
875
|
-
}): Promise<IServiceResult<unknown>>;
|
|
876
|
-
export {};
|
|
877
|
-
|
|
878
|
-
}
|
|
879
|
-
declare module 'mini_program_gizwits_sdk/src/services/login' {
|
|
880
|
-
export interface ILoginRes {
|
|
881
|
-
expire_at: number;
|
|
882
|
-
token: string;
|
|
883
|
-
uid: string;
|
|
884
|
-
}
|
|
885
|
-
export function AnonymousLogin({ uid }: {
|
|
886
|
-
uid: string;
|
|
887
|
-
}): Promise<import("mini_program_gizwits_sdk/src/openApiRequest").IServiceResult<ILoginRes>>;
|
|
888
|
-
|
|
889
|
-
}
|
|
890
|
-
declare module 'mini_program_gizwits_sdk/src/services/tool' {
|
|
891
|
-
export const psKeySign: (productSecret: string) => {
|
|
892
|
-
Signature: string;
|
|
893
|
-
timestamp: number;
|
|
894
|
-
};
|
|
895
|
-
|
|
896
|
-
}
|
|
897
|
-
declare module 'mini_program_gizwits_sdk/src/services/uploadP0' {
|
|
898
|
-
export interface IUploadRes {
|
|
899
|
-
}
|
|
900
|
-
interface IData {
|
|
901
|
-
raw: string;
|
|
902
|
-
created_at: number;
|
|
903
|
-
}
|
|
904
|
-
interface IProps {
|
|
905
|
-
device: IDevice;
|
|
906
|
-
data: IData[];
|
|
907
|
-
productSecret: string;
|
|
908
|
-
}
|
|
909
|
-
export function uploadP0({ device, data, productSecret }: IProps): Promise<import("mini_program_gizwits_sdk/src/openApiRequest").IServiceResult<IUploadRes>>;
|
|
910
|
-
export {};
|
|
911
|
-
|
|
912
|
-
}
|
|
913
|
-
declare module 'mini_program_gizwits_sdk/src/sleep' {
|
|
914
|
-
const sleep: (time: number) => Promise<void>;
|
|
915
|
-
export default sleep;
|
|
916
|
-
|
|
917
|
-
}
|
|
918
|
-
declare module 'mini_program_gizwits_sdk/src/utils' {
|
|
919
|
-
import { IProductInfo } from 'mini_program_gizwits_sdk/src/sdk';
|
|
920
|
-
export function ab2hex(buffer: ArrayBuffer): any;
|
|
921
|
-
export function compareWXSDKVersion(v1: string, v2: string): 1 | -1 | 0;
|
|
922
|
-
export const isError: (err: unknown) => err is IError;
|
|
923
|
-
export const wrapErrorInfo: (errorMessage: string) => {
|
|
924
|
-
errorCode: string;
|
|
925
|
-
errorMessage: string;
|
|
926
|
-
};
|
|
927
|
-
export const unionBy: <T>(array: T[], key: string) => T[];
|
|
928
|
-
interface IWXDevicesResult {
|
|
929
|
-
success: true;
|
|
930
|
-
bleDevices: WechatMiniprogram.BlueToothDevice[];
|
|
931
|
-
}
|
|
932
|
-
export function isWXDevicesResult(res: unknown): res is IWXDevicesResult;
|
|
933
|
-
export function str2Buf(arr: string): ArrayBuffer;
|
|
934
|
-
export const numberArray2Uint8Array: (numArr: number[]) => Uint8Array;
|
|
935
|
-
export const advertisData2PkAndMac: (advertisData: ArrayBuffer, pks: string[]) => {
|
|
936
|
-
bleWorkStatus: number;
|
|
937
|
-
productKey: any;
|
|
938
|
-
mac: any;
|
|
939
|
-
};
|
|
940
|
-
export const isSameDevice: (deviceA: IDevice, deviceB: IDevice) => boolean;
|
|
941
|
-
export const merageBleLocalDevices: (mainDevice: IDevice[], localDevice: IDevice[]) => IDevice[];
|
|
942
|
-
export const merageLanLocalDevices: (mainDevice: IDevice[], localDevice: IDevice[]) => IDevice[];
|
|
943
|
-
export const getFirstConnectType: (device: IDevice, type?: TConnectType) => TConnectType;
|
|
944
|
-
export const getProductInfoThroughPK: (pk: string, productInfos: IProductInfo[]) => IProductInfo;
|
|
945
|
-
export const mergeObject: (obj1: any, obj2: any) => any;
|
|
946
|
-
export function hex2ab(str: any): Uint8Array;
|
|
947
|
-
type BroadcastCmd = 0x19 | 0x94;
|
|
948
|
-
type TBoradcastRes = {
|
|
949
|
-
mac: string;
|
|
950
|
-
cmd: BroadcastCmd;
|
|
951
|
-
data: string[];
|
|
952
|
-
};
|
|
953
|
-
export function parseBroadcastData(data: number[]): TBoradcastRes;
|
|
954
|
-
export function ab2numbers(buffer: ArrayBuffer): any;
|
|
955
|
-
export function encrypt(uuids: number[], key: number): string[];
|
|
956
|
-
export const convertToServiceUuids: ({ len, data, index, mac }: {
|
|
957
|
-
len?: any;
|
|
958
|
-
data?: any;
|
|
959
|
-
index?: number;
|
|
960
|
-
mac: any;
|
|
961
|
-
}) => any;
|
|
962
|
-
export function convertToUuids(mac: number, sn: number, data: number[]): string[];
|
|
963
|
-
export {};
|
|
964
|
-
|
|
965
|
-
}
|
|
966
|
-
declare module 'mini_program_gizwits_sdk/src/wechatApi' {
|
|
967
|
-
interface IBluetoothAdapterStateResult {
|
|
968
|
-
discovering: boolean;
|
|
969
|
-
available: boolean;
|
|
970
|
-
}
|
|
971
|
-
export interface IWechatResult {
|
|
972
|
-
errMsg: string;
|
|
973
|
-
errCode: number;
|
|
974
|
-
}
|
|
975
|
-
export function retryConnect(deviceId: string, timeout?: number): Promise<IWechatResult | {
|
|
976
|
-
success: boolean;
|
|
977
|
-
}>;
|
|
978
|
-
export function openBluetoothAdapter(): Promise<IWechatResult>;
|
|
979
|
-
export function closeBluetoothAdapter(): Promise<IWechatResult>;
|
|
980
|
-
export function getBluetoothAdapterState(): Promise<IBluetoothAdapterStateResult>;
|
|
981
|
-
export function startBluetoothDevicesDiscovery(allowDuplicatesKey?: boolean): Promise<IWechatResult>;
|
|
982
|
-
export function getBluetoothDevices(): Promise<WechatMiniprogram.BlueToothDevice[]>;
|
|
983
|
-
export function createBLEConnection(deviceId: string, timeout: number): Promise<IWechatResult>;
|
|
984
|
-
interface IBLEService {
|
|
985
|
-
uuid: string;
|
|
986
|
-
isPrimary: boolean;
|
|
987
|
-
}
|
|
988
|
-
export function getBLEDeviceServices(deviceId: string): Promise<IBLEService[]>;
|
|
989
|
-
interface IBLECharacteristic {
|
|
990
|
-
uuid: string;
|
|
991
|
-
properties: {
|
|
992
|
-
read: boolean;
|
|
993
|
-
write: boolean;
|
|
994
|
-
notify: boolean;
|
|
995
|
-
indicate: boolean;
|
|
996
|
-
};
|
|
997
|
-
}
|
|
998
|
-
export function getBLEDeviceCharacteristics(deviceId: string, serviceId: string): Promise<IBLECharacteristic[]>;
|
|
999
|
-
export function notifyBLECharacteristicValueChange(deviceId: string, serviceId: string, characteristicId: string, state?: boolean): Promise<IWechatResult>;
|
|
1000
|
-
export function writeBLECharacteristicValue(deviceId: string, serviceId: string, characteristicId: string, value: ArrayBuffer): Promise<IWechatResult>;
|
|
1001
|
-
export function unpackWriteBLECharacteristicValue(deviceId: string, serviceId: string, characteristicId: string, value: ArrayBuffer): Promise<IWechatResult>;
|
|
1002
|
-
export {};
|
|
1003
|
-
|
|
1004
|
-
}
|
|
1005
|
-
declare module 'mini_program_gizwits_sdk' {
|
|
1006
|
-
import main = require('mini_program_gizwits_sdk/index');
|
|
1007
|
-
export = main;
|
|
1008
|
-
}
|
|
1
|
+
import 'miniprogram-api-typings';
|
|
2
|
+
import gizwitsSdk from './src/sdk';
|
|
3
|
+
import errorCode from './src/errorCode';
|
|
4
|
+
import { BleHandle } from './src/handler/ble';
|
|
5
|
+
export { errorCode, BleHandle };
|
|
6
|
+
export default gizwitsSdk;
|