replace : iotivity -> iotivity-sec
[platform/upstream/iotivity.git] / service / easy-setup / enrollee / src / samsung / sc_easysetup.c
1 //******************************************************************
2 //
3 // Copyright 2015 Samsung Electronics All Rights Reserved.
4 //
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6 //
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
10 //
11 //      http://www.apache.org/licenses/LICENSE-2.0
12 //
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
18 //
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20
21
22 #include "samsung/sc_easysetup.h"
23 #include "string.h"
24 #include "oic_malloc.h"
25 #include "logger.h"
26 #include "stdio.h"
27
28 #include "ocpayload.h"
29 #include "oic_string.h"
30 #include "oic_malloc.h"
31
32 #include "resourcehandler.h"
33
34 /**
35  * @var SC_ENROLLEE_TAG
36  * @brief Logging tag for module name.
37  */
38 #define SC_ENROLLEE_TAG "ES_SC_ENROLLEE"
39
40 EasySetupResource g_ESEasySetupResource;
41 WiFiConfResource g_ESWiFiConfResource;
42 CoapCloudConfResource g_ESCoapCloudConfResource;
43 DevConfResource g_ESDevConfResource;
44
45 SCProperties g_SCProperties;
46
47 static void ReadAccountData(OCRepPayload* payload,void** userdata);
48 static void ReadTnCdata(OCRepPayload* payload,void** userdata);
49 static void WriteTnCdata(OCRepPayload* payload, char* resourceType);
50 static void WriteWifiData(OCRepPayload* payload, char* resourceType);
51
52 ESResult SetSCProperties(const SCProperties *prop)
53 {
54     OIC_LOG(INFO, SC_ENROLLEE_TAG, "SetSCProperties IN");
55     if(prop != NULL)
56     {
57         memcpy(&g_SCProperties, prop, sizeof(SCProperties));
58         OIC_LOG(INFO, SC_ENROLLEE_TAG, "SetSCProperties OUT");
59         return ES_OK;
60     }
61     OIC_LOG(INFO, SC_ENROLLEE_TAG, "SetSCProperties OUT");
62     return ES_ERROR;
63 }
64
65 static void ReadAccountData(OCRepPayload* payload,void** userdata)
66 {
67     OIC_LOG(INFO, SC_ENROLLEE_TAG, "ReadAccountData IN");
68
69     char* account = NULL;
70
71     if(OCRepPayloadGetPropString(payload, SC_RSRVD_ES_VENDOR_ACCOUNT, &account))
72     {
73         if(*userdata == NULL)
74         {
75             *userdata = (void*)OICMalloc(sizeof(SCDevConfProperties));
76             if( *userdata == NULL )
77             {
78                 OIC_LOG(ERROR, SC_ENROLLEE_TAG, "OICMalloc for SCDevConfProperties is failed");
79                 return ;
80             }
81         }
82
83         SCDevConfProperties *pDevConfProp = (SCDevConfProperties*)(*userdata);
84         OICStrcpy(pDevConfProp->account, MAXLEN_STRING, account);
85         OICStrcpy(g_SCProperties.account, MAXLEN_STRING, account);
86
87         OIC_LOG_V(INFO_PRIVATE, SC_ENROLLEE_TAG, "[User specific property] %s : %s",
88                 SC_RSRVD_ES_VENDOR_ACCOUNT, pDevConfProp->account);
89
90     }
91     OIC_LOG(INFO, SC_ENROLLEE_TAG, "ReadAccountData OUT");
92
93 }
94
95 ESResult SetSCTncInfo(SCTncInfo *tncInfo)
96 {
97     if(tncInfo == NULL)
98     {
99         return ES_ERROR;
100     }
101     g_SCProperties.tncInfo = *tncInfo;
102     return ES_OK;
103 }
104
105 ESResult SetSCTncStatus(int status)
106 {
107     g_SCProperties.tncStatus = status;
108     return ES_OK;
109 }
110
111 ESResult SetSCNetConnectionState(NETCONNECTION_STATE netConnectionState)
112 {
113     OIC_LOG(INFO, SC_ENROLLEE_TAG, "SetSCNetConnectionState IN");
114
115     OIC_LOG_V(INFO_PRIVATE, SC_ENROLLEE_TAG, "SetSCNetConnectionState: %d", netConnectionState);
116     g_SCProperties.netConnectionState = netConnectionState;
117
118     if(OC_STACK_NO_OBSERVERS == OCNotifyAllObservers(g_ESEasySetupResource.handle, OC_HIGH_QOS))
119     {
120         OIC_LOG(DEBUG, SC_ENROLLEE_TAG, "provResource doesn't have any observers.");
121     }
122
123     OIC_LOG(INFO, SC_ENROLLEE_TAG, "SetSCNetConnectionState OUT");
124     return ES_OK;
125 }
126
127 static void ReadTnCdata(OCRepPayload* payload,void** userdata)
128 {
129     OIC_LOG(INFO, SC_ENROLLEE_TAG, "ReadTnCdata IN");
130
131     char* tncResult = NULL;
132
133     if (OCRepPayloadGetPropString(payload, SC_RSRVD_ES_VENDOR_TNC_RESULT, &tncResult))
134     {
135         if(*userdata == NULL)
136         {
137             *userdata = (void*)OICMalloc(sizeof(SCCoapCloudServerConfProperties));
138             if( *userdata == NULL )
139             {
140                 OIC_LOG(ERROR, SC_ENROLLEE_TAG, "OICMalloc for SCCoapCloudServerConfProperties is failed");
141                 return ;
142             }
143         }
144
145         SCCoapCloudServerConfProperties *pProp = (SCCoapCloudServerConfProperties*)(*userdata);
146         OICStrcpy(pProp->tncResult, MAXLEN_STRING, tncResult);
147         OICStrcpy(g_SCProperties.tncResult, MAXLEN_STRING, tncResult);
148
149         OIC_LOG_V(INFO_PRIVATE, SC_ENROLLEE_TAG, "[User specific property] %s : %s",
150                 SC_RSRVD_ES_VENDOR_TNC_RESULT, pProp->tncResult);
151     }
152
153     OIC_LOG(INFO, SC_ENROLLEE_TAG, "ReadTnCdata OUT");
154 }
155
156 void WriteTnCdata(OCRepPayload* payload, char* resourceType)
157 {
158     OIC_LOG(INFO, SC_ENROLLEE_TAG, "WriteTnCdata IN");
159
160     if(payload == NULL || resourceType == NULL)
161     {
162         OIC_LOG(DEBUG, SC_ENROLLEE_TAG, "Invalid Params payload or resourceType is NULL");
163         OIC_LOG(DEBUG, SC_ENROLLEE_TAG, "WriteTnCdata OUT");
164         return;
165     }
166     if(strstr(resourceType, OC_RSRVD_ES_RES_TYPE_EASYSETUP))
167     {
168         OCRepPayloadSetPropInt(payload, SC_RSRVD_ES_VENDOR_TNC_STATUS, g_SCProperties.tncStatus);
169     }
170     else if(strstr(resourceType, OC_RSRVD_ES_RES_TYPE_DEVCONF))
171     {
172         OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_TNC_HEADER,
173                 g_SCProperties.tncInfo.header);
174         OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_TNC_VERSION,
175                 g_SCProperties.tncInfo.version);
176     }
177     else if(strstr(resourceType, OC_RSRVD_ES_RES_TYPE_COAPCLOUDCONF))
178     {
179         OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_TNC_RESULT,
180                 g_SCProperties.tncResult);
181     }
182     OIC_LOG(INFO, SC_ENROLLEE_TAG, "WriteTnCdata OUT");
183 }
184
185 void WriteWifiData(OCRepPayload* payload, char* resourceType)
186 {
187     OIC_LOG(INFO, SC_ENROLLEE_TAG, "WriteWifiData IN");
188
189     if(payload == NULL || resourceType == NULL)
190     {
191         OIC_LOG(DEBUG, SC_ENROLLEE_TAG, "Invalid Params payload or resourceType is NULL");
192         OIC_LOG(DEBUG, SC_ENROLLEE_TAG, "WriteWifiData OUT");
193         return;
194     }
195
196     if(strstr(resourceType, OC_RSRVD_ES_RES_TYPE_WIFICONF))
197     {
198         OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_BSSID,
199                 g_SCProperties.bssid);
200     }
201     OIC_LOG(INFO, SC_ENROLLEE_TAG, "WriteWifiData OUT");
202 }
203
204 ESResult SetRegisterSetDevice(const char *regSetDevice)
205 {
206     if(regSetDevice != NULL)
207     {
208         OICStrcpy(g_SCProperties.regSetDev, sizeof(g_SCProperties.regSetDev), regSetDevice);
209         return ES_OK;
210     }
211     return ES_ERROR;
212 }
213
214 ESResult SetNetworkProvInfo(const char *nwProvInfo)
215 {
216     if(nwProvInfo != NULL)
217     {
218         OICStrcpy(g_SCProperties.nwProvInfo, sizeof(g_SCProperties.nwProvInfo), nwProvInfo);
219         return ES_OK;
220     }
221     return ES_ERROR;
222 }
223
224 ESResult SetSCPnPPin(const char *pnp)
225 {
226     if(pnp != NULL)
227     {
228         OICStrcpy(g_SCProperties.pnpPin, sizeof(g_SCProperties.pnpPin), pnp);
229         return ES_OK;
230     }
231     return ES_ERROR;
232 }
233
234 ESResult SetESVersionInfo(const char *esProtocolVersion)
235 {
236     if(esProtocolVersion != NULL)
237     {
238         OICStrcpy(g_SCProperties.esProtocolVersion, sizeof(g_SCProperties.esProtocolVersion), esProtocolVersion);
239         return ES_OK;
240     }
241     return ES_ERROR;
242 }
243
244 void ReadUserdataCb(OCRepPayload* payload, char* resourceType, void** userdata)
245 {
246     OIC_LOG(INFO, SC_ENROLLEE_TAG, "ReadUserdataCb IN");
247
248     if(payload != NULL)
249     {
250         if(strstr(resourceType, OC_RSRVD_ES_RES_TYPE_WIFICONF))
251         {
252             int64_t channel = -1;
253             char *bssid = NULL;
254             if (OCRepPayloadGetPropInt(payload, SC_RSRVD_ES_VENDOR_DISCOVERY_CHANNEL, &channel))
255             {
256                 if(*userdata == NULL)
257                 {
258                     *userdata = (void*)OICMalloc(sizeof(SCWiFiConfProperties));
259                     if( *userdata == NULL )
260                     {
261                         OIC_LOG(ERROR, SC_ENROLLEE_TAG, "OICMalloc for SCWiFiConfProperties is failed");
262                         return ;
263                     }
264                     memset(*userdata, 0, sizeof(SCWiFiConfProperties));
265                 }
266                 OIC_LOG_V(INFO_PRIVATE, SC_ENROLLEE_TAG, "[User specific property] %s : [%" PRId64 "]",
267                                                             SC_RSRVD_ES_VENDOR_DISCOVERY_CHANNEL, channel);
268                 ((SCWiFiConfProperties*)(*userdata))->discoveryChannel = (int) channel;
269                 g_SCProperties.discoveryChannel = channel;
270             }
271             if (OCRepPayloadGetPropString(payload, SC_RSRVD_ES_VENDOR_BSSID, &bssid))
272             {
273                 if(*userdata == NULL)
274                 {
275                     *userdata = (void*) OICMalloc(sizeof(SCWiFiConfProperties));
276                     if( *userdata == NULL )
277                     {
278                         OIC_LOG(ERROR, SC_ENROLLEE_TAG, "OICMalloc for SCWiFiConfProperties is failed");
279                         return ;
280                     }
281                     memset(*userdata, 0, sizeof(SCWiFiConfProperties));
282                 }
283                 if (*userdata != NULL)
284                 {
285                     OIC_LOG_V(INFO_PRIVATE, SC_ENROLLEE_TAG, "[User specific property] %s : %s",
286                             SC_RSRVD_ES_VENDOR_BSSID, bssid);
287                     SCWiFiConfProperties* pWifiConfProp = (SCWiFiConfProperties*)(*userdata);
288                     OICStrcpy(pWifiConfProp->bssid, sizeof(pWifiConfProp->bssid), bssid);
289                     OICStrcpy(g_SCProperties.bssid, sizeof(g_SCProperties.bssid), bssid);
290                     OICFree(bssid);
291                 }
292             }
293         }
294         else if(strstr(resourceType, OC_RSRVD_ES_RES_TYPE_DEVCONF))
295         {
296             if(*userdata == NULL)
297             {
298                 *userdata = (void*)OICMalloc(sizeof(SCDevConfProperties));
299                 if( *userdata == NULL )
300                 {
301                     OIC_LOG(ERROR, SC_ENROLLEE_TAG, "OICMalloc for SCDevConfProperties is failed");
302                     return ;
303                 }
304                 memset(*userdata, 0, sizeof(SCDevConfProperties));
305             }
306
307             SCDevConfProperties *pDevConfProp = (SCDevConfProperties*)(*userdata);
308
309             char**locationList = NULL;
310             size_t dimensions[MAX_REP_ARRAY_DEPTH] = {0};
311             if(OCRepPayloadGetStringArray(payload, SC_RSRVD_ES_VENDOR_LOCATION, &locationList, dimensions))
312             {
313                 for(size_t idx = 0; idx < dimensions[0]; idx++)
314                 {
315                     OICStrcpy(pDevConfProp->location[idx], strlen(locationList[idx])+1, locationList[idx]);
316                     OICStrcpy(g_SCProperties.location[idx], strlen(locationList[idx])+1, locationList[idx]);
317
318                     OIC_LOG_V(INFO_PRIVATE, SC_ENROLLEE_TAG, "[User specific property] %s : %s",
319                                         SC_RSRVD_ES_VENDOR_LOCATION, pDevConfProp->location[idx]);
320                 }
321
322                 ((SCDevConfProperties*)(*userdata))->numLocation = (int)dimensions[0];
323                 g_SCProperties.numLocation = (int)dimensions[0];
324             }
325
326             ReadAccountData(payload,userdata);
327
328             char *regMobileDev = NULL;
329             if (OCRepPayloadGetPropString(payload, SC_RSRVD_ES_VENDOR_REGISTER_MOBILE_DEV, &regMobileDev))
330             {
331                 OICStrcpy(pDevConfProp->regMobileDev, strlen(regMobileDev)+1, regMobileDev);
332                 OICStrcpy(g_SCProperties.regMobileDev, strlen(regMobileDev)+1, regMobileDev);
333                 OIC_LOG_V(INFO_PRIVATE, SC_ENROLLEE_TAG, "pDevConfProp.regMobileDev %s", g_SCProperties.regMobileDev);
334             }
335
336             char *country = NULL;
337             if (OCRepPayloadGetPropString(payload, SC_RSRVD_ES_VENDOR_COUNTRY, &country))
338             {
339                 OICStrcpy(pDevConfProp->country, strlen(country)+1, country);
340                 OICStrcpy(g_SCProperties.country, strlen(country)+1, country);
341                 OIC_LOG_V(INFO_PRIVATE, SC_ENROLLEE_TAG, "pDevConfProp.country %s", g_SCProperties.country);
342             }
343
344             char *language = NULL;
345             if (OCRepPayloadGetPropString(payload, SC_RSRVD_ES_VENDOR_LANGUAGE, &language))
346             {
347                 OICStrcpy(pDevConfProp->language, strlen(language)+1, language);
348                 OICStrcpy(g_SCProperties.language, strlen(language)+1, language);
349                 OIC_LOG_V(INFO_PRIVATE, SC_ENROLLEE_TAG, "pDevConfProp.language %s", g_SCProperties.language);
350             }
351
352             char *gpsLocation = NULL;
353             if (OCRepPayloadGetPropString(payload, SC_RSRVD_ES_VENDOR_GPSLOCATION, &gpsLocation))
354             {
355                 OICStrcpy(pDevConfProp->gpsLocation, strlen(gpsLocation)+1, gpsLocation);
356                 OICStrcpy(g_SCProperties.gpsLocation, strlen(gpsLocation)+1, gpsLocation);
357                 OIC_LOG_V(INFO_PRIVATE, SC_ENROLLEE_TAG, "pDevConfProp.gpsLocation %s", g_SCProperties.gpsLocation);
358             }
359
360             char *utcDateTime = NULL;
361             if (OCRepPayloadGetPropString(payload, SC_RSRVD_ES_VENDOR_UTC_DATE_TIME, &utcDateTime))
362             {
363                 OICStrcpy(pDevConfProp->utcDateTime, strlen(utcDateTime)+1, utcDateTime);
364                 OICStrcpy(g_SCProperties.utcDateTime, strlen(utcDateTime)+1, utcDateTime);
365                 OIC_LOG_V(INFO_PRIVATE, SC_ENROLLEE_TAG, "pDevConfProp.utcDateTime %s", g_SCProperties.utcDateTime);
366             }
367
368             char *regionalDateTime = NULL;
369             if (OCRepPayloadGetPropString(payload, SC_RSRVD_ES_VENDOR_REGIONAL_DATE_TIME, &regionalDateTime))
370             {
371                 OICStrcpy(pDevConfProp->regionalDateTime, strlen(regionalDateTime)+1, regionalDateTime);
372                 OICStrcpy(g_SCProperties.regionalDateTime, strlen(regionalDateTime)+1, regionalDateTime);
373                 OIC_LOG_V(INFO_PRIVATE, SC_ENROLLEE_TAG, "pDevConfProp.regionalDateTime %s", g_SCProperties.regionalDateTime);
374             }
375         }
376         else if(strstr(resourceType, OC_RSRVD_ES_RES_TYPE_COAPCLOUDCONF))
377         {
378             char* clientID = NULL;
379             if(OCRepPayloadGetPropString(payload, SC_RSRVD_ES_VENDOR_CLIENTID, &clientID))
380             {
381                 if(*userdata == NULL)
382                 {
383                     *userdata = (void*)OICMalloc(sizeof(SCCoapCloudServerConfProperties));
384                     if( *userdata == NULL )
385                     {
386                         OIC_LOG(ERROR, SC_ENROLLEE_TAG, "OICMalloc for SCCoapCloudServerConfProperties is failed");
387                         return ;
388                     }
389                     memset(*userdata, 0, sizeof(SCCoapCloudServerConfProperties));
390                 }
391
392                 SCCoapCloudServerConfProperties *pCloudProp =
393                                                     (SCCoapCloudServerConfProperties*)(*userdata);
394
395                 OICStrcpy(pCloudProp->clientID, strlen(clientID)+1, clientID);
396                 OICStrcpy(g_SCProperties.clientID, strlen(clientID)+1, clientID);
397
398                 OIC_LOG_V(INFO_PRIVATE, SC_ENROLLEE_TAG, "[User specific property] %s : %s",
399                                         SC_RSRVD_ES_VENDOR_CLIENTID, pCloudProp->clientID);
400             }
401
402             //SC_RSRVD_ES_VENDOR_AAC
403             char *aac = NULL;
404             if (OCRepPayloadGetPropString(payload, SC_RSRVD_ES_VENDOR_AAC, &aac))
405             {
406                 if(*userdata == NULL)
407                 {
408                     *userdata = (void*)OICMalloc(sizeof(SCCoapCloudServerConfProperties));
409                     if( *userdata == NULL )
410                     {
411                         OIC_LOG(ERROR, SC_ENROLLEE_TAG, "OICMalloc for SCCoapCloudServerConfProperties is failed");
412                         return ;
413                     }
414                     memset(*userdata, 0, sizeof(SCCoapCloudServerConfProperties));
415                 }
416
417                 if (*userdata != NULL)
418                 {
419                     SCCoapCloudServerConfProperties *pCloudProp =
420                                                     (SCCoapCloudServerConfProperties*) (*userdata);
421                     pCloudProp->aac[0] = '\0';
422
423                     OICStrcpy(pCloudProp->aac, MAXLEN_STRING, aac);
424                     OICStrcpy(g_SCProperties.aac, MAXLEN_STRING, aac);
425                     OICFree(aac);
426
427                     OIC_LOG_V(INFO_PRIVATE, SC_ENROLLEE_TAG, "[User specific property] %s : %s",
428                             SC_RSRVD_ES_VENDOR_AAC, pCloudProp->aac);
429                 }
430             }
431
432             //SC_RSRVD_ES_VENDOR_UID
433             char *uid = NULL;
434             if (OCRepPayloadGetPropString(payload, SC_RSRVD_ES_VENDOR_UID, &uid))
435             {
436                 if(*userdata == NULL)
437                 {
438                     *userdata = (void*)OICMalloc(sizeof(SCCoapCloudServerConfProperties));
439                     if( *userdata == NULL )
440                     {
441                         OIC_LOG(ERROR, SC_ENROLLEE_TAG, "OICMalloc for SCCoapCloudServerConfProperties is failed");
442                         return ;
443                     }
444                     memset(*userdata, 0, sizeof(SCCoapCloudServerConfProperties));
445                 }
446
447                 if (*userdata != NULL)
448                 {
449                     SCCoapCloudServerConfProperties *pCloudProp =
450                                                     (SCCoapCloudServerConfProperties*) (*userdata);
451                     pCloudProp->uid[0] = '\0';
452
453                     OICStrcpy(pCloudProp->uid, MAXLEN_STRING, uid);
454                     OICStrcpy(g_SCProperties.uid, MAXLEN_STRING, uid);
455                     OICFree(uid);
456
457                     OIC_LOG_V(INFO_PRIVATE, SC_ENROLLEE_TAG, "[User specific property] %s : %s",
458                             SC_RSRVD_ES_VENDOR_UID, pCloudProp->uid);
459                 }
460             }
461
462             //SC_RSRVD_ES_VENDOR_REFRESH_TOKEN
463             char *refreshToken = NULL;
464             if (OCRepPayloadGetPropString(payload, SC_RSRVD_ES_VENDOR_REFRESH_TOKEN, &refreshToken))
465             {
466                 if(*userdata == NULL)
467                 {
468                     *userdata = (void*)OICMalloc(sizeof(SCCoapCloudServerConfProperties));
469                     if( *userdata == NULL )
470                     {
471                         OIC_LOG(ERROR, SC_ENROLLEE_TAG, "OICMalloc for SCCoapCloudServerConfProperties is failed");
472                         return ;
473                     }
474                     memset(*userdata, 0, sizeof(SCCoapCloudServerConfProperties));
475                 }
476
477                 if (*userdata != NULL)
478                 {
479                     SCCoapCloudServerConfProperties *pCloudProp =
480                                                     (SCCoapCloudServerConfProperties*) (*userdata);
481                     pCloudProp->refreshToken[0] = '\0';
482
483                     OICStrcpy(pCloudProp->refreshToken, MAXLEN_STRING, refreshToken);
484                     OICStrcpy(g_SCProperties.refreshToken, MAXLEN_STRING, refreshToken);
485                     OICFree(refreshToken);
486
487                     OIC_LOG_V(INFO_PRIVATE, SC_ENROLLEE_TAG, "[User specific property] %s : %s",
488                             SC_RSRVD_ES_VENDOR_REFRESH_TOKEN, pCloudProp->refreshToken);
489                 }
490             }
491
492             ReadTnCdata(payload,userdata);
493         }
494     }
495
496     OIC_LOG(INFO, SC_ENROLLEE_TAG, "ReadUserdataCb OUT");
497 }
498
499 void WriteUserdataCb(OCRepPayload* payload, char* resourceType)
500 {
501     OIC_LOG(INFO, SC_ENROLLEE_TAG, "WriteUserdataCb IN");
502
503     if(payload != NULL)
504     {
505         if(strstr(resourceType, OC_RSRVD_ES_RES_TYPE_EASYSETUP))
506         {
507             OCRepPayloadSetPropInt(payload, SC_RSRVD_ES_VENDOR_NETCONNECTION_STATE, (int) g_SCProperties.netConnectionState);
508         }
509
510         if(strstr(resourceType, OC_RSRVD_ES_RES_TYPE_DEVCONF))
511         {
512 #ifndef __TIZENRT__
513             OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_DEVICE_TYPE, g_SCProperties.deviceType);
514             OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_DEVICE_SUBTYPE, g_SCProperties.deviceSubType);
515             OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_REGISTER_SET_DEV, g_SCProperties.regSetDev);
516             OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_REGISTER_MOBILE_DEV, g_SCProperties.regMobileDev);
517             OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_NETWORK_PROV_INFO, g_SCProperties.nwProvInfo);
518             OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_PNP_PIN, g_SCProperties.pnpPin);
519             OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_MODEL_NUMBER, g_SCProperties.modelNumber);
520             OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_COUNTRY, g_SCProperties.country);
521             OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_LANGUAGE, g_SCProperties.language);
522             OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_GPSLOCATION, g_SCProperties.gpsLocation);
523             OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_UTC_DATE_TIME, g_SCProperties.utcDateTime);
524             OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_REGIONAL_DATE_TIME, g_SCProperties.regionalDateTime);
525             OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_ES_PROTOCOL_VERSION, g_SCProperties.esProtocolVersion);
526 #else
527             if(g_SCProperties.deviceType != NULL)
528             {
529                 OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_DEVICE_TYPE, g_SCProperties.deviceType);
530             }
531             if(g_SCProperties.deviceSubType != NULL)
532             {
533                 OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_DEVICE_SUBTYPE, g_SCProperties.deviceSubType);
534             }
535             if(g_SCProperties.regSetDev != NULL)
536             {
537                 OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_REGISTER_SET_DEV, g_SCProperties.regSetDev);
538             }
539             if(g_SCProperties.regMobileDev != NULL)
540             {
541                 OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_REGISTER_MOBILE_DEV, g_SCProperties.regMobileDev);
542             }
543             if(g_SCProperties.nwProvInfo!= NULL)
544             {
545                 OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_NETWORK_PROV_INFO, g_SCProperties.nwProvInfo);
546             }
547             if(g_SCProperties.pnpPin != NULL)
548             {
549                OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_PNP_PIN, g_SCProperties.pnpPin);
550             }
551             if(g_SCProperties.modelNumber != NULL)
552             {
553                OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_MODEL_NUMBER, g_SCProperties.modelNumber);
554             }
555             if(g_SCProperties.country != NULL)
556             {
557                OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_COUNTRY, g_SCProperties.country);
558             }
559             if(g_SCProperties.language != NULL)
560             {
561                OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_LANGUAGE, g_SCProperties.language);
562             }
563             if(g_SCProperties.gpsLocation != NULL)
564             {
565                OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_GPSLOCATION, g_SCProperties.gpsLocation);
566             }
567             if(g_SCProperties.esProtocolVersion != NULL)
568             {
569                 OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_ES_PROTOCOL_VERSION, g_SCProperties.esProtocolVersion);
570             }
571 #endif
572         }
573     }
574
575     WriteTnCdata(payload, resourceType);
576     WriteWifiData(payload, resourceType);
577
578     OIC_LOG(INFO, SC_ENROLLEE_TAG, "WriteUserdataCb OUT");
579 }