[version] add thread version string (#11276)

This commit adds thread version string for the "tv" entry in border
agent MeshCoP TXT records.

The commit also replaces "1.3.1" with "1.4.0".
This commit is contained in:
Li Cao
2025-02-24 09:00:55 -08:00
committed by GitHub
parent 522f590fb6
commit 0b0f371d34
6 changed files with 60 additions and 29 deletions
+1
View File
@@ -713,6 +713,7 @@ openthread_core_files = [
"thread/tmf.hpp",
"thread/uri_paths.cpp",
"thread/uri_paths.hpp",
"thread/version.cpp",
"thread/version.hpp",
"utils/channel_manager.cpp",
"utils/channel_manager.hpp",
+1
View File
@@ -250,6 +250,7 @@ set(COMMON_SOURCES
thread/time_sync_service.cpp
thread/tmf.cpp
thread/uri_paths.cpp
thread/version.cpp
utils/channel_manager.cpp
utils/channel_monitor.cpp
utils/flash.cpp
+1 -13
View File
@@ -379,18 +379,6 @@ template <> Error BorderAgent::MeshCoPTxtEncoder::AppendTxtEntry<NameData>(const
Error BorderAgent::MeshCoPTxtEncoder::EncodeTxtData(void)
{
#if OPENTHREAD_CONFIG_THREAD_VERSION == OT_THREAD_VERSION_1_1
static const char kThreadVersionString[] = "1.1.1";
#elif OPENTHREAD_CONFIG_THREAD_VERSION == OT_THREAD_VERSION_1_2
static const char kThreadVersionString[] = "1.2.0";
#elif OPENTHREAD_CONFIG_THREAD_VERSION == OT_THREAD_VERSION_1_3
static const char kThreadVersionString[] = "1.3.0";
#elif OPENTHREAD_CONFIG_THREAD_VERSION == OT_THREAD_VERSION_1_3_1
static const char kThreadVersionString[] = "1.3.1";
#elif OPENTHREAD_CONFIG_THREAD_VERSION == OT_THREAD_VERSION_1_4
static const char kThreadVersionString[] = "1.4.0";
#endif
Error error = kErrorNone;
#if OPENTHREAD_CONFIG_BORDER_AGENT_ID_ENABLE
Id id;
@@ -405,7 +393,7 @@ Error BorderAgent::MeshCoPTxtEncoder::EncodeTxtData(void)
#endif
SuccessOrExit(error = AppendTxtEntry("nn", Get<NetworkNameManager>().GetNetworkName().GetAsData()));
SuccessOrExit(error = AppendTxtEntry("xp", Get<ExtendedPanIdManager>().GetExtPanId()));
SuccessOrExit(error = AppendTxtEntry("tv", NameData(kThreadVersionString, sizeof(kThreadVersionString) - 1)));
SuccessOrExit(error = AppendTxtEntry("tv", NameData(kThreadVersionString, strlen(kThreadVersionString))));
SuccessOrExit(error = AppendTxtEntry("xa", Get<Mac::Mac>().GetExtAddress()));
state = GetStateBitmap();
+53
View File
@@ -0,0 +1,53 @@
/*
* Copyright (c) 2025, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @file
* This file implements Thread Version.
*/
#include "version.hpp"
namespace ot {
#if OPENTHREAD_CONFIG_THREAD_VERSION == OT_THREAD_VERSION_1_1
const char kThreadVersionString[] = "1.1.1";
#elif OPENTHREAD_CONFIG_THREAD_VERSION == OT_THREAD_VERSION_1_2
const char kThreadVersionString[] = "1.2.0";
#elif OPENTHREAD_CONFIG_THREAD_VERSION == OT_THREAD_VERSION_1_3
const char kThreadVersionString[] = "1.3.0";
#elif OPENTHREAD_CONFIG_THREAD_VERSION == OT_THREAD_VERSION_1_3_1
// Support projects on legacy "1.3.1" version, which is now "1.4"
const char kThreadVersionString[] = "1.4.0";
#elif OPENTHREAD_CONFIG_THREAD_VERSION == OT_THREAD_VERSION_1_4
const char kThreadVersionString[] = "1.4.0";
#else
#error "The `OPENTHREAD_CONFIG_THREAD_VERSION` is not valid or supported"
#endif
} // namespace ot
+2
View File
@@ -49,6 +49,8 @@ constexpr uint16_t kThreadVersion1p3 = OT_THREAD_VERSION_1_3; ///< Thread Versio
constexpr uint16_t kThreadVersion1p3p1 = OT_THREAD_VERSION_1_3_1; ///< Thread Version 1.3.1
constexpr uint16_t kThreadVersion1p4 = OT_THREAD_VERSION_1_4; ///< Thread Version 1.4
extern const char kThreadVersionString[]; ///< Thread version as human-readable string.
} // namespace ot
#endif // VERSION_HPP_
+2 -16
View File
@@ -808,18 +808,6 @@ template <> bool CheckObjectSameAsTxtEntryData<NameData>(const TxtEntry &aTxtEnt
memcmp(aTxtEntry.mValue, aNameData.GetBuffer(), aNameData.GetLength()) == 0;
}
#if OPENTHREAD_CONFIG_THREAD_VERSION == OT_THREAD_VERSION_1_1
static const char kThreadVersionString[] = "1.1.1";
#elif OPENTHREAD_CONFIG_THREAD_VERSION == OT_THREAD_VERSION_1_2
static const char kThreadVersionString[] = "1.2.0";
#elif OPENTHREAD_CONFIG_THREAD_VERSION == OT_THREAD_VERSION_1_3
static const char kThreadVersionString[] = "1.3.0";
#elif OPENTHREAD_CONFIG_THREAD_VERSION == OT_THREAD_VERSION_1_3_1
static const char kThreadVersionString[] = "1.3.1";
#elif OPENTHREAD_CONFIG_THREAD_VERSION == OT_THREAD_VERSION_1_4
static const char kThreadVersionString[] = "1.4.0";
#endif
void TestBorderAgentMeshCoPServiceChangedCallback(void)
{
Core nexus;
@@ -850,8 +838,7 @@ void TestBorderAgentMeshCoPServiceChangedCallback(void)
VerifyOrQuit(meshCoPServiceTester.FindTxtEntry("xp", txtEntry));
VerifyOrQuit(CheckObjectSameAsTxtEntryData(txtEntry, node0.Get<ExtendedPanIdManager>().GetExtPanId()));
VerifyOrQuit(meshCoPServiceTester.FindTxtEntry("tv", txtEntry));
VerifyOrQuit(
CheckObjectSameAsTxtEntryData(txtEntry, NameData(kThreadVersionString, sizeof(kThreadVersionString) - 1)));
VerifyOrQuit(CheckObjectSameAsTxtEntryData(txtEntry, NameData(kThreadVersionString, strlen(kThreadVersionString))));
VerifyOrQuit(meshCoPServiceTester.FindTxtEntry("xa", txtEntry));
VerifyOrQuit(CheckObjectSameAsTxtEntryData(txtEntry, node0.Get<Mac::Mac>().GetExtAddress()));
VerifyOrQuit(meshCoPServiceTester.FindTxtEntry("sb", txtEntry));
@@ -880,8 +867,7 @@ void TestBorderAgentMeshCoPServiceChangedCallback(void)
VerifyOrQuit(meshCoPServiceTester.FindTxtEntry("xp", txtEntry));
VerifyOrQuit(CheckObjectSameAsTxtEntryData(txtEntry, node0.Get<ExtendedPanIdManager>().GetExtPanId()));
VerifyOrQuit(meshCoPServiceTester.FindTxtEntry("tv", txtEntry));
VerifyOrQuit(
CheckObjectSameAsTxtEntryData(txtEntry, NameData(kThreadVersionString, sizeof(kThreadVersionString) - 1)));
VerifyOrQuit(CheckObjectSameAsTxtEntryData(txtEntry, NameData(kThreadVersionString, strlen(kThreadVersionString))));
VerifyOrQuit(meshCoPServiceTester.FindTxtEntry("xa", txtEntry));
VerifyOrQuit(CheckObjectSameAsTxtEntryData(txtEntry, node0.Get<Mac::Mac>().GetExtAddress()));
VerifyOrQuit(meshCoPServiceTester.FindTxtEntry("sb", txtEntry));