Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rosek86 committed Dec 3, 2023
1 parent 981b4ab commit e8f84f7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
5 changes: 4 additions & 1 deletion examples/le-discover-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ class App extends NbleGapCentral {
},
},
});

this.on('error', (err) => console.log('NbleGapCentral Error:', err));
}

protected async onAdvert(report: GapAdvertReport): Promise<void> {
Expand Down Expand Up @@ -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(() => {});
}
}

Expand Down
14 changes: 1 addition & 13 deletions src/gap/GapCentral.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
}

Expand Down

0 comments on commit e8f84f7

Please sign in to comment.