mirror of
https://github.com/aljazceru/meshcore-web.git
synced 2025-12-18 16:44:21 +01:00
show error message if failed to connect to device
This commit is contained in:
@@ -10,9 +10,20 @@ class Connection {
|
|||||||
await this.connect(await BleConnection.open());
|
await this.connect(await BleConnection.open());
|
||||||
return true;
|
return true;
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
|
|
||||||
console.log(e);
|
console.log(e);
|
||||||
|
|
||||||
|
// ignore device not selected error
|
||||||
|
if(e.name === "NotFoundError"){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// show error message
|
||||||
|
alert("failed to connect to ble device!");
|
||||||
|
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static async connectViaSerial() {
|
static async connectViaSerial() {
|
||||||
@@ -20,9 +31,20 @@ class Connection {
|
|||||||
await this.connect(await SerialConnection.open());
|
await this.connect(await SerialConnection.open());
|
||||||
return true;
|
return true;
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
|
|
||||||
console.log(e);
|
console.log(e);
|
||||||
|
|
||||||
|
// ignore device not selected error
|
||||||
|
if(e.name === "NotFoundError"){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// show error message
|
||||||
|
alert("failed to connect to serial device!");
|
||||||
|
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static async connect(connection) {
|
static async connect(connection) {
|
||||||
|
|||||||
Reference in New Issue
Block a user