return result;
}
+ result = OCPlatform::setPropertyValue(PAYLOAD_TYPE_DEVICE, OC_RSRVD_PROTOCOL_INDEPENDENT_ID,
+ "d7d2b492-83ac-4783-9dcc-b1b54587ebed");
+
+ if (result != OC_STACK_OK)
+ {
+ cout << "Failed to set piid" << endl;
+ return result;
+ }
+
return OC_STACK_OK;
}
}
VERIFY_SUCCESS(OCSetPropertyValue(PAYLOAD_TYPE_DEVICE, OC_RSRVD_DEVICE_NAME, "Living Room Light"));
+ VERIFY_SUCCESS(OCSetPropertyValue(PAYLOAD_TYPE_DEVICE, OC_RSRVD_PROTOCOL_INDEPENDENT_ID,
+ "91debd4b-c875-47e1-9e1d-b1cd32baeb01"));
cout << "Device information published successfully." << endl;
return OC_STACK_OK;
VERIFY_SUCCESS(OCSetPropertyValue(PAYLOAD_TYPE_DEVICE, OC_RSRVD_DATA_MODEL_VERSION,
"IoTivity/Zigbee Data Model Version"));
+ VERIFY_SUCCESS(OCSetPropertyValue(PAYLOAD_TYPE_DEVICE, OC_RSRVD_PROTOCOL_INDEPENDENT_ID,
+ "4ea65ac9-59a3-4eb8-8d77-76c3ee72c250"));
+
OIC_LOG(INFO, TAG, "Device information initialized successfully.");
return OC_STACK_OK;
/** Device Data Model version.*/
#define OC_DATA_MODEL_VERSION "res.1.1.0,sh.1.1.0"
+
+/** Protocol-Independent ID.*/
+#define OC_RSRVD_PROTOCOL_INDEPENDENT_ID "piid"
+
/**
* These provide backward compatibility - their use is deprecated.
*/
const char *operatingSystemVersion = "myOS";
const char *hardwareVersion = "myHardwareVersion";
const char *platformID = "0A3E0D6F-DBF5-404E-8719-D6880042463A";
+const char *protocolIndependentID = "6ef9211d-2d5c-401e-8e5d-4b3af48a054f";
const char *manufacturerLink = "https://www.iotivity.org";
const char *modelNumber = "myModelNumber";
const char *platformVersion = "myPlatformVersion";
VERIFY_SUCCESS(OCSetPropertyValue(PAYLOAD_TYPE_DEVICE, OC_RSRVD_SPEC_VERSION, specVersion));
VERIFY_SUCCESS(OCSetPropertyValue(PAYLOAD_TYPE_DEVICE, OC_RSRVD_DATA_MODEL_VERSION,
dataModelVersions));
+ VERIFY_SUCCESS(OCSetPropertyValue(PAYLOAD_TYPE_DEVICE, OC_RSRVD_PROTOCOL_INDEPENDENT_ID,
+ protocolIndependentID));
OIC_LOG(INFO, TAG, "Device information initialized successfully.");
return OC_STACK_OK;
OIC_LOG(INFO, TAG, "Device Registration failed!");
exit (EXIT_FAILURE);
}
-
+
/*
* Declare and create the example resource: Light
*/
const char *operatingSystemVersion = "myOS";
const char *hardwareVersion = "myHardwareVersion";
const char *platformID = "0A3E0D6F-DBF5-404E-8719-D6880042463A";
+const char *protocolIndependentID = "45a908e9-c06c-4935-b2dd-4195da863a11";
const char *manufacturerLink = "https://www.iotivity.org";
const char *modelNumber = "myModelNumber";
const char *platformVersion = "myPlatformVersion";
VERIFY_SUCCESS(OCSetPropertyValue(PAYLOAD_TYPE_DEVICE, OC_RSRVD_SPEC_VERSION, specVersion));
VERIFY_SUCCESS(OCSetPropertyValue(PAYLOAD_TYPE_DEVICE, OC_RSRVD_DATA_MODEL_VERSION,
dataModelVersions));
+ VERIFY_SUCCESS(OCSetPropertyValue(PAYLOAD_TYPE_DEVICE, OC_RSRVD_PROTOCOL_INDEPENDENT_ID,
+ protocolIndependentID));
OIC_LOG(INFO, TAG, "Device information initialized successfully.");
return OC_STACK_OK;
std::string deviceName = "Bill's Battlestar";
std::string specVersion = "core.1.1.0";
std::vector<std::string> dataModelVersions = {"res.1.1.0", "sh.1.1.0"};
+std::string protocolIndependentID = "4cae60c1-48cb-47dc-882e-dedec114f45c";
// Device type
std::string deviceType = "oic.d.tv";
return result;
}
+ result = OCPlatform::setPropertyValue(PAYLOAD_TYPE_DEVICE, OC_RSRVD_PROTOCOL_INDEPENDENT_ID,
+ protocolIndependentID);
+ if (result != OC_STACK_OK)
+ {
+ std::cout << "Failed to set piid" << std::endl;
+ return result;
+ }
+
return OC_STACK_OK;
}
std::string deviceName = "IoTivity Fridge Server";
std::string specVersion = "core.1.1.0";
std::vector<std::string> dataModelVersions = {"res.1.1.0"};
+std::string protocolIndependentID = "054718eb-b1e7-4e9e-9892-30e718a6a8f3";
// OCPlatformInfo Contains all the platform info to be stored
OCPlatformInfo platformInfo;
return result;
}
+ result = OCPlatform::setPropertyValue(PAYLOAD_TYPE_DEVICE, OC_RSRVD_PROTOCOL_INDEPENDENT_ID,
+ protocolIndependentID);
+ if (result != OC_STACK_OK)
+ {
+ std::cout << "Failed to set piid" << std::endl;
+ return result;
+ }
+
return OC_STACK_OK;
}
std::string deviceName = "IoTivity Garage Server";
std::string specVersion = "core.1.1.0";
std::vector<std::string> dataModelVersions = {"res.1.1.0"};
+std::string protocolIndependentID = "1cbab786-ca5f-4eb9-89b2-e90eb4820145";
// OCPlatformInfo Contains all the platform info to be stored
OCPlatformInfo platformInfo;
return result;
}
+ result = OCPlatform::setPropertyValue(PAYLOAD_TYPE_DEVICE, OC_RSRVD_PROTOCOL_INDEPENDENT_ID,
+ protocolIndependentID);
+ if (result != OC_STACK_OK)
+ {
+ cout << "Failed to set piid" << endl;
+ return result;
+ }
+
return OC_STACK_OK;
}
}
result = SetDeviceInfo();
+
if (result != OC_STACK_OK)
{
std::cout << "Device Registration failed\n";
std::string deviceName = "IoTivity Light Server";
std::string specVersion = "core.1.1.0";
std::vector<std::string> dataModelVersions = {"res.1.1.0"};
+std::string protocolIndependentID = "b0ed9259-ec95-4ac6-8f62-241d0da02683";
// OCPlatformInfo Contains all the platform info to be stored
OCPlatformInfo platformInfo;
return result;
}
+ result = OCPlatform::setPropertyValue(PAYLOAD_TYPE_DEVICE, OC_RSRVD_PROTOCOL_INDEPENDENT_ID,
+ protocolIndependentID);
+ if (result != OC_STACK_OK)
+ {
+ cout << "Failed to set piid" << endl;
+ return result;
+ }
+
return OC_STACK_OK;
}
return result;
}
+ result = OCPlatform::setPropertyValue(PAYLOAD_TYPE_DEVICE, OC_RSRVD_PROTOCOL_INDEPENDENT_ID,
+ "9f9752ed-b4ab-4662-af22-7e541bbee2fb");
+ if (result != OC_STACK_OK)
+ {
+ cout << "Failed to set piid" << endl;
+ return result;
+ }
+
return OC_STACK_OK;
}
std::string deviceName = "IoTivity Presence Server";
std::string specVersion = "core.1.1.0";
std::vector<std::string> dataModelVersions = {"res.1.1.0"};
+std::string protocolIndependentID = "41a75d38-83c3-4b83-a794-f2174990b30b";
// OCPlatformInfo Contains all the platform info to be stored
OCPlatformInfo platformInfo;
return result;
}
+ result = OCPlatform::setPropertyValue(PAYLOAD_TYPE_DEVICE, OC_RSRVD_PROTOCOL_INDEPENDENT_ID,
+ protocolIndependentID);
+ if (result != OC_STACK_OK)
+ {
+ cout << "Failed to set piid" << endl;
+ return result;
+ }
+
return OC_STACK_OK;
}
}
result = SetDeviceInfo();
+
if (result != OC_STACK_OK)
{
std::cout << "Device Registration failed\n";
std::string deviceName = "IoTivity Room Server";
std::string specVersion = "core.1.1.0";
std::vector<std::string> dataModelVersions = {"res.1.1.0"};
+std::string protocolIndependentID = "ac1b42a7-0518-448f-9b11-bfe328837bbf";
// OCPlatformInfo Contains all the platform info to be stored
OCPlatformInfo platformInfo;
return result;
}
+ result = OCPlatform::setPropertyValue(PAYLOAD_TYPE_DEVICE, OC_RSRVD_PROTOCOL_INDEPENDENT_ID,
+ protocolIndependentID);
+ if (result != OC_STACK_OK)
+ {
+ cout << "Failed to set piid" << endl;
+ return result;
+ }
+
return OC_STACK_OK;
}
std::string deviceType = "oic.wk.tv";
std::string specVersion = "core.1.1.0";
std::vector<std::string> dataModelVersions = {"res.1.1.0", "sh.1.1.0"};
+std::string protocolIndependentID = "fa008167-3bbf-4c9d-8604-c9bcb96cb712";
// OCPlatformInfo Contains all the platform info to be stored
OCPlatformInfo platformInfo;
return result;
}
+ result = OCPlatform::setPropertyValue(PAYLOAD_TYPE_DEVICE, OC_RSRVD_PROTOCOL_INDEPENDENT_ID,
+ protocolIndependentID);
+ if (result != OC_STACK_OK)
+ {
+ cout << "Failed to set piid" << endl;
+ return result;
+ }
+
return OC_STACK_OK;
}
}
result = SetDeviceInfo();
+
if (result != OC_STACK_OK)
{
std::cout << "Device Registration failed\n";
std::string deviceName = "IoTivity Simple Server HQ";
std::string specVersion = "core.1.1.0";
std::vector<std::string> dataModelVersions = {"res.1.1.0"};
+std::string protocolIndependentID = "88b3584f-d7bc-4e56-9210-0e8b305202c3";
// OCPlatformInfo Contains all the platform info to be stored
OCPlatformInfo platformInfo;
return result;
}
+ result = OCPlatform::setPropertyValue(PAYLOAD_TYPE_DEVICE, OC_RSRVD_PROTOCOL_INDEPENDENT_ID,
+ protocolIndependentID);
+ if (result != OC_STACK_OK)
+ {
+ cout << "Failed to set piid" << endl;
+ return result;
+ }
+
return OC_STACK_OK;
}
}
result = SetDeviceInfo();
+
if (result != OC_STACK_OK)
{
std::cout << "Device Registration failed\n";
OCDeviceInfo deviceInfo;
DuplicateString(&deviceInfo.deviceName, "myDeviceName");
deviceInfo.types = NULL;
- OCResourcePayloadAddStringLL(&deviceInfo.types, "oic.wk.d");
+ OCResourcePayloadAddStringLL(&deviceInfo.types, OC_RSRVD_RESOURCE_TYPE_DEVICE);
OCResourcePayloadAddStringLL(&deviceInfo.types, "oic.d.tv");
DuplicateString(&deviceInfo.specVersion, "mySpecVersion");
deviceInfo.dataModelVersions = nullptr;
OCResourcePayloadAddStringLL(&deviceInfo.dataModelVersions, "myDataModelVersions");
EXPECT_EQ(OC_STACK_OK, OCPlatform::registerDeviceInfo(deviceInfo));
+ EXPECT_EQ(OC_STACK_OK, OCPlatform::setPropertyValue(
+ PAYLOAD_TYPE_DEVICE, OC_RSRVD_PROTOCOL_INDEPENDENT_ID,
+ "bda0e016-fe64-41dc-871e-c7e94cc143b9"));
EXPECT_NO_THROW(DeleteDeviceInfo(deviceInfo));
}
dmv.push_back("myDataModelVersions");
EXPECT_EQ(OC_STACK_OK, OCPlatform::setPropertyValue(PAYLOAD_TYPE_DEVICE, OC_RSRVD_DATA_MODEL_VERSION,
dmv));
+ EXPECT_EQ(OC_STACK_OK, OCPlatform::setPropertyValue(PAYLOAD_TYPE_DEVICE, OC_RSRVD_PROTOCOL_INDEPENDENT_ID,
+ "99a74220-73d3-426f-8397-3c06d586a865"));
OCResourceHandle handle = OCGetResourceHandleAtUri(OC_RSRVD_DEVICE_URI);
ASSERT_TRUE(NULL != handle);
EXPECT_EQ(OC_STACK_OK, OCBindResourceTypeToResource(handle, "oic.wk.tv"));
TEST(DeviceDiscoveryEncoding, Normal)
{
sid1 = OCGetServerInstanceIDString();
+ static const char piid1[] = "e987b8f5-527a-454e-98c1-1eef2e5f1cf5";
const char devicename1[] = "device name";
OCRepPayload *device = OCRepPayloadCreate();
EXPECT_TRUE(device);
EXPECT_TRUE(OCRepPayloadSetPropString(device, OC_RSRVD_DEVICE_ID, sid1));
EXPECT_TRUE(OCRepPayloadSetPropString(device, OC_RSRVD_DEVICE_NAME, devicename1));
EXPECT_TRUE(OCRepPayloadSetPropString(device, OC_RSRVD_SPEC_VERSION, OC_SPEC_VERSION));
+ EXPECT_TRUE(OCRepPayloadSetPropString(device, OC_RSRVD_PROTOCOL_INDEPENDENT_ID, piid1));
EXPECT_TRUE(OCRepPayloadSetPropString(device, "x.org.iotivity.newproperty", "value"));
size_t dim[MAX_REP_ARRAY_DEPTH] = {1, 0, 0};
EXPECT_TRUE(OCRepPayloadGetPropString(parsedRep, OC_RSRVD_DEVICE_ID, &value));
EXPECT_STREQ(sid1, value);
OICFree(value);
+ EXPECT_TRUE(OCRepPayloadGetPropString(parsedRep, OC_RSRVD_PROTOCOL_INDEPENDENT_ID, &value));
+ EXPECT_STREQ(piid1, value);
+ OICFree(value);
EXPECT_TRUE(OCRepPayloadGetPropString(parsedRep, OC_RSRVD_DEVICE_NAME, &value));
EXPECT_STREQ(devicename1, value);
OICFree(value);
EXPECT_STREQ(OC_DATA_MODEL_VERSION, dmv[0]);
OICFree(dmv[0]);
OICFree(dmv);
- EXPECT_STREQ("oic.wk.d", parsedRep->types->value);
+ EXPECT_STREQ(OC_RSRVD_RESOURCE_TYPE_DEVICE, parsedRep->types->value);
EXPECT_STREQ("oic.d.tv", parsedRep->types->next->value);
EXPECT_EQ(device->base.type, parsedRep->base.type);
EXPECT_TRUE(OCRepPayloadAddResourceType(device, "oic.d.tv"));
EXPECT_TRUE(OCRepPayloadSetPropString(device, OC_RSRVD_DEVICE_NAME, devicename1));
EXPECT_TRUE(OCRepPayloadSetPropString(device, OC_RSRVD_DEVICE_ID, sid1));
+ EXPECT_TRUE(OCRepPayloadSetPropString(device, OC_RSRVD_PROTOCOL_INDEPENDENT_ID, piid1));
EXPECT_TRUE(OCRepPayloadSetPropString(device, OC_RSRVD_SPEC_VERSION, OC_SPEC_VERSION));
size_t dim1[MAX_REP_ARRAY_DEPTH] = {2, 0, 0};
char **dt1 = (char **)OICMalloc(sizeof(char *) * 2);
{
try
{
- SimulatorManager::getInstance()->setDeviceInfo("IoTivity Simulator Linux Sample");
+ SimulatorManager::getInstance()->setDeviceInfo("IoTivity Simulator Linux Sample",
+ "c49f7cba-3b3d-490b-9d3f-d4f17a3dad26");
std::cout << "Setting Device Info is successful" << std::endl;
}
catch (InvalidArgsException &e)
void setDeviceInfo(const std::string &deviceName);
/**
+ * API for registering device information with stack.
+ *
+ * @param deviceName - Device name to be registered.
+ * @param protocolIndependentID - Protocol-independent UUID to be registered.
+ *
+ * NOTE: API throws @InvalidArgsException and @SimulatorException on error.
+ */
+ void setDeviceInfo(const std::string &deviceName, const std::string &protocolIndependentID);
+
+ /**
* API for getting platform information from remote device.
* Received platform information will be notified through the callback set using
* @callback parameter.
}
JNIEXPORT void JNICALL
+Java_org_oic_simulator_SimulatorManager_nativeSetDeviceInfo2
+(JNIEnv *env, jobject /*object*/, jstring jDeviceName, jstring jProtocolIndependentID)
+{
+ VALIDATE_INPUT(env, !jDeviceName, "Device name is null!")
+
+ try
+ {
+ JniString jniDeviceName(env, jDeviceName);
+ JniString jniProtocolIndependentID(env, jProtocolIndependentID);
+ SimulatorManager::getInstance()->setDeviceInfo(jniDeviceName.get(), jniProtocolIndependentID.get());
+ }
+ catch (InvalidArgsException &e)
+ {
+ ThrowInvalidArgsException(env, e.code(), e.what());
+ }
+ catch (SimulatorException &e)
+ {
+ ThrowSimulatorException(env, e.code(), e.what());
+ }
+}
+
+JNIEXPORT void JNICALL
Java_org_oic_simulator_SimulatorManager_nativeFindDevices
(JNIEnv *env, jobject /*object*/, jstring jHostUri, jobject jListener)
{
/**
* API to set the device information.
*
+ * @deprecated Use setDeviceInfo2 instead.
+ *
* @param deviceInfo
* Device information.
*
}
/**
+ * API to set the device information.
+ *
+ * @param deviceInfo
+ * Device information.
+ * @param protocolIndependentID
+ * Protocol-independent UUID of the device.
+ *
+ * @throws InvalidArgsException
+ * Thrown if the input parameter is empty.
+ * @throws SimulatorException
+ * Thrown for other errors.
+ */
+ public static void setDeviceInfo2(String deviceInfo, String protocolIndependentID)
+ throws InvalidArgsException, SimulatorException {
+ nativeSetDeviceInfo2(deviceInfo, protocolIndependentID);
+ }
+
+ /**
* API to search for devices on the given host in the network.
*
* @param hostUri
FindResourceListener listener);
private static native void nativeSetDeviceInfo(String deviceInfo);
+ private static native void nativeSetDeviceInfo2(String deviceInfo,
+ String protocolIndependentID);
private static native void nativeFindDevices(String hostUri,
DeviceListener listener);
ocDeviceInfo);
}
+void SimulatorManager::setDeviceInfo(const std::string &deviceName, const std::string &protocolIndependentID)
+{
+ setDeviceInfo(deviceName);
+
+ typedef OCStackResult (*SetPropertyValue)(OCPayloadType, const std::string&,
+ const std::string&);
+
+ invokeocplatform(static_cast<SetPropertyValue>(OC::OCPlatform::setPropertyValue),
+ PAYLOAD_TYPE_DEVICE,
+ OC_RSRVD_PROTOCOL_INDEPENDENT_ID,
+ protocolIndependentID.c_str());
+}
+
void SimulatorManager::getPlatformInfo(const std::string &host, PlatformInfoCallback callback)
{
VALIDATE_CALLBACK(callback)