From 2ad35698ca42de7497f02bbc3959371065503f0f Mon Sep 17 00:00:00 2001 From: Jihun Ha Date: Mon, 3 Apr 2017 21:07:13 +0900 Subject: [PATCH] Add two APIs in EnrolleeConf class The two APIs are added in EnrolleConf class so that provisioning status and last error code properties can be passed to application as a response of getConfiguration API call. Note that those APIs are already provided in EnrolleeStatus class which is a GET request with baseline interface. Change-Id: I46133a189fff5201df9526bf2ef6009834ab77ab Signed-off-by: Jihun Ha Reviewed-on: https://gerrit.iotivity.org/gerrit/18445 Tested-by: jenkins-iotivity Reviewed-by: Heewon Park Reviewed-by: Uze Choi --- .../easy-setup/mediator/richsdk/inc/ESRichCommon.h | 50 ++++++++++++++++++++++ .../mediator/linux/richsdk_sample/mediator.cpp | 2 + 2 files changed, 52 insertions(+) diff --git a/service/easy-setup/mediator/richsdk/inc/ESRichCommon.h b/service/easy-setup/mediator/richsdk/inc/ESRichCommon.h index d346875..c66cf67 100755 --- a/service/easy-setup/mediator/richsdk/inc/ESRichCommon.h +++ b/service/easy-setup/mediator/richsdk/inc/ESRichCommon.h @@ -768,6 +768,56 @@ namespace OIC } /** + * Get a provisioning status property of Enrollee. + * + * @return a provisioning status property of Enrollee + */ + ProvStatus getProvStatus() const + { + OCRepresentation rep; + if(m_EasySetupRep.hasAttribute(OC_RSRVD_REPRESENTATION)) + { + rep = m_EasySetupRep.getValue(OC_RSRVD_REPRESENTATION); + } + else + { + return ES_STATE_INIT; + } + + if(rep.hasAttribute(OC_RSRVD_ES_PROVSTATUS)) + { + return static_cast( + rep.getValue(OC_RSRVD_ES_PROVSTATUS)); + } + return ES_STATE_INIT; + } + + /** + * Get a last error code property of Enrollee. + * + * @return a last error code property of Enrollee. + */ + ESErrorCode getLastErrCode() const + { + OCRepresentation rep; + if(m_EasySetupRep.hasAttribute(OC_RSRVD_REPRESENTATION)) + { + rep = m_EasySetupRep.getValue(OC_RSRVD_REPRESENTATION); + } + else + { + return ES_ERRCODE_NO_ERROR; + } + + if(rep.hasAttribute(OC_RSRVD_ES_LAST_ERRORCODE)) + { + return static_cast( + rep.getValue(OC_RSRVD_ES_LAST_ERRORCODE)); + } + return ES_ERRCODE_NO_ERROR; + } + + /** * Get an accessibility to cloud server of an Enrollee * * @return an accessibility to cloud server of an Enrollee diff --git a/service/easy-setup/sampleapp/mediator/linux/richsdk_sample/mediator.cpp b/service/easy-setup/sampleapp/mediator/linux/richsdk_sample/mediator.cpp index 19a8ad0..b23f07a 100755 --- a/service/easy-setup/sampleapp/mediator/linux/richsdk_sample/mediator.cpp +++ b/service/easy-setup/sampleapp/mediator/linux/richsdk_sample/mediator.cpp @@ -71,6 +71,8 @@ int processUserInput(int min = std::numeric_limits::min(), void printConfiguration(const EnrolleeConf& conf) { cout << "===========================================" << endl; + cout << "\tProvStatus : " << conf.getProvStatus() << endl; + cout << "\tLastErrCode : " << conf.getLastErrCode() << endl; cout << "\tDevice Name : " << conf.getDeviceName() << endl; cout << "\tModel Number : " << conf.getModelNumber() << endl; -- 2.7.4