mirror of
https://github.com/arduino/Arduino.git
synced 2024-12-02 13:24:12 +01:00
Using additional info in avahi payload to print discovered board type
This commit is contained in:
parent
69e6419394
commit
d7c4481baa
@ -421,8 +421,12 @@ public class Base {
|
|||||||
@Override
|
@Override
|
||||||
public void boardOnline(ServiceEvent serviceEvent) {
|
public void boardOnline(ServiceEvent serviceEvent) {
|
||||||
Map<String, Object> board = new HashMap<String, Object>();
|
Map<String, Object> board = new HashMap<String, Object>();
|
||||||
|
board.put("hostname", serviceEvent.getName());
|
||||||
board.put("addresses", serviceEvent.getInfo().getInet4Addresses());
|
board.put("addresses", serviceEvent.getInfo().getInet4Addresses());
|
||||||
board.put("type", serviceEvent.getType());
|
if (serviceEvent.getInfo().hasData()) {
|
||||||
|
board.put("id", serviceEvent.getInfo().getPropertyString("board"));
|
||||||
|
board.put("distro_version", serviceEvent.getInfo().getPropertyString("distro_version"));
|
||||||
|
}
|
||||||
Base.this.boardsViaNetwork.put(serviceEvent.getName(), board);
|
Base.this.boardsViaNetwork.put(serviceEvent.getName(), board);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1008,9 +1008,10 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
exception.printStackTrace();
|
exception.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Map.Entry<String, Map<String, Object>> entry : base.getBoardsViaNetwork().entrySet()) {
|
for (Map<String, Object> board : base.getBoardsViaNetwork().values()) {
|
||||||
Inet4Address[] addresses = (Inet4Address[]) entry.getValue().get("addresses");
|
String boardName = Base.getPlatform().resolveDeviceByBoardID(Base.packages, (String) board.get("id"));
|
||||||
String label = addresses[0].getHostAddress() + " (" + entry.getKey() + ")";
|
Inet4Address[] addresses = (Inet4Address[]) board.get("addresses");
|
||||||
|
String label = board.get("hostname") + "@" + addresses[0].getHostAddress() + " (" + boardName + ")";
|
||||||
JCheckBoxMenuItem rbMenuItem = new JCheckBoxMenuItem(label, label.equals(Preferences.get("serial.port")));
|
JCheckBoxMenuItem rbMenuItem = new JCheckBoxMenuItem(label, label.equals(Preferences.get("serial.port")));
|
||||||
rbMenuItem.addActionListener(new SerialMenuListener(label));
|
rbMenuItem.addActionListener(new SerialMenuListener(label));
|
||||||
serialMenu.add(rbMenuItem);
|
serialMenu.add(rbMenuItem);
|
||||||
|
@ -165,6 +165,19 @@ public class Platform {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String resolveDeviceByBoardID(Map<String, TargetPackage> packages, String boardId) {
|
||||||
|
for (TargetPackage targetPackage : packages.values()) {
|
||||||
|
for (TargetPlatform targetPlatform : targetPackage.getPlatforms().values()) {
|
||||||
|
for (TargetBoard board : targetPlatform.getBoards().values()) {
|
||||||
|
if (boardId.equals(board.getId())) {
|
||||||
|
return board.getName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user