@@ -17,7 +17,7 @@ class BoardStateProvider extends ChangeNotifier {
1717 bool pslabIsConnected = false ;
1818 bool hasPermission = false ;
1919 late ScienceLabCommon scienceLabCommon;
20- String pslabVersionID = 'Not Connected ' ;
20+ String pslabVersionID = '' ;
2121 String pslabVersionIDV6 = 'PSLab V6' ;
2222 String pslabVersionIDV5 = 'PSLab V5' ;
2323 int pslabVersion = 0 ;
@@ -44,37 +44,35 @@ class BoardStateProvider extends ChangeNotifier {
4444
4545 if (configProvider.config.autoStart) {
4646 if (! kIsWeb && defaultTargetPlatform == TargetPlatform .android) {
47- UsbSerial .usbEventStream? .listen (
48- (UsbEvent usbEvent) async {
49- if (usbEvent.event == UsbEvent .ACTION_USB_ATTACHED ) {
50- if (_isProcessing) return ;
51- _isProcessing = true ;
52- if (! scienceLabCommon.isConnected () &&
53- await attemptToConnectPSLab ()) {
54- pslabIsConnected = await scienceLabCommon.openDevice ();
55- await setPSLabVersionIDs ();
56- await fetchFirmwareVersion ();
57- _isProcessing = false ;
58- }
59- } else if (usbEvent.event == UsbEvent .ACTION_USB_DETACHED &&
60- ! scienceLabCommon.isWiFiConnected ()) {
61- scienceLabCommon.setConnected (false );
62- pslabIsConnected = false ;
63- pslabVersionID = 'Not Connected' ;
64- notifyListeners ();
47+ UsbSerial .usbEventStream? .listen ((UsbEvent usbEvent) async {
48+ if (usbEvent.event == UsbEvent .ACTION_USB_ATTACHED ) {
49+ if (_isProcessing) return ;
50+ _isProcessing = true ;
51+ if (! scienceLabCommon.isConnected () &&
52+ await attemptToConnectPSLab ()) {
53+ pslabIsConnected = await scienceLabCommon.openDevice ();
54+ await setPSLabVersionIDs ();
55+ await fetchFirmwareVersion ();
56+ _isProcessing = false ;
6557 }
66- },
67- );
58+ } else if (usbEvent.event == UsbEvent .ACTION_USB_DETACHED &&
59+ ! scienceLabCommon.isWiFiConnected ()) {
60+ scienceLabCommon.setConnected (false );
61+ pslabIsConnected = false ;
62+ pslabVersionID = appLocalizations.notConnected;
63+ notifyListeners ();
64+ }
65+ });
6866 }
6967 }
7068
71- Connectivity ()
72- .onConnectivityChanged
73- . listen (( List < ConnectivityResult > results ) {
69+ Connectivity ().onConnectivityChanged. listen ((
70+ List < ConnectivityResult > results,
71+ ) {
7472 if (results.contains (ConnectivityResult .none)) {
7573 scienceLabCommon.setWiFiConnected (false );
7674 pslabIsConnected = false ;
77- pslabVersionID = 'Not Connected' ;
75+ pslabVersionID = appLocalizations.notConnected ;
7876 notifyListeners ();
7977 }
8078 });
@@ -100,8 +98,10 @@ class BoardStateProvider extends ChangeNotifier {
10098
10199 Future <void > fetchFirmwareVersion () async {
102100 if (getIt.get <ScienceLab >().isConnected ()) {
103- pslabFirmwareVersion =
104- await getIt.get <ScienceLab >().mPacketHandler.getFirmwareVersion ();
101+ pslabFirmwareVersion = await getIt
102+ .get <ScienceLab >()
103+ .mPacketHandler
104+ .getFirmwareVersion ();
105105 }
106106 if (pslabFirmwareVersion < 3 && pslabFirmwareVersion != 0 ) {
107107 legacyFirmwareNotifier.value = "LegacyFirmwareDetected" ;
0 commit comments