Skip to content
Closed
Prev Previous commit
Next Next commit
Add files via upload
  • Loading branch information
holgerlembke authored Nov 22, 2016
commit ec6a5737d41569b048b33af80c01de322c866255
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ public void run(){
//System.out.print(packet.getLength());
//System.out.print(" Data received from ");

String board = null;
InetAddress senderip = packet.getAddress();
//System.out.println(senderip);

Expand All @@ -100,37 +99,28 @@ public void run(){

// msg typ 1
if (lines[0].equals("1")) {
// check the IP has an entry, if not, create new one
// check the IP has an entry, if not, create new one, else use exsting one
BoardPort port;
int portexists = hasip(senderip.toString().substring(1));
if (portexists == -1) {
// new port
BoardPort port = new BoardPort();

port.setAddress(senderip.toString().substring(1));
port.setProtocol("network");
port.setOnlineStatus(true);
port.setLabel(lines[1]+" at "+senderip.toString().substring(1));
port.setLastseen(System.currentTimeMillis());

port.getPrefs().put("port", lines[2]);
/*
ServiceInfo info = serviceEvent.getInfo();
if (info.hasData()) {
port.getPrefs().put("distro_version", info.getPropertyString("distro_version"));
}
*/

port.getPrefs().put("board", board);
port.getPrefs().put("ssh_upload", "no");
port.getPrefs().put("tcp_check", "no");
port.getPrefs().put("auth_upload", "no");

port = new BoardPort();
udpBoardPorts.add(port);
} else {
// only update
BoardPort port = udpBoardPorts.get(portexists);
port.setLastseen(System.currentTimeMillis());
port = udpBoardPorts.get(portexists);
}

port.setAddress(senderip.toString().substring(1));
port.setProtocol("network");
port.setOnlineStatus(true);
port.setLabel(lines[1]+" at "+senderip.toString().substring(1));
port.setLastseen(System.currentTimeMillis());

port.getPrefs().put("port", lines[2]);
port.getPrefs().put("board", "");
port.getPrefs().put("ssh_upload", "no");
port.getPrefs().put("tcp_check", "no");
port.getPrefs().put("auth_upload", "no");
}
}
}
Expand Down Expand Up @@ -159,7 +149,7 @@ public void terminate()

message format

1\Ndisplayname\N
1\Ndisplayname\Nuploadport\N

1 - id of this message type
future protocols can choose different numbers to implement more details
Expand Down