mini_program_gizwits_sdk 3.6.4 → 3.6.5

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.
Files changed (134) hide show
  1. package/dist/index.js +3 -3
  2. package/package.json +1 -1
  3. package/yarn-error.log +6901 -0
  4. package/dist/src/GizLog.d.ts +0 -18
  5. package/dist/src/crc/calculators/crc16modbus.d.ts +0 -2
  6. package/dist/src/crc/calculators/crc32.d.ts +0 -2
  7. package/dist/src/crc/crc16modbus.d.ts +0 -7
  8. package/dist/src/crc/crc32.d.ts +0 -7
  9. package/dist/src/crc/create_buffer.d.ts +0 -3
  10. package/dist/src/crc/define_crc.d.ts +0 -7
  11. package/dist/src/crc/index.d.ts +0 -19
  12. package/dist/src/crc/types.d.ts +0 -11
  13. package/dist/src/errorCode.d.ts +0 -3
  14. package/dist/src/globalData.d.ts +0 -2
  15. package/dist/src/handler/EventListener.d.ts +0 -9
  16. package/dist/src/handler/ble.d.ts +0 -105
  17. package/dist/src/handler/lan.d.ts +0 -78
  18. package/dist/src/handler/socket.d.ts +0 -151
  19. package/dist/src/openApiRequest.d.ts +0 -3
  20. package/dist/src/productConfigFileManage.d.ts +0 -11
  21. package/dist/src/protocol/Bind.d.ts +0 -7
  22. package/dist/src/protocol/DeviceInfo.d.ts +0 -11
  23. package/dist/src/protocol/DiscoverUDP.d.ts +0 -17
  24. package/dist/src/protocol/GetDeviceStatus.d.ts +0 -5
  25. package/dist/src/protocol/Login.d.ts +0 -12
  26. package/dist/src/protocol/Ntp.d.ts +0 -5
  27. package/dist/src/protocol/OTA/AwaitNoti.d.ts +0 -7
  28. package/dist/src/protocol/OTA/CheckCanOTA.d.ts +0 -10
  29. package/dist/src/protocol/OTA/OTAPackPackage.d.ts +0 -8
  30. package/dist/src/protocol/OTA/OtaComplete.d.ts +0 -8
  31. package/dist/src/protocol/OTA/PreOTA.d.ts +0 -11
  32. package/dist/src/protocol/OTA/ResetPosition.d.ts +0 -6
  33. package/dist/src/protocol/OffLineData.d.ts +0 -23
  34. package/dist/src/protocol/ProtocolBase.d.ts +0 -11
  35. package/dist/src/protocol/Reset.d.ts +0 -8
  36. package/dist/src/protocol/SetReset.d.ts +0 -7
  37. package/dist/src/protocol/WifiConfig.d.ts +0 -6
  38. package/dist/src/protocol/dataPoint.d.ts +0 -34
  39. package/dist/src/protocol/tool.d.ts +0 -14
  40. package/dist/src/randomCode.d.ts +0 -3
  41. package/dist/src/request.d.ts +0 -1
  42. package/dist/src/sdk.d.ts +0 -136
  43. package/dist/src/sentry.d.ts +0 -2
  44. package/dist/src/services/devices.d.ts +0 -47
  45. package/dist/src/services/login.d.ts +0 -4
  46. package/dist/src/services/monitor.d.ts +0 -12
  47. package/dist/src/services/ota.d.ts +0 -7
  48. package/dist/src/services/tool.d.ts +0 -4
  49. package/dist/src/services/uploadP0.d.ts +0 -14
  50. package/dist/src/sleep.d.ts +0 -2
  51. package/dist/src/types/index.d.ts +0 -361
  52. package/dist/src/utils.d.ts +0 -46
  53. package/dist/src/wechatApi.d.ts +0 -19
  54. package/dist/src/wifiConfig/ConfigBase.d.ts +0 -27
  55. package/dist/src/wifiConfig/ap.d.ts +0 -11
  56. package/dist/src/wifiConfig/ble.d.ts +0 -41
  57. package/dist/src/wifiConfig/nfc/disposeData.d.ts +0 -2
  58. package/dist/src/wifiConfig/nfc/formatData.d.ts +0 -3
  59. package/dist/src/wifiConfig/nfc/formatSSID.d.ts +0 -6
  60. package/dist/src/wifiConfig/nfc/index.d.ts +0 -22
  61. package/dist/src/wifiConfig/nfc/isIncludedCH.d.ts +0 -1
  62. package/dist/src/wifiConfig/nfc/nfcAConnect.d.ts +0 -6
  63. package/dist/src/wifiConfig/nfc/nfcATransceive.d.ts +0 -5
  64. package/dist/src/wifiConfig/nfc/ssIDToASC.d.ts +0 -1
  65. package/dist/src/wifiConfig/nfc/stringToGbk.d.ts +0 -1
  66. package/dist/src/wifiConfig/nfc/transceive.wx.d.ts +0 -2
  67. package/dist/src/wifiConfig/nfc/types.d.ts +0 -15
  68. package/index.ts +0 -8
  69. package/src/GizLog.ts +0 -51
  70. package/src/crc/calculators/crc16modbus.ts +0 -36
  71. package/src/crc/calculators/crc32.ts +0 -47
  72. package/src/crc/crc16modbus.ts +0 -3
  73. package/src/crc/crc32.ts +0 -4
  74. package/src/crc/create_buffer.ts +0 -7
  75. package/src/crc/define_crc.ts +0 -9
  76. package/src/crc/index.ts +0 -10
  77. package/src/crc/package.json +0 -3
  78. package/src/crc/types.ts +0 -10
  79. package/src/errorCode.ts +0 -83
  80. package/src/globalData.ts +0 -9
  81. package/src/handler/EventListener.ts +0 -44
  82. package/src/handler/ble.ts +0 -1369
  83. package/src/handler/lan.ts +0 -389
  84. package/src/handler/socket.ts +0 -686
  85. package/src/openApiRequest.ts +0 -50
  86. package/src/productConfigFileManage.ts +0 -72
  87. package/src/protocol/Bind.ts +0 -22
  88. package/src/protocol/DeviceInfo.ts +0 -37
  89. package/src/protocol/DiscoverUDP.ts +0 -80
  90. package/src/protocol/GetDeviceStatus.ts +0 -61
  91. package/src/protocol/Login.ts +0 -43
  92. package/src/protocol/Ntp.ts +0 -13
  93. package/src/protocol/OTA/AwaitNoti.ts +0 -14
  94. package/src/protocol/OTA/CheckCanOTA.ts +0 -23
  95. package/src/protocol/OTA/OTAPackPackage.ts +0 -37
  96. package/src/protocol/OTA/OtaComplete.ts +0 -17
  97. package/src/protocol/OTA/PreOTA.ts +0 -48
  98. package/src/protocol/OTA/ResetPosition.ts +0 -14
  99. package/src/protocol/OffLineData.ts +0 -81
  100. package/src/protocol/ProtocolBase.ts +0 -54
  101. package/src/protocol/Reset.ts +0 -16
  102. package/src/protocol/SetReset.ts +0 -13
  103. package/src/protocol/WifiConfig.ts +0 -42
  104. package/src/protocol/dataPoint.ts +0 -687
  105. package/src/protocol/tool.ts +0 -140
  106. package/src/randomCode.ts +0 -25
  107. package/src/request.ts +0 -22
  108. package/src/sdk.ts +0 -1536
  109. package/src/sentry.ts +0 -55
  110. package/src/services/devices.ts +0 -313
  111. package/src/services/login.ts +0 -11
  112. package/src/services/monitor.ts +0 -117
  113. package/src/services/ota.ts +0 -17
  114. package/src/services/tool.ts +0 -10
  115. package/src/services/uploadP0.ts +0 -57
  116. package/src/sleep.ts +0 -2
  117. package/src/types/index.ts +0 -456
  118. package/src/utils.ts +0 -449
  119. package/src/wechatApi.ts +0 -211
  120. package/src/wifiConfig/ConfigBase.ts +0 -235
  121. package/src/wifiConfig/ap.ts +0 -185
  122. package/src/wifiConfig/ble.ts +0 -460
  123. package/src/wifiConfig/nfc/disposeData.ts +0 -63
  124. package/src/wifiConfig/nfc/formatData.ts +0 -46
  125. package/src/wifiConfig/nfc/formatSSID.ts +0 -59
  126. package/src/wifiConfig/nfc/index.ts +0 -134
  127. package/src/wifiConfig/nfc/isIncludedCH.ts +0 -8
  128. package/src/wifiConfig/nfc/nfcAConnect.ts +0 -30
  129. package/src/wifiConfig/nfc/nfcATransceive.ts +0 -29
  130. package/src/wifiConfig/nfc/ssIDToASC.ts +0 -12
  131. package/src/wifiConfig/nfc/stringToGbk.ts +0 -51
  132. package/src/wifiConfig/nfc/transceive.wx.ts +0 -124
  133. package/src/wifiConfig/nfc/types.ts +0 -18
  134. package/src/wifiConfig/timeZoneName.json +0 -1
