From ea33d713435d6359f8fe32eb2c2dcc5428eeb40d Mon Sep 17 00:00:00 2001 From: Rafael Araujo Lehmkuhl Date: Fri, 12 Jan 2024 15:48:57 -0300 Subject: [PATCH] blueos: Allow fetching Mavlink2Rest version --- src/libs/blueos.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/libs/blueos.ts b/src/libs/blueos.ts index e83435fd8..e05570187 100644 --- a/src/libs/blueos.ts +++ b/src/libs/blueos.ts @@ -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 => { + 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}`) + } +} +