}
}
+void receivedPlatformInfo(const OCRepresentation& rep)
+{
+ std::cout << "\nPlatform Information received ---->\n";
+ std::string value;
+ std::string values[] =
+ {
+ "pi", "Platform ID ",
+ "mnmn", "Manufacturer name ",
+ "mnml", "Manufacturer url ",
+ "mnmo", "Manufacturer Model No ",
+ "mndt", "Manufactured Date ",
+ "mnpv", "Manufacturer Platform Version ",
+ "mnos", "Manufacturer OS version ",
+ "mnhw", "Manufacturer hardware version ",
+ "mnfv", "Manufacturer firmware version ",
+ "mnsl", "Manufacturer support url ",
+ "st", "Manufacturer system time "
+ };
+
+ for (unsigned int i = 0; i < sizeof(values) / sizeof(values[0]) ; i += 2)
+ {
+ if(rep.getValue(values[i], value))
+ {
+ std::cout << values[i + 1] << " : "<< value << std::endl;
+ }
+ }
+}
+
+void receivedDeviceInfo(const OCRepresentation& rep)
+{
+ std::cout << "\nDevice Information received ---->\n";
+ std::string value;
+ std::string values[] =
+ {
+ "di", "Device ID ",
+ "n", "Device name ",
+ "lcv", "Spec version url ",
+ "dmv", "Data Model Model ",
+ };
+
+ for (unsigned int i = 0; i < sizeof(values) / sizeof(values[0]); i += 2)
+ {
+ if (rep.getValue(values[i], value))
+ {
+ std::cout << values[i + 1] << " : " << value << std::endl;
+ }
+ }
+}
// Callback to found resources
void foundResource(std::shared_ptr<OCResource> resource)
{
std::cout << "\t\t" << resourceInterfaces << std::endl;
}
- OCStackResult ret;
+ std::cout << "Querying for platform information... " << std::endl;
- std::cout << "Querying for platform information... " << std::endl;
+ OCStackResult ret = OCPlatform::getPlatformInfo("", platformDiscoveryURI,
+ resource->connectivityType(),
+ &receivedPlatformInfo);
- ret = OCPlatform::getPlatformInfo("", platformDiscoveryURI, CT_ADAPTER_IP, NULL);
-
- if (ret == OC_STACK_OK)
- {
- std::cout << "Get platform information is done." << std::endl;
- }
- else
- {
- std::cout << "Get platform information failed." << std::endl;
- }
+ if (ret == OC_STACK_OK)
+ {
+ std::cout << "Get platform information is done." << std::endl;
+ }
+ else
+ {
+ std::cout << "Get platform information failed." << std::endl;
+ }
- std::cout << "Querying for device information... " << std::endl;
+ std::cout << "Querying for device information... " << std::endl;
- ret = OCPlatform::getDeviceInfo(resource->host(), deviceDiscoveryURI,
- resource->connectivityType(), NULL);
+ ret = OCPlatform::getDeviceInfo(resource->host(), deviceDiscoveryURI,
+ resource->connectivityType(),
+ &receivedDeviceInfo);
- if (ret == OC_STACK_OK)
- {
- std::cout << "Getting device information is done." << std::endl;
- }
- else
- {
- std::cout << "Getting device information failed." << std::endl;
- }
+ if (ret == OC_STACK_OK)
+ {
+ std::cout << "Getting device information is done." << std::endl;
+ }
+ else
+ {
+ std::cout << "Getting device information failed." << std::endl;
+ }
if(resourceURI == "/a/light")
{