37
37
import java .net .InetAddress ;
38
38
import java .util .*;
39
39
40
- import cc .arduino .packages .discoverers .network .BoardReachabilityFilter ;
41
-
42
40
public class NetworkDiscovery implements Discovery , ServiceListener , Runnable {
43
41
44
42
private final List <BoardPort > reachableBoardPorts = new LinkedList <>();
45
43
private final List <BoardPort > boardPortsDiscoveredWithJmDNS = new LinkedList <>();
46
- private Timer reachabilityTimer ;
47
44
private JmmDNS jmdns = null ;
48
45
49
46
private void removeDuplicateBoards (BoardPort newBoard ) {
@@ -81,6 +78,7 @@ public void serviceResolved(ServiceEvent serviceEvent) {
81
78
}
82
79
83
80
ServiceInfo info = serviceEvent .getInfo ();
81
+
84
82
for (InetAddress inetAddress : info .getInet4Addresses ()) {
85
83
String address = inetAddress .getHostAddress ();
86
84
String name = serviceEvent .getName ();
@@ -145,10 +143,9 @@ public void run() {
145
143
146
144
@ Override
147
145
public void start () {
146
+ System .getProperties ().setProperty ("net.dns.ttl" , "10" );
148
147
jmdns = JmmDNS .Factory .getInstance ();
149
148
jmdns .addServiceListener ("_arduino._tcp.local." , this );
150
- reachabilityTimer = new Timer ();
151
- new BoardReachabilityFilter (this ).start (reachabilityTimer );
152
149
}
153
150
154
151
@ Override
@@ -164,15 +161,12 @@ public void stop() {
164
161
e.printStackTrace();
165
162
}
166
163
*/
167
- if (reachabilityTimer != null ) {
168
- reachabilityTimer .cancel ();
169
- }
170
164
}
171
165
172
166
@ Override
173
167
public List <BoardPort > listDiscoveredBoards () {
174
168
synchronized (reachableBoardPorts ) {
175
- return new LinkedList <>( reachableBoardPorts );
169
+ return getBoardPortsDiscoveredWithJmDNS ( );
176
170
}
177
171
}
178
172
0 commit comments