#define SC_RSRVD_ES_VENDOR_UTC_DATE_TIME "x.com.samsung.datetime"
#define SC_RSRVD_ES_VENDOR_REGIONAL_DATE_TIME "x.com.samsung.regionaldatetime"
#define SC_RSRVD_ES_VENDOR_ES_PROTOCOL_VERSION "x.com.samsung.espv"
-
+#define SC_RSRVD_ES_VENDOR_CANDIDATEAPS "x.com.samsung.candidateaps"
+#define SC_RSRVD_ES_VENDOR_SSID "x.com.samsung.ssid"
+#define SC_RSRVD_ES_VENDOR_PASSPHRASE "x.com.samsung.passphrase"
+#define SC_RSRVD_ES_VENDOR_CANDIDATE_CHANNEL "x.com.samsung.channel"
#define WIFI_DISCOVERY_CHANNEL_INIT -1
NET_STATE_NOT_CONNECTED /**< Not connected, at all **/
} NETCONNECTION_STATE;
+typedef struct SCCandidateAPInfo
+{
+ char ssid[MAXLEN_STRING];
+ char passphrase[MAXLEN_STRING];
+ int channel;
+ char bssid[MAXLEN_STRING];
+} SCCandidateAPInfo;
+
typedef struct SCWiFiConfProperties
{
int discoveryChannel; /**< Wi-Fi AP Channel used for fast discovery **/
char bssid[MAXLEN_STRING]; /**< Wi-Fi bssid information. **/
+ int numCandidateAP;
+ SCCandidateAPInfo candidateAPInfo[5];
} SCWiFiConfProperties;
typedef struct SCTncInfo
char utcDateTime[MAXLEN_DATE_TIME]; /**< UTC date time **/
char regionalDateTime[MAXLEN_DATE_TIME]; /**< Regional date time **/
char esProtocolVersion[MAXLEN_STRING]; /**< Samsung Easy Setup Protocol Version **/
+ int numCandidateAP;
+ SCCandidateAPInfo candidateAPInfo[5];
} SCProperties;
void ReadUserdataCb(OCRepPayload* payload, char* resourceType, void** userdata);
OICFree(bssid);
}
}
+
+ OCRepPayload **repPayload = NULL;
+ size_t dimensions[MAX_REP_ARRAY_DEPTH];
+ if(OCRepPayloadGetPropObjectArray(payload, SC_RSRVD_ES_VENDOR_CANDIDATEAPS, &repPayload, dimensions))
+ {
+ if(*userdata == NULL)
+ {
+ *userdata = (void*) OICMalloc(sizeof(SCWiFiConfProperties));
+ if( *userdata == NULL )
+ {
+ OIC_LOG(ERROR, SC_ENROLLEE_TAG, "OICMalloc for SCWiFiConfProperties is failed");
+ return ;
+ }
+ memset(*userdata, 0, sizeof(SCWiFiConfProperties));
+ }
+ //size_t dim = calcDimTotal(dimensions);
+ SCWiFiConfProperties* pWifiConfProp = (SCWiFiConfProperties*)(*userdata);
+ for (size_t i = 0; i < dimensions[0]; i++)
+ {
+ int64_t cd_channel = -1;
+ char *cd_bssid = NULL;
+ char *ssid = NULL;
+ char *pwd = NULL;
+ if (OCRepPayloadGetPropString(repPayload[i], SC_RSRVD_ES_VENDOR_SSID, &ssid))
+ {
+ OICStrcpy(pWifiConfProp->candidateAPInfo[i].ssid, sizeof(pWifiConfProp->candidateAPInfo[i].ssid), ssid);
+ OICStrcpy(g_SCProperties.candidateAPInfo[i].ssid, sizeof(g_SCProperties.candidateAPInfo[i].ssid), ssid);
+ OIC_LOG_V(INFO_PRIVATE, SC_ENROLLEE_TAG, "[User specific property] %s : %s",
+ SC_RSRVD_ES_VENDOR_SSID, ssid);
+ OICFree(ssid);
+ }
+ if (OCRepPayloadGetPropString(repPayload[i], SC_RSRVD_ES_VENDOR_PASSPHRASE, &pwd))
+ {
+ OICStrcpy(pWifiConfProp->candidateAPInfo[i].passphrase, sizeof(pWifiConfProp->candidateAPInfo[i].passphrase), pwd);
+ OICStrcpy(g_SCProperties.candidateAPInfo[i].passphrase, sizeof(g_SCProperties.candidateAPInfo[i].passphrase), pwd);
+ OIC_LOG_V(INFO_PRIVATE, SC_ENROLLEE_TAG, "[User specific property] %s : %s",
+ SC_RSRVD_ES_VENDOR_PASSPHRASE, ssid);
+ OICFree(pwd);
+ }
+ if (OCRepPayloadGetPropInt(repPayload[i], SC_RSRVD_ES_VENDOR_CANDIDATE_CHANNEL, &cd_channel))
+ {
+ pWifiConfProp->candidateAPInfo[i].channel = (int) cd_channel;
+ g_SCProperties.candidateAPInfo[i].channel = cd_channel;
+ OIC_LOG_V(INFO_PRIVATE, SC_ENROLLEE_TAG, "[User specific property] %s : %d",
+ SC_RSRVD_ES_VENDOR_CANDIDATE_CHANNEL, cd_channel);
+ }
+ if (OCRepPayloadGetPropString(repPayload[i], SC_RSRVD_ES_VENDOR_BSSID, &cd_bssid))
+ {
+ OICStrcpy(pWifiConfProp->candidateAPInfo[i].bssid, sizeof(pWifiConfProp->candidateAPInfo[i].bssid), cd_bssid);
+ OICStrcpy(g_SCProperties.candidateAPInfo[i].bssid, sizeof(g_SCProperties.candidateAPInfo[i].bssid), cd_bssid);
+ OIC_LOG_V(INFO_PRIVATE, SC_ENROLLEE_TAG, "[User specific property] %s : %s",
+ SC_RSRVD_ES_VENDOR_BSSID, cd_bssid);
+ OICFree(bssid);
+ }
+ }
+ pWifiConfProp->numCandidateAP = (int)dimensions[0];
+ g_SCProperties.numCandidateAP = (int)dimensions[0];
+ }
}
else if(strstr(resourceType, OC_RSRVD_ES_RES_TYPE_DEVCONF))
{
OCRepPayloadSetPropInt(payload, SC_RSRVD_ES_VENDOR_NETCONNECTION_STATE, (int) g_SCProperties.netConnectionState);
}
+ if(strstr(resourceType, OC_RSRVD_ES_RES_TYPE_WIFICONF))
+ {
+ OCRepPayload **repPayload = OICCalloc(g_SCProperties.numCandidateAP, sizeof(OCRepPayload *));
+
+ for (size_t i = 0; i < (size_t)g_SCProperties.numCandidateAP; i++)
+ {
+ repPayload[i] = OCRepPayloadCreate();
+ if (!repPayload[i])
+ {
+ OCRepPayloadDestroy(payload);
+ for (size_t k = 0; k < i; k++)
+ {
+ OCRepPayloadDestroy(repPayload[k]);
+ }
+ OCRepPayloadDestroy(*repPayload);
+ break;
+ }
+ OCRepPayloadSetPropString(repPayload[i], SC_RSRVD_ES_VENDOR_SSID, g_SCProperties.candidateAPInfo[i].ssid);
+ OCRepPayloadSetPropString(repPayload[i], SC_RSRVD_ES_VENDOR_PASSPHRASE, g_SCProperties.candidateAPInfo[i].passphrase);
+ OCRepPayloadSetPropString(repPayload[i], SC_RSRVD_ES_VENDOR_BSSID, g_SCProperties.candidateAPInfo[i].bssid);
+ OCRepPayloadSetPropInt(repPayload[i], SC_RSRVD_ES_VENDOR_CANDIDATE_CHANNEL, g_SCProperties.candidateAPInfo[i].channel);
+ }
+ size_t dimensions[MAX_REP_ARRAY_DEPTH] = {g_SCProperties.numCandidateAP, 0, 0};
+ OCRepPayloadSetPropObjectArray(payload,SC_RSRVD_ES_VENDOR_CANDIDATEAPS, (const struct OCRepPayload **)repPayload, dimensions);
+ }
if(strstr(resourceType, OC_RSRVD_ES_RES_TYPE_DEVCONF))
{
#ifndef __TIZENRT__
#define SC_RSRVD_ES_VENDOR_COUNTRY "x.com.samsung.country"
#define SC_RSRVD_ES_VENDOR_GPSLOCATION "x.com.samsung.gpslocation"
#define SC_RSRVD_ES_VENDOR_ES_PROTOCOL_VERSION "x.com.samsung.espv"
+#define SC_RSRVD_ES_VENDOR_CANDIDATEAPS "x.com.samsung.candidateaps"
+#define SC_RSRVD_ES_VENDOR_SSID "x.com.samsung.ssid"
+#define SC_RSRVD_ES_VENDOR_PASSPHRASE "x.com.samsung.passphrase"
+#define SC_RSRVD_ES_VENDOR_CANDIDATE_CHANNEL "x.com.samsung.channel"
+
+#define MAXLEN_STRING 1000
namespace OIC
TC_STATUS_TIMEOUT_TO_AGREE
} TC_STATUS;
+ typedef struct SCCandidateAPInfo
+ {
+ std::string ssid;
+ std::string passphrase;
+ int channel;
+ std::string bssid;
+ } SCCandidateAPInfo;
+
/**
* @brief Properties of provisioning resource. It includes a provisioning status and last
* error code.
}
return {};
}
+
+ /**
+ * Set Candidate AP information which is stored.
+ *
+ * @param clientID - Client service ID
+ */
+ void setCandidateAPList(SCCandidateAPInfo *candidateInfo,int numCandidateAP)
+ {
+ std::vector<OC::OCRepresentation> candidateAPList;
+ for (int i=0;i<numCandidateAP;i++)
+ {
+ OCRepresentation candidateListInfo;
+ candidateListInfo.setValue(SC_RSRVD_ES_VENDOR_BSSID, candidateInfo[i].bssid);
+ candidateListInfo.setValue(SC_RSRVD_ES_VENDOR_CANDIDATE_CHANNEL, candidateInfo[i].channel);
+ candidateListInfo.setValue(SC_RSRVD_ES_VENDOR_PASSPHRASE, candidateInfo[i].passphrase);
+ candidateListInfo.setValue(SC_RSRVD_ES_VENDOR_SSID, candidateInfo[i].ssid);
+ candidateAPList.push_back(candidateListInfo);
+ }
+ m_rep.setValue(SC_RSRVD_ES_VENDOR_CANDIDATEAPS, candidateAPList);
+ }
+
+ /**
+ * Get Candidate AP information which is registered in device.
+ *
+ * @return SCCandidateAPInfo list.
+ */
+ std::vector<SCCandidateAPInfo> getCandidateAPList()
+ {
+ if(m_rep.hasAttribute(SC_RSRVD_ES_VENDOR_CANDIDATEAPS))
+ {
+ std::vector<OC::OCRepresentation> candidateInfo=
+ m_rep.getValue<std::vector<OC::OCRepresentation>>(SC_RSRVD_ES_VENDOR_CANDIDATEAPS);
+ std::vector<SCCandidateAPInfo> postcandidateInfo;
+ for(std::vector<OC::OCRepresentation>::iterator it = candidateInfo.begin();
+ it != candidateInfo.end(); ++it)
+ {
+ OC::OCRepresentation rep = *it;
+ SCCandidateAPInfo candidateInfotemp;
+ if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_SSID))
+ {
+ candidateInfotemp.ssid=rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_SSID);
+ }
+ if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_PASSPHRASE))
+ {
+ candidateInfotemp.passphrase=rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_PASSPHRASE);
+ }
+ if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_CANDIDATE_CHANNEL))
+ {
+ candidateInfotemp.channel=rep.getValue<int>(SC_RSRVD_ES_VENDOR_CANDIDATE_CHANNEL);
+
+ }
+ if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_BSSID))
+ {
+ candidateInfotemp.bssid=rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_BSSID);
+ }
+ postcandidateInfo.push_back(candidateInfotemp);
+ }
+ return postcandidateInfo;
+ }
+ return {};
+ }
};
class SCCloudProp : public CloudProp
}
/**
+ * Get Candidate AP information which is registered in device.
+ *
+ * @return SCCandidateAPInfo list.
+ */
+ std::vector<SCCandidateAPInfo> getCandidateAPList() const
+ {
+ std::vector<OCRepresentation> children = m_EasySetupRep.getChildren();
+ for(auto child = children.begin(); child != children.end(); ++child)
+ {
+ if(child->getUri().find(OC_RSRVD_ES_URI_WIFICONF) != std::string::npos)
+ {
+ OCRepresentation rep;
+ if(child->hasAttribute(OC_RSRVD_REPRESENTATION))
+ {
+ rep = child->getValue<OCRepresentation>(OC_RSRVD_REPRESENTATION);
+ }
+
+ if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_CANDIDATEAPS))
+ {
+ std::vector<OC::OCRepresentation> candidateInfo=rep.getValue<std::vector<OC::OCRepresentation>>(SC_RSRVD_ES_VENDOR_CANDIDATEAPS);
+ std::vector<SCCandidateAPInfo> postcandidateInfo;
+ for(std::vector<OC::OCRepresentation>::iterator it = candidateInfo.begin();
+ it != candidateInfo.end(); ++it)
+ {
+ OC::OCRepresentation rep = *it;
+ SCCandidateAPInfo candidateInfotemp;
+ if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_SSID))
+ {
+ candidateInfotemp.ssid=rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_SSID);
+ }
+ if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_PASSPHRASE))
+ {
+ candidateInfotemp.passphrase=rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_PASSPHRASE);
+ }
+ if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_CANDIDATE_CHANNEL))
+ {
+ candidateInfotemp.channel=rep.getValue<int>(SC_RSRVD_ES_VENDOR_CANDIDATE_CHANNEL);
+
+ }
+ if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_BSSID))
+ {
+ candidateInfotemp.bssid=rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_BSSID);
+ }
+ postcandidateInfo.push_back(candidateInfotemp);
+ }
+ return postcandidateInfo;
+ }
+ }
+ }
+ }
+
+ /**
* Get network provisioning information for the device.
* Mediator can use this information to enquire & validate registration status with corresponding Network Vendor.
* The format is in JSON. The key indicates the meaning of value and the value is a
printf("S: Enabled Security\n");
printf("I: Init & Start EasySetup\n");
printf("D: Set DeviceInfo\n");
+ printf("W: Set WiFiInfo\n");
printf("T: Terminate\n");
printf("Q: Quit\n");
printf("============\n");
{
SCWiFiConfProperties *data = eventData->userdata;
printf("[SC] DiscoveryChannel : %d\n", data->discoveryChannel);
+ printf("[SC] Number of candidate AP : %d\n", data->numCandidateAP);
+ for (int i = 0; i< data->numCandidateAP ; i++)
+ {
+ printf("[SC] Candidate Bssid : %s\n", data->candidateAPInfo[i].bssid);
+ printf("[SC] Candidate Channel : %d\n", data->candidateAPInfo[i].channel);
+ printf("[SC] Candidate Passphrase : %s\n", data->candidateAPInfo[i].passphrase);
+ printf("[SC] Candidate SSID : %s\n", data->candidateAPInfo[i].ssid);
+ }
+
}
printf("WiFiProvCbInApp OUT\n");
printf("SetDeviceInfo OUT\n");
}
+void SetWiFiInfo()
+{
+
+ printf("SetWiFiInfo IN\n");
+ strncpy(g_SCProperties.candidateAPInfo[0].ssid, "x_5GHz", MAXLEN_STRING);
+ strncpy(g_SCProperties.candidateAPInfo[0].passphrase, "12345678",MAXLEN_STRING);
+ g_SCProperties.candidateAPInfo[0].channel = 149;
+ strncpy(g_SCProperties.candidateAPInfo[0].bssid, "aa:bb:cc:dd:ee:01", MAXLEN_STRING);
+ strncpy(g_SCProperties.candidateAPInfo[1].ssid, "5GHz", MAXLEN_STRING);
+ strncpy(g_SCProperties.candidateAPInfo[1].passphrase, "12345678",MAXLEN_STRING);
+ g_SCProperties.candidateAPInfo[1].channel = 161;
+ strncpy(g_SCProperties.candidateAPInfo[1].bssid, "aa:bb:cc:dd:ee:02", MAXLEN_STRING);
+ g_SCProperties.numCandidateAP=2;
+
+ if(SetSCProperties(&g_SCProperties) == ES_ERROR)
+ printf("SetSCProperties Error\n");
+ printf("SetWiFiInfo OUT\n");
+
+}
+
void StopEasySetup()
{
printf("StopEasySetup IN\n");
SetDeviceInfo();
PrintMenu();
break;
+ case 'W': // Set Device Info
+ case 'w':
+ SetWiFiInfo();
+ PrintMenu();
+ break;
case 'T': // stop easy setup
case 't':
StopEasySetup();
cout << "\tUTC time: " << conf.getUTCDatetime() << endl;
cout << "\tRegional time: " << conf.getRegionalDatetime() << endl;
cout << "\tEasy Setup Protocol Version: " << conf.getESProtocolVersion() << endl;
+ std::vector<SCCandidateAPInfo> candidateInfo = conf.getCandidateAPList();
+ int size = candidateInfo.size();
+ for(int i=0;i< size;i++)
+ {
+ cout << "[SC] Candidate Bssid :" << candidateInfo[i].bssid << endl;
+ cout << "[SC] Candidate Channel :" << candidateInfo[i].channel << endl;
+ cout << "[SC] Candidate Passphrase :" << candidateInfo[i].passphrase << endl;
+ cout << "[SC] Candidate SSID :" << candidateInfo[i].ssid << endl;
+ }
cout << "===========================================" << endl;
}
scDevProp.setRegisterMobileDevice("{\"wm\":\"00:11:22:33:44:55\",\"pm\":\"00:11:22:33:44:55\",\"bm\":\"00:11:22:33:44:55\",\"dt\":\"0\",\"it\":\"0\"}");
scDevProp.setSSOList("[{\"AvailableCount\" : \"1\", \"RegisteredCount\" : \"3\", \"AccountList\" : {\"aaa@samsung.com\", \"bbb@samsung.com\",\"ccc@samsung.com\"} }] ");
+ SCCandidateAPInfo candidateAPInfo[2];
+ candidateAPInfo[0].ssid = "x_5GHz";
+ candidateAPInfo[0].passphrase= "12345678";
+ candidateAPInfo[0].channel = 149;
+ candidateAPInfo[0].bssid = "aa:bb:cc:dd:ee:01";
+ candidateAPInfo[1].ssid = "y_5GHz";
+ candidateAPInfo[1].passphrase= "12345678";
+ candidateAPInfo[1].channel = 161;
+ candidateAPInfo[1].bssid = "aa:bb:cc:dd:ee:02";
+ scDevProp.setCandidateAPList(candidateAPInfo,2);
// Set UTC and regional date
time_t t = time(NULL);