fix(#807): honest systemDevices merge + Windows live-scan filter
#570 option A (owner-approved). The systemDevices merge is the #49 coexistence door (attach to a radio another app connected), so it keeps every OS-connected device rather than dropping by name, which would hide a never-handshaked or renamed radio. Changes: - stop fabricating serviceUuids: [NUS] on synthesized entries (it lied and defeated downstream service filtering); rssi 0 is now documented as an OS-connected sentinel, exposed via isSystemConnected() for the UI (#809) to badge instead of showing a signal bar. - track system-connected ids; honor a _suppressedSystemDeviceIds set that the negative-memory store (#808) will populate. - Windows-only live-scan name-prefix filter: the vendored WinRT watcher ignores withServices and forwards every advertiser, so non-radios are filtered in the live path on Windows (Android/iOS already OS-filter; web uses the chooser). The plugin-level service filter was reverted (Gemini review: rests on an unverified adv assumption). - matchesDeviceNamePrefix is now case-insensitive (review) and gained the Offband- prefix (its own radios must not be filtered). Parent #806. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>pull/1355/head
parent
ce8da46764
commit
4df0c477a3
@ -0,0 +1,67 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:meshcore_open/connector/meshcore_uuids.dart';
|
||||
|
||||
/// #570: the scanner filters non-radio BLE devices (paired watches, PCs) out
|
||||
/// of the list by name prefix, because systemDevices and the Windows scan
|
||||
/// carry no usable service filter. These cases pin the prefix set and the
|
||||
/// matcher's exact-prefix (not substring) behavior.
|
||||
void main() {
|
||||
group('MeshCoreUuids.matchesDeviceNamePrefix (#570)', () {
|
||||
test('accepts known radio name prefixes', () {
|
||||
const radios = [
|
||||
'MeshCore-WSMJ898',
|
||||
'Offband-MC-Strycher-R1W',
|
||||
'Whisper-abcd',
|
||||
'WisCore-1234',
|
||||
'Seeed XIAO',
|
||||
'Lilygo T-Beam',
|
||||
'HT-n5262',
|
||||
'LowMesh_MC_01',
|
||||
'NRF52-DK',
|
||||
];
|
||||
for (final name in radios) {
|
||||
expect(
|
||||
MeshCoreUuids.matchesDeviceNamePrefix(name),
|
||||
isTrue,
|
||||
reason: '$name should be recognized as a radio',
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test('rejects non-radio device names', () {
|
||||
const notRadios = [
|
||||
'Galaxy Watch6',
|
||||
"Ben's MacBook Pro",
|
||||
'Pixel Buds',
|
||||
'Unknown Device',
|
||||
'', // empty cached name
|
||||
'nimble', // stale cached name seen in #189
|
||||
];
|
||||
for (final name in notRadios) {
|
||||
expect(
|
||||
MeshCoreUuids.matchesDeviceNamePrefix(name),
|
||||
isFalse,
|
||||
reason: '$name should not be recognized as a radio',
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test('matches on prefix, not substring', () {
|
||||
// A name that merely contains a prefix mid-string is not a radio.
|
||||
expect(
|
||||
MeshCoreUuids.matchesDeviceNamePrefix('My MeshCore-ish toy'),
|
||||
isFalse,
|
||||
);
|
||||
});
|
||||
|
||||
test('is case-insensitive', () {
|
||||
expect(MeshCoreUuids.matchesDeviceNamePrefix('meshcore-abcd'), isTrue);
|
||||
expect(MeshCoreUuids.matchesDeviceNamePrefix('OFFBAND-1234'), isTrue);
|
||||
expect(MeshCoreUuids.matchesDeviceNamePrefix('seeed xiao'), isTrue);
|
||||
});
|
||||
|
||||
test('Offband- is included (its own radios must not be filtered out)', () {
|
||||
expect(MeshCoreUuids.deviceNamePrefixes, contains('Offband-'));
|
||||
});
|
||||
});
|
||||
}
|
||||
Loading…
Reference in new issue