@psdk/device-ble-taro
Advanced tools
Comparing version 0.2.57 to 0.2.58
@@ -8,2 +8,3 @@ import { ConnectedDevice, ConnectionState, ReadOptions } from "@psdk/frame-father"; | ||
private dataOfRead; | ||
private notifyCallback?; | ||
constructor(options: { | ||
@@ -13,2 +14,3 @@ device: Taro.onBluetoothDeviceFound.CallbackResultBlueToothDevice; | ||
}); | ||
notify(callback: (value: Taro.onBLECharacteristicValueChange.CallbackResult) => Promise<void>): void; | ||
private doListen; | ||
@@ -15,0 +17,0 @@ private realRead; |
@@ -27,18 +27,24 @@ "use strict"; | ||
} | ||
notify(callback) { | ||
this.notifyCallback = callback; | ||
} | ||
doListen() { | ||
taro_1.default.onBLECharacteristicValueChange(value => { | ||
this.dataOfRead.push(value); | ||
}); | ||
taro_1.default.onBLECharacteristicValueChange((value) => __awaiter(this, void 0, void 0, function* () { | ||
// this.dataOfRead.push(value) | ||
if (this.notifyCallback) { | ||
yield this.notifyCallback(value); | ||
} | ||
})); | ||
taro_1.default.onBLEConnectionStateChange(value => { | ||
this._connectionState = value.connected ? frame_father_1.ConnectionState.CONNECTED : frame_father_1.ConnectionState.DISCONNECTED; | ||
}); | ||
// Taro.notifyBLECharacteristicValueChange({ | ||
// deviceId: this.device.deviceId, | ||
// serviceId: this.readPair.service.uuid, | ||
// characteristicId: this.readPair.characteristic.uuid, | ||
// state: true, | ||
// success: result => console.log(result), | ||
// // @ts-ignore | ||
// fail: (e) => console.error(e), | ||
// }); | ||
taro_1.default.notifyBLECharacteristicValueChange({ | ||
deviceId: this.device.deviceId, | ||
serviceId: this.scpair.service.uuid, | ||
characteristicId: this.scpair.read.uuid, | ||
state: true, | ||
success: result => console.log(result), | ||
// @ts-ignore | ||
fail: (e) => console.error(e), | ||
}); | ||
} | ||
@@ -45,0 +51,0 @@ realRead() { |
@@ -267,3 +267,3 @@ "use strict"; | ||
write: characteristic, | ||
read: properties.read ? characteristic : null, | ||
read: properties.notify ? characteristic : null, | ||
}; | ||
@@ -284,3 +284,3 @@ } | ||
// @ts-ignore | ||
return properties.write && (properties.read); | ||
return properties.write && (properties.notify); | ||
}); | ||
@@ -309,3 +309,3 @@ if (pickedCharacteristic) { | ||
const properties = characteristic.properties; | ||
return (properties.read); | ||
return (properties.notify); | ||
}); | ||
@@ -312,0 +312,0 @@ if (writeCharacteristic && readCharacteristic) { |
{ | ||
"name": "@psdk/device-ble-taro", | ||
"version": "0.2.57", | ||
"version": "0.2.58", | ||
"description": "psdk", | ||
@@ -49,4 +49,4 @@ "main": "build/index.js", | ||
"dependencies": { | ||
"@psdk/device-bluetooth-traits": "0.2.57", | ||
"@psdk/frame-father": "0.2.57", | ||
"@psdk/device-bluetooth-traits": "0.2.58", | ||
"@psdk/frame-father": "0.2.58", | ||
"await-timeout": "^1.1.1" | ||
@@ -58,3 +58,3 @@ }, | ||
], | ||
"gitHead": "9f9f4a756c4cddbfd4a81300ea7fd66a4c28b0fb" | ||
"gitHead": "0af603c67f29dde30d53226ba732565150126a8d" | ||
} |
Sorry, the diff of this file is not supported yet
28275
561
+ Added@psdk/device-bluetooth-traits@0.2.58(transitive)
+ Added@psdk/frame-father@0.2.58(transitive)
- Removed@psdk/device-bluetooth-traits@0.2.57(transitive)
- Removed@psdk/frame-father@0.2.57(transitive)
Updated@psdk/frame-father@0.2.58