mini_program_gizwits_sdk 3.1.17-13 → 3.1.17-14

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mini_program_gizwits_sdk",
3
- "version": "3.1.17-13",
3
+ "version": "3.1.17-14",
4
4
  "description": "云端推送解除绑定的时候,移除m2m的订阅",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {
@@ -180,6 +180,7 @@ export class BleHandle extends EventListener<TBleHandleEvent> {
180
180
  if (!curDevice.value) {
181
181
  return;
182
182
  }
183
+ console.log('handleOnBLECharacteristicValueChange', curDevice)
183
184
  const hexString = ab2hex(curDevice.value);
184
185
  try {
185
186
  const data = new ProtocolBase(hexStrint2byte(hexString));
package/src/sdk.ts CHANGED
@@ -849,7 +849,8 @@ class GizwitsMiniSDK {
849
849
  ssid,
850
850
  password,
851
851
  this.specialProductKeys,
852
- this.specialProductKeySecrets
852
+ this.specialProductKeySecrets,
853
+ this.bleHandle
853
854
  );
854
855
  const data =
855
856
  await this.currentWifiConfigHandle.setDeviceOnboardingDeploy({
@@ -19,12 +19,15 @@ import sleep from "../sleep";
19
19
  import ConfigBase from "./ConfigBase";
20
20
  import WifiConfig from "../protocol/WifiConfig";
21
21
  import GizLog from "../GizLog";
22
+ import gizwitsSdk from "mini_program_gizwits_sdk";
23
+ import { BleHandle } from "../handler/ble";
22
24
 
23
25
  interface IArgs {
24
26
  bleDeviceId: string;
25
27
  arrayBuffer: ArrayBuffer;
26
28
  serviceUUIDSuffix?: string;
27
29
  characteristicUUIDSuffix?: string;
30
+ bleHandle: BleHandle;
28
31
  }
29
32
 
30
33
  const configAck = '0000000303000002';
@@ -34,6 +37,7 @@ export function sendBLEConfigCmd({
34
37
  arrayBuffer,
35
38
  serviceUUIDSuffix = 'abf0',
36
39
  characteristicUUIDSuffix = 'abf7',
40
+ bleHandle
37
41
  }: IArgs) {
38
42
  let sendInterval = null;
39
43
  let closeTimeout = null;
@@ -134,13 +138,15 @@ export function sendBLEConfigCmd({
134
138
  GizLog.debug('GIZ_SDK: 收到设备返回ack', hexString)
135
139
  if (hexString === configAck) {
136
140
  // 发送成功
137
- wx.offBLECharacteristicValueChange(handleBLECharacteristicValueChange);
141
+ bleHandle.removeEventListener("GizBleDeviceData", handleBLECharacteristicValueChange)
138
142
  resolve(true);
139
143
  }
140
144
  };
141
145
 
146
+ bleHandle.addEventListener("GizBleDeviceData", handleBLECharacteristicValueChange)
147
+
142
148
  // 订阅特征值变化
143
- wx.onBLECharacteristicValueChange(handleBLECharacteristicValueChange);
149
+ // wx.onBLECharacteristicValueChange(handleBLECharacteristicValueChange);
144
150
 
145
151
  GizLog.debug(
146
152
  'GIZ_SDK: on notifyBLECharacteristicValueChange success',
@@ -202,6 +208,12 @@ interface ISetDeviceOnboardingDeployProps {
202
208
 
203
209
 
204
210
  class BLEConfig extends ConfigBase {
211
+ bleHandle: BleHandle;
212
+
213
+ constructor(ssid: string, password: string, specialProductKeys: string[], specialProductKeySecrets: string[],bleHandle: BleHandle) {
214
+ super(ssid,password,specialProductKeys,specialProductKeySecrets)
215
+ this.bleHandle = bleHandle;
216
+ }
205
217
  destroy = () => {
206
218
  this.cleanTimeout();
207
219
  }
@@ -389,6 +401,7 @@ class BLEConfig extends ConfigBase {
389
401
  (await sendBLEConfigCmd({
390
402
  bleDeviceId: bleDevice.deviceId,
391
403
  arrayBuffer: uint8Array.buffer,
404
+ bleHandle: this.bleHandle
392
405
  }));
393
406
 
394
407
  if (!success) {