@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**/ | ||||
@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()); | ||||
} | } | ||||
}); | }); | ||||
@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()); | ||||
} | } | ||||
}); | }); |
import android.widget.Button; | import android.widget.Button; | ||||
import android.widget.TextView; | import android.widget.TextView; | ||||
import android.widget.Toast; | 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; | ||||
@ExperimentalGetImage | @ExperimentalGetImage | ||||
public class MainActivity extends AppCompatActivity { | public class MainActivity extends AppCompatActivity { | ||||
WifiCommunication communication; | |||||
//WifiCommunication communication; | |||||
PermissionRequest permission; | PermissionRequest permission; | ||||
boolean communicationRunning = true; | boolean communicationRunning = true; | ||||
TextView textview1; | TextView textview1; | ||||
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() { | |||||
@Override | |||||
public void onClick(View v) { | |||||
if(button1.isChecked()){ | |||||
if(detectorService != null){ | |||||
detectorService.videoDetector.startDetection(); | |||||
} | |||||
}else{ | |||||
detectorService.videoDetector.stopDetection(); | |||||
} | |||||
} | |||||
}); | |||||
//textview1 = findViewById(R.id.textView1); | //textview1 = findViewById(R.id.textView1); | ||||
//Button button1 = findViewById(R.id.buttonSend); | //Button button1 = findViewById(R.id.buttonSend); | ||||
@Override | @Override | ||||
protected void onResume() { | protected void onResume() { | ||||
super.onResume(); | super.onResume(); | ||||
if (communicationRunning){ | |||||
/*if (communicationRunning){ | |||||
communication = new WifiCommunication(1234); | communication = new WifiCommunication(1234); | ||||
communication.setOnConnectionListener(new WifiCommunication.OnConnectionListener() { | communication.setOnConnectionListener(new WifiCommunication.OnConnectionListener() { | ||||
@Override | @Override | ||||
} | } | ||||
}); | }); | ||||
communicationRunning = false; | communicationRunning = false; | ||||
} | |||||
}*/ | |||||
permission = new PermissionRequest(MainActivity.this); | permission = new PermissionRequest(MainActivity.this); | ||||
permission.rechtePruefen(); | permission.rechtePruefen(); | ||||
} | } |
package com.example.ueberwachungssystem; | package com.example.ueberwachungssystem; | ||||
import android.annotation.SuppressLint; | import android.annotation.SuppressLint; | ||||
import android.util.Log; | |||||
import android.widget.Toast; | import android.widget.Toast; | ||||
import androidx.annotation.NonNull; | import androidx.annotation.NonNull; | ||||
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(","); | ||||
Log.d("empfangen", rxString); | |||||
if(!previousRxString.equals(rxString) && splitrxString[0].equals("1") && splitrxString.length==7) { | if(!previousRxString.equals(rxString) && splitrxString[0].equals("1") && splitrxString.length==7) { | ||||
//rxStringBuffer.append(rxString).append("\n"); | //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; | ||||
} | } | ||||
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); |