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