mini_program_gizwits_sdk 3.6.0 → 3.6.2

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 (59) hide show
  1. package/README.md +57 -15
  2. package/dist/index.d.ts +2 -0
  3. package/dist/index.js +3 -3
  4. package/dist/package.json +55 -0
  5. package/dist/src/GizLog.d.ts +1 -1
  6. package/dist/src/errorCode.d.ts +1 -3
  7. package/dist/src/handler/ble.d.ts +5 -66
  8. package/dist/src/handler/lan.d.ts +3 -18
  9. package/dist/src/handler/socket.d.ts +1 -0
  10. package/dist/src/openApiRequest.d.ts +1 -5
  11. package/dist/src/productConfigFileManage.d.ts +3 -6
  12. package/dist/src/protocol/OTA/CheckCanOTA.d.ts +1 -1
  13. package/dist/src/protocol/{DataPoint.d.ts → dataPoint.d.ts} +0 -34
  14. package/dist/src/randomCode.d.ts +1 -5
  15. package/dist/src/sdk.d.ts +9 -104
  16. package/dist/src/sdk.js +1101 -0
  17. package/dist/src/services/devices.d.ts +1 -17
  18. package/dist/src/services/login.d.ts +2 -6
  19. package/dist/src/services/monitor.d.ts +2 -1
  20. package/dist/src/services/monitor.js +72 -0
  21. package/dist/src/services/ota.d.ts +2 -6
  22. package/dist/src/services/uploadP0.d.ts +2 -1
  23. package/dist/src/types/index.d.ts +360 -0
  24. package/dist/src/utils.d.ts +1 -6
  25. package/dist/src/wechatApi.d.ts +1 -22
  26. package/dist/src/wifiConfig/ConfigBase.d.ts +2 -9
  27. package/dist/src/wifiConfig/ap.d.ts +1 -11
  28. package/dist/src/wifiConfig/ble.d.ts +2 -8
  29. package/dist/src/wifiConfig/nfc/index.d.ts +2 -2
  30. package/global.d.ts +3 -19
  31. package/index.ts +2 -0
  32. package/package.json +2 -2
  33. package/src/errorCode.ts +3 -3
  34. package/src/handler/ble.ts +4 -79
  35. package/src/handler/lan.ts +3 -24
  36. package/src/handler/socket.ts +3 -0
  37. package/src/openApiRequest.ts +2 -14
  38. package/src/productConfigFileManage.ts +3 -5
  39. package/src/protocol/OTA/AwaitNoti.ts +0 -2
  40. package/src/protocol/OTA/CheckCanOTA.ts +1 -2
  41. package/src/protocol/OTA/OTAPackPackage.ts +1 -1
  42. package/src/protocol/OTA/PreOTA.ts +2 -3
  43. package/src/protocol/OTA/ResetPosition.ts +1 -2
  44. package/src/protocol/dataPoint.ts +1 -42
  45. package/src/randomCode.ts +1 -12
  46. package/src/sdk.ts +11 -114
  47. package/src/services/devices.ts +2 -22
  48. package/src/services/login.ts +1 -5
  49. package/src/services/monitor.ts +1 -0
  50. package/src/services/ota.ts +1 -5
  51. package/src/services/uploadP0.ts +1 -0
  52. package/src/types/index.ts +455 -0
  53. package/src/utils.ts +1 -6
  54. package/src/wechatApi.ts +1 -22
  55. package/src/wifiConfig/ConfigBase.ts +2 -10
  56. package/src/wifiConfig/ap.ts +1 -13
  57. package/src/wifiConfig/ble.ts +2 -9
  58. package/src/wifiConfig/nfc/index.ts +1 -4
  59. package/src/global.d.ts +0 -52
package/src/errorCode.ts CHANGED
@@ -1,6 +1,6 @@
1
- interface IErrorCode {
2
- [key: string]: IError;
3
- }
1
+ import { IError, IErrorCode } from "./types";
2
+
3
+
4
4
  const errorCode: IErrorCode = {
5
5
  GIZ_OPENAPI_DEVICE_NOT_BOUND: {
6
6
  errorCode: 9017,
@@ -1,6 +1,6 @@
1
1
  import GizLog from '../GizLog';
2
2
  import Bind from '../protocol/Bind';
3
- import { padBoradcastData } from '../protocol/DataPoint';
3
+ import { padBoradcastData } from '../protocol/dataPoint';
4
4
  import GetDeviceStatus from '../protocol/GetDeviceStatus';
5
5
  import Login from '../protocol/Login';
6
6
  import ProtocolBase from '../protocol/ProtocolBase';
@@ -22,7 +22,6 @@ import {
22
22
  } from '../utils';
23
23
  import { downloadFile, retryConnect, unpackWriteBLECharacteristicValue } from '../wechatApi';
24
24
  import EventListener from './EventListener';
25
- import { IOTAType, IResult } from '../sdk';
26
25
  import { checkUpdate } from '../services/ota';
27
26
  import errorCode from '../errorCode';
28
27
  import DeviceInfo from '../protocol/DeviceInfo';
@@ -32,82 +31,8 @@ import ResetPosition from '../protocol/OTA/ResetPosition';
32
31
  import OTAPackPackage from '../protocol/OTA/OTAPackPackage';
33
32
  import AwaitNoti from '../protocol/OTA/AwaitNoti';
34
33
  import OtaComplete from '../protocol/OTA/OtaComplete';
34
+ import { BleConnectDevice, IDevice, IOTAType, IResult, TBleHandleEvent, BleConstructorParams, GizwitsWxBlueToothDevice, IStartScanResult, TBleDataListener, IDeviceReq, StartUpgradeParams, CheckOTAParams } from '../types';
35
35
 
36
- type GizBleDeviceListotifications = (devices: IDevice[]) => void;
37
- type GizBleDeviceDataNotifications = (
38
- curDevice: WechatMiniprogram.OnBLECharacteristicValueChangeListenerResult,
39
- hexString: string
40
- ) => void;
41
- type GizBleErrorNotifications = (err: { errCode: number; errMsg: string }) => void;
42
- // 返回true 代表放弃监听
43
- type TBleDataListener<T> = (_curDevice: WechatMiniprogram.OnBLECharacteristicValueChangeListenerResult,
44
- hexString: string) => T | null | undefined;
45
-
46
- interface CheckOTAParams {
47
- device: IDevice;
48
- type: IOTAType;
49
- }
50
-
51
- type OTAEventCode = 'GizOTAEventPretreatment' | 'GizOTAEventDownload' | 'GizOTAEventTransmit' | 'GizOTAEventReboot' | 'GizOTAEventFinish'
52
- interface OTAEvent {
53
- code: OTAEventCode; //
54
- };
55
- interface OTAProgressEvent {
56
- firmwareSize: number;
57
- packageMaxLen: number;
58
- currentNumber: number;
59
- currentProgress: number; // 0 ~ 100
60
- }
61
-
62
- export type OTAProgressEventCallback = (event: OTAProgressEvent) => void;
63
- export type OTAEventCallback = (event: OTAEvent) => void;
64
- interface StartUpgradeParams extends CheckOTAParams {
65
- onProgress: OTAProgressEventCallback
66
- onEvent: OTAEventCallback
67
- productKey: string
68
- }
69
-
70
-
71
- export interface TBleHandleEvent {
72
- GizBleDeviceData: GizBleDeviceDataNotifications;
73
- GizBleDeviceList: GizBleDeviceListotifications;
74
- GizBleError: GizBleErrorNotifications;
75
- }
76
-
77
- export interface GizwitsWxBlueToothDevice extends WechatMiniprogram.BlueToothDevice {
78
- communicationType: 'BLE_BROADCAST' | 'BLE';
79
- }
80
-
81
- interface BleHandleParams {
82
- serviceUUIDSuffix: string;
83
- characteristicUUIDSuffix: string;
84
- }
85
-
86
- export interface IStartScanResult {
87
- scanList: IDevice[];
88
- err?: ReturnType<typeof wrapErrorInfo>;
89
- }
90
-
91
- interface IDeviceReq<T> {
92
- success: boolean;
93
- data: T;
94
- }
95
-
96
- // export type BleHandle = ReturnType<typeof createBleHandle>;
97
-
98
- export type OnScanDevice = (scanList: IDevice[]) => void;
99
- interface ConnectDevice {
100
- deviceId?: string;
101
- serviceId?: string;
102
- characteristicId?: string;
103
- errMsg?: string;
104
- }
105
-
106
- interface ConstructorParams {
107
- pks: string[];
108
- bleHandleParams?: BleHandleParams;
109
- offlineThreshold?: number;
110
- }
111
36
 
112
37
  function createUUID32() {
113
38
  let dt = new Date().getTime();
@@ -180,7 +105,7 @@ function reportConnectEvent(
180
105
  export class BleHandle extends EventListener<TBleHandleEvent> {
181
106
  private serviceUUIDSuffix: string;
182
107
  // private characteristicUUIDSuffix: string;
183
- public connectedList: ConnectDevice[] = [];
108
+ public connectedList: BleConnectDevice[] = [];
184
109
  private connectingDevId: string | null = null;
185
110
  public pks: string[] = [];
186
111
  private listenDevOfflineTimer: any = null;
@@ -219,7 +144,7 @@ export class BleHandle extends EventListener<TBleHandleEvent> {
219
144
  characteristicUUIDSuffix: 'abf7',
220
145
  },
221
146
  offlineThreshold,
222
- }: ConstructorParams) {
147
+ }: BleConstructorParams) {
223
148
  super();
224
149
  const { serviceUUIDSuffix } = bleHandleParams;
225
150
  this.serviceUUIDSuffix = serviceUUIDSuffix;
@@ -4,35 +4,14 @@ import DiscoverUDP from "../protocol/DiscoverUDP";
4
4
  import Login from "../protocol/Login";
5
5
  import ProtocolBase from "../protocol/ProtocolBase";
6
6
  import { arrayToUint8, hexStrint2byte } from "../protocol/tool";
7
- import { IResult } from "../sdk";
8
7
  import sleep from "../sleep";
8
+ import { IDevice, ILanDevice, IResult, LanConnectDevice, TLanHandleEvent } from "../types";
9
9
  import { ab2hex, ab2numbers } from "../utils";
10
10
  import EventListener from "./EventListener";
11
11
 
12
- // 局域网连接设备结构
13
- interface ConnectDevice {
14
- mac: string
15
- productKey: string
16
- socketHandle: TCPHandler
17
- }
18
-
19
- // 局域网设备
20
- interface ILanDevice extends IDevice {
21
- expandData: DiscoverUDP
22
- ip: string
23
- }
24
-
25
- type GizLanDeviceListNotifications = (devices: IDevice[]) => void;
26
- type GizLanDeviceDataNotifications = (mac: string, data: string) => void;
27
- export interface TLanHandleEvent {
28
- GizLanDeviceList: GizLanDeviceListNotifications;
29
- GizLanDeviceData: GizLanDeviceDataNotifications
30
- }
31
-
32
-
33
12
  export class LanHandle extends EventListener<TLanHandleEvent> {
34
13
  // private characteristicUUIDSuffix: string;
35
- public connectedList: ConnectDevice[] = [];
14
+ public connectedList: LanConnectDevice[] = [];
36
15
  public pks: string[] = [];
37
16
  // private globalListenerMap = {};
38
17
  public scanList: ILanDevice[] = [];
@@ -273,7 +252,7 @@ interface ITCPHandlerProps {
273
252
  onClose: (ip) => void
274
253
  onData: (mac: string, data: string) => void
275
254
  }
276
- class TCPHandler {
255
+ export class TCPHandler {
277
256
  private deviceTCPPort = 12416
278
257
  private ip = ""
279
258
  private productKey = ""
@@ -1,6 +1,9 @@
1
1
  import errorCode from "../errorCode";
2
2
  import GizLog from "../GizLog";
3
3
  import request from "../openApiRequest";
4
+ import { IDevice, IError, IOnDeviceStatusChanged,
5
+ IDeviceStatusChangedProps, IDeviceRawStatusChangedProps,
6
+ IOnSocketStatusChanged, IEmptyFn, ICommonObj } from "../types";
4
7
  import { compareWXSDKVersion, isError } from '../utils';
5
8
 
6
9
  // commType = 'custom' | 'attrs_v4'
@@ -1,19 +1,7 @@
1
1
  import errorCode from './errorCode';
2
2
  import { getGlobalData } from "./globalData";
3
3
  import request from './request';
4
-
5
- interface IResult<T> {
6
- data: T;
7
- errMsg: string;
8
- statusCode: number;
9
- }
10
-
11
- export interface IServiceResult<T> {
12
- success: boolean;
13
- data?: T;
14
- err?: IError;
15
- }
16
-
4
+ import { IError, IServiceResult, IWechatApiResult } from './types';
17
5
 
18
6
  const openApiRequest = async <T>(url: string, options: any, needToken: boolean = true): Promise<IServiceResult<T>> => {
19
7
  const requestOptions = { ...options };
@@ -29,7 +17,7 @@ const openApiRequest = async <T>(url: string, options: any, needToken: boolean =
29
17
  requestOptions.header = { ...headers, ...options.headers };
30
18
  delete requestOptions.headers;
31
19
  const openApiUrl = getGlobalData('cloudServiceInfo').openAPIInfo;
32
- const res = await request<IResult<T>>('https://' + openApiUrl + url, requestOptions);
20
+ const res = await request<IWechatApiResult<T>>('https://' + openApiUrl + url, requestOptions);
33
21
  // 统一封装OPEN API的错误码
34
22
  if (res.statusCode >= 200 && res.statusCode < 300) {
35
23
  return {
@@ -1,12 +1,10 @@
1
1
  import openApiRequest from './openApiRequest';
2
- import { IDataPointConfig } from './protocol/DataPoint';
2
+ import { IProductConfigData, IDataPointConfig } from './types';
3
3
  // 管理配置文件
4
4
 
5
- interface IData {
6
- [key: string]: IDataPointConfig;
7
- }
5
+
8
6
  class ProductConfigFileManage {
9
- data: IData = {};
7
+ data: IProductConfigData = {};
10
8
  key = 'dataPointConfig';
11
9
 
12
10
  init = async () => {
@@ -1,6 +1,4 @@
1
- import { IOTAType } from "../../sdk";
2
1
  import ProtocolBase from "../ProtocolBase";
3
- import { arrayToString, fillString, hexStrint2byte } from "../tool";
4
2
 
5
3
  class AwaitNoti extends ProtocolBase {
6
4
  state = 0; // 0继续 1失败
@@ -1,6 +1,5 @@
1
- import { IOTAType } from "../../sdk";
1
+ import { IOTAType } from "../../types";
2
2
  import ProtocolBase from "../ProtocolBase";
3
- import { arrayToString } from "../tool";
4
3
 
5
4
  class CheckCanOTA extends ProtocolBase {
6
5
  type: IOTAType = 'MCU';
@@ -1,5 +1,5 @@
1
1
  import { crc16modbus } from '../../crc'
2
- import { getVariableLength } from "../DataPoint";
2
+ import { getVariableLength } from "../dataPoint";
3
3
  import ProtocolBase from "../ProtocolBase";
4
4
  import { bytesToInt, fillString, hexStrint2byte } from "../tool";
5
5
 
@@ -1,7 +1,6 @@
1
- import { IOTAType } from "../../sdk";
2
- import { getVariableLength } from "../DataPoint";
1
+ import { getVariableLength } from "../dataPoint";
3
2
  import ProtocolBase from "../ProtocolBase";
4
- import { arrayToString, bytesToHexString, bytesToInt, fillString, hexStrint2byte, string2Bytes } from "../tool";
3
+ import { bytesToHexString, bytesToInt, fillString, hexStrint2byte, string2Bytes } from "../tool";
5
4
 
6
5
  type TState = 0 | 1 | 2 | 3 // 0x00 正常升级 0x01 pk不一致 0x02 版本低于当前 0x03 大小超过范围
7
6
  class PreOTA extends ProtocolBase {
@@ -1,6 +1,5 @@
1
- import { IOTAType } from "../../sdk";
2
1
  import ProtocolBase from "../ProtocolBase";
3
- import { arrayToString, fillString, hexStrint2byte } from "../tool";
2
+ import { fillString, hexStrint2byte } from "../tool";
4
3
 
5
4
  class ResetPosition extends ProtocolBase {
6
5
  constructor(data: number[]) {
@@ -1,48 +1,7 @@
1
1
  import productConfigFileManage from "../productConfigFileManage";
2
+ import { IDataPointAttr, TDataOptionType, TDataType } from "../types";
2
3
  import { arrayToString, checkHeader, fillString, getProtocolLen, hexStrint2byte, completeBlock} from "./tool";
3
4
 
4
- export interface IDataPointConfig {
5
- name: string;
6
- protocolType: 'var_len' | 'standard';
7
- entities: IDataPointEntitie[];
8
- }
9
-
10
-
11
-
12
- interface IDataPointEntitie {
13
- display_name: string;
14
- attrs: IDataPointAttr[];
15
- }
16
-
17
- interface IDataPointPosition {
18
- byte_offset: number;
19
- unit: 'bit' | 'byte';
20
- len: number;
21
- bit_offset: number;
22
- }
23
-
24
- type TDataType = 'bool' | 'uint8' | 'uint16' | 'uint32' | 'binary' | 'enum' | 'number';
25
-
26
-
27
- interface IUnitSpec {
28
- addition: number;
29
- max: number;
30
- ratio: number;
31
- min: number;
32
- }
33
-
34
- type TDataOptionType = 'status_writable' | 'status_readonly' | 'alert' | 'fault' | 'ALL';
35
- export interface IDataPointAttr {
36
- display_name: string;
37
- uint_spec: IUnitSpec;
38
- name:string;
39
- data_type: TDataType;
40
- position: IDataPointPosition;
41
- type: TDataOptionType;
42
- id: number;
43
- enum: string[];
44
- desc: string;
45
- }
46
5
 
47
6
  const fixType = (type: TDataType) => {
48
7
  return type.indexOf('uint') !== -1 ? 'number' : type;
package/src/randomCode.ts CHANGED
@@ -1,16 +1,5 @@
1
1
  import {MD5, AES, enc, pad, mode} from 'crypto-js';
2
-
3
- interface IGetRandomCodes {
4
- SSID: string;
5
- password: string;
6
- pks: string[];
7
- }
8
-
9
- interface IGetRandomCode {
10
- SSID: string;
11
- password: string;
12
- pk: string;
13
- }
2
+ import { IGetRandomCode, IGetRandomCodes } from './types';
14
3
 
15
4
  const getRandomCodes = ({ SSID, password, pks }: IGetRandomCodes): string[] => {
16
5
  const randomCodes: string[] = [];
package/src/sdk.ts CHANGED
@@ -3,12 +3,12 @@ import { getGlobalData, setGlobalData } from './globalData';
3
3
  import sdkConfig from '../package.json';
4
4
  import { LanHandle } from './handler/lan';
5
5
  import productConfigFileManage from './productConfigFileManage';
6
- import { formatEnum, IDataPointConfig, pack, unpack } from './protocol/DataPoint';
6
+ import { formatEnum, pack, unpack } from './protocol/dataPoint';
7
7
  import Ntp from './protocol/Ntp';
8
8
  import { CancelSync, DeletePackage, RequestSync, SyncPackage } from './protocol/OffLineData';
9
9
  import ProtocolBase from './protocol/ProtocolBase';
10
10
  import { arrayToString, hexStrint2byte } from './protocol/tool';
11
- import { BleHandle, OTAEventCallback, OTAProgressEventCallback } from './handler/ble';
11
+ import { BleHandle } from './handler/ble';
12
12
  import GizwitsWS from './handler/socket';
13
13
  import Reset from './protocol/Reset';
14
14
  import SetReset from './protocol/SetReset';
@@ -20,13 +20,12 @@ import {
20
20
  bindMac,
21
21
  editBindInfo,
22
22
  getBindingList,
23
- IOpenApiDevice,
24
23
  ISafeRegisterReturn,
25
24
  IUnbindReturn,
26
25
  safeRegister,
27
26
  unbindDevice
28
27
  } from './services/devices';
29
- import { AnonymousLogin, ILoginRes } from './services/login';
28
+ import { AnonymousLogin } from './services/login';
30
29
  import { uploadP0 } from './services/uploadP0';
31
30
  import sleep from './sleep';
32
31
  import {
@@ -41,118 +40,16 @@ import {
41
40
  import ApConfig from './wifiConfig/ap';
42
41
  import BLEConfig from './wifiConfig/ble';
43
42
  import NFCConfig from './wifiConfig/nfc';
44
- import { ConfigEventData } from './wifiConfig/ConfigBase';
43
+ import { IDevice, TConnectType, IOnDeviceStatusChanged,
44
+ IOpenApiDevice,
45
+ IDeviceStatusChangedProps, IOnSocketStatusChanged,
46
+ IProductInfo, GizwitsSdkOption, SyncCallBack, ISDKResult,
47
+ IResult, IOTAType, IBindRemoteDeviceParams, ICloudServiceInfo,
48
+ TListenerType, IDeviceSafetyParams, ISetDeviceOnboardingDeployProps,
49
+ IDataPointConfig, OTAEventCallback, OTAProgressEventCallback, ILoginRes,
50
+ IDeviceSafetyRegisterParams } from './types';
45
51
 
46
52
  const version = sdkConfig.version;
47
- interface SyncCallBackParams {
48
- event: TSyncEvnet;
49
- currentNum?: number;
50
- totalNum?: number;
51
- message?: string;
52
- }
53
- type TSyncEvnet = 'SYNC_START' | 'SYNC_END' | 'SYNC_FAIL' | 'SYNC_CANCEL' | 'SYNC_PROGRESS';
54
- export type SyncCallBack = (data: SyncCallBackParams) => void
55
- export type IOTAType = 'MCU' | 'MODULE'
56
-
57
- // 接口返回格式
58
- export interface ISDKResult<T> {
59
- data?: T;
60
- err?: IError;
61
- message?: string;
62
- success: boolean;
63
- }
64
- export interface ISetCommonDeviceOnboardingDeployProps {
65
- ssid: string;
66
- bssid?: string;
67
- password: string;
68
- timeout: number;
69
- isBind?: boolean;
70
- mode?: 0 | 3 | 5; // 0 AP 3 BLE 5 NFC
71
- softAPSSIDPrefix?: string;
72
- }
73
-
74
- export interface ISetDeviceOnboardingDeployProps
75
- extends ISetCommonDeviceOnboardingDeployProps {
76
- softAPSSIDPrefix: string;
77
- eventCallBack: (event: ConfigEventData) => void, // 配网回调
78
- }
79
-
80
- export interface IRandomCodesResult {
81
- random_code: string;
82
- product_key: string;
83
- mac: string;
84
- did: string;
85
- user_id: string;
86
- timestamp: number;
87
- type: string;
88
- wifi_soft_ver: string;
89
- lan_proto_ver: string;
90
- }
91
-
92
- interface IBindRemoteDeviceParams {
93
- productKey: string;
94
- mac: string;
95
- beOwner?: boolean;
96
- alias?: string;
97
- }
98
-
99
- interface IDeviceStatusNoti {
100
- device: IDevice;
101
- connectType: TConnectType;
102
- }
103
- interface IDeviceAttrsNoti {
104
- device: IDevice;
105
- data: object;
106
- }
107
-
108
- export interface TListenerType {
109
- GizDeviceListNotifications: TDeviceListNotifications;
110
- GizDeviceStatusNotifications: TDeviceStatusNotifications;
111
- GizDeviceAttrsNotifications: TDeviceAttrsNotifications;
112
- onScanListChange: OnScanListChange;
113
- onBleHandleError: OnBleHandleError;
114
- }
115
-
116
- type TDeviceListNotifications = (devices: IDevice[]) => void;
117
- type TDeviceStatusNotifications = (data: IDeviceStatusNoti) => void;
118
- type TDeviceAttrsNotifications = (data: IDeviceAttrsNoti) => void;
119
- type OnScanListChange = (devices: IDevice[]) => void;
120
- type OnBleHandleError = (error: IError) => void;
121
-
122
- interface IDeviceSafetyRegisterParams {
123
- mac: string;
124
- productKey: string;
125
- }
126
-
127
- interface IDeviceSafetyParams extends IDeviceSafetyRegisterParams {
128
- isReset: boolean;
129
- }
130
- export interface IResult<T> {
131
- success: boolean;
132
- data?: T;
133
- err?: IError;
134
- }
135
-
136
- interface ICloudServiceInfo {
137
- openAPIInfo: string;
138
- }
139
-
140
- export type TimeoutHandle = ReturnType<typeof setTimeout> | null;
141
- export type IntervalHandle = ReturnType<typeof setInterval> | null;
142
- export interface IProductInfo {
143
- productKey: string;
144
- productSecret: string;
145
- }
146
- interface GizwitsSdkOption {
147
- appID: string;
148
- appSecret: string;
149
- productInfo: IProductInfo[];
150
- cloudServiceInfo?: ICloudServiceInfo;
151
- token?: string;
152
- uid?: string;
153
- offlineThreshold?: number;
154
- }
155
-
156
53
  class GizwitsMiniSDK {
157
54
  private listenerMap: any = {};
158
55
  private keepScanTimer: any = null;
@@ -1,31 +1,11 @@
1
1
  import { enc, AES, mode, pad } from 'crypto-js';
2
- import openApiRequest, { IServiceResult } from '../openApiRequest';
2
+ import openApiRequest from '../openApiRequest';
3
3
  import getRandomCodes from '../randomCode';
4
- import { IRandomCodesResult } from '../sdk';
5
4
  import { psKeySign } from './tool';
5
+ import { IDevice, IDeviceRes, IOpenApiDevice, IRandomCodesResult, IServiceResult } from '../types';
6
6
  // eslint-disable-next-line import/no-commonjs
7
7
  // const CryptoJS = require('crypto-js');
8
8
 
9
- export interface IOpenApiDevice {
10
- product_key: string;
11
- did: string;
12
- mac: string;
13
- passcode: string;
14
- is_online: boolean;
15
- host: string;
16
- port: string;
17
- port_s: string;
18
- ws_port: number;
19
- wss_port: number;
20
- dev_alias: string;
21
- remark: string;
22
- type: 'normal' | 'center_control' | 'sub_dev';
23
- }
24
-
25
- interface IDeviceRes {
26
- devices: IOpenApiDevice[];
27
- }
28
-
29
9
  // 云端aes 特殊解码
30
10
  class Padding {
31
11
  /**
@@ -1,10 +1,6 @@
1
1
  import openApiRequest from "../openApiRequest";
2
+ import { ILoginRes } from "../types";
2
3
 
3
- export interface ILoginRes {
4
- expire_at: number;
5
- token: string;
6
- uid: string;
7
- }
8
4
  export async function AnonymousLogin ({uid}: {uid: string}) {
9
5
  return openApiRequest<ILoginRes>('/app/users', {
10
6
  data: {
@@ -1,6 +1,7 @@
1
1
  import { version } from '../../package.json';
2
2
  import { getGlobalData } from "../globalData";
3
3
  import openApiRequest from '../openApiRequest';
4
+ import { IDevice } from '../types';
4
5
 
5
6
  interface MobileInfo {
6
7
  brand: string;
@@ -1,10 +1,6 @@
1
1
  import openApiRequest from "../openApiRequest";
2
- import { IOTAType } from "../sdk";
2
+ import { IOTAType, OTARes } from "../types";
3
3
 
4
- export interface OTARes {
5
- download_url: string;
6
- soft_ver: string; // 新的版本号
7
- }
8
4
 
9
5
  //type 指定固件类型,1代表WiFi模组,2代表MCU
10
6
  export async function checkUpdate ({did, type, hardVersion, softVersion}: {did: string, type: IOTAType, hardVersion: string, softVersion: string}) {
@@ -1,5 +1,6 @@
1
1
  import openApiRequest from "../openApiRequest";
2
2
  import { enc, AES, mode, pad } from 'crypto-js';
3
+ import { IDevice } from "../types";
3
4
 
4
5
  export interface IUploadRes {
5
6
  }