diff --git a/src/integrations/bluetooth-classic/bluetooth-classic.service.spec.ts b/src/integrations/bluetooth-classic/bluetooth-classic.service.spec.ts index 9d8f71b9..5a1ea68b 100644 --- a/src/integrations/bluetooth-classic/bluetooth-classic.service.spec.ts +++ b/src/integrations/bluetooth-classic/bluetooth-classic.service.spec.ts @@ -195,6 +195,20 @@ Requesting information ... }); }); + it('should return the address as device name if none was found', async () => { + jest.spyOn(util, 'promisify').mockImplementation(() => { + return jest.fn().mockResolvedValue({ + stdout: 'IO error' + }); + }); + + expect(await service.inquireDeviceInfo('F0:99:B6:12:34:AB')).toStrictEqual({ + address: 'F0:99:B6:12:34:AB', + name: 'F0:99:B6:12:34:AB', + manufacturer: undefined + }); + }); + it('should return barebones information if request fails', async () => { jest.spyOn(util, 'promisify').mockImplementation(() => { return jest.fn().mockRejectedValue({ stderr: 'I/O Error' }); diff --git a/src/integrations/bluetooth-classic/bluetooth-classic.service.ts b/src/integrations/bluetooth-classic/bluetooth-classic.service.ts index fbc2ec9e..601028d6 100644 --- a/src/integrations/bluetooth-classic/bluetooth-classic.service.ts +++ b/src/integrations/bluetooth-classic/bluetooth-classic.service.ts @@ -216,8 +216,8 @@ export class BluetoothClassicService extends KalmanFilterable(Object, 1.4, 1) return { address, - name: nameMatches[1], - manufacturer: manufacturerMatches[1] + name: nameMatches ? nameMatches[1] : address, + manufacturer: manufacturerMatches ? manufacturerMatches[1] : undefined }; } catch (e) { this.logger.error(e.message, e.stack);