char *str = OICStrdup(from);
char *ptr = strtok(str, ";");
- if(ptr == NULL)
+ if (ptr == NULL)
{
+ OICFree(str);
return false;
}
do
{
- if(strstr(ptr, ".if."))
+ if (strstr(ptr, ".if."))
{
char *if_ptr = NULL;
if_ptr = strtok(ptr, "=");
if_ptr = strtok(NULL, "=");
- if(!strcmp(if_ptr, iface))
+ if (!strcmp(if_ptr, iface))
{
+ OICFree(str);
return true;
}
}
} while ((ptr = strtok(NULL, ";")));
+ OICFree(str);
return false;
}
ESResult SetCallbackForUserData(ESReadUserdataCb readCb, ESWriteUserdataCb writeCb)
{
- if(!readCb && !writeCb)
+ if (!readCb && !writeCb)
{
OIC_LOG(DEBUG, ES_RH_TAG, "Both of callbacks for user data are null");
return ES_ERROR;
OC_RSRVD_ES_URI_EASYSETUP, OCEntityHandlerCb,
NULL, OC_DISCOVERABLE | OC_OBSERVABLE);
}
- if(res != OC_STACK_OK)
+ if (res != OC_STACK_OK)
{
OIC_LOG_V(ERROR, ES_RH_TAG, "Created EasySetup resource with result: %s", getResult(res));
return res;
}
res = OCBindResourceTypeToResource(g_ESEasySetupResource.handle, OC_RSRVD_ES_RES_TYPE_COL);
- if(res != OC_STACK_OK)
+ if (res != OC_STACK_OK)
{
OIC_LOG_V(ERROR, ES_RH_TAG, "Binding Resource type with result: %s", getResult(res));
return res;
}
res = OCBindResourceInterfaceToResource(g_ESEasySetupResource.handle, OC_RSRVD_INTERFACE_LL);
- if(res != OC_STACK_OK)
+ if (res != OC_STACK_OK)
{
OIC_LOG_V(ERROR, ES_RH_TAG, "Binding Resource interface with result: %s", getResult(res));
return res;
}
res = OCBindResourceInterfaceToResource(g_ESEasySetupResource.handle, OC_RSRVD_INTERFACE_BATCH);
- if(res != OC_STACK_OK)
+ if (res != OC_STACK_OK)
{
OIC_LOG_V(ERROR, ES_RH_TAG, "Binding Resource interface with result: %s", getResult(res));
return res;
if (OCRepPayloadGetIntArray(input, OC_RSRVD_ES_CONNECT, &connect_req, dimensions))
{
ESConnectRequest* connectRequest = (ESConnectRequest*)OICMalloc(sizeof(ESConnectRequest));
+ if (!connectRequest)
+ {
+ OIC_LOG(ERROR, ES_RH_TAG, "Failed to allocate Payload");
+ return NULL;
+ }
+
int cntRequest = 0;
for (int i = 0 ; i < NUM_CONNECT_TYPE ; ++i)
{
g_ESEasySetupResource.connectRequest[i] = ES_CONNECT_NONE;
connectRequest->connect[i] = ES_CONNECT_NONE;
- if(i < dimensions[0] &&
+ if (i < dimensions[0] &&
(connect_req[i] == ES_CONNECT_WIFI || connect_req[i] == ES_CONNECT_COAPCLOUD))
{
g_ESEasySetupResource.connectRequest[cntRequest] = connect_req[i];
connectRequest->numRequest = cntRequest;
g_ESEasySetupResource.numRequest = cntRequest;
- if(g_ESEasySetupResource.connectRequest[0] != ES_CONNECT_NONE)
+ if (g_ESEasySetupResource.connectRequest[0] != ES_CONNECT_NONE)
{
OIC_LOG(DEBUG, ES_RH_TAG, "Send ConnectRequest Callback To ES");
- // TODO : Need to check appropriateness of gWiFiData
- if(gConnectRequestEvtCb != NULL)
+ //@todo Need to check appropriateness of gWiFiData
+ if (gConnectRequestEvtCb != NULL)
{
gConnectRequestEvtCb(ES_OK, connectRequest);
}
}
}
- if(ehRequest->query)
+ if (ehRequest->query)
{
- if(CompareResourceInterface(ehRequest->query, OC_RSRVD_INTERFACE_BATCH))
+ if (CompareResourceInterface(ehRequest->query, OC_RSRVD_INTERFACE_BATCH))
{
// When Provisioning resource has a POST with BatchInterface
updateCoapCloudConfResource(input);
{
ESWiFiConfData* wiFiData = (ESWiFiConfData*)OICMalloc(sizeof(ESWiFiConfData));
- if(wiFiData == NULL)
+ if (wiFiData == NULL)
{
OIC_LOG(DEBUG, ES_RH_TAG, "OICMalloc is failed");
return ;
OIC_LOG_V(INFO_PRIVATE, ES_RH_TAG, "g_ESWiFiConfResource.encType %u", g_ESWiFiConfResource.encType);
}
- if(gReadUserdataCb)
+ if (gReadUserdataCb)
{
gReadUserdataCb(input, OC_RSRVD_ES_RES_TYPE_WIFICONF, &wiFiData->userdata);
}
- if(ssid || cred || authType!= -1 || encType != -1)
+ if (ssid || cred || authType!= -1 || encType != -1)
{
OIC_LOG(DEBUG, ES_RH_TAG, "Send WiFiConfRsrc Callback To ES");
- // TODO : Need to check appropriateness of gWiFiData
- if(gWifiConfRsrcEvtCb != NULL)
+ //@todo Need to check appropriateness of gWiFiData
+ if (gWifiConfRsrcEvtCb != NULL)
{
gWifiConfRsrcEvtCb(ES_OK, wiFiData);
}
}
}
- if(OC_STACK_NO_OBSERVERS == OCNotifyAllObservers(g_ESWiFiConfResource.handle, OC_HIGH_QOS))
+ if (OC_STACK_NO_OBSERVERS == OCNotifyAllObservers(g_ESWiFiConfResource.handle, OC_HIGH_QOS))
{
OIC_LOG(DEBUG, ES_RH_TAG, "Enrollee doesn't have any observer.");
}
{
ESCoapCloudConfData* cloudData = (ESCoapCloudConfData*)OICMalloc(sizeof(ESCoapCloudConfData));
- if(cloudData == NULL)
+ if (cloudData == NULL)
{
OIC_LOG(DEBUG, ES_RH_TAG, "OICMalloc is failed");
return;
OIC_LOG_V(INFO_PRIVATE, ES_RH_TAG, "g_ESCoapCloudConfResource.ciServer %s", g_ESCoapCloudConfResource.ciServer);
}
- if(gReadUserdataCb)
+ if (gReadUserdataCb)
{
gReadUserdataCb(input, OC_RSRVD_ES_RES_TYPE_COAPCLOUDCONF, &cloudData->userdata);
}
- if(authCode || accessToken || authProvider || ciServer)
+ if (authCode || accessToken || authProvider || ciServer)
{
OIC_LOG(DEBUG, ES_RH_TAG, "Send CoapCloudConfRsrc Callback To ES");
- // TODO : Need to check appropriateness of gCloudData
- if(gCoapCloudConfRsrcEvtCb != NULL)
+ //@todo Need to check appropriateness of gCloudData
+ if (gCoapCloudConfRsrcEvtCb != NULL)
{
gCoapCloudConfRsrcEvtCb(ES_OK, cloudData);
}
}
}
- if(OC_STACK_NO_OBSERVERS == OCNotifyAllObservers(g_ESCoapCloudConfResource.handle, OC_HIGH_QOS))
+ if (OC_STACK_NO_OBSERVERS == OCNotifyAllObservers(g_ESCoapCloudConfResource.handle, OC_HIGH_QOS))
{
OIC_LOG(DEBUG, ES_RH_TAG, "CoapCloudConf resource doesn't have any observer.");
}
{
ESDevConfData* devConfData = (ESDevConfData*)OICMalloc(sizeof(ESDevConfData));
- if(devConfData == NULL)
+ if (devConfData == NULL)
{
OIC_LOG(DEBUG, ES_RH_TAG, "OICMalloc is failed");
return;
OIC_LOG_V(INFO_PRIVATE, ES_RH_TAG, "g_ESDevConfResource.language %s", g_ESDevConfResource.language);
}
- if(gReadUserdataCb)
+ if (gReadUserdataCb)
{
gReadUserdataCb(input, OC_RSRVD_ES_RES_TYPE_DEVCONF, &devConfData->userdata);
}
- if(country || language)
+ if (country || language)
{
OIC_LOG(DEBUG, ES_RH_TAG, "Send DevConfRsrc Callback To ES");
- // TODO : Need to check appropriateness of gDevConfData
- if(gDevConfRsrcEvtCb != NULL)
+ //@todo : Need to check appropriateness of gDevConfData
+ if (gDevConfRsrcEvtCb != NULL)
{
gDevConfRsrcEvtCb(ES_OK, devConfData);
}
}
}
- if(OC_STACK_NO_OBSERVERS == OCNotifyAllObservers(g_ESDevConfResource.handle, OC_HIGH_QOS))
+ if (OC_STACK_NO_OBSERVERS == OCNotifyAllObservers(g_ESDevConfResource.handle, OC_HIGH_QOS))
{
OIC_LOG(DEBUG, ES_RH_TAG, "devConfResource doesn't have any observer.");
}
return NULL;
}
- if(g_ESWiFiConfResource.handle == NULL)
+ if (g_ESWiFiConfResource.handle == NULL)
{
OIC_LOG(ERROR, ES_RH_TAG, "WiFiConf resource is not created");
return NULL;
OCRepPayload* repPayload = NULL;
OCRepPayload* tempPayload = NULL;
- if(!strcmp(interface, OC_RSRVD_INTERFACE_BATCH))
+ if (!strcmp(interface, OC_RSRVD_INTERFACE_BATCH))
{
repPayload = OCRepPayloadCreate();
if (!repPayload)
size_t interfacesDimensions[MAX_REP_ARRAY_DEPTH] = {1, 0, 0};
char **interfaces = (char **)OICMalloc(3 * sizeof(char*));
+ if (!interfaces)
+ {
+ OIC_LOG(ERROR, ES_RH_TAG, "Failed to allocate Payload");
+ return NULL;
+ }
interfaces[0] = OICStrdup(OC_RSRVD_INTERFACE_DEFAULT);
size_t resourceTypesDimensions[MAX_REP_ARRAY_DEPTH] = {1, 0, 0};
char **resourceTypes = (char **)OICMalloc(2 * sizeof(char*));
+ if (!resourceTypes)
+ {
+ OIC_LOG(ERROR, ES_RH_TAG, "Failed to allocate Payload");
+ return NULL;
+ }
resourceTypes[0] = OICStrdup(OC_RSRVD_ES_RES_TYPE_WIFICONF);
size_t dimensions[MAX_REP_ARRAY_DEPTH] = {g_ESWiFiConfResource.numMode, 0, 0};
int64_t *modes_64 = (int64_t *)OICMalloc(g_ESWiFiConfResource.numMode * sizeof(int64_t));
- for(int i = 0 ; i < g_ESWiFiConfResource.numMode ; ++i)
+ if (!modes_64)
+ {
+ OIC_LOG(ERROR, ES_RH_TAG, "Failed to allocate Payload");
+ return NULL;
+ }
+
+ for (int i = 0 ; i < g_ESWiFiConfResource.numMode ; ++i)
{
modes_64[i] = g_ESWiFiConfResource.supportedMode[i];
}
OCRepPayloadSetPropInt(payload, OC_RSRVD_ES_AUTHTYPE, (int) g_ESWiFiConfResource.authType);
OCRepPayloadSetPropInt(payload, OC_RSRVD_ES_ENCTYPE, (int) g_ESWiFiConfResource.encType);
- if(gWriteUserdataCb)
+ if (gWriteUserdataCb)
{
gWriteUserdataCb(payload, OC_RSRVD_ES_RES_TYPE_WIFICONF);
}
- if(!strcmp(interface, OC_RSRVD_INTERFACE_BATCH))
+ if (!strcmp(interface, OC_RSRVD_INTERFACE_BATCH))
{
payload = tempPayload;
OCRepPayloadSetPropObject(payload, OC_RSRVD_REPRESENTATION, repPayload);
return NULL;
}
- if(g_ESCoapCloudConfResource.handle == NULL)
+ if (g_ESCoapCloudConfResource.handle == NULL)
{
OIC_LOG(ERROR, ES_RH_TAG, "CoapCloudConf resource is not created");
return NULL;
OCRepPayload* repPayload = NULL;
OCRepPayload* tempPayload = NULL;
- if(!strcmp(interface, OC_RSRVD_INTERFACE_BATCH))
+ if (!strcmp(interface, OC_RSRVD_INTERFACE_BATCH))
{
repPayload = OCRepPayloadCreate();
if (!repPayload)
size_t interfacesDimensions[MAX_REP_ARRAY_DEPTH] = {1, 0, 0};
char **interfaces = (char **)OICMalloc(3 * sizeof(char*));
+ if (!interfaces)
+ {
+ OIC_LOG(ERROR, ES_RH_TAG, "Failed to allocate Payload");
+ return NULL;
+ }
interfaces[0] = OICStrdup(OC_RSRVD_INTERFACE_DEFAULT);
size_t resourceTypesDimensions[MAX_REP_ARRAY_DEPTH] = {1, 0, 0};
char **resourceTypes = (char **)OICMalloc(2 * sizeof(char*));
+ if (!resourceTypes)
+ {
+ OIC_LOG(ERROR, ES_RH_TAG, "Failed to allocate Payload");
+ return NULL;
+ }
resourceTypes[0] = OICStrdup(OC_RSRVD_ES_RES_TYPE_COAPCLOUDCONF);
OCRepPayloadSetPropString(payload, OC_RSRVD_ES_AUTHPROVIDER, g_ESCoapCloudConfResource.authProvider);
OCRepPayloadSetPropString(payload, OC_RSRVD_ES_CISERVER, g_ESCoapCloudConfResource.ciServer);
- if(gWriteUserdataCb)
+ if (gWriteUserdataCb)
{
gWriteUserdataCb(payload, OC_RSRVD_ES_RES_TYPE_COAPCLOUDCONF);
}
- if(!strcmp(interface, OC_RSRVD_INTERFACE_BATCH))
+ if (!strcmp(interface, OC_RSRVD_INTERFACE_BATCH))
{
payload = tempPayload;
OCRepPayloadSetPropObject(payload, OC_RSRVD_REPRESENTATION, repPayload);
return NULL;
}
- if(g_ESDevConfResource.handle == NULL)
+ if (g_ESDevConfResource.handle == NULL)
{
OIC_LOG(ERROR, ES_RH_TAG, "DevConf resource is not created");
return NULL;
OCRepPayload* repPayload = NULL;
OCRepPayload* tempPayload = NULL;
- if(!strcmp(interface, OC_RSRVD_INTERFACE_BATCH))
+ if (!strcmp(interface, OC_RSRVD_INTERFACE_BATCH))
{
repPayload = OCRepPayloadCreate();
if (!repPayload)
size_t interfacesDimensions[MAX_REP_ARRAY_DEPTH] = {1, 0, 0};
char **interfaces = (char **)OICMalloc(3 * sizeof(char*));
+ if (!interfaces)
+ {
+ OIC_LOG(ERROR, ES_RH_TAG, "Failed to allocate Payload");
+ return NULL;
+ }
interfaces[0] = OICStrdup(OC_RSRVD_INTERFACE_DEFAULT);
size_t resourceTypesDimensions[MAX_REP_ARRAY_DEPTH] = {1, 0, 0};
char **resourceTypes = (char **)OICMalloc(2 * sizeof(char*));
+ if (!resourceTypes)
+ {
+ OIC_LOG(ERROR, ES_RH_TAG, "Failed to allocate Payload");
+ return NULL;
+ }
resourceTypes[0] = OICStrdup(OC_RSRVD_ES_RES_TYPE_DEVCONF);
OCRepPayloadSetPropString(payload, OC_RSRVD_ES_LANGUAGE, g_ESDevConfResource.language);
OCRepPayloadSetPropString(payload, OC_RSRVD_ES_COUNTRY, g_ESDevConfResource.country);
- if(gWriteUserdataCb)
+ if (gWriteUserdataCb)
{
gWriteUserdataCb(payload, OC_RSRVD_ES_RES_TYPE_DEVCONF);
}
- if(!strcmp(interface, OC_RSRVD_INTERFACE_BATCH))
+ if (!strcmp(interface, OC_RSRVD_INTERFACE_BATCH))
{
payload = tempPayload;
OCRepPayloadSetPropObject(payload, OC_RSRVD_REPRESENTATION, repPayload);
}
// Requested interface is Link list interface
- //if(ehRequest->query && CompareResourceInterface(ehRequest->query, OC_RSRVD_INTERFACE_LL))
- if(!ehRequest->query ||
+ if (!ehRequest->query ||
(ehRequest->query && !strcmp(ehRequest->query, "")) ||
(ehRequest->query && CompareResourceInterface(ehRequest->query, OC_RSRVD_INTERFACE_LL)) ||
(ehRequest->query && CompareResourceInterface(ehRequest->query, OC_RSRVD_INTERFACE_DEFAULT)))
int childResCnt = 0;
- if(g_ESWiFiConfResource.handle != NULL)
+ if (g_ESWiFiConfResource.handle != NULL)
{
OCRepPayload *add = OCRepPayloadCreate();
- if(!add)
+ if (!add)
{
OIC_LOG(ERROR, ES_RH_TAG, "Failed to allocate Payload");
return NULL;
char **resourceInterface = NULL;
resourceInterface = (char **)OICMalloc(sizeof(char *) * 1);
- if(!resourceType || !resourceInterface)
+ if (!resourceType || !resourceInterface)
{
OIC_LOG(ERROR, ES_RH_TAG, "Failed to allocate Payload");
return NULL;
arrayPayload[childResCnt++] = add;
}
- if(g_ESDevConfResource.handle != NULL)
+ if (g_ESDevConfResource.handle != NULL)
{
OCRepPayload *add = OCRepPayloadCreate();
- if(!add)
+ if (!add)
{
OIC_LOG(ERROR, ES_RH_TAG, "Failed to allocate Payload");
return NULL;
char **resourceInterface = NULL;
resourceInterface = (char **)OICMalloc(sizeof(char *) * 1);
- if(!resourceType || !resourceInterface)
+ if (!resourceType || !resourceInterface)
{
OIC_LOG(ERROR, ES_RH_TAG, "Failed to allocate Payload");
return NULL;
arrayPayload[childResCnt++] = add;
}
- if(g_ESCoapCloudConfResource.handle != NULL)
+ if (g_ESCoapCloudConfResource.handle != NULL)
{
OCRepPayload *add = OCRepPayloadCreate();
- if(!add)
+ if (!add)
{
OIC_LOG(ERROR, ES_RH_TAG, "Failed to allocate Payload");
return NULL;
char **resourceInterface = NULL;
resourceInterface = (char **)OICMalloc(sizeof(char *) * 1);
- if(!resourceType || !resourceInterface)
+ if (!resourceType || !resourceInterface)
{
OIC_LOG(ERROR, ES_RH_TAG, "Failed to allocate Payload");
return NULL;
size_t dimensions[MAX_REP_ARRAY_DEPTH] = {childResCnt, 0, 0};
- if(!ehRequest->query ||
+ if (!ehRequest->query ||
(ehRequest->query && !strcmp(ehRequest->query, "")) ||
(ehRequest->query && CompareResourceInterface(ehRequest->query, OC_RSRVD_INTERFACE_DEFAULT)))
{
OCRepPayloadSetPropInt(payload, OC_RSRVD_ES_PROVSTATUS, g_ESEasySetupResource.status);
OCRepPayloadSetPropInt(payload, OC_RSRVD_ES_LAST_ERRORCODE, g_ESEasySetupResource.lastErrCode);
- if(g_ESEasySetupResource.numRequest > 0)
+ if (g_ESEasySetupResource.numRequest > 0)
{
size_t dimensions[MAX_REP_ARRAY_DEPTH] = {g_ESEasySetupResource.numRequest, 0, 0};
int64_t *connectRequest = (int64_t *)OICMalloc(g_ESEasySetupResource.numRequest * sizeof(int64_t));
- if(!connectRequest)
+ if (!connectRequest)
{
OIC_LOG(ERROR, ES_RH_TAG, "Failed to allocate Payload");
return NULL;
OCRepPayloadSetIntArray(payload, OC_RSRVD_ES_CONNECT, NULL, dimensions);
}
- if(gWriteUserdataCb)
+ if (gWriteUserdataCb)
{
gWriteUserdataCb(payload, OC_RSRVD_ES_RES_TYPE_EASYSETUP);
}
size_t interfacesDimensions[MAX_REP_ARRAY_DEPTH] = {3, 0, 0};
char **interfaces = (char **)OICMalloc(3 * sizeof(char*));
- if(!interfaces)
+ if (!interfaces)
{
OIC_LOG(ERROR, ES_RH_TAG, "Failed to allocate Payload");
return NULL;
size_t resourceTypesDimensions[MAX_REP_ARRAY_DEPTH] = {2, 0, 0};
char **resourceTypes = (char **)OICMalloc(2 * sizeof(char*));
- if(!resourceTypes)
+ if (!resourceTypes)
{
OIC_LOG(ERROR, ES_RH_TAG, "Failed to allocate Payload");
return NULL;
OCRepPayloadSetPropInt(repPayload, OC_RSRVD_ES_PROVSTATUS, g_ESEasySetupResource.status);
OCRepPayloadSetPropInt(repPayload, OC_RSRVD_ES_LAST_ERRORCODE, g_ESEasySetupResource.lastErrCode);
- if(g_ESEasySetupResource.numRequest > 0)
+ if (g_ESEasySetupResource.numRequest > 0)
{
size_t dimensions[MAX_REP_ARRAY_DEPTH] = {g_ESEasySetupResource.numRequest, 0, 0};
int64_t *connectRequest = (int64_t *)OICMalloc(g_ESEasySetupResource.numRequest * sizeof(int64_t));
- if(!connectRequest)
+ if (!connectRequest)
{
OIC_LOG(ERROR, ES_RH_TAG, "Failed to allocate Payload");
return NULL;
}
- for(int i = 0 ; i < g_ESEasySetupResource.numRequest ; ++i)
+ for (int i = 0 ; i < g_ESEasySetupResource.numRequest ; ++i)
{
connectRequest[i] = g_ESEasySetupResource.connectRequest[i];
}
OCRepPayloadSetIntArray(payload, OC_RSRVD_ES_CONNECT, NULL, dimensions);
}
- if(gWriteUserdataCb)
+ if (gWriteUserdataCb)
{
gWriteUserdataCb(repPayload, OC_RSRVD_ES_RES_TYPE_EASYSETUP);
}
OCRepPayloadSetPropObject(payload, OC_RSRVD_REPRESENTATION, repPayload);
}
- if(ehRequest->query)
+ if (ehRequest->query)
{
- if(CompareResourceInterface(ehRequest->query, OC_RSRVD_INTERFACE_BATCH))
+ if (CompareResourceInterface(ehRequest->query, OC_RSRVD_INTERFACE_BATCH))
{// When Provisioning resource has a GET with BatchInterface
OCRepPayload* head = payload;
OCRepPayload* nextPayload = NULL;
nextPayload = constructResponseOfWiFiConf(OC_RSRVD_INTERFACE_BATCH);
- if(nextPayload != NULL)
+ if (nextPayload != NULL)
{
payload->next = nextPayload;
payload = payload->next;
}
nextPayload = constructResponseOfCoapCloudConf(OC_RSRVD_INTERFACE_BATCH);
- if(nextPayload != NULL)
+ if (nextPayload != NULL)
{
payload->next = nextPayload;
payload = payload->next;
}
nextPayload = constructResponseOfDevConf(OC_RSRVD_INTERFACE_BATCH);
- if(nextPayload != NULL)
+ if (nextPayload != NULL)
{
payload->next = nextPayload;
}
bool maskFlag = false;
res = initEasySetupResource(isSecured);
- if(res != OC_STACK_OK)
+ if (res != OC_STACK_OK)
{
// TODO: destroy logic will be added
OIC_LOG_V(ERROR, ES_RH_TAG, "initEasySetupResource result: %s", getResult(res));
return res;
}
- if((resourceMask & ES_WIFICONF_RESOURCE) == ES_WIFICONF_RESOURCE)
+ if ((resourceMask & ES_WIFICONF_RESOURCE) == ES_WIFICONF_RESOURCE)
{
maskFlag = true;
res = initWiFiConfResource(isSecured);
- if(res != OC_STACK_OK)
+ if (res != OC_STACK_OK)
{
OIC_LOG_V(ERROR, ES_RH_TAG, "initWiFiConfResource result: %s", getResult(res));
return res;
}
res = OCBindResource(g_ESEasySetupResource.handle, g_ESWiFiConfResource.handle);
- if(res != OC_STACK_OK)
+ if (res != OC_STACK_OK)
{
OIC_LOG_V(ERROR, ES_RH_TAG, "Bind WiFiConfResource result: %s", getResult(res));
return res;
}
- if((resourceMask & ES_COAPCLOUDCONF_RESOURCE) == ES_COAPCLOUDCONF_RESOURCE)
+ if ((resourceMask & ES_COAPCLOUDCONF_RESOURCE) == ES_COAPCLOUDCONF_RESOURCE)
{
maskFlag = true;
res = initCoapCloudConfResource(isSecured);
- if(res != OC_STACK_OK)
+ if (res != OC_STACK_OK)
{
OIC_LOG_V(ERROR, ES_RH_TAG, "initCoapCloudConfResource result: %s", getResult(res));
return res;
}
res = OCBindResource(g_ESEasySetupResource.handle, g_ESCoapCloudConfResource.handle);
- if(res != OC_STACK_OK)
+ if (res != OC_STACK_OK)
{
OIC_LOG_V(ERROR, ES_RH_TAG, "Bind CoapCloudConfResource result: %s", getResult(res));
return res;
}
}
- if((resourceMask & ES_DEVCONF_RESOURCE) == ES_DEVCONF_RESOURCE)
+ if ((resourceMask & ES_DEVCONF_RESOURCE) == ES_DEVCONF_RESOURCE)
{
maskFlag = true;
res = initDevConfResource(isSecured);
- if(res != OC_STACK_OK)
+ if (res != OC_STACK_OK)
{
OIC_LOG_V(ERROR, ES_RH_TAG, "initDevConf result: %s", getResult(res));
return res;
}
res = OCBindResource(g_ESEasySetupResource.handle, g_ESDevConfResource.handle);
- if(res != OC_STACK_OK)
+ if (res != OC_STACK_OK)
{
OIC_LOG_V(ERROR, ES_RH_TAG, "Bind DevConfResource result: %s", getResult(res));
return res;
}
}
- if(maskFlag == false)
+ if (maskFlag == false)
{
OIC_LOG_V(ERROR, ES_RH_TAG, "Invalid ResourceMask");
return OC_STACK_ERROR;
if (g_ESWiFiConfResource.handle != NULL)
{
res = OCUnBindResource(g_ESEasySetupResource.handle, g_ESWiFiConfResource.handle);
- if(res != OC_STACK_OK)
+ if (res != OC_STACK_OK)
{
OIC_LOG_V(ERROR, ES_RH_TAG, "Unbind WiFi resource error with result: %s", getResult(res));
}
if (g_ESCoapCloudConfResource.handle != NULL)
{
res = OCUnBindResource(g_ESEasySetupResource.handle, g_ESCoapCloudConfResource.handle);
- if(res != OC_STACK_OK)
+ if (res != OC_STACK_OK)
{
OIC_LOG_V(ERROR, ES_RH_TAG, "Unbind CloudServer resource error with result: %s", getResult(res));
}
if (g_ESDevConfResource.handle != NULL)
{
res = OCUnBindResource(g_ESEasySetupResource.handle, g_ESDevConfResource.handle);
- if(res != OC_STACK_OK)
+ if (res != OC_STACK_OK)
{
OIC_LOG_V(ERROR, ES_RH_TAG, "Unbind DevConf resource error with result: %s", getResult(res));
}
}
}
- if(g_ESCoapCloudConfResource.handle != NULL)
+ if (g_ESCoapCloudConfResource.handle != NULL)
{
res = OCDeleteResource(g_ESCoapCloudConfResource.handle);
if (res != OC_STACK_OK)
}
}
- if(g_ESDevConfResource.handle != NULL)
+ if (g_ESDevConfResource.handle != NULL)
{
res = OCDeleteResource(g_ESDevConfResource.handle);
if (res != OC_STACK_OK)
}
}
- if(g_ESEasySetupResource.handle != NULL)
+ if (g_ESEasySetupResource.handle != NULL)
{
res = OCDeleteResource(g_ESEasySetupResource.handle);
if (res != OC_STACK_OK)
OCRepPayload *getResp = NULL;
*payload = NULL;
- if(ehRequest->resource == g_ESEasySetupResource.handle)
+ if (ehRequest->resource == g_ESEasySetupResource.handle)
{
- if(ehRequest->query &&
+ if (ehRequest->query &&
strcmp(ehRequest->query, "") &&
!CompareResourceInterface(ehRequest->query, OC_RSRVD_INTERFACE_LL) &&
!CompareResourceInterface(ehRequest->query, OC_RSRVD_INTERFACE_BATCH) &&
getResp = constructResponseOfEasySetup(ehRequest);
}
}
- else if(ehRequest->resource == g_ESWiFiConfResource.handle)
+ else if (ehRequest->resource == g_ESWiFiConfResource.handle)
{
- if(CheckEhRequestPayload(ehRequest) != OC_EH_OK)
+ if (CheckEhRequestPayload(ehRequest) != OC_EH_OK)
{
OIC_LOG(ERROR, ES_RH_TAG, "Not supported Interface");
return OC_EH_BAD_REQ;
getResp = constructResponseOfWiFiConf(OC_RSRVD_INTERFACE_DEFAULT);
}
}
- else if(ehRequest->resource == g_ESCoapCloudConfResource.handle)
+ else if (ehRequest->resource == g_ESCoapCloudConfResource.handle)
{
- if(CheckEhRequestPayload(ehRequest) != OC_EH_OK)
+ if (CheckEhRequestPayload(ehRequest) != OC_EH_OK)
{
OIC_LOG(ERROR, ES_RH_TAG, "Not supported Interface");
return OC_EH_BAD_REQ;
getResp = constructResponseOfCoapCloudConf(OC_RSRVD_INTERFACE_DEFAULT);
}
}
- else if(ehRequest->resource == g_ESDevConfResource.handle)
+ else if (ehRequest->resource == g_ESDevConfResource.handle)
{
- if(CheckEhRequestPayload(ehRequest) != OC_EH_OK)
+ if (CheckEhRequestPayload(ehRequest) != OC_EH_OK)
{
OIC_LOG(ERROR, ES_RH_TAG, "Not supported Interface");
return OC_EH_BAD_REQ;
return ehResult;
}
- if(ehRequest->resource == g_ESEasySetupResource.handle)
+ if (ehRequest->resource == g_ESEasySetupResource.handle)
{
- if(ehRequest->query &&
+ if (ehRequest->query &&
strcmp(ehRequest->query, "") &&
!CompareResourceInterface(ehRequest->query, OC_RSRVD_INTERFACE_BATCH) &&
!CompareResourceInterface(ehRequest->query, OC_RSRVD_INTERFACE_DEFAULT))
updateEasySetupResource(ehRequest, input);
}
}
- else if(ehRequest->resource == g_ESWiFiConfResource.handle)
+ else if (ehRequest->resource == g_ESWiFiConfResource.handle)
{
- if(CheckEhRequestPayload(ehRequest) != OC_EH_OK)
+ if (CheckEhRequestPayload(ehRequest) != OC_EH_OK)
{
OIC_LOG(ERROR, ES_RH_TAG, "Not supported Interface");
return OC_EH_BAD_REQ;
updateWiFiConfResource(input);
}
}
- else if(ehRequest->resource == g_ESCoapCloudConfResource.handle)
+ else if (ehRequest->resource == g_ESCoapCloudConfResource.handle)
{
- if(CheckEhRequestPayload(ehRequest) != OC_EH_OK)
+ if (CheckEhRequestPayload(ehRequest) != OC_EH_OK)
{
OIC_LOG(ERROR, ES_RH_TAG, "Not supported Interface");
return OC_EH_BAD_REQ;
updateCoapCloudConfResource(input);
}
}
- else if(ehRequest->resource == g_ESDevConfResource.handle)
+ else if (ehRequest->resource == g_ESDevConfResource.handle)
{
- if(CheckEhRequestPayload(ehRequest) != OC_EH_OK)
+ if (CheckEhRequestPayload(ehRequest) != OC_EH_OK)
{
OIC_LOG(ERROR, ES_RH_TAG, "Not supported Interface");
return OC_EH_BAD_REQ;
}
OCRepPayload *getResp = NULL;
- if(ehRequest->resource == g_ESEasySetupResource.handle)
+ if (ehRequest->resource == g_ESEasySetupResource.handle)
{
getResp = constructResponseOfEasySetup(ehRequest);
}
- else if(ehRequest->resource == g_ESWiFiConfResource.handle)
+ else if (ehRequest->resource == g_ESWiFiConfResource.handle)
{
getResp = constructResponseOfWiFiConf(OC_RSRVD_INTERFACE_DEFAULT);
}
- else if(ehRequest->resource == g_ESCoapCloudConfResource.handle)
+ else if (ehRequest->resource == g_ESCoapCloudConfResource.handle)
{
getResp = constructResponseOfCoapCloudConf(OC_RSRVD_INTERFACE_DEFAULT);
}
- else if(ehRequest->resource == g_ESDevConfResource.handle)
+ else if (ehRequest->resource == g_ESDevConfResource.handle)
{
getResp = constructResponseOfDevConf(OC_RSRVD_INTERFACE_DEFAULT);
}
OIC_LOG_V(INFO_PRIVATE, ES_RH_TAG, "WiFi Freq : %d", g_ESWiFiConfResource.supportedFreq);
int modeIdx = 0;
- while((deviceProperty->WiFi).mode[modeIdx] != WiFi_EOF)
+ while ((deviceProperty->WiFi).mode[modeIdx] != WiFi_EOF)
{
g_ESWiFiConfResource.supportedMode[modeIdx] = (deviceProperty->WiFi).mode[modeIdx];
OIC_LOG_V(INFO_PRIVATE, ES_RH_TAG, "WiFi Mode : %d", g_ESWiFiConfResource.supportedMode[modeIdx]);
(deviceProperty->DevConf).modelNumber);
OIC_LOG_V(INFO_PRIVATE, ES_RH_TAG, "Model Number : %s", g_ESDevConfResource.modelNumber);
- if(OC_STACK_NO_OBSERVERS == OCNotifyAllObservers(g_ESWiFiConfResource.handle, OC_HIGH_QOS))
+ if (OC_STACK_NO_OBSERVERS == OCNotifyAllObservers(g_ESWiFiConfResource.handle, OC_HIGH_QOS))
{
OIC_LOG(DEBUG, ES_RH_TAG, "wifiResource doesn't have any observers.");
}
- if(OC_STACK_NO_OBSERVERS == OCNotifyAllObservers(g_ESDevConfResource.handle, OC_HIGH_QOS))
+ if (OC_STACK_NO_OBSERVERS == OCNotifyAllObservers(g_ESDevConfResource.handle, OC_HIGH_QOS))
{
OIC_LOG(DEBUG, ES_RH_TAG, "devConfResource doesn't have any observers.");
}
g_ESEasySetupResource.status = esState;
OIC_LOG_V(INFO_PRIVATE, ES_RH_TAG, "Enrollee Status : %d", g_ESEasySetupResource.status);
- if(OC_STACK_NO_OBSERVERS == OCNotifyAllObservers(g_ESEasySetupResource.handle, OC_HIGH_QOS))
+ if (OC_STACK_NO_OBSERVERS == OCNotifyAllObservers(g_ESEasySetupResource.handle, OC_HIGH_QOS))
{
OIC_LOG(DEBUG, ES_RH_TAG, "provResource doesn't have any observers.");
}
g_ESEasySetupResource.lastErrCode = esErrCode;
OIC_LOG_V(INFO_PRIVATE, ES_RH_TAG, "Enrollee ErrorCode : %d", g_ESEasySetupResource.lastErrCode);
- if(OC_STACK_NO_OBSERVERS == OCNotifyAllObservers(g_ESEasySetupResource.handle, OC_HIGH_QOS))
+ if (OC_STACK_NO_OBSERVERS == OCNotifyAllObservers(g_ESEasySetupResource.handle, OC_HIGH_QOS))
{
OIC_LOG(DEBUG, ES_RH_TAG, "provResource doesn't have any observers.");
}
OCEntityHandlerResult CheckEhRequestPayload(OCEntityHandlerRequest *ehRequest)
{
- if( !(ehRequest->query) ||
+ if (!(ehRequest->query) ||
(ehRequest->query &&
(strcmp(ehRequest->query, "") && !CompareResourceInterface(ehRequest->query,
OC_RSRVD_INTERFACE_DEFAULT))))