Added registration of device info to slave
authorAndriy Gudz <a.gudz@samsung.com>
Fri, 28 Apr 2017 05:35:45 +0000 (08:35 +0300)
committerAndriy Gudz <a.gudz@samsung.com>
Fri, 28 Apr 2017 05:35:45 +0000 (08:35 +0300)
demo/iot-es/src/slave/CMakeLists.txt
demo/iot-es/src/slave/enrolleewifi.c
demo/iot-es/src/slave/register_device.cpp [new file with mode: 0644]
demo/iot-es/src/slave/register_device.h [new file with mode: 0644]

index 59b185a..a132ba1 100644 (file)
@@ -1,7 +1,7 @@
 get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME)
 project(${ProjectId})
 
-FILE(GLOB SRCS enrolleewifi.c easysetup_x.c)
+FILE(GLOB SRCS enrolleewifi.c easysetup_x.c register_device.cpp)
 
 add_executable(${PROJECT_NAME} ${SRCS})
 
index 62e71b2..9e42876 100755 (executable)
@@ -28,6 +28,8 @@
 #include <stdlib.h>
 #include <pthread.h>
 
+#include "register_device.h"
+
 #define TAG "ENROLLEE_SAMPLE"
 
 void *listeningFunc(void *);
@@ -182,6 +184,8 @@ void SetDeviceInfo()
            deviceProperty.DevConf.deviceName,
            deviceProperty.DevConf.modelNumber);
 
+    registerDeviceInfoX(deviceProperty.DevConf.deviceName, deviceProperty.DevConf.modelNumber);
+
     // Set user properties if needed
     char userValue_str[] = "user_str";
     g_userProperties.userValue_int = 0;
diff --git a/demo/iot-es/src/slave/register_device.cpp b/demo/iot-es/src/slave/register_device.cpp
new file mode 100644 (file)
index 0000000..4739af7
--- /dev/null
@@ -0,0 +1,36 @@
+/**
+ * @brief  TODO
+ * @date   Created 28.04.2017
+ * @author Created 2017 in Samsung Ukraine R&D Center (SURC) under a contract
+ *                between LLC "Samsung Electronics Ukraine Company" (Kiev, Ukraine)
+ *                and "Samsung Electronics Co", Ltd (Seoul, Republic of Korea).
+ *         Copyright: (c) Samsung Electronics Co, Ltd 2017. All rights reserved.
+ * @author Mail to: <A HREF="mailto:a.gudz@samsung.com">Andriy Gudz, a.gudz@samsung.com</A>
+ */
+
+#include <string>
+
+#include "register_device.h"
+
+#include <OCApi.h>
+#include <OCPlatform.h>
+
+void registerDeviceInfoX(char* name, char* model)
+{
+    OCDeviceInfo        devInfoAirConditioner;
+    OCStringLL          deviceType;
+    OCStringLL          deviceModel;
+
+    deviceType.value = "oic.d.airconditioner";
+    deviceType.next = NULL;
+
+    deviceModel.value = model;
+    deviceModel.next = NULL;
+
+    devInfoAirConditioner.deviceName = name;
+    devInfoAirConditioner.types = &deviceType;
+    devInfoAirConditioner.specVersion = NULL;
+    devInfoAirConditioner.dataModelVersions = &deviceModel;
+
+    OC::OCPlatform::registerDeviceInfo(devInfoAirConditioner);
+}
diff --git a/demo/iot-es/src/slave/register_device.h b/demo/iot-es/src/slave/register_device.h
new file mode 100644 (file)
index 0000000..1a789a4
--- /dev/null
@@ -0,0 +1,23 @@
+/**
+ * @brief  TODO
+ * @date   Created 28.04.2017
+ * @author Created 2017 in Samsung Ukraine R&D Center (SURC) under a contract
+ *                between LLC "Samsung Electronics Ukraine Company" (Kiev, Ukraine)
+ *                and "Samsung Electronics Co", Ltd (Seoul, Republic of Korea).
+ *         Copyright: (c) Samsung Electronics Co, Ltd 2017. All rights reserved.
+ * @author Mail to: <A HREF="mailto:a.gudz@samsung.com">Andriy Gudz, a.gudz@samsung.com</A>
+ */
+#ifndef REGISTER_DEVICE_H
+#define REGISTER_DEVICE_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void registerDeviceInfoX(char* name, char* model);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // REGISTER_DEVICE_H