Commit 132838c4 authored by Ankur Bansal's avatar Ankur Bansal

[IOT-2628][EasySetup]Update WifiConf prop. types

- Change properties from integer to string enums: swmt, swf, wat, wet
- Change supported frequencies from single value to array.
- Create type converters for enum to string and string to enum.
- Remove EOF marker in enum WIFI_MODE.
- Update Enrollee sample apps (Linux and Tizen).
- Cleanup some unused code in easysetup.c.
- Fixed unit test cases for Enrollee and Mediator.

Note: This impacts Easy Setup Enrollee API "ESSetDeviceProperty".

Thanks-To: Abhishek Pandey <abhi.siso@samsung.com>
Change-Id: Iea8191616cea89a0273e0f5486bd259735e914fa
Signed-off-by: default avatarAbhishek Pandey <abhi.siso@samsung.com>
Signed-off-by: default avatarAnkur Bansal <ankur.b1@samsung.com>
parent ebe66972
......@@ -120,7 +120,7 @@ if target_os == 'arduino':
es_enrollee_src = None
if target_os in ['linux', 'tizen']:
es_enrollee_common_src = ['./src/easysetup.c', './src/resourcehandler.c']
es_enrollee_common_src = ['./src/easysetup.c', './src/resourcehandler.c', './src/es_util.c']
enrollee_sdk_shared = enrollee_env.SharedLibrary('ESEnrolleeSDK',
es_enrollee_common_src)
enrollee_sdk_static = enrollee_env.StaticLibrary('ESEnrolleeSDK',
......@@ -135,7 +135,7 @@ if target_os in ['linux', 'tizen']:
'service/easy-setup', 'easysetup.h')
if target_os == 'arduino':
es_enrollee_common_src = ['./src/easysetup.c', './src/resourcehandler.c']
es_enrollee_common_src = ['./src/easysetup.c', './src/resourcehandler.c', './src/es_util.c']
enrollee_sdk_static = enrollee_env.StaticLibrary('ESEnrolleeSDK',
es_enrollee_common_src)
enrollee_env.InstallTarget(enrollee_sdk_static, 'libESEnrolleeSDK')
......
......@@ -82,8 +82,10 @@ typedef struct
*/
struct
{
WIFI_MODE mode[NUM_WIFIMODE];
WIFI_FREQ freq;
WIFI_MODE supportedMode[NUM_WIFIMODE];
uint8_t numSupportedMode;
WIFI_FREQ supportedFreq[NUM_WIFIFREQ];
uint8_t numSupportedFreq;
} WiFi;
/**
......
//******************************************************************
//
// Copyright 2017 Samsung Electronics All Rights Reserved.
//
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#ifndef ES_UTIL_H_
#define ES_UTIL_H_
#include "escommon.h"
#ifdef __cplusplus
extern "C"
{
#endif
// Some type conversion helpers
// For all *EnumToString(...) functions: They take the Enum Type Value as input (val), and return
// the corresponding string representation, which conforms to the OCF specification.
// For all *StringToEnum(...) functions: They take the string representation, as per the OCF
// specification as input (valIn). And return the Enum Value in valOut. If conversion fails,
// false is returned by the function.
const char* WiFiModeEnumToString(WIFI_MODE val);
bool WiFiModeStringToEnum(const char *valIn, WIFI_MODE *valOut);
const char* WiFiFreqEnumToString(WIFI_FREQ val);
bool WiFiFreqStringToEnum(const char *val, WIFI_FREQ *valOut);
const char* WiFiAuthTypeEnumToString(WIFI_AUTHTYPE val);
bool WiFiAuthTypeStringToEnum(const char *val, WIFI_AUTHTYPE *valOut);
const char* WiFiEncTypeEnumToString(WIFI_ENCTYPE val);
bool WiFiEncTypeStringToEnum(const char *val, WIFI_ENCTYPE *valOut);
#ifdef __cplusplus
}
#endif // __cplusplus
#endif //ES_UTIL_H_
......@@ -42,7 +42,6 @@
static bool gIsSecured = false;
static ESProvisioningCallbacks gESProvisioningCb;
static ESDeviceProperty gESDeviceProperty;
void ESConnectRequestCallback(ESResult esResult, ESConnectRequest *eventData)
{
......@@ -208,19 +207,6 @@ ESResult ESSetDeviceProperty(ESDeviceProperty *deviceProperty)
return ES_ERROR;
}
int modeIdx = 0;
while((deviceProperty->WiFi).mode[modeIdx] != WiFi_EOF)
{
(gESDeviceProperty.WiFi).mode[modeIdx] = (deviceProperty->WiFi).mode[modeIdx];
OIC_LOG_V(INFO_PRIVATE, ES_ENROLLEE_TAG, "WiFi Mode : %d", (gESDeviceProperty.WiFi).mode[modeIdx]);
modeIdx ++;
}
(gESDeviceProperty.WiFi).freq = (deviceProperty->WiFi).freq;
OIC_LOG_V(INFO_PRIVATE, ES_ENROLLEE_TAG, "WiFi Freq : %d", (gESDeviceProperty.WiFi).freq);
OICStrcpy((gESDeviceProperty.DevConf).deviceName, OIC_STRING_MAX_VALUE, (deviceProperty->DevConf).deviceName);
OIC_LOG_V(INFO_PRIVATE, ES_ENROLLEE_TAG, "Device Name : %s", (gESDeviceProperty.DevConf).deviceName);
OIC_LOG(INFO, ES_ENROLLEE_TAG, "ESSetDeviceProperty OUT");
return ES_OK;
}
......@@ -296,4 +282,4 @@ ESResult ESSetCallbackForUserdata(ESReadUserdataCb readCb, ESWriteUserdataCb wri
SetCallbackForUserData(readCb, writeCb);
return ES_OK;
}
\ No newline at end of file
}
//******************************************************************
//
// Copyright 2017 Samsung Electronics All Rights Reserved.
//
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#include <string.h>
#include "escommon.h"
// Lookup Table Template
// static const struct
// {
// <<EnumType>> valEnum;
// char *valStr;
// } <<TableName>> [] = { { <<Enum value>>, <<char* value>> }, ... }
// Helper to convert Enum to String (char*) value (by searching it in the lookup table)
#define LookupEnumToStr( val, lut, ret) \
{ \
ret = NULL; \
const size_t n = sizeof(lut) / sizeof(lut[0]); \
for (size_t i = 0; i < n; ++i) \
{ \
if (lut[i].valEnum == val) \
{ \
ret = lut[i].valStr; \
break; \
} \
} \
}
// Helper to convert String (char*) to Enum value (by searching it in the lookup table)
#define LookupStrToEnum( valIn, lut, valOut, result) \
{ \
result = false; \
const size_t n = sizeof(lut) / sizeof(lut[0]); \
for (size_t i = 0; i < n; ++i) \
{ \
if (strcmp(lut[i].valStr, valIn) == 0) \
{ \
valOut = lut[i].valEnum; \
result = true; \
break; \
} \
} \
}
static const struct
{
WIFI_MODE valEnum;
char *valStr;
} wifiModeConvertLookup[] =
{
{ WIFI_11A, "A" },
{ WIFI_11B, "B" },
{ WIFI_11G, "G" },
{ WIFI_11N, "N" },
{ WIFI_11AC, "AC" },
};
static const struct
{
WIFI_FREQ valEnum;
char *valStr;
} wifiFreqConvertLookup[] =
{
{ WIFI_24G, "2.4G" },
{ WIFI_5G, "5G"}
};
static const struct
{
WIFI_AUTHTYPE valEnum;
char *valStr;
} wifiAuthtypeConvertLookup[] =
{
{ NONE_AUTH, "None" },
{ WEP, "WEP"},
{ WPA_PSK, "WPA_PSK" },
{ WPA2_PSK, "WPA2_PSK" },
};
static const struct
{
WIFI_ENCTYPE valEnum;
char *valStr;
} wifiEnctypeConvertLookup[] =
{
{ NONE_ENC, "None" },
{ WEP_64, "WEP_64" },
{ WEP_128, "WEP_128" },
{ TKIP, "TKIP" },
{ AES, "AES" },
{ TKIP_AES, "TKIP_AES" },
};
const char* WiFiModeEnumToString(WIFI_MODE val)
{
char *ret = NULL;
LookupEnumToStr(val, wifiModeConvertLookup, ret);
return ret;
}
bool WiFiModeStringToEnum(const char *valIn, WIFI_MODE *valOut)
{
bool result = false;
LookupStrToEnum(valIn, wifiModeConvertLookup, (*valOut), result);
return result;
}
const char* WiFiFreqEnumToString(WIFI_FREQ val)
{
char *ret = NULL;
LookupEnumToStr(val, wifiFreqConvertLookup, ret);
return ret;
}
bool WiFiFreqStringToEnum(const char *val, WIFI_FREQ *valOut)
{
bool result = false;
LookupStrToEnum(val, wifiFreqConvertLookup, (*valOut), result);
return result;
}
const char* WiFiAuthTypeEnumToString(WIFI_AUTHTYPE val)
{
char *ret = NULL;
LookupEnumToStr(val, wifiAuthtypeConvertLookup, ret);
return ret;
}
bool WiFiAuthTypeStringToEnum(const char *val, WIFI_AUTHTYPE *valOut)
{
bool result = false;
LookupStrToEnum(val, wifiAuthtypeConvertLookup, (*valOut), result);
return result;
}
const char* WiFiEncTypeEnumToString(WIFI_ENCTYPE val)
{
char *ret = NULL;
LookupEnumToStr(val, wifiEnctypeConvertLookup, ret);
return ret;
}
bool WiFiEncTypeStringToEnum(const char *val, WIFI_ENCTYPE *valOut)
{
bool result = false;
LookupStrToEnum(val, wifiEnctypeConvertLookup, (*valOut), result);
return result;
}
......@@ -19,6 +19,7 @@
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#include "resourcehandler.h"
#include "internal/es_util.h"
#include "ocpayload.h"
#include "oic_string.h"
......@@ -221,7 +222,9 @@ OCStackResult initWiFiConfResource(bool isSecured)
{
OCStackResult res = OC_STACK_ERROR;
g_ESWiFiConfResource.supportedFreq = WIFI_BOTH;
g_ESWiFiConfResource.supportedFreq[0] = WIFI_24G;
g_ESWiFiConfResource.supportedFreq[1] = WIFI_5G;
g_ESWiFiConfResource.numSupportedFreq=2;
g_ESWiFiConfResource.supportedMode[0] = WIFI_11A;
g_ESWiFiConfResource.supportedMode[1] = WIFI_11B;
g_ESWiFiConfResource.supportedMode[2] = WIFI_11G;
......@@ -398,12 +401,12 @@ void updateEasySetupResource(OCEntityHandlerRequest* ehRequest, OCRepPayload* in
void updateWiFiConfResource(OCRepPayload* input)
{
ESWiFiConfData* wiFiData = (ESWiFiConfData*)OICMalloc(sizeof(ESWiFiConfData));
ESWiFiConfData* wiFiData = (ESWiFiConfData*) OICMalloc(sizeof(ESWiFiConfData));
if (wiFiData == NULL)
{
OIC_LOG(DEBUG, ES_RH_TAG, "OICMalloc is failed");
return ;
return;
}
memset(wiFiData->ssid, 0, OIC_STRING_MAX_VALUE);
......@@ -417,7 +420,8 @@ void updateWiFiConfResource(OCRepPayload* input)
{
OICStrcpy(g_ESWiFiConfResource.ssid, sizeof(g_ESWiFiConfResource.ssid), ssid);
OICStrcpy(wiFiData->ssid, sizeof(wiFiData->ssid), ssid);
OIC_LOG_V(INFO_PRIVATE, ES_RH_TAG, "g_ESWiFiConfResource.ssid : %s", g_ESWiFiConfResource.ssid);
OIC_LOG_V(INFO_PRIVATE, ES_RH_TAG, "g_ESWiFiConfResource.ssid : %s",
g_ESWiFiConfResource.ssid);
}
char* cred = NULL;
......@@ -425,23 +429,38 @@ void updateWiFiConfResource(OCRepPayload* input)
{
OICStrcpy(g_ESWiFiConfResource.cred, sizeof(g_ESWiFiConfResource.cred), cred);
OICStrcpy(wiFiData->pwd, sizeof(wiFiData->pwd), cred);
OIC_LOG_V(INFO_PRIVATE, ES_RH_TAG, "g_ESWiFiConfResource.cred %s", g_ESWiFiConfResource.cred);
OIC_LOG_V(INFO_PRIVATE, ES_RH_TAG, "g_ESWiFiConfResource.cred %s",
g_ESWiFiConfResource.cred);
}
int64_t authType = -1;
if (OCRepPayloadGetPropInt(input, OC_RSRVD_ES_AUTHTYPE, &authType))
bool validAuthType = false;
char *authType = NULL;
if (OCRepPayloadGetPropString(input, OC_RSRVD_ES_AUTHTYPE, &authType))
{
g_ESWiFiConfResource.authType = authType;
wiFiData->authtype = g_ESWiFiConfResource.authType;
OIC_LOG_V(INFO_PRIVATE, ES_RH_TAG, "g_ESWiFiConfResource.authType %u", g_ESWiFiConfResource.authType);
WIFI_AUTHTYPE tmp;
validAuthType = WiFiAuthTypeStringToEnum(authType, &tmp);
if (validAuthType == true)
{
g_ESWiFiConfResource.authType = tmp;
wiFiData->authtype = g_ESWiFiConfResource.authType;
OIC_LOG_V(INFO_PRIVATE, ES_RH_TAG, "g_ESWiFiConfResource.authType %u",
g_ESWiFiConfResource.authType);
}
}
int64_t encType = -1;
if (OCRepPayloadGetPropInt(input, OC_RSRVD_ES_ENCTYPE, &encType))
bool validEncType = false;
char *encType = NULL;
if (OCRepPayloadGetPropString(input, OC_RSRVD_ES_ENCTYPE, &encType))
{
g_ESWiFiConfResource.encType = encType;
wiFiData->enctype = g_ESWiFiConfResource.encType;
OIC_LOG_V(INFO_PRIVATE, ES_RH_TAG, "g_ESWiFiConfResource.encType %u", g_ESWiFiConfResource.encType);
WIFI_ENCTYPE tmp;
validEncType = WiFiEncTypeStringToEnum(encType, &tmp);
if (validEncType == true)
{
g_ESWiFiConfResource.encType = tmp;
wiFiData->enctype = g_ESWiFiConfResource.encType;
OIC_LOG_V(INFO_PRIVATE, ES_RH_TAG, "g_ESWiFiConfResource.encType %u",
g_ESWiFiConfResource.encType);
}
}
if (gReadUserdataCb)
......@@ -449,7 +468,7 @@ void updateWiFiConfResource(OCRepPayload* input)
gReadUserdataCb(input, OC_RSRVD_ES_RES_TYPE_WIFICONF, &wiFiData->userdata);
}
if (ssid || cred || authType!= -1 || encType != -1)
if (ssid || cred || validAuthType || validEncType)
{
OIC_LOG(DEBUG, ES_RH_TAG, "Send WiFiConfRsrc Callback To ES");
......@@ -469,6 +488,10 @@ void updateWiFiConfResource(OCRepPayload* input)
OIC_LOG(DEBUG, ES_RH_TAG, "Enrollee doesn't have any observer.");
}
OICFree(encType);
OICFree(authType);
OICFree(cred);
OICFree(ssid);
OICFree(wiFiData);
}
......@@ -662,32 +685,33 @@ OCRepPayload* constructResponseOfWiFiConf(char *interface)
OCRepPayloadAddResourceType(payload, OC_RSRVD_ES_RES_TYPE_WIFICONF);
}
size_t dimensions[MAX_REP_ARRAY_DEPTH] = {g_ESWiFiConfResource.numMode, 0, 0};
int64_t *modes_64 = (int64_t *)OICMalloc(g_ESWiFiConfResource.numMode * sizeof(int64_t));
if (!modes_64)
{
OIC_LOG(ERROR, ES_RH_TAG, "Failed to allocate Payload");
return NULL;
}
for (int i = 0 ; i < g_ESWiFiConfResource.numMode ; ++i)
{
modes_64[i] = g_ESWiFiConfResource.supportedMode[i];
}
// Do not add Read Only Properties when using OC_RSRVD_INTERFACE_READ_WRITE
if (strcmp(interface, OC_RSRVD_INTERFACE_READ_WRITE) != 0)
{
OCRepPayloadSetIntArray(payload, OC_RSRVD_ES_SUPPORTEDWIFIMODE, (int64_t *) modes_64,
dimensions);
OCRepPayloadSetPropInt(payload, OC_RSRVD_ES_SUPPORTEDWIFIFREQ,
g_ESWiFiConfResource.supportedFreq);
size_t dimensionsModes[MAX_REP_ARRAY_DEPTH] = { g_ESWiFiConfResource.numMode, 0, 0 };
const char *modes[NUM_WIFIMODE] = { 0, };
for (int i = 0; i < g_ESWiFiConfResource.numMode; ++i)
{
modes[i] = WiFiModeEnumToString(g_ESWiFiConfResource.supportedMode[i]);
}
OCRepPayloadSetStringArray(payload, OC_RSRVD_ES_SUPPORTEDWIFIMODE, &modes[0],
dimensionsModes);
size_t dimensionsFreq[MAX_REP_ARRAY_DEPTH] = { g_ESWiFiConfResource.numSupportedFreq, 0, 0 };
const char *freq[NUM_WIFIFREQ] = { 0, };
for (int i = 0; i < g_ESWiFiConfResource.numSupportedFreq; ++i)
{
freq[i] = WiFiFreqEnumToString(g_ESWiFiConfResource.supportedFreq[i]);
}
OCRepPayloadSetStringArray(payload, OC_RSRVD_ES_SUPPORTEDWIFIFREQ, freq, dimensionsFreq);
}
OCRepPayloadSetPropString(payload, OC_RSRVD_ES_SSID, g_ESWiFiConfResource.ssid);
OCRepPayloadSetPropString(payload, OC_RSRVD_ES_CRED, g_ESWiFiConfResource.cred);
OCRepPayloadSetPropInt(payload, OC_RSRVD_ES_AUTHTYPE, (int) g_ESWiFiConfResource.authType);
OCRepPayloadSetPropInt(payload, OC_RSRVD_ES_ENCTYPE, (int) g_ESWiFiConfResource.encType);
OCRepPayloadSetPropString(payload, OC_RSRVD_ES_AUTHTYPE,
WiFiAuthTypeEnumToString(g_ESWiFiConfResource.authType));
OCRepPayloadSetPropString(payload, OC_RSRVD_ES_ENCTYPE,
WiFiEncTypeEnumToString(g_ESWiFiConfResource.encType));
if (gWriteUserdataCb)
{
......@@ -1642,17 +1666,26 @@ OCStackResult SetDeviceProperty(ESDeviceProperty *deviceProperty)
{
OIC_LOG(DEBUG, ES_RH_TAG, "SetDeviceProperty IN");
g_ESWiFiConfResource.supportedFreq = (deviceProperty->WiFi).freq;
OIC_LOG_V(INFO_PRIVATE, ES_RH_TAG, "WiFi Freq : %d", g_ESWiFiConfResource.supportedFreq);
if (deviceProperty->WiFi.numSupportedMode > NUM_WIFIMODE
|| deviceProperty->WiFi.numSupportedFreq > NUM_WIFIFREQ)
{
OIC_LOG(ERROR, ES_RH_TAG, "SetDeviceProperty: Invalid Input Param");
return OC_STACK_INVALID_PARAM;
}
g_ESWiFiConfResource.numSupportedFreq = deviceProperty->WiFi.numSupportedFreq;
for (uint8_t i = 0; i < g_ESWiFiConfResource.numSupportedFreq; ++i)
{
g_ESWiFiConfResource.supportedFreq[i] = (deviceProperty->WiFi).supportedFreq[i];
OIC_LOG_V(INFO_PRIVATE, ES_RH_TAG, "WiFi Freq : %d", g_ESWiFiConfResource.supportedFreq[i]);
}
int modeIdx = 0;
while ((deviceProperty->WiFi).mode[modeIdx] != WiFi_EOF)
g_ESWiFiConfResource.numMode = deviceProperty->WiFi.numSupportedMode;
for (uint8_t i = 0; i < g_ESWiFiConfResource.numMode; ++i)
{
g_ESWiFiConfResource.supportedMode[modeIdx] = (deviceProperty->WiFi).mode[modeIdx];
OIC_LOG_V(INFO_PRIVATE, ES_RH_TAG, "WiFi Mode : %d", g_ESWiFiConfResource.supportedMode[modeIdx]);
modeIdx ++;
g_ESWiFiConfResource.supportedMode[i] = (deviceProperty->WiFi).supportedMode[i];
OIC_LOG_V(INFO_PRIVATE, ES_RH_TAG, "WiFi Mode : %d", g_ESWiFiConfResource.supportedMode[i]);
}
g_ESWiFiConfResource.numMode = modeIdx;
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);
......
......@@ -56,8 +56,9 @@ typedef struct
{
OCResourceHandle handle;
WIFI_MODE supportedMode[NUM_WIFIMODE];
uint8_t numMode; // the number of device's supported wifi modes
WIFI_FREQ supportedFreq;
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
char ssid[OIC_STRING_MAX_VALUE]; // SSID
char cred[OIC_STRING_MAX_VALUE]; // credential information.
WIFI_AUTHTYPE authType;
......
......@@ -158,9 +158,14 @@ public:
ESResult setDeviceProperty()
{
ESDeviceProperty deviceProperty = {
{{WIFI_11G, WiFi_EOF}, WIFI_5G}, {"Test Device"}
};
ESDeviceProperty deviceProperty =
{
{
{ WIFI_11G, WIFI_11N, WIFI_11AC }, 3,
{ WIFI_24G, WIFI_5G }, 2
},
{ "Test Device"}
};
return ESSetDeviceProperty(&deviceProperty);
}
......@@ -317,7 +322,7 @@ TEST_F(EasysetupEnrolleeTest, DevicePropertyIsWellConstructedInResponsePayload)
if(status->getESResult() == ES_OK)
{
EnrolleeConf conf = status->getEnrolleeConf();
if(conf.getWiFiModes().at(0) == WIFI_11G &&
if(conf.getWiFiModes().size() > 0 && conf.getWiFiModes().at(0) == WIFI_11G &&
conf.getWiFiFreq() == WIFI_5G &&
!strcmp(conf.getDeviceName().c_str(), "Test Device"))
{
......
......@@ -38,6 +38,7 @@ extern "C"
#define OIC_URI_STRING_MAX_VALUE 256
#define MAX_WEBLINKLEN 3
#define NUM_WIFIMODE 10
#define NUM_WIFIFREQ 5
#define NUM_CONNECT_TYPE 3
/**
......@@ -80,6 +81,7 @@ extern "C"
/**
* @brief Supported WIFI frequency like 2.4G and 5G
*/
//TODO: Remove WIFI_BOTH & WIFI_FREQ_NONE, if they are not used anymore. Array should be used to specify multiple values.
typedef enum
{
WIFI_24G = 0, /**< 2.4G **/
......@@ -97,11 +99,9 @@ typedef enum
WIFI_11B, /**< 802.11b **/
WIFI_11G, /**< 802.11g **/
WIFI_11N, /**< 802.11n **/
WIFI_11AC, /**< 802.11ac **/
WiFi_EOF = 999
WIFI_11AC /**< 802.11ac **/
} WIFI_MODE;
/**
* @brief WIFI Authentication tlype of the Enroller
*/
......
......@@ -984,11 +984,11 @@ namespace OIC
{
return WIFI_11N;
}
else if(0 == wifiMode.compare("AC"))
else /* if(0 == wifiMode.compare("AC")) */
{
return WIFI_11AC;
}
return WiFi_EOF;
//return WiFi_EOF;
}
WIFI_FREQ getWiFiFreqAsEnum(std::vector<std::string> wifiFreqList) const
......
......@@ -206,7 +206,7 @@ namespace OIC
HeaderOptions headerOptions = m_ocResource->getServerHeaderOptions();
if (headerOptions.size() == 0)
{
OIC_LOG (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "No header option exists");
OIC_LOG (ERROR, ES_REMOTE_ENROLLEE_RES_TAG, "No header option exists");
}
else
{
......@@ -217,8 +217,12 @@ namespace OIC
size_t dataLength = it->getOptionData().length();
if (dataLength == 0)
{
OIC_LOG (DEBUG, ES_REMOTE_ENROLLEE_RES_TAG, "GetOCFServerVersion: version not found!");
return 0;
OIC_LOG (ERROR, ES_REMOTE_ENROLLEE_RES_TAG,
"GetOCFServerVersion: version value not found!");
// Content Format Version Header Option ID exist but not value.
// As OIC server don't use this header option ID, assuming as OCF Server.
return 1;
}
int version = (it->getOptionData().c_str()[0]) * 256;
......
......@@ -61,10 +61,14 @@ public:
ESResult setDeviceProperty()
{
ESDeviceProperty deviceProperty = {
{{WIFI_11G, WiFi_EOF}, WIFI_5G}, {"Test Device"}
};
ESDeviceProperty deviceProperty =
{
{
{ WIFI_11G, WIFI_11N, WIFI_11AC }, 3,
{ WIFI_24G, WIFI_5G }, 2
},
{ "Test Device"}
};
return ESSetDeviceProperty(&deviceProperty);
}
......
......@@ -240,8 +240,10 @@ TEST_F(GetConfigurationTest, GetConfigurationSucceed)
EnrolleeConf conf = status->getEnrolleeConf();
if(!conf.getWiFiModes().empty())
{
if(conf.getWiFiModes().at(0) == WIFI_11G &&
conf.getWiFiFreq() == WIFI_5G &&
if(conf.getWiFiModes().size() > 0 &&
conf.getWiFiModes().at(0) == WIFI_11G &&
conf.getWiFiFreq() == WIFI_BOTH &&