Skip to content

Commit

Permalink
fix: Support multiple hci socket implementations
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco Crespi committed May 6, 2021
1 parent 1c06ad8 commit 070f4c5
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/bindings/hci/misc/Hci.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 14 additions & 1 deletion lib/bindings/hci/misc/Hci.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/bindings/hci/misc/Hci.js.map

Large diffs are not rendered by default.

17 changes: 16 additions & 1 deletion src/bindings/hci/misc/Hci.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,22 @@ export class Hci extends TypedEmitter<HciEvents> {
}

private static createSocket() {
return new (require(`@modum-io/bluetooth-hci-socket`))();
let Socket;
try {
Socket = require(`@modum-io/bluetooth-hci-socket`);
} catch {
try {
Socket = require(`@abandonware/bluetooth-hci-socket`);
} catch {}
}

if (!Socket) {
throw new Error(
`Could not find any socket implementations. Please install @modum-io/bluetooth-hci-socket or @abandonware/bluetooth-hci-socket`
);
}

return new Socket();
}

public static getDeviceList(): HciDevice[] {
Expand Down

0 comments on commit 070f4c5

Please sign in to comment.