m_enrolleeNWProvInfo = enrolleeNWProvInfo;\r
}\r
\r
- void RemoteEnrolleeResource::onProvPostResource(const HeaderOptions& /*headerOptions*/,\r
+ void RemoteEnrolleeResource::checkProvInformationCb(const HeaderOptions& /*headerOptions*/,\r
const OCRepresentation& rep, const int eCode)\r
{\r
- OC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_TAG, "onProvPostResource : %s, eCode = %d",\r
+ OC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_TAG, "checkProvInformationCb : %s, eCode = %d",\r
rep.getUri().c_str(),\r
eCode);\r
\r
if(eCode != 0)\r
{\r
OC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_TAG,\r
- "onProvPostResource : Provisioning is failed ");\r
+ "checkProvInformationCb : Provisioning is failed ");\r
std::shared_ptr< ProvisioningStatus > provStatus = std::make_shared<\r
ProvisioningStatus >(ESResult::ES_ERROR, ESState::ES_PROVISIONING_ERROR);\r
m_provStatusCb(provStatus);\r
rep.getValue(OC_RSRVD_ES_TNN, tnn);\r
rep.getValue(OC_RSRVD_ES_CD, cd);\r
\r
- OC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_TAG, "onProvPostResource : ps - %d",\r
- ps);OC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_TAG, "onProvResource : tnn - %s",\r
- tnn.c_str());OC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_TAG, "onProvResource : cd - %s",\r
- cd.c_str());\r
+ OC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_TAG, "checkProvInformationCb : ps - %d", ps);\r
+ OC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_TAG, "checkProvInformationCb : tnn - %s", tnn.c_str());\r
+ OC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_TAG, "checkProvInformationCb : cd - %s", cd.c_str());\r
\r
//Provisioning status check\r
- if (ps == 0)\r
+ if (ps == ES_PS_PROVISIONING_COMPLETED)\r
{\r
- OC::QueryParamsMap query;\r
- OC::OCRepresentation rep;\r
-\r
- OCStackResult result = m_ocResource->get(m_ocResource->getResourceTypes().at(0),\r
- m_ocResource->getResourceInterfaces().at(0), query,\r
- std::function<\r
- void(const HeaderOptions& headerOptions,\r
- const OCRepresentation& rep, const int eCode) >(\r
- std::bind(&RemoteEnrolleeResource::onProvResource, this,\r
- std::placeholders::_1, std::placeholders::_2,\r
- std::placeholders::_3)));\r
+ if(tnn != std::string(m_enrolleeNWProvInfo.netAddressInfo.WIFI.ssid))\r
+ {\r
+ OC_LOG_V (ERROR, ES_REMOTE_ENROLLEE_TAG,\r
+ "checkProvInformationCb : Network SSID is not the same as the "\r
+ "SSID provisioned");\r
+ std::shared_ptr< ProvisioningStatus > provStatus = std::make_shared<\r
+ ProvisioningStatus >(ESResult::ES_ERROR,\r
+ ESState::ES_PROVISIONING_ERROR);\r
+ m_provStatusCb(provStatus);\r
+ return;\r
+ }\r
\r
- if(result != OCStackResult::OC_STACK_OK)\r
+ if(cd != std::string(m_enrolleeNWProvInfo.netAddressInfo.WIFI.pwd))\r
{\r
+ OC_LOG_V (ERROR, ES_REMOTE_ENROLLEE_TAG,\r
+ "checkProvInformationCb : Network PWD is not the same as the "\r
+ "PWD provisioned");\r
std::shared_ptr< ProvisioningStatus > provStatus = std::make_shared<\r
ProvisioningStatus >(ESResult::ES_ERROR,\r
ESState::ES_PROVISIONING_ERROR);\r
m_provStatusCb(provStatus);\r
return;\r
}\r
+\r
+ OC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_TAG,\r
+ "checkProvInformationCb : Provisioning is success ");\r
+ std::shared_ptr< ProvisioningStatus > provStatus = std::make_shared<\r
+ ProvisioningStatus >(ESResult::ES_OK, ESState::ES_PROVISIONING_SUCCESS);\r
+ m_provStatusCb(provStatus);\r
+ return;\r
}\r
else\r
{\r
OC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_TAG,\r
- "onProvResource : Provisioning is failed ");\r
+ "checkProvInformationCb : Provisioning is failed ");\r
std::shared_ptr< ProvisioningStatus > provStatus = std::make_shared<\r
ProvisioningStatus >(ESResult::ES_ERROR, ESState::ES_PROVISIONING_ERROR);\r
m_provStatusCb(provStatus);\r
}\r
}\r
\r
- void RemoteEnrolleeResource::onProvResource(const HeaderOptions& /*headerOptions*/,\r
+ void RemoteEnrolleeResource::getProvStatusResponse(const HeaderOptions& /*headerOptions*/,\r
const OCRepresentation& rep,\r
const int eCode)\r
{\r
- OC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_TAG, "onProvResource : %s, eCode = %d",\r
+ OC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_TAG, "getProvStatusResponse : %s, eCode = %d",\r
rep.getUri().c_str(),\r
eCode);\r
\r
if (eCode != 0)\r
{\r
OC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_TAG,\r
- "onProvResource : Provisioning is failed ");\r
+ "getProvStatusResponse : Provisioning is failed ");\r
std::shared_ptr< ProvisioningStatus > provStatus = std::make_shared<\r
ProvisioningStatus >(ESResult::ES_ERROR, ESState::ES_PROVISIONING_ERROR);\r
m_provStatusCb(provStatus);\r
rep.getValue(OC_RSRVD_ES_TNN, tnn);\r
rep.getValue(OC_RSRVD_ES_CD, cd);\r
\r
- OC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_TAG, "onProvResource : ps - %d",\r
+ OC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_TAG, "getProvStatusResponse : ps - %d",\r
ps);\r
- OC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_TAG, "onProvResource : tnn - %s",\r
+ OC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_TAG, "getProvStatusResponse : tnn - %s",\r
tnn.c_str());\r
- OC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_TAG, "onProvResource : cd - %s",\r
+ OC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_TAG, "getProvStatusResponse : cd - %s",\r
cd.c_str());\r
\r
- if (ps == 1) //ps == 1 indicates the need for provisioning\r
+ if (ps == ES_PS_NEED_PROVISIONING) //Indicates the need for provisioning\r
{\r
OCRepresentation provisioningRepresentation;\r
\r
provisioningRepresentation.setValue(OC_RSRVD_ES_CD,\r
std::string(m_enrolleeNWProvInfo.netAddressInfo.WIFI.pwd));\r
\r
- OC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_TAG, "onProvResource : ssid - %s",\r
+ OC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_TAG, "getProvStatusResponse : ssid - %s",\r
m_enrolleeNWProvInfo.netAddressInfo.WIFI.ssid);\r
- OC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_TAG, "onProvResource : pwd - %s",\r
+ OC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_TAG, "getProvStatusResponse : pwd - %s",\r
m_enrolleeNWProvInfo.netAddressInfo.WIFI.pwd);\r
\r
m_ocResource->put(provisioningRepresentation, QueryParamsMap(),\r
std::function<\r
void(const HeaderOptions& headerOptions,\r
const OCRepresentation& rep, const int eCode) >(\r
- std::bind(&RemoteEnrolleeResource::onProvPostResource, this,\r
+ std::bind(&RemoteEnrolleeResource::checkProvInformationCb, this,\r
std::placeholders::_1, std::placeholders::_2,\r
std::placeholders::_3)));\r
}\r
- else if(ps == 0) //ps == 1 indicates that provisioning is completed\r
+ else if(ps == ES_PS_PROVISIONING_COMPLETED) //Indicates that provisioning is completed\r
{\r
OC_LOG_V (DEBUG, ES_REMOTE_ENROLLEE_TAG,\r
- "onProvResource : Provisioning is successful");\r
+ "getProvStatusResponse : Provisioning is successful");\r
std::shared_ptr< ProvisioningStatus > provStatus = std::make_shared<\r
ProvisioningStatus >(ESResult::ES_OK, ESState::ES_PROVISIONED_ALREADY);\r
m_provStatusCb(provStatus);\r
OC::QueryParamsMap query;\r
OC::OCRepresentation rep;\r
\r
- OCStackResult result = m_ocResource->get(m_ocResource->getResourceTypes().at(0),\r
- m_ocResource->getResourceInterfaces().at(0), query,\r
- std::function<\r
- void(const HeaderOptions& headerOptions, const OCRepresentation& rep,\r
- const int eCode) >(\r
- std::bind(&RemoteEnrolleeResource::onProvResource, this,\r
- std::placeholders::_1, std::placeholders::_2,\r
- std::placeholders::_3)));\r
+ std::function <OCStackResult(void)> getProvisioingStatus = [&]\r
+ { return m_ocResource->get(m_ocResource->getResourceTypes().at(0),\r
+ m_ocResource->getResourceInterfaces().at(0), query,\r
+ std::function<\r
+ void(const HeaderOptions& headerOptions, const OCRepresentation& rep,\r
+ const int eCode) >(\r
+ std::bind(&RemoteEnrolleeResource::getProvStatusResponse, this,\r
+ std::placeholders::_1, std::placeholders::_2,\r
+ std::placeholders::_3)));\r
+ };\r
+\r
+ OCStackResult result = getProvisioingStatus();\r
\r
if (result != OCStackResult::OC_STACK_OK)\r
{\r
std::function<\r
void(const HeaderOptions& headerOptions, const OCRepresentation& rep,\r
const int eCode) >(\r
- std::bind(&RemoteEnrolleeResource::onProvPostResource, this,\r
+ std::bind(&RemoteEnrolleeResource::checkProvInformationCb, this,\r
std::placeholders::_1, std::placeholders::_2,\r
std::placeholders::_3)));\r
}\r