private async Task ConnectDisconnect(string currentState) { if (currentState.Equals("Connect")) { serialConnection = new BluetoothSerialConnection("SPP"); dev = new ELM327(serialConnection, new OBDConsoleLogger(OBDLogLevel.Debug)); while (!serialConnection.IsOpen) { try { await dev.InitializeAsync(); } catch (Exception) { } } connectionBtn.Content = "Disconnect"; } else { serialConnection.Dispose(); dev.Dispose(); connectionBtn.Content = "Connect"; } }
public void Close(ISerialConnection con) { con.Dispose(); con.Close(); }
public void Dispose() { serialConnection.Dispose(); }