mirror of
https://github.com/aljazceru/meshcore-web.git
synced 2025-12-17 16:24:18 +01:00
gracefully handle failed to connect
This commit is contained in:
@@ -6,11 +6,23 @@ import Utils from "./Utils.js";
|
|||||||
class Connection {
|
class Connection {
|
||||||
|
|
||||||
static async connectViaBluetooth() {
|
static async connectViaBluetooth() {
|
||||||
await this.connect(await BleConnection.open());
|
try {
|
||||||
|
await this.connect(await BleConnection.open());
|
||||||
|
return true;
|
||||||
|
} catch(e) {
|
||||||
|
console.log(e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static async connectViaSerial() {
|
static async connectViaSerial() {
|
||||||
await this.connect(await SerialConnection.open());
|
try {
|
||||||
|
await this.connect(await SerialConnection.open());
|
||||||
|
return true;
|
||||||
|
} catch(e) {
|
||||||
|
console.log(e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static async connect(connection) {
|
static async connect(connection) {
|
||||||
|
|||||||
Reference in New Issue
Block a user