X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=service%2Feasy-setup%2Fmediator%2Frichsdk%2Fsrc%2FEnrolleeResource.cpp;h=a1e35e9df2645785c93a71c7ebd295b0a3f220b1;hb=7f00f942c39b7bc27c7eeecf213a239c3fe4173c;hp=a79e93fb75222ecf06aa593bcbc72ca6d3b2212d;hpb=b786f86f6bccbfe850cba42cb32e1afa894b8c74;p=platform%2Fupstream%2Fiotivity.git diff --git a/service/easy-setup/mediator/richsdk/src/EnrolleeResource.cpp b/service/easy-setup/mediator/richsdk/src/EnrolleeResource.cpp index a79e93f..a1e35e9 100755 --- a/service/easy-setup/mediator/richsdk/src/EnrolleeResource.cpp +++ b/service/easy-setup/mediator/richsdk/src/EnrolleeResource.cpp @@ -36,161 +36,194 @@ namespace OIC EnrolleeResource::EnrolleeResource(std::shared_ptr< OC::OCResource > resource) { m_ocResource = resource; + m_getStatusCb = nullptr; + m_getConfigurationStatusCb = nullptr; + m_devicePropProvStatusCb = nullptr; + m_connectRequestStatusCb = nullptr; } - void EnrolleeResource::checkProvInformationCb(const HeaderOptions& /*headerOptions*/, - const OCRepresentation& rep, const int eCode) + void EnrolleeResource::onEnrolleeResourceSafetyCB(const HeaderOptions& headerOptions, + const OCRepresentation& rep, + const int eCode, + ESEnrolleeResourceCb cb, + std::weak_ptr this_ptr) { - OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "checkProvInformationCb : %s, eCode = %d", - rep.getUri().c_str(), - eCode); + OIC_LOG(DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "onEnrolleeResourceSafetyCB"); + std::shared_ptr Ptr = this_ptr.lock(); + if(Ptr) + { + cb(headerOptions, rep, eCode); + } + } - if (eCode != 0) + void EnrolleeResource::onProvisioningResponse(const HeaderOptions& /*headerOptions*/, + const OCRepresentation& /*rep*/, const int eCode) + { + OIC_LOG_V(DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "onProvisioningResponse : eCode = %d", + eCode); + + if (eCode > OCStackResult::OC_STACK_RESOURCE_CHANGED) { - OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, - "checkProvInformationCb : Provisioning is failed "); - std::shared_ptr< DataProvisioningStatus > provStatus = std::make_shared< - DataProvisioningStatus >(ESResult::ES_ERROR, ESDataProvState::ES_PROVISIONING_ERROR); - m_dataProvStatusCb(provStatus); + ESResult result = ESResult::ES_ERROR; + + OIC_LOG(ERROR, ES_REMOTE_ENROLLEE_RES_TAG, + "onProvisioningResponse : Provisioning is failed "); + + if(eCode == OCStackResult::OC_STACK_COMM_ERROR) + { + OIC_LOG(ERROR, ES_REMOTE_ENROLLEE_RES_TAG, + "can't receive any response from Enrollee by a timeout threshold."); + result = ESResult::ES_COMMUNICATION_ERROR; + } + + std::shared_ptr< DevicePropProvisioningStatus > provStatus = std::make_shared< + DevicePropProvisioningStatus >(result); + m_devicePropProvStatusCb(provStatus); return; } - // int ps = -1; - // rep.getValue(OC_RSRVD_ES_PROVSTATUS, ps); - // OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "checkProvInformationCb : ps - %d", ps); - OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, - "checkProvInformationCb : Provisioning is success. " - "Now trigger network connection "); + OIC_LOG(DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, + "onProvisioningResponse : Provisioning is success. "); - std::shared_ptr< DataProvisioningStatus > provStatus = std::make_shared< - DataProvisioningStatus >(ESResult::ES_OK, ESDataProvState::ES_PROVISIONING_SUCCESS); - m_dataProvStatusCb(provStatus); + std::shared_ptr< DevicePropProvisioningStatus > provStatus = std::make_shared< + DevicePropProvisioningStatus >(ESResult::ES_OK); + m_devicePropProvStatusCb(provStatus); } - void EnrolleeResource::onRequestPropertyDataResponse(const HeaderOptions& /*headerOptions*/, + void EnrolleeResource::onGetStatusResponse(const HeaderOptions& /*headerOptions*/, const OCRepresentation& rep, const int eCode) { - OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "onRequestPropertyDataResponse : %s, eCode = %d", - rep.getUri().c_str(), eCode); + OIC_LOG_V(DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "onGetStatusResponse : eCode = %d", + eCode); - if (eCode != 0) + if (eCode > OCStackResult::OC_STACK_RESOURCE_CHANGED) { - ESResult result = ESResult::ES_ERROR; + ESResult result = ESResult::ES_ERROR; - OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG,"onRequestPropertyDataResponse : onRequestPropertyDataResponse is failed "); + OIC_LOG(ERROR, ES_REMOTE_ENROLLEE_RES_TAG, + "onGetStatusResponse : onGetStatusResponse is failed "); - if (eCode == OCStackResult::OC_STACK_UNAUTHORIZED_REQ) + if(eCode == OCStackResult::OC_STACK_COMM_ERROR) { - OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, - "Mediator is unauthorized from Enrollee."); - result = ESResult::ES_UNAUTHORIZED; + OIC_LOG(ERROR, ES_REMOTE_ENROLLEE_RES_TAG, + "can't receive any response from Enrollee by a timeout threshold."); + result = ESResult::ES_COMMUNICATION_ERROR; } - PropertyData propertyData; - std::shared_ptr< RequestPropertyDataStatus > requestPropertyDataStatus = std::make_shared< - RequestPropertyDataStatus >(result, propertyData ); - m_RequestPropertyDataStatusCb(requestPropertyDataStatus); - } + EnrolleeStatus enrolleeStatus(rep); + std::shared_ptr< GetEnrolleeStatus > getEnrolleeStatus = std::make_shared< + GetEnrolleeStatus >(result, enrolleeStatus); + m_getStatusCb(getEnrolleeStatus); + } else { - PropertyData propertyData = parsePropertyDataFromRepresentation(rep); + EnrolleeStatus enrolleeStatus(rep); + std::shared_ptr< GetEnrolleeStatus > getEnrolleeStatus = std::make_shared< + GetEnrolleeStatus >(ESResult::ES_OK, enrolleeStatus); - std::shared_ptr< RequestPropertyDataStatus > requestPropertyDataStatus = std::make_shared< - RequestPropertyDataStatus >(ESResult::ES_OK, propertyData); - m_RequestPropertyDataStatusCb(requestPropertyDataStatus); + m_getStatusCb(getEnrolleeStatus); } } - void EnrolleeResource::getProvStatusResponse(const HeaderOptions& /*headerOptions*/, + void EnrolleeResource::onGetConfigurationResponse(const HeaderOptions& /*headerOptions*/, const OCRepresentation& rep, const int eCode) { - OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "getProvStatusResponse : %s, eCode = %d", - rep.getUri().c_str(), - eCode); + OIC_LOG_V(DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "onGetConfigurationResponse : eCode = %d", + eCode); - if (eCode != 0) + if (eCode > OCStackResult::OC_STACK_RESOURCE_CHANGED) { - ESResult result = ESResult::ES_ERROR; + ESResult result = ESResult::ES_ERROR; - OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG,"getProvStatusResponse : Provisioning is failed "); + OIC_LOG(ERROR, ES_REMOTE_ENROLLEE_RES_TAG, + "onGetConfigurationResponse : onGetConfigurationResponse is failed "); - if (eCode == OCStackResult::OC_STACK_UNAUTHORIZED_REQ) + if(eCode == OCStackResult::OC_STACK_COMM_ERROR) { - OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, - "Mediator is unauthorized from Enrollee."); - result = ESResult::ES_UNAUTHORIZED; + OIC_LOG(ERROR, ES_REMOTE_ENROLLEE_RES_TAG, + "can't receive any response from Enrollee by a timeout threshold."); + result = ESResult::ES_COMMUNICATION_ERROR; } - std::shared_ptr< DataProvisioningStatus > provStatus = std::make_shared< - DataProvisioningStatus >(result, ESDataProvState::ES_PROVISIONING_ERROR); - m_dataProvStatusCb(provStatus); - return; + EnrolleeConf enrolleeConf(rep); + std::shared_ptr< GetConfigurationStatus > getConfigurationStatus = std::make_shared< + GetConfigurationStatus >(result, enrolleeConf); + m_getConfigurationStatusCb(getConfigurationStatus); } + else + { + EnrolleeConf enrolleeConf(rep); - int ps = -1; - - rep.getValue(OC_RSRVD_ES_PROVSTATUS, ps); + std::shared_ptr< GetConfigurationStatus > getConfigurationStatus = std::make_shared< + GetConfigurationStatus >(ESResult::ES_OK, enrolleeConf); + m_getConfigurationStatusCb(getConfigurationStatus); + } + } - OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "getProvStatusResponse : ps - %d", - ps); + void EnrolleeResource::onConnectRequestResponse(const HeaderOptions& /*headerOptions*/, + const OCRepresentation& /*rep*/, const int eCode) + { + OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "onConnectRequestResponse : eCode = %d", + eCode); - //if (ps == ES_PS_NEED_PROVISIONING) //Indicates the need for provisioning - if (ps == 0) //Indicates the need for provisioning - { - OCRepresentation provisioningRepresentation; - - provisioningRepresentation.setValue(OC_RSRVD_ES_SSID, m_dataProvInfo.WIFI.ssid); - provisioningRepresentation.setValue(OC_RSRVD_ES_CRED, m_dataProvInfo.WIFI.pwd); - provisioningRepresentation.setValue(OC_RSRVD_ES_AUTHTYPE, m_dataProvInfo.WIFI.authtype); - provisioningRepresentation.setValue(OC_RSRVD_ES_ENCTYPE, m_dataProvInfo.WIFI.enctype); - provisioningRepresentation.setValue(OC_RSRVD_ES_LANGUAGE, m_dataProvInfo.Device.language); - provisioningRepresentation.setValue(OC_RSRVD_ES_COUNTRY, m_dataProvInfo.Device.country); - - OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "getProvStatusResponse : ssid - %s", - (m_dataProvInfo.WIFI.ssid).c_str()); - OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "getProvStatusResponse : pwd - %s", - (m_dataProvInfo.WIFI.pwd).c_str()); - OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "getProvStatusResponse : authtype - %d", - m_dataProvInfo.WIFI.authtype); - OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "getProvStatusResponse : enctype - %d", - m_dataProvInfo.WIFI.enctype); - OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "getProvStatusResponse : language - %s", - (m_dataProvInfo.Device.language).c_str()); - OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "getProvStatusResponse : country - %s", - (m_dataProvInfo.Device.country).c_str()); - - m_ocResource->post(OC_RSRVD_ES_PROV_RES_TYPE, BATCH_INTERFACE, - provisioningRepresentation, QueryParamsMap(), - std::function< - void(const HeaderOptions& headerOptions, - const OCRepresentation& rep, const int eCode) >( - std::bind(&EnrolleeResource::checkProvInformationCb, this, - std::placeholders::_1, std::placeholders::_2, - std::placeholders::_3))); - } - else if (ps == ES_PS_PROVISIONING_COMPLETED) //Indicates that provisioning is completed + if (eCode > OCStackResult::OC_STACK_RESOURCE_CHANGED) { + ESResult result = ESResult::ES_ERROR; + OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, - "getProvStatusResponse : Provisioning is successful"); - std::shared_ptr< DataProvisioningStatus > provStatus = std::make_shared< - DataProvisioningStatus >(ESResult::ES_OK, ESDataProvState::ES_PROVISIONED_ALREADY); - m_dataProvStatusCb(provStatus); + "onConnectRequestResponse : onConnectRequestResponse is failed "); + + if(eCode == OCStackResult::OC_STACK_COMM_ERROR) + { + OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, + "can't receive any response from Enrollee by a timeout threshold."); + result = ESResult::ES_COMMUNICATION_ERROR; + } + + std::shared_ptr< ConnectRequestStatus > connectRequestStatus = std::make_shared< + ConnectRequestStatus >(result); + m_connectRequestStatusCb(connectRequestStatus); + return; } + + OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, + "onConnectRequestResponse : Provisioning is success. "); + + std::shared_ptr< ConnectRequestStatus > connectRequestStatus = std::make_shared< + ConnectRequestStatus >(ESResult::ES_OK); + m_connectRequestStatusCb(connectRequestStatus); } - void EnrolleeResource::registerRequestPropertyDataStatusCallback(RequestPropertyDataStatusCb callback) + + void EnrolleeResource::registerGetStatusCallback( + const GetStatusCb callback) { - m_RequestPropertyDataStatusCb = callback; + m_getStatusCb = callback; } - void EnrolleeResource::registerProvStatusCallback(DataProvStatusCb callback) + void EnrolleeResource::registerGetConfigurationStatusCallback( + const GetConfigurationStatusCb callback) { - m_dataProvStatusCb = callback; + m_getConfigurationStatusCb = callback; } - void EnrolleeResource::RequestPropertyData() + void EnrolleeResource::registerDevicePropProvStatusCallback( + const DevicePropProvStatusCb callback) { + m_devicePropProvStatusCb = callback; + } + + void EnrolleeResource::registerConnectRequestStatusCallback( + const ConnectRequestStatusCb callback) + { + m_connectRequestStatusCb = callback; + } + + void EnrolleeResource::getStatus() + { + OIC_LOG(DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "getStatus IN"); + if (m_ocResource == nullptr) { throw ESBadRequestException("Resource is not initialized"); @@ -199,151 +232,128 @@ namespace OIC OC::QueryParamsMap query; OC::OCRepresentation rep; - std::function< OCStackResult(void) > requestPropertyDataStatus = [&] - { return m_ocResource->get(m_ocResource->getResourceTypes().at(0), - BATCH_INTERFACE, query, std::function( - std::bind(&EnrolleeResource::onRequestPropertyDataResponse, this, - std::placeholders::_1, std::placeholders::_2, - std::placeholders::_3))); + std::function< OCStackResult(void) > getStatus = [&] + { + ESEnrolleeResourceCb cb = std::bind(&EnrolleeResource::onEnrolleeResourceSafetyCB, + std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, + static_cast( + std::bind(&EnrolleeResource::onGetStatusResponse, this, + std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)), + shared_from_this()); + + return m_ocResource->get(m_ocResource->getResourceTypes().at(0), + DEFAULT_INTERFACE, query, cb, OC::QualityOfService::HighQos); }; - OCStackResult result = requestPropertyDataStatus(); + OCStackResult result = getStatus(); if (result != OCStackResult::OC_STACK_OK) { - PropertyData propertyData; - std::shared_ptr< RequestPropertyDataStatus > requestPropertyDataStatus = std::make_shared< - RequestPropertyDataStatus >(ESResult::ES_ERROR, propertyData); - m_RequestPropertyDataStatusCb(requestPropertyDataStatus); + EnrolleeStatus enrolleeStatus(rep);// = {ES_STATE_INIT, ES_ERRCODE_NO_ERROR}; + std::shared_ptr< GetEnrolleeStatus > getEnrolleeStatus = std::make_shared< + GetEnrolleeStatus >(ESResult::ES_ERROR, enrolleeStatus); + + m_getStatusCb(getEnrolleeStatus); + return; } + OIC_LOG(DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "getStatus OUT"); } - void EnrolleeResource::provisionEnrollee(const DataProvInfo& dataProvInfo) - + void EnrolleeResource::getConfiguration() { + OIC_LOG(DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "getConfiguration IN"); + if (m_ocResource == nullptr) { throw ESBadRequestException("Resource is not initialized"); } - m_dataProvInfo = dataProvInfo; - OC::QueryParamsMap query; OC::OCRepresentation rep; - std::function< OCStackResult(void) > getProvisioingStatus = [&] - { return m_ocResource->get(m_ocResource->getResourceTypes().at(0), - m_ocResource->getResourceInterfaces().at(0), query, - std::function< - void(const HeaderOptions& headerOptions, const OCRepresentation& rep, - const int eCode) >( - std::bind(&EnrolleeResource::getProvStatusResponse, this, - std::placeholders::_1, std::placeholders::_2, - std::placeholders::_3))); + std::function< OCStackResult(void) > getConfigurationStatus = [&] + { + ESEnrolleeResourceCb cb = std::bind(&EnrolleeResource::onEnrolleeResourceSafetyCB, + std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, + static_cast( + std::bind(&EnrolleeResource::onGetConfigurationResponse, this, + std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)), + shared_from_this()); + + return m_ocResource->get(m_ocResource->getResourceTypes().at(0), + BATCH_INTERFACE, query, cb, OC::QualityOfService::HighQos); }; - OCStackResult result = getProvisioingStatus(); + OCStackResult result = getConfigurationStatus(); if (result != OCStackResult::OC_STACK_OK) { - std::shared_ptr< DataProvisioningStatus > provStatus = std::make_shared< - DataProvisioningStatus >(ESResult::ES_ERROR, ESDataProvState::ES_PROVISIONING_ERROR); - m_dataProvStatusCb(provStatus); + EnrolleeConf enrolleeConf(rep); + std::shared_ptr< GetConfigurationStatus > getConfigurationStatus = std::make_shared< + GetConfigurationStatus >(ESResult::ES_ERROR, enrolleeConf); + m_getConfigurationStatusCb(getConfigurationStatus); return; } + + OIC_LOG(DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "getConfiguration OUT"); } - void EnrolleeResource::unprovisionEnrollee() + void EnrolleeResource::provisionProperties(const DeviceProp& deviceProp) { + OIC_LOG(DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "provisionProperties IN"); if (m_ocResource == nullptr) { throw ESBadRequestException("Resource is not initialized"); } - OCRepresentation provisioningRepresentation; + OC::QueryParamsMap query; + OC::OCRepresentation provisioningRepresentation = deviceProp.toOCRepresentation(); + + ESEnrolleeResourceCb cb = std::bind(&EnrolleeResource::onEnrolleeResourceSafetyCB, + std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, + static_cast( + std::bind(&EnrolleeResource::onProvisioningResponse, this, + std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)), + shared_from_this()); - provisioningRepresentation.setValue(OC_RSRVD_ES_SSID, ""); - provisioningRepresentation.setValue(OC_RSRVD_ES_CRED, ""); + m_ocResource->post(OC_RSRVD_ES_RES_TYPE_EASYSETUP, BATCH_INTERFACE, + provisioningRepresentation, QueryParamsMap(), cb, OC::QualityOfService::HighQos); - m_ocResource->post(provisioningRepresentation, QueryParamsMap(), - std::function< - void(const HeaderOptions& headerOptions, const OCRepresentation& rep, - const int eCode) >( - std::bind(&EnrolleeResource::checkProvInformationCb, this, - std::placeholders::_1, std::placeholders::_2, - std::placeholders::_3))); + OIC_LOG(DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "provisionProperties OUT"); } - PropertyData EnrolleeResource::parsePropertyDataFromRepresentation(const OCRepresentation& rep) + void EnrolleeResource::requestToConnect(const std::vector &connectTypes) { - OIC_LOG(DEBUG,ES_REMOTE_ENROLLEE_RES_TAG, "Enter parsePropertyDataFromRepresentation"); - - DeviceConfig devInfo; - NetworkInfo netInfo; - bool cloudable = false; - - std::vector children = rep.getChildren(); - - for(auto prop = children.begin(); prop != children.end(); ++prop) + OIC_LOG (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "requestToConnect IN"); + if (m_ocResource == nullptr) { - if(prop->getUri().find(OC_RSRVD_ES_URI_WIFI) != std::string::npos) - { - OIC_LOG(DEBUG,ES_REMOTE_ENROLLEE_RES_TAG, "Find wifi resource"); - if(prop->hasAttribute(OC_RSRVD_ES_SUPPORTEDWIFIMODE) - && prop->hasAttribute(OC_RSRVD_ES_SUPPORTEDWIFIFREQ)) - { - std::vector types = prop->getValue>(OC_RSRVD_ES_SUPPORTEDWIFIMODE); - - for(auto type = types.begin(); type != types.end(); ++type) - { - OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "OC_RSRVD_ES_SUPPORTEDWIFIMODE = %d", - *type); - netInfo.types.push_back(static_cast(*type)); - } + throw ESBadRequestException("Resource is not initialized"); + } - netInfo.freq = static_cast(prop->getValue(OC_RSRVD_ES_SUPPORTEDWIFIFREQ)); + OC::QueryParamsMap query; + OC::OCRepresentation requestRepresentation; + std::vector connectTypes_int; + connectTypes_int.clear(); + for(auto it : connectTypes) + { + connectTypes_int.push_back(static_cast(it)); + } - OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "OC_RSRVD_ES_SUPPORTEDWIFIFREQ = %d", - netInfo.freq); - } - } + requestRepresentation.setValue>(OC_RSRVD_ES_CONNECT, connectTypes_int); - else if(prop->getUri().find(OC_RSRVD_ES_URI_DEVCONF) != std::string::npos) - { - OIC_LOG(DEBUG,ES_REMOTE_ENROLLEE_RES_TAG, "Find devconf"); - if(prop->hasAttribute(OC_RSRVD_ES_DEVNAME) - && prop->hasAttribute(OC_RSRVD_ES_LANGUAGE) - && prop->hasAttribute(OC_RSRVD_ES_COUNTRY)) - { - //TODO:: setting DeviceID. - //devInfo.id = devId; - devInfo.name = prop->getValue(OC_RSRVD_ES_DEVNAME); - devInfo.language = prop->getValue(OC_RSRVD_ES_LANGUAGE); - devInfo.country = prop->getValue(OC_RSRVD_ES_COUNTRY); - - OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "OC_RSRVD_ES_DEVNAME = %s", - devInfo.name.c_str()); - OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "OC_RSRVD_ES_LANGUAGE = %s", - devInfo.language.c_str()); - OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "OC_RSRVD_ES_COUNTRY = %s", - devInfo.country.c_str()); - } - } + ESEnrolleeResourceCb cb = std::bind(&EnrolleeResource::onEnrolleeResourceSafetyCB, + std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, + static_cast( + std::bind(&EnrolleeResource::onConnectRequestResponse, this, + std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)), + shared_from_this()); - else if(prop->getUri().find(OC_RSRVD_ES_URI_CLOUDSERVER) != std::string::npos) - { - OIC_LOG(DEBUG,ES_REMOTE_ENROLLEE_RES_TAG, "Find cloudserver"); - cloudable = true; - OIC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "cloudable = %d", - cloudable); - } - } + m_ocResource->post(OC_RSRVD_ES_RES_TYPE_EASYSETUP, OC_RSRVD_INTERFACE_DEFAULT, + requestRepresentation, QueryParamsMap(), cb, OC::QualityOfService::HighQos); - return PropertyData(devInfo, netInfo, cloudable); + OIC_LOG (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "requestToConnect OUT"); } - } }