|
89 | 89 | class="ma-2" |
90 | 90 | dense |
91 | 91 | > |
92 | | - No flight controller detected. |
| 92 | + {{ board_detection_message }} |
93 | 93 | </v-alert> |
94 | 94 | <div class="d-flex justify-space-between"> |
95 | 95 | <model-viewer |
@@ -396,6 +396,7 @@ export default Vue.extend({ |
396 | 396 | model_viewer_supported: MODEL_VIEWER_SUPPORTED, |
397 | 397 | model_viewer_ready: false, |
398 | 398 | board_not_detected: false, |
| 399 | + board_detection_message: 'No flight controller detected.', |
399 | 400 | } |
400 | 401 | }, |
401 | 402 | computed: { |
@@ -537,12 +538,9 @@ export default Vue.extend({ |
537 | 538 | this.retry_count += 1 |
538 | 539 | }, |
539 | 540 | async setupBoat() { |
540 | | - await fetchCurrentBoard() |
541 | | - if (!autopilot.current_board) { |
542 | | - this.board_not_detected = true |
| 541 | + if (!await this.isBoardDetected()) { |
543 | 542 | return |
544 | 543 | } |
545 | | - this.board_not_detected = false |
546 | 544 | this.vehicle_type = Vehicle.Rover |
547 | 545 | this.vehicle_name = 'BlueBoat' |
548 | 546 | this.vehicle_image = '/assets/vehicles/images/bb120.png' |
@@ -603,12 +601,9 @@ export default Vue.extend({ |
603 | 601 | } |
604 | 602 | }, |
605 | 603 | async setupROV() { |
606 | | - await fetchCurrentBoard() |
607 | | - if (!autopilot.current_board) { |
608 | | - this.board_not_detected = true |
| 604 | + if (!await this.isBoardDetected()) { |
609 | 605 | return |
610 | 606 | } |
611 | | - this.board_not_detected = false |
612 | 607 | this.vehicle_type = Vehicle.Sub |
613 | 608 | this.vehicle_name = 'BlueROV' |
614 | 609 | this.vehicle_image = '/assets/vehicles/images/bluerov2.png' |
@@ -683,8 +678,7 @@ export default Vue.extend({ |
683 | 678 | .catch((error) => `Failed to disable smart wifi hotspot: ${error.message ?? error.response?.data}.`) |
684 | 679 | }, |
685 | 680 | async installLatestStableFirmware(vehicle: Vehicle): Promise<ConfigurationStatus> { |
686 | | - await fetchCurrentBoard() |
687 | | - if (!autopilot.current_board) { |
| 681 | + if (!await this.isBoardDetected()) { |
688 | 682 | return 'No flight controller board detected.' |
689 | 683 | } |
690 | 684 |
|
@@ -773,6 +767,22 @@ export default Vue.extend({ |
773 | 767 | validateParams(): boolean { |
774 | 768 | return this.$refs.param_loader?.validateParams() |
775 | 769 | }, |
| 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 | + }, |
776 | 786 | }, |
777 | 787 | }) |
778 | 788 | </script> |
|
0 commit comments