diff --git a/src/ncp/ncp_base_dispatcher.cpp b/src/ncp/ncp_base_dispatcher.cpp index cdd9792af..06507dfa3 100644 --- a/src/ncp/ncp_base_dispatcher.cpp +++ b/src/ncp/ncp_base_dispatcher.cpp @@ -581,6 +581,9 @@ NcpBase::PropertyHandler NcpBase::FindGetPropertyHandler(spinel_prop_key_t aKey) case SPINEL_PROP_THREAD_ADDRESS_CACHE_TABLE: handler = &NcpBase::HandlePropertyGet; break; + case SPINEL_PROP_THREAD_NEW_DATASET: + handler = &NcpBase::HandlePropertyGet; + break; #if OPENTHREAD_ENABLE_JOINER case SPINEL_PROP_MESHCOP_JOINER_STATE: handler = &NcpBase::HandlePropertyGet; diff --git a/src/ncp/ncp_base_ftd.cpp b/src/ncp/ncp_base_ftd.cpp index 1963d54dc..76d95fcea 100644 --- a/src/ncp/ncp_base_ftd.cpp +++ b/src/ncp/ncp_base_ftd.cpp @@ -40,6 +40,7 @@ #include #endif #include +#include #include #include #include @@ -438,6 +439,25 @@ exit: return error; } +template <> otError NcpBase::HandlePropertyGet(void) +{ + otError error; + otOperationalDataset dataset; + + error = otDatasetCreateNewNetwork(mInstance, &dataset); + + if (error == OT_ERROR_NONE) + { + error = EncodeOperationalDataset(dataset); + } + else + { + error = mEncoder.OverwriteWithLastStatusError(ThreadErrorToSpinelStatus(error)); + } + + return error; +} + #if OPENTHREAD_ENABLE_COMMISSIONER template <> otError NcpBase::HandlePropertyGet(void) diff --git a/src/ncp/spinel.c b/src/ncp/spinel.c index 5388e2f58..807ed6275 100644 --- a/src/ncp/spinel.c +++ b/src/ncp/spinel.c @@ -1689,6 +1689,10 @@ const char *spinel_prop_key_to_cstr(spinel_prop_key_t prop_key) ret = "DATASET_DEST_ADDRESS"; break; + case SPINEL_PROP_THREAD_NEW_DATASET: + ret = "THREAD_NEW_DATASET"; + break; + case SPINEL_PROP_MESHCOP_JOINER_STATE: ret = "MESHCOP_JOINER_STATE"; break; diff --git a/src/ncp/spinel.h b/src/ncp/spinel.h index 5b294efd8..f47c68fce 100644 --- a/src/ncp/spinel.h +++ b/src/ncp/spinel.h @@ -2383,6 +2383,34 @@ typedef enum */ SPINEL_PROP_DATASET_DEST_ADDRESS = SPINEL_PROP_THREAD_EXT__BEGIN + 39, + /// Thread New Operational Dataset + /** Format: `A(t(iD))` - Read only - FTD build only + * + * This property allows host to request NCP to create and return a new Operation Dataset to use when forming a new + * network. + * + * Operational Dataset consists of a set of supported properties (e.g., channel, master key, network name, PAN id, + * etc). Note that not all supported properties may be present (have a value) in a Dataset. + * + * The Dataset value is encoded as an array of structs containing pairs of property key (as `i`) followed by the + * property value (as `D`). The property value must follow the format associated with the corresponding property. + * + * The following properties can be included in a Dataset list: + * + * SPINEL_PROP_DATASET_ACTIVE_TIMESTAMP + * SPINEL_PROP_PHY_CHAN + * SPINEL_PROP_PHY_CHAN_SUPPORTED (Channel Mask Page 0) + * SPINEL_PROP_NET_MASTER_KEY + * SPINEL_PROP_NET_NETWORK_NAME + * SPINEL_PROP_NET_XPANID + * SPINEL_PROP_MAC_15_4_PANID + * SPINEL_PROP_IPV6_ML_PREFIX + * SPINEL_PROP_NET_PSKC + * SPINEL_PROP_DATASET_SECURITY_POLICY + * + */ + SPINEL_PROP_THREAD_NEW_DATASET = SPINEL_PROP_THREAD_EXT__BEGIN + 40, + SPINEL_PROP_THREAD_EXT__END = 0x1600, SPINEL_PROP_IPV6__BEGIN = 0x60,