diff options
author | Jakob Stendahl <jakobste@uio.no> | 2021-01-12 10:43:03 +0100 |
---|---|---|
committer | Jakob Stendahl <jakobste@uio.no> | 2021-01-12 10:43:03 +0100 |
commit | 23c95e883760db30b98d0b65a65a85cc5eb3597d (patch) | |
tree | 2e04c4c35a6d0eaa609bf0828136a155eb5186f1 /script.js | |
parent | 365d19cdd6cc8d4c8518976252b0d9cfe1dc387d (diff) | |
download | hoverbit-ble-23c95e883760db30b98d0b65a65a85cc5eb3597d.tar.gz hoverbit-ble-23c95e883760db30b98d0b65a65a85cc5eb3597d.zip |
:bug: Disconnect on error
Diffstat (limited to 'script.js')
-rw-r--r-- | script.js | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -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); |