[border agent] add OT API to get Border Agent MeshCoP Service TXT data (#11291)

This commit adds a new OT API `otBorderAgentGetMeshCoPServiceTxtData`
to get MeshCoP Service TXT data from OT core.

The intention is to facilitate the NCP property update for MeshCoP
Service TXT data. With the get API, NCP property update can use the
`ChangedPropsSet` way which is more robust.
This commit is contained in:
Li Cao
2025-02-26 19:37:47 -08:00
committed by GitHub
parent a67454f8cc
commit 560940af20
6 changed files with 64 additions and 41 deletions
+9 -16
View File
@@ -752,15 +752,11 @@ public:
{
}
void HandleMeshCoPServiceChanged(const uint8_t *aTxtData, uint16_t aLength)
void HandleMeshCoPServiceChanged(void)
{
mIsRunning = mBorderAgent.IsRunning();
mUdpPort = mBorderAgent.GetUdpPort();
assert(aLength <= kMaxTxtDataLen);
memcpy(mTxtData, aTxtData, aLength);
mTxtDataLength = aLength;
SuccessOrQuit(mBorderAgent.GetMeshCoPServiceTxtData(mTxtData));
}
bool FindTxtEntry(const char *aKey, TxtEntry &aTxtEntry)
@@ -768,7 +764,7 @@ public:
bool found = false;
TxtEntry::Iterator iter;
iter.Init(mTxtData, mTxtDataLength);
iter.Init(mTxtData.mData, mTxtData.mLength);
while (iter.GetNextEntry(aTxtEntry) == kErrorNone)
{
if (strcmp(aTxtEntry.mKey, aKey) == 0)
@@ -781,18 +777,15 @@ public:
return found;
}
static constexpr uint16_t kMaxTxtDataLen = 128;
BorderAgent &mBorderAgent;
uint8_t mTxtData[kMaxTxtDataLen];
uint16_t mTxtDataLength;
bool mIsRunning;
uint16_t mUdpPort;
BorderAgent &mBorderAgent;
otBorderAgentMeshCoPServiceTxtData mTxtData;
bool mIsRunning;
uint16_t mUdpPort;
};
static void HandleMeshCoPServiceChanged(const uint8_t *aTxtData, uint16_t aLength, void *aContext)
static void HandleMeshCoPServiceChanged(void *aContext)
{
static_cast<MeshCoPServiceTester *>(aContext)->HandleMeshCoPServiceChanged(aTxtData, aLength);
static_cast<MeshCoPServiceTester *>(aContext)->HandleMeshCoPServiceChanged();
}
template <typename ObjectType> bool CheckObjectSameAsTxtEntryData(const TxtEntry &aTxtEntry, const ObjectType &aObject)