Skip to content

Commit

Permalink
fix(bluetooth-classic): ignore requests for undefined addresses
Browse files Browse the repository at this point in the history
Closes #136
  • Loading branch information
mKeRix committed Mar 22, 2020
1 parent c5b181f commit ed733a3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Expand Up @@ -329,6 +329,22 @@ Requesting information ...
expect(handleSpy.mock.calls[1][0].device).toEqual(device);
});

it('should not trigger Bluetooth commands for undefined addresses', async () => {
jest.spyOn(service, 'shouldInquire').mockReturnValue(true);
const inquireSpy = jest.spyOn(service, 'inquireRssi');

await service.handleRssiRequest(undefined);
expect(inquireSpy).not.toHaveBeenCalled();
});

it('should not trigger Bluetooth commands for empty addresses', async () => {
jest.spyOn(service, 'shouldInquire').mockReturnValue(true);
const inquireSpy = jest.spyOn(service, 'inquireRssi');

await service.handleRssiRequest('');
expect(inquireSpy).not.toHaveBeenCalled();
});

it('should ignore RSSI requests of inquiries are disabled', () => {
jest.spyOn(service, 'shouldInquire').mockReturnValue(false);
const handleRssiMock = jest
Expand Down
Expand Up @@ -90,6 +90,11 @@ export class BluetoothClassicService extends KalmanFilterable(Object, 1.4, 1)
* @param address - Bluetooth MAC address
*/
async handleRssiRequest(address: string): Promise<void> {
if (_.isEmpty(address)) {
this.logger.error('RSSI update for empty address requested');
return;
}

if (this.shouldInquire()) {
let rssi = await this.inquireRssi(address);

Expand Down

0 comments on commit ed733a3

Please sign in to comment.