remote: update to release feature
This commit is contained in:
parent
ec7c7a280f
commit
8cad838dd4
|
@ -39,8 +39,9 @@ public class NetworkConnector implements Closeable {
|
|||
*/
|
||||
public static final byte DISCONNECT = 14;
|
||||
public static final byte UPDATE_CONNECTOR_SOFTWARE_LATEST = 15;
|
||||
public static final byte UPDATE_FIRMWARE = 16;
|
||||
public static final byte UPDATE_FIRMWARE_LATEST = 16;
|
||||
public static final byte UPDATE_CONNECTOR_SOFTWARE_RELEASE = 17;
|
||||
public static final byte UPDATE_FIRMWARE_RELEASE = 17;
|
||||
private final static Logging log = Logging.getLogging(NetworkConnector.class);
|
||||
private boolean isClosed;
|
||||
|
||||
|
@ -147,8 +148,10 @@ public class NetworkConnector implements Closeable {
|
|||
context.onConnectorSoftwareUpdateToLatestRequest();
|
||||
} else if (connectorCommand == NetworkConnector.UPDATE_CONNECTOR_SOFTWARE_RELEASE) {
|
||||
context.onConnectorSoftwareUpdateToReleaseRequest();
|
||||
} else if (connectorCommand == NetworkConnector.UPDATE_FIRMWARE) {
|
||||
context.onFirmwareUpdateRequest();
|
||||
} else if (connectorCommand == NetworkConnector.UPDATE_FIRMWARE_LATEST) {
|
||||
context.onFirmwareUpdateToLatestRequest();
|
||||
} else if (connectorCommand == NetworkConnector.UPDATE_FIRMWARE_RELEASE) {
|
||||
context.onFirmwareUpdateToReleaseRequest();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -45,8 +45,13 @@ public class NetworkConnectorContext {
|
|||
System.exit(UPDATE_RELEASE_SBC_EXIT_CODE);
|
||||
}
|
||||
|
||||
public void onFirmwareUpdateRequest() {
|
||||
public void onFirmwareUpdateToLatestRequest() {
|
||||
log.info("onFirmwareUpdateRequest");
|
||||
System.exit(UPDATE_LATEST_FIRMWARE_EXIT_CODE);
|
||||
}
|
||||
|
||||
public void onFirmwareUpdateToReleaseRequest() {
|
||||
log.info("onFirmwareUpdateRequest");
|
||||
System.exit(UPDATE_RELEASE_FIRMWARE_EXIT_CODE);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,21 @@
|
|||
package com.rusefi.proxy.client;
|
||||
|
||||
import com.rusefi.proxy.NetworkConnector;
|
||||
|
||||
public enum UpdateType {
|
||||
CONTROLLER,
|
||||
FIRMWARE,
|
||||
CONTROLLER_RELEASE,
|
||||
CONTROLLER(NetworkConnector.UPDATE_CONNECTOR_SOFTWARE_LATEST),
|
||||
FIRMWARE(NetworkConnector.UPDATE_FIRMWARE_LATEST),
|
||||
CONTROLLER_RELEASE(NetworkConnector.UPDATE_CONNECTOR_SOFTWARE_RELEASE),
|
||||
FIRMWARE_RELEASE(NetworkConnector.UPDATE_FIRMWARE_RELEASE),
|
||||
;
|
||||
|
||||
private final byte code;
|
||||
|
||||
UpdateType(int code) {
|
||||
this.code = (byte) code;
|
||||
}
|
||||
|
||||
public byte getCode() {
|
||||
return code;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,13 +34,13 @@ public class UpdateRequestHandler implements Take {
|
|||
RqForm rqForm = new RqFormBase(req);
|
||||
|
||||
String json = rqForm.param(ProxyClient.JSON).iterator().next();
|
||||
String type = rqForm.param(ProxyClient.UPDATE_TYPE).iterator().next();
|
||||
String updateTypeString = rqForm.param(ProxyClient.UPDATE_TYPE).iterator().next();
|
||||
|
||||
ApplicationRequest applicationRequest = ApplicationRequest.valueOf(json);
|
||||
UserDetails tuner = backend.getUserDetailsResolver().apply(applicationRequest.getSessionDetails().getAuthToken());
|
||||
|
||||
ControllerKey key = new ControllerKey(applicationRequest.getVehicleOwner().getUserId(), applicationRequest.getSessionDetails().getControllerInfo());
|
||||
log.info("Online Request for " + key + ": " + type);
|
||||
log.info("Online Request for " + key + ": " + updateTypeString);
|
||||
|
||||
ControllerConnectionState state = backend.acquire(key, tuner);
|
||||
if (state == null)
|
||||
|
@ -49,13 +49,8 @@ public class UpdateRequestHandler implements Take {
|
|||
// should controller communication happen on http thread or not?
|
||||
new Thread(() -> {
|
||||
try {
|
||||
if (type.equals(UpdateType.FIRMWARE.name())) {
|
||||
state.invokeOnlineCommand(NetworkConnector.UPDATE_FIRMWARE);
|
||||
} else if (type.equals(UpdateType.CONTROLLER_RELEASE.name())) {
|
||||
state.invokeOnlineCommand(NetworkConnector.UPDATE_FIRMWARE);
|
||||
} else {
|
||||
state.invokeOnlineCommand(NetworkConnector.UPDATE_CONNECTOR_SOFTWARE_LATEST);
|
||||
}
|
||||
UpdateType type = UpdateType.valueOf(updateTypeString);
|
||||
state.invokeOnlineCommand(type.getCode());
|
||||
} catch (IOException e) {
|
||||
throw new IllegalStateException(e);
|
||||
} finally {
|
||||
|
|
|
@ -48,8 +48,6 @@ import static com.rusefi.ui.storage.PersistentConfiguration.getConfig;
|
|||
public class RemoteTab {
|
||||
private static final String APPLICATION_PORT = "application_port";
|
||||
public static final String HOWTO_REMOTE_TUNING = "https://github.com/rusefi/rusefi/wiki/HOWTO-Remote-Tuning";
|
||||
private static final String UPDATE_ECU_FIRMWARE = "Update ECU firmware";
|
||||
private static final String UPDATE_REMOTE_CONNECTOR_SOFTWARE = "Update Remote Connector Software";
|
||||
private final JComponent content = new JPanel(new BorderLayout());
|
||||
private final JScrollPane scroll = new JScrollPane(content, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
||||
|
||||
|
@ -185,24 +183,33 @@ public class RemoteTab {
|
|||
|
||||
if (publicSession.getImplementation().equals(NetworkConnector.Implementation.SBC.name())) {
|
||||
|
||||
JButton updateSoftware = new JButton(UPDATE_REMOTE_CONNECTOR_SOFTWARE);
|
||||
updateSoftware.addActionListener(new AbstractAction() {
|
||||
JPanel updateSoftwarePanel = new JPanel(new FlowLayout());
|
||||
|
||||
|
||||
JButton updateSoftwareLatest = new JButton("Update Connector to Latest");
|
||||
updateSoftwareLatest.addActionListener(new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
requestUpdate(publicSession, updateSoftware, UpdateType.CONTROLLER);
|
||||
requestUpdate(publicSession, updateSoftwareLatest, UpdateType.CONTROLLER);
|
||||
}
|
||||
});
|
||||
bottomPanel.add(updateSoftware);
|
||||
|
||||
JButton updateSoftwareRelease = new JButton("Update Connector to Release");
|
||||
updateSoftwareRelease.addActionListener(new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
requestUpdate(publicSession, updateSoftwareRelease, UpdateType.CONTROLLER_RELEASE);
|
||||
}
|
||||
});
|
||||
updateSoftwarePanel.add(updateSoftwareLatest);
|
||||
updateSoftwarePanel.add(updateSoftwareRelease);
|
||||
|
||||
bottomPanel.add(updateSoftwarePanel);
|
||||
}
|
||||
|
||||
JButton updateFirmware = new JButton(UPDATE_ECU_FIRMWARE);
|
||||
updateFirmware.addActionListener(new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
requestUpdate(publicSession, updateFirmware, UpdateType.FIRMWARE);
|
||||
}
|
||||
});
|
||||
bottomPanel.add(updateFirmware);
|
||||
JPanel updateFirmwarePanel = createUpdateFirmwarePanel(publicSession);
|
||||
|
||||
bottomPanel.add(updateFirmwarePanel);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -221,6 +228,31 @@ public class RemoteTab {
|
|||
return userPanel;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private JPanel createUpdateFirmwarePanel(PublicSession publicSession) {
|
||||
JButton updateFirmwareLatest = new JButton("Update ECU to latest");
|
||||
updateFirmwareLatest.addActionListener(new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
requestUpdate(publicSession, updateFirmwareLatest, UpdateType.FIRMWARE);
|
||||
}
|
||||
});
|
||||
|
||||
JButton updateFirmwareRelease = new JButton("Update ECU to release");
|
||||
updateFirmwareRelease.addActionListener(new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
requestUpdate(publicSession, updateFirmwareRelease, UpdateType.FIRMWARE_RELEASE);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
JPanel updateFirmwarePanel = new JPanel(new FlowLayout());
|
||||
updateFirmwarePanel.add(updateFirmwareLatest);
|
||||
updateFirmwarePanel.add(updateFirmwareRelease);
|
||||
return updateFirmwarePanel;
|
||||
}
|
||||
|
||||
private void requestUpdate(PublicSession publicSession, JButton updateSoftware, UpdateType type) {
|
||||
try {
|
||||
LocalApplicationProxy.requestSoftwareUpdate(HttpUtil.PROXY_JSON_API_HTTP_PORT,
|
||||
|
|
|
@ -76,7 +76,7 @@ public class Updater {
|
|||
public void run() {
|
||||
ConnectionAndMeta connectionAndMeta;
|
||||
try {
|
||||
connectionAndMeta = new ConnectionAndMeta(PLUGIN_BODY_JAR).invoke();
|
||||
connectionAndMeta = new ConnectionAndMeta(PLUGIN_BODY_JAR).invoke(ConnectionAndMeta.BASE_URL_LATEST);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue