mirror of
https://github.com/espressif/openthread.git
synced 2026-08-20 17:39:51 +00:00
[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:
+10
-12
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user