@ -143,7 +143,7 @@ class MeshCoreConnector extends ChangeNotifier {
MeshCoreTransportType _activeTransport = MeshCoreTransportType . bluetooth ;
final List < ScanResult > _scanResults = [ ] ;
final List < ScanResult > _ linuxS ystemScanResults = [ ] ;
final List < ScanResult > _ s ystemScanResults = [ ] ;
final List < Contact > _contacts = [ ] ;
final List < Contact > _discoveredContacts = [ ] ;
final List < Channel > _channels = [ ] ;
@ -1362,7 +1362,7 @@ class MeshCoreConnector extends ChangeNotifier {
if ( _state = = MeshCoreConnectionState . scanning ) return ;
_scanResults . clear ( ) ;
_ linuxS ystemScanResults. clear ( ) ;
_ s ystemScanResults. clear ( ) ;
_setState ( MeshCoreConnectionState . scanning ) ;
/ / Ensure any previous scan is fully stopped . Guard with isScanningNow to
@ -1401,15 +1401,19 @@ class MeshCoreConnector extends ChangeNotifier {
await Future . delayed ( const Duration ( milliseconds: 300 ) ) ;
}
if ( PlatformInfo . isLinux ) {
await _loadLinuxSystemDevicesForScan ( ) ;
/ / Surface radios already connected to the OS — by us or by another app such
/ / as MeshCore — so we can attach to them . A connected BLE radio stops
/ / advertising , so a scan alone never finds it ; systemDevices does . Supported
/ / on every native platform ( Android / iOS / macOS / Linux ) , not web .
if ( ! PlatformInfo . isWeb ) {
await _loadSystemDevicesForScan ( ) ;
}
_scanSubscription = FlutterBluePlus . scanResults . listen ( ( results ) {
_scanResults
. . clear ( )
. . addAll ( results ) ;
_merge Linux SystemScanResults( ) ;
_merge SystemScanResults( ) ;
notifyListeners ( ) ;
} ) ;
@ -1430,12 +1434,12 @@ class MeshCoreConnector extends ChangeNotifier {
await stopScan ( ) ;
}
Future < void > _load Linux SystemDevicesForScan( ) async {
Future < void > _load SystemDevicesForScan( ) async {
try {
final systemDevices = await FlutterBluePlus . systemDevices ( [
Guid ( MeshCoreUuids . service ) ,
] ) ;
_ linuxS ystemScanResults
_ s ystemScanResults
. . clear ( )
. . addAll (
systemDevices
@ -1461,24 +1465,24 @@ class MeshCoreConnector extends ChangeNotifier {
) ,
) ,
) ;
_merge Linux SystemScanResults( ) ;
_merge SystemScanResults( ) ;
notifyListeners ( ) ;
} catch ( error ) {
_appDebugLogService ? . warn (
' Failed loading Linux paired/ system BLE devices: $ error ' ,
' Failed loading system BLE devices: $ error ' ,
tag: ' BLE Scan ' ,
) ;
}
}
void _merge Linux SystemScanResults( ) {
if ( ! PlatformInfo . isLinux | | _linuxS ystemScanResults. isEmpty ) {
void _merge SystemScanResults( ) {
if ( _s ystemScanResults. isEmpty ) {
return ;
}
final existingIds = _scanResults
. map ( ( result ) = > result . device . remoteId . str )
. toSet ( ) ;
for ( final result in _ linuxS ystemScanResults) {
for ( final result in _ s ystemScanResults) {
if ( existingIds . contains ( result . device . remoteId . str ) ) {
continue ;
}