3737import java .net .InetAddress ;
3838import java .util .*;
3939
40- import cc .arduino .packages .discoverers .network .BoardReachabilityFilter ;
41-
4240public class NetworkDiscovery implements Discovery , ServiceListener , Runnable {
4341
4442 private final List <BoardPort > reachableBoardPorts = new LinkedList <>();
4543 private final List <BoardPort > boardPortsDiscoveredWithJmDNS = new LinkedList <>();
46- private Timer reachabilityTimer ;
4744 private JmmDNS jmdns = null ;
4845
4946 private void removeDuplicateBoards (BoardPort newBoard ) {
@@ -81,6 +78,7 @@ public void serviceResolved(ServiceEvent serviceEvent) {
8178 }
8279
8380 ServiceInfo info = serviceEvent .getInfo ();
81+
8482 for (InetAddress inetAddress : info .getInet4Addresses ()) {
8583 String address = inetAddress .getHostAddress ();
8684 String name = serviceEvent .getName ();
@@ -145,10 +143,9 @@ public void run() {
145143
146144 @ Override
147145 public void start () {
146+ System .getProperties ().setProperty ("net.dns.ttl" , "10" );
148147 jmdns = JmmDNS .Factory .getInstance ();
149148 jmdns .addServiceListener ("_arduino._tcp.local." , this );
150- reachabilityTimer = new Timer ();
151- new BoardReachabilityFilter (this ).start (reachabilityTimer );
152149 }
153150
154151 @ Override
@@ -164,15 +161,12 @@ public void stop() {
164161 e.printStackTrace();
165162 }
166163 */
167- if (reachabilityTimer != null ) {
168- reachabilityTimer .cancel ();
169- }
170164 }
171165
172166 @ Override
173167 public List <BoardPort > listDiscoveredBoards () {
174168 synchronized (reachableBoardPorts ) {
175- return new LinkedList <>( reachableBoardPorts );
169+ return getBoardPortsDiscoveredWithJmDNS ( );
176170 }
177171 }
178172
0 commit comments