From 292d0b2bd3b3d138c569fcc47331f182b4cd2a6d Mon Sep 17 00:00:00 2001 From: christianrowlands Date: Tue, 30 Jul 2024 12:10:44 -0400 Subject: [PATCH] Read in the streaming options from the QR Code MQTT settings --- README.md | 20 ++++++++++--------- .../fragments/CodeScannerFragment.java | 5 +++-- .../model/MqttConnectionSettings.java | 2 +- .../networksurvey/util/PreferenceUtils.java | 20 +++++++++++++++++++ 4 files changed, 35 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index e4ad0e70..509f4848 100644 --- a/README.md +++ b/README.md @@ -12,10 +12,10 @@

-The Network Survey Android App provides a basic survey capability for logging and analyzing -Cellular networks, Wi-Fi networks, Bluetooth Devices, and GNSS constellations. Capture detailed -records of signal strength, network information, and device data. All data can be conveniently -logged to GeoPackage or CSV files for offline analysis. Alternatively, choose to live stream the +The Network Survey Android App provides a basic survey capability for logging and analyzing +Cellular networks, Wi-Fi networks, Bluetooth Devices, and GNSS constellations. Capture detailed +records of signal strength, network information, and device data. All data can be conveniently +logged to GeoPackage or CSV files for offline analysis. Alternatively, choose to live stream the data via MQTT or gRPC protocols for real-time monitoring and integration with other systems. The Network Survey user manual can be found [here](https://networksurvey.app/manual). @@ -63,8 +63,8 @@ If you're interested in CDR logging that includes SMS events and call details: ## Tracking And Privacy -The version of this app on the Play Store has Firebase Crashlytics and Analytics set up. This means -that app crash logs and analytics are sent off the device to Firebase. If you don't want to +The version of this app on the Play Store has Firebase Crashlytics and Analytics set up. This means +that app crash logs and analytics are sent off the device to Firebase. If you don't want to participate in this type of tracking then you have three options. 1. Install the app @@ -89,8 +89,8 @@ If you want to build using the command line, the apk can be built and installed commands. Make sure your phone is connected to your computer before running the install command. There are two build variants available for this app. The default build variant is the regular -version of the app which is the "Google Play" version. As noted in the privacy section, the -"Google Play" version has Firebase Crashlytics and Analytics enabled. The second build variant is +version of the app which is the "Google Play" version. As noted in the privacy section, the +"Google Play" version has Firebase Crashlytics and Analytics enabled. The second build variant is the "CDR" version. The "CDR" version does not have Firebase Crashlytics and Analytics enabled, and it has the extended CDR logging features (as discussed above). @@ -174,7 +174,9 @@ you can use the `mqtt_topic_prefix` field to change the topic to something like "mqtt_port": 8883, "mqtt_client": "aclient", "mqtt_tls": true, - "mqtt_topic_prefix": "my/custom/topic/path/" + "mqtt_topic_prefix": "my/custom/topic/path/", + "cellular_stream_enabled": true, + "wifi_stream_enabled": true } ``` diff --git a/networksurvey/src/main/java/com/craxiom/networksurvey/fragments/CodeScannerFragment.java b/networksurvey/src/main/java/com/craxiom/networksurvey/fragments/CodeScannerFragment.java index b79b7230..708560d0 100644 --- a/networksurvey/src/main/java/com/craxiom/networksurvey/fragments/CodeScannerFragment.java +++ b/networksurvey/src/main/java/com/craxiom/networksurvey/fragments/CodeScannerFragment.java @@ -34,13 +34,14 @@ public class CodeScannerFragment extends Fragment public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - final Activity activity = getActivity(); View root = inflater.inflate(R.layout.fragment_scanner, container, false); + final Activity activity = getActivity(); + if (activity == null) return null; + CodeScannerView scannerView = root.findViewById(R.id.scanner_view); codeScanner = new CodeScanner(activity, scannerView); codeScanner.setDecodeCallback(result -> activity.runOnUiThread(() -> { - if (!result.getText().isEmpty()) { try diff --git a/networksurvey/src/main/java/com/craxiom/networksurvey/fragments/model/MqttConnectionSettings.java b/networksurvey/src/main/java/com/craxiom/networksurvey/fragments/model/MqttConnectionSettings.java index 8cde07fe..8607f33c 100644 --- a/networksurvey/src/main/java/com/craxiom/networksurvey/fragments/model/MqttConnectionSettings.java +++ b/networksurvey/src/main/java/com/craxiom/networksurvey/fragments/model/MqttConnectionSettings.java @@ -23,7 +23,7 @@ public record MqttConnectionSettings( @SerializedName("wifi_stream_enabled") Boolean wifiStreamEnabled, @SerializedName("bluetooth_stream_enabled") Boolean bluetoothStreamEnabled, @SerializedName("gnss_stream_enabled") Boolean gnssStreamEnabled, - @SerializedName("device_status_stream_enabled") Boolean deviceStatusStreamEnabled // TODO Handle these fields in the QR Code scanner + @SerializedName("device_status_stream_enabled") Boolean deviceStatusStreamEnabled ) implements Serializable { diff --git a/networksurvey/src/main/java/com/craxiom/networksurvey/util/PreferenceUtils.java b/networksurvey/src/main/java/com/craxiom/networksurvey/util/PreferenceUtils.java index d0351301..e2c3d357 100644 --- a/networksurvey/src/main/java/com/craxiom/networksurvey/util/PreferenceUtils.java +++ b/networksurvey/src/main/java/com/craxiom/networksurvey/util/PreferenceUtils.java @@ -683,6 +683,26 @@ public static void populatePrefsFromMqttConnectionSettings(MqttConnectionSetting { edit.putString(MqttConstants.PROPERTY_MQTT_TOPIC_PREFIX, mqttConnectionSettings.mqttTopicPrefix()); } + if (mqttConnectionSettings.cellularStreamEnabled() != null) + { + edit.putBoolean(NetworkSurveyConstants.PROPERTY_MQTT_CELLULAR_STREAM_ENABLED, mqttConnectionSettings.cellularStreamEnabled()); + } + if (mqttConnectionSettings.wifiStreamEnabled() != null) + { + edit.putBoolean(NetworkSurveyConstants.PROPERTY_MQTT_WIFI_STREAM_ENABLED, mqttConnectionSettings.wifiStreamEnabled()); + } + if (mqttConnectionSettings.bluetoothStreamEnabled() != null) + { + edit.putBoolean(NetworkSurveyConstants.PROPERTY_MQTT_BLUETOOTH_STREAM_ENABLED, mqttConnectionSettings.bluetoothStreamEnabled()); + } + if (mqttConnectionSettings.gnssStreamEnabled() != null) + { + edit.putBoolean(NetworkSurveyConstants.PROPERTY_MQTT_GNSS_STREAM_ENABLED, mqttConnectionSettings.gnssStreamEnabled()); + } + if (mqttConnectionSettings.deviceStatusStreamEnabled() != null) + { + edit.putBoolean(NetworkSurveyConstants.PROPERTY_MQTT_DEVICE_STATUS_STREAM_ENABLED, mqttConnectionSettings.deviceStatusStreamEnabled()); + } edit.apply(); }