Skip to content

Commit

Permalink
blueos: Allow fetching Mavlink2Rest version
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaellehmkuhl authored and patrickelectric committed Jan 31, 2024
1 parent 70133a9 commit ea33d71
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/libs/blueos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,19 @@ export const getIpsInformationFromVehicle = async (vehicleAddress: string): Prom
throw new Error(`Could not get information about IPs on BlueOS. ${error}`)
}
}

/* eslint-disable jsdoc/require-jsdoc */
type RawM2rServiceInfo = { name: string; version: string; sha: string; build_date: string; authors: string }
type RawM2rInfo = { version: number; service: RawM2rServiceInfo }
/* eslint-enable jsdoc/require-jsdoc */

export const getMavlink2RestVersion = async (vehicleAddress: string): Promise<string> => {
try {
const url = `http://${vehicleAddress}/mavlink2rest/info`
const m2rRawInfo: RawM2rInfo = await ky.get(url, { timeout: 5000 }).json()
return m2rRawInfo.service.version
} catch (error) {
throw new Error(`Could not get Mavlink2Rest version. ${error}`)
}
}

0 comments on commit ea33d71

Please sign in to comment.