From e8f84f79449091a2f224f5a941db7e743be13ef2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Rosi=C5=84ski?= Date: Sun, 3 Dec 2023 20:34:52 +0100 Subject: [PATCH] fixes --- examples/le-discover-cache.ts | 5 ++++- src/gap/GapCentral.ts | 14 +------------- 2 files changed, 5 insertions(+), 14 deletions(-) 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/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 }; }