REO progress

This commit is contained in:
rusefi 2020-08-15 15:34:50 -04:00
parent 10db154a21
commit e77e7bd7d2
4 changed files with 20 additions and 3 deletions

View File

@ -5,7 +5,9 @@ import com.rusefi.Listener;
import com.rusefi.Timeouts; import com.rusefi.Timeouts;
import com.rusefi.binaryprotocol.BinaryProtocol; import com.rusefi.binaryprotocol.BinaryProtocol;
import com.rusefi.binaryprotocol.IncomingDataBuffer; import com.rusefi.binaryprotocol.IncomingDataBuffer;
import com.rusefi.config.generated.Fields;
import com.rusefi.io.IoStream; import com.rusefi.io.IoStream;
import com.rusefi.proxy.NetworkConnector;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
@ -55,6 +57,9 @@ public class BinaryProtocolProxy {
continue; continue;
} }
BinaryProtocolServer.Packet clientRequest = readClientRequest(clientStream.getDataBuffer(), firstByte); BinaryProtocolServer.Packet clientRequest = readClientRequest(clientStream.getDataBuffer(), firstByte);
byte[] packet = clientRequest.getPacket();
if (packet.length > 1 && packet[0] == Fields.TS_ONLINE_PROTOCOL && packet[1] == NetworkConnector.DISCONNECT)
throw new IOException("User requested disconnect");
/** /**
* Two reasons for synchronization: * Two reasons for synchronization:

View File

@ -33,6 +33,7 @@ import static com.rusefi.binaryprotocol.BinaryProtocol.sleep;
* see NetworkConnectorStartup * see NetworkConnectorStartup
*/ */
public class NetworkConnector implements Closeable { public class NetworkConnector implements Closeable {
public static final byte DISCONNECT = 14;
public static final byte UPDATE_CONNECTOR_SOFTWARE = 15; public static final byte UPDATE_CONNECTOR_SOFTWARE = 15;
public static final byte UPDATE_FIRMWARE = 16; public static final byte UPDATE_FIRMWARE = 16;
private final static Logging log = Logging.getLogging(NetworkConnector.class); private final static Logging log = Logging.getLogging(NetworkConnector.class);

View File

@ -2,6 +2,7 @@ package com.rusefi.proxy.client;
import com.devexperts.logging.Logging; import com.devexperts.logging.Logging;
import com.rusefi.NamedThreadFactory; import com.rusefi.NamedThreadFactory;
import com.rusefi.config.generated.Fields;
import com.rusefi.io.IoStream; import com.rusefi.io.IoStream;
import com.rusefi.io.commands.GetOutputsCommand; import com.rusefi.io.commands.GetOutputsCommand;
import com.rusefi.io.commands.HelloCommand; import com.rusefi.io.commands.HelloCommand;
@ -10,6 +11,7 @@ import com.rusefi.io.serial.StreamStatistics;
import com.rusefi.io.tcp.BinaryProtocolProxy; import com.rusefi.io.tcp.BinaryProtocolProxy;
import com.rusefi.io.tcp.ServerSocketReference; import com.rusefi.io.tcp.ServerSocketReference;
import com.rusefi.io.tcp.TcpIoStream; import com.rusefi.io.tcp.TcpIoStream;
import com.rusefi.proxy.NetworkConnector;
import com.rusefi.server.ApplicationRequest; import com.rusefi.server.ApplicationRequest;
import com.rusefi.server.rusEFISSLContext; import com.rusefi.server.rusEFISSLContext;
import com.rusefi.tools.online.HttpUtil; import com.rusefi.tools.online.HttpUtil;
@ -133,6 +135,13 @@ public class LocalApplicationProxy implements Closeable {
@Override @Override
public void close() { public void close() {
serverHolder.close(); serverHolder.close();
byte[] request = new byte[2];
request[0] = Fields.TS_ONLINE_PROTOCOL;
request[1] = NetworkConnector.DISCONNECT;
try {
authenticatorToProxyStream.sendPacket(request);
} catch (IOException ignored) {
}
authenticatorToProxyStream.close(); authenticatorToProxyStream.close();
} }

View File

@ -118,7 +118,8 @@ public class RemoteTab {
if (currentState == null) { if (currentState == null) {
requestListDownload(); requestListDownload();
} else { } else {
setConnectedStatus(currentState.getApplicationRequest().getVehicleOwner(), null); setConnectedStatus(currentState.getApplicationRequest().getVehicleOwner(), null,
currentState.getApplicationRequest().getSessionDetails().getControllerInfo());
} }
} }
@ -209,7 +210,7 @@ public class RemoteTab {
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
@Override @Override
public void run() { public void run() {
setConnectedStatus(publicSession.getVehicleOwner(), authenticatorToProxyStream); setConnectedStatus(publicSession.getVehicleOwner(), authenticatorToProxyStream, publicSession.getControllerInfo());
} }
}); });
}; };
@ -219,13 +220,14 @@ public class RemoteTab {
}, "Authenticator").start(); }, "Authenticator").start();
} }
private void setConnectedStatus(UserDetails userDetails, StreamStatistics authenticatorToProxyStream) { private void setConnectedStatus(UserDetails userDetails, StreamStatistics authenticatorToProxyStream, ControllerInfo controllerInfo) {
if (authenticatorToProxyStream != null) { if (authenticatorToProxyStream != null) {
streamStatusControl = new StreamStatusControl(authenticatorToProxyStream); streamStatusControl = new StreamStatusControl(authenticatorToProxyStream);
} }
setStatus("Connected to " + userDetails.getUserName(), setStatus("Connected to " + userDetails.getUserName(),
new JLabel("You can now connect your TunerStudio to IP address localhost and port " + getLocalPort()), new JLabel("You can now connect your TunerStudio to IP address localhost and port " + getLocalPort()),
new URLLabel(SignatureHelper.getUrl(controllerInfo.getSignature())),
disconnect, streamStatusControl == null ? null : streamStatusControl.getContent()); disconnect, streamStatusControl == null ? null : streamStatusControl.getContent());
} }