mirror of
https://github.com/espressif/openthread.git
synced 2026-08-23 02:39:52 +00:00
[spinel] add spinel property to get/set dataset in raw TLVs (#10569)
This commit adds two new spinel properties: `SPINEL_PROP_THREAD_ACTIVE_DATASET_TLVS` and `SPINEL_PROP_THREAD_PENDING_DATASET_TLVS`, as well as the get/set property handler on NCP side. Currently we can only transport dataset through spinel with fixed format. Using Tlvs allows us to append TLVs are not defined in the current Thread Specification.
This commit is contained in:
@@ -3388,6 +3388,30 @@ enum
|
||||
*/
|
||||
SPINEL_PROP_THREAD_BACKBONE_ROUTER_LOCAL_REGISTRATION_JITTER = SPINEL_PROP_THREAD_EXT__BEGIN + 59,
|
||||
|
||||
/// Thread Active Operational Dataset in raw TLVs format.
|
||||
/** Format: `D` - Read-Write
|
||||
*
|
||||
* This property provides access to the current Thread Active Operational Dataset. A Thread device maintains the
|
||||
* Operational Dataset that it has stored locally and the one currently in use by the partition to which it is
|
||||
* attached. This property corresponds to the locally stored Dataset on the device.
|
||||
*
|
||||
* On write, any unknown/unsupported TLVs must be ignored.
|
||||
*
|
||||
*/
|
||||
SPINEL_PROP_THREAD_ACTIVE_DATASET_TLVS = SPINEL_PROP_THREAD_EXT__BEGIN + 60,
|
||||
|
||||
/// Thread Pending Operational Dataset in raw TLVs format.
|
||||
/** Format: `D` - Read-Write
|
||||
*
|
||||
* This property provides access to the current locally stored Pending Operational Dataset.
|
||||
*
|
||||
* The formatting of this property follows the same rules as in SPINEL_PROP_THREAD_ACTIVE_DATASET_TLVS.
|
||||
*
|
||||
* On write, any unknown/unsupported TLVs must be ignored.
|
||||
*
|
||||
*/
|
||||
SPINEL_PROP_THREAD_PENDING_DATASET_TLVS = SPINEL_PROP_THREAD_EXT__BEGIN + 61,
|
||||
|
||||
SPINEL_PROP_THREAD_EXT__END = 0x1600,
|
||||
|
||||
SPINEL_PROP_IPV6__BEGIN = 0x60,
|
||||
|
||||
@@ -334,6 +334,8 @@ NcpBase::PropertyHandler NcpBase::FindGetPropertyHandler(spinel_prop_key_t aKey)
|
||||
OT_NCP_GET_HANDLER_ENTRY(SPINEL_PROP_THREAD_BACKBONE_ROUTER_LOCAL_CONFIG),
|
||||
OT_NCP_GET_HANDLER_ENTRY(SPINEL_PROP_THREAD_BACKBONE_ROUTER_LOCAL_REGISTRATION_JITTER),
|
||||
#endif
|
||||
OT_NCP_GET_HANDLER_ENTRY(SPINEL_PROP_THREAD_ACTIVE_DATASET_TLVS),
|
||||
OT_NCP_GET_HANDLER_ENTRY(SPINEL_PROP_THREAD_PENDING_DATASET_TLVS),
|
||||
#if OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE
|
||||
OT_NCP_GET_HANDLER_ENTRY(SPINEL_PROP_CHANNEL_MANAGER_NEW_CHANNEL),
|
||||
OT_NCP_GET_HANDLER_ENTRY(SPINEL_PROP_CHANNEL_MANAGER_DELAY),
|
||||
@@ -603,6 +605,8 @@ NcpBase::PropertyHandler NcpBase::FindSetPropertyHandler(spinel_prop_key_t aKey)
|
||||
OT_NCP_SET_HANDLER_ENTRY(SPINEL_PROP_THREAD_BACKBONE_ROUTER_LOCAL_REGISTER),
|
||||
OT_NCP_SET_HANDLER_ENTRY(SPINEL_PROP_THREAD_BACKBONE_ROUTER_LOCAL_REGISTRATION_JITTER),
|
||||
#endif
|
||||
OT_NCP_SET_HANDLER_ENTRY(SPINEL_PROP_THREAD_ACTIVE_DATASET_TLVS),
|
||||
OT_NCP_SET_HANDLER_ENTRY(SPINEL_PROP_THREAD_PENDING_DATASET_TLVS),
|
||||
#if OPENTHREAD_CONFIG_COMMISSIONER_ENABLE
|
||||
OT_NCP_SET_HANDLER_ENTRY(SPINEL_PROP_MESHCOP_COMMISSIONER_ANNOUNCE_BEGIN),
|
||||
OT_NCP_SET_HANDLER_ENTRY(SPINEL_PROP_MESHCOP_COMMISSIONER_ENERGY_SCAN),
|
||||
|
||||
@@ -1370,6 +1370,30 @@ template <> otError NcpBase::HandlePropertyGet<SPINEL_PROP_THREAD_PENDING_DATASE
|
||||
return EncodeOperationalDataset(dataset);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
otError NcpBase::DecodeOperationalDataset(otOperationalDataset &aDataset,
|
||||
const uint8_t **aTlvs,
|
||||
uint8_t *aTlvsLength,
|
||||
@@ -1651,6 +1675,40 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
template <> otError NcpBase::HandlePropertySet<SPINEL_PROP_THREAD_ACTIVE_DATASET_TLVS>(void)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
const uint8_t *tlvs = nullptr;
|
||||
uint16_t len = 0;
|
||||
otOperationalDatasetTlvs dataset;
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadData(tlvs, len));
|
||||
VerifyOrExit(len <= OT_OPERATIONAL_DATASET_MAX_LENGTH, error = OT_ERROR_PARSE);
|
||||
memcpy(&dataset.mTlvs, tlvs, len);
|
||||
dataset.mLength = static_cast<uint8_t>(len);
|
||||
SuccessOrExit(error = otDatasetSetActiveTlvs(mInstance, &dataset));
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
template <> otError NcpBase::HandlePropertySet<SPINEL_PROP_THREAD_PENDING_DATASET_TLVS>(void)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
const uint8_t *tlvs = nullptr;
|
||||
uint16_t len = 0;
|
||||
otOperationalDatasetTlvs dataset;
|
||||
|
||||
SuccessOrExit(error = mDecoder.ReadData(tlvs, len));
|
||||
VerifyOrExit(len <= OT_OPERATIONAL_DATASET_MAX_LENGTH, error = OT_ERROR_PARSE);
|
||||
memcpy(&dataset.mTlvs, tlvs, len);
|
||||
dataset.mLength = static_cast<uint8_t>(len);
|
||||
SuccessOrExit(error = otDatasetSetPendingTlvs(mInstance, &dataset));
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
template <> otError NcpBase::HandlePropertySet<SPINEL_PROP_THREAD_MGMT_SET_ACTIVE_DATASET>(void)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
Reference in New Issue
Block a user