*/
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) **/
+ // TODO: variables can be added when some properties in oic.r.devconf resource are specified.
void *userdata; /**< Vender-specific data**/
} ESDevConfData;
struct
{
char deviceName[OIC_STRING_MAX_VALUE];
- char modelNumber[OIC_STRING_MAX_VALUE];
} DevConf;
} ESDeviceProperty;
OCStackResult res = OC_STACK_ERROR;
OICStrcpy(g_ESDevConfResource.devName, sizeof(g_ESDevConfResource.devName), "");
- OICStrcpy(g_ESDevConfResource.modelNumber, sizeof(g_ESDevConfResource.modelNumber), "");
- OICStrcpy(g_ESDevConfResource.location, sizeof(g_ESDevConfResource.location), "");
- OICStrcpy(g_ESDevConfResource.country, sizeof(g_ESDevConfResource.country), "");
- OICStrcpy(g_ESDevConfResource.language, sizeof(g_ESDevConfResource.language), "");
if (isSecured)
{
OIC_LOG(DEBUG, ES_RH_TAG, "OICMalloc is failed");
return;
}
- memset(devConfData->language, 0, OIC_STRING_MAX_VALUE);
- memset(devConfData->country, 0, OIC_STRING_MAX_VALUE);
devConfData->userdata = NULL;
- char *location = NULL;
- if (OCRepPayloadGetPropString(input, OC_RSRVD_ES_LOCATION, &location))
- {
- OICStrcpy(g_ESDevConfResource.location, sizeof(g_ESDevConfResource.location), location);
- OICStrcpy(devConfData->location, sizeof(devConfData->location), location);
- OIC_LOG_V(INFO_PRIVATE, ES_RH_TAG, "g_ESDevConfResource.location %s", g_ESDevConfResource.location);
- }
-
- char *country = NULL;
- if (OCRepPayloadGetPropString(input, OC_RSRVD_ES_COUNTRY, &country))
- {
- OICStrcpy(g_ESDevConfResource.country, sizeof(g_ESDevConfResource.country), country);
- OICStrcpy(devConfData->country, sizeof(devConfData->country), country);
- OIC_LOG_V(INFO_PRIVATE, ES_RH_TAG, "g_ESDevConfResource.country %s", g_ESDevConfResource.country);
- }
-
- char *language = NULL;
- if (OCRepPayloadGetPropString(input, OC_RSRVD_ES_LANGUAGE, &language))
- {
- OICStrcpy(g_ESDevConfResource.language, sizeof(g_ESDevConfResource.language), language);
- OICStrcpy(devConfData->language, sizeof(devConfData->language), language);
- OIC_LOG_V(INFO_PRIVATE, ES_RH_TAG, "g_ESDevConfResource.language %s", g_ESDevConfResource.language);
- }
-
if (gReadUserdataCb)
{
gReadUserdataCb(input, OC_RSRVD_ES_RES_TYPE_DEVCONF, &devConfData->userdata);
}
- if (country || language)
+ // If a writable property in oic.r.devconf is added later,
+ // a condition for calling a resistered callback should be implemented also.
+ if( devConfData->userdata != NULL )
{
OIC_LOG(DEBUG, ES_RH_TAG, "Send DevConfRsrc Callback To ES");
}
OCRepPayloadSetPropString(payload, OC_RSRVD_ES_DEVNAME, g_ESDevConfResource.devName);
- OCRepPayloadSetPropString(payload, OC_RSRVD_ES_MODELNUMBER, g_ESDevConfResource.modelNumber);
- OCRepPayloadSetPropString(payload, OC_RSRVD_ES_LOCATION, g_ESDevConfResource.location);
- OCRepPayloadSetPropString(payload, OC_RSRVD_ES_LANGUAGE, g_ESDevConfResource.language);
- OCRepPayloadSetPropString(payload, OC_RSRVD_ES_COUNTRY, g_ESDevConfResource.country);
if (gWriteUserdataCb)
{
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);
- OICStrcpy(g_ESDevConfResource.modelNumber, OIC_STRING_MAX_VALUE,
- (deviceProperty->DevConf).modelNumber);
- OIC_LOG_V(INFO_PRIVATE, ES_RH_TAG, "Model Number : %s", g_ESDevConfResource.modelNumber);
-
if (OC_STACK_NO_OBSERVERS == OCNotifyAllObservers(g_ESWiFiConfResource.handle, OC_HIGH_QOS))
{
OIC_LOG(DEBUG, ES_RH_TAG, "wifiResource doesn't have any observers.");
ESResult setDeviceProperty()
{
ESDeviceProperty deviceProperty = {
- {{WIFI_11G, WiFi_EOF}, WIFI_5G}, {"Test Device", "Test Model Number"}
+ {{WIFI_11G, WiFi_EOF}, WIFI_5G}, {"Test Device"}
};
return ESSetDeviceProperty(&deviceProperty);
cntForReceivedCallbackWithSuccess++;
}
});
- mocks.OnCallFunc(DevConfProvCbInApp).Do(
- [& cntForReceivedCallbackWithSuccess](ESDevConfData *data)
- {
- if(!strcmp(data->language, "korean") &&
- !strcmp(data->country, "Korea"))
- {
- cntForReceivedCallbackWithSuccess++;
- }
- });
startEnrollee();
std::unique_lock< std::mutex > lock{ mutexForCondition };
responseCon.wait_for(lock, g_waitForResponse);
- EXPECT_EQ(cntForReceivedCallbackWithSuccess, 3);
+ EXPECT_EQ(cntForReceivedCallbackWithSuccess, 2);
ESTerminateEnrollee();
}
{
DeviceProp devProp;
devProp.setWiFiProp("Iotivity_SSID", "Iotivity_PWD", WPA2_PSK, TKIP_AES);
- devProp.setDevConfProp("korean", "Korea", "Location");
m_remoteEnrollee->provisionDeviceProperties(devProp,
std::bind(&ESMediatorSimulator::deviceProvisioningStatusCallback,
#define OC_RSRVD_ES_CISERVER "cis"
#define OC_RSRVD_ES_SERVERID "sid"
#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"
#define OC_RSRVD_ES_HREF "href"
#define OC_RSRVD_ES_CONNECT "cn"
}
/**
- * Set DevConf resource properties to be delivered to Enrollee
- *
- * @param language IETF language tag using ISO 639X
- * @param country ISO Country Code (ISO 3166-1 Alpha-2)
- * @param location location information
- */
- void setDevConfProp(string language, string country, string location)
- {
- m_rep.setValue(OC_RSRVD_ES_LANGUAGE, language);
- m_rep.setValue(OC_RSRVD_ES_COUNTRY, country);
- m_rep.setValue(OC_RSRVD_ES_LOCATION, location);
- }
-
- /**
* Get a SSID of Enroller
*
* @return a SSID of enroller
}
/**
- * Get a language to be set. A language is expressed in IETF language tag
- * using ISO 639X.
- *
- * @return a language to be set
- */
- std::string getLanguage() const
- {
- if(m_rep.hasAttribute(OC_RSRVD_ES_LANGUAGE))
- {
- return m_rep.getValue<std::string>(OC_RSRVD_ES_LANGUAGE);
- }
- return std::string("");
- }
-
- /**
- * Get a country to be set. A country is expressed in ISO Country Code
- * (ISO 3166-1 Alpha-2)
- *
- * @return a country to be set
- */
- std::string getCountry() const
- {
- if(m_rep.hasAttribute(OC_RSRVD_ES_COUNTRY))
- {
- return m_rep.getValue<std::string>(OC_RSRVD_ES_COUNTRY);
- }
- return std::string("");
- }
-
- /**
- * Get a location to be set. A location is GPS information
- *
- * @return a country to be set
- */
- std::string getLocation() const
- {
- if(m_rep.hasAttribute(OC_RSRVD_ES_LOCATION))
- {
- return m_rep.getValue<std::string>(OC_RSRVD_ES_LOCATION);
- }
- return std::string("");
- }
-
- /**
* Get OCRepresentation object
*
* @return OCRepresentation object
}
/**
- * Get a model number of Enrollee.
- *
- * @return a model number of Enrollee
- */
- std::string getModelNumber() const
- {
- std::vector<OCRepresentation> children = m_EasySetupRep.getChildren();
- for(auto child = children.begin(); child != children.end(); ++child)
- {
- if(child->getUri().find(OC_RSRVD_ES_URI_DEVCONF) != std::string::npos)
- {
- OCRepresentation rep;
- if(child->hasAttribute(OC_RSRVD_REPRESENTATION))
- {
- rep = child->getValue<OCRepresentation>(OC_RSRVD_REPRESENTATION);
- }
- else
- {
- return std::string("");
- }
-
- if(rep.hasAttribute(OC_RSRVD_ES_MODELNUMBER))
- {
- return rep.getValue<std::string>(OC_RSRVD_ES_MODELNUMBER);
- }
- }
- }
- return std::string("");
- }
-
- /**
* Get a set of WiFi supported modes of Enrollee
*
* @return a set of WiFi supported modes of Enrollee
ESResult setDeviceProperty()
{
ESDeviceProperty deviceProperty = {
- {{WIFI_11G, WiFi_EOF}, WIFI_5G}, {"Test Device", "Test Model Number"}
+ {{WIFI_11G, WiFi_EOF}, WIFI_5G}, {"Test Device"}
};
return ESSetDeviceProperty(&deviceProperty);
{
if(conf.getWiFiModes().at(0) == WIFI_11G &&
conf.getWiFiFreq() == WIFI_5G &&
- !strcmp(conf.getDeviceName().c_str(), "Test Device") &&
- !strcmp(conf.getModelNumber().c_str(), "Test Model Number"))
+ !strcmp(conf.getDeviceName().c_str(), "Test Device"))
{
isWellConstructed = true;
}
cout << "getDeviceName : " << conf.getDeviceName().c_str() << endl;
- cout << "getModelNumber : " << conf.getModelNumber().c_str() << endl;
}
}
});
{
DeviceProp devProp;
devProp.setWiFiProp("Iotivity_SSID", "Iotivity_PWD", WPA2_PSK, TKIP_AES);
- devProp.setDevConfProp("korean", "Korea", "Location");
EXPECT_ANY_THROW(g_remoteEnrollee->provisionDeviceProperties(devProp, nullptr));
}
{
DeviceProp devProp;
devProp.setWiFiProp("Iotivity_SSID", "Iotivity_PWD", WPA2_PSK, TKIP_AES);
- devProp.setDevConfProp("korean", "Korea", "Location");
int cntForReceivedCallbackWithSuccess = 0;
return ;
}
- printf("Language : %s\n", eventData->language);
- printf("Country : %s\n", eventData->country);
-
printf("DevConfProvCbInApp OUT\n");
}
printf("SetDeviceInfo IN\n");
ESDeviceProperty deviceProperty = {
- {{WIFI_11G, WIFI_11N, WIFI_11AC, WiFi_EOF}, WIFI_5G}, {"Test Device", "Test Model Number"}
+ {{WIFI_11G, WIFI_11N, WIFI_11AC, WiFi_EOF}, WIFI_5G}, {"Test Device"}
};
// Set user properties if needed
cout << "\tProvStatus : " << conf.getProvStatus() << endl;
cout << "\tLastErrCode : " << conf.getLastErrCode() << endl;
cout << "\tDevice Name : " << conf.getDeviceName() << endl;
- cout << "\tModel Number : " << conf.getModelNumber() << endl;
for(auto it : conf.getWiFiModes())
{
DeviceProp devProp;
devProp.setWiFiProp("Iotivity_SSID", "Iotivity_PWD", WPA2_PSK, TKIP_AES);
- devProp.setDevConfProp("korean", "Korea", "Location");
try
{
{
cout << "===========================================" << endl;
cout << "\tDevice Name : " << conf.getDeviceName() << endl;
- cout << "\tModel Number : " << conf.getModelNumber() << endl;
for(auto it : conf.getWiFiModes())
{
DeviceProp devProp;
devProp.setWiFiProp("Iotivity_SSID", "Iotivity_PWD", WPA2_PSK, TKIP_AES);
- devProp.setDevConfProp("korean", "Korea", "Location");
try
{