Skip to content

Commit 1bf07c9

Browse files
Merge branch 'flutter' into Search-bar
2 parents 8cf509b + 7c3d78d commit 1bf07c9

41 files changed

Lines changed: 2005 additions & 141 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

android/gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
33
zipStoreBase=GRADLE_USER_HOME
44
zipStorePath=wrapper/dists
5-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-all.zip
5+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-all.zip

android/settings.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ pluginManagement {
1818

1919
plugins {
2020
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
21-
id "com.android.application" version "8.3.1" apply false
22-
id "org.jetbrains.kotlin.android" version "1.8.22" apply false
21+
id "com.android.application" version "8.10.1" apply false
22+
id "org.jetbrains.kotlin.android" version "2.1.21" apply false
2323
}
2424

2525
include ":app"

assets/icons/ic_wifi_connected.png

23.3 KB
Loading
3.06 KB
Loading

assets/images/logo.png

4.19 KB
Loading

assets/images/phone_x_axis.png

23.1 KB
Loading

assets/images/phone_y_axis.png

17.9 KB
Loading

assets/images/phone_z_axis.png

21.4 KB
Loading

lib/communication/packet_handler.dart

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@ import 'dart:convert';
33
import 'package:flutter/foundation.dart';
44
import 'package:pslab/communication/commands_proto.dart';
55
import 'package:pslab/communication/handler/base.dart';
6+
import 'package:pslab/communication/socket_client.dart';
67
import 'package:pslab/others/logger_service.dart';
8+
import 'package:pslab/others/science_lab_common.dart';
9+
import 'package:pslab/providers/locator.dart';
710

811
class PacketHandler {
912
late Uint8List _buffer;
1013
late bool _connected;
1114
late CommunicationHandler _mCommunicationHandler;
15+
late SocketClient _socketClient;
1216
static String version = '';
1317
late CommandsProto _mCommandsProto;
1418
int _timeout = 500, versionStringLength = 8;
@@ -18,12 +22,15 @@ class PacketHandler {
1822
_timeout = timeout;
1923
_mCommandsProto = CommandsProto();
2024
_mCommunicationHandler = communicationHandler;
21-
_connected = (_mCommunicationHandler.isConnected());
25+
_socketClient = getIt.get<SocketClient>();
26+
_connected = (getIt.get<ScienceLabCommon>().isWiFiConnected() ||
27+
_mCommunicationHandler.isConnected());
2228
_buffer = Uint8List(10000);
2329
}
2430

2531
bool isConnected() {
26-
_connected = (_mCommunicationHandler.isConnected());
32+
_connected = (getIt.get<ScienceLabCommon>().isWiFiConnected() ||
33+
_mCommunicationHandler.isConnected());
2734
return _connected;
2835
}
2936

@@ -145,13 +152,17 @@ class PacketHandler {
145152
if (_mCommunicationHandler.isConnected()) {
146153
bytesRead[0] =
147154
await _mCommunicationHandler.read(_buffer, bytesToRead, _timeout);
155+
} else if (getIt.get<ScienceLabCommon>().isWiFiConnected()) {
156+
bytesRead[0] = await _socketClient.read(_buffer, bytesToRead, _timeout);
148157
}
149158
return bytesRead[0];
150159
}
151160

152161
void _commonWrite(Uint8List data) {
153162
if (_mCommunicationHandler.isConnected()) {
154163
_mCommunicationHandler.write(data, _timeout);
164+
} else if (getIt.get<ScienceLabCommon>().isWiFiConnected()) {
165+
_socketClient.write(data, _timeout);
155166
}
156167
}
157168
}

lib/communication/science_lab.dart

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ import 'package:flutter/foundation.dart';
33
import 'package:pslab/communication/commands_proto.dart';
44
import 'package:pslab/communication/handler/base.dart';
55
import 'package:pslab/communication/packet_handler.dart';
6+
import 'package:pslab/communication/socket_client.dart';
67
import 'package:pslab/others/logger_service.dart';
8+
import 'package:pslab/providers/locator.dart';
79

810
import 'analogChannel/analog_acquisition_channel.dart';
911
import 'analogChannel/analog_constants.dart';
@@ -33,12 +35,14 @@ class ScienceLab {
3335
List<DigitalChannel> dChannels = [];
3436

3537
late CommunicationHandler mCommunicationHandler;
38+
late SocketClient mSocketClient;
3639
late PacketHandler mPacketHandler;
3740
late CommandsProto mCommandsProto;
3841
late AnalogConstants mAnalogConstants;
3942

4043
ScienceLab(CommunicationHandler communicationHandler) {
4144
mCommunicationHandler = communicationHandler;
45+
mSocketClient = getIt.get<SocketClient>();
4246
mCommandsProto = CommandsProto();
4347
mAnalogConstants = AnalogConstants();
4448
}
@@ -57,8 +61,20 @@ class ScienceLab {
5761
}
5862
}
5963

64+
Future<void> connectWiFi() async {
65+
try {
66+
await mSocketClient.openConnection("192.168.4.1", 80);
67+
mPacketHandler = PacketHandler(500, mCommunicationHandler);
68+
} catch (e) {
69+
logger.e(e);
70+
}
71+
if (isConnected()) {
72+
await _initializeVariables();
73+
}
74+
}
75+
6076
bool isConnected() {
61-
return mCommunicationHandler.isConnected();
77+
return (mSocketClient.isConnected() || mCommunicationHandler.isConnected());
6278
}
6379

6480
bool isDeviceFound() {

0 commit comments

Comments
 (0)