Skip to content

Commit e138d85

Browse files
nicoschmdtpatrickelectric
authored andcommitted
frontend: wizard: add board detection helper
1 parent 4b97af5 commit e138d85

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

core/frontend/src/components/wizard/Wizard.vue

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
class="ma-2"
9090
dense
9191
>
92-
No flight controller detected.
92+
{{ board_detection_message }}
9393
</v-alert>
9494
<div class="d-flex justify-space-between">
9595
<model-viewer
@@ -396,6 +396,7 @@ export default Vue.extend({
396396
model_viewer_supported: MODEL_VIEWER_SUPPORTED,
397397
model_viewer_ready: false,
398398
board_not_detected: false,
399+
board_detection_message: 'No flight controller detected.',
399400
}
400401
},
401402
computed: {
@@ -537,12 +538,9 @@ export default Vue.extend({
537538
this.retry_count += 1
538539
},
539540
async setupBoat() {
540-
await fetchCurrentBoard()
541-
if (!autopilot.current_board) {
542-
this.board_not_detected = true
541+
if (!await this.isBoardDetected()) {
543542
return
544543
}
545-
this.board_not_detected = false
546544
this.vehicle_type = Vehicle.Rover
547545
this.vehicle_name = 'BlueBoat'
548546
this.vehicle_image = '/assets/vehicles/images/bb120.png'
@@ -603,12 +601,9 @@ export default Vue.extend({
603601
}
604602
},
605603
async setupROV() {
606-
await fetchCurrentBoard()
607-
if (!autopilot.current_board) {
608-
this.board_not_detected = true
604+
if (!await this.isBoardDetected()) {
609605
return
610606
}
611-
this.board_not_detected = false
612607
this.vehicle_type = Vehicle.Sub
613608
this.vehicle_name = 'BlueROV'
614609
this.vehicle_image = '/assets/vehicles/images/bluerov2.png'
@@ -683,8 +678,7 @@ export default Vue.extend({
683678
.catch((error) => `Failed to disable smart wifi hotspot: ${error.message ?? error.response?.data}.`)
684679
},
685680
async installLatestStableFirmware(vehicle: Vehicle): Promise<ConfigurationStatus> {
686-
await fetchCurrentBoard()
687-
if (!autopilot.current_board) {
681+
if (!await this.isBoardDetected()) {
688682
return 'No flight controller board detected.'
689683
}
690684
@@ -773,6 +767,22 @@ export default Vue.extend({
773767
validateParams(): boolean {
774768
return this.$refs.param_loader?.validateParams()
775769
},
770+
async isBoardDetected(): Promise<boolean> {
771+
try {
772+
await fetchCurrentBoard()
773+
} catch (error) {
774+
this.board_not_detected = true
775+
this.board_detection_message = `Failed to communicate with autopilot manager: ${error}`
776+
return false
777+
}
778+
if (!autopilot.current_board) {
779+
this.board_not_detected = true
780+
this.board_detection_message = 'No flight controller detected.'
781+
return false
782+
}
783+
this.board_not_detected = false
784+
return true
785+
},
776786
},
777787
})
778788
</script>

0 commit comments

Comments
 (0)