if(CreateEasySetupResources(gIsSecured, resourceMask) != OC_STACK_OK)
{
- // TODO : Error Handling
+ UnRegisterResourceEventCallBack();
+
+ if (DeleteEasySetupResources() != OC_STACK_OK)
+ {
+ OIC_LOG(ERROR, ES_ENROLLEE_TAG, "Deleting prov resource error!!");
+ }
+
return ES_ERROR;
}
if(SetDeviceProperty(deviceProperty) != OC_STACK_OK)
{
+ OIC_LOG(ERROR, ES_ENROLLEE_TAG, "ESSetDeviceProperty Error");
return ES_ERROR;
}
OICStrcpy((gESDeviceProperty.DevConf).deviceName, MAX_DEVICELEN, (deviceProperty->DevConf).deviceName);
OIC_LOG_V(INFO, ES_ENROLLEE_TAG, "Device Name : %s", (gESDeviceProperty.DevConf).deviceName);
-
OIC_LOG(INFO, ES_ENROLLEE_TAG, "ESSetDeviceProperty OUT");
return ES_OK;
}
+ESResult ESSetState(ESEnrolleeState esState)
+{
+ OIC_LOG(INFO, ES_ENROLLEE_TAG, "ESSetState IN");
+
+ if(esState <= 0 || esState >= 6)
+ {
+ OIC_LOG_V(ERROR, ES_ENROLLEE_TAG, "Invalid ESEnrolleeState : %d", esState);
+ return ES_ERROR;
+ }
+
+ if(SetEnrolleeState(esState) != OC_STACK_OK)
+ {
+ OIC_LOG(ERROR, ES_ENROLLEE_TAG, "ESSetState Error");
+ return ES_ERROR;
+ }
+
+ OIC_LOG(INFO, ES_ENROLLEE_TAG, "ESSetState OUT");
+ return ES_OK;
+}
+
+ESResult ESSetErrorCode(ESErrorCode esErrCode)
+{
+ OIC_LOG(INFO, ES_ENROLLEE_TAG, "ESSetErrorCode IN");
+
+ if(esErrCode <= 0 || esErrCode >= 7)
+ {
+ if(esErrCode != 999)
+ {
+ OIC_LOG_V(ERROR, ES_ENROLLEE_TAG, "Invalid ESErrorCode : %d", esErrCode);
+ return ES_ERROR;
+ }
+ }
+
+ if(SetEnrolleeErrCode(esErrCode) != OC_STACK_OK)
+ {
+ OIC_LOG(ERROR, ES_ENROLLEE_TAG, "ESSetErrorCode Error");
+ return ES_ERROR;
+ }
+
+ OIC_LOG(INFO, ES_ENROLLEE_TAG, "ESSetErrorCode OUT");
+ return ES_OK;
+}
+
ESResult ESTerminateEnrollee()
{
+ OIC_LOG(INFO, ES_ENROLLEE_TAG, "ESTerminateEnrollee IN");
+
UnRegisterResourceEventCallBack();
//Delete Prov resource
res = initWiFiResource(isSecured);
if(res != OC_STACK_OK)
{
- // TODO: destroy logic will be added
OIC_LOG_V(ERROR, ES_RH_TAG, "initWiFiResource result: %s", getResult(res));
-
return res;
}
res = OCBindResource(gProvResource.handle, gWiFiResource.handle);
if(res != OC_STACK_OK)
{
- // TODO : Error Handling
OIC_LOG_V(ERROR, ES_RH_TAG, "Bind WiFiResource result: %s", getResult(res));
-
return res;
}
res = initCloudServerResource(isSecured);
if(res != OC_STACK_OK)
{
- // TODO: destroy logic will be added
OIC_LOG_V(ERROR, ES_RH_TAG, "initCloudResource result: %s", getResult(res));
-
return res;
}
res = OCBindResource(gProvResource.handle, gCloudResource.handle);
if(res != OC_STACK_OK)
{
- // TODO : Error Handling
OIC_LOG_V(ERROR, ES_RH_TAG, "Bind CloudResource result: %s", getResult(res));
-
return res;
}
}
res = initDevConfResource(isSecured);
if(res != OC_STACK_OK)
{
- // TODO: destroy logic will be added
OIC_LOG_V(ERROR, ES_RH_TAG, "initDevConf result: %s", getResult(res));
-
return res;
}
res = OCBindResource(gProvResource.handle, gDevConfResource.handle);
if(res != OC_STACK_OK)
{
- // TODO : Error Handling
OIC_LOG_V(ERROR, ES_RH_TAG, "Bind DevConfResource result: %s", getResult(res));
-
return res;
}
}
if(maskFlag == false)
{
- // TODO: destroy logic will be added
OIC_LOG_V(ERROR, ES_RH_TAG, "Invalid ResourceMask");
return OC_STACK_ERROR;
}
+
OIC_LOG_V(INFO, ES_RH_TAG, "Created all resources with result: %s", getResult(res));
+
return res;
}
OCStackResult DeleteEasySetupResources()
{
- OCStackResult res = OCDeleteResource(gProvResource.handle);
+ OCStackResult res = OCDeleteResource(gWiFiResource.handle);
if (res != OC_STACK_OK)
{
- OIC_LOG_V(INFO, ES_RH_TAG, "Deleting Prov resource error with result: %s", getResult(res));
+ OIC_LOG_V(ERROR, ES_RH_TAG, "Deleting WiFi resource error with result: %s", getResult(res));
}
- res = OCDeleteResource(gWiFiResource.handle);
+ res = OCDeleteResource(gCloudResource.handle);
if (res != OC_STACK_OK)
{
- OIC_LOG_V(INFO, ES_RH_TAG, "Deleting WiFi resource error with result: %s", getResult(res));
+ OIC_LOG_V(ERROR, ES_RH_TAG, "Deleting CloudServer resource error with result: %s", getResult(res));
}
- res = OCDeleteResource(gCloudResource.handle);
+ res = OCDeleteResource(gDevConfResource.handle);
if (res != OC_STACK_OK)
{
- OIC_LOG_V(INFO, ES_RH_TAG, "Deleting CloudServer resource error with result: %s", getResult(res));
+ OIC_LOG_V(ERROR, ES_RH_TAG, "Deleting DevConf resource error with result: %s", getResult(res));
}
- res = OCDeleteResource(gDevConfResource.handle);
+
+ res = OCDeleteResource(gProvResource.handle);
if (res != OC_STACK_OK)
{
- OIC_LOG_V(INFO, ES_RH_TAG, "Deleting DevConf resource error with result: %s", getResult(res));
+ OIC_LOG_V(ERROR, ES_RH_TAG, "Deleting Prov resource error with result: %s", getResult(res));
}
return res;
OIC_LOG_V(INFO, ES_RH_TAG, "Device Name : %s", gDevConfResource.devName);
OIC_LOG(INFO, ES_RH_TAG, "SetDeviceProperty OUT");
- return OC_EH_OK;
+ return OC_STACK_OK;
+}
+
+OCStackResult SetEnrolleeState(ESEnrolleeState esState)
+{
+ OIC_LOG(INFO, ES_RH_TAG, "SetEnrolleeState IN");
+
+ gProvResource.status = esState;
+ OIC_LOG_V(INFO, ES_RH_TAG, "Enrollee Status : %d", gProvResource.status);
+
+ OIC_LOG(INFO, ES_RH_TAG, "SetEnrolleeState OUT");
+ return OC_STACK_OK;
}
+OCStackResult SetEnrolleeErrCode(ESErrorCode esErrCode)
+{
+ OIC_LOG(INFO, ES_RH_TAG, "SetEnrolleeErrCode IN");
+
+ gProvResource.lastErrCode = esErrCode;
+ OIC_LOG_V(INFO, ES_RH_TAG, "Enrollee ErrorCode : %d", gProvResource.lastErrCode);
+
+ OIC_LOG(INFO, ES_RH_TAG, "SetEnrolleeErrCode OUT");
+ return OC_STACK_OK;
+}
const char *getResult(OCStackResult result)
{
switch (result)