1
0
mirror of https://github.com/arduino/Arduino.git synced 2024-12-01 12:24:14 +01:00

Using additional info in avahi payload to print discovered board type

This commit is contained in:
Federico Fissore 2013-06-04 17:26:31 +02:00
parent 69e6419394
commit d7c4481baa
3 changed files with 22 additions and 4 deletions

View File

@ -421,8 +421,12 @@ public class Base {
@Override
public void boardOnline(ServiceEvent serviceEvent) {
Map<String, Object> board = new HashMap<String, Object>();
board.put("hostname", serviceEvent.getName());
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);
}
});

View File

@ -1008,9 +1008,10 @@ public class Editor extends JFrame implements RunnerListener {
exception.printStackTrace();
}
for (Map.Entry<String, Map<String, Object>> entry : base.getBoardsViaNetwork().entrySet()) {
Inet4Address[] addresses = (Inet4Address[]) entry.getValue().get("addresses");
String label = addresses[0].getHostAddress() + " (" + entry.getKey() + ")";
for (Map<String, Object> board : base.getBoardsViaNetwork().values()) {
String boardName = Base.getPlatform().resolveDeviceByBoardID(Base.packages, (String) board.get("id"));
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")));
rbMenuItem.addActionListener(new SerialMenuListener(label));
serialMenu.add(rbMenuItem);

View File

@ -165,6 +165,19 @@ public class Platform {
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;
}
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .