Update sc_enrollee.c 86/191486/1
authorkush.agrawal@samsung.com <kush.agrawal@samsung.com>
Wed, 3 Oct 2018 08:07:00 +0000 (13:37 +0530)
committerAmit KS <amit.s12@samsung.com>
Wed, 17 Oct 2018 11:36:43 +0000 (17:06 +0530)
cherry picked from commit 352502d7d0ed803fa124e3f1502047be066ab52f

Change-Id: I8cb30184e34f086d965ad0a39767fcdeaf23d438
Signed-off-by: agrkush <kush.agrawal@samsung.com>
Signed-off-by: Amit KS <amit.s12@samsung.com>
service/easy-setup/enrollee/inc/samsung/sc_easysetup.h
service/easy-setup/enrollee/src/samsung/sc_easysetup.c
service/easy-setup/mediator/richsdk/inc/ESSCCommon.h
service/easy-setup/sampleapp/enrollee/linux-samsung/sc_enrollee.c
service/easy-setup/sampleapp/mediator/linux-samsung/richsdk_sample/mediator_sc.cpp

index 6703071..fc4a42a 100644 (file)
@@ -27,6 +27,7 @@
 #define MAXLEN_STRING 1000
 #define MAXNUM_LOCATION 20
 #define MAXLEN_DATE_TIME 33
+#define MAXNUM_CANDIDATE_AP 20
 
 #define SC_RSRVD_ES_VENDOR_NETCONNECTION_STATE  "x.com.samsung.ncs"
 #define SC_RSRVD_ES_VENDOR_DISCOVERY_CHANNEL    "x.com.samsung.chn"
@@ -86,7 +87,7 @@ 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];
+    SCCandidateAPInfo candidateAPInfo[MAXNUM_CANDIDATE_AP];
 } SCWiFiConfProperties;
 
 typedef struct SCTncInfo
@@ -150,7 +151,7 @@ typedef struct SCProperties
     char regionalDateTime[MAXLEN_DATE_TIME];        /**< Regional date time **/
     char esProtocolVersion[MAXLEN_STRING];          /**< Samsung Easy Setup Protocol Version **/
     int numCandidateAP;
-    SCCandidateAPInfo candidateAPInfo[5];
+    SCCandidateAPInfo candidateAPInfo[MAXNUM_CANDIDATE_AP];
 } SCProperties;
 
 void ReadUserdataCb(OCRepPayload* payload, char* resourceType, void** userdata);
index 8981ea4..ac883f0 100755 (executable)
@@ -565,12 +565,12 @@ void WriteUserdataCb(OCRepPayload* payload, char* resourceType)
 
     if(payload != NULL)
     {
-        if(strstr(resourceType, OC_RSRVD_ES_RES_TYPE_EASYSETUP))
+        if (strstr(resourceType, OC_RSRVD_ES_RES_TYPE_EASYSETUP))
         {
             OCRepPayloadSetPropInt(payload, SC_RSRVD_ES_VENDOR_NETCONNECTION_STATE, (int) g_SCProperties.netConnectionState);
         }
 
-        if(strstr(resourceType, OC_RSRVD_ES_RES_TYPE_WIFICONF))
+        if (strstr(resourceType, OC_RSRVD_ES_RES_TYPE_WIFICONF))
         {
            OCRepPayload **repPayload = OICCalloc(g_SCProperties.numCandidateAP, sizeof(OCRepPayload *));
 
index 229a3ca..68e4dba 100644 (file)
@@ -402,7 +402,7 @@ namespace OIC
              */
             std::vector<SCCandidateAPInfo> getCandidateAPList()
             {
-                if(m_rep.hasAttribute(SC_RSRVD_ES_VENDOR_CANDIDATEAPS))
+                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);
@@ -412,20 +412,20 @@ namespace OIC
                     {
                         OC::OCRepresentation rep = *it;
                         SCCandidateAPInfo candidateInfotemp;
-                        if(rep.hasAttribute(SC_RSRVD_ES_VENDOR_SSID))
+                        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))
+                        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))
+                        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))
+                        if (rep.hasAttribute(SC_RSRVD_ES_VENDOR_BSSID))
                         {
                             candidateInfotemp.bssid=rep.getValue<std::string>(SC_RSRVD_ES_VENDOR_BSSID);
                         }
@@ -740,6 +740,7 @@ namespace OIC
                         }
                     }
                 }
+                return {};
             }
 
             /**
index 41ec0bd..0713cc9 100644 (file)
@@ -81,7 +81,7 @@ void WiFiProvCbInApp(ESWiFiConfData *eventData)
         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++)
+        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);
@@ -230,7 +230,6 @@ void SetDeviceInfo()
 
 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);
@@ -245,7 +244,6 @@ void SetWiFiInfo()
     if(SetSCProperties(&g_SCProperties) == ES_ERROR)
         printf("SetSCProperties Error\n");
     printf("SetWiFiInfo OUT\n");
-
 }
 
 void StopEasySetup()
index bf03576..2cffbf6 100644 (file)
@@ -93,8 +93,8 @@ void printConfiguration(const SCEnrolleeConf& conf)
     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++)
+    size_t  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;