mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-08 02:54:24 +01:00
Change builder domain with https and add logging
This commit is contained in:
parent
2d042820a0
commit
85e91ef079
@ -26,6 +26,8 @@ import cc.arduino.packages.BoardPort;
|
|||||||
import cc.arduino.utils.network.HttpConnectionManager;
|
import cc.arduino.utils.network.HttpConnectionManager;
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
import processing.app.debug.TargetBoard;
|
import processing.app.debug.TargetBoard;
|
||||||
import processing.app.debug.TargetPackage;
|
import processing.app.debug.TargetPackage;
|
||||||
import processing.app.debug.TargetPlatform;
|
import processing.app.debug.TargetPlatform;
|
||||||
@ -58,6 +60,7 @@ import static processing.app.I18n.tr;
|
|||||||
* know if name is proper Java package syntax.)
|
* know if name is proper Java package syntax.)
|
||||||
*/
|
*/
|
||||||
public class Platform {
|
public class Platform {
|
||||||
|
private static Logger log = LogManager.getLogger(Platform.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the default L & F. While I enjoy the bounty of the sixteen possible
|
* Set the default L & F. While I enjoy the bounty of the sixteen possible
|
||||||
@ -163,6 +166,7 @@ public class Platform {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private native String resolveDeviceAttachedToNative(String serial);
|
private native String resolveDeviceAttachedToNative(String serial);
|
||||||
|
|
||||||
private native String[] listSerialsNative();
|
private native String[] listSerialsNative();
|
||||||
|
|
||||||
public String preListAllCandidateDevices() {
|
public String preListAllCandidateDevices() {
|
||||||
@ -181,34 +185,23 @@ public class Platform {
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class BoardCloudAPIid {
|
|
||||||
public BoardCloudAPIid() { }
|
|
||||||
private String name;
|
|
||||||
private String architecture;
|
|
||||||
private String id;
|
|
||||||
public String getName() { return name; }
|
|
||||||
public String getArchitecture() { return architecture; }
|
|
||||||
public String getId() { return id; }
|
|
||||||
public void setName(String tmp) { name = tmp; }
|
|
||||||
public void setArchitecture(String tmp) { architecture = tmp; }
|
|
||||||
public void setId(String tmp) { id = tmp; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized void getBoardWithMatchingVidPidFromCloud(String vid, String pid) {
|
public synchronized void getBoardWithMatchingVidPidFromCloud(String vid, String pid) {
|
||||||
// this method is less useful in Windows < WIN10 since you need drivers to be already installed
|
// this method is less useful in Windows < WIN10 since you need drivers to be already installed
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||||
try {
|
try {
|
||||||
URL jsonUrl = new URL("http", "api-builder.arduino.cc", 80, "/builder/v1/boards/0x"+vid+"/0x"+pid);
|
URL jsonUrl = new URL(String.format("https://builder.arduino.cc/builder/v1/boards/0x%s/0x%s", vid, pid));
|
||||||
|
|
||||||
final HttpURLConnection httpConnection = new HttpConnectionManager(jsonUrl)
|
final HttpURLConnection httpConnection = new HttpConnectionManager(jsonUrl)
|
||||||
.makeConnection();
|
.makeConnection();
|
||||||
int code = httpConnection.getResponseCode();
|
int code = httpConnection.getResponseCode();
|
||||||
if (code == 404) {
|
if (code == 404) {
|
||||||
|
log.warn("Fail to get the Vid Pid information from the builder response code={}", code);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
InputStream is = httpConnection.getInputStream();
|
InputStream is = httpConnection.getInputStream();
|
||||||
BoardCloudAPIid board = mapper.readValue(is, BoardCloudAPIid.class);
|
BoardCloudAPIid board = mapper.readValue(is, BoardCloudAPIid.class);
|
||||||
|
log.info("Board info from the cloud {}", board);
|
||||||
// Launch a popup with a link to boardmanager#board.getName()
|
// Launch a popup with a link to boardmanager#board.getName()
|
||||||
// replace spaces with &
|
// replace spaces with &
|
||||||
String realBoardName = board.getName().replaceAll("\\(.*?\\)", "").trim();
|
String realBoardName = board.getName().replaceAll("\\(.*?\\)", "").trim();
|
||||||
@ -263,6 +256,58 @@ public class Platform {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class BoardCloudAPIid {
|
||||||
|
public BoardCloudAPIid() {
|
||||||
|
}
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
private String fqbn;
|
||||||
|
private String architecture;
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFqbn() {
|
||||||
|
return fqbn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getArchitecture() {
|
||||||
|
return architecture;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String tmp) {
|
||||||
|
name = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFqbn(String fqbn) {
|
||||||
|
this.fqbn = fqbn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setArchitecture(String tmp) {
|
||||||
|
architecture = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(String tmp) {
|
||||||
|
id = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "BoardCloudAPIid{" +
|
||||||
|
"name='" + name + '\'' +
|
||||||
|
", fqbn='" + fqbn + '\'' +
|
||||||
|
", architecture='" + architecture + '\'' +
|
||||||
|
", id='" + id + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public String resolveDeviceByBoardID(Map<String, TargetPackage> packages, String boardId) {
|
public String resolveDeviceByBoardID(Map<String, TargetPackage> packages, String boardId) {
|
||||||
assert packages != null;
|
assert packages != null;
|
||||||
assert boardId != null;
|
assert boardId != null;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user