mini_program_gizwits_sdk 3.3.2 → 3.3.25-kuka

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.
@@ -0,0 +1,7 @@
1
+ export interface IServiceResult<T> {
2
+ success: boolean;
3
+ data?: T;
4
+ err?: IError;
5
+ }
6
+ declare const aepApiRequest: <T>(url: string, options: any, needToken?: boolean) => Promise<IServiceResult<T>>;
7
+ export default aepApiRequest;
@@ -38,7 +38,7 @@ export declare class BleHandle extends EventListener<TBleHandleEvent> {
38
38
  private serviceUUIDSuffix;
39
39
  connectedList: ConnectDevice[];
40
40
  private connectingDevId;
41
- pks: string[];
41
+ private pks;
42
42
  private listenDevOfflineTimer;
43
43
  private boradcastTimer;
44
44
  private boradcastDataCache;
@@ -48,9 +48,6 @@ export declare class BleHandle extends EventListener<TBleHandleEvent> {
48
48
  private disableScanFlag;
49
49
  private peripheralServer;
50
50
  private isActive;
51
- private _offlineThreshold;
52
- set offlineThreshold(value: any);
53
- get offlineThreshold(): any;
54
51
  scanList: IDevice[];
55
52
  constructor({ pks, bleHandleParams, offlineThreshold, }: ConstructorParams);
56
53
  private onBluetoothAdapterStateChange;
@@ -18,7 +18,7 @@ export interface TLanHandleEvent {
18
18
  }
19
19
  export declare class LanHandle extends EventListener<TLanHandleEvent> {
20
20
  connectedList: ConnectDevice[];
21
- pks: string[];
21
+ private pks;
22
22
  scanList: ILanDevice[];
23
23
  private boradcastTimer;
24
24
  private UDPSocket;
package/dist/src/sdk.d.ts CHANGED
@@ -21,7 +21,7 @@ export interface ISetCommonDeviceOnboardingDeployProps {
21
21
  password: string;
22
22
  timeout: number;
23
23
  isBind?: boolean;
24
- mode?: 0 | 3;
24
+ mode?: 0 | 3 | 10;
25
25
  softAPSSIDPrefix?: string;
26
26
  }
27
27
  export interface ISetDeviceOnboardingDeployProps extends ISetCommonDeviceOnboardingDeployProps {
@@ -75,6 +75,7 @@ export interface IResult<T> {
75
75
  }
76
76
  interface ICloudServiceInfo {
77
77
  openAPIInfo: string;
78
+ aepInfo: string;
78
79
  }
79
80
  export declare type TimeoutHandle = ReturnType<typeof setTimeout> | null;
80
81
  export declare type IntervalHandle = ReturnType<typeof setInterval> | null;
@@ -92,6 +93,7 @@ interface GizwitsSdkOption {
92
93
  offlineThreshold?: number;
93
94
  }
94
95
  declare class GizwitsMiniSDK {
96
+ private version;
95
97
  private listenerMap;
96
98
  private keepScanTimer;
97
99
  private _deviceList;
@@ -118,12 +120,10 @@ declare class GizwitsMiniSDK {
118
120
  private syncDataTimoutTimer;
119
121
  private SYNC_TIMEOUT;
120
122
  private syncDevice?;
121
- constructor(props: GizwitsSdkOption);
123
+ constructor({ appID, appSecret, productInfo, cloudServiceInfo, token, uid, offlineThreshold, }: GizwitsSdkOption);
122
124
  private get bleHandle();
123
125
  private get lanHandle();
124
126
  private get socketHandle();
125
- private init;
126
- reInit(props: GizwitsSdkOption): void;
127
127
  get specialProductKeys(): string[];
128
128
  get specialProductKeySecrets(): string[];
129
129
  private handleBleError;
@@ -138,7 +138,7 @@ declare class GizwitsMiniSDK {
138
138
  startAutoScan: (services?: string[]) => void;
139
139
  stopAutoScan: () => void;
140
140
  setDeviceMeta: <K extends "did" | "mac" | "productKey" | "bleWorkStatus" | "name" | "isBind" | "rootDeviceId" | "bleDeviceID" | "remark" | "passcode" | "connectType" | "isOnline" | "isLanOnline" | "isBleOnline" | "host" | "wss_port" | "ctime">(curDev: IDevice, key: K, value: IDevice[K], force?: boolean) => void;
141
- static getVersion: () => {
141
+ getVersion: () => {
142
142
  success: boolean;
143
143
  data: string;
144
144
  };
@@ -0,0 +1,67 @@
1
+ import { IResult } from "../sdk";
2
+ import ConfigBase from "./ConfigBase";
3
+ import { BleHandle } from "../handler/ble";
4
+ interface IVerifyOnlineResult {
5
+ data: {
6
+ mac: string;
7
+ onlineStatus: number;
8
+ lastOnlineTime: string;
9
+ };
10
+ }
11
+ interface IConfigResult {
12
+ mac: string;
13
+ productKey: string;
14
+ }
15
+ interface IArgs {
16
+ bleDeviceId: string;
17
+ arrayBuffer: ArrayBuffer;
18
+ serviceUUIDSuffix?: string;
19
+ characteristicUUIDSuffix?: string;
20
+ bleHandle: BleHandle;
21
+ }
22
+ export declare function sendBLEConfigCmd({ bleDeviceId, arrayBuffer, serviceUUIDSuffix, characteristicUUIDSuffix, bleHandle }: IArgs): Promise<boolean | void>;
23
+ interface configBLEDeviceParams {
24
+ ssid: string;
25
+ password: string;
26
+ softAPSSIDPrefix?: string;
27
+ timeout: number;
28
+ }
29
+ interface ISetDeviceOnboardingDeployProps {
30
+ timeout: number;
31
+ isBind: boolean;
32
+ softAPSSIDPrefix: string;
33
+ }
34
+ interface IOnlieTimeMap {
35
+ [key: string]: string;
36
+ }
37
+ declare class BLEAliCloudConfig extends ConfigBase {
38
+ bleHandle: BleHandle;
39
+ lastestOnlineTimeMap: IOnlieTimeMap;
40
+ constructor(ssid: string, password: string, specialProductKeys: string[], specialProductKeySecrets: string[], bleHandle: BleHandle);
41
+ destroy: () => void;
42
+ isValidBleDevice: (bleDevice: WechatMiniprogram.BlueToothDevice, softAPSSIDPrefix?: string) => boolean;
43
+ enableBluetoothDevicesDescovery: () => Promise<{
44
+ success: false;
45
+ err: IError;
46
+ } | {
47
+ success: true;
48
+ }>;
49
+ enableAndGetBluetoothDevices: (softAPSSIDPrefix?: string) => Promise<{
50
+ success: false;
51
+ err: IError;
52
+ } | {
53
+ success: true;
54
+ bleDevices?: WechatMiniprogram.BlueToothDevice[];
55
+ }>;
56
+ setDeviceOnboardingDeploy: ({ timeout, isBind, softAPSSIDPrefix, }: ISetDeviceOnboardingDeployProps) => Promise<IResult<IDevice[]>>;
57
+ getDeviceLastestOnlineTime: ({ productKey, mac }: {
58
+ productKey: string;
59
+ mac: string;
60
+ }) => Promise<import("../aepApi/aepApiRequest").IServiceResult<IVerifyOnlineResult>>;
61
+ verifyDeviceOnline: ({ productKey, mac }: {
62
+ productKey: string;
63
+ mac: string;
64
+ }) => Promise<IResult<IVerifyOnlineResult>>;
65
+ configBLEDevice: ({ ssid, password, softAPSSIDPrefix, }: configBLEDeviceParams) => Promise<IResult<IConfigResult>>;
66
+ }
67
+ export default BLEAliCloudConfig;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mini_program_gizwits_sdk",
3
- "version": "3.3.2",
4
- "description": "增加代理蓝牙设备重置功能",
3
+ "version": "3.3.25-kuka",
4
+ "description": "更新文档",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {
7
7
  "test": "node_modules/mocha/bin/_mocha -r ts-node/register tests/**/*.spec.ts -file ./tests/setup-wx.js -timeout 60s",
@@ -0,0 +1,62 @@
1
+ import request from '../request';
2
+ import { getGlobalData } from "../globalData";
3
+ import errorCode from '../errorCode';
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
+
17
+
18
+ const aepApiRequest = async <T>(url: string, options: any, needToken: boolean = true): Promise<IServiceResult<T>> => {
19
+ const requestOptions = { ...options };
20
+ const headers: any = {
21
+ 'Content-Type': 'application/json',
22
+ 'X-Gizwits-Application-Id': getGlobalData('appID'),
23
+ };
24
+
25
+ if (needToken) {
26
+ headers['Authorization'] = getGlobalData('token');
27
+ }
28
+
29
+ requestOptions.header = { ...headers, ...options.headers };
30
+ delete requestOptions.headers;
31
+ const aepApiUrl = getGlobalData('cloudServiceInfo').aepInfo;
32
+ const res = await request<IResult<T>>(aepApiUrl + url, requestOptions);
33
+ // 统一封装OPEN API的错误码
34
+ if (res.statusCode >= 200 && res.statusCode < 300) {
35
+ return {
36
+ success: true,
37
+ data: res.data
38
+ }
39
+ }
40
+
41
+ let baseError = {
42
+ success: false,
43
+ err: {
44
+ errorCode: errorCode.GIZ_SDK_HTTP_REQUEST_FAILED.errorCode,
45
+ errorMessage: '',
46
+ }
47
+ }
48
+ try {
49
+ baseError = {
50
+ success: false,
51
+ err: {
52
+ errorCode: (res.data as any).error_code,
53
+ errorMessage: (res.data as any).error_message,
54
+ }
55
+ }
56
+ } catch (error) {
57
+
58
+ }
59
+ return baseError;
60
+ }
61
+
62
+ export default aepApiRequest;
@@ -18,7 +18,6 @@ import { padBoradcastData } from '../protocol/DataPoint';
18
18
  import GizLog from '../GizLog';
19
19
  import EventListener from './EventListener';
20
20
  import sleep from '../sleep';
21
- import Reset from '../protocol/Reset';
22
21
 
23
22
  type GizBleDeviceListotifications = (devices: IDevice[]) => void;
24
23
  type GizBleDeviceDataNotifications = (
@@ -73,12 +72,12 @@ export class BleHandle extends EventListener<TBleHandleEvent> {
73
72
  // private characteristicUUIDSuffix: string;
74
73
  public connectedList: ConnectDevice[] = [];
75
74
  private connectingDevId: string | null = null;
76
- public pks: string[] = [];
75
+ private pks: string[] = [];
77
76
  private listenDevOfflineTimer: any = null;
78
77
 
79
78
  private boradcastTimer: any;
80
79
  private boradcastDataCache: any = {}
81
- private baseServices: string[] = ['ABF8', 'ABF0', 'F0AB', 'F8AB'];
80
+ private baseServices: string[] = [];
82
81
 
83
82
  private tmpBleData = ''; // 接收分包数据用
84
83
  private tmpDataNum = 0; // 剩余字节数
@@ -88,23 +87,13 @@ export class BleHandle extends EventListener<TBleHandleEvent> {
88
87
 
89
88
  private isActive = true; // 小程序是否活跃
90
89
 
91
- private _offlineThreshold = null;
92
- public set offlineThreshold(value) {
93
- this._offlineThreshold = value;
94
- }
95
-
96
- public get offlineThreshold() {
97
- return this._offlineThreshold || 10000;
98
- }
99
-
100
-
101
90
  // private globalListenerMap = {};
102
91
  public scanList: IDevice[] = [];
103
92
  constructor({
104
93
  pks = [],
105
94
  bleHandleParams = {
106
- serviceUUIDSuffix: 'abf0',
107
- characteristicUUIDSuffix: 'abf7',
95
+ serviceUUIDSuffix: 'fe60',
96
+ characteristicUUIDSuffix: 'fe61',
108
97
  },
109
98
  offlineThreshold,
110
99
  }: ConstructorParams) {
@@ -118,8 +107,7 @@ export class BleHandle extends EventListener<TBleHandleEvent> {
118
107
  // 或 addEventListener 参数 deviceData deviceList error
119
108
  // this.globalListenerMap = globalListenerMap;
120
109
 
121
- this.offlineThreshold = offlineThreshold;
122
- this.listenDevOffline();
110
+ this.listenDevOffline(offlineThreshold ?? 10000);
123
111
  this.listenConnection();
124
112
 
125
113
  wx.onAppShow(this.onAppShow);
@@ -152,7 +140,7 @@ export class BleHandle extends EventListener<TBleHandleEvent> {
152
140
  }
153
141
 
154
142
 
155
- private listenDevOffline = () => {
143
+ private listenDevOffline = (offlineThreshold: number) => {
156
144
  // 定时检查设备列表,移除超时设备
157
145
  this.listenDevOfflineTimer = setInterval(() => {
158
146
  // 非激活状态不处理
@@ -167,9 +155,9 @@ export class BleHandle extends EventListener<TBleHandleEvent> {
167
155
  }
168
156
  // 广播类型的设备由于性能问题,双倍的时间才触发离线
169
157
  if (d.connectType === "BLE_BROADCAST") {
170
- return now - d.ctime < this.offlineThreshold * 2;
158
+ return now - d.ctime < offlineThreshold * 2;
171
159
  }
172
- return now - d.ctime < this.offlineThreshold;
160
+ return now - d.ctime < offlineThreshold;
173
161
  });
174
162
  if (newDeviceList.length !== this.scanList.length) {
175
163
  this.scanList = newDeviceList;
@@ -390,6 +378,7 @@ export class BleHandle extends EventListener<TBleHandleEvent> {
390
378
  */
391
379
  (unionBy(resData.devices, 'deviceId') as GizwitsWxBlueToothDevice[]).map((device) => {
392
380
  const { advertisData, deviceId, name, localName } = device;
381
+
393
382
  const advertisDataStr = ab2hex(advertisData);
394
383
 
395
384
  // 从服务uuid里面扫描广播类的设备
@@ -590,36 +579,34 @@ export class BleHandle extends EventListener<TBleHandleEvent> {
590
579
  })
591
580
  .catch((err) => this.notifyError(err));
592
581
 
593
- this.write(deviceId, numberArray2Uint8Array(Bind.pack()).buffer);
594
- const data = await this.handleBindReq(deviceId);
595
- GizLog.log('handleBindReq', data);
596
-
597
- if (data.success) {
598
- this.write(
599
- deviceId,
600
- numberArray2Uint8Array(Login.pack({ passcode: data.data })).buffer
601
- );
602
- const loginData = (await this.handleLoginReq(deviceId).catch((err) =>
603
- this.notifyError(err)
604
- )) as any;
605
- if (loginData?.success) {
606
-
607
- // 登录成功后查询一下 重置状态
608
- this.write(deviceId, numberArray2Uint8Array(Reset.pack()).buffer);
609
- return {
610
- success: true,
611
- message: 'ok',
612
- };
613
- }
614
- }
615
-
616
- // 绑定失败,异常退出断开蓝牙
617
- await wx.closeBLEConnection({
618
- deviceId,
619
- });
582
+ // this.write(deviceId, numberArray2Uint8Array(Bind.pack()).buffer);
583
+ // const data = await this.handleBindReq(deviceId);
584
+ // GizLog.log('handleBindReq', data);
585
+
586
+ // if (data.success) {
587
+ // this.write(
588
+ // deviceId,
589
+ // numberArray2Uint8Array(Login.pack({ passcode: data.data })).buffer
590
+ // );
591
+ // const loginData = (await this.handleLoginReq(deviceId).catch((err) =>
592
+ // this.notifyError(err)
593
+ // )) as any;
594
+ // if (loginData?.success) {
595
+
596
+ // return {
597
+ // success: true,
598
+ // message: 'ok',
599
+ // };
600
+ // }
601
+ // }
602
+
603
+ // // 绑定失败,异常退出断开蓝牙
604
+ // await wx.closeBLEConnection({
605
+ // deviceId,
606
+ // });
620
607
 
621
608
  return {
622
- success: false,
609
+ success: true,
623
610
  message: 'ok',
624
611
  };
625
612
  } finally {
@@ -33,7 +33,7 @@ export interface TLanHandleEvent {
33
33
  export class LanHandle extends EventListener<TLanHandleEvent> {
34
34
  // private characteristicUUIDSuffix: string;
35
35
  public connectedList: ConnectDevice[] = [];
36
- public pks: string[] = [];
36
+ private pks: string[] = [];
37
37
  // private globalListenerMap = {};
38
38
  public scanList: ILanDevice[] = [];
39
39
 
@@ -28,9 +28,9 @@ interface IGWSProps extends ICommonProps {
28
28
 
29
29
  export default class GizwitsWS {
30
30
 
31
- public appID: string;
32
- public token: string;
33
- public uid: string;
31
+ appID: string;
32
+ token: string;
33
+ uid: string;
34
34
  _maxSocketNum: number;
35
35
  _bindingDevices: { [did: string]: IDevice } | null = null;
36
36
  _connections: { [wsInfo: string]: Connection } = {};
@@ -425,6 +425,13 @@ export class Connection {
425
425
  message: 'Socket not ready'
426
426
  })
427
427
  return;
428
+ // this._waitSends.push(data);
429
+ // resolve({
430
+ // success: true,
431
+ // message: '',
432
+ // })
433
+ // GizLog.debug('GIZ_SDK: cache data wait socket ready');
434
+ return;
428
435
  }
429
436
  if (this._websocket && (forced || this.ready)) {
430
437
  this._websocket.send({
package/src/sdk.ts CHANGED
@@ -4,6 +4,7 @@ import GizwitsWS from './handler/socket';
4
4
 
5
5
  import ApConfig from './wifiConfig/ap';
6
6
  import BLEConfig from './wifiConfig/ble';
7
+ import BLEAliConfig from './wifiConfig/ble_ailCloud';
7
8
  import GizLog, { TLogType } from './GizLog';
8
9
  import { errorCode } from '..';
9
10
  import { AnonymousLogin, ILoginRes } from './services/login';
@@ -34,11 +35,7 @@ import { CancelSync, DeletePackage, RequestSync, SyncPackage } from './protocol/
34
35
  import { uploadP0 } from './services/uploadP0';
35
36
  import sleep from './sleep';
36
37
  import Ntp from './protocol/Ntp';
37
- import sdkConfig from '../package.json';
38
- import Reset from './protocol/Reset';
39
- import SetReset from './protocol/SetReset';
40
38
 
41
- const version = sdkConfig.version;
42
39
  interface SyncCallBackParams {
43
40
  event: TSyncEvnet;
44
41
  currentNum?: number;
@@ -61,7 +58,7 @@ export interface ISetCommonDeviceOnboardingDeployProps {
61
58
  password: string;
62
59
  timeout: number;
63
60
  isBind?: boolean;
64
- mode?: 0 | 3; // 0 AP 3 BLE
61
+ mode?: 0 | 3 | 10; // 0 AP 3 BLE 10 BLE Ali
65
62
  softAPSSIDPrefix?: string;
66
63
  }
67
64
 
@@ -128,6 +125,7 @@ export interface IResult<T> {
128
125
 
129
126
  interface ICloudServiceInfo {
130
127
  openAPIInfo: string;
128
+ aepInfo: string;
131
129
  }
132
130
 
133
131
  export type TimeoutHandle = ReturnType<typeof setTimeout> | null;
@@ -147,6 +145,7 @@ interface GizwitsSdkOption {
147
145
  }
148
146
 
149
147
  class GizwitsMiniSDK {
148
+ private version = '3.1.11-1';
150
149
  private listenerMap: any = {};
151
150
  private keepScanTimer: any = null;
152
151
 
@@ -269,8 +268,38 @@ class GizwitsMiniSDK {
269
268
  private SYNC_TIMEOUT: number = 4 * 60 * 1000
270
269
  private syncDevice?: IDevice;
271
270
 
272
- constructor(props: GizwitsSdkOption) {
273
- this.init(props);
271
+ constructor({
272
+ appID,
273
+ appSecret,
274
+ productInfo,
275
+ cloudServiceInfo,
276
+ token,
277
+ uid,
278
+ offlineThreshold,
279
+ }: GizwitsSdkOption) {
280
+ this.productInfo = productInfo;
281
+ // 保存相关信息
282
+ setGlobalData('appID', appID);
283
+ setGlobalData('appSecret', appSecret);
284
+ setGlobalData('productInfo', productInfo);
285
+ setGlobalData('token', token);
286
+ setGlobalData('uid', uid);
287
+
288
+ /**
289
+ * 同时也设置域名信息
290
+ */
291
+ this.setDomain(cloudServiceInfo);
292
+
293
+ this.offlineThreshold = offlineThreshold;
294
+
295
+ GizLog.debug(`init sdk success, current version: ${this.version}`);
296
+
297
+ /**
298
+ * lan 比较特殊
299
+ * 初始化sdk的时候就要开始扫描设备
300
+ */
301
+ this.initLan();
302
+
274
303
  }
275
304
 
276
305
  private get bleHandle() {
@@ -307,63 +336,6 @@ class GizwitsMiniSDK {
307
336
  return this._gizSocket;
308
337
  }
309
338
 
310
-
311
- private init = ({
312
- appID,
313
- appSecret,
314
- productInfo,
315
- cloudServiceInfo,
316
- token,
317
- uid,
318
- offlineThreshold,
319
- }: GizwitsSdkOption) => {
320
- this.productInfo = productInfo;
321
- // 保存相关信息
322
- setGlobalData('appID', appID);
323
- setGlobalData('appSecret', appSecret);
324
- setGlobalData('productInfo', productInfo);
325
- setGlobalData('token', token);
326
- setGlobalData('uid', uid);
327
-
328
- /**
329
- * 同时也设置域名信息
330
- */
331
- this.setDomain(cloudServiceInfo);
332
-
333
- this.offlineThreshold = offlineThreshold;
334
-
335
- GizLog.debug(`init sdk success, current version: ${GizwitsMiniSDK.getVersion().data}`);
336
-
337
- /**
338
- * lan 比较特殊
339
- * 初始化sdk的时候就要开始扫描设备
340
- */
341
- this.initLan();
342
- }
343
- public reInit(props: GizwitsSdkOption) {
344
- this.init(props);
345
-
346
- // 更新handler 参数
347
- this.lanHandle.pks = this.specialProductKeys;
348
- this.bleHandle.pks = this.specialProductKeys;
349
- this.bleHandle.offlineThreshold = props.offlineThreshold;
350
-
351
- const { appID, token, cloudServiceInfo = {openAPIInfo: ''} } = props;
352
- const openAPIInfo = (cloudServiceInfo && cloudServiceInfo.openAPIInfo) || 'api.gizwits.com';
353
- if (appID !== getGlobalData('appID') ||
354
- token !== getGlobalData('token') ||
355
- openAPIInfo !== getGlobalData('cloudServiceInfo').openAPIInfo
356
- ) {
357
- // 需要重启
358
- this.socketHandle.destory();
359
- this._gizSocket = null;
360
- // eslint-disable-next-line @typescript-eslint/no-unused-expressions
361
- this.socketHandle;
362
-
363
- this.getBindingList();
364
- }
365
- }
366
-
367
339
  get specialProductKeys() {
368
340
  return this.productInfo.map((item) => item.productKey ?? '');
369
341
  }
@@ -454,32 +426,6 @@ class GizwitsMiniSDK {
454
426
  }
455
427
  break
456
428
  }
457
- case '0062': {
458
- // 蓝牙重置命令,app代理设备进行重置
459
- const resetInfo = new Reset(bleBytesData)
460
- GizLog.debug("收到代理重置事件", resetInfo)
461
-
462
- if (resetInfo.status === 1) {
463
- // 需要重置
464
- this.deviceSafetyApi({
465
- mac: target.mac,
466
- productKey: target.productKey,
467
- isReset: true
468
- }).then(async data => {
469
- GizLog.debug("代理重置结果", data)
470
- if (data.success && data.data.successDevices.length > 0) {
471
- // 回写数据
472
- GizLog.debug("重置成功,回写数据")
473
- await this.bleHandle.write(curDevice.deviceId, numberArray2Uint8Array(SetReset.pack(0)).buffer)
474
- }
475
- })
476
- }
477
- break;
478
- }
479
- case '0064': {
480
- // 回写重置结果ack,暂时先忽略
481
- break;
482
- }
483
429
  case '0052': {
484
430
  // 设备回复是否允许同步数据
485
431
  const requestSyncData = new RequestSync(bleBytesData)
@@ -710,10 +656,10 @@ class GizwitsMiniSDK {
710
656
  }
711
657
  };
712
658
 
713
- static getVersion = () => {
659
+ getVersion = () => {
714
660
  return {
715
661
  success: true,
716
- data: version,
662
+ data: this.version,
717
663
  };
718
664
  };
719
665
 
@@ -1244,6 +1190,26 @@ class GizwitsMiniSDK {
1244
1190
  GizLog.debug('GIZ_SDK: 配网用时:' + (eTime - sTime));
1245
1191
  return data;
1246
1192
  }
1193
+ case 10: {
1194
+ this.currentWifiConfigHandle = new BLEAliConfig(
1195
+ ssid,
1196
+ password,
1197
+ this.specialProductKeys,
1198
+ this.specialProductKeySecrets,
1199
+ this.bleHandle
1200
+ );
1201
+ const data =
1202
+ await this.currentWifiConfigHandle.setDeviceOnboardingDeploy({
1203
+ timeout,
1204
+ isBind,
1205
+ softAPSSIDPrefix,
1206
+ });
1207
+ this.currentWifiConfigHandle = null;
1208
+ const eTime = new Date().getTime();
1209
+ GizLog.debug('GIZ_SDK: 配网结束时间:' + eTime);
1210
+ GizLog.debug('GIZ_SDK: 配网用时:' + (eTime - sTime));
1211
+ return data;
1212
+ }
1247
1213
  }
1248
1214
  } catch (error) {
1249
1215
  GizLog.error("GIZ_SDK: setDeviceOnboardingDeploy", new Error(JSON.stringify(error)));
@@ -1268,8 +1234,10 @@ class GizwitsMiniSDK {
1268
1234
  private setDomain = (cloudServiceInfo: ICloudServiceInfo) => {
1269
1235
  const openAPIInfo =
1270
1236
  (cloudServiceInfo && cloudServiceInfo.openAPIInfo) || 'api.gizwits.com';
1237
+ const aepInfo =
1238
+ (cloudServiceInfo && cloudServiceInfo.aepInfo) || 'https://gj-app.iotsdk.com/';
1271
1239
 
1272
- const newData = { ...(cloudServiceInfo || {}), openAPIInfo };
1240
+ const newData = { ...(cloudServiceInfo || {}), openAPIInfo, aepInfo };
1273
1241
  setGlobalData('cloudServiceInfo', newData);
1274
1242
  };
1275
1243