Skip to content

Commit

Permalink
joystick-config: Fix warning about manual-control message not being s…
Browse files Browse the repository at this point in the history
…upported

It was mistakenly warning about the `MANUAL_CONTROL` message not being supported when it failed to fetch the information from BlueOS.
  • Loading branch information
rafaellehmkuhl committed Nov 21, 2024
1 parent a44a54e commit cb5dfcc
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/views/ConfigurationJoystickView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -592,20 +592,11 @@ const controllerStore = useControllerStore()
const { globalAddress } = useMainVehicleStore()
const interfaceStore = useAppInterfaceStore()
const m2rSupportsExtendedManualControl = ref<boolean>()
const ardupilotSupportsExtendedManualControl = ref<boolean>()
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
Expand Down Expand Up @@ -658,6 +649,20 @@ const filteredProtocols = protocols.filter(
(protocol) => protocol === JoystickProtocol.MAVLinkManualControl || protocol === JoystickProtocol.CockpitAction
)
const warnIfJoystickDoesNotSupportExtendedManualControl = async (): Promise<void> => {
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
Expand Down

0 comments on commit cb5dfcc

Please sign in to comment.