Fix empty channel slot handling

This commit is contained in:
Janez T
2026-03-11 15:10:57 +01:00
parent 0dfb84bf4e
commit 2d23328ad0

View File

@@ -848,10 +848,21 @@ class ConnectionProvider with ChangeNotifier {
return true; return true;
} catch (e) { } catch (e) {
debugPrint('❌ [Provider] Failed to check slot $channelIdx: $e'); debugPrint('❌ [Provider] Failed to check slot $channelIdx: $e');
if (_isEmptyChannelQueryError(e)) {
debugPrint(
' Treating slot $channelIdx as empty because the device reported it was not found',
);
return true;
}
return false; return false;
} }
} }
bool _isEmptyChannelQueryError(Object error) {
final message = error.toString().toLowerCase();
return message.contains('not found');
}
Future<int?> findNextEmptyChannelSlot() async { Future<int?> findNextEmptyChannelSlot() async {
if (!_activeService.isConnected) { if (!_activeService.isConnected) {
throw Exception('Not connected to device'); throw Exception('Not connected to device');