[IOT-2628][EasySetup]Add new prop. swat,swet
authorAnkur Bansal <ankur.b1@samsung.com>
Sun, 20 Aug 2017 09:28:59 +0000 (14:58 +0530)
committerAnkur Bansal <ankur.b1@samsung.com>
Wed, 13 Sep 2017 09:35:02 +0000 (15:05 +0530)
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 <ankur.b1@samsung.com>
service/easy-setup/enrollee/inc/ESEnrolleeCommon.h
service/easy-setup/enrollee/src/resourcehandler.c
service/easy-setup/enrollee/src/resourcehandler.h
service/easy-setup/enrollee/unittests/ESEnrolleeTest.cpp
service/easy-setup/inc/escommon.h
service/easy-setup/mediator/richsdk/unittests/ESEnrolleeSimulator.h
service/easy-setup/sampleapp/enrollee/linux/enrolleewifi.c
service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample/enrolleewifi.cpp

index 60356fa..d33dff5 100644 (file)
@@ -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;
 
     /**
index ac99a06..6490462 100644 (file)
@@ -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))
index ca4c4d4..1c7cc19 100644 (file)
@@ -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;
index a984f78..1f28db9 100644 (file)
@@ -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"}
             };
index b0407bd..a9930f2 100644 (file)
@@ -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.
index fcea3c7..906f44f 100644 (file)
@@ -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"}
             };
index 90595ee..93522dd 100644 (file)
@@ -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"}
         };
index bd191da..b04f5a0 100644 (file)
@@ -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"}
         };