Skip to content

Commit

Permalink
fix(bluetooth-classic): fix health indicator when device not in reach
Browse files Browse the repository at this point in the history
A low scan time limit previously caused the health indicator to fail
wrongly when the scanned device was not in reach.

Closes #284
  • Loading branch information
mKeRix committed Oct 4, 2020
1 parent 32f34ad commit a23065f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -778,4 +778,14 @@ Requesting information ...
expect(healthIndicator.reportSuccess).not.toHaveBeenCalled();
expect(healthIndicator.reportError).not.toHaveBeenCalled();
});

it('should not report an error if the scan was stopped due to low time limits', async () => {
mockExec.mockRejectedValue({
message: 'killed',
signal: 'SIGKILL',
});
await service.inquireRssi('');

expect(healthIndicator.reportError).not.toHaveBeenCalled();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ import { BluetoothClassicHealthIndicator } from './bluetooth-classic.health';
const execPromise = util.promisify(exec);

@Injectable()
export class BluetoothClassicService extends KalmanFilterable(Object, 1.4, 1)
export class BluetoothClassicService
extends KalmanFilterable(Object, 1.4, 1)
implements OnModuleInit, OnApplicationBootstrap {
private readonly config: BluetoothClassicConfig;
private rotationOffset = 0;
Expand Down Expand Up @@ -225,8 +226,12 @@ export class BluetoothClassicService extends KalmanFilterable(Object, 1.4, 1)
this.logger.debug(
`Query of ${address} reached scan time limit, resetting hci${this.config.hciDeviceId}`
);
this.healthIndicator.reportError();
this.resetHciDevice();

// when not reachable a scan runs for 6s, so lower time limits might not be an error
if (this.config.scanTimeLimit >= 6) {
this.healthIndicator.reportError();
}
} else if (
e.message?.includes('Input/output') ||
e.message?.includes('I/O')
Expand Down

0 comments on commit a23065f

Please sign in to comment.