From 7604b05a006c6c7defb6aa52508249db3fff877a Mon Sep 17 00:00:00 2001 From: J Blackman Date: Wed, 1 Feb 2023 03:50:55 +1100 Subject: [PATCH] Enable retrieval of the BUILD_KEY using MSP2 (#12264) * Enable retrieval of the BUILD_KEY using MSP2 * Repositioning --- src/main/build/version.c | 6 ++++++ src/main/build/version.h | 2 ++ src/main/cli/cli.c | 2 +- src/main/msp/msp.c | 6 +++++- src/main/msp/msp_protocol_v2_betaflight.h | 1 + 5 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/main/build/version.c b/src/main/build/version.c index 99d5c45d8f..a9fc58e561 100644 --- a/src/main/build/version.c +++ b/src/main/build/version.c @@ -26,3 +26,9 @@ const char * const targetName = __TARGET__; const char * const shortGitRevision = __REVISION__; const char * const buildDate = __DATE__; const char * const buildTime = __TIME__; + +#ifdef BUILD_KEY +const char * const buildKey = STR(BUILD_KEY); +#else +const char * const buildKey = " "; +#endif diff --git a/src/main/build/version.h b/src/main/build/version.h index 248c064758..72b48a5945 100644 --- a/src/main/build/version.h +++ b/src/main/build/version.h @@ -42,3 +42,5 @@ extern const char* const buildDate; // "MMM DD YYYY" MMM = Jan/Feb/... extern const char* const buildTime; // "HH:MM:SS" #define MSP_API_VERSION_STRING STR(API_VERSION_MAJOR) "." STR(API_VERSION_MINOR) + +extern const char* const buildKey; diff --git a/src/main/cli/cli.c b/src/main/cli/cli.c index 94bb7fd363..88711a6373 100644 --- a/src/main/cli/cli.c +++ b/src/main/cli/cli.c @@ -4815,7 +4815,7 @@ static void cliStatus(const char *cmdName, char *cmdline) #endif #ifdef BUILD_KEY - cliPrintf("BUILD KEY: %s", STR(BUILD_KEY)); + cliPrintf("BUILD KEY: %s", buildKey); #ifdef RELEASE_NAME cliPrintf(" (%s)", STR(RELEASE_NAME)); #endif diff --git a/src/main/msp/msp.c b/src/main/msp/msp.c index 7662e98a3c..553e7e03af 100644 --- a/src/main/msp/msp.c +++ b/src/main/msp/msp.c @@ -2522,7 +2522,7 @@ static mspResult_e mspFcProcessOutCommandWithArg(mspDescriptor_t srcDesc, int16_ // type byte, then length byte followed by the actual characters const uint8_t textType = sbufBytesRemaining(src) ? sbufReadU8(src) : 0; - char* textVar; + const char *textVar; switch (textType) { case MSP2TEXT_PILOT_NAME: @@ -2541,6 +2541,10 @@ static mspResult_e mspFcProcessOutCommandWithArg(mspDescriptor_t srcDesc, int16_ textVar = currentControlRateProfile->profileName; break; + case MSP2TEXT_BUILDKEY: + textVar = buildKey; + break; + default: return MSP_RESULT_ERROR; } diff --git a/src/main/msp/msp_protocol_v2_betaflight.h b/src/main/msp/msp_protocol_v2_betaflight.h index f59d4a6128..a2906c95a4 100644 --- a/src/main/msp/msp_protocol_v2_betaflight.h +++ b/src/main/msp/msp_protocol_v2_betaflight.h @@ -32,3 +32,4 @@ #define MSP2TEXT_CRAFT_NAME 2 #define MSP2TEXT_PID_PROFILE_NAME 3 #define MSP2TEXT_RATE_PROFILE_NAME 4 +#define MSP2TEXT_BUILDKEY 5