From d17f455ae1de8fe721d0e81dfe311137b1ecfc5f Mon Sep 17 00:00:00 2001 From: Bastian Kohler Date: Wed, 21 Jun 2023 13:05:56 +0200 Subject: [PATCH] Added toMessage() to DetectionReport --- .../Detection/DetectionReport.java | 12 ++++++++++++ .../example/ueberwachungssystem/MainActivity.java | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/example/ueberwachungssystem/Detection/DetectionReport.java b/app/src/main/java/com/example/ueberwachungssystem/Detection/DetectionReport.java index dc09371..6e80a74 100644 --- a/app/src/main/java/com/example/ueberwachungssystem/Detection/DetectionReport.java +++ b/app/src/main/java/com/example/ueberwachungssystem/Detection/DetectionReport.java @@ -3,6 +3,8 @@ package com.example.ueberwachungssystem.Detection; import android.annotation.SuppressLint; import android.util.Log; +import com.example.ueberwachungssystem.WifiCommunication; + import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; @@ -38,6 +40,16 @@ public class DetectionReport { return String.join("\t", state, time, type, value); } + public String toMessage() { + String state; + if(detectionState) + state = "An"; + else + state = "Aus"; + + return String.join(",", "1", timeStamp, "Gruppe2", WifiCommunication.getLocalIpAddress(), state, detectionType, String.valueOf(detectedValue)); + } + /** Debug Report */ public void log(String tag) { Log.d(tag, this.toString()); diff --git a/app/src/main/java/com/example/ueberwachungssystem/MainActivity.java b/app/src/main/java/com/example/ueberwachungssystem/MainActivity.java index 8766d85..24cdcb3 100644 --- a/app/src/main/java/com/example/ueberwachungssystem/MainActivity.java +++ b/app/src/main/java/com/example/ueberwachungssystem/MainActivity.java @@ -104,7 +104,7 @@ public class MainActivity extends AppCompatActivity { detectorService.setOnDetectionListener(new DetectorService.OnDetectionListener() { @Override public void onDetection(@NonNull DetectionReport detectionReport) { - Log.d("onDetection", detectionReport.toString()); + Log.d("onDetection", detectionReport.toMessage()); } }); }