diff --git a/CHANGELOG.md b/CHANGELOG.md index 9aa0057..76de328 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to this project will be documented in this file. +## [1.1.1] - 2023-12-03 + +- Fixes + ## [1.1.0] - 2023-12-03 - Fix the problem of connection attempts using an incorrect address type diff --git a/examples/le-discover-cache.ts b/examples/le-discover-cache.ts index 80d09c0..2d2321f 100644 --- a/examples/le-discover-cache.ts +++ b/examples/le-discover-cache.ts @@ -43,6 +43,8 @@ class App extends NbleGapCentral { }, }, }); + + this.on('error', (err) => console.log('NbleGapCentral Error:', err)); } protected async onAdvert(report: GapAdvertReport): Promise { @@ -107,7 +109,8 @@ class App extends NbleGapCentral { console.log(e); } finally { console.log('Disconnecting...'); - await this.disconnect(event.connectionHandle); + await this.disconnect(event.connectionHandle) + .catch(() => {}); } } diff --git a/package.json b/package.json index 295f9ef..1d13493 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bluetooth-hci", - "version": "1.1.0", + "version": "1.1.1", "description": "Bluetooth HCI host implementation", "main": "lib/src/index.js", "types": "lib/src/index.d.ts", diff --git a/src/gap/GapCentral.ts b/src/gap/GapCentral.ts index f175c3b..867b439 100644 --- a/src/gap/GapCentral.ts +++ b/src/gap/GapCentral.ts @@ -449,21 +449,9 @@ export class GapCentral extends EventEmitter { } private async getRemoteInfo(connComplete: LeConnectionCompleteEvent | LeEnhConnectionCompleteEvent) { - // NOTE: don't know why but sometimes first request to remote device gives no response - // so we try to read remote version information twice - // problem occurs on nRF52840 Dongle with HCI controller - const timeoutMs = connComplete.connectionIntervalMs * 10; - - let version: ReadRemoteVersionInformationCompleteEvent; - try { - version = await this.hci.readRemoteVersionInformationAwait(connComplete.connectionHandle, timeoutMs); - } catch { - version = await this.hci.readRemoteVersionInformationAwait(connComplete.connectionHandle, timeoutMs); - } - + const version = await this.hci.readRemoteVersionInformationAwait(connComplete.connectionHandle, timeoutMs); const features = await this.hci.leReadRemoteFeaturesAwait(connComplete.connectionHandle, timeoutMs); - return { version, features }; } diff --git a/src/gatt/GattClient.ts b/src/gatt/GattClient.ts index c8e5b63..06d7357 100644 --- a/src/gatt/GattClient.ts +++ b/src/gatt/GattClient.ts @@ -183,7 +183,7 @@ export class GattClient extends EventEmitter { } public async read(char: GattCharacteristic.AsObject): Promise { - const handle = char.valueHandle; + const handle = char.handle + 1; const blob = await this.att.readReq({ attributeHandle: handle }); let part = blob.attributeValue; @@ -203,12 +203,12 @@ export class GattClient extends EventEmitter { } public async write(char: GattCharacteristic.AsObject, value: Buffer): Promise { - const handle = char.valueHandle; + const handle = char.handle + 1; await this.att.writeReq({ attributeHandle: handle, attributeValue: value }); } public async writeWithoutResponse(char: GattCharacteristic.AsObject, value: Buffer): Promise { - const handle = char.valueHandle; + const handle = char.handle + 1; await this.att.writeCmd({ attributeHandle: handle, attributeValue: value }); }