From: Ankur Bansal Date: Sun, 20 Aug 2017 09:28:59 +0000 (+0530) Subject: [IOT-2628][EasySetup]Add new prop. swat,swet X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5617a85df2ed9feecf501d6f946dff621f15d532;p=platform%2Fupstream%2Fiotivity.git [IOT-2628][EasySetup]Add new prop. swat,swet Add new mandatory properties to oic.r.wificonf - swat: Enrollee's supported Wi-Fi Authentication Types - swet: Enrollee's supported Wi-Fi Encryption Types - Update Enrollee sample apps (Linux and Tizen). Note: This impacts Easy Setup Enrollee API "ESSetDeviceProperty". Change-Id: Ic765671dfbe3a4e1c8a857ef6ae1d3dcb9ba783e Signed-off-by: Ankur Bansal --- diff --git a/service/easy-setup/enrollee/inc/ESEnrolleeCommon.h b/service/easy-setup/enrollee/inc/ESEnrolleeCommon.h index 60356fa..d33dff5 100644 --- a/service/easy-setup/enrollee/inc/ESEnrolleeCommon.h +++ b/service/easy-setup/enrollee/inc/ESEnrolleeCommon.h @@ -86,6 +86,10 @@ typedef struct uint8_t numSupportedMode; WIFI_FREQ supportedFreq[NUM_WIFIFREQ]; uint8_t numSupportedFreq; + WIFI_AUTHTYPE supportedAuthType[NUM_WIFIAUTHTYPE]; + uint8_t numSupportedAuthType; + WIFI_ENCTYPE supportedEncType[NUM_WIFIENCTYPE]; + uint8_t numSupportedEncType; } WiFi; /** diff --git a/service/easy-setup/enrollee/src/resourcehandler.c b/service/easy-setup/enrollee/src/resourcehandler.c index ac99a06..6490462 100644 --- a/service/easy-setup/enrollee/src/resourcehandler.c +++ b/service/easy-setup/enrollee/src/resourcehandler.c @@ -706,6 +706,26 @@ OCRepPayload* constructResponseOfWiFiConf(char *interface) OCRepPayloadSetStringArray(payload, OC_RSRVD_ES_SUPPORTEDWIFIFREQ, freq, dimensionsFreq); } + size_t dimensionsAuthType[MAX_REP_ARRAY_DEPTH] = { g_ESWiFiConfResource.numSupportedAuthType, 0, + 0 }; + const char *authType[NUM_WIFIAUTHTYPE] = { 0, }; + for (int i = 0; i < g_ESWiFiConfResource.numSupportedAuthType; ++i) + { + authType[i] = WiFiAuthTypeEnumToString(g_ESWiFiConfResource.supportedAuthType[i]); + } + OCRepPayloadSetStringArray(payload, OC_RSRVD_ES_SUPPORTEDWIFIAUTHTYPE, authType, + dimensionsAuthType); + + size_t dimensionsEncType[MAX_REP_ARRAY_DEPTH] = + { g_ESWiFiConfResource.numSupportedEncType, 0, 0 }; + const char *encType[NUM_WIFIENCTYPE] = { 0, }; + for (int i = 0; i < g_ESWiFiConfResource.numSupportedEncType; ++i) + { + encType[i] = WiFiEncTypeEnumToString(g_ESWiFiConfResource.supportedEncType[i]); + } + OCRepPayloadSetStringArray(payload, OC_RSRVD_ES_SUPPORTEDWIFIENCTYPE, encType, + dimensionsEncType); + OCRepPayloadSetPropString(payload, OC_RSRVD_ES_SSID, g_ESWiFiConfResource.ssid); OCRepPayloadSetPropString(payload, OC_RSRVD_ES_CRED, g_ESWiFiConfResource.cred); OCRepPayloadSetPropString(payload, OC_RSRVD_ES_AUTHTYPE, @@ -1667,7 +1687,9 @@ OCStackResult SetDeviceProperty(ESDeviceProperty *deviceProperty) OIC_LOG(DEBUG, ES_RH_TAG, "SetDeviceProperty IN"); if (deviceProperty->WiFi.numSupportedMode > NUM_WIFIMODE - || deviceProperty->WiFi.numSupportedFreq > NUM_WIFIFREQ) + || deviceProperty->WiFi.numSupportedFreq > NUM_WIFIFREQ + || deviceProperty->WiFi.numSupportedAuthType > NUM_WIFIAUTHTYPE + || deviceProperty->WiFi.numSupportedEncType > NUM_WIFIENCTYPE) { OIC_LOG(ERROR, ES_RH_TAG, "SetDeviceProperty: Invalid Input Param"); return OC_STACK_INVALID_PARAM; @@ -1687,7 +1709,24 @@ OCStackResult SetDeviceProperty(ESDeviceProperty *deviceProperty) OIC_LOG_V(INFO_PRIVATE, ES_RH_TAG, "WiFi Mode : %d", g_ESWiFiConfResource.supportedMode[i]); } - OICStrcpy(g_ESDevConfResource.devName, OIC_STRING_MAX_VALUE, (deviceProperty->DevConf).deviceName); + g_ESWiFiConfResource.numSupportedAuthType = deviceProperty->WiFi.numSupportedAuthType; + for (uint8_t i = 0; i < g_ESWiFiConfResource.numSupportedAuthType; ++i) + { + g_ESWiFiConfResource.supportedAuthType[i] = (deviceProperty->WiFi).supportedAuthType[i]; + OIC_LOG_V(INFO_PRIVATE, ES_RH_TAG, "WiFi Auth Type : %d", + g_ESWiFiConfResource.supportedAuthType[i]); + } + + g_ESWiFiConfResource.numSupportedEncType = deviceProperty->WiFi.numSupportedEncType; + for (uint8_t i = 0; i < g_ESWiFiConfResource.numSupportedEncType; ++i) + { + g_ESWiFiConfResource.supportedEncType[i] = (deviceProperty->WiFi).supportedEncType[i]; + OIC_LOG_V(INFO_PRIVATE, ES_RH_TAG, "WiFi Enc Type : %d", + g_ESWiFiConfResource.supportedAuthType[i]); + } + + OICStrcpy(g_ESDevConfResource.devName, OIC_STRING_MAX_VALUE, + (deviceProperty->DevConf).deviceName); OIC_LOG_V(INFO_PRIVATE, ES_RH_TAG, "Device Name : %s", g_ESDevConfResource.devName); if (OC_STACK_NO_OBSERVERS == OCNotifyAllObservers(g_ESWiFiConfResource.handle, OC_HIGH_QOS)) diff --git a/service/easy-setup/enrollee/src/resourcehandler.h b/service/easy-setup/enrollee/src/resourcehandler.h index ca4c4d4..1c7cc19 100644 --- a/service/easy-setup/enrollee/src/resourcehandler.h +++ b/service/easy-setup/enrollee/src/resourcehandler.h @@ -59,6 +59,10 @@ typedef struct uint8_t numMode; // the number of device's supported Wi-Fi modes WIFI_FREQ supportedFreq[NUM_WIFIFREQ]; uint8_t numSupportedFreq; // the number of device's supported Wi-Fi frequency bands + WIFI_AUTHTYPE supportedAuthType[NUM_WIFIAUTHTYPE]; + uint8_t numSupportedAuthType; + WIFI_ENCTYPE supportedEncType[NUM_WIFIENCTYPE]; + uint8_t numSupportedEncType; char ssid[OIC_STRING_MAX_VALUE]; // SSID char cred[OIC_STRING_MAX_VALUE]; // credential information. WIFI_AUTHTYPE authType; diff --git a/service/easy-setup/enrollee/unittests/ESEnrolleeTest.cpp b/service/easy-setup/enrollee/unittests/ESEnrolleeTest.cpp index a984f78..1f28db9 100644 --- a/service/easy-setup/enrollee/unittests/ESEnrolleeTest.cpp +++ b/service/easy-setup/enrollee/unittests/ESEnrolleeTest.cpp @@ -162,7 +162,9 @@ public: { { { WIFI_11G, WIFI_11N, WIFI_11AC }, 3, - { WIFI_24G, WIFI_5G }, 2 + { WIFI_24G, WIFI_5G }, 2, + { WPA_PSK, WPA2_PSK }, 2, + { AES, TKIP_AES }, 2 }, { "Test Device"} }; diff --git a/service/easy-setup/inc/escommon.h b/service/easy-setup/inc/escommon.h index b0407bd..a9930f2 100644 --- a/service/easy-setup/inc/escommon.h +++ b/service/easy-setup/inc/escommon.h @@ -40,6 +40,8 @@ extern "C" #define NUM_WIFIMODE 10 #define NUM_WIFIFREQ 5 #define NUM_CONNECT_TYPE 3 +#define NUM_WIFIAUTHTYPE 4 +#define NUM_WIFIENCTYPE 6 /** * Attributes used to form a proper easysetup conforming JSON message. diff --git a/service/easy-setup/mediator/richsdk/unittests/ESEnrolleeSimulator.h b/service/easy-setup/mediator/richsdk/unittests/ESEnrolleeSimulator.h index fcea3c7..906f44f 100644 --- a/service/easy-setup/mediator/richsdk/unittests/ESEnrolleeSimulator.h +++ b/service/easy-setup/mediator/richsdk/unittests/ESEnrolleeSimulator.h @@ -65,7 +65,9 @@ public: { { { WIFI_11G, WIFI_11N, WIFI_11AC }, 3, - { WIFI_24G, WIFI_5G }, 2 + { WIFI_24G, WIFI_5G }, 2, + { WPA_PSK, WPA2_PSK }, 2, + { AES, TKIP_AES }, 2 }, { "Test Device"} }; diff --git a/service/easy-setup/sampleapp/enrollee/linux/enrolleewifi.c b/service/easy-setup/sampleapp/enrollee/linux/enrolleewifi.c index 90595ee..93522dd 100644 --- a/service/easy-setup/sampleapp/enrollee/linux/enrolleewifi.c +++ b/service/easy-setup/sampleapp/enrollee/linux/enrolleewifi.c @@ -204,7 +204,9 @@ void SetDeviceInfo() { { { WIFI_11G, WIFI_11N, WIFI_11AC }, 3, - { WIFI_24G, WIFI_5G }, 2 + { WIFI_24G, WIFI_5G }, 2, + { WPA_PSK, WPA2_PSK }, 2, + { AES, TKIP_AES }, 2 }, { "Test Device"} }; diff --git a/service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample/enrolleewifi.cpp b/service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample/enrolleewifi.cpp index bd191da..b04f5a0 100644 --- a/service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample/enrolleewifi.cpp +++ b/service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample/enrolleewifi.cpp @@ -250,7 +250,9 @@ void SetDeviceInfo() { { { WIFI_11G, WIFI_11N, WIFI_11AC }, 3, - { WIFI_24G, WIFI_5G }, 2 + { WIFI_24G, WIFI_5G }, 2, + { WPA_PSK, WPA2_PSK }, 2, + { AES, TKIP_AES }, 2 }, { "Test Device"} };