|
|
@@ -31,6 +31,8 @@ public class WifiCommunication { |
|
|
|
private final DatagramSocket socket; |
|
|
|
volatile private boolean running; |
|
|
|
|
|
|
|
private boolean Gruppe =true; |
|
|
|
|
|
|
|
private OnConnectionListener listener; |
|
|
|
@SuppressLint("SetTextI18n") |
|
|
|
public WifiCommunication(int port) { |
|
|
@@ -66,7 +68,6 @@ public class WifiCommunication { |
|
|
|
} |
|
|
|
|
|
|
|
private class ReceiveThread extends Thread { |
|
|
|
private StringBuffer rxStringBuffer = new StringBuffer(); |
|
|
|
private String rxString=""; |
|
|
|
private String previousRxString = ""; |
|
|
|
|
|
|
@@ -79,13 +80,16 @@ public class WifiCommunication { |
|
|
|
socket.receive(rxPacket); |
|
|
|
rxString = new String(receiveData, 0, rxPacket.getLength()); |
|
|
|
String[] splitrxString = rxString.split(","); |
|
|
|
if(!previousRxString.equals(rxString) && splitrxString[0].equals("1") && splitrxString.length==7) { |
|
|
|
//rxStringBuffer.append(rxString).append("\n"); |
|
|
|
Log.d("empfangen", rxString); |
|
|
|
sendWifiData(rxString); |
|
|
|
//mainActivity.runOnUiThread(() -> mainActivity.tvMessages.setText(rxStringBuffer)); |
|
|
|
previousRxString = rxString; |
|
|
|
if(Gruppe){ |
|
|
|
if(!previousRxString.equals(rxString) && splitrxString[0].equals("1") && splitrxString.length==7) { |
|
|
|
//rxStringBuffer.append(rxString).append("\n"); |
|
|
|
Log.d("empfangen", rxString); |
|
|
|
sendWifiData(rxString); |
|
|
|
//mainActivity.runOnUiThread(() -> mainActivity.tvMessages.setText(rxStringBuffer)); |
|
|
|
previousRxString = rxString; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} while (running); |
|
|
|
} |
|
|
|
catch (IOException e) { |