@psdk/device-ble-wechat
Advanced tools
Comparing version 0.5.12 to 0.5.13
@@ -10,7 +10,2 @@ "use strict"; | ||
class WechatBleConnectedDevice { | ||
device; | ||
scpair; | ||
_connectionState; | ||
dataOfRead; | ||
notifyCallback; | ||
constructor(options) { | ||
@@ -97,2 +92,3 @@ this.device = options.device; | ||
async read(options) { | ||
var _a; | ||
if (this.dataOfRead.length > 0) { | ||
@@ -102,3 +98,3 @@ this.dataOfRead.splice(0, this.dataOfRead.length); | ||
await this.realRead(); | ||
const timeout = (options?.timeout ?? 5000); | ||
const timeout = ((_a = options === null || options === void 0 ? void 0 : options.timeout) !== null && _a !== void 0 ? _a : 5000); | ||
const startTime = +new Date(); | ||
@@ -105,0 +101,0 @@ while (true) { |
@@ -12,5 +12,2 @@ "use strict"; | ||
class WechatBleBluetooth extends device_bluetooth_traits_1.Jluetooth { | ||
options; | ||
discoveredCallback; | ||
connectedDevice; | ||
constructor(options) { | ||
@@ -36,4 +33,5 @@ super(); | ||
async connect(device, options) { | ||
var _a; | ||
if (this.isConnected()) { | ||
if (!(options?.autoSwitchDevice ?? false)) { | ||
if (!((_a = options === null || options === void 0 ? void 0 : options.autoSwitchDevice) !== null && _a !== void 0 ? _a : false)) { | ||
return this.connectedDevice; | ||
@@ -44,3 +42,3 @@ } | ||
const origin = device.origin; | ||
await this.createBLEConnection({ deviceId: origin.deviceId, timeout: options?.timeout, }); | ||
await this.createBLEConnection({ deviceId: origin.deviceId, timeout: options === null || options === void 0 ? void 0 : options.timeout, }); | ||
await await_timeout_1.default.set(500); | ||
@@ -140,6 +138,7 @@ const services = await this.getBLEDeviceServices({ deviceId: origin.deviceId }); | ||
.filter(item => { | ||
var _a, _b; | ||
const name = item.name || item.localName; | ||
if (name) | ||
return true; | ||
return this.options?.allowNoName ?? true; | ||
return (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.allowNoName) !== null && _b !== void 0 ? _b : true; | ||
}) | ||
@@ -219,2 +218,3 @@ .map(item => new device_bluetooth_traits_1.JluetoothDevice({ | ||
async findSCPair(options) { | ||
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k; | ||
// fill data | ||
@@ -230,5 +230,5 @@ const _characteristicsMap = new Map(); | ||
// use special first | ||
if (this.options?.allowedWriteCharacteristic && this.options?.allowedReadCharacteristic) { | ||
if (((_a = this.options) === null || _a === void 0 ? void 0 : _a.allowedWriteCharacteristic) && ((_b = this.options) === null || _b === void 0 ? void 0 : _b.allowedReadCharacteristic)) { | ||
for (const service of options.services) { | ||
if (!device_bluetooth_traits_1.TBluetoothHelpers.isAllowServices(service.uuid, this.options?.allowServices)) { | ||
if (!device_bluetooth_traits_1.TBluetoothHelpers.isAllowServices(service.uuid, (_c = this.options) === null || _c === void 0 ? void 0 : _c.allowServices)) { | ||
continue; | ||
@@ -240,3 +240,3 @@ } | ||
for (const characteristic of characteristics) { | ||
if (this.options?.allowedWriteCharacteristic.toLowerCase() == characteristic.uuid.toLowerCase()) { | ||
if (((_d = this.options) === null || _d === void 0 ? void 0 : _d.allowedWriteCharacteristic.toLowerCase()) == characteristic.uuid.toLowerCase()) { | ||
writeCharacteristic = characteristic; | ||
@@ -246,3 +246,3 @@ } | ||
for (const characteristic of characteristics) { | ||
if (this.options?.allowedReadCharacteristic.toLowerCase() == characteristic.uuid.toLowerCase()) { | ||
if (((_e = this.options) === null || _e === void 0 ? void 0 : _e.allowedReadCharacteristic.toLowerCase()) == characteristic.uuid.toLowerCase()) { | ||
readCharacteristic = characteristic; | ||
@@ -262,3 +262,3 @@ } | ||
for (const service of options.services) { | ||
if (!device_bluetooth_traits_1.TBluetoothHelpers.isAllowServices(service.uuid, this.options?.allowServices)) { | ||
if (!device_bluetooth_traits_1.TBluetoothHelpers.isAllowServices(service.uuid, (_f = this.options) === null || _f === void 0 ? void 0 : _f.allowServices)) { | ||
continue; | ||
@@ -282,6 +282,6 @@ } | ||
} | ||
if (this.options?.allowDetectDifferentCharacteristic ?? true) { | ||
if ((_h = (_g = this.options) === null || _g === void 0 ? void 0 : _g.allowDetectDifferentCharacteristic) !== null && _h !== void 0 ? _h : true) { | ||
// choose different characteristic with write and read properties | ||
for (const service of options.services) { | ||
if (!device_bluetooth_traits_1.TBluetoothHelpers.isAllowServices(service.uuid, this.options?.allowServices)) { | ||
if (!device_bluetooth_traits_1.TBluetoothHelpers.isAllowServices(service.uuid, (_j = this.options) === null || _j === void 0 ? void 0 : _j.allowServices)) { | ||
continue; | ||
@@ -311,3 +311,3 @@ } | ||
for (const service of options.services) { | ||
if (!device_bluetooth_traits_1.TBluetoothHelpers.isAllowServices(service.uuid, this.options?.allowServices)) { | ||
if (!device_bluetooth_traits_1.TBluetoothHelpers.isAllowServices(service.uuid, (_k = this.options) === null || _k === void 0 ? void 0 : _k.allowServices)) { | ||
continue; | ||
@@ -314,0 +314,0 @@ } |
{ | ||
"name": "@psdk/device-ble-wechat", | ||
"version": "0.5.12", | ||
"version": "0.5.13", | ||
"description": "psdk", | ||
@@ -29,4 +29,4 @@ "main": "build/index.js", | ||
"dependencies": { | ||
"@psdk/device-bluetooth-traits": "0.5.12", | ||
"@psdk/frame-father": "0.5.12", | ||
"@psdk/device-bluetooth-traits": "0.5.13", | ||
"@psdk/frame-father": "0.5.13", | ||
"await-timeout": "^1.1.1" | ||
@@ -39,3 +39,3 @@ }, | ||
], | ||
"gitHead": "bb30f7d6c858f5fd7afa620cae11b594fe4aa9f7" | ||
"gitHead": "79e71d930b142e5849dd7d6061562530060ead31" | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
1462206
2673
+ Added@psdk/device-bluetooth-traits@0.5.13(transitive)
+ Added@psdk/frame-father@0.5.13(transitive)
- Removed@psdk/device-bluetooth-traits@0.5.12(transitive)
- Removed@psdk/frame-father@0.5.12(transitive)
Updated@psdk/frame-father@0.5.13