Skip to content

Commit

Permalink
[cli-tcat] define VendorInfo as a member variable (openthread#9869)
Browse files Browse the repository at this point in the history
Changes `mVendorInfo` to be a member variable of `Tcat` class
instead of a static variable.
  • Loading branch information
abtink authored Feb 22, 2024
1 parent a0d805c commit f0b6fce
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/cli/cli_tcat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -116,8 +115,9 @@ template <> otError Tcat::Process<Cmd("start")>(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<const uint8_t *>(OT_CLI_TCAT_X509_CERT),
sizeof(OT_CLI_TCAT_X509_CERT), reinterpret_cast<const uint8_t *>(OT_CLI_TCAT_PRIV_KEY),
Expand All @@ -130,7 +130,7 @@ template <> otError Tcat::Process<Cmd("start")>(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;
Expand Down
4 changes: 4 additions & 0 deletions src/cli/cli_tcat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@

#include "openthread-core-config.h"

#include <openthread/tcat.h>

#include "cli/cli_output.hpp"

#if OPENTHREAD_CONFIG_BLE_TCAT_ENABLE && OPENTHREAD_CONFIG_CLI_BLE_SECURE_ENABLE
Expand Down Expand Up @@ -78,6 +80,8 @@ class Tcat : private Output
using Command = CommandEntry<Tcat>;

template <CommandId kCommandId> otError Process(Arg aArgs[]);

otTcatVendorInfo mVendorInfo;
};

} // namespace Cli
Expand Down

0 comments on commit f0b6fce

Please sign in to comment.