Commit 7d3afa78 authored by Soemin Tjong's avatar Soemin Tjong Committed by Dan Mihai

IoT-2208: fix IPCA to get device's DMV and PIID

https://jira.iotivity.org/browse/IOT-2208

IPCA should not use OCPlatform::getPropertyValue() to obtain the data
model versions and protocol independent ID of the remote server.

It is incorrect as they return the values of the local server
(i.e. the app's own device info).

Change-Id: I7e8f64d9c7ebebd1b9bb4ec9290fbbdd1e0fa412
Signed-off-by: default avatarSoemin Tjong <stjong@microsoft.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/19645Tested-by: default avatarjenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: default avatarDan Mihai <Daniel.Mihai@microsoft.com>
parent 62178436
......@@ -709,13 +709,14 @@ void OCFFramework::OnDeviceInfoCallback(const OCRepresentation& rep)
}
// Not reading "di" because it's already known in OnResourceFound().
std::array<std::string, 3> keys = { {"n", "icv", "dmv"} };
std::array<std::string, 4> keys = { {"n", "icv", "dmv", "piid"} };
std::string dataModelVersion;
std::vector<std::string*> Values =
{
&(deviceDetails->deviceInfo.deviceName),
&(deviceDetails->deviceInfo.deviceSoftwareVersion),
&dataModelVersion
&dataModelVersion,
&(deviceDetails->deviceInfo.platformIndependentId)
};
for (size_t i = 0; i < keys.size(); i++)
......@@ -734,15 +735,13 @@ void OCFFramework::OnDeviceInfoCallback(const OCRepresentation& rep)
deviceDetails->deviceInfo.deviceUris = deviceDetails->deviceUris;
OCPlatform::getPropertyValue(
PAYLOAD_TYPE_DEVICE,
OC_RSRVD_DATA_MODEL_VERSION,
deviceDetails->deviceInfo.dataModelVersions);
OCPlatform::getPropertyValue(
PAYLOAD_TYPE_DEVICE,
OC_RSRVD_PROTOCOL_INDEPENDENT_ID,
deviceDetails->deviceInfo.platformIndependentId);
// Convert data model versions returned by server in CSV to array.
std::istringstream stringStream(dataModelVersion.c_str());
std::string token;
while (std::getline(stringStream, token, ','))
{
deviceDetails->deviceInfo.dataModelVersions.push_back(token);
}
deviceDetails->deviceInfoAvailable = true;
}
......
......@@ -342,7 +342,25 @@ OCStackResult OCPlatform::getDeviceInfo(const std::string& host,
ocRep.setDevAddr(addr);
ocRep.setValue(OC_RSRVD_DEVICE_NAME, g_deviceInfo.deviceName);
ocRep.setValue(OC_RSRVD_SPEC_VERSION, g_deviceInfo.specVersion);
ocRep.setValue(OC_RSRVD_DATA_MODEL_VERSION, g_deviceInfo.dataModelVersions);
ocRep.setValue(OC_RSRVD_PROTOCOL_INDEPENDENT_ID, g_deviceInfo.platformIndependentId);
// DMV is returned in CSV.
std::ostringstream outputStream;
bool firstEntry = true;
for (auto dataModelVersion : g_deviceInfo.dataModelVersions)
{
if (!firstEntry)
{
outputStream << ',' << dataModelVersion;
}
else
{
outputStream << dataModelVersion;
firstEntry = false;
}
}
ocRep.setValue(OC_RSRVD_DATA_MODEL_VERSION, outputStream.str());
std::thread getDeviceInfoCallbackThread(deviceInfoHandler, ocRep);
getDeviceInfoCallbackThread.detach();
......
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