Compare commits
6
Commits
copie
..
3d9e6b7a3e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3d9e6b7a3e | ||
|
|
61cad34931 | ||
|
|
e54322e3e2 | ||
|
|
edcf555b5b | ||
|
|
e571373fbb | ||
|
|
8e002107b5 |
No files matched your search
@@ -5,7 +5,6 @@ import android.os.Binder;
|
|||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
@@ -28,39 +27,48 @@ public class DetectorService extends LifecycleService {
|
|||||||
public Accelerometer motionDetector = null;
|
public Accelerometer motionDetector = null;
|
||||||
public MicrophoneDetector audioDetector = null;
|
public MicrophoneDetector audioDetector = null;
|
||||||
|
|
||||||
WifiCommunication wifiCommunication;
|
public WifiCommunication wifiCommunication;
|
||||||
|
|
||||||
|
String wifiData;
|
||||||
|
StringBuffer stringBufferWifi = new StringBuffer();
|
||||||
|
|
||||||
|
String typOfAlarm;
|
||||||
|
|
||||||
String dataFromWifi;
|
|
||||||
StringBuffer stringBufferFromWifi;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||||
if (isServiceRunning)
|
if (isServiceRunning)
|
||||||
return START_NOT_STICKY;
|
return START_NOT_STICKY;
|
||||||
|
|
||||||
|
/** Wifi Instanz **/
|
||||||
/** Wifi Instanz Starten und Listener **/
|
|
||||||
wifiCommunication = new WifiCommunication(1234);
|
wifiCommunication = new WifiCommunication(1234);
|
||||||
|
wifiCommunication.sendTrue("TEst");
|
||||||
|
|
||||||
wifiCommunication.setOnConnectionListener(new WifiCommunication.OnConnectionListener() {
|
wifiCommunication.setOnConnectionListener(new WifiCommunication.OnConnectionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onConnection(String data) {
|
public void onConnection(String data) {
|
||||||
dataFromWifi = data;
|
Log.d("Listener", data);
|
||||||
|
wifiData = data;
|
||||||
stringToStringbuffer(data);
|
stringToStringbuffer(data);
|
||||||
}
|
Log.d("buffer",stringBufferWifi.toString());
|
||||||
|
passToServiceListener(stringBufferWifi);
|
||||||
|
checkState(data);
|
||||||
|
checkTyp(data);
|
||||||
|
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** Video Detection/Recorder **/
|
/** Video Detection/Recorder **/
|
||||||
videoDetector = new VideoDetector(this);
|
videoDetector = new VideoDetector(this);
|
||||||
videoDetector.setOnDetectionListener(new Detector.OnDetectionListener() {
|
videoDetector.setOnDetectionListener(new Detector.OnDetectionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onDetection(@NonNull DetectionReport detectionReport) {
|
public void onDetection(@NonNull DetectionReport detectionReport) {
|
||||||
//passToServiceListener(detectionReport);
|
//passToServiceListener(detectionReport);
|
||||||
Log.d("Video", detectionReport.toMessage());
|
|
||||||
wifiCommunication.sendTrue(detectionReport.toMessage());
|
wifiCommunication.sendTrue(detectionReport.toMessage());
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
/** Motion Detection**/
|
/** Motion Detection**/
|
||||||
@@ -70,7 +78,6 @@ public class DetectorService extends LifecycleService {
|
|||||||
@Override
|
@Override
|
||||||
public void onDetection(@NonNull DetectionReport detectionReport) {
|
public void onDetection(@NonNull DetectionReport detectionReport) {
|
||||||
//passToServiceListener(detectionReport);
|
//passToServiceListener(detectionReport);
|
||||||
Log.d("Motion", detectionReport.toMessage());
|
|
||||||
wifiCommunication.sendTrue(detectionReport.toMessage());
|
wifiCommunication.sendTrue(detectionReport.toMessage());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -80,7 +87,6 @@ public class DetectorService extends LifecycleService {
|
|||||||
@Override
|
@Override
|
||||||
public void onDetection(@NonNull DetectionReport detectionReport) {
|
public void onDetection(@NonNull DetectionReport detectionReport) {
|
||||||
//passToServiceListener(detectionReport);
|
//passToServiceListener(detectionReport);
|
||||||
Log.d("Audio", detectionReport.toMessage());
|
|
||||||
wifiCommunication.sendTrue(detectionReport.toMessage());
|
wifiCommunication.sendTrue(detectionReport.toMessage());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -90,6 +96,8 @@ public class DetectorService extends LifecycleService {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
isServiceRunning = true;
|
isServiceRunning = true;
|
||||||
return super.onStartCommand(intent, flags, startId);
|
return super.onStartCommand(intent, flags, startId);
|
||||||
}
|
}
|
||||||
@@ -131,10 +139,29 @@ public class DetectorService extends LifecycleService {
|
|||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** string to stringbuffer **/
|
public void stringToStringbuffer(String string){
|
||||||
public void stringToStringbuffer(String dataString){
|
if(string != null) {
|
||||||
stringBufferFromWifi.append(dataString).append("\n");
|
stringBufferWifi.insert(0,string + "\n");
|
||||||
passToServiceListener(stringBufferFromWifi);
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String[] splitString(String string){
|
||||||
|
String[] splitrxString = string.split(",");
|
||||||
|
return splitrxString; //splitrxString[0] = "1",splitrxString[1] = "HH:MM:SS", splitrxString[0].equals("1")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean checkState(String string){
|
||||||
|
Log.d("state", String.valueOf(splitString(string)[4].equals("An")));
|
||||||
|
return splitString(string)[4].equals("An");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String checkTyp(String string){
|
||||||
|
if (splitString(string)[5] != null) {
|
||||||
|
typOfAlarm = splitString(string)[5];
|
||||||
|
Log.d("Type", typOfAlarm);
|
||||||
|
}
|
||||||
|
return typOfAlarm;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,81 +1,132 @@
|
|||||||
package com.example.ueberwachungssystem;
|
package com.example.ueberwachungssystem;
|
||||||
|
|
||||||
import static android.content.ContentValues.TAG;
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.content.ComponentName;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.ServiceConnection;
|
|
||||||
import android.net.wifi.WifiInfo;
|
|
||||||
import android.net.wifi.WifiManager;
|
|
||||||
import android.net.wifi.WifiInfo;
|
|
||||||
import android.net.wifi.WifiManager;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.os.IBinder;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.widget.Toast;
|
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import android.widget.Toast;
|
|
||||||
import android.widget.ToggleButton;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.camera.core.ExperimentalGetImage;
|
import androidx.camera.core.ExperimentalGetImage;
|
||||||
|
import androidx.camera.view.PreviewView;
|
||||||
|
|
||||||
|
import android.content.ComponentName;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.ServiceConnection;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.IBinder;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
import android.widget.ToggleButton;
|
||||||
|
|
||||||
|
import com.example.ueberwachungssystem.Detection.Accelerometer;
|
||||||
|
import com.example.ueberwachungssystem.Detection.AudioRecorder;
|
||||||
import com.example.ueberwachungssystem.Detection.DetectionReport;
|
import com.example.ueberwachungssystem.Detection.DetectionReport;
|
||||||
|
import com.example.ueberwachungssystem.Detection.Detector;
|
||||||
import com.example.ueberwachungssystem.Detection.DetectorService;
|
import com.example.ueberwachungssystem.Detection.DetectorService;
|
||||||
|
import com.example.ueberwachungssystem.Detection.MicrophoneDetector;
|
||||||
import java.net.InetAddress;
|
import com.example.ueberwachungssystem.Detection.VideoDetector;
|
||||||
import java.net.UnknownHostException;
|
|
||||||
import java.nio.ByteBuffer;
|
|
||||||
import java.nio.ByteOrder;
|
|
||||||
|
|
||||||
@ExperimentalGetImage
|
@ExperimentalGetImage
|
||||||
public class MainActivity extends AppCompatActivity {
|
public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
//WifiCommunication communication;
|
|
||||||
PermissionRequest permission;
|
|
||||||
boolean communicationRunning = true;
|
|
||||||
TextView textview1;
|
|
||||||
|
|
||||||
private DetectorService detectorService = new DetectorService();
|
private DetectorService detectorService = new DetectorService();
|
||||||
|
ImageView inputImageView;
|
||||||
|
ImageView outputImageView;
|
||||||
|
ToggleButton toggleButton;
|
||||||
|
int num=0;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
|
|
||||||
|
inputImageView = findViewById(R.id.inputImageView);
|
||||||
|
outputImageView = findViewById(R.id.outputImageView);
|
||||||
|
toggleButton = findViewById(R.id.toggleButton);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
|
||||||
|
PermissionHandler permissionHandler = new PermissionHandler(this);
|
||||||
|
//permissionHandler.getPermissions();
|
||||||
|
if (permissionHandler.hasPermissions()) {
|
||||||
|
|
||||||
Intent serviceIntent = new Intent(this, DetectorService.class);
|
Intent serviceIntent = new Intent(this, DetectorService.class);
|
||||||
bindService(serviceIntent, serviceConnection, Context.BIND_AUTO_CREATE);
|
bindService(serviceIntent, serviceConnection, Context.BIND_AUTO_CREATE);
|
||||||
startService(serviceIntent);
|
startService(serviceIntent);
|
||||||
ToggleButton button1 = findViewById(R.id.toggleButton);
|
|
||||||
button1.setOnClickListener(new View.OnClickListener() {
|
toggleButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if(button1.isChecked()){
|
if (toggleButton.isChecked())
|
||||||
|
{
|
||||||
if (detectorService != null){
|
if (detectorService != null){
|
||||||
|
|
||||||
detectorService.videoDetector.startDetection();
|
detectorService.videoDetector.startDetection();
|
||||||
|
|
||||||
|
detectorService.audioDetector.startDetection();
|
||||||
|
|
||||||
|
detectorService.motionDetector.startDetection();
|
||||||
|
|
||||||
|
detectorService.audioRecorder.stopRecording();
|
||||||
|
|
||||||
|
detectorService.videoDetector.startRecording();
|
||||||
}
|
}
|
||||||
}else{
|
}
|
||||||
|
else {
|
||||||
detectorService.videoDetector.stopDetection();
|
detectorService.videoDetector.stopDetection();
|
||||||
|
|
||||||
|
detectorService.audioDetector.stopDetection();
|
||||||
|
|
||||||
|
detectorService.motionDetector.stopDetection();
|
||||||
|
|
||||||
|
detectorService.audioRecorder.stopRecording();
|
||||||
|
|
||||||
|
detectorService.videoDetector.stopRecording();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
//textview1 = findViewById(R.id.textView1);
|
}else{
|
||||||
|
Toast.makeText(this,"Bitte Rechte geben", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
|
||||||
//Button button1 = findViewById(R.id.buttonSend);
|
}
|
||||||
/*button1.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
public void onClick(View v) {
|
getMenuInflater().inflate(R.menu.options_menu, menu);
|
||||||
communication.sendTrue("Testmessage");
|
return true;
|
||||||
|
}
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
Toast.makeText(this, "Selected Item: " + item.getTitle(), Toast.LENGTH_SHORT).show();
|
||||||
|
PopUpClass popUpClass;
|
||||||
|
switch (item.getItemId()) {
|
||||||
|
case R.id.Rechteverwaltung:
|
||||||
|
popUpClass = new PopUpClass(MainActivity.this);
|
||||||
|
popUpClass.showPopupWindow(inputImageView);
|
||||||
|
popUpClass.RechtePrüfen();
|
||||||
|
return true;
|
||||||
|
case R.id.Sensoren:
|
||||||
|
popUpClass = new PopUpClass(MainActivity.this);
|
||||||
|
popUpClass.showPopupWindow(inputImageView);
|
||||||
|
popUpClass.Sensoren();
|
||||||
|
return true;
|
||||||
|
case R.id.Impressum:
|
||||||
|
popUpClass = new PopUpClass(MainActivity.this);
|
||||||
|
popUpClass.showPopupWindow(inputImageView);
|
||||||
|
popUpClass.Impressum();
|
||||||
|
return true;
|
||||||
|
case R.id.Detection:
|
||||||
|
popUpClass = new PopUpClass(MainActivity.this);
|
||||||
|
popUpClass.showPopupWindow(inputImageView);
|
||||||
|
popUpClass.DetectionTotal(num);
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
});*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ServiceConnection serviceConnection = new ServiceConnection() {
|
private ServiceConnection serviceConnection = new ServiceConnection() {
|
||||||
@@ -83,76 +134,18 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
public void onServiceConnected(ComponentName name, IBinder service) {
|
public void onServiceConnected(ComponentName name, IBinder service) {
|
||||||
DetectorService.ServiceBinder binder = (DetectorService.ServiceBinder) service;
|
DetectorService.ServiceBinder binder = (DetectorService.ServiceBinder) service;
|
||||||
detectorService = binder.getBoundService();
|
detectorService = binder.getBoundService();
|
||||||
|
detectorService.videoDetector.debugProcessing(null, outputImageView); //inputImageView
|
||||||
|
|
||||||
detectorService.setOnDetectionListener(new DetectorService.OnDetectionListener() {
|
detectorService.setOnDetectionListener(new DetectorService.OnDetectionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onDetection(StringBuffer stringBuffer) {
|
public void onDetection(@NonNull StringBuffer stringBuffer) {
|
||||||
//textview für oli
|
Log.d("onDetection", stringBuffer.toString()); //Für oli hier Textview einbauen
|
||||||
Log.d("Debugger", stringBuffer.toString());
|
num++;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onServiceDisconnected(ComponentName name) {
|
public void onServiceDisconnected(ComponentName name) {
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@Override
|
|
||||||
protected void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
/*if (communicationRunning){
|
|
||||||
communication = new WifiCommunication(1234);
|
|
||||||
communication.setOnConnectionListener(new WifiCommunication.OnConnectionListener() {
|
|
||||||
@Override
|
|
||||||
public void onConnection(String data) {
|
|
||||||
//Log.d("Test", data.toString());
|
|
||||||
runOnUiThread(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
textview1.setText(data);
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
communicationRunning = false;
|
|
||||||
}*/
|
|
||||||
permission = new PermissionRequest(MainActivity.this);
|
|
||||||
permission.rechtePruefen();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onPause() {
|
|
||||||
super.onPause();
|
|
||||||
//communication.stopCommunication();
|
|
||||||
}
|
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
|
||||||
getMenuInflater().inflate(R.menu.options_menu, menu);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
/*public boolean onOptionsItemSelected(MenuItem item) {
|
|
||||||
Toast.makeText(this, "Selected Item: " + item.getTitle(), Toast.LENGTH_SHORT).show();
|
|
||||||
PopUpClass popUpClass;
|
|
||||||
switch (item.getItemId()) {
|
|
||||||
case R.id.Rechteverwaltung:
|
|
||||||
popUpClass = new PopUpClass(MainActivity.this);
|
|
||||||
popUpClass.showPopupWindow(textview1);
|
|
||||||
popUpClass.RechtePrüfen();
|
|
||||||
return true;
|
|
||||||
case R.id.Sensoren:
|
|
||||||
popUpClass = new PopUpClass(MainActivity.this);
|
|
||||||
popUpClass.showPopupWindow(textview1);
|
|
||||||
popUpClass.Sensoren();
|
|
||||||
return true;
|
|
||||||
case R.id.Impressum:
|
|
||||||
popUpClass = new PopUpClass(MainActivity.this);
|
|
||||||
popUpClass.showPopupWindow(textview1);
|
|
||||||
popUpClass.Impressum();
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
return super.onOptionsItemSelected(item);
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ public class PermissionRequest extends AppCompatActivity{
|
|||||||
handler.post(new Runnable() {
|
handler.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
Toast.makeText(mainActivity.getApplicationContext(),"Es werden Rechte benötigt", Toast.LENGTH_LONG).show();
|
Toast.makeText(mainActivity.getApplicationContext(),"Es werden Rechte benötigt", Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,8 @@ public class PopUpClass {
|
|||||||
Button buttonEdit = popupView.findViewById(R.id.RechteAnfordern);
|
Button buttonEdit = popupView.findViewById(R.id.RechteAnfordern);
|
||||||
buttonEdit.setOnClickListener(new View.OnClickListener() {
|
buttonEdit.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {RechteAnfordern();
|
public void onClick(View v) {
|
||||||
|
RechteAnfordern();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -81,5 +82,7 @@ public class PopUpClass {
|
|||||||
public void Impressum(){
|
public void Impressum(){
|
||||||
PopUpText.setText("Die Ueberwachungsapp wurde im Rahmen eines Praktikums der TH-Nürnberg programmiert");
|
PopUpText.setText("Die Ueberwachungsapp wurde im Rahmen eines Praktikums der TH-Nürnberg programmiert");
|
||||||
}
|
}
|
||||||
|
public void DetectionTotal(int num) {
|
||||||
|
PopUpText.setText("Total Detektions:" +num);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -31,6 +31,11 @@ public class WifiCommunication {
|
|||||||
private final DatagramSocket socket;
|
private final DatagramSocket socket;
|
||||||
volatile private boolean running;
|
volatile private boolean running;
|
||||||
|
|
||||||
|
private boolean Gruppe =true;
|
||||||
|
private boolean showMessage = true;
|
||||||
|
|
||||||
|
StringBuffer rxStringBuffer = new StringBuffer();
|
||||||
|
|
||||||
private OnConnectionListener listener;
|
private OnConnectionListener listener;
|
||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
public WifiCommunication(int port) {
|
public WifiCommunication(int port) {
|
||||||
@@ -61,11 +66,11 @@ public class WifiCommunication {
|
|||||||
public void sendWifiData(String wifiMessage) {
|
public void sendWifiData(String wifiMessage) {
|
||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
listener.onConnection(wifiMessage);
|
listener.onConnection(wifiMessage);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ReceiveThread extends Thread {
|
private class ReceiveThread extends Thread {
|
||||||
private StringBuffer rxStringBuffer = new StringBuffer();
|
|
||||||
private String rxString="";
|
private String rxString="";
|
||||||
private String previousRxString = "";
|
private String previousRxString = "";
|
||||||
|
|
||||||
@@ -78,14 +83,31 @@ public class WifiCommunication {
|
|||||||
socket.receive(rxPacket);
|
socket.receive(rxPacket);
|
||||||
rxString = new String(receiveData, 0, rxPacket.getLength());
|
rxString = new String(receiveData, 0, rxPacket.getLength());
|
||||||
String[] splitrxString = rxString.split(",");
|
String[] splitrxString = rxString.split(",");
|
||||||
|
String[] splitrxStringBuffer = splitBufferIntoStrings(rxStringBuffer);
|
||||||
|
for(String elem: splitrxStringBuffer){
|
||||||
|
if(elem.equals(rxString)){
|
||||||
|
showMessage = false;
|
||||||
|
}else{
|
||||||
|
showMessage = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(Gruppe){
|
||||||
|
if(!previousRxString.equals(rxString) && splitrxString[0].equals("1") && splitrxString.length==7 && showMessage) {
|
||||||
|
rxStringBuffer.append(rxString).append("\n");
|
||||||
Log.d("empfangen", rxString);
|
Log.d("empfangen", rxString);
|
||||||
if(!previousRxString.equals(rxString) && splitrxString[0].equals("1") && splitrxString.length==7) {
|
|
||||||
//rxStringBuffer.append(rxString).append("\n");
|
|
||||||
sendWifiData(rxString);
|
sendWifiData(rxString);
|
||||||
|
|
||||||
//mainActivity.runOnUiThread(() -> mainActivity.tvMessages.setText(rxStringBuffer));
|
//mainActivity.runOnUiThread(() -> mainActivity.tvMessages.setText(rxStringBuffer));
|
||||||
previousRxString = rxString;
|
previousRxString = rxString;
|
||||||
}
|
}
|
||||||
|
}else{
|
||||||
|
if(!previousRxString.equals(rxString) && splitrxString[0].equals("1") && splitrxString.length==7 && showMessage) {
|
||||||
|
rxStringBuffer.append(rxString).append("\n");
|
||||||
|
Log.d("empfangen", rxString);
|
||||||
|
sendWifiData(rxString);
|
||||||
|
//mainActivity.runOnUiThread(() -> mainActivity.tvMessages.setText(rxStringBuffer));
|
||||||
|
previousRxString = rxString;
|
||||||
|
}
|
||||||
|
}
|
||||||
} while (running);
|
} while (running);
|
||||||
}
|
}
|
||||||
catch (IOException e) {
|
catch (IOException e) {
|
||||||
@@ -102,15 +124,18 @@ public class WifiCommunication {
|
|||||||
if(send)
|
if(send)
|
||||||
{
|
{
|
||||||
send = false;
|
send = false;
|
||||||
|
/*SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");
|
||||||
|
Date curDate = new Date(System.currentTimeMillis());
|
||||||
|
String str = formatter.format(curDate);*/
|
||||||
byte[] send_Data = new byte[512];
|
byte[] send_Data = new byte[512];
|
||||||
String txString = (messageToSend);
|
String txString = (messageToSend); //"1," +str+ ",Gruppe2," + getLocalIpAddress() + ",An,Video,"
|
||||||
|
Log.d("send", txString);
|
||||||
send_Data = txString.getBytes();
|
send_Data = txString.getBytes();
|
||||||
|
|
||||||
DatagramPacket txPacket = new DatagramPacket(send_Data, txString.length(), address, port);
|
DatagramPacket txPacket = new DatagramPacket(send_Data, txString.length(), address, port);
|
||||||
|
|
||||||
for(int i = 0; i < 500; i++) {
|
for(int i = 0; i < 500; i++) {
|
||||||
socket.send(txPacket);
|
socket.send(txPacket);
|
||||||
Log.d("senden", txPacket.getData().toString());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (running);
|
} while (running);
|
||||||
@@ -144,4 +169,8 @@ public class WifiCommunication {
|
|||||||
running = false;
|
running = false;
|
||||||
socket.close();
|
socket.close();
|
||||||
}
|
}
|
||||||
|
public String[] splitBufferIntoStrings(StringBuffer string){
|
||||||
|
String[] splitrxString2 = string.toString().split("\n");
|
||||||
|
return splitrxString2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -4,6 +4,8 @@
|
|||||||
android:title="Rechteverwaltung" />
|
android:title="Rechteverwaltung" />
|
||||||
<item android:id="@+id/Sensoren"
|
<item android:id="@+id/Sensoren"
|
||||||
android:title="Sensoren" />
|
android:title="Sensoren" />
|
||||||
|
<item android:id="@+id/Detection"
|
||||||
|
android:title="Detektionen" />
|
||||||
<item android:id="@+id/Impressum"
|
<item android:id="@+id/Impressum"
|
||||||
android:title="Impressum" />
|
android:title="Impressum" />
|
||||||
</menu>
|
</menu>
|
||||||
Reference in new issue
Block a user