@psdk/ohos-bluetooth-le
Advanced tools
Comparing version 0.5.20 to 0.5.21
// @ts-nocheck | ||
import { CollectionKit, ConnectionState } from "@psdk/frame-father"; | ||
import Timeout from 'await-timeout'; | ||
import ble from '@ohos.bluetooth.ble'; | ||
@@ -74,4 +75,20 @@ import constant from '@ohos.bluetooth.constant'; | ||
} | ||
read(options) { | ||
return this.dataOfRead.pop(); | ||
async read(options) { | ||
if (this.dataOfRead.length > 0) { | ||
this.dataOfRead.splice(0, this.dataOfRead.length); | ||
} | ||
const timeout = (options?.timeout ?? 5000); | ||
const startTime = +new Date(); | ||
while (true) { | ||
const now = +new Date(); | ||
if (now - startTime > timeout) { | ||
return new Uint8Array([]); | ||
} | ||
if (this.dataOfRead.length == 0) { | ||
await Timeout.set(100); | ||
continue; | ||
} | ||
const data = this.dataOfRead.pop(); | ||
return new Uint8Array(data); | ||
} | ||
} | ||
@@ -78,0 +95,0 @@ async write(data) { |
{ | ||
"name": "@psdk/ohos-bluetooth-le", | ||
"version": "0.5.20", | ||
"version": "0.5.21", | ||
"description": "psdk - ohos bluetooth le device support", | ||
@@ -27,4 +27,4 @@ "main": "build/index.js", | ||
"dependencies": { | ||
"@psdk/device-bluetooth-traits": "0.5.20", | ||
"@psdk/frame-father": "0.5.20", | ||
"@psdk/device-bluetooth-traits": "0.5.21", | ||
"@psdk/frame-father": "0.5.21", | ||
"await-timeout": "^1.1.1" | ||
@@ -37,3 +37,3 @@ }, | ||
], | ||
"gitHead": "da9fa7627da04e3d4f3794f51b3c93a6626bdd9d" | ||
"gitHead": "1746a624a1de144d6a7c134b5b07c20e93e004bc" | ||
} |
Sorry, the diff of this file is not supported yet
18030
371
+ Added@psdk/device-bluetooth-traits@0.5.21(transitive)
+ Added@psdk/frame-father@0.5.21(transitive)
- Removed@psdk/device-bluetooth-traits@0.5.20(transitive)
- Removed@psdk/frame-father@0.5.20(transitive)
Updated@psdk/frame-father@0.5.21