Add native local network integrations

This commit is contained in:
2026-05-05 18:45:46 +00:00
parent 282283d344
commit cfab8c593e
70 changed files with 9688 additions and 176 deletions
@@ -0,0 +1,45 @@
import { expect, tap } from '@git.zone/tstest/tapbundle';
import { createBluetoothLeTrackerDiscoveryDescriptor } from '../../ts/integrations/bluetooth_le_tracker/index.js';
tap.test('matches Bluetooth LE advertisements and manual BLE entries', async () => {
const descriptor = createBluetoothLeTrackerDiscoveryDescriptor();
const bluetoothMatcher = descriptor.getMatchers().find((matcherArg) => matcherArg.id === 'bluetooth-le-tracker-bluetooth-match');
const manualMatcher = descriptor.getMatchers().find((matcherArg) => matcherArg.id === 'bluetooth-le-tracker-manual-match');
const bluetoothResult = await bluetoothMatcher!.matches({
address: 'AA-BB-CC-DD-EE-FF',
name: 'Backpack Tag\x00',
rssi: -61,
connectable: false,
serviceUuids: ['0000180f-0000-1000-8000-00805f9b34fb'],
manufacturerData: { '76': [1, 2, 3] },
}, {});
const manualResult = await manualMatcher!.matches({
mac: 'BLE_11:22:33:44:55:66',
name: 'Keys Beacon',
track: true,
trackBattery: true,
}, {});
expect(bluetoothResult.matched).toBeTrue();
expect(bluetoothResult.normalizedDeviceId).toEqual('aa:bb:cc:dd:ee:ff');
expect(bluetoothResult.candidate?.metadata?.haMac).toEqual('BLE_AA:BB:CC:DD:EE:FF');
expect(manualResult.matched).toBeTrue();
expect(manualResult.candidate?.macAddress).toEqual('11:22:33:44:55:66');
});
tap.test('validates Bluetooth LE tracker candidates', async () => {
const validator = createBluetoothLeTrackerDiscoveryDescriptor().getValidators()[0];
const result = await validator.validate({
source: 'bluetooth',
id: 'aabbccddeeff',
name: 'BLE tracker tag',
metadata: { sourceType: 'bluetooth_le' },
}, {});
expect(result.matched).toBeTrue();
expect(result.confidence).toEqual('high');
expect(result.candidate?.integrationDomain).toEqual('bluetooth_le_tracker');
});
export default tap.start();