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