Skip to content

Commit a83770c

Browse files
roadfunroadfun
roadfun
authored and
roadfun
committed
Fix for arduino#2576
I’ve had a couple issues with unreliable Yun discovery. This change has fixed those issue for me and would appear to address concerns raised in arduino#2576.
1 parent cf3e948 commit a83770c

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

arduino-core/src/cc/arduino/packages/discoverers/NetworkDiscovery.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,19 @@ public List<BoardPort> discovery() {
6262
Iterator<BoardPort> iterator = ports.iterator();
6363
while (iterator.hasNext()) {
6464
try {
65-
BoardPort board = iterator.next();
66-
if (!NetUtils.isReachable(InetAddress.getByName(board.getAddress()), Integer.parseInt(board.getPrefs().get("port")))) {
67-
iterator.remove();
68-
}
65+
BoardPort board = iterator.next();
66+
InetAddress address= InetAddress.getByName(board.getAddress());
67+
boolean reachable = false;
68+
try {
69+
reachable = address.isReachable(100);
70+
} catch (IOException e) {
71+
// ignore (reachable is false by default)
72+
}
73+
if (!reachable) {
74+
iterator.remove();
75+
}
6976
} catch (UnknownHostException e) {
70-
iterator.remove();
77+
iterator.remove();
7178
}
7279
}
7380
return ports;

0 commit comments

Comments
 (0)