1 //******************************************************************
3 // Copyright 2015 Samsung Electronics All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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
11 // http://www.apache.org/licenses/LICENSE-2.0
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.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
22 #include "samsung/sc_easysetup.h"
24 #include "oic_malloc.h"
28 #include "ocpayload.h"
29 #include "oic_string.h"
30 #include "oic_malloc.h"
32 #include "resourcehandler.h"
35 * @var SC_ENROLLEE_TAG
36 * @brief Logging tag for module name.
38 #define SC_ENROLLEE_TAG "ES_SC_ENROLLEE"
40 SCProperties g_SCProperties;
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);
47 ESResult SetSCProperties(const SCProperties *prop)
49 OIC_LOG(INFO, SC_ENROLLEE_TAG, "SetSCProperties IN");
52 memcpy(&g_SCProperties, prop, sizeof(SCProperties));
53 OIC_LOG(INFO, SC_ENROLLEE_TAG, "SetSCProperties OUT");
56 OIC_LOG(INFO, SC_ENROLLEE_TAG, "SetSCProperties OUT");
60 static void ReadAccountData(OCRepPayload* payload,void** userdata)
62 OIC_LOG(INFO, SC_ENROLLEE_TAG, "ReadAccountData IN");
66 if(OCRepPayloadGetPropString(payload, SC_RSRVD_ES_VENDOR_ACCOUNT, &account))
70 *userdata = (void*)OICMalloc(sizeof(SCDevConfProperties));
71 if( *userdata == NULL )
73 OIC_LOG(ERROR, SC_ENROLLEE_TAG, "OICMalloc for SCDevConfProperties is failed");
79 SCDevConfProperties *pDevConfProp = (SCDevConfProperties*)(*userdata);
80 OICStrcpy(pDevConfProp->account, MAXLEN_STRING, account);
81 OICStrcpy(g_SCProperties.account, MAXLEN_STRING, account);
83 OIC_LOG_V(INFO_PRIVATE, SC_ENROLLEE_TAG, "[User specific property] %s : %s",
84 SC_RSRVD_ES_VENDOR_ACCOUNT, pDevConfProp->account);
88 OIC_LOG(INFO, SC_ENROLLEE_TAG, "ReadAccountData OUT");
92 ESResult SetSCTncInfo(SCTncInfo *tncInfo)
98 g_SCProperties.tncInfo = *tncInfo;
102 ESResult SetSCTncStatus(int status)
104 g_SCProperties.tncStatus = status;
108 ESResult SetSCNetConnectionState(NETCONNECTION_STATE netConnectionState)
110 OIC_LOG(INFO, SC_ENROLLEE_TAG, "SetSCNetConnectionState IN");
112 OIC_LOG_V(INFO_PRIVATE, SC_ENROLLEE_TAG, "SetSCNetConnectionState: %d", netConnectionState);
113 g_SCProperties.netConnectionState = netConnectionState;
115 if(OC_STACK_NO_OBSERVERS == OCNotifyAllObservers(g_ESEasySetupResource.handle, OC_HIGH_QOS))
117 OIC_LOG(DEBUG, SC_ENROLLEE_TAG, "provResource doesn't have any observers.");
120 OIC_LOG(INFO, SC_ENROLLEE_TAG, "SetSCNetConnectionState OUT");
124 static void ReadTnCdata(OCRepPayload* payload,void** userdata)
126 OIC_LOG(INFO, SC_ENROLLEE_TAG, "ReadTnCdata IN");
128 char* tncResult = NULL;
130 if (OCRepPayloadGetPropString(payload, SC_RSRVD_ES_VENDOR_TNC_RESULT, &tncResult))
132 if(*userdata == NULL)
134 *userdata = (void*)OICMalloc(sizeof(SCCoapCloudServerConfProperties));
135 if( *userdata == NULL )
137 OIC_LOG(ERROR, SC_ENROLLEE_TAG, "OICMalloc for SCCoapCloudServerConfProperties is failed");
142 SCCoapCloudServerConfProperties *pProp = (SCCoapCloudServerConfProperties*)(*userdata);
143 OICStrcpy(pProp->tncResult, MAXLEN_STRING, tncResult);
144 OICStrcpy(g_SCProperties.tncResult, MAXLEN_STRING, tncResult);
146 OIC_LOG_V(INFO_PRIVATE, SC_ENROLLEE_TAG, "[User specific property] %s : %s",
147 SC_RSRVD_ES_VENDOR_TNC_RESULT, pProp->tncResult);
150 OIC_LOG(INFO, SC_ENROLLEE_TAG, "ReadTnCdata OUT");
153 void WriteTnCdata(OCRepPayload* payload, char* resourceType)
155 OIC_LOG(INFO, SC_ENROLLEE_TAG, "WriteTnCdata IN");
157 if(payload == NULL || resourceType == NULL)
159 OIC_LOG(DEBUG, SC_ENROLLEE_TAG, "Invalid Params payload or resourceType is NULL");
160 OIC_LOG(DEBUG, SC_ENROLLEE_TAG, "WriteTnCdata OUT");
163 if(strstr(resourceType, OC_RSRVD_ES_RES_TYPE_EASYSETUP))
165 OCRepPayloadSetPropInt(payload, SC_RSRVD_ES_VENDOR_TNC_STATUS, g_SCProperties.tncStatus);
167 else if(strstr(resourceType, OC_RSRVD_ES_RES_TYPE_DEVCONF))
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);
174 else if(strstr(resourceType, OC_RSRVD_ES_RES_TYPE_COAPCLOUDCONF))
176 OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_TNC_RESULT,
177 g_SCProperties.tncResult);
179 OIC_LOG(INFO, SC_ENROLLEE_TAG, "WriteTnCdata OUT");
182 void WriteWifiData(OCRepPayload* payload, char* resourceType)
184 OIC_LOG(INFO, SC_ENROLLEE_TAG, "WriteWifiData IN");
186 if(payload == NULL || resourceType == NULL)
188 OIC_LOG(DEBUG, SC_ENROLLEE_TAG, "Invalid Params payload or resourceType is NULL");
189 OIC_LOG(DEBUG, SC_ENROLLEE_TAG, "WriteWifiData OUT");
193 if(strstr(resourceType, OC_RSRVD_ES_RES_TYPE_WIFICONF))
195 OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_BSSID,
196 g_SCProperties.bssid);
198 OIC_LOG(INFO, SC_ENROLLEE_TAG, "WriteWifiData OUT");
201 ESResult SetRegisterSetDevice(const char *regSetDevice)
203 if(regSetDevice != NULL)
205 OICStrcpy(g_SCProperties.regSetDev, sizeof(g_SCProperties.regSetDev), regSetDevice);
211 ESResult SetNetworkProvInfo(const char *nwProvInfo)
213 if(nwProvInfo != NULL)
215 OICStrcpy(g_SCProperties.nwProvInfo, sizeof(g_SCProperties.nwProvInfo), nwProvInfo);
221 ESResult SetSCPnPPin(const char *pnp)
225 OICStrcpy(g_SCProperties.pnpPin, sizeof(g_SCProperties.pnpPin), pnp);
231 ESResult SetESVersionInfo(const char *esProtocolVersion)
233 if(esProtocolVersion != NULL)
235 OICStrcpy(g_SCProperties.esProtocolVersion, sizeof(g_SCProperties.esProtocolVersion), esProtocolVersion);
241 ESResult SetSSOList(const char *ssoList)
245 OICStrcpy(g_SCProperties.ssoList, sizeof(g_SCProperties.ssoList), ssoList);
251 void ReadUserdataCb(OCRepPayload* payload, char* resourceType, void** userdata)
253 OIC_LOG(INFO, SC_ENROLLEE_TAG, "ReadUserdataCb IN");
257 if(strstr(resourceType, OC_RSRVD_ES_RES_TYPE_WIFICONF))
259 int64_t channel = -1;
261 if (OCRepPayloadGetPropInt(payload, SC_RSRVD_ES_VENDOR_DISCOVERY_CHANNEL, &channel))
263 if(*userdata == NULL)
265 *userdata = (void*)OICMalloc(sizeof(SCWiFiConfProperties));
266 if( *userdata == NULL )
268 OIC_LOG(ERROR, SC_ENROLLEE_TAG, "OICMalloc for SCWiFiConfProperties is failed");
271 memset(*userdata, 0, sizeof(SCWiFiConfProperties));
273 OIC_LOG_V(INFO_PRIVATE, SC_ENROLLEE_TAG, "[User specific property] %s : [%" PRId64 "]",
274 SC_RSRVD_ES_VENDOR_DISCOVERY_CHANNEL, channel);
275 ((SCWiFiConfProperties*)(*userdata))->discoveryChannel = (int) channel;
276 g_SCProperties.discoveryChannel = channel;
278 if (OCRepPayloadGetPropString(payload, SC_RSRVD_ES_VENDOR_BSSID, &bssid))
280 if(*userdata == NULL)
282 *userdata = (void*) OICMalloc(sizeof(SCWiFiConfProperties));
283 if( *userdata == NULL )
285 OIC_LOG(ERROR, SC_ENROLLEE_TAG, "OICMalloc for SCWiFiConfProperties is failed");
288 memset(*userdata, 0, sizeof(SCWiFiConfProperties));
290 if (*userdata != NULL)
292 OIC_LOG_V(INFO_PRIVATE, SC_ENROLLEE_TAG, "[User specific property] %s : %s",
293 SC_RSRVD_ES_VENDOR_BSSID, bssid);
294 SCWiFiConfProperties* pWifiConfProp = (SCWiFiConfProperties*)(*userdata);
295 OICStrcpy(pWifiConfProp->bssid, sizeof(pWifiConfProp->bssid), bssid);
296 OICStrcpy(g_SCProperties.bssid, sizeof(g_SCProperties.bssid), bssid);
301 OCRepPayload **repPayload = NULL;
302 size_t dimensions[MAX_REP_ARRAY_DEPTH];
303 if(OCRepPayloadGetPropObjectArray(payload, SC_RSRVD_ES_VENDOR_CANDIDATEAPS, &repPayload, dimensions))
305 if(*userdata == NULL)
307 *userdata = (void*) OICMalloc(sizeof(SCWiFiConfProperties));
308 if( *userdata == NULL )
310 OIC_LOG(ERROR, SC_ENROLLEE_TAG, "OICMalloc for SCWiFiConfProperties is failed");
313 memset(*userdata, 0, sizeof(SCWiFiConfProperties));
315 //size_t dim = calcDimTotal(dimensions);
316 SCWiFiConfProperties* pWifiConfProp = (SCWiFiConfProperties*)(*userdata);
317 for (size_t i = 0; i < dimensions[0]; i++)
319 int64_t cd_channel = -1;
320 char *cd_bssid = NULL;
323 if (OCRepPayloadGetPropString(repPayload[i], SC_RSRVD_ES_VENDOR_SSID, &ssid))
325 OICStrcpy(pWifiConfProp->candidateAPInfo[i].ssid, sizeof(pWifiConfProp->candidateAPInfo[i].ssid), ssid);
326 OICStrcpy(g_SCProperties.candidateAPInfo[i].ssid, sizeof(g_SCProperties.candidateAPInfo[i].ssid), ssid);
327 OIC_LOG_V(INFO_PRIVATE, SC_ENROLLEE_TAG, "[User specific property] %s : %s",
328 SC_RSRVD_ES_VENDOR_SSID, ssid);
331 if (OCRepPayloadGetPropString(repPayload[i], SC_RSRVD_ES_VENDOR_PASSPHRASE, &pwd))
333 OICStrcpy(pWifiConfProp->candidateAPInfo[i].passphrase, sizeof(pWifiConfProp->candidateAPInfo[i].passphrase), pwd);
334 OICStrcpy(g_SCProperties.candidateAPInfo[i].passphrase, sizeof(g_SCProperties.candidateAPInfo[i].passphrase), pwd);
335 OIC_LOG_V(INFO_PRIVATE, SC_ENROLLEE_TAG, "[User specific property] %s : %s",
336 SC_RSRVD_ES_VENDOR_PASSPHRASE, ssid);
339 if (OCRepPayloadGetPropInt(repPayload[i], SC_RSRVD_ES_VENDOR_CANDIDATE_CHANNEL, &cd_channel))
341 pWifiConfProp->candidateAPInfo[i].channel = (int) cd_channel;
342 g_SCProperties.candidateAPInfo[i].channel = cd_channel;
343 OIC_LOG_V(INFO_PRIVATE, SC_ENROLLEE_TAG, "[User specific property] %s : %d",
344 SC_RSRVD_ES_VENDOR_CANDIDATE_CHANNEL, (int) cd_channel);
346 if (OCRepPayloadGetPropString(repPayload[i], SC_RSRVD_ES_VENDOR_BSSID, &cd_bssid))
348 OICStrcpy(pWifiConfProp->candidateAPInfo[i].bssid, sizeof(pWifiConfProp->candidateAPInfo[i].bssid), cd_bssid);
349 OICStrcpy(g_SCProperties.candidateAPInfo[i].bssid, sizeof(g_SCProperties.candidateAPInfo[i].bssid), cd_bssid);
350 OIC_LOG_V(INFO_PRIVATE, SC_ENROLLEE_TAG, "[User specific property] %s : %s",
351 SC_RSRVD_ES_VENDOR_BSSID, cd_bssid);
355 pWifiConfProp->numCandidateAP = (int)dimensions[0];
356 g_SCProperties.numCandidateAP = (int)dimensions[0];
359 else if(strstr(resourceType, OC_RSRVD_ES_RES_TYPE_DEVCONF))
361 if(*userdata == NULL)
363 *userdata = (void*)OICMalloc(sizeof(SCDevConfProperties));
364 if( *userdata == NULL )
366 OIC_LOG(ERROR, SC_ENROLLEE_TAG, "OICMalloc for SCDevConfProperties is failed");
369 memset(*userdata, 0, sizeof(SCDevConfProperties));
372 SCDevConfProperties *pDevConfProp = (SCDevConfProperties*)(*userdata);
374 char**locationList = NULL;
375 size_t dimensions[MAX_REP_ARRAY_DEPTH] = {0};
376 if(OCRepPayloadGetStringArray(payload, SC_RSRVD_ES_VENDOR_LOCATION, &locationList, dimensions))
378 for(size_t idx = 0; idx < dimensions[0]; idx++)
380 OICStrcpy(pDevConfProp->location[idx], strlen(locationList[idx])+1, locationList[idx]);
381 OICStrcpy(g_SCProperties.location[idx], strlen(locationList[idx])+1, locationList[idx]);
383 OIC_LOG_V(INFO_PRIVATE, SC_ENROLLEE_TAG, "[User specific property] %s : %s",
384 SC_RSRVD_ES_VENDOR_LOCATION, pDevConfProp->location[idx]);
387 ((SCDevConfProperties*)(*userdata))->numLocation = (int)dimensions[0];
388 g_SCProperties.numLocation = (int)dimensions[0];
391 ReadAccountData(payload,userdata);
393 char *regMobileDev = NULL;
394 if (OCRepPayloadGetPropString(payload, SC_RSRVD_ES_VENDOR_REGISTER_MOBILE_DEV, ®MobileDev))
396 OICStrcpy(pDevConfProp->regMobileDev, strlen(regMobileDev)+1, regMobileDev);
397 OICStrcpy(g_SCProperties.regMobileDev, strlen(regMobileDev)+1, regMobileDev);
398 OIC_LOG_V(INFO_PRIVATE, SC_ENROLLEE_TAG, "pDevConfProp.regMobileDev %s", g_SCProperties.regMobileDev);
401 char *country = NULL;
402 if (OCRepPayloadGetPropString(payload, SC_RSRVD_ES_VENDOR_COUNTRY, &country))
404 OICStrcpy(pDevConfProp->country, strlen(country)+1, country);
405 OICStrcpy(g_SCProperties.country, strlen(country)+1, country);
406 OIC_LOG_V(INFO_PRIVATE, SC_ENROLLEE_TAG, "pDevConfProp.country %s", g_SCProperties.country);
409 char *language = NULL;
410 if (OCRepPayloadGetPropString(payload, SC_RSRVD_ES_VENDOR_LANGUAGE, &language))
412 OICStrcpy(pDevConfProp->language, strlen(language)+1, language);
413 OICStrcpy(g_SCProperties.language, strlen(language)+1, language);
414 OIC_LOG_V(INFO_PRIVATE, SC_ENROLLEE_TAG, "pDevConfProp.language %s", g_SCProperties.language);
417 char *gpsLocation = NULL;
418 if (OCRepPayloadGetPropString(payload, SC_RSRVD_ES_VENDOR_GPSLOCATION, &gpsLocation))
420 OICStrcpy(pDevConfProp->gpsLocation, strlen(gpsLocation)+1, gpsLocation);
421 OICStrcpy(g_SCProperties.gpsLocation, strlen(gpsLocation)+1, gpsLocation);
422 OIC_LOG_V(INFO_PRIVATE, SC_ENROLLEE_TAG, "pDevConfProp.gpsLocation %s", g_SCProperties.gpsLocation);
425 char *utcDateTime = NULL;
426 if (OCRepPayloadGetPropString(payload, SC_RSRVD_ES_VENDOR_UTC_DATE_TIME, &utcDateTime))
428 OICStrcpy(pDevConfProp->utcDateTime, strlen(utcDateTime)+1, utcDateTime);
429 OICStrcpy(g_SCProperties.utcDateTime, strlen(utcDateTime)+1, utcDateTime);
430 OIC_LOG_V(INFO_PRIVATE, SC_ENROLLEE_TAG, "pDevConfProp.utcDateTime %s", g_SCProperties.utcDateTime);
433 char *regionalDateTime = NULL;
434 if (OCRepPayloadGetPropString(payload, SC_RSRVD_ES_VENDOR_REGIONAL_DATE_TIME, ®ionalDateTime))
436 OICStrcpy(pDevConfProp->regionalDateTime, strlen(regionalDateTime)+1, regionalDateTime);
437 OICStrcpy(g_SCProperties.regionalDateTime, strlen(regionalDateTime)+1, regionalDateTime);
438 OIC_LOG_V(INFO_PRIVATE, SC_ENROLLEE_TAG, "pDevConfProp.regionalDateTime %s", g_SCProperties.regionalDateTime);
441 char *ssoList = NULL;
442 if (OCRepPayloadGetPropString(payload, SC_RSRVD_ES_VENDOR_SSO_LIST, &ssoList))
444 OICStrcpy(pDevConfProp->ssoList, strlen(ssoList)+1, ssoList);
445 OICStrcpy(g_SCProperties.ssoList, strlen(ssoList)+1, ssoList);
446 OIC_LOG_V(INFO_PRIVATE, SC_ENROLLEE_TAG, "pDevConfProp.ssoList %s", g_SCProperties.ssoList);
449 else if(strstr(resourceType, OC_RSRVD_ES_RES_TYPE_COAPCLOUDCONF))
451 char* clientID = NULL;
452 if(OCRepPayloadGetPropString(payload, SC_RSRVD_ES_VENDOR_CLIENTID, &clientID))
454 if(*userdata == NULL)
456 *userdata = (void*)OICMalloc(sizeof(SCCoapCloudServerConfProperties));
457 if( *userdata == NULL )
459 OIC_LOG(ERROR, SC_ENROLLEE_TAG, "OICMalloc for SCCoapCloudServerConfProperties is failed");
462 memset(*userdata, 0, sizeof(SCCoapCloudServerConfProperties));
465 SCCoapCloudServerConfProperties *pCloudProp =
466 (SCCoapCloudServerConfProperties*)(*userdata);
468 OICStrcpy(pCloudProp->clientID, strlen(clientID)+1, clientID);
469 OICStrcpy(g_SCProperties.clientID, strlen(clientID)+1, clientID);
471 OIC_LOG_V(INFO_PRIVATE, SC_ENROLLEE_TAG, "[User specific property] %s : %s",
472 SC_RSRVD_ES_VENDOR_CLIENTID, pCloudProp->clientID);
475 //SC_RSRVD_ES_VENDOR_AAC
477 if (OCRepPayloadGetPropString(payload, SC_RSRVD_ES_VENDOR_AAC, &aac))
479 if(*userdata == NULL)
481 *userdata = (void*)OICMalloc(sizeof(SCCoapCloudServerConfProperties));
482 if( *userdata == NULL )
484 OIC_LOG(ERROR, SC_ENROLLEE_TAG, "OICMalloc for SCCoapCloudServerConfProperties is failed");
487 memset(*userdata, 0, sizeof(SCCoapCloudServerConfProperties));
490 if (*userdata != NULL)
492 SCCoapCloudServerConfProperties *pCloudProp =
493 (SCCoapCloudServerConfProperties*) (*userdata);
494 pCloudProp->aac[0] = '\0';
496 OICStrcpy(pCloudProp->aac, MAXLEN_STRING, aac);
497 OICStrcpy(g_SCProperties.aac, MAXLEN_STRING, aac);
500 OIC_LOG_V(INFO_PRIVATE, SC_ENROLLEE_TAG, "[User specific property] %s : %s",
501 SC_RSRVD_ES_VENDOR_AAC, pCloudProp->aac);
505 //SC_RSRVD_ES_VENDOR_UID
507 if (OCRepPayloadGetPropString(payload, SC_RSRVD_ES_VENDOR_UID, &uid))
509 if(*userdata == NULL)
511 *userdata = (void*)OICMalloc(sizeof(SCCoapCloudServerConfProperties));
512 if( *userdata == NULL )
514 OIC_LOG(ERROR, SC_ENROLLEE_TAG, "OICMalloc for SCCoapCloudServerConfProperties is failed");
517 memset(*userdata, 0, sizeof(SCCoapCloudServerConfProperties));
520 if (*userdata != NULL)
522 SCCoapCloudServerConfProperties *pCloudProp =
523 (SCCoapCloudServerConfProperties*) (*userdata);
524 pCloudProp->uid[0] = '\0';
526 OICStrcpy(pCloudProp->uid, MAXLEN_STRING, uid);
527 OICStrcpy(g_SCProperties.uid, MAXLEN_STRING, uid);
530 OIC_LOG_V(INFO_PRIVATE, SC_ENROLLEE_TAG, "[User specific property] %s : %s",
531 SC_RSRVD_ES_VENDOR_UID, pCloudProp->uid);
535 //SC_RSRVD_ES_VENDOR_REFRESH_TOKEN
536 char *refreshToken = NULL;
537 if (OCRepPayloadGetPropString(payload, SC_RSRVD_ES_VENDOR_REFRESH_TOKEN, &refreshToken))
539 if(*userdata == NULL)
541 *userdata = (void*)OICMalloc(sizeof(SCCoapCloudServerConfProperties));
542 if( *userdata == NULL )
544 OIC_LOG(ERROR, SC_ENROLLEE_TAG, "OICMalloc for SCCoapCloudServerConfProperties is failed");
547 memset(*userdata, 0, sizeof(SCCoapCloudServerConfProperties));
550 if (*userdata != NULL)
552 SCCoapCloudServerConfProperties *pCloudProp =
553 (SCCoapCloudServerConfProperties*) (*userdata);
554 pCloudProp->refreshToken[0] = '\0';
556 OICStrcpy(pCloudProp->refreshToken, MAXLEN_STRING, refreshToken);
557 OICStrcpy(g_SCProperties.refreshToken, MAXLEN_STRING, refreshToken);
558 OICFree(refreshToken);
560 OIC_LOG_V(INFO_PRIVATE, SC_ENROLLEE_TAG, "[User specific property] %s : %s",
561 SC_RSRVD_ES_VENDOR_REFRESH_TOKEN, pCloudProp->refreshToken);
565 ReadTnCdata(payload,userdata);
569 OIC_LOG(INFO, SC_ENROLLEE_TAG, "ReadUserdataCb OUT");
572 void WriteUserdataCb(OCRepPayload* payload, char* resourceType)
574 OIC_LOG(INFO, SC_ENROLLEE_TAG, "WriteUserdataCb IN");
578 if (strstr(resourceType, OC_RSRVD_ES_RES_TYPE_EASYSETUP))
580 OCRepPayloadSetPropInt(payload, SC_RSRVD_ES_VENDOR_NETCONNECTION_STATE, (int) g_SCProperties.netConnectionState);
583 if (strstr(resourceType, OC_RSRVD_ES_RES_TYPE_WIFICONF))
585 OCRepPayload **repPayload = OICCalloc(g_SCProperties.numCandidateAP, sizeof(OCRepPayload *));
587 for (size_t i = 0; i < (size_t)g_SCProperties.numCandidateAP; i++)
589 repPayload[i] = OCRepPayloadCreate();
592 OCRepPayloadDestroy(payload);
593 for (size_t k = 0; k < i; k++)
595 OCRepPayloadDestroy(repPayload[k]);
597 OCRepPayloadDestroy(*repPayload);
600 OCRepPayloadSetPropString(repPayload[i], SC_RSRVD_ES_VENDOR_SSID, g_SCProperties.candidateAPInfo[i].ssid);
601 OCRepPayloadSetPropString(repPayload[i], SC_RSRVD_ES_VENDOR_PASSPHRASE, g_SCProperties.candidateAPInfo[i].passphrase);
602 OCRepPayloadSetPropString(repPayload[i], SC_RSRVD_ES_VENDOR_BSSID, g_SCProperties.candidateAPInfo[i].bssid);
603 OCRepPayloadSetPropInt(repPayload[i], SC_RSRVD_ES_VENDOR_CANDIDATE_CHANNEL, g_SCProperties.candidateAPInfo[i].channel);
605 size_t dimensions[MAX_REP_ARRAY_DEPTH] = {g_SCProperties.numCandidateAP, 0, 0};
606 OCRepPayloadSetPropObjectArray(payload,SC_RSRVD_ES_VENDOR_CANDIDATEAPS, (const struct OCRepPayload **)repPayload, dimensions);
608 if(strstr(resourceType, OC_RSRVD_ES_RES_TYPE_DEVCONF))
611 OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_DEVICE_TYPE, g_SCProperties.deviceType);
612 OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_DEVICE_SUBTYPE, g_SCProperties.deviceSubType);
613 OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_REGISTER_SET_DEV, g_SCProperties.regSetDev);
614 OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_REGISTER_MOBILE_DEV, g_SCProperties.regMobileDev);
615 OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_NETWORK_PROV_INFO, g_SCProperties.nwProvInfo);
616 OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_SSO_LIST, g_SCProperties.ssoList);
617 OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_PNP_PIN, g_SCProperties.pnpPin);
618 OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_MODEL_NUMBER, g_SCProperties.modelNumber);
619 OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_COUNTRY, g_SCProperties.country);
620 OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_LANGUAGE, g_SCProperties.language);
621 OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_GPSLOCATION, g_SCProperties.gpsLocation);
622 OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_UTC_DATE_TIME, g_SCProperties.utcDateTime);
623 OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_REGIONAL_DATE_TIME, g_SCProperties.regionalDateTime);
624 OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_ES_PROTOCOL_VERSION, g_SCProperties.esProtocolVersion);
626 if(g_SCProperties.deviceType != NULL)
628 OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_DEVICE_TYPE, g_SCProperties.deviceType);
630 if(g_SCProperties.deviceSubType != NULL)
632 OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_DEVICE_SUBTYPE, g_SCProperties.deviceSubType);
634 if(g_SCProperties.regSetDev != NULL)
636 OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_REGISTER_SET_DEV, g_SCProperties.regSetDev);
638 if(g_SCProperties.regMobileDev != NULL)
640 OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_REGISTER_MOBILE_DEV, g_SCProperties.regMobileDev);
642 if(g_SCProperties.nwProvInfo!= NULL)
644 OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_NETWORK_PROV_INFO, g_SCProperties.nwProvInfo);
646 if(g_SCProperties.ssoList!= NULL)
648 OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_SSO_LIST, g_SCProperties.ssoList);
650 if(g_SCProperties.pnpPin != NULL)
652 OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_PNP_PIN, g_SCProperties.pnpPin);
654 if(g_SCProperties.modelNumber != NULL)
656 OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_MODEL_NUMBER, g_SCProperties.modelNumber);
658 if(g_SCProperties.country != NULL)
660 OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_COUNTRY, g_SCProperties.country);
662 if(g_SCProperties.language != NULL)
664 OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_LANGUAGE, g_SCProperties.language);
666 if(g_SCProperties.gpsLocation != NULL)
668 OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_GPSLOCATION, g_SCProperties.gpsLocation);
670 if(g_SCProperties.esProtocolVersion != NULL)
672 OCRepPayloadSetPropString(payload, SC_RSRVD_ES_VENDOR_ES_PROTOCOL_VERSION, g_SCProperties.esProtocolVersion);
678 WriteTnCdata(payload, resourceType);
679 WriteWifiData(payload, resourceType);
681 OIC_LOG(INFO, SC_ENROLLEE_TAG, "WriteUserdataCb OUT");