Merge pull request #16 from espressif/fix_disconnect_connect_issue

Fix the issue for connect after disconnect
This commit is contained in:
Adwait 2022-02-25 15:04:54 +05:30 committed by GitHub
commit ae891744ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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 () => { disconnectButton.onclick = async () => {
await transport.disconnect(); if(transport)
await transport.disconnect();
term.clear(); term.clear();
connected = false; connected = false;
baudrates.style.display = "initial"; baudrates.style.display = "initial";
@ -184,6 +193,7 @@ disconnectButton.onclick = async () => {
filesDiv.style.display = "none"; filesDiv.style.display = "none";
alertDiv.style.display = "none"; alertDiv.style.display = "none";
consoleDiv.style.display = "initial"; consoleDiv.style.display = "initial";
cleanUp();
}; };
consoleStartButton.onclick = async () => { consoleStartButton.onclick = async () => {