@@ -48,33 +48,33 @@ class BoardStateProvider extends ChangeNotifier {
4848
4949 if (configProvider.config.autoStart) {
5050 if (! kIsWeb && defaultTargetPlatform == TargetPlatform .android) {
51- _usbSubscription ?? = UsbSerial .usbEventStream? .listen ((
52- UsbEvent usbEvent,
53- ) async {
54- if (usbEvent.event == UsbEvent .ACTION_USB_ATTACHED ) {
55- if (_isProcessing) return ;
56- _isProcessing = true ;
57- if (! scienceLabCommon.isConnected () &&
58- await attemptToConnectPSLab ()) {
59- pslabIsConnected = await scienceLabCommon.openDevice ();
60- await setPSLabVersionIDs ();
61- await fetchFirmwareVersion ();
62- _isProcessing = false ;
51+ _usbSubscription ?? = UsbSerial .usbEventStream? .listen (
52+ (UsbEvent usbEvent) async {
53+ if (usbEvent.event == UsbEvent .ACTION_USB_ATTACHED ) {
54+ if (_isProcessing) return ;
55+ _isProcessing = true ;
56+ if (! scienceLabCommon.isConnected () &&
57+ await attemptToConnectPSLab ()) {
58+ pslabIsConnected = await scienceLabCommon.openDevice ();
59+ await setPSLabVersionIDs ();
60+ await fetchFirmwareVersion ();
61+ _isProcessing = false ;
62+ }
63+ } else if (usbEvent.event == UsbEvent .ACTION_USB_DETACHED &&
64+ ! scienceLabCommon.isWiFiConnected ()) {
65+ scienceLabCommon.setConnected (false );
66+ pslabIsConnected = false ;
67+ pslabVersionID = 'Not Connected' ;
68+ notifyListeners ();
6369 }
64- } else if (usbEvent.event == UsbEvent .ACTION_USB_DETACHED &&
65- ! scienceLabCommon.isWiFiConnected ()) {
66- scienceLabCommon.setConnected (false );
67- pslabIsConnected = false ;
68- pslabVersionID = 'Not Connected' ;
69- notifyListeners ();
70- }
71- });
70+ },
71+ );
7272 }
7373 }
7474
75- _connectivitySubscription ?? = Connectivity ().onConnectivityChanged. listen ((
76- List < ConnectivityResult > results,
77- ) {
75+ _connectivitySubscription ?? = Connectivity ()
76+ .onConnectivityChanged
77+ . listen (( List < ConnectivityResult > results ) {
7878 if (results.contains (ConnectivityResult .none)) {
7979 scienceLabCommon.setWiFiConnected (false );
8080 pslabIsConnected = false ;
@@ -104,10 +104,8 @@ class BoardStateProvider extends ChangeNotifier {
104104
105105 Future <void > fetchFirmwareVersion () async {
106106 if (getIt.get <ScienceLab >().isConnected ()) {
107- pslabFirmwareVersion = await getIt
108- .get <ScienceLab >()
109- .mPacketHandler
110- .getFirmwareVersion ();
107+ pslabFirmwareVersion =
108+ await getIt.get <ScienceLab >().mPacketHandler.getFirmwareVersion ();
111109 }
112110 if (pslabFirmwareVersion < 3 && pslabFirmwareVersion != 0 ) {
113111 legacyFirmwareNotifier.value = "LegacyFirmwareDetected" ;
@@ -134,4 +132,4 @@ class BoardStateProvider extends ChangeNotifier {
134132 legacyFirmwareNotifier.dispose ();
135133 super .dispose ();
136134 }
137- }
135+ }
0 commit comments