Adding a helper function to determine if node is commissioned or not. (#1190)

This commit is contained in:
Vaas Krishnamurthy
2017-01-23 12:00:27 -08:00
committed by Jonathan Hui
parent 0d6866e013
commit 5a6f10d1e7
2 changed files with 25 additions and 0 deletions
+10
View File
@@ -930,6 +930,16 @@ OTAPI ThreadError OTCALL otGetActiveDataset(otInstance *aInstance, otOperational
*/
OTAPI ThreadError OTCALL otSetActiveDataset(otInstance *aInstance, const otOperationalDataset *aDataset);
/**
* This function indicates whether a valid network is present in the Active Operational Dataset or not.
*
* @param[in] aInstance A pointer to an OpenThread instance.
*
* @returns TRUE if a valid network is present in the Active Operational Dataset, FALSE otherwise.
*
*/
OTAPI bool OTCALL otIsNodeCommissioned(otInstance *aInstance);
/**
* This function gets the Pending Operational Dataset.
*
+15
View File
@@ -1636,6 +1636,21 @@ exit:
return error;
}
bool otIsNodeCommissioned(otInstance *aInstance)
{
otOperationalDataset dataset;
otGetActiveDataset(aInstance, &dataset);
if ((dataset.mIsMasterKeySet) && (dataset.mIsNetworkNameSet) &&
(dataset.mIsExtendedPanIdSet) && (dataset.mIsPanIdSet) && (dataset.mIsChannelSet))
{
return true;
}
return false;
}
ThreadError otGetPendingDataset(otInstance *aInstance, otOperationalDataset *aDataset)
{
ThreadError error = kThreadError_None;