Skip to content

Commit

Permalink
mavlink-message-actions: Fix parsing of data-lake variables
Browse files Browse the repository at this point in the history
- Cast boolean variables to ones and zeroes (which is how MAVLink encodes booleans).
- Update reference to action for every callback run
  • Loading branch information
rafaellehmkuhl authored and ArturoManzoli committed Nov 21, 2024
1 parent 591705c commit 3d70e3c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/libs/actions/mavlink-message-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,12 @@ export const saveMavlinkMessageActionConfigs = (): void => {
export type MavlinkMessageActionCallback = () => void

export const getMavlinkMessageActionCallback = (id: string): MavlinkMessageActionCallback => {
const action = getMavlinkMessageActionConfig(id)
if (!action) {
throw new Error(`Action with id ${id} not found.`)
}

return () => {
const action = getMavlinkMessageActionConfig(id)
if (!action) {
throw new Error(`Action with id ${id} not found.`)
}

const message: Message = {
type: action.messageType,
...processMessageConfig(action.messageConfig),
Expand All @@ -144,7 +144,7 @@ const processMessageConfig = (config: MavlinkMessageConfig): Record<string, any>
if (typeof v.value === 'string' && v.value.startsWith('{{') && v.value.endsWith('}}')) {
const variableName = v.value.slice(2, -2).trim()
const variableValue = getCockpitActionVariableData(variableName)
processedConfig[k] = variableValue
processedConfig[k] = typeof variableValue === 'boolean' ? (variableValue ? 1 : 0) : variableValue
} else if (v.type === MessageFieldType.TYPE_STRUCT_ENUM) {
processedConfig[k] = { type: v.value }
} else if (v.type === MessageFieldType.NUMBER) {
Expand Down

0 comments on commit 3d70e3c

Please sign in to comment.