fix: handle serial port disconnect
This commit is contained in:
parent
6b57c8b2a7
commit
e20cfd3e6d
1 changed files with 4 additions and 3 deletions
|
|
@ -69,7 +69,8 @@ async function serialSigner(path) {
|
||||||
})
|
})
|
||||||
|
|
||||||
navigator.serial.addEventListener('disconnect', () => {
|
navigator.serial.addEventListener('disconnect', () => {
|
||||||
console.log('### navigator.serial event: disconnected!', event)
|
console.log('### navigator.serial event: disconnected!')
|
||||||
|
this.selectedPort = null
|
||||||
this.hww.authenticated = false
|
this.hww.authenticated = false
|
||||||
this.$q.notify({
|
this.$q.notify({
|
||||||
type: 'warning',
|
type: 'warning',
|
||||||
|
|
@ -113,14 +114,13 @@ async function serialSigner(path) {
|
||||||
/* Ignore the error */
|
/* Ignore the error */
|
||||||
})
|
})
|
||||||
if (this.selectedPort) await this.selectedPort.close()
|
if (this.selectedPort) await this.selectedPort.close()
|
||||||
this.selectedPort = null
|
|
||||||
this.$q.notify({
|
this.$q.notify({
|
||||||
type: 'positive',
|
type: 'positive',
|
||||||
message: 'Serial port disconnected!',
|
message: 'Serial port disconnected!',
|
||||||
timeout: 5000
|
timeout: 5000
|
||||||
})
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.selectedPort = null
|
|
||||||
this.$q.notify({
|
this.$q.notify({
|
||||||
type: 'warning',
|
type: 'warning',
|
||||||
message: 'Cannot close serial port!',
|
message: 'Cannot close serial port!',
|
||||||
|
|
@ -128,6 +128,7 @@ async function serialSigner(path) {
|
||||||
timeout: 10000
|
timeout: 10000
|
||||||
})
|
})
|
||||||
} finally {
|
} finally {
|
||||||
|
this.selectedPort = null
|
||||||
this.hww.authenticated = false
|
this.hww.authenticated = false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue