@psdk/device-ble-taro 0.2.57 → 0.2.58

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.
@@ -5,10 +5,12 @@ export declare class TaroBleConnectedDevice implements ConnectedDevice {
5
5
  private scpair;
6
6
  private _connectionState;
7
7
  private dataOfRead;
8
+ private notifyCallback?;
8
9
  constructor(options: {
9
10
  device: Taro.onBluetoothDeviceFound.CallbackResultBlueToothDevice;
10
11
  scpair: ServiceCharacteristicPair;
11
12
  });
13
+ notify(callback: (value: Taro.onBLECharacteristicValueChange.CallbackResult) => Promise<void>): void;
12
14
  private doListen;
13
15
  private realRead;
14
16
  connectionState(): ConnectionState;
@@ -1 +1 @@
1
- {"version":3,"file":"connected.d.ts","sourceRoot":"","sources":["../src/connected.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAE,eAAe,EAAE,WAAW,EAAC,MAAM,oBAAoB,CAAC;AAEjF,OAAO,IAAI,MAAM,cAAc,CAAC;AAEhC,qBAAa,sBAAuB,YAAW,eAAe;IAC5D,OAAO,CAAC,MAAM,CAA4D;IAC1E,OAAO,CAAC,MAAM,CAA4B;IAE1C,OAAO,CAAC,gBAAgB,CAAkB;IAC1C,OAAO,CAAC,UAAU,CAA4D;gBAE3D,OAAO,EAAE;QAC1B,MAAM,EAAE,IAAI,CAAC,sBAAsB,CAAC,6BAA6B,CAAC;QAClE,MAAM,EAAE,yBAAyB,CAAC;KACnC;IAQD,OAAO,CAAC,QAAQ;YAkBF,QAAQ;IAuBtB,eAAe,IAAI,eAAe;IAIlC,UAAU,IAAI,MAAM;IAId,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAejC,OAAO,IAAI,OAAO;IAIZ,IAAI,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC;IAsBhD,KAAK,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAqB5C,KAAK,I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AE,IAAI,CAAC,oBAAoB,CAAC,UAAU,CAAC;IAC9C,KAAK,EAAE,IAAI,CAAC,2BAA2B,CAAC,iBAAiB,CAAC;IAC1D,IAAI,CAAC,EAAE,IAAI,CAAC,2BAA2B,CAAC,iBAAiB,CAAC;CAC3D"}
@@ -24,22 +24,28 @@ class TaroBleConnectedDevice {
24
24
  this.dataOfRead = [];
25
25
  this.doListen();
26
26
  }
27
+ notify(callback) {
28
+ this.notifyCallback = callback;
29
+ }
27
30
  doListen() {
28
- taro_1.default.onBLECharacteristicValueChange(value => {
29
- this.dataOfRead.push(value);
30
- });
31
+ taro_1.default.onBLECharacteristicValueChange((value) => __awaiter(this, void 0, void 0, function* () {
32
+ // this.dataOfRead.push(value)
33
+ if (this.notifyCallback) {
34
+ yield this.notifyCallback(value);
35
+ }
36
+ }));
31
37
  taro_1.default.onBLEConnectionStateChange(value => {
32
38
  this._connectionState = value.connected ? frame_father_1.ConnectionState.CONNECTED : frame_father_1.ConnectionState.DISCONNECTED;
33
39
  });
34
- // Taro.notifyBLECharacteristicValueChange({
35
- // deviceId: this.device.deviceId,
36
- // serviceId: this.readPair.service.uuid,
37
- // characteristicId: this.readPair.characteristic.uuid,
38
- // state: true,
39
- // success: result => console.log(result),
40
- // // @ts-ignore
41
- // fail: (e) => console.error(e),
42
- // });
40
+ taro_1.default.notifyBLECharacteristicValueChange({
41
+ deviceId: this.device.deviceId,
42
+ serviceId: this.scpair.service.uuid,
43
+ characteristicId: this.scpair.read.uuid,
44
+ state: true,
45
+ success: result => console.log(result),
46
+ // @ts-ignore
47
+ fail: (e) => console.error(e),
48
+ });
43
49
  }
44
50
  realRead() {
45
51
  return __awaiter(this, void 0, void 0, function* () {
package/build/provider.js CHANGED
@@ -264,7 +264,7 @@ class TaroBleBluetooth extends device_bluetooth_traits_1.Jluetooth {
264
264
  return {
265
265
  service,
266
266
  write: characteristic,
267
- read: properties.read ? characteristic : null,
267
+ read: properties.notify ? characteristic : null,
268
268
  };
269
269
  }
270
270
  }
@@ -280,7 +280,7 @@ class TaroBleBluetooth extends device_bluetooth_traits_1.Jluetooth {
280
280
  const pickedCharacteristic = characteristics.find(characteristic => {
281
281
  const properties = characteristic.properties;
282
282
  // @ts-ignore
283
- return properties.write && (properties.read);
283
+ return properties.write && (properties.notify);
284
284
  });
285
285
  if (pickedCharacteristic) {
286
286
  return {
@@ -304,7 +304,7 @@ class TaroBleBluetooth extends device_bluetooth_traits_1.Jluetooth {
304
304
  });
305
305
  const readCharacteristic = characteristics.find(characteristic => {
306
306
  const properties = characteristic.properties;
307
- return (properties.read);
307
+ return (properties.notify);
308
308
  });
309
309
  if (writeCharacteristic && readCharacteristic) {
310
310
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@psdk/device-ble-taro",
3
- "version": "0.2.57",
3
+ "version": "0.2.58",
4
4
  "description": "psdk",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -46,13 +46,13 @@
46
46
  "webpack-cli": "^4.9.2"
47
47
  },
48
48
  "dependencies": {
49
- "@psdk/device-bluetooth-traits": "0.2.57",
50
- "@psdk/frame-father": "0.2.57",
49
+ "@psdk/device-bluetooth-traits": "0.2.58",
50
+ "@psdk/frame-father": "0.2.58",
51
51
  "await-timeout": "^1.1.1"
52
52
  },
53
53
  "files": [
54
54
  "build",
55
55
  "!build/browser/psdk*"
56
56
  ],
57
- "gitHead": "9f9f4a756c4cddbfd4a81300ea7fd66a4c28b0fb"
57
+ "gitHead": "0af603c67f29dde30d53226ba732565150126a8d"
58
58
  }