From 5a6f10d1e74ab8ec5bb8ec89191eef47659ccc22 Mon Sep 17 00:00:00 2001 From: Vaas Krishnamurthy Date: Mon, 23 Jan 2017 12:00:27 -0800 Subject: [PATCH] Adding a helper function to determine if node is commissioned or not. (#1190) --- include/openthread.h | 10 ++++++++++ src/core/openthread.cpp | 15 +++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/include/openthread.h b/include/openthread.h index df715a6ff..2283d450e 100644 --- a/include/openthread.h +++ b/include/openthread.h @@ -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. * diff --git a/src/core/openthread.cpp b/src/core/openthread.cpp index fbe9266ab..c6f9690fc 100644 --- a/src/core/openthread.cpp +++ b/src/core/openthread.cpp @@ -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;