[meshcop] support get/set operational dataset via raw TLVs (#5055)

- Add CLI commands to get/set operational dataset using TLVs.
This commit is contained in:
Jonathan Hui
2020-06-09 11:53:13 -07:00
committed by GitHub
parent 5550a608d6
commit f36ad41c62
12 changed files with 402 additions and 43 deletions
+89 -8
View File
@@ -234,6 +234,24 @@ typedef struct otOperationalDataset
otOperationalDatasetComponents mComponents; ///< Specifies which components are set in the Dataset.
} otOperationalDataset;
/**
* Maximum length of Operational Dataset in bytes.
*
*/
#define OT_OPERATIONAL_DATASET_MAX_LENGTH 254
/**
* This structure represents an Active or Pending Operational Dataset.
*
* The Operational Dataset is TLV encoded as specified by Thread.
*
*/
typedef struct otOperationalDatasetTlvs
{
uint8_t mTlvs[OT_OPERATIONAL_DATASET_MAX_LENGTH]; ///< Operational Dataset TLVs.
uint8_t mLength; ///< Size of Operational Dataset in bytes.
} otOperationalDatasetTlvs;
/**
* This enumeration represents meshcop TLV types.
*
@@ -298,11 +316,23 @@ bool otDatasetIsCommissioned(otInstance *aInstance);
* @param[out] aDataset A pointer to where the Active Operational Dataset will be placed.
*
* @retval OT_ERROR_NONE Successfully retrieved the Active Operational Dataset.
* @retval OT_ERROR_INVALID_ARGS @p aDataset was NULL.
* @retval OT_ERROR_NOT_FOUND No corresponding value in the setting store.
*
*/
otError otDatasetGetActive(otInstance *aInstance, otOperationalDataset *aDataset);
/**
* This function gets the Active Operational Dataset.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[out] aDataset A pointer to where the Active Operational Dataset will be placed.
*
* @retval OT_ERROR_NONE Successfully retrieved the Active Operational Dataset.
* @retval OT_ERROR_NOT_FOUND No corresponding value in the setting store.
*
*/
otError otDatasetGetActiveTlvs(otInstance *aInstance, otOperationalDatasetTlvs *aDataset);
/**
* This function sets the Active Operational Dataset.
*
@@ -322,13 +352,39 @@ otError otDatasetGetActive(otInstance *aInstance, otOperationalDataset *aDataset
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aDataset A pointer to the Active Operational Dataset.
*
* @retval OT_ERROR_NONE Successfully set the Active Operational Dataset.
* @retval OT_ERROR_NO_BUFS Insufficient buffer space to set the Active Operational Dataset.
* @retval OT_ERROR_INVALID_ARGS @p aDataset was NULL.
* @retval OT_ERROR_NONE Successfully set the Active Operational Dataset.
* @retval OT_ERROR_NO_BUFS Insufficient buffer space to set the Active Operational Dataset.
* @retval OT_ERROR_NOT_IMPLEMENTED The platform does not implement settings functionality.
*
*/
otError otDatasetSetActive(otInstance *aInstance, const otOperationalDataset *aDataset);
/**
* This function sets the Active Operational Dataset.
*
* If the dataset does not include an Active Timestamp, the dataset is only partially complete.
*
* If Thread is enabled on a device that has a partially complete Active Dataset, the device will attempt to attach to
* an existing Thread network using any existing information in the dataset. Only the Thread Master Key is needed to
* attach to a network.
*
* If channel is not included in the dataset, the device will send MLE Announce messages across different channels to
* find neighbors on other channels.
*
* If the device successfully attaches to a Thread network, the device will then retrieve the full Active Dataset from
* its Parent. Note that a router-capable device will not transition to the Router or Leader roles until it has a
* complete Active Dataset.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aDataset A pointer to the Active Operational Dataset.
*
* @retval OT_ERROR_NONE Successfully set the Active Operational Dataset.
* @retval OT_ERROR_NO_BUFS Insufficient buffer space to set the Active Operational Dataset.
* @retval OT_ERROR_NOT_IMPLEMENTED The platform does not implement settings functionality.
*
*/
otError otDatasetSetActiveTlvs(otInstance *aInstance, const otOperationalDatasetTlvs *aDataset);
/**
* This function gets the Pending Operational Dataset.
*
@@ -336,24 +392,49 @@ otError otDatasetSetActive(otInstance *aInstance, const otOperationalDataset *aD
* @param[out] aDataset A pointer to where the Pending Operational Dataset will be placed.
*
* @retval OT_ERROR_NONE Successfully retrieved the Pending Operational Dataset.
* @retval OT_ERROR_INVALID_ARGS @p aDataset was NULL.
* @retval OT_ERROR_NOT_FOUND No corresponding value in the setting store.
*
*/
otError otDatasetGetPending(otInstance *aInstance, otOperationalDataset *aDataset);
/**
* This function gets the Pending Operational Dataset.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[out] aDataset A pointer to where the Pending Operational Dataset will be placed.
*
* @retval OT_ERROR_NONE Successfully retrieved the Pending Operational Dataset.
* @retval OT_ERROR_NOT_FOUND No corresponding value in the setting store.
*
*/
otError otDatasetGetPendingTlvs(otInstance *aInstance, otOperationalDatasetTlvs *aDataset);
/**
* This function sets the Pending Operational Dataset.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aDataset A pointer to the Pending Operational Dataset.
*
* @retval OT_ERROR_NONE Successfully set the Pending Operational Dataset.
* @retval OT_ERROR_NO_BUFS Insufficient buffer space to set the Pending Operational Dataset.
* @retval OT_ERROR_INVALID_ARGS @p aDataset was NULL.
* @retval OT_ERROR_NONE Successfully set the Pending Operational Dataset.
* @retval OT_ERROR_NO_BUFS Insufficient buffer space to set the Pending Operational Dataset.
* @retval OT_ERROR_NOT_IMPLEMENTED The platform does not implement settings functionality.
*
*/
otError otDatasetSetPending(otInstance *aInstance, const otOperationalDataset *aDataset);
/**
* This function sets the Pending Operational Dataset.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aDataset A pointer to the Pending Operational Dataset.
*
* @retval OT_ERROR_NONE Successfully set the Pending Operational Dataset.
* @retval OT_ERROR_NO_BUFS Insufficient buffer space to set the Pending Operational Dataset.
* @retval OT_ERROR_NOT_IMPLEMENTED The platform does not implement settings functionality.
*
*/
otError otDatasetSetPendingTlvs(otInstance *aInstance, const otOperationalDatasetTlvs *aDataset);
/**
* This function sends MGMT_ACTIVE_GET.
*
+1 -1
View File
@@ -53,7 +53,7 @@ extern "C" {
* @note This number versions both OpenThread platform and user APIs.
*
*/
#define OPENTHREAD_API_VERSION (3)
#define OPENTHREAD_API_VERSION (4)
/**
* @addtogroup api-instance