diff --git a/android/app/build.gradle b/android/app/build.gradle index 208f653..d9bf2b8 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -32,7 +32,7 @@ if (keystorePropertiesFile.exists()) { } android { - compileSdkVersion flutter.compileSdkVersion + compileSdkVersion 34 ndkVersion flutter.ndkVersion compileOptions { diff --git a/assets/json/bootstrap_response.json b/assets/json/bootstrap_response.json index 9768ec5..3209fdd 100644 --- a/assets/json/bootstrap_response.json +++ b/assets/json/bootstrap_response.json @@ -1,15 +1,6 @@ { - "payload": { - "config": { - "broker": "mqtt://18.156.72.225:1883", - "topics": { - "to_server": "/appserver/to_server/100/1/104400", - "from_server": "/appserver/from_server/100/1/104400" - } - }, - "label": { - "main_title": "Hauptseite" - }, - "option": {} - } + "broker": "mqtt://18.156.72.225:1883", + "id": "100/1/104400", + "to_server": "/appserver/to_server/", + "from_server": "/appserver/from_server/" } \ No newline at end of file diff --git a/ios/Flutter/AppFrameworkInfo.plist b/ios/Flutter/AppFrameworkInfo.plist index 9625e10..7c56964 100644 --- a/ios/Flutter/AppFrameworkInfo.plist +++ b/ios/Flutter/AppFrameworkInfo.plist @@ -21,6 +21,6 @@ CFBundleVersion 1.0 MinimumOSVersion - 11.0 + 12.0 diff --git a/ios/Podfile.lock b/ios/Podfile.lock index f916467..b765834 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -1,5 +1,7 @@ PODS: - Alamofire (5.8.1) + - audioplayers_darwin (0.0.1): + - Flutter - DKImagePickerController/Core (4.3.4): - DKImagePickerController/ImageDataManager - DKImagePickerController/Resource @@ -42,6 +44,8 @@ PODS: - Flutter - Polyline - Tangram-es + - geolocator_apple (1.2.0): + - Flutter - image_picker_ios (0.0.1): - Flutter - isar_flutter_libs (1.0.0): @@ -66,10 +70,12 @@ PODS: - Flutter DEPENDENCIES: + - audioplayers_darwin (from `.symlinks/plugins/audioplayers_darwin/ios`) - file_picker (from `.symlinks/plugins/file_picker/ios`) - Flutter (from `Flutter`) - flutter_barcode_scanner (from `.symlinks/plugins/flutter_barcode_scanner/ios`) - flutter_osm_plugin (from `.symlinks/plugins/flutter_osm_plugin/ios`) + - geolocator_apple (from `.symlinks/plugins/geolocator_apple/ios`) - image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`) - isar_flutter_libs (from `.symlinks/plugins/isar_flutter_libs/ios`) - open_filex (from `.symlinks/plugins/open_filex/ios`) @@ -89,6 +95,8 @@ SPEC REPOS: - Tangram-es EXTERNAL SOURCES: + audioplayers_darwin: + :path: ".symlinks/plugins/audioplayers_darwin/ios" file_picker: :path: ".symlinks/plugins/file_picker/ios" Flutter: @@ -97,6 +105,8 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/flutter_barcode_scanner/ios" flutter_osm_plugin: :path: ".symlinks/plugins/flutter_osm_plugin/ios" + geolocator_apple: + :path: ".symlinks/plugins/geolocator_apple/ios" image_picker_ios: :path: ".symlinks/plugins/image_picker_ios/ios" isar_flutter_libs: @@ -114,23 +124,25 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: Alamofire: 3ca42e259043ee0dc5c0cdd76c4bc568b8e42af7 + audioplayers_darwin: 877d9a4d06331c5c374595e46e16453ac7eafa40 DKImagePickerController: b512c28220a2b8ac7419f21c491fc8534b7601ac DKPhotoGallery: fdfad5125a9fdda9cc57df834d49df790dbb4179 file_picker: ce3938a0df3cc1ef404671531facef740d03f920 - Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 + Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7 flutter_barcode_scanner: 7a1144744c28dc0c57a8de7218ffe5ec59a9e4bf flutter_osm_plugin: 029b14f54485ced3190bb2c4444616b76e10c6a8 - image_picker_ios: 4a8aadfbb6dc30ad5141a2ce3832af9214a705b5 + geolocator_apple: 9157311f654584b9bb72686c55fc02a97b73f461 + image_picker_ios: 99dfe1854b4fa34d0364e74a78448a0151025425 isar_flutter_libs: b69f437aeab9c521821c3f376198c4371fa21073 open_filex: 6e26e659846ec990262224a12ef1c528bb4edbe4 - path_provider_foundation: 29f094ae23ebbca9d3d0cec13889cd9060c0e943 + path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c permission_handler_apple: e76247795d700c14ea09e3a2d8855d41ee80a2e6 Polyline: 2a1f29f87f8d9b7de868940f4f76deb8c678a5b1 SDWebImage: 96e0c18ef14010b7485210e92fac888587ebb958 - shared_preferences_foundation: 5b919d13b803cadd15ed2dc053125c68730e5126 + shared_preferences_foundation: b4c3b4cddf1c21f02770737f147a3f5da9d39695 SwiftyGif: 93a1cc87bf3a51916001cf8f3d63835fb64c819f Tangram-es: 628b634f7fc09d2217469b9914de00d9de49ff9d - url_launcher_ios: 68d46cc9766d0c41dbdc884310529557e3cd7a86 + url_launcher_ios: 6116280ddcfe98ab8820085d8d76ae7449447586 PODFILE CHECKSUM: cc1f88378b4bfcf93a6ce00d2c587857c6008d3b diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index aaf19bd..0c8f4c6 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -343,7 +343,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; @@ -421,7 +421,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -470,7 +470,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; diff --git a/lib/content_views/approach_area_page.dart b/lib/content_views/approach_area_page.dart index faf074e..efb1ed3 100644 --- a/lib/content_views/approach_area_page.dart +++ b/lib/content_views/approach_area_page.dart @@ -190,7 +190,7 @@ class _ApproachAreaPageState extends State { message.reqZip!.zip = zip; } - MqttCore.instance.publishText("/appserver/to_server/100/1/104400/set_location", jsonEncode(message.toJson())); + MqttCore.instance.publishText("set_location", jsonEncode(message.toJson())); } } diff --git a/lib/content_views/assigned_jobs_page.dart b/lib/content_views/assigned_jobs_page.dart index 2950cf9..bb59214 100644 --- a/lib/content_views/assigned_jobs_page.dart +++ b/lib/content_views/assigned_jobs_page.dart @@ -196,7 +196,7 @@ class _AssignedJobsPageState extends State { message.track.pos.long = currentPosition != null ? currentPosition.longitude : 0.0; message.track.pos.acc = currentPosition != null ? currentPosition.accuracy.toInt() : 0; - MqttCore.instance.publishText("/appserver/to_server/100/1/104400/reaction", jsonEncode(message.toJson())); + MqttCore.instance.publishText("reaction", jsonEncode(message.toJson())); job.state = 9; MyApp.isarInstance.writeTxnSync(() => {MyApp.isarInstance.jobs.putSync(job)}); diff --git a/lib/content_views/main_page.dart b/lib/content_views/main_page.dart index f285467..80e6e9e 100644 --- a/lib/content_views/main_page.dart +++ b/lib/content_views/main_page.dart @@ -1,3 +1,5 @@ +import 'dart:convert'; + import 'package:flutter/material.dart'; import 'package:isar/isar.dart'; import 'package:stadtbote/content_views/accepted_jobs_page.dart'; @@ -325,15 +327,13 @@ class _MainPageState extends State { var position = MyApp.currentPosition; var logoutMessage = LogoutMessage(); - logoutMessage.logout = LogoutContainer(); if (position != null) { - logoutMessage.logout.pos = LogoutMessagePosition(); - logoutMessage.logout.pos!.time = position.timestamp.toIso8601String(); - logoutMessage.logout.pos!.lat = position.latitude; - logoutMessage.logout.pos!.long = position.longitude; - logoutMessage.logout.pos!.acc = position.accuracy.toInt(); + logoutMessage.time = position.timestamp.toIso8601String(); + logoutMessage.lat = position.latitude; + logoutMessage.long = position.longitude; + logoutMessage.acc = position.accuracy.toInt(); } - MqttCore.instance.publishPayloadMessage('session', logoutMessage.toJson()); + MqttCore.instance.publishText("session", jsonEncode(logoutMessage.toJson())); } } diff --git a/lib/content_views/messages_page.dart b/lib/content_views/messages_page.dart index e843f60..4c782e1 100644 --- a/lib/content_views/messages_page.dart +++ b/lib/content_views/messages_page.dart @@ -109,7 +109,7 @@ class _MessagesPageState extends State { var json = jsonEncode(message.toJson()); - MqttCore.instance.publishText('/appserver/to_server/100/1/104400/set_location', jsonEncode(message.toJson())); + MqttCore.instance.publishText('set_location', jsonEncode(message.toJson())); _messages.insert(0, types.TextMessage( author: _user, diff --git a/lib/content_views/task_list_page.dart b/lib/content_views/task_list_page.dart index 6e84ae7..93302aa 100644 --- a/lib/content_views/task_list_page.dart +++ b/lib/content_views/task_list_page.dart @@ -407,7 +407,7 @@ class _TaskListPageState extends State { message.task.pos!.long = position.longitude; } - MqttCore.instance.publishText("/appserver/to_server/100/1/104400/fin_task", jsonEncode(message.toJson())); + MqttCore.instance.publishText("fin_task", jsonEncode(message.toJson())); } FinTourTask _createAnswerHeader(TaskInfo taskInfo) { @@ -449,7 +449,7 @@ class _TaskListPageState extends State { } } - MqttCore.instance.publishText("/appserver/to_server/100/1/104400/fin_tour", jsonEncode(message.toJson())); + MqttCore.instance.publishText("fin_tour", jsonEncode(message.toJson())); widget.tour.state = Constants.stateFinishedNotConfirmed; await MyApp.isarInstance.writeTxn(() async { diff --git a/lib/popups/accept_jobs_popup.dart b/lib/popups/accept_jobs_popup.dart index 7dc7162..9082612 100644 --- a/lib/popups/accept_jobs_popup.dart +++ b/lib/popups/accept_jobs_popup.dart @@ -173,7 +173,7 @@ _sendAnswer(Job job, int item) { message.track.pos.long = currentPosition != null ? currentPosition.longitude : 0.0; message.track.pos.acc = currentPosition != null ? currentPosition.accuracy.toInt() : 0; - MqttCore.instance.publishText("/appserver/to_server/100/1/104400/reaction", jsonEncode(message.toJson())); + MqttCore.instance.publishText("reaction", jsonEncode(message.toJson())); job.state = 9; MyApp.isarInstance.writeTxnSync(() => {MyApp.isarInstance.jobs.putSync(job)}); diff --git a/lib/protocoll_messages/bootstrap_response_payload.dart b/lib/protocoll_messages/bootstrap_response_payload.dart index a914af4..41281e6 100644 --- a/lib/protocoll_messages/bootstrap_response_payload.dart +++ b/lib/protocoll_messages/bootstrap_response_payload.dart @@ -4,14 +4,21 @@ import 'package:stadtbote/protocoll_messages/bootstrap_response_config.dart'; part 'bootstrap_response_payload.g.dart'; @JsonSerializable() -class BootstrapResponsePayload +class BootstrapResponse { - late BootstrapResponseConfig config; + late String broker; + late String id; - BootstrapResponsePayload(); + @JsonKey(name: "to_server") + late String toServer; - factory BootstrapResponsePayload.fromJson(Map json) => _$BootstrapResponsePayloadFromJson(json); + @JsonKey(name: "from_server") + late String fromServer; - Map toJson() => _$BootstrapResponsePayloadToJson(this); + BootstrapResponse(); + + factory BootstrapResponse.fromJson(Map json) => _$BootstrapResponseFromJson(json); + + Map toJson() => _$BootstrapResponseToJson(this); } diff --git a/lib/protocoll_messages/bootstrap_response_payload.g.dart b/lib/protocoll_messages/bootstrap_response_payload.g.dart index 552db65..f1d0c58 100644 --- a/lib/protocoll_messages/bootstrap_response_payload.g.dart +++ b/lib/protocoll_messages/bootstrap_response_payload.g.dart @@ -6,14 +6,17 @@ part of 'bootstrap_response_payload.dart'; // JsonSerializableGenerator // ************************************************************************** -BootstrapResponsePayload _$BootstrapResponsePayloadFromJson( - Map json) => - BootstrapResponsePayload() - ..config = BootstrapResponseConfig.fromJson( - json['config'] as Map); +BootstrapResponse _$BootstrapResponseFromJson(Map json) => + BootstrapResponse() + ..broker = json['broker'] as String + ..id = json['id'] as String + ..toServer = json['to_server'] as String + ..fromServer = json['from_server'] as String; -Map _$BootstrapResponsePayloadToJson( - BootstrapResponsePayload instance) => +Map _$BootstrapResponseToJson(BootstrapResponse instance) => { - 'config': instance.config, + 'broker': instance.broker, + 'id': instance.id, + 'to_server': instance.toServer, + 'from_server': instance.fromServer, }; diff --git a/lib/protocoll_messages/logout_message.dart b/lib/protocoll_messages/logout_message.dart index bc92ec8..8026364 100644 --- a/lib/protocoll_messages/logout_message.dart +++ b/lib/protocoll_messages/logout_message.dart @@ -4,28 +4,6 @@ part 'logout_message.g.dart'; @JsonSerializable() class LogoutMessage { - late LogoutContainer logout; - - LogoutMessage(); - - factory LogoutMessage.fromJson(Map json) => _$LogoutMessageFromJson(json); - - Map toJson() => _$LogoutMessageToJson(this); -} - -@JsonSerializable() -class LogoutContainer { - late LogoutMessagePosition? pos; - - LogoutContainer(); - - factory LogoutContainer.fromJson(Map json) => _$LogoutContainerFromJson(json); - - Map toJson() => _$LogoutContainerToJson(this); -} - -@JsonSerializable() -class LogoutMessagePosition { late String time; late double lat; @@ -34,10 +12,10 @@ class LogoutMessagePosition { late int acc; - LogoutMessagePosition(); + LogoutMessage(); - factory LogoutMessagePosition.fromJson(Map json) => _$LogoutMessagePositionFromJson(json); + factory LogoutMessage.fromJson(Map json) => _$LogoutMessageFromJson(json); - Map toJson() => _$LogoutMessagePositionToJson(this); + Map toJson() => _$LogoutMessageToJson(this); } diff --git a/lib/protocoll_messages/logout_message.g.dart b/lib/protocoll_messages/logout_message.g.dart index a107ce8..ffbfb87 100644 --- a/lib/protocoll_messages/logout_message.g.dart +++ b/lib/protocoll_messages/logout_message.g.dart @@ -8,35 +8,12 @@ part of 'logout_message.dart'; LogoutMessage _$LogoutMessageFromJson(Map json) => LogoutMessage() - ..logout = - LogoutContainer.fromJson(json['logout'] as Map); - -Map _$LogoutMessageToJson(LogoutMessage instance) => - { - 'logout': instance.logout, - }; - -LogoutContainer _$LogoutContainerFromJson(Map json) => - LogoutContainer() - ..pos = json['pos'] == null - ? null - : LogoutMessagePosition.fromJson(json['pos'] as Map); - -Map _$LogoutContainerToJson(LogoutContainer instance) => - { - 'pos': instance.pos, - }; - -LogoutMessagePosition _$LogoutMessagePositionFromJson( - Map json) => - LogoutMessagePosition() ..time = json['time'] as String ..lat = (json['lat'] as num).toDouble() ..long = (json['long'] as num).toDouble() ..acc = json['acc'] as int; -Map _$LogoutMessagePositionToJson( - LogoutMessagePosition instance) => +Map _$LogoutMessageToJson(LogoutMessage instance) => { 'time': instance.time, 'lat': instance.lat, diff --git a/lib/protocoll_messages/start_session_message.dart b/lib/protocoll_messages/start_session_message.dart index 531b57f..da279d5 100644 --- a/lib/protocoll_messages/start_session_message.dart +++ b/lib/protocoll_messages/start_session_message.dart @@ -6,8 +6,6 @@ part 'start_session_message.g.dart'; @JsonSerializable() class StartSessionMessage { - late bool startSession; - StartSessionMessage(); factory StartSessionMessage.fromJson(Map json) => _$StartSessionMessageFromJson(json); diff --git a/lib/protocoll_messages/start_session_message.g.dart b/lib/protocoll_messages/start_session_message.g.dart index d1fa018..e99df88 100644 --- a/lib/protocoll_messages/start_session_message.g.dart +++ b/lib/protocoll_messages/start_session_message.g.dart @@ -7,10 +7,8 @@ part of 'start_session_message.dart'; // ************************************************************************** StartSessionMessage _$StartSessionMessageFromJson(Map json) => - StartSessionMessage()..startSession = json['startSession'] as bool; + StartSessionMessage(); Map _$StartSessionMessageToJson( StartSessionMessage instance) => - { - 'startSession': instance.startSession, - }; + {}; diff --git a/lib/tools/mqtt_core.dart b/lib/tools/mqtt_core.dart index ed6c642..de7fa4e 100644 --- a/lib/tools/mqtt_core.dart +++ b/lib/tools/mqtt_core.dart @@ -48,6 +48,7 @@ class MqttCore { late String _brokerUri; late int _brokerPort; late String _fromServerTopic; + late String _clientId; late String _toServerTopic; late MqttServerClient _mqttClient; @@ -127,12 +128,14 @@ class MqttCore { } } - publishText(String topic, String text) { + publishText(String subtopic, String text) { try { var buffer = Uint8Buffer(); buffer.addAll(text.codeUnits); - _mqttClient.publishMessage(topic, MqttQos.exactlyOnce, buffer); + var topic = "$_toServerTopic$subtopic/$_clientId"; + + _mqttClient.publishMessage( topic, MqttQos.exactlyOnce, buffer); Util.logInfo("send message $text to $topic"); } catch (e) { @@ -140,22 +143,6 @@ class MqttCore { } } - publishPayloadMessage(String receiver, Map payload) { - try { - var payloadContainer = PayloadContainer(); - payloadContainer.id = const Uuid().v4().toString(); - payloadContainer.recv = receiver; - payloadContainer.store = true; - payloadContainer.payload = payload; - - var json = jsonEncode(payloadContainer.toJson()); - - publishText(_toServerTopic, json); - } catch (e) { - Util.logException(e.toString()); - } - } - void _setupSubscriptions() async { Util.logInfo('_setupSubscriptions called'); @@ -170,7 +157,7 @@ class MqttCore { Util.logInfo('mesage: $payload'); var topicArray = topic!.split('/'); - var messageType = topicArray[topicArray.length - 1]; + var messageType = topicArray[3]; switch(messageType) { case 'session': @@ -210,12 +197,9 @@ class MqttCore { } }); - _mqttClient.subscribe(_fromServerTopic + "/session", MqttQos.exactlyOnce); - _mqttClient.subscribe(_fromServerTopic + "/status", MqttQos.exactlyOnce); - _mqttClient.subscribe(_fromServerTopic + "/job", MqttQos.exactlyOnce); - _mqttClient.subscribe(_fromServerTopic + "/job_del", MqttQos.exactlyOnce); - _mqttClient.subscribe(_fromServerTopic + "/ranking", MqttQos.exactlyOnce); - Util.logInfo('subscribed to topic: $_fromServerTopic'); + var topic = "$_fromServerTopic#"; + _mqttClient.subscribe(topic, MqttQos.exactlyOnce); + Util.logInfo('subscribed to topic: $topic'); MessageService().publish(Constants.messageTopicConnectionStatusChanged, arguments: ConnectionStatus(status: ConnectionStatusEnum.connected)); } @@ -369,13 +353,14 @@ class MqttCore { var responseText = await rootBundle.loadString('assets/json/bootstrap_response.json'); - var bootstrapResponsePayload = BootstrapResponsePayload.fromJson(jsonDecode(responseText)["payload"]); + var bootstrapResponse = BootstrapResponse.fromJson(jsonDecode(responseText)); - var brokerUriAndPortArray = bootstrapResponsePayload.config.broker.replaceFirst("mqtt://", "").split(":"); + var brokerUriAndPortArray = bootstrapResponse.broker.replaceFirst("mqtt://", "").split(":"); _brokerUri = brokerUriAndPortArray[0]; _brokerPort = int.parse(brokerUriAndPortArray[1]); - _fromServerTopic = bootstrapResponsePayload.config.topics.fromServer; - _toServerTopic = bootstrapResponsePayload.config.topics.toServer; + _clientId = bootstrapResponse.id; + _fromServerTopic = bootstrapResponse.fromServer; + _toServerTopic = bootstrapResponse.toServer; _connectToBroker(); } catch (ex) { @@ -385,13 +370,10 @@ class MqttCore { _initSession() { var startSessionMessage = StartSessionMessage(); - startSessionMessage.startSession = true; - - var topic = "$_toServerTopic/session"; var jsonMap = startSessionMessage.toJson(); var json = jsonEncode(jsonMap); - publishText(topic, json); + publishText("session", json); } _sendSyncMessage() async @@ -410,7 +392,7 @@ class MqttCore { answer.sync.jobs.add(syncJob); } - MqttCore.instance.publishText("/appserver/to_server/100/1/104400/sync", jsonEncode(answer.toJson())); + MqttCore.instance.publishText("sync", jsonEncode(answer.toJson())); } void _startTrackTimer() { @@ -424,7 +406,7 @@ class MqttCore { trackMessage.pos.long = answer.longitude; trackMessage.pos.acc = answer.accuracy.toInt(); - publishText("/appserver/to_server/100/1/104400/track", jsonEncode(answer.toJson())); + publishText("track", jsonEncode(answer.toJson())); } }); }