Commit a31b400c authored by Jihun Ha's avatar Jihun Ha Committed by Madan Lanka

Add 'model number' and 'location' properties in DevConf resource

'Model number' property is set by Enrollee. Contrarily, 'Location' property
is given by Mediator, which is GPS information in JSON format.

Change-Id: I21d4d91705913702645cbadcd687d3b098b77e83
Signed-off-by: default avatarJihun Ha <jihun.ha@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/10483Tested-by: default avatarjenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: default avatarMadan Lanka <lanka.madan@samsung.com>
parent 0d893c92
......@@ -34,8 +34,8 @@ extern "C"
*/
typedef struct
{
char ssid[MAX_SSIDLEN]; /**< Ssid of the Enroller**/
char pwd[MAX_CREDLEN]; /**< Pwd of the Enroller**/
char ssid[OIC_STRING_MAX_VALUE]; /**< Ssid of the Enroller**/
char pwd[OIC_STRING_MAX_VALUE]; /**< Pwd of the Enroller**/
WIFI_AUTHTYPE authtype; /**< Auth type of the Enroller**/
WIFI_ENCTYPE enctype; /**< Encryption type of the Enroller**/
void *userdata; /**< Vender-specific data**/
......@@ -46,6 +46,7 @@ typedef struct
*/
typedef struct
{
char location[OIC_STRING_MAX_VALUE]; /**< GPS information of device. Longitude and latitude in json format **/
char language[OIC_STRING_MAX_VALUE]; /**< IETF language tag using ISO 639X **/
char country[OIC_STRING_MAX_VALUE]; /**< ISO Country Code (ISO 3166-1 Alpha-2) **/
void *userdata; /**< Vender-specific data**/
......@@ -81,7 +82,8 @@ typedef struct
*/
struct
{
char deviceName[MAX_DEVICELEN];
char deviceName[OIC_STRING_MAX_VALUE];
char modelNumber[OIC_STRING_MAX_VALUE];
} DevConf;
} ESDeviceProperty;
......
......@@ -191,7 +191,7 @@ ESResult ESSetDeviceProperty(ESDeviceProperty *deviceProperty)
(gESDeviceProperty.WiFi).freq = (deviceProperty->WiFi).freq;
OIC_LOG_V(INFO, ES_ENROLLEE_TAG, "WiFi Freq : %d", (gESDeviceProperty.WiFi).freq);
OICStrcpy((gESDeviceProperty.DevConf).deviceName, MAX_DEVICELEN, (deviceProperty->DevConf).deviceName);
OICStrcpy((gESDeviceProperty.DevConf).deviceName, OIC_STRING_MAX_VALUE, (deviceProperty->DevConf).deviceName);
OIC_LOG_V(INFO, ES_ENROLLEE_TAG, "Device Name : %s", (gESDeviceProperty.DevConf).deviceName);
OIC_LOG(INFO, ES_ENROLLEE_TAG, "ESSetDeviceProperty OUT");
......
......@@ -111,8 +111,8 @@ void GetTargetNetworkInfoFromProvResource(char *name, char *pass)
{
if (name != NULL && pass != NULL)
{
OICStrcpy(name, MAX_SSIDLEN, gWiFiResource.ssid);
OICStrcpy(pass, MAX_CREDLEN, gWiFiResource.cred);
OICStrcpy(name, MAX_WEBLINKLEN, gWiFiResource.ssid);
OICStrcpy(pass, MAX_WEBLINKLEN, gWiFiResource.cred);
}
}
......@@ -225,6 +225,8 @@ OCStackResult initDevConfResource(bool isSecured)
OCStackResult res = OC_STACK_ERROR;
OICStrcpy(gDevConfResource.devName, sizeof(gDevConfResource.devName), "");
OICStrcpy(gDevConfResource.modelNumber, sizeof(gDevConfResource.modelNumber), "");
OICStrcpy(gDevConfResource.location, sizeof(gDevConfResource.location), "");
OICStrcpy(gDevConfResource.country, sizeof(gDevConfResource.country), "");
OICStrcpy(gDevConfResource.language, sizeof(gDevConfResource.language), "");
......@@ -273,8 +275,8 @@ void updateWiFiResource(OCRepPayload* input)
return ;
}
memset(wiFiData->ssid, 0, MAX_SSIDLEN);
memset(wiFiData->pwd, 0, MAX_CREDLEN);
memset(wiFiData->ssid, 0, MAX_WEBLINKLEN);
memset(wiFiData->pwd, 0, MAX_WEBLINKLEN);
wiFiData->authtype = NONE_AUTH;
wiFiData->enctype = NONE_AUTH;
wiFiData->userdata = NULL;
......@@ -409,6 +411,14 @@ void updateDevConfResource(OCRepPayload* input)
memset(devConfData->country, 0, OIC_STRING_MAX_VALUE);
devConfData->userdata = NULL;
char *location = NULL;
if (OCRepPayloadGetPropString(input, OC_RSRVD_ES_LOCATION, &location))
{
OICStrcpy(gDevConfResource.location, sizeof(gDevConfResource.location), location);
OICStrcpy(devConfData->location, sizeof(devConfData->location), location);
OIC_LOG_V(INFO, ES_RH_TAG, "gDevConfResource.location %s", gDevConfResource.location);
}
char *country = NULL;
if (OCRepPayloadGetPropString(input, OC_RSRVD_ES_COUNTRY, &country))
{
......@@ -517,6 +527,8 @@ OCRepPayload* constructResponseOfDevConf()
OIC_LOG(INFO, ES_RH_TAG, "constructResponse prov res");
OCRepPayloadSetUri(payload, OC_RSRVD_ES_URI_DEVCONF);
OCRepPayloadSetPropString(payload, OC_RSRVD_ES_DEVNAME, gDevConfResource.devName);
OCRepPayloadSetPropString(payload, OC_RSRVD_ES_MODELNUMBER, gDevConfResource.modelNumber);
OCRepPayloadSetPropString(payload, OC_RSRVD_ES_LOCATION, gDevConfResource.location);
OCRepPayloadSetPropString(payload, OC_RSRVD_ES_LANGUAGE, gDevConfResource.language);
OCRepPayloadSetPropString(payload, OC_RSRVD_ES_COUNTRY, gDevConfResource.country);
......@@ -956,9 +968,13 @@ OCStackResult SetDeviceProperty(ESDeviceProperty *deviceProperty)
}
gWiFiResource.numMode = modeIdx;
OICStrcpy(gDevConfResource.devName, MAX_DEVICELEN, (deviceProperty->DevConf).deviceName);
OICStrcpy(gDevConfResource.devName, OIC_STRING_MAX_VALUE, (deviceProperty->DevConf).deviceName);
OIC_LOG_V(INFO, ES_RH_TAG, "Device Name : %s", gDevConfResource.devName);
OICStrcpy(gDevConfResource.modelNumber, OIC_STRING_MAX_VALUE,
(deviceProperty->DevConf).modelNumber);
OIC_LOG_V(INFO, ES_RH_TAG, "Model Number : %s", gDevConfResource.modelNumber);
OIC_LOG(INFO, ES_RH_TAG, "SetDeviceProperty OUT");
return OC_STACK_OK;
}
......
......@@ -56,8 +56,8 @@ typedef struct
WIFI_MODE supportedMode[NUM_WIFIMODE];
uint8_t numMode; // the number of device's supported wifi modes
WIFI_FREQ supportedFreq;
char ssid[MAX_SSIDLEN]; // SSID
char cred[MAX_CREDLEN]; // credential information.
char ssid[OIC_STRING_MAX_VALUE]; // SSID
char cred[OIC_STRING_MAX_VALUE]; // credential information.
WIFI_AUTHTYPE authType;
WIFI_ENCTYPE encType;
} WiFiResource;
......@@ -73,7 +73,9 @@ typedef struct
typedef struct
{
OCResourceHandle handle;
char devName[MAX_DEVICELEN];
char devName[OIC_STRING_MAX_VALUE];
char modelNumber[OIC_STRING_MAX_VALUE];
char location[OIC_STRING_MAX_VALUE];
char language[OIC_STRING_MAX_VALUE];
char country[OIC_STRING_MAX_VALUE];
} DevConfResource;
......
......@@ -30,14 +30,9 @@ extern "C"
#endif
// Defines
#define OIC_STRING_MAX_VALUE 100
#define IPV4_ADDR_SIZE 16
#define IP_PORT 55555
/**
* @brief Mac address length for BT port
*/
#define NET_MACADDR_SIZE 18
#define OIC_STRING_MAX_VALUE 64
#define MAX_WEBLINKLEN 3
#define NUM_WIFIMODE 5
/**
* Attributes used to form a proper easysetup conforming JSON message.
......@@ -58,6 +53,8 @@ extern "C"
#define OC_RSRVD_ES_DEVNAME "dn"
#define OC_RSRVD_ES_LANGUAGE "lang"
#define OC_RSRVD_ES_COUNTRY "ctry"
#define OC_RSRVD_ES_MODELNUMBER "mnmo"
#define OC_RSRVD_ES_LOCATION "loc"
/**
* Easysetup defined resoruce types and uris.
......@@ -71,12 +68,6 @@ extern "C"
#define OC_RSRVD_ES_RES_TYPE_DEVCONF "ocf.wk.devconf"
#define OC_RSRVD_ES_URI_DEVCONF "/DevConfProvisioningResURI"
#define NUM_WIFIMODE 10
#define MAX_SSIDLEN 33
#define MAX_CREDLEN 20
#define MAX_DEVICELEN 100
#define MAX_WEBLINKLEN 100
/**
* @brief Supported WIFI frequency like 2.4G and 5G
......
......@@ -173,7 +173,7 @@ void SetDeviceInfo()
printf("SetDeviceInfo IN\n");
ESDeviceProperty deviceProperty = {
{{WIFI_11G, WIFI_11N, WIFI_11AC, WiFi_EOF}, WIFI_5G}, {"Test Device"}
{{WIFI_11G, WIFI_11N, WIFI_11AC, WiFi_EOF}, WIFI_5G}, {"Test Device", "Test Model Number"}
};
// Set user properties if needed
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment