From f2d5f05d2b34e8ada7864a447a32343f4b4a2ed8 Mon Sep 17 00:00:00 2001 From: Adwait Patankar Date: Thu, 24 Feb 2022 16:38:07 +0530 Subject: [PATCH] Fix the issue for connect after disconnect --- index.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 1ceb76d..a36a7d1 100644 --- a/index.js +++ b/index.js @@ -172,8 +172,17 @@ function removeRow(btnName) { } } +// to be called on disconnect - remove any stale references of older connections if any +function cleanUp() { + device = null; + transport = null; + this.chip = null; +} + disconnectButton.onclick = async () => { - await transport.disconnect(); + if(transport) + await transport.disconnect(); + term.clear(); connected = false; baudrates.style.display = "initial"; @@ -184,6 +193,7 @@ disconnectButton.onclick = async () => { filesDiv.style.display = "none"; alertDiv.style.display = "none"; consoleDiv.style.display = "initial"; + cleanUp(); }; consoleStartButton.onclick = async () => {