Skip to content

Commit

Permalink
fix(bluetooth): attempt adapter reset on LE timeouts
Browse files Browse the repository at this point in the history
This sometimes help resolve issues around connections to BLE devices
failing.
  • Loading branch information
mKeRix committed Nov 1, 2020
1 parent 4d6fbb7 commit 386ef37
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/integrations/bluetooth/bluetooth.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ Requesting information ...
);
}).rejects.toThrow();

expect(peripheral.disconnect).toHaveBeenCalled();
expect(mockExec).toHaveBeenCalledWith(expect.stringContaining('reset'));
expect(peripheral.removeAllListeners).toHaveBeenCalled();
});

Expand Down
2 changes: 1 addition & 1 deletion src/integrations/bluetooth/bluetooth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ export class BluetoothService {
`Failed to connect to ${peripheral.address}: ${e.message}`,
e.trace
);
peripheral.disconnect();
peripheral.removeAllListeners();
await this.resetHciDevice(this.lowEnergyAdapterId);
this.unlockAdapter(this.lowEnergyAdapterId);
throw e;
}
Expand Down

0 comments on commit 386ef37

Please sign in to comment.