WIFI connection support added
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import 'package:drift/drift.dart';
|
||||
|
||||
import '../../transport/connection_type.dart';
|
||||
import 'app_database.dart';
|
||||
|
||||
/// Zugriff auf die Einzeilen-Einstellungstabelle (Doku 7.5): welches
|
||||
@@ -18,6 +19,9 @@ class AppSettingsRepository {
|
||||
int? currentMissionId,
|
||||
String? connectionDeviceAddress,
|
||||
bool connectionAutoConnect,
|
||||
ConnectionType connectionType,
|
||||
String? connectionWifiHost,
|
||||
int connectionWifiPort,
|
||||
})> load() async {
|
||||
final row = await (_db.select(_db.appSettingsTable)
|
||||
..where((s) => s.id.equals(_rowId)))
|
||||
@@ -27,6 +31,12 @@ class AppSettingsRepository {
|
||||
currentMissionId: row?.currentMissionId,
|
||||
connectionDeviceAddress: row?.connectionDeviceAddress,
|
||||
connectionAutoConnect: row?.connectionAutoConnect ?? true,
|
||||
connectionType: ConnectionType.values.firstWhere(
|
||||
(t) => t.name == row?.connectionType,
|
||||
orElse: () => ConnectionType.bluetooth,
|
||||
),
|
||||
connectionWifiHost: row?.connectionWifiHost,
|
||||
connectionWifiPort: row?.connectionWifiPort ?? kDefaultWifiPort,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -64,6 +74,36 @@ class AppSettingsRepository {
|
||||
));
|
||||
}
|
||||
|
||||
/// Gewaehlte Verbindungsart (Doku Kommunikationsschicht 7).
|
||||
Future<void> setConnectionType(ConnectionType type) async {
|
||||
await _upsert(AppSettingsTableCompanion(
|
||||
id: const Value(_rowId),
|
||||
connectionType: Value(type.name),
|
||||
));
|
||||
}
|
||||
|
||||
/// Vom Nutzer eingetragene Ziel-IP der WLAN-Bruecke (Doku 3), oder null um
|
||||
/// die Vorgabe zu loeschen und nur noch aus dem Verkehr zu lernen.
|
||||
Future<String?> loadConnectionWifiHost() async =>
|
||||
(await load()).connectionWifiHost;
|
||||
|
||||
Future<void> setConnectionWifiHost(String? host) async {
|
||||
await _upsert(AppSettingsTableCompanion(
|
||||
id: const Value(_rowId),
|
||||
connectionWifiHost: Value(host),
|
||||
));
|
||||
}
|
||||
|
||||
Future<int> loadConnectionWifiPort() async =>
|
||||
(await load()).connectionWifiPort;
|
||||
|
||||
Future<void> setConnectionWifiPort(int port) async {
|
||||
await _upsert(AppSettingsTableCompanion(
|
||||
id: const Value(_rowId),
|
||||
connectionWifiPort: Value(port),
|
||||
));
|
||||
}
|
||||
|
||||
Future<void> _upsert(AppSettingsTableCompanion companion) async {
|
||||
await _db.into(_db.appSettingsTable).insertOnConflictUpdate(companion);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user