Skip to content

Commit 433237c

Browse files
author
jantje
committed
Update to latest code of arduino for bonjour
1 parent c5fec60 commit 433237c

File tree

9 files changed

+756
-481
lines changed

9 files changed

+756
-481
lines changed

io.sloeber.core/src/cc/arduino/packages/BoardPort.java

Lines changed: 84 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -29,84 +29,90 @@
2929

3030
package cc.arduino.packages;
3131

32-
@SuppressWarnings({ "unqualified-field-access", "nls" })
32+
33+
3334
public class BoardPort {
3435

35-
private String address;
36-
private String protocol;
37-
private String boardName;
38-
private String vid;
39-
private String pid;
40-
private String iserial;
41-
private String label;
42-
private boolean online;
43-
44-
public BoardPort() {
45-
}
46-
47-
public String getAddress() {
48-
return address;
49-
}
50-
51-
public void setAddress(String address) {
52-
this.address = address;
53-
}
54-
55-
public String getProtocol() {
56-
return protocol;
57-
}
58-
59-
public void setProtocol(String protocol) {
60-
this.protocol = protocol;
61-
}
62-
63-
public String getBoardName() {
64-
return boardName;
65-
}
66-
67-
public void setBoardName(String boardName) {
68-
this.boardName = boardName;
69-
}
70-
71-
public void setLabel(String label) {
72-
this.label = label;
73-
}
74-
75-
public String getLabel() {
76-
return label;
77-
}
78-
79-
public void setOnlineStatus(boolean online) {
80-
this.online = online;
81-
}
82-
83-
public boolean isOnline() {
84-
return online;
85-
}
86-
87-
public void setVIDPID(String vid, String pid) {
88-
this.vid = vid;
89-
this.pid = pid;
90-
}
91-
92-
public String getVID() {
93-
return vid;
94-
}
95-
96-
public String getPID() {
97-
return pid;
98-
}
99-
100-
public void setISerial(String iserial) {
101-
this.iserial = iserial;
102-
}
103-
104-
public String getISerial() {
105-
return iserial;
106-
}
107-
108-
@Override
109-
public String toString() {
110-
return this.address + "_" + this.vid + "_" + this.pid;
111-
}
36+
private String address;
37+
private String protocol;
38+
private String boardName;
39+
private String vid;
40+
private String pid;
41+
private String iserial;
42+
private String label;
43+
private final PreferencesMap prefs;
44+
private boolean online;
45+
46+
public BoardPort() {
47+
this.prefs = new PreferencesMap();
48+
}
49+
50+
public String getAddress() {
51+
return this.address;
52+
}
53+
54+
public void setAddress(String address) {
55+
this.address = address;
56+
}
57+
58+
public String getProtocol() {
59+
return this.protocol;
60+
}
61+
62+
public void setProtocol(String protocol) {
63+
this.protocol = protocol;
64+
}
65+
66+
public String getBoardName() {
67+
return this.boardName;
68+
}
69+
70+
public void setBoardName(String boardName) {
71+
this.boardName = boardName;
72+
}
73+
74+
public PreferencesMap getPrefs() {
75+
return this.prefs;
76+
}
77+
78+
public void setLabel(String label) {
79+
this.label = label;
80+
}
81+
82+
public String getLabel() {
83+
return this.label;
84+
}
85+
86+
public void setOnlineStatus(boolean online) {
87+
this.online = online;
88+
}
89+
90+
public boolean isOnline() {
91+
return this.online;
92+
}
93+
94+
public void setVIDPID(String vid, String pid) {
95+
this.vid = vid;
96+
this.pid = pid;
97+
}
98+
99+
public String getVID() {
100+
return this.vid;
101+
}
102+
103+
public String getPID() {
104+
return this.pid;
105+
}
106+
107+
public void setISerial(String iserial) {
108+
this.iserial = iserial;
109+
}
110+
public String getISerial() {
111+
return this.iserial;
112+
}
113+
114+
@Override
115+
public String toString() {
116+
return this.address+"_"+this.vid+"_"+this.pid; //$NON-NLS-1$//$NON-NLS-2$
117+
}
112118
}
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,56 @@
1-
/*
2-
* This file is part of Arduino.
3-
*
4-
* Arduino is free software; you can redistribute it and/or modify
5-
* it under the terms of the GNU General Public License as published by
6-
* the Free Software Foundation; either version 2 of the License, or
7-
* (at your option) any later version.
8-
*
9-
* This program is distributed in the hope that it will be useful,
10-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12-
* GNU General Public License for more details.
13-
*
14-
* You should have received a copy of the GNU General Public License
15-
* along with this program; if not, write to the Free Software
16-
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17-
*
18-
* As a special exception, you may use this file as part of a free software
19-
* library without restriction. Specifically, if other files instantiate
20-
* templates or use macros or inline functions from this file, or you compile
21-
* this file and link it with other files to produce an executable, this
22-
* file does not by itself cause the resulting executable to be covered by
23-
* the GNU General Public License. This exception does not however
24-
* invalidate any other reasons why the executable file might be covered by
25-
* the GNU General Public License.
26-
*
27-
* Copyright 2013 Arduino LLC (http://www.arduino.cc/)
28-
*/
29-
30-
package cc.arduino.packages.discoverers;
31-
32-
import java.net.InetAddress;
33-
import java.util.Collections;
34-
import java.util.HashSet;
35-
import java.util.Set;
36-
import java.util.Timer;
37-
import java.util.TimerTask;
38-
39-
import javax.jmdns.NetworkTopologyDiscovery;
40-
41-
public class NetworkChecker extends TimerTask {
42-
43-
private final NetworkTopologyDiscovery topology;
44-
45-
private Set<InetAddress> knownAddresses;
46-
47-
public NetworkChecker(NetworkTopologyDiscovery topology) {
48-
super();
49-
this.topology = topology;
50-
this.knownAddresses = Collections.synchronizedSet(new HashSet<InetAddress>());
51-
}
52-
53-
public void start(Timer timer) {
54-
timer.schedule(this, 0, 3000);
55-
}
56-
57-
@Override
58-
public void run() {
59-
try {
60-
InetAddress[] curentAddresses = this.topology.getInetAddresses();
61-
Set<InetAddress> current = new HashSet<>(curentAddresses.length);
62-
for (InetAddress address : curentAddresses) {
63-
current.add(address);
64-
if (!this.knownAddresses.contains(address)) {
65-
NetworkDiscovery.inetAddressAdded(address);
66-
}
67-
}
68-
for (InetAddress address : this.knownAddresses) {
69-
if (!current.contains(address)) {
70-
NetworkDiscovery.inetAddressRemoved(address);
71-
}
72-
}
73-
this.knownAddresses = current;
74-
} catch (Exception e) {
75-
e.printStackTrace();
76-
}
77-
}
78-
}
1+
/*
2+
* This file is part of Arduino.
3+
*
4+
* Arduino is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation; either version 2 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program; if not, write to the Free Software
16+
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17+
*
18+
* As a special exception, you may use this file as part of a free software
19+
* library without restriction. Specifically, if other files instantiate
20+
* templates or use macros or inline functions from this file, or you compile
21+
* this file and link it with other files to produce an executable, this
22+
* file does not by itself cause the resulting executable to be covered by
23+
* the GNU General Public License. This exception does not however
24+
* invalidate any other reasons why the executable file might be covered by
25+
* the GNU General Public License.
26+
*
27+
* Copyright 2013 Arduino LLC (http://www.arduino.cc/)
28+
*/
29+
30+
package cc.arduino.packages;
31+
32+
import java.util.List;
33+
34+
public interface Discovery {
35+
36+
/**
37+
* Start discovery service
38+
*
39+
* @throws Exception
40+
*/
41+
void start() throws Exception;
42+
43+
/**
44+
* Stop discovery service
45+
*/
46+
void stop() throws Exception;
47+
48+
/**
49+
* Return the list of discovered ports.
50+
*
51+
* @return
52+
*/
53+
List<BoardPort> listDiscoveredBoards();
54+
List<BoardPort> listDiscoveredBoards(boolean complete);
55+
56+
}

0 commit comments

Comments
 (0)