ESCloudProvState and ESResult can produce a similar result in easy setup.
So ESCloudProvState is decided to be merged into ESResult for consistency
with the other provisioning API like deviceProvisioning.
Change-Id: Ic937688f0f47eac9b7f4ce2b257ea7c3c6306eba
Signed-off-by: Jihun Ha <jihun.ha@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/10685
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Madan Lanka <lanka.madan@samsung.com>
if(m_CloudPropProvisioningCb != NULL)
{
m_CloudPropProvisioningCb(cloudPropProvisioningStatus);
- if(cloudPropProvisioningStatus->getESCloudState() == ES_CLOUD_PROVISIONING_SUCCESS)
+ if(cloudPropProvisioningStatus->getESResult() == ES_OK)
{
m_CloudPropProvisioningCb = NULL;
}
typedef enum
{
- ES_ERROR = -1,
ES_OK = 0,
- ES_NETWORKFOUND = 1,
- ES_NETWORKCONNECTED,
- ES_NETWORKNOTCONNECTED,
- ES_RESOURCECREATED = 11,
- ES_RECVREQOFPROVRES = 21,
- ES_RECVREQOFNETRES,
- ES_RECVUPDATEOFPROVRES,
- ES_RECVTRIGGEROFPROVRES,
- ES_UNAUTHORIZED = 31,
- ES_UNSUPPORTED_OPERATION = 41
+ ES_FOUND_ENROLLEE = 1,
+ ES_NOT_FOUND_ENROLLEE = 11,
+ ES_SEC_OPERATION_IS_NOT_SUPPORTED = 20,
+ ES_UNAUTHORIZED_REQ = 21,
+ ES_SEC_PROVISION_FAILS = 22,
+ ES_ERROR = 255,
} ESResult;
/**
};
/**
- * @brief Provisioning state in cloud server property provisioning.
- */
- typedef enum
- {
- ES_CLOUD_PROVISIONING_ERROR = -1, /**< An error in cloud provisioning happens **/
- ES_CLOUD_PROVISIONING_SUCCESS, /**< Cloud provisioning is successfully done **/
- ES_CLOUD_ENROLLEE_FOUND, /**< An enrollee is found in a given network **/
- ES_CLOUD_ENROLLEE_NOT_FOUND /**< NO enrollee is found in a given network **/
- }ESCloudProvState;
-
- /**
* Security Provisioning Status
*/
class SecProvisioningStatus
class CloudPropProvisioningStatus
{
public:
- CloudPropProvisioningStatus(ESResult result, ESCloudProvState state) :
- m_result(result), m_esCloudState(state)
+ CloudPropProvisioningStatus(ESResult result) :
+ m_result(result)
{
}
return m_result;
}
- ESCloudProvState getESCloudState()
- {
- return m_esCloudState;
- }
-
private:
ESResult m_result;
- ESCloudProvState m_esCloudState;
};
/**
if (eCode > OCStackResult::OC_STACK_RESOURCE_CHANGED)
{
- ESResult result = ESResult::ES_ERROR;
+ ESResult result = ESResult::ES_ERROR;
OIC_LOG(DEBUG, ES_CLOUD_RES_TAG,"onCloudProvResponse : onCloudProvResponse is failed ");
if (eCode == OCStackResult::OC_STACK_UNAUTHORIZED_REQ)
{
OIC_LOG(DEBUG, ES_CLOUD_RES_TAG, "Mediator is unauthorized from Enrollee.");
- result = ESResult::ES_UNAUTHORIZED;
+ result = ESResult::ES_UNAUTHORIZED_REQ;
}
std::shared_ptr< CloudPropProvisioningStatus > provStatus = std::make_shared<
- CloudPropProvisioningStatus >(
- result, ESCloudProvState::ES_CLOUD_PROVISIONING_ERROR);
+ CloudPropProvisioningStatus >(result);
m_cloudPropProvStatusCb(provStatus);
}
else
{
OIC_LOG(DEBUG, ES_CLOUD_RES_TAG,"onCloudProvResponse : onCloudProvResponse is success ");
std::shared_ptr< CloudPropProvisioningStatus > provStatus =
- std::make_shared<CloudPropProvisioningStatus >(
- ESResult::ES_OK, ESCloudProvState::ES_CLOUD_PROVISIONING_SUCCESS);
+ std::make_shared<CloudPropProvisioningStatus >(ESResult::ES_OK);
m_cloudPropProvStatusCb(provStatus);
}
}
{
OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG,
"Mediator is unauthorized from Enrollee.");
- result = ESResult::ES_UNAUTHORIZED;
+ result = ESResult::ES_UNAUTHORIZED_REQ;
}
EnrolleeStatus enrolleeStatus(rep);
{
OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG,
"Mediator is unauthorized from Enrollee.");
- result = ESResult::ES_UNAUTHORIZED;
+ result = ESResult::ES_UNAUTHORIZED_REQ;
}
EnrolleeConf enrolleeConf(rep);
void RemoteEnrollee::provisionSecurity(const SecurityProvStatusCb callback)
{
#ifdef __WITH_DTLS__
+ std::cout << __func__ << std::endl;
if(!callback)
{
throw ESInvalidParameterException("Callback is empty");
std::shared_ptr< SecProvisioningStatus > securityProvisioningStatus =
std::make_shared< SecProvisioningStatus >
- ("", ES_UNSUPPORTED_OPERATION);
+ ("", ESResult::ES_SEC_OPERATION_IS_NOT_SUPPORTED);
m_securityProvStatusCb(securityProvisioningStatus);
#endif
}
m_cloudResource = std::make_shared<CloudResource>(m_ocResource);
std::shared_ptr< CloudPropProvisioningStatus > provStatus = std::make_shared<
- CloudPropProvisioningStatus >(ESResult::ES_OK,
- ESCloudProvState::ES_CLOUD_ENROLLEE_FOUND);
+ CloudPropProvisioningStatus >(ESResult::ES_FOUND_ENROLLEE);
m_cloudPropProvStatusCb(provStatus);
}
"Exception caught in provisionCloudProperties = %s", e.what());
std::shared_ptr< CloudPropProvisioningStatus > provStatus = std::make_shared<
- CloudPropProvisioningStatus >(ESResult::ES_ERROR,
- ESCloudProvState::ES_CLOUD_ENROLLEE_NOT_FOUND);
+ CloudPropProvisioningStatus >(ESResult::ES_NOT_FOUND_ENROLLEE);
m_cloudPropProvStatusCb(provStatus);
return;
}
m_cloudResource = nullptr;
std::shared_ptr< CloudPropProvisioningStatus > provStatus = std::make_shared<
- CloudPropProvisioningStatus >(ESResult::ES_ERROR,
- ESCloudProvState::ES_CLOUD_PROVISIONING_ERROR);
+ CloudPropProvisioningStatus >(ESResult::ES_ERROR);
m_cloudPropProvStatusCb(provStatus);
return;
}
static std::mutex g_discoverymtx;
static std::condition_variable g_cond;
-#define PROV_RESOURCE_TYPE "ocf.wk.prov"
-
typedef void (*Runner)();
Runner g_currentRun;
void provisionSecurity()
{
- remoteEnrollee->provisionSecurity(provisionSecurityStatusCallback);
+ try
+ {
+ remoteEnrollee->provisionSecurity(provisionSecurityStatusCallback);
+ }
+ catch (OCException &e)
+ {
+ std::cout << "Exception during provisionSecurity call" << e.reason();
+ return;
+ }
}
void getStatusCallback(std::shared_ptr< GetEnrolleeStatus > getEnrolleeStatus)
try
{
- //remoteEnrollee->provisionDeviceProperties(deviceProp, deviceProvisioningStatusCallback);
remoteEnrollee->provisionDeviceProperties(devProp, deviceProvisioningStatusCallback);
}
catch (OCException &e)
void cloudProvisioningStatusCallback(std::shared_ptr< CloudPropProvisioningStatus > provStatus)
{
- switch (provStatus->getESCloudState())
+ switch (provStatus->getESResult())
{
- case ES_CLOUD_PROVISIONING_ERROR:
- cout << "Cloud Provisioning is failed." << endl;
- break;
- case ES_CLOUD_PROVISIONING_SUCCESS:
+ case ES_OK:
cout << "Cloud Provisioning is success." << endl;
break;
- case ES_CLOUD_ENROLLEE_FOUND:
+ case ES_FOUND_ENROLLEE:
cout << "Enrollee is found in a given network." << endl;
break;
- case ES_CLOUD_ENROLLEE_NOT_FOUND:
+ case ES_NOT_FOUND_ENROLLEE:
cout << "Enrollee is not found in a given network." << endl;
break;
+ default:
+ cout << "Cloud Provisioning is failed." << endl;
+ break;
}
}
// Do some operations with resource object.
if(resource &&
!curResource &&
- resource->getResourceTypes().at(0) == PROV_RESOURCE_TYPE)
+ resource->getResourceTypes().at(0) == OC_RSRVD_ES_RES_TYPE_PROV)
{
std::cout<<"DISCOVERED Resource:"<<std::endl;
// Get the resource URI
return -1;
}
#endif
- requestURI << OC_RSRVD_WELL_KNOWN_URI << "?rt=" << PROV_RESOURCE_TYPE;
+ requestURI << OC_RSRVD_WELL_KNOWN_URI << "?rt=" << OC_RSRVD_ES_RES_TYPE_PROV;
OCPlatform::findResource("", requestURI.str(), CT_DEFAULT, &foundResource);
std::cout<< "Finding Resource... " <<std::endl;