From d478f2f4fa0272930122ceaaf7a26f39ec66d9d0 Mon Sep 17 00:00:00 2001 From: "kush.agrawal@samsung.com" Date: Wed, 3 Oct 2018 13:37:00 +0530 Subject: [PATCH] Update sc_enrollee.c cherry picked from commit 352502d7d0ed803fa124e3f1502047be066ab52f Change-Id: I8cb30184e34f086d965ad0a39767fcdeaf23d438 Signed-off-by: agrkush Signed-off-by: Amit KS --- service/easy-setup/enrollee/inc/samsung/sc_easysetup.h | 5 +++-- service/easy-setup/enrollee/src/samsung/sc_easysetup.c | 4 ++-- service/easy-setup/mediator/richsdk/inc/ESSCCommon.h | 11 ++++++----- .../easy-setup/sampleapp/enrollee/linux-samsung/sc_enrollee.c | 4 +--- .../mediator/linux-samsung/richsdk_sample/mediator_sc.cpp | 4 ++-- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/service/easy-setup/enrollee/inc/samsung/sc_easysetup.h b/service/easy-setup/enrollee/inc/samsung/sc_easysetup.h index 6703071..fc4a42a 100644 --- a/service/easy-setup/enrollee/inc/samsung/sc_easysetup.h +++ b/service/easy-setup/enrollee/inc/samsung/sc_easysetup.h @@ -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); diff --git a/service/easy-setup/enrollee/src/samsung/sc_easysetup.c b/service/easy-setup/enrollee/src/samsung/sc_easysetup.c index 8981ea4..ac883f0 100644 --- a/service/easy-setup/enrollee/src/samsung/sc_easysetup.c +++ b/service/easy-setup/enrollee/src/samsung/sc_easysetup.c @@ -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 *)); diff --git a/service/easy-setup/mediator/richsdk/inc/ESSCCommon.h b/service/easy-setup/mediator/richsdk/inc/ESSCCommon.h index 229a3ca..68e4dba 100644 --- a/service/easy-setup/mediator/richsdk/inc/ESSCCommon.h +++ b/service/easy-setup/mediator/richsdk/inc/ESSCCommon.h @@ -402,7 +402,7 @@ namespace OIC */ std::vector getCandidateAPList() { - if(m_rep.hasAttribute(SC_RSRVD_ES_VENDOR_CANDIDATEAPS)) + if (m_rep.hasAttribute(SC_RSRVD_ES_VENDOR_CANDIDATEAPS)) { std::vector candidateInfo= m_rep.getValue>(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(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(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(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(SC_RSRVD_ES_VENDOR_BSSID); } @@ -740,6 +740,7 @@ namespace OIC } } } + return {}; } /** diff --git a/service/easy-setup/sampleapp/enrollee/linux-samsung/sc_enrollee.c b/service/easy-setup/sampleapp/enrollee/linux-samsung/sc_enrollee.c index 41ec0bd..0713cc9 100644 --- a/service/easy-setup/sampleapp/enrollee/linux-samsung/sc_enrollee.c +++ b/service/easy-setup/sampleapp/enrollee/linux-samsung/sc_enrollee.c @@ -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() diff --git a/service/easy-setup/sampleapp/mediator/linux-samsung/richsdk_sample/mediator_sc.cpp b/service/easy-setup/sampleapp/mediator/linux-samsung/richsdk_sample/mediator_sc.cpp index bf03576..2cffbf6 100644 --- a/service/easy-setup/sampleapp/mediator/linux-samsung/richsdk_sample/mediator_sc.cpp +++ b/service/easy-setup/sampleapp/mediator/linux-samsung/richsdk_sample/mediator_sc.cpp @@ -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 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; -- 2.7.4