aboutsummaryrefslogtreecommitdiff
path: root/script.js
diff options
context:
space:
mode:
authorJakob Stendahl <jakobste@uio.no>2021-01-12 10:43:03 +0100
committerJakob Stendahl <jakobste@uio.no>2021-01-12 10:43:03 +0100
commit23c95e883760db30b98d0b65a65a85cc5eb3597d (patch)
tree2e04c4c35a6d0eaa609bf0828136a155eb5186f1 /script.js
parent365d19cdd6cc8d4c8518976252b0d9cfe1dc387d (diff)
downloadhoverbit-ble-23c95e883760db30b98d0b65a65a85cc5eb3597d.tar.gz
hoverbit-ble-23c95e883760db30b98d0b65a65a85cc5eb3597d.zip
:bug: Disconnect on error
Diffstat (limited to 'script.js')
-rw-r--r--script.js7
1 files changed, 4 insertions, 3 deletions
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);