Add two APIs in EnrolleeConf class 45/18445/6
authorJihun Ha <jihun.ha@samsung.com>
Mon, 3 Apr 2017 12:07:13 +0000 (21:07 +0900)
committerUze Choi <uzchoi@samsung.com>
Fri, 7 Apr 2017 06:50:58 +0000 (06:50 +0000)
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 <jihun.ha@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/18445
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Heewon Park <h_w.park@samsung.com>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
service/easy-setup/mediator/richsdk/inc/ESRichCommon.h
service/easy-setup/sampleapp/mediator/linux/richsdk_sample/mediator.cpp

index d346875..c66cf67 100755 (executable)
@@ -767,6 +767,56 @@ namespace OIC
                 return WIFI_FREQ_NONE;
             }
 
+            /**
+             * 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<OCRepresentation>(OC_RSRVD_REPRESENTATION);
+                }
+                else
+                {
+                    return ES_STATE_INIT;
+                }
+
+                if(rep.hasAttribute(OC_RSRVD_ES_PROVSTATUS))
+                {
+                    return static_cast<ProvStatus>(
+                                        rep.getValue<int>(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<OCRepresentation>(OC_RSRVD_REPRESENTATION);
+                }
+                else
+                {
+                    return ES_ERRCODE_NO_ERROR;
+                }
+
+                if(rep.hasAttribute(OC_RSRVD_ES_LAST_ERRORCODE))
+                {
+                    return static_cast<ESErrorCode>(
+                                        rep.getValue<int>(OC_RSRVD_ES_LAST_ERRORCODE));
+                }
+                return ES_ERRCODE_NO_ERROR;
+            }
+
             /**
              * Get an accessibility to cloud server of an Enrollee
              *
index 19a8ad0..b23f07a 100755 (executable)
@@ -71,6 +71,8 @@ int processUserInput(int min = std::numeric_limits<int>::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;