@@ -1,456 +0,0 @@
1
- import { TCPHandler } from "../handler/lan";
2
- import DiscoverUDP from "../protocol/DiscoverUDP";
3
- import { wrapErrorInfo } from "../utils";
4
-
5
-
6
- export type TUtf8 = {
7
- toBytes: (data: any) => any
8
- }
9
-
10
- export type TUtils = {
11
- utf8: TUtf8;
12
- }
13
-
14
- export interface ecb {
15
- new(data: any): any;
16
- }
17
-
18
- export type TModeOfOperation = {
19
- ecb: ecb;
20
- }
21
- export interface IError {
22
- errorCode: number;
23
- errorMessage?: string;
24
- }
25
-
26
- export interface ICommonObj {
27
- [key: string]: any
28
- }
29
-
30
- export interface IDeviceStatusChangedProps {
31
- did: string;
32
- attrs: ICommonObj;
33
- }
34
-
35
- export interface IDeviceRawStatusChangedProps {
36
- did: string;
37
- raw: Uint8Array;
38
- }
39
-
40
- export interface IOnDeviceStatusChanged {
41
- (data: IDeviceStatusChangedProps | IDeviceRawStatusChangedProps): void;
42
- }
43
-
44
- export interface IOnSocketStatusChanged {
45
- (dids: string[], enabled: boolean): void;
46
- }
47
-
48
- export interface IEmptyFn {
49
- (): void;
50
- }
51
-
52
- export interface IDevice {
53
- mac: string;
54
- productKey: string;
55
- did: string;
56
- bleWorkStatus?: number; // 0 默认状态 1 配网状态
57
- name: string;
58
- localName: string;
59
- isBind: boolean;
60
- rootDeviceId?: string;
61
- bleDeviceID?: string;
62
- remark?: string;
63
- passcode?: string;
64
- connectType: TConnectType;
65
- isOnline: boolean; // 代表大循环在线
66
- isLanOnline: boolean; // 代表小循环在线
67
- isBleOnline: boolean; // 代表蓝牙在线
68
- host?: string;
69
- wss_port?: number;
70
- ctime?: number;
71
- }
72
-
73
- export type TConnectType = 'BLE' | 'BLE_BROADCAST' | 'LAN' | 'WAN' | 'NONE';
74
-
75
- export interface IBluetoothAdapterStateResult {
76
- discovering: boolean;
77
- available: boolean;
78
- }
79
-
80
- export interface IWechatResult {
81
- errMsg: string;
82
- errCode: number;
83
- }
84
-
85
- export interface IWXDevicesResult {
86
- success: true;
87
- bleDevices: WechatMiniprogram.BlueToothDevice[];
88
- }
89
-
90
- /**sdk */
91
-
92
- export interface SyncCallBackParams {
93
- event: TSyncEvnet;
94
- currentNum?: number;
95
- totalNum?: number;
96
- message?: string;
97
- }
98
- export type TSyncEvnet = 'SYNC_START' | 'SYNC_END' | 'SYNC_FAIL' | 'SYNC_CANCEL' | 'SYNC_PROGRESS';
99
- export type SyncCallBack = (data: SyncCallBackParams) => void
100
- export type IOTAType = 'MCU' | 'MODULE'
101
-
102
- // 接口返回格式
103
- export interface ISDKResult<T> {
104
- data?: T;
105
- err?: IError;
106
- message?: string;
107
- success: boolean;
108
- }
109
- export interface ISetCommonDeviceOnboardingDeployProps {
110
- ssid: string;
111
- bssid?: string;
112
- password: string;
113
- timeout: number;
114
- isBind?: boolean;
115
- mode?: 0 | 3 | 5; // 0 AP 3 BLE 5 NFC
116
- softAPSSIDPrefix?: string;
117
- }
118
-
119
- export interface ISetDeviceOnboardingDeployProps
120
- extends ISetCommonDeviceOnboardingDeployProps {
121
- softAPSSIDPrefix: string;
122
- eventCallBack: (event: ConfigEventData) => void, // 配网回调
123
- }
124
-
125
- export interface IRandomCodesResult {
126
- random_code: string;
127
- product_key: string;
128
- mac: string;
129
- did: string;
130
- user_id: string;
131
- timestamp: number;
132
- type: string;
133
- wifi_soft_ver: string;
134
- lan_proto_ver: string;
135
- }
136
-
137
- export interface IBindRemoteDeviceParams {
138
- productKey: string;
139
- mac: string;
140
- beOwner?: boolean;
141
- alias?: string;
142
- }
143
-
144
- export interface IDeviceStatusNoti {
145
- device: IDevice;
146
- connectType: TConnectType;
147
- }
148
- export interface IDeviceAttrsNoti {
149
- device: IDevice;
150
- data: object;
151
- }
152
-
153
- export interface TListenerType {
154
- GizDeviceListNotifications: TDeviceListNotifications;
155
- GizDeviceStatusNotifications: TDeviceStatusNotifications;
156
- GizDeviceAttrsNotifications: TDeviceAttrsNotifications;
157
- onScanListChange: OnScanListChange;
158
- onBleHandleError: OnBleHandleError;
159
- }
160
-
161
- export type TDeviceListNotifications = (devices: IDevice[]) => void;
162
- export type TDeviceStatusNotifications = (data: IDeviceStatusNoti) => void;
163
- export type TDeviceAttrsNotifications = (data: IDeviceAttrsNoti) => void;
164
- export type OnScanListChange = (devices: IDevice[]) => void;
165
- export type OnBleHandleError = (error: IError) => void;
166
-
167
- export interface IDeviceSafetyRegisterParams {
168
- mac: string;
169
- productKey: string;
170
- }
171
-
172
- export interface IDeviceSafetyParams extends IDeviceSafetyRegisterParams {
173
- isReset: boolean;
174
- }
175
- export interface IResult<T> {
176
- success: boolean;
177
- data?: T;
178
- err?: IError;
179
- }
180
-
181
- export interface ICloudServiceInfo {
182
- openAPIInfo: string;
183
- }
184
-
185
- export type TimeoutHandle = ReturnType<typeof setTimeout> | null;
186
- export type IntervalHandle = ReturnType<typeof setInterval> | null;
187
- export interface IProductInfo {
188
- productKey: string;
189
- productSecret: string;
190
- }
191
- export interface GizwitsSdkOption {
192
- appID: string;
193
- appSecret: string;
194
- productInfo: IProductInfo[];
195
- cloudServiceInfo?: ICloudServiceInfo;
196
- token?: string;
197
- uid?: string;
198
- offlineThreshold?: number;
199
- }
200
-
201
- /**sdk */
202
-
203
-
204
- export interface IRejectCallback {
205
- (result: IResult<unknown>): void;
206
- }
207
- export type TConfigEvent = 'GIZ_CONFIG_START' | 'GIZ_DISCOVER_SUCCESS' | 'GIZ_CONNECT_SUCCESS' | 'GIZ_CONFIG_SEND_SUCCESS' | 'GIZ_CONFIG_RECV_SUCCESS' | 'GIZ_CONFIG_SUCCESS'
208
- export interface ConfigEventData {
209
- event: TConfigEvent;
210
- deviceID?: string;
211
- }
212
-
213
- export interface IOpenApiDevice {
214
- product_key: string;
215
- did: string;
216
- mac: string;
217
- passcode: string;
218
- is_online: boolean;
219
- host: string;
220
- port: string;
221
- port_s: string;
222
- ws_port: number;
223
- wss_port: number;
224
- dev_alias: string;
225
- remark: string;
226
- type: 'normal' | 'center_control' | 'sub_dev';
227
- }
228
-
229
- export interface IDeviceRes {
230
- devices: IOpenApiDevice[];
231
- }
232
-
233
- export interface IErrorCode {
234
- [key: string]: IError;
235
- }
236
-
237
- export interface IWechatApiResult<T> {
238
- data: T;
239
- errMsg: string;
240
- statusCode: number;
241
- }
242
-
243
- export interface IServiceResult<T> {
244
- success: boolean;
245
- data?: T;
246
- err?: IError;
247
- }
248
-
249
-
250
- export interface IGetRandomCodes {
251
- SSID: string;
252
- password: string;
253
- pks: string[];
254
- }
255
-
256
- export interface IGetRandomCode {
257
- SSID: string;
258
- password: string;
259
- pk: string;
260
- }
261
-
262
-
263
- export interface IProductConfigData {
264
- [key: string]: IDataPointConfig;
265
- }
266
-
267
-
268
- export interface IDataPointConfig {
269
- name: string;
270
- protocolType: 'var_len' | 'standard';
271
- entities: IDataPointEntitie[];
272
- }
273
-
274
-
275
-
276
- export interface IDataPointEntitie {
277
- display_name: string;
278
- attrs: IDataPointAttr[];
279
- }
280
-
281
- export interface IDataPointPosition {
282
- byte_offset: number;
283
- unit: 'bit' | 'byte';
284
- len: number;
285
- bit_offset: number;
286
- }
287
-
288
- export type TDataType = 'bool' | 'uint8' | 'uint16' | 'uint32' | 'binary' | 'enum' | 'number';
289
-
290
-
291
- export interface IUnitSpec {
292
- addition: number;
293
- max: number;
294
- ratio: number;
295
- min: number;
296
- }
297
-
298
- export type TDataOptionType = 'status_writable' | 'status_readonly' | 'alert' | 'fault' | 'ALL';
299
- export interface IDataPointAttr {
300
- display_name: string;
301
- uint_spec: IUnitSpec;
302
- name:string;
303
- data_type: TDataType;
304
- position: IDataPointPosition;
305
- type: TDataOptionType;
306
- id: number;
307
- enum: string[];
308
- desc: string;
309
- }
310
-
311
- /**
312
- * 蓝牙
313
- */
314
-
315
- export type GizBleDeviceListotifications = (devices: IDevice[]) => void;
316
- export type GizBleDeviceDataNotifications = (
317
- curDevice: WechatMiniprogram.OnBLECharacteristicValueChangeListenerResult,
318
- hexString: string
319
- ) => void;
320
- export type GizBleErrorNotifications = (err: { errCode: number; errMsg: string }) => void;
321
- // 返回true 代表放弃监听
322
- export type TBleDataListener<T> = (_curDevice: WechatMiniprogram.OnBLECharacteristicValueChangeListenerResult,
323
- hexString: string) => T | null | undefined;
324
-
325
- export interface CheckOTAParams {
326
- device: IDevice;
327
- type: IOTAType;
328
- }
329
-
330
- export type OTAEventCode = 'GizOTAEventPretreatment' | 'GizOTAEventDownload' | 'GizOTAEventTransmit' | 'GizOTAEventReboot' | 'GizOTAEventFinish'
331
- export interface OTAEvent {
332
- code: OTAEventCode; //
333
- };
334
- export interface OTAProgressEvent {
335
- firmwareSize: number;
336
- packageMaxLen: number;
337
- currentNumber: number;
338
- currentProgress: number; // 0 ~ 100
339
- }
340
-
341
- export type OTAProgressEventCallback = (event: OTAProgressEvent) => void;
342
- export type OTAEventCallback = (event: OTAEvent) => void;
343
- export interface StartUpgradeParams extends CheckOTAParams {
344
- onProgress: OTAProgressEventCallback
345
- onEvent: OTAEventCallback
346
- productKey: string
347
- }
348
-
349
-
350
- export interface TBleHandleEvent {
351
- GizBleDeviceData: GizBleDeviceDataNotifications;
352
- GizBleDeviceList: GizBleDeviceListotifications;
353
- GizBleError: GizBleErrorNotifications;
354
- }
355
-
356
- export interface GizwitsWxBlueToothDevice extends WechatMiniprogram.BlueToothDevice {
357
- communicationType: 'BLE_BROADCAST' | 'BLE';
358
- }
359
-
360
- export interface BleHandleParams {
361
- serviceUUIDSuffix: string;
362
- characteristicUUIDSuffix: string;
363
- }
364
-
365
- export interface IStartScanResult {
366
- scanList: IDevice[];
367
- err?: ReturnType<typeof wrapErrorInfo>;
368
- }
369
-
370
- export interface IDeviceReq<T> {
371
- success: boolean;
372
- data: T;
373
- }
374
-
375
- // export type BleHandle = ReturnType<typeof createBleHandle>;
376
-
377
- export type OnScanDevice = (scanList: IDevice[]) => void;
378
- export interface BleConnectDevice {
379
- deviceId?: string;
380
- serviceId?: string;
381
- characteristicId?: string;
382
- errMsg?: string;
383
- }
384
-
385
- export interface BleConstructorParams {
386
- pks: string[];
387
- bleHandleParams?: BleHandleParams;
388
- offlineThreshold?: number;
389
- }
390
- /**
391
- * 蓝牙
392
- */
393
-
394
-
395
-
396
- // 局域网连接设备结构
397
- export interface LanConnectDevice {
398
- mac: string
399
- productKey: string
400
- socketHandle: TCPHandler
401
- }
402
-
403
- // 局域网设备
404
- export interface ILanDevice extends IDevice {
405
- expandData: DiscoverUDP
406
- ip: string
407
- }
408
-
409
- export type GizLanDeviceListNotifications = (devices: IDevice[]) => void;
410
- export type GizLanDeviceDataNotifications = (mac: string, data: string) => void;
411
- export interface TLanHandleEvent {
412
- GizLanDeviceList: GizLanDeviceListNotifications;
413
- GizLanDeviceData: GizLanDeviceDataNotifications
414
- }
415
-
416
-
417
-
418
- export interface IBLEService {
419
- uuid: string;
420
- isPrimary: boolean;
421
- }
422
- export interface IBLECharacteristic {
423
- uuid: string;
424
- properties: {
425
- read: boolean;
426
- write: boolean;
427
- notify: boolean;
428
- indicate: boolean;
429
- }
430
- }
431
-
432
- export interface ILoginRes {
433
- expire_at: number;
434
- token: string;
435
- uid: string;
436
- }
437
-
438
- export interface OTARes {
439
- download_url: string;
440
- soft_ver: string; // 新的版本号
441
- }
442
-
443
- export interface configDeviceParams {
444
- ssid: string;
445
- password: string;
446
- softAPSSIDPrefix: string;
447
- }
448
-
449
-
450
-
451
- export interface configBLEDeviceParams {
452
- ssid: string;
453
- password: string;
454
- softAPSSIDPrefix?: string;
455
- timeout: number;
456
- }