From f0b6fcea6ef77c9a54ab11767593f9a8798e3662 Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Thu, 22 Feb 2024 11:30:23 -0800 Subject: [PATCH] [cli-tcat] define `VendorInfo` as a member variable (#9869) Changes `mVendorInfo` to be a member variable of `Tcat` class instead of a static variable. --- src/cli/cli_tcat.cpp | 12 ++++++------ src/cli/cli_tcat.hpp | 4 ++++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/cli/cli_tcat.cpp b/src/cli/cli_tcat.cpp index 491aaf6c03e..7845be89bdd 100644 --- a/src/cli/cli_tcat.cpp +++ b/src/cli/cli_tcat.cpp @@ -79,9 +79,8 @@ namespace ot { namespace Cli { -otTcatVendorInfo sVendorInfo; -const char kPskdVendor[] = "J01NM3"; -const char kUrl[] = "dummy_url"; +const char kPskdVendor[] = "J01NM3"; +const char kUrl[] = "dummy_url"; static void HandleBleSecureReceive(otInstance *aInstance, const otMessage *aMessage, @@ -116,8 +115,9 @@ template <> otError Tcat::Process(Arg aArgs[]) otError error = OT_ERROR_NONE; - sVendorInfo.mPskdString = kPskdVendor; - sVendorInfo.mProvisioningUrl = kUrl; + ClearAllBytes(mVendorInfo); + mVendorInfo.mPskdString = kPskdVendor; + mVendorInfo.mProvisioningUrl = kUrl; otBleSecureSetCertificate(GetInstancePtr(), reinterpret_cast(OT_CLI_TCAT_X509_CERT), sizeof(OT_CLI_TCAT_X509_CERT), reinterpret_cast(OT_CLI_TCAT_PRIV_KEY), @@ -130,7 +130,7 @@ template <> otError Tcat::Process(Arg aArgs[]) otBleSecureSetSslAuthMode(GetInstancePtr(), true); SuccessOrExit(error = otBleSecureStart(GetInstancePtr(), nullptr, HandleBleSecureReceive, true, nullptr)); - SuccessOrExit(error = otBleSecureTcatStart(GetInstancePtr(), &sVendorInfo, nullptr)); + SuccessOrExit(error = otBleSecureTcatStart(GetInstancePtr(), &mVendorInfo, nullptr)); exit: return error; diff --git a/src/cli/cli_tcat.hpp b/src/cli/cli_tcat.hpp index 3f1d0be6e6e..91b36cc4b6e 100644 --- a/src/cli/cli_tcat.hpp +++ b/src/cli/cli_tcat.hpp @@ -31,6 +31,8 @@ #include "openthread-core-config.h" +#include + #include "cli/cli_output.hpp" #if OPENTHREAD_CONFIG_BLE_TCAT_ENABLE && OPENTHREAD_CONFIG_CLI_BLE_SECURE_ENABLE @@ -78,6 +80,8 @@ class Tcat : private Output using Command = CommandEntry; template otError Process(Arg aArgs[]); + + otTcatVendorInfo mVendorInfo; }; } // namespace Cli