Update snapshot(2017-12-06)
[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                 OICFree(account);
80                 return;
81             }
82         }
83
84         SCDevConfProperties *pDevConfProp = (SCDevConfProperties*)(*userdata);
85         OICStrcpy(pDevConfProp->account, MAXLEN_STRING, account);
86         OICStrcpy(g_SCProperties.account, MAXLEN_STRING, account);
87
88         OIC_LOG_V(INFO_PRIVATE, SC_ENROLLEE_TAG, "[User specific property] %s : %s",
89                 SC_RSRVD_ES_VENDOR_ACCOUNT, pDevConfProp->account);
90
91         OICFree(account);
92     }
93     OIC_LOG(INFO, SC_ENROLLEE_TAG, "ReadAccountData OUT");
94
95 }
96
97 ESResult SetSCTncInfo(SCTncInfo *tncInfo)
98 {
99     if(tncInfo == NULL)
100     {
101         return ES_ERROR;
102     }
103     g_SCProperties.tncInfo = *tncInfo;
104     return ES_OK;
105 }
106
107 ESResult SetSCTncStatus(int status)
108 {
109     g_SCProperties.tncStatus = status;
110     return ES_OK;
111 }
112
113 ESResult SetSCNetConnectionState(NETCONNECTION_STATE netConnectionState)
114 {
115     OIC_LOG(INFO, SC_ENROLLEE_TAG, "SetSCNetConnectionState IN");
116
117     OIC_LOG_V(INFO_PRIVATE, SC_ENROLLEE_TAG, "SetSCNetConnectionState: %d", netConnectionState);
118     g_SCProperties.netConnectionState = netConnectionState;
119
120     if(OC_STACK_NO_OBSERVERS == OCNotifyAllObservers(g_ESEasySetupResource.handle, OC_HIGH_QOS))
121     {
122         OIC_LOG(DEBUG, SC_ENROLLEE_TAG, "provResource doesn't have any observers.");
123     }
124
125     OIC_LOG(INFO, SC_ENROLLEE_TAG, "SetSCNetConnectionState OUT");
126     return ES_OK;
127 }
128
129 static void ReadTnCdata(OCRepPayload* payload,void** userdata)
130 {
131     OIC_LOG(INFO, SC_ENROLLEE_TAG, "ReadTnCdata IN");
132
133     char* tncResult = NULL;
134
135     if (OCRepPayloadGetPropString(payload, SC_RSRVD_ES_VENDOR_TNC_RESULT, &tncResult))
136     {
137         if(*userdata == NULL)
138         {
139             *userdata = (void*)OICMalloc(sizeof(SCCoapCloudServerConfProperties));
140             if( *userdata == NULL )
141             {
142                 OIC_LOG(ERROR, SC_ENROLLEE_TAG, "OICMalloc for SCCoapCloudServerConfProperties is failed");
143                 return ;
144             }
145         }
146
147         SCCoapCloudServerConfProperties *pProp = (SCCoapCloudServerConfProperties*)(*userdata);
148         OICStrcpy(pProp->tncResult, MAXLEN_STRING, tncResult);
149         OICStrcpy(g_SCProperties.tncResult, MAXLEN_STRING, tncResult);
150
151         OIC_LOG_V(INFO_PRIVATE, SC_ENROLLEE_TAG, "[User specific property] %s : %s",
152                 SC_RSRVD_ES_VENDOR_TNC_RESULT, pProp->tncResult);
153     }
154
155     OIC_LOG(INFO, SC_ENROLLEE_TAG, "ReadTnCdata OUT");
156 }
157
158 void WriteTnCdata(OCRepPayload* payload, char* resourceType)
159 {
160     OIC_LOG(INFO, SC_ENROLLEE_TAG, "WriteTnCdata IN");
161
162     if(payload == NULL || resourceType == NULL)
163     {
164         OIC_LOG(DEBUG, SC_ENROLLEE_TAG, "Invalid Params payload or resourceType is NULL");
165         OIC_LOG(DEBUG, SC_ENROLLEE_TAG, "WriteTnCdata OUT");
166         return;
167     }
168     if(strstr(resourceType, OC_RSRVD_ES_RES_TYPE_EASYSETUP))
169     {
170         OCRepPayloadSetPropInt(payload, SC_RSRVD_ES_VENDOR_TNC_STATUS, g_SCProperties.tncStatus);
171     }
172     else if(strstr(resourceType, OC_RSRVD_ES_RES_TYPE_DEVCONF))
173     {
174         OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_TNC_HEADER,
175                 g_SCProperties.tncInfo.header);
176         OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_TNC_VERSION,
177                 g_SCProperties.tncInfo.version);
178     }
179     else if(strstr(resourceType, OC_RSRVD_ES_RES_TYPE_COAPCLOUDCONF))
180     {
181         OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_TNC_RESULT,
182                 g_SCProperties.tncResult);
183     }
184     OIC_LOG(INFO, SC_ENROLLEE_TAG, "WriteTnCdata OUT");
185 }
186
187 void WriteWifiData(OCRepPayload* payload, char* resourceType)
188 {
189     OIC_LOG(INFO, SC_ENROLLEE_TAG, "WriteWifiData IN");
190
191     if(payload == NULL || resourceType == NULL)
192     {
193         OIC_LOG(DEBUG, SC_ENROLLEE_TAG, "Invalid Params payload or resourceType is NULL");
194         OIC_LOG(DEBUG, SC_ENROLLEE_TAG, "WriteWifiData OUT");
195         return;
196     }
197
198     if(strstr(resourceType, OC_RSRVD_ES_RES_TYPE_WIFICONF))
199     {
200         OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_BSSID,
201                 g_SCProperties.bssid);
202     }
203     OIC_LOG(INFO, SC_ENROLLEE_TAG, "WriteWifiData OUT");
204 }
205
206 ESResult SetRegisterSetDevice(const char *regSetDevice)
207 {
208     if(regSetDevice != NULL)
209     {
210         OICStrcpy(g_SCProperties.regSetDev, sizeof(g_SCProperties.regSetDev), regSetDevice);
211         return ES_OK;
212     }
213     return ES_ERROR;
214 }
215
216 ESResult SetNetworkProvInfo(const char *nwProvInfo)
217 {
218     if(nwProvInfo != NULL)
219     {
220         OICStrcpy(g_SCProperties.nwProvInfo, sizeof(g_SCProperties.nwProvInfo), nwProvInfo);
221         return ES_OK;
222     }
223     return ES_ERROR;
224 }
225
226 ESResult SetSCPnPPin(const char *pnp)
227 {
228     if(pnp != NULL)
229     {
230         OICStrcpy(g_SCProperties.pnpPin, sizeof(g_SCProperties.pnpPin), pnp);
231         return ES_OK;
232     }
233     return ES_ERROR;
234 }
235
236 ESResult SetESVersionInfo(const char *esProtocolVersion)
237 {
238     if(esProtocolVersion != NULL)
239     {
240         OICStrcpy(g_SCProperties.esProtocolVersion, sizeof(g_SCProperties.esProtocolVersion), esProtocolVersion);
241         return ES_OK;
242     }
243     return ES_ERROR;
244 }
245
246 void ReadUserdataCb(OCRepPayload* payload, char* resourceType, void** userdata)
247 {
248     OIC_LOG(INFO, SC_ENROLLEE_TAG, "ReadUserdataCb IN");
249
250     if(payload != NULL)
251     {
252         if(strstr(resourceType, OC_RSRVD_ES_RES_TYPE_WIFICONF))
253         {
254             int64_t channel = -1;
255             char *bssid = NULL;
256             if (OCRepPayloadGetPropInt(payload, SC_RSRVD_ES_VENDOR_DISCOVERY_CHANNEL, &channel))
257             {
258                 if(*userdata == NULL)
259                 {
260                     *userdata = (void*)OICMalloc(sizeof(SCWiFiConfProperties));
261                     if( *userdata == NULL )
262                     {
263                         OIC_LOG(ERROR, SC_ENROLLEE_TAG, "OICMalloc for SCWiFiConfProperties is failed");
264                         return ;
265                     }
266                     memset(*userdata, 0, sizeof(SCWiFiConfProperties));
267                 }
268                 OIC_LOG_V(INFO_PRIVATE, SC_ENROLLEE_TAG, "[User specific property] %s : [%" PRId64 "]",
269                                                             SC_RSRVD_ES_VENDOR_DISCOVERY_CHANNEL, channel);
270                 ((SCWiFiConfProperties*)(*userdata))->discoveryChannel = (int) channel;
271                 g_SCProperties.discoveryChannel = channel;
272             }
273             if (OCRepPayloadGetPropString(payload, SC_RSRVD_ES_VENDOR_BSSID, &bssid))
274             {
275                 if(*userdata == NULL)
276                 {
277                     *userdata = (void*) OICMalloc(sizeof(SCWiFiConfProperties));
278                     if( *userdata == NULL )
279                     {
280                         OIC_LOG(ERROR, SC_ENROLLEE_TAG, "OICMalloc for SCWiFiConfProperties is failed");
281                         return ;
282                     }
283                     memset(*userdata, 0, sizeof(SCWiFiConfProperties));
284                 }
285                 if (*userdata != NULL)
286                 {
287                     OIC_LOG_V(INFO_PRIVATE, SC_ENROLLEE_TAG, "[User specific property] %s : %s",
288                             SC_RSRVD_ES_VENDOR_BSSID, bssid);
289                     SCWiFiConfProperties* pWifiConfProp = (SCWiFiConfProperties*)(*userdata);
290                     OICStrcpy(pWifiConfProp->bssid, sizeof(pWifiConfProp->bssid), bssid);
291                     OICStrcpy(g_SCProperties.bssid, sizeof(g_SCProperties.bssid), bssid);
292                     OICFree(bssid);
293                 }
294             }
295         }
296         else if(strstr(resourceType, OC_RSRVD_ES_RES_TYPE_DEVCONF))
297         {
298             if(*userdata == NULL)
299             {
300                 *userdata = (void*)OICMalloc(sizeof(SCDevConfProperties));
301                 if( *userdata == NULL )
302                 {
303                     OIC_LOG(ERROR, SC_ENROLLEE_TAG, "OICMalloc for SCDevConfProperties is failed");
304                     return ;
305                 }
306                 memset(*userdata, 0, sizeof(SCDevConfProperties));
307             }
308
309             SCDevConfProperties *pDevConfProp = (SCDevConfProperties*)(*userdata);
310
311             char**locationList = NULL;
312             size_t dimensions[MAX_REP_ARRAY_DEPTH] = {0};
313             if(OCRepPayloadGetStringArray(payload, SC_RSRVD_ES_VENDOR_LOCATION, &locationList, dimensions))
314             {
315                 for(size_t idx = 0; idx < dimensions[0]; idx++)
316                 {
317                     OICStrcpy(pDevConfProp->location[idx], strlen(locationList[idx])+1, locationList[idx]);
318                     OICStrcpy(g_SCProperties.location[idx], strlen(locationList[idx])+1, locationList[idx]);
319
320                     OIC_LOG_V(INFO_PRIVATE, SC_ENROLLEE_TAG, "[User specific property] %s : %s",
321                                         SC_RSRVD_ES_VENDOR_LOCATION, pDevConfProp->location[idx]);
322                 }
323
324                 ((SCDevConfProperties*)(*userdata))->numLocation = (int)dimensions[0];
325                 g_SCProperties.numLocation = (int)dimensions[0];
326             }
327
328             ReadAccountData(payload,userdata);
329
330             char *regMobileDev = NULL;
331             if (OCRepPayloadGetPropString(payload, SC_RSRVD_ES_VENDOR_REGISTER_MOBILE_DEV, &regMobileDev))
332             {
333                 OICStrcpy(pDevConfProp->regMobileDev, strlen(regMobileDev)+1, regMobileDev);
334                 OICStrcpy(g_SCProperties.regMobileDev, strlen(regMobileDev)+1, regMobileDev);
335                 OIC_LOG_V(INFO_PRIVATE, SC_ENROLLEE_TAG, "pDevConfProp.regMobileDev %s", g_SCProperties.regMobileDev);
336             }
337
338             char *country = NULL;
339             if (OCRepPayloadGetPropString(payload, SC_RSRVD_ES_VENDOR_COUNTRY, &country))
340             {
341                 OICStrcpy(pDevConfProp->country, strlen(country)+1, country);
342                 OICStrcpy(g_SCProperties.country, strlen(country)+1, country);
343                 OIC_LOG_V(INFO_PRIVATE, SC_ENROLLEE_TAG, "pDevConfProp.country %s", g_SCProperties.country);
344             }
345
346             char *language = NULL;
347             if (OCRepPayloadGetPropString(payload, SC_RSRVD_ES_VENDOR_LANGUAGE, &language))
348             {
349                 OICStrcpy(pDevConfProp->language, strlen(language)+1, language);
350                 OICStrcpy(g_SCProperties.language, strlen(language)+1, language);
351                 OIC_LOG_V(INFO_PRIVATE, SC_ENROLLEE_TAG, "pDevConfProp.language %s", g_SCProperties.language);
352             }
353
354             char *gpsLocation = NULL;
355             if (OCRepPayloadGetPropString(payload, SC_RSRVD_ES_VENDOR_GPSLOCATION, &gpsLocation))
356             {
357                 OICStrcpy(pDevConfProp->gpsLocation, strlen(gpsLocation)+1, gpsLocation);
358                 OICStrcpy(g_SCProperties.gpsLocation, strlen(gpsLocation)+1, gpsLocation);
359                 OIC_LOG_V(INFO_PRIVATE, SC_ENROLLEE_TAG, "pDevConfProp.gpsLocation %s", g_SCProperties.gpsLocation);
360             }
361
362             char *utcDateTime = NULL;
363             if (OCRepPayloadGetPropString(payload, SC_RSRVD_ES_VENDOR_UTC_DATE_TIME, &utcDateTime))
364             {
365                 OICStrcpy(pDevConfProp->utcDateTime, strlen(utcDateTime)+1, utcDateTime);
366                 OICStrcpy(g_SCProperties.utcDateTime, strlen(utcDateTime)+1, utcDateTime);
367                 OIC_LOG_V(INFO_PRIVATE, SC_ENROLLEE_TAG, "pDevConfProp.utcDateTime %s", g_SCProperties.utcDateTime);
368             }
369
370             char *regionalDateTime = NULL;
371             if (OCRepPayloadGetPropString(payload, SC_RSRVD_ES_VENDOR_REGIONAL_DATE_TIME, &regionalDateTime))
372             {
373                 OICStrcpy(pDevConfProp->regionalDateTime, strlen(regionalDateTime)+1, regionalDateTime);
374                 OICStrcpy(g_SCProperties.regionalDateTime, strlen(regionalDateTime)+1, regionalDateTime);
375                 OIC_LOG_V(INFO_PRIVATE, SC_ENROLLEE_TAG, "pDevConfProp.regionalDateTime %s", g_SCProperties.regionalDateTime);
376             }
377         }
378         else if(strstr(resourceType, OC_RSRVD_ES_RES_TYPE_COAPCLOUDCONF))
379         {
380             char* clientID = NULL;
381             if(OCRepPayloadGetPropString(payload, SC_RSRVD_ES_VENDOR_CLIENTID, &clientID))
382             {
383                 if(*userdata == NULL)
384                 {
385                     *userdata = (void*)OICMalloc(sizeof(SCCoapCloudServerConfProperties));
386                     if( *userdata == NULL )
387                     {
388                         OIC_LOG(ERROR, SC_ENROLLEE_TAG, "OICMalloc for SCCoapCloudServerConfProperties is failed");
389                         return ;
390                     }
391                     memset(*userdata, 0, sizeof(SCCoapCloudServerConfProperties));
392                 }
393
394                 SCCoapCloudServerConfProperties *pCloudProp =
395                                                     (SCCoapCloudServerConfProperties*)(*userdata);
396
397                 OICStrcpy(pCloudProp->clientID, strlen(clientID)+1, clientID);
398                 OICStrcpy(g_SCProperties.clientID, strlen(clientID)+1, clientID);
399
400                 OIC_LOG_V(INFO_PRIVATE, SC_ENROLLEE_TAG, "[User specific property] %s : %s",
401                                         SC_RSRVD_ES_VENDOR_CLIENTID, pCloudProp->clientID);
402             }
403
404             //SC_RSRVD_ES_VENDOR_AAC
405             char *aac = NULL;
406             if (OCRepPayloadGetPropString(payload, SC_RSRVD_ES_VENDOR_AAC, &aac))
407             {
408                 if(*userdata == NULL)
409                 {
410                     *userdata = (void*)OICMalloc(sizeof(SCCoapCloudServerConfProperties));
411                     if( *userdata == NULL )
412                     {
413                         OIC_LOG(ERROR, SC_ENROLLEE_TAG, "OICMalloc for SCCoapCloudServerConfProperties is failed");
414                         return ;
415                     }
416                     memset(*userdata, 0, sizeof(SCCoapCloudServerConfProperties));
417                 }
418
419                 if (*userdata != NULL)
420                 {
421                     SCCoapCloudServerConfProperties *pCloudProp =
422                                                     (SCCoapCloudServerConfProperties*) (*userdata);
423                     pCloudProp->aac[0] = '\0';
424
425                     OICStrcpy(pCloudProp->aac, MAXLEN_STRING, aac);
426                     OICStrcpy(g_SCProperties.aac, MAXLEN_STRING, aac);
427                     OICFree(aac);
428
429                     OIC_LOG_V(INFO_PRIVATE, SC_ENROLLEE_TAG, "[User specific property] %s : %s",
430                             SC_RSRVD_ES_VENDOR_AAC, pCloudProp->aac);
431                 }
432             }
433
434             //SC_RSRVD_ES_VENDOR_UID
435             char *uid = NULL;
436             if (OCRepPayloadGetPropString(payload, SC_RSRVD_ES_VENDOR_UID, &uid))
437             {
438                 if(*userdata == NULL)
439                 {
440                     *userdata = (void*)OICMalloc(sizeof(SCCoapCloudServerConfProperties));
441                     if( *userdata == NULL )
442                     {
443                         OIC_LOG(ERROR, SC_ENROLLEE_TAG, "OICMalloc for SCCoapCloudServerConfProperties is failed");
444                         return ;
445                     }
446                     memset(*userdata, 0, sizeof(SCCoapCloudServerConfProperties));
447                 }
448
449                 if (*userdata != NULL)
450                 {
451                     SCCoapCloudServerConfProperties *pCloudProp =
452                                                     (SCCoapCloudServerConfProperties*) (*userdata);
453                     pCloudProp->uid[0] = '\0';
454
455                     OICStrcpy(pCloudProp->uid, MAXLEN_STRING, uid);
456                     OICStrcpy(g_SCProperties.uid, MAXLEN_STRING, uid);
457                     OICFree(uid);
458
459                     OIC_LOG_V(INFO_PRIVATE, SC_ENROLLEE_TAG, "[User specific property] %s : %s",
460                             SC_RSRVD_ES_VENDOR_UID, pCloudProp->uid);
461                 }
462             }
463
464             //SC_RSRVD_ES_VENDOR_REFRESH_TOKEN
465             char *refreshToken = NULL;
466             if (OCRepPayloadGetPropString(payload, SC_RSRVD_ES_VENDOR_REFRESH_TOKEN, &refreshToken))
467             {
468                 if(*userdata == NULL)
469                 {
470                     *userdata = (void*)OICMalloc(sizeof(SCCoapCloudServerConfProperties));
471                     if( *userdata == NULL )
472                     {
473                         OIC_LOG(ERROR, SC_ENROLLEE_TAG, "OICMalloc for SCCoapCloudServerConfProperties is failed");
474                         return ;
475                     }
476                     memset(*userdata, 0, sizeof(SCCoapCloudServerConfProperties));
477                 }
478
479                 if (*userdata != NULL)
480                 {
481                     SCCoapCloudServerConfProperties *pCloudProp =
482                                                     (SCCoapCloudServerConfProperties*) (*userdata);
483                     pCloudProp->refreshToken[0] = '\0';
484
485                     OICStrcpy(pCloudProp->refreshToken, MAXLEN_STRING, refreshToken);
486                     OICStrcpy(g_SCProperties.refreshToken, MAXLEN_STRING, refreshToken);
487                     OICFree(refreshToken);
488
489                     OIC_LOG_V(INFO_PRIVATE, SC_ENROLLEE_TAG, "[User specific property] %s : %s",
490                             SC_RSRVD_ES_VENDOR_REFRESH_TOKEN, pCloudProp->refreshToken);
491                 }
492             }
493
494             ReadTnCdata(payload,userdata);
495         }
496     }
497
498     OIC_LOG(INFO, SC_ENROLLEE_TAG, "ReadUserdataCb OUT");
499 }
500
501 void WriteUserdataCb(OCRepPayload* payload, char* resourceType)
502 {
503     OIC_LOG(INFO, SC_ENROLLEE_TAG, "WriteUserdataCb IN");
504
505     if(payload != NULL)
506     {
507         if(strstr(resourceType, OC_RSRVD_ES_RES_TYPE_EASYSETUP))
508         {
509             OCRepPayloadSetPropInt(payload, SC_RSRVD_ES_VENDOR_NETCONNECTION_STATE, (int) g_SCProperties.netConnectionState);
510         }
511
512         if(strstr(resourceType, OC_RSRVD_ES_RES_TYPE_DEVCONF))
513         {
514 #ifndef __TIZENRT__
515             OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_DEVICE_TYPE, g_SCProperties.deviceType);
516             OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_DEVICE_SUBTYPE, g_SCProperties.deviceSubType);
517             OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_REGISTER_SET_DEV, g_SCProperties.regSetDev);
518             OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_REGISTER_MOBILE_DEV, g_SCProperties.regMobileDev);
519             OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_NETWORK_PROV_INFO, g_SCProperties.nwProvInfo);
520             OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_PNP_PIN, g_SCProperties.pnpPin);
521             OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_MODEL_NUMBER, g_SCProperties.modelNumber);
522             OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_COUNTRY, g_SCProperties.country);
523             OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_LANGUAGE, g_SCProperties.language);
524             OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_GPSLOCATION, g_SCProperties.gpsLocation);
525             OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_UTC_DATE_TIME, g_SCProperties.utcDateTime);
526             OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_REGIONAL_DATE_TIME, g_SCProperties.regionalDateTime);
527             OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_ES_PROTOCOL_VERSION, g_SCProperties.esProtocolVersion);
528 #else
529             if(g_SCProperties.deviceType != NULL)
530             {
531                 OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_DEVICE_TYPE, g_SCProperties.deviceType);
532             }
533             if(g_SCProperties.deviceSubType != NULL)
534             {
535                 OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_DEVICE_SUBTYPE, g_SCProperties.deviceSubType);
536             }
537             if(g_SCProperties.regSetDev != NULL)
538             {
539                 OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_REGISTER_SET_DEV, g_SCProperties.regSetDev);
540             }
541             if(g_SCProperties.regMobileDev != NULL)
542             {
543                 OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_REGISTER_MOBILE_DEV, g_SCProperties.regMobileDev);
544             }
545             if(g_SCProperties.nwProvInfo!= NULL)
546             {
547                 OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_NETWORK_PROV_INFO, g_SCProperties.nwProvInfo);
548             }
549             if(g_SCProperties.pnpPin != NULL)
550             {
551                OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_PNP_PIN, g_SCProperties.pnpPin);
552             }
553             if(g_SCProperties.modelNumber != NULL)
554             {
555                OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_MODEL_NUMBER, g_SCProperties.modelNumber);
556             }
557             if(g_SCProperties.country != NULL)
558             {
559                OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_COUNTRY, g_SCProperties.country);
560             }
561             if(g_SCProperties.language != NULL)
562             {
563                OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_LANGUAGE, g_SCProperties.language);
564             }
565             if(g_SCProperties.gpsLocation != NULL)
566             {
567                OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_GPSLOCATION, g_SCProperties.gpsLocation);
568             }
569             if(g_SCProperties.esProtocolVersion != NULL)
570             {
571                 OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_ES_PROTOCOL_VERSION, g_SCProperties.esProtocolVersion);
572             }
573 #endif
574         }
575     }
576
577     WriteTnCdata(payload, resourceType);
578     WriteWifiData(payload, resourceType);
579
580     OIC_LOG(INFO, SC_ENROLLEE_TAG, "WriteUserdataCb OUT");
581 }