|
|
|
|
|
|
|
|
private final DatagramSocket socket; |
|
|
private final DatagramSocket socket; |
|
|
volatile private boolean running; |
|
|
volatile private boolean running; |
|
|
|
|
|
|
|
|
|
|
|
private boolean Gruppe =true; |
|
|
|
|
|
|
|
|
private OnConnectionListener listener; |
|
|
private OnConnectionListener listener; |
|
|
@SuppressLint("SetTextI18n") |
|
|
@SuppressLint("SetTextI18n") |
|
|
public WifiCommunication(int port) { |
|
|
public WifiCommunication(int port) { |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
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 = ""; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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(","); |
|
|
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); |
|
|
} while (running); |
|
|
} |
|
|
} |
|
|
catch (IOException e) { |
|
|
catch (IOException e) { |