From cb5dfccb719ce667db9802b500fd268f4defc0ab Mon Sep 17 00:00:00 2001 From: Rafael Araujo Lehmkuhl Date: Thu, 21 Nov 2024 00:27:59 -0300 Subject: [PATCH] joystick-config: Fix warning about manual-control message not being supported It was mistakenly warning about the `MANUAL_CONTROL` message not being supported when it failed to fetch the information from BlueOS. --- src/views/ConfigurationJoystickView.vue | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/views/ConfigurationJoystickView.vue b/src/views/ConfigurationJoystickView.vue index 665166507..cd40b38e3 100644 --- a/src/views/ConfigurationJoystickView.vue +++ b/src/views/ConfigurationJoystickView.vue @@ -592,20 +592,11 @@ const controllerStore = useControllerStore() const { globalAddress } = useMainVehicleStore() const interfaceStore = useAppInterfaceStore() -const m2rSupportsExtendedManualControl = ref() -const ardupilotSupportsExtendedManualControl = ref() const showJoystickWarningMessage = ref(false) onMounted(async () => { controllerStore.enableForwarding = false - const m2rVersion = await getMavlink2RestVersion(globalAddress) - m2rSupportsExtendedManualControl.value = semver.gte(m2rVersion, '0.11.19') - const ardupilotVersion = await getArdupilotVersion(globalAddress) - ardupilotSupportsExtendedManualControl.value = semver.gte(ardupilotVersion, '4.1.2') - - if (m2rSupportsExtendedManualControl.value || ardupilotSupportsExtendedManualControl.value) { - showJoystickWarningMessage.value = true - } + warnIfJoystickDoesNotSupportExtendedManualControl() }) // Does not let the joystick forwarding to be enabled while the user is in this page @@ -658,6 +649,20 @@ const filteredProtocols = protocols.filter( (protocol) => protocol === JoystickProtocol.MAVLinkManualControl || protocol === JoystickProtocol.CockpitAction ) +const warnIfJoystickDoesNotSupportExtendedManualControl = async (): Promise => { + try { + const m2rVersion = await getMavlink2RestVersion(globalAddress) + const m2rSupportsExtendedManualControl = semver.gte(m2rVersion, '0.11.19') + const ardupilotVersion = await getArdupilotVersion(globalAddress) + const ardupilotSupportsExtendedManualControl = semver.gte(ardupilotVersion, '4.1.2') + + showJoystickWarningMessage.value = !m2rSupportsExtendedManualControl || !ardupilotSupportsExtendedManualControl + } catch (error) { + console.error(`Error getting Mavlink2Rest or Ardupilot version. ${error}. Will try again in 10 seconds.`) + setTimeout(warnIfJoystickDoesNotSupportExtendedManualControl, 10000) + } +} + const sortJoystickActions = (protocol: string): JoystickAction[] => { const searchTerm = searchTermsJoy[protocol].toLowerCase() || '' return buttonActionsToShow.value