diff --git a/photon-core/src/main/java/org/photonvision/common/configuration/NetworkConfig.java b/photon-core/src/main/java/org/photonvision/common/configuration/NetworkConfig.java index fd4890a31b..c18768f7b2 100644 --- a/photon-core/src/main/java/org/photonvision/common/configuration/NetworkConfig.java +++ b/photon-core/src/main/java/org/photonvision/common/configuration/NetworkConfig.java @@ -21,12 +21,8 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.util.HashMap; -import java.util.Map; import org.photonvision.common.hardware.Platform; import org.photonvision.common.networking.NetworkMode; -import org.photonvision.common.util.file.JacksonUtils; public class NetworkConfig { // Can be an integer team number, or an IP address @@ -104,17 +100,6 @@ public NetworkConfig(NetworkConfig config) { config.matchCamerasOnlyByPath); } - public Map toHashMap() { - try { - var ret = new ObjectMapper().convertValue(this, JacksonUtils.UIMap.class); - ret.put("canManage", this.deviceCanManageNetwork()); - return ret; - } catch (Exception e) { - e.printStackTrace(); - return new HashMap<>(); - } - } - @JsonIgnore public String getPhysicalInterfaceName() { return this.networkManagerIface; @@ -125,18 +110,12 @@ public String getEscapedInterfaceName() { return "\"" + networkManagerIface + "\""; } - @JsonIgnore - public boolean shouldManage() { - return this.shouldManage; - } - - @JsonIgnore public void setShouldManage(boolean shouldManage) { this.shouldManage = shouldManage && this.deviceCanManageNetwork(); } @JsonIgnore - private boolean deviceCanManageNetwork() { + protected boolean deviceCanManageNetwork() { return Platform.isLinux(); } diff --git a/photon-core/src/main/java/org/photonvision/common/dataflow/websocket/UINetConfig.java b/photon-core/src/main/java/org/photonvision/common/dataflow/websocket/UINetConfig.java index b9cc906c69..dd146b7df3 100644 --- a/photon-core/src/main/java/org/photonvision/common/dataflow/websocket/UINetConfig.java +++ b/photon-core/src/main/java/org/photonvision/common/dataflow/websocket/UINetConfig.java @@ -27,8 +27,10 @@ public UINetConfig( super(config); this.networkInterfaceNames = networkInterfaceNames; this.networkingDisabled = networkingDisabled; + this.canManage = this.deviceCanManageNetwork(); } public List networkInterfaceNames; public boolean networkingDisabled; + public boolean canManage; } diff --git a/photon-core/src/main/java/org/photonvision/common/networking/NetworkManager.java b/photon-core/src/main/java/org/photonvision/common/networking/NetworkManager.java index e2f44103ff..9a543c4962 100644 --- a/photon-core/src/main/java/org/photonvision/common/networking/NetworkManager.java +++ b/photon-core/src/main/java/org/photonvision/common/networking/NetworkManager.java @@ -113,7 +113,7 @@ public void initialize(boolean shouldManage) { } public void reinitialize() { - initialize(ConfigManager.getInstance().getConfig().getNetworkConfig().shouldManage()); + initialize(ConfigManager.getInstance().getConfig().getNetworkConfig().shouldManage); DataChangeService.getInstance() .publishEvent(