From 07e79ba539b31b2a0c3cf28d528f06149867932f Mon Sep 17 00:00:00 2001 From: Esko Dijk Date: Mon, 2 Mar 2026 19:34:32 +0100 Subject: [PATCH] [cli][tcat] initialize TCAT from CLI with proper vendor app URL and fix TLV status to 'Unsupported' (#12340) This updates the TCAT CLI to use the configured 'vendor app URL' by default as the TCAT Provisioning URL, instead of a dummy value. It also updates the max length of this URL to the configured vendor app URL max length as agreed by JIRA BHC-769. Also 2 related minor validation fixes in TCAT agent code. Furthermore, the Get Provisioning URL TLV TCAT command is fixed to return status 'Unsupported' in case the URL is not configured (null or zero-length), to comply to the spec. --- src/cli/cli_tcat.cpp | 9 +++------ src/core/meshcop/tcat_agent.cpp | 11 ++++------- src/core/meshcop/tcat_agent.hpp | 3 ++- tests/scripts/expect/cli-tcat.exp | 6 +++--- 4 files changed, 12 insertions(+), 17 deletions(-) diff --git a/src/cli/cli_tcat.cpp b/src/cli/cli_tcat.cpp index 4574d3f76..ecbe37a80 100644 --- a/src/cli/cli_tcat.cpp +++ b/src/cli/cli_tcat.cpp @@ -28,17 +28,15 @@ #include "openthread-core-config.h" -#include "cli/cli_utils.hpp" - #include "cli/cli_tcat.hpp" +#include "cli/cli_utils.hpp" #include "common/code_utils.hpp" #include "common/debug.hpp" #include "common/string.hpp" #include - -#include #include +#include #include #include @@ -123,7 +121,6 @@ otTcatGeneralDeviceId sGeneralDeviceId; const char kPskdVendor[] = "JJJJJJ"; const char kInstallVendor[] = "InstallCode"; -const char kUrl[] = "dummy_url"; const char kApplicationServiceName1[] = "echo"; const char kApplicationServiceName2[] = "discard"; @@ -356,7 +353,7 @@ template <> otError Tcat::Process(Arg aArgs[]) ClearAllBytes(mVendorInfo); mVendorInfo.mPskdString = kPskdVendor; - mVendorInfo.mProvisioningUrl = kUrl; + mVendorInfo.mProvisioningUrl = otThreadGetVendorAppUrl(GetInstancePtr()); mVendorInfo.mInstallCode = kInstallVendor; mVendorInfo.mApplicationServiceName[0] = kApplicationServiceName1; mVendorInfo.mApplicationServiceName[1] = kApplicationServiceName2; diff --git a/src/core/meshcop/tcat_agent.cpp b/src/core/meshcop/tcat_agent.cpp index d026adfbb..5572266c0 100644 --- a/src/core/meshcop/tcat_agent.cpp +++ b/src/core/meshcop/tcat_agent.cpp @@ -48,11 +48,8 @@ RegisterLogModule("TcatAgent"); bool TcatAgent::VendorInfo::IsValid(void) const { - return (mProvisioningUrl == nullptr || - (IsValidUtf8String(mProvisioningUrl) && - (static_cast(StringLength(mProvisioningUrl, kProvisioningUrlMaxLength)) < - kProvisioningUrlMaxLength))) && - mPskdString != nullptr; + // Note: mProvisioningUrl can be nullptr, if not present + return mPskdString != nullptr && Tlv::ValidateStringValue(mProvisioningUrl) == kErrorNone; } TcatAgent::TcatAgent(Instance &aInstance) @@ -825,10 +822,10 @@ Error TcatAgent::HandleGetProvisioningUrl(Message &aOutgoingMessage, bool &aResp uint16_t length; VerifyOrExit(mVendorInfo != nullptr, error = kErrorInvalidState); - VerifyOrExit(mVendorInfo->mProvisioningUrl != nullptr, error = kErrorInvalidState); + VerifyOrExit(mVendorInfo->mProvisioningUrl != nullptr, error = kErrorNotImplemented); length = StringLength(mVendorInfo->mProvisioningUrl, kProvisioningUrlMaxLength); - VerifyOrExit(length > 0 && length <= Tlv::kBaseTlvMaxLength, error = kErrorNotFound); + VerifyOrExit(length > 0, error = kErrorNotImplemented); SuccessOrExit(error = Tlv::AppendTlv(aOutgoingMessage, kTlvResponseWithPayload, mVendorInfo->mProvisioningUrl, length)); diff --git a/src/core/meshcop/tcat_agent.hpp b/src/core/meshcop/tcat_agent.hpp index 599c956ae..616fd10c2 100644 --- a/src/core/meshcop/tcat_agent.hpp +++ b/src/core/meshcop/tcat_agent.hpp @@ -38,6 +38,7 @@ #if OPENTHREAD_CONFIG_BLE_TCAT_ENABLE +#include #include #include @@ -473,7 +474,7 @@ private: uint8_t CheckAuthorizationRequirements(CommandClassFlags aFlagsChecked, Dataset::Info *aDatasetInfo) const; static constexpr uint16_t kPingPayloadMaxLength = 512; - static constexpr uint16_t kProvisioningUrlMaxLength = 64; + static constexpr uint16_t kProvisioningUrlMaxLength = OT_NETWORK_DIAGNOSTIC_MAX_VENDOR_APP_URL_TLV_LENGTH; static constexpr uint16_t kMaxPskdLength = OT_JOINER_MAX_PSKD_LENGTH; static constexpr uint16_t kTcatMaxDeviceIdSize = OT_TCAT_MAX_DEVICEID_SIZE; static constexpr uint16_t kInstallCodeMaxSize = 255; diff --git a/tests/scripts/expect/cli-tcat.exp b/tests/scripts/expect/cli-tcat.exp index b483ebebc..816312ae6 100755 --- a/tests/scripts/expect/cli-tcat.exp +++ b/tests/scripts/expect/cli-tcat.exp @@ -90,9 +90,9 @@ expect_line "\tLEN:\t8" expect_line "\tVALUE:\t0xef1398c2fd504b67" send "provisioning_url\n" -expect_line "\tTYPE:\tRESPONSE_W_PAYLOAD" -expect_line "\tLEN:\t9" -expect_line "\tVALUE:\t0x64756d6d795f75726c" +expect_line "\tTYPE:\tRESPONSE_W_STATUS" +expect_line "\tLEN:\t1" +expect_line "\tVALUE:\t0x01" send "get_apps\n" expect_line "\tApplication 1 is UDP service: echo"