From 23c95e883760db30b98d0b65a65a85cc5eb3597d Mon Sep 17 00:00:00 2001 From: Jakob Stendahl Date: Tue, 12 Jan 2021 10:43:03 +0100 Subject: :bug: Disconnect on error --- script.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'script.js') diff --git a/script.js b/script.js index 3763ec8..85b5d61 100644 --- a/script.js +++ b/script.js @@ -189,8 +189,10 @@ document.getElementById("btn_connect").onclick = async () => { document.querySelector(".info-device").classList.remove("connected"); document.querySelector(".connection-status").innerHTML = "DISCONNECTED"; clearInterval(connCheckInterval); + device.gatt.disconnect(); } } else { + clearInterval(connCheckInterval); alert("FATAL ERROR, Please reload page..."); clearInterval(connCheckInterval); } @@ -232,12 +234,11 @@ document.getElementById("btn_connect").onclick = async () => { "T" + hoverControl.getThrottle() + "R" + hoverControl.getRudder() + "A" + (hoverControl.getArm() ? "1" : "0") + - "S0" + // Sending this one because my decoding-code is a bit buggy currently. ":"; - console.log(command); await services.uartService.sendText(command); } else { - clearInterval(sendCommands) + clearInterval(sendCommands); + device.gatt.disconnect(); } } }, 50); -- cgit v1.2.3