{
}
+IPCAStatus OCFFramework::SetPlatformInfo(const OCPlatformInfo* pi)
+{
+ // Set platform info properties.
+ // Note: Platform ID is not set as it is automatically generated by the stack.
+
+ if (pi->manufacturerName &&
+ (OC_STACK_OK != OCPlatform::setPropertyValue(PAYLOAD_TYPE_PLATFORM,
+ OC_RSRVD_MFG_NAME,
+ pi->manufacturerName)))
+ {
+ OIC_LOG(ERROR, TAG, "Failed to set manufacturerName.");
+ return IPCA_FAIL;
+ }
+
+ if (pi->manufacturerUrl &&
+ (OC_STACK_OK != OCPlatform::setPropertyValue(PAYLOAD_TYPE_PLATFORM,
+ OC_RSRVD_MFG_URL,
+ pi->manufacturerUrl)))
+ {
+ OIC_LOG(ERROR, TAG, "Failed to set manufacturerUrl.");
+ return IPCA_FAIL;
+ }
+
+ if (pi->modelNumber &&
+ (OC_STACK_OK != OCPlatform::setPropertyValue(PAYLOAD_TYPE_PLATFORM,
+ OC_RSRVD_MODEL_NUM,
+ pi->modelNumber)))
+
+ {
+ OIC_LOG(ERROR, TAG, "Failed to set modelNumber.");
+ return IPCA_FAIL;
+ }
+
+ if (pi->dateOfManufacture &&
+ (OC_STACK_OK != OCPlatform::setPropertyValue(PAYLOAD_TYPE_PLATFORM,
+ OC_RSRVD_MFG_DATE,
+ pi->dateOfManufacture)))
+ {
+ OIC_LOG(ERROR, TAG, "Failed to set dateOfManufacture.");
+ return IPCA_FAIL;
+ }
+
+ if (pi->platformVersion &&
+ (OC_STACK_OK != OCPlatform::setPropertyValue(PAYLOAD_TYPE_PLATFORM,
+ OC_RSRVD_PLATFORM_VERSION,
+ pi->platformVersion)))
+ {
+ OIC_LOG(ERROR, TAG, "Failed to set platformVersion.");
+ return IPCA_FAIL;
+ }
+
+
+ if (pi->operatingSystemVersion &&
+ (OC_STACK_OK != OCPlatform::setPropertyValue(PAYLOAD_TYPE_PLATFORM,
+ OC_RSRVD_OS_VERSION,
+ pi->operatingSystemVersion)))
+ {
+ OIC_LOG(ERROR, TAG, "Failed to set operatingSystemVersion.");
+ return IPCA_FAIL;
+ }
+
+ if (pi->hardwareVersion &&
+ (OC_STACK_OK != OCPlatform::setPropertyValue(PAYLOAD_TYPE_PLATFORM,
+ OC_RSRVD_HARDWARE_VERSION,
+ pi->hardwareVersion)))
+ {
+ OIC_LOG(ERROR, TAG, "Failed to set hardwareVersion.");
+ return IPCA_FAIL;
+ }
+
+ if (pi->firmwareVersion &&
+ (OC_STACK_OK != OCPlatform::setPropertyValue(PAYLOAD_TYPE_PLATFORM,
+ OC_RSRVD_FIRMWARE_VERSION,
+ pi->firmwareVersion)))
+ {
+ OIC_LOG(ERROR, TAG, "Failed to set firmwareVersion.");
+ return IPCA_FAIL;
+ }
+
+ if (pi->supportUrl &&
+ (OC_STACK_OK != OCPlatform::setPropertyValue(PAYLOAD_TYPE_PLATFORM,
+ OC_RSRVD_SUPPORT_URL,
+ pi->supportUrl)))
+ {
+ OIC_LOG(ERROR, TAG, "Failed to set supportUrl.");
+ return IPCA_FAIL;
+ }
+
+ if (pi->systemTime &&
+ (OC_STACK_OK != OCPlatform::setPropertyValue(PAYLOAD_TYPE_PLATFORM,
+ OC_RSRVD_SYSTEM_TIME,
+ pi->systemTime)))
+ {
+ OIC_LOG(ERROR, TAG, "Failed to set systemTime.");
+ return IPCA_FAIL;
+ }
+
+ return IPCA_OK;
+}
+
+IPCAStatus OCFFramework::SetDeviceInfo(const OCDeviceInfo* di)
+{
+ if (di->deviceName &&
+ (OC_STACK_OK != OCPlatform::setPropertyValue(PAYLOAD_TYPE_DEVICE,
+ OC_RSRVD_DEVICE_NAME,
+ di->deviceName)))
+ {
+ OIC_LOG(ERROR, TAG, "Failed to set deviceName.");
+ return IPCA_FAIL;
+ }
+
+ std::vector<std::string> dataModelVersions;
+ OCStringLL* ver = di->dataModelVersions;
+ while (ver)
+ {
+ dataModelVersions.push_back(ver->value);
+ ver = ver->next;
+ }
+
+ if (dataModelVersions.size() &&
+ (OC_STACK_OK != OCPlatform::setPropertyValue(PAYLOAD_TYPE_DEVICE,
+ OC_RSRVD_DATA_MODEL_VERSION,
+ dataModelVersions)))
+ {
+ OIC_LOG(ERROR, TAG, "Failed to set dataModelVersions.");
+ return IPCA_FAIL;
+ }
+
+ if (di->specVersion &&
+ (OC_STACK_OK != OCPlatform::setPropertyValue(PAYLOAD_TYPE_DEVICE,
+ OC_RSRVD_SPEC_VERSION,
+ di->specVersion)))
+ {
+ OIC_LOG(ERROR, TAG, "Failed to set specVersion.");
+ return IPCA_FAIL;
+ }
+
+ return IPCA_OK;
+}
+
IPCAStatus OCFFramework::Start(const IPCAAppInfoInternal& appInfo, bool isUnitTestMode)
{
std::lock_guard<std::mutex> lock(m_startStopMutex);
// Device Info.
char deviceName[256];
char deviceSoftwareVersion[256];
- char manufacturerName[256];
+ char manufacturerName[256]; // @note: set the manufacturer name of device info ("dmn") when
+ // implemented.
OCStringLL types { nullptr, nullptr }; // no vertical resource type.
CopyStringToBufferAllowTruncate(
// Platform Info
IPCAUuid platformUUID;
- char platformId[UUID_STRING_SIZE] = { 0 };
char platformManufacturerName[256] = "";
char manufacturerUrl[256] = "";
char modelNumber[] = "";
char supportURL[] = "";
#if defined(_WIN32)
- // @todo: generate per platform UUID (e.g. using input such as hostname).
- platformUUID = {0xd9, 0x9c, 0x23, 0x50, 0xd9, 0x5e, 0x11, 0xe6,
- 0xbf, 0x26, 0xce, 0xc0, 0xc9, 0x32, 0xce, 0x01};
std::string platformName = "Microsoft";
std::string platformUrl = "http://www.microsoft.com";
#else
- platformUUID = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
- 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0};
std::string platformName = "";
std::string platformUrl = "";
#endif
CopyStringToBufferAllowTruncate(platformUrl,
manufacturerUrl, ARRAY_SIZE(manufacturerUrl));
- OCConvertUuidToString(platformUUID.uuid, platformId);
-
OCPlatformInfo platformInfo = {
- platformId,
+ nullptr, /* rely on the stack to generate the platform ID. */
platformManufacturerName,
manufacturerUrl,
modelNumber,
if (!isUnitTestMode)
{
- if (OC_STACK_OK != OCPlatform::registerPlatformInfo(platformInfo))
+ if (IPCA_OK != SetPlatformInfo(&platformInfo))
{
return IPCA_FAIL;
}
- if (OC_STACK_OK != OCPlatform::registerDeviceInfo(deviceInfo))
+
+ if (OC_STACK_OK != SetDeviceInfo(&deviceInfo))
{
return IPCA_FAIL;
}