[ncp] fix implementation of NCP get dataset tlvs (#10850)

This commit fixes the bug in NCP Get
`SPINEL_PROP_THREAD_ACTIVE_DATASET_TLVS` and
`SPINEL_PROP_THREAD_PENDING_DATASET_TLVS`.

There are cases where dataset doesn't exist and
`otDatasetGetActiveTlvs` returns `OT_ERROR_NOT_FOUND`. This will cause
that the NCP doesn't send any responses to the host. This commit lets
the implementation ignore the NOT_FOUND error and will encode empty
data in this case.
This commit is contained in:
Li Cao
2024-10-21 09:16:18 +01:00
committed by GitHub
parent a1474853d8
commit 2bc8685060
+10 -12
View File
@@ -1372,26 +1372,24 @@ template <> otError NcpBase::HandlePropertyGet<SPINEL_PROP_THREAD_PENDING_DATASE
template <> otError NcpBase::HandlePropertyGet<SPINEL_PROP_THREAD_ACTIVE_DATASET_TLVS>(void)
{
otError error = OT_ERROR_NONE;
otOperationalDatasetTlvs dataset;
SuccessOrExit(error = otDatasetGetActiveTlvs(mInstance, &dataset));
SuccessOrExit(error = mEncoder.WriteData(dataset.mTlvs, dataset.mLength));
exit:
return error;
if (otDatasetGetActiveTlvs(mInstance, &dataset) != OT_ERROR_NONE)
{
dataset.mLength = 0;
}
return mEncoder.WriteData(dataset.mTlvs, dataset.mLength);
}
template <> otError NcpBase::HandlePropertyGet<SPINEL_PROP_THREAD_PENDING_DATASET_TLVS>(void)
{
otError error = OT_ERROR_NONE;
otOperationalDatasetTlvs dataset;
SuccessOrExit(error = otDatasetGetPendingTlvs(mInstance, &dataset));
SuccessOrExit(error = mEncoder.WriteData(dataset.mTlvs, dataset.mLength));
exit:
return error;
if (otDatasetGetPendingTlvs(mInstance, &dataset) != OT_ERROR_NONE)
{
dataset.mLength = 0;
}
return mEncoder.WriteData(dataset.mTlvs, dataset.mLength);
}
otError NcpBase::DecodeOperationalDataset(otOperationalDataset &aDataset,