summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjunkyu han <junkyu.han@samsung.com>2018-04-27 07:31:40 +0900
committerjunkyu han <junkyu.han@samsung.com>2018-04-27 07:31:40 +0900
commit0b9223b8bff109e6da245767a742ee4dcea972c2 (patch)
tree701700cac074fc1c88a2cba9dc169962e881621f
parenta0597833b0a581f6874dde22009b702ae5eebe3b (diff)
parent55f6e7a130bf77de4e6432216124584ca0e36303 (diff)
downloadrcc-0b9223b8bff109e6da245767a742ee4dcea972c2.tar.gz
rcc-0b9223b8bff109e6da245767a742ee4dcea972c2.tar.bz2
rcc-0b9223b8bff109e6da245767a742ee4dcea972c2.zip
Merge remote-tracking branch 'temp/master'
-rw-r--r--.cproject366
-rw-r--r--.exportMap5
-rw-r--r--.gitignore3
-rw-r--r--.project46
-rw-r--r--.tproject12
-rwxr-xr-xCMakeLists.txt81
-rw-r--r--LICENSE.Flora206
-rw-r--r--inc/connection_manager.h32
-rw-r--r--inc/connectivity.h164
-rw-r--r--inc/controller.h27
-rw-r--r--inc/controller_internal.h28
-rw-r--r--inc/controller_util.h30
-rw-r--r--inc/log.h101
-rwxr-xr-xinc/resource.h43
-rw-r--r--inc/resource/resource_PCA9685.h29
-rw-r--r--inc/resource/resource_adc_mcp3008.h30
-rw-r--r--inc/resource/resource_camera.h30
-rw-r--r--inc/resource/resource_flame_sensor.h35
-rw-r--r--inc/resource/resource_flame_sensor_internal.h31
-rw-r--r--inc/resource/resource_gas_detection_sensor.h34
-rw-r--r--inc/resource/resource_gas_detection_sensor_internal.h31
-rw-r--r--inc/resource/resource_illuminance_sensor.h35
-rw-r--r--inc/resource/resource_illuminance_sensor_internal.h31
-rw-r--r--inc/resource/resource_infrared_motion_sensor.h34
-rw-r--r--inc/resource/resource_infrared_motion_sensor_internal.h31
-rw-r--r--inc/resource/resource_infrared_obstacle_avoidance_sensor.h34
-rw-r--r--inc/resource/resource_infrared_obstacle_avoidance_sensor_internal.h31
-rw-r--r--inc/resource/resource_led.h27
-rw-r--r--inc/resource/resource_led_internal.h27
-rw-r--r--inc/resource/resource_motor_driver_L298N.h82
-rw-r--r--inc/resource/resource_motor_driver_L298N_internal.h25
-rwxr-xr-xinc/resource/resource_rain_sensor.h35
-rwxr-xr-xinc/resource/resource_rain_sensor_internal.h31
-rw-r--r--inc/resource/resource_servo_motor.h36
-rw-r--r--inc/resource/resource_servo_motor_internal.h25
-rw-r--r--inc/resource/resource_sound_detection_sensor.h35
-rw-r--r--inc/resource/resource_sound_detection_sensor_internal.h31
-rw-r--r--inc/resource/resource_sound_level_sensor.h36
-rw-r--r--inc/resource/resource_sound_level_sensor_internal.h27
-rw-r--r--inc/resource/resource_tilt_sensor.h35
-rw-r--r--inc/resource/resource_tilt_sensor_internal.h31
-rw-r--r--inc/resource/resource_touch_sensor.h34
-rw-r--r--inc/resource/resource_touch_sensor_internal.h31
-rw-r--r--inc/resource/resource_ultrasonic_sensor.h36
-rw-r--r--inc/resource/resource_ultrasonic_sensor_internal.h33
-rw-r--r--inc/resource/resource_vibration_sensor.h34
-rw-r--r--inc/resource/resource_vibration_sensor_internal.h31
-rwxr-xr-xinc/resource_internal.h62
-rw-r--r--inc/webutil.h88
-rw-r--r--org.tizen.position-finder-server.manifest5
-rw-r--r--packaging/org.tizen.position-finder-server.spec100
-rw-r--r--project_def.prop11
-rw-r--r--res/iotcon-test-svr-db-server.datbin0 -> 2733 bytes
-rw-r--r--res/pi.conf4
-rw-r--r--settings13
-rwxr-xr-xshared/res/default_icon.pngbin0 -> 57662 bytes
-rw-r--r--src/connection_manager.c206
-rw-r--r--src/connectivity.c1272
-rw-r--r--src/controller.c216
-rw-r--r--src/controller_internal.c47
-rw-r--r--src/controller_util.c144
-rw-r--r--src/resource.c46
-rw-r--r--src/resource/resource_PCA9685.c249
-rw-r--r--src/resource/resource_adc_mcp3008.c208
-rw-r--r--src/resource/resource_camera.c233
-rw-r--r--src/resource/resource_flame_sensor.c63
-rw-r--r--src/resource/resource_gas_detection_sensor.c63
-rw-r--r--src/resource/resource_illuminance_sensor.c73
-rw-r--r--src/resource/resource_infrared_motion_sensor.c58
-rw-r--r--src/resource/resource_infrared_obstacle_avoidance_sensor.c62
-rw-r--r--src/resource/resource_led.c59
-rw-r--r--src/resource/resource_motor_driver_L298N.c333
-rwxr-xr-xsrc/resource/resource_rain_sensor.c61
-rw-r--r--src/resource/resource_servo_motor.c75
-rw-r--r--src/resource/resource_sound_detection_sensor.c63
-rw-r--r--src/resource/resource_sound_level_sensor.c55
-rw-r--r--src/resource/resource_tilt_sensor.c63
-rw-r--r--src/resource/resource_touch_sensor.c62
-rw-r--r--src/resource/resource_ultrasonic_sensor.c157
-rw-r--r--src/resource/resource_vibration_sensor.c58
-rw-r--r--src/webutil.c695
-rw-r--r--tizen-manifest.xml14
-rw-r--r--tizen-manifest.xml.in18
83 files changed, 7178 insertions, 0 deletions
diff --git a/.cproject b/.cproject
new file mode 100644
index 0000000..3b6306a
--- /dev/null
+++ b/.cproject
@@ -0,0 +1,366 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
+ <storageModule moduleId="org.eclipse.cdt.core.settings">
+ <cconfiguration id="org.tizen.nativecore.config.sbi.gcc45.app.debug.1045789686">
+ <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="org.tizen.nativecore.config.sbi.gcc45.app.debug.1045789686" moduleId="org.eclipse.cdt.core.settings" name="Debug">
+ <externalSettings/>
+ <extensions>
+ <extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
+ <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.MakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.tizen.nativecore.NativeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ </extensions>
+ </storageModule>
+ <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+ <configuration artifactName="position-finder-server" buildArtefactType="org.tizen.nativecore.buildArtefactType.app" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.tizen.nativecore.buildArtefactType.app,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug" description="" errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;" id="org.tizen.nativecore.config.sbi.gcc45.app.debug.1045789686" name="Debug" parent="org.tizen.nativecore.config.sbi.gcc45.app.debug">
+ <folderInfo id="org.tizen.nativecore.config.sbi.gcc45.app.debug.1045789686." name="/" resourcePath="">
+ <toolChain id="org.tizen.nativecore.toolchain.sbi.gcc45.app.debug.294603308" name="Tizen Native Toolchain" superClass="org.tizen.nativecore.toolchain.sbi.gcc45.app.debug">
+ <targetPlatform binaryParser="org.eclipse.cdt.core.ELF" id="org.tizen.nativeide.target.sbi.gnu.platform.base.1660201476" osList="linux,win32" superClass="org.tizen.nativeide.target.sbi.gnu.platform.base"/>
+ <builder autoBuildTarget="all" buildPath="${workspace_loc:/position-finder-server}/Debug" enableAutoBuild="true" id="org.tizen.nativecore.target.sbi.gnu.builder.1226976345" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Tizen Application Builder" superClass="org.tizen.nativecore.target.sbi.gnu.builder"/>
+ <tool command="arm-linux-gnueabi-ar.exe" id="org.tizen.nativecore.tool.sbi.gnu.archiver.1457470606" name="Archiver" superClass="org.tizen.nativecore.tool.sbi.gnu.archiver"/>
+ <tool command="clang++.exe" id="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler.708136271" name="C++ Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler">
+ <option id="gnu.cpp.compiler.option.optimization.level.20646666" name="Optimization Level" superClass="gnu.cpp.compiler.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
+ <option defaultValue="gnu.cpp.compiler.debugging.level.max" id="sbi.gnu.cpp.compiler.option.debugging.level.core.1960652830" name="Debug level" superClass="sbi.gnu.cpp.compiler.option.debugging.level.core" valueType="enumerated"/>
+ <option defaultValue="false" id="sbi.gnu.cpp.compiler.option.misc.pic.core.158221433" name="-fPIC option" superClass="sbi.gnu.cpp.compiler.option.misc.pic.core" valueType="boolean"/>
+ <option id="sbi.gnu.cpp.compiler.option.934548463" superClass="sbi.gnu.cpp.compiler.option" valueType="userObjs">
+ <listOptionValue builtIn="false" value="iot-headless-4.0-device.core_llvm40.armel"/>
+ </option>
+ <option id="sbi.gnu.cpp.compiler.option.frameworks_inc.core.1078374883" superClass="sbi.gnu.cpp.compiler.option.frameworks_inc.core" valueType="includePath">
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/libxml2&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/appcore-agent&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/appfw&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/base&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ckm&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/dbus-1.0&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/device&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/dlog&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ecore-1&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/efl-1&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/eina-1&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/eina-1/eina&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/eo-1&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/fontconfig&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/freetype2&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/gio-unix-2.0&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/glib-2.0&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/harfbuzz&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/iotcon&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/json-glib-1.0&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/media&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/minizip&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/network&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/storage&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/system&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/lib/dbus-1.0/include&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/lib/glib-2.0/include&quot;"/>
+ </option>
+ <option id="sbi.gnu.cpp.compiler.option.frameworks_cflags.core.36195591" superClass="sbi.gnu.cpp.compiler.option.frameworks_cflags.core" valueType="stringList">
+ <listOptionValue builtIn="false" value="${TC_COMPILER_MISC}"/>
+ <listOptionValue builtIn="false" value="${RS_COMPILER_MISC}"/>
+ <listOptionValue builtIn="false" value=" -fPIE"/>
+ <listOptionValue builtIn="false" value="--sysroot=&quot;${SBI_SYSROOT}&quot;"/>
+ <listOptionValue builtIn="false" value="-mthumb"/>
+ </option>
+ <option id="gnu.cpp.compiler.option.include.paths.1458394978" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
+ </option>
+ <option id="sbi.gnu.cpp.compiler.option.frameworks.core.1342606927" superClass="sbi.gnu.cpp.compiler.option.frameworks.core" valueType="userObjs">
+ <listOptionValue builtIn="false" value="Native_API"/>
+ </option>
+ <option id="sbi.gnu.cpp.compiler.option.preprocessor.def.deprecation.477719209" superClass="sbi.gnu.cpp.compiler.option.preprocessor.def.deprecation" valueType="definedSymbols">
+ <listOptionValue builtIn="false" value="TIZEN_DEPRECATION"/>
+ <listOptionValue builtIn="false" value="DEPRECATION_WARNING"/>
+ <listOptionValue builtIn="false" value="_DEBUG"/>
+ </option>
+ <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1513216984" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
+ </tool>
+ <tool command="clang.exe" id="org.tizen.nativecore.tool.sbi.gnu.c.compiler.1532913853" name="C Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.c.compiler">
+ <option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.option.optimization.level.422540635" name="Optimization Level" superClass="gnu.c.compiler.option.optimization.level" valueType="enumerated"/>
+ <option defaultValue="gnu.c.debugging.level.max" id="sbi.gnu.c.compiler.option.debugging.level.core.1168079152" name="Debug level" superClass="sbi.gnu.c.compiler.option.debugging.level.core" valueType="enumerated"/>
+ <option defaultValue="false" id="sbi.gnu.c.compiler.option.misc.pic.core.233734257" name="-fPIC option" superClass="sbi.gnu.c.compiler.option.misc.pic.core" valueType="boolean"/>
+ <option id="sbi.gnu.c.compiler.option.1781474443" superClass="sbi.gnu.c.compiler.option" valueType="userObjs">
+ <listOptionValue builtIn="false" value="iot-headless-4.0-device.core_llvm40.armel"/>
+ </option>
+ <option id="sbi.gnu.c.compiler.option.frameworks_inc.core.867520754" superClass="sbi.gnu.c.compiler.option.frameworks_inc.core" valueType="includePath">
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/libxml2&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/appcore-agent&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/appfw&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/base&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ckm&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/dbus-1.0&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/device&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/dlog&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ecore-1&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/efl-1&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/eina-1&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/eina-1/eina&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/eo-1&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/fontconfig&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/freetype2&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/gio-unix-2.0&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/glib-2.0&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/harfbuzz&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/iotcon&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/json-glib-1.0&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/media&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/minizip&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/network&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/storage&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/system&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/lib/dbus-1.0/include&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/lib/glib-2.0/include&quot;"/>
+ </option>
+ <option id="sbi.gnu.c.compiler.option.frameworks_cflags.core.1905889482" superClass="sbi.gnu.c.compiler.option.frameworks_cflags.core" valueType="stringList">
+ <listOptionValue builtIn="false" value="${TC_COMPILER_MISC}"/>
+ <listOptionValue builtIn="false" value="${RS_COMPILER_MISC}"/>
+ <listOptionValue builtIn="false" value=" -fPIE"/>
+ <listOptionValue builtIn="false" value="--sysroot=&quot;${SBI_SYSROOT}&quot;"/>
+ <listOptionValue builtIn="false" value="-mthumb"/>
+ </option>
+ <option id="gnu.c.compiler.option.include.paths.627767632" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
+ </option>
+ <option id="sbi.gnu.c.compiler.option.frameworks.core.500734913" superClass="sbi.gnu.c.compiler.option.frameworks.core" valueType="userObjs">
+ <listOptionValue builtIn="false" value="Native_API"/>
+ </option>
+ <option id="sbi.gnu.c.compiler.option.preprocessor.def.symbols.deprecation.910927601" superClass="sbi.gnu.c.compiler.option.preprocessor.def.symbols.deprecation" valueType="definedSymbols">
+ <listOptionValue builtIn="false" value="TIZEN_DEPRECATION"/>
+ <listOptionValue builtIn="false" value="DEPRECATION_WARNING"/>
+ <listOptionValue builtIn="false" value="_DEBUG"/>
+ </option>
+ <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1907145943" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
+ </tool>
+ <tool id="org.tizen.nativeide.tool.sbi.gnu.c.linker.base.1879762281" name="C Linker" superClass="org.tizen.nativeide.tool.sbi.gnu.c.linker.base"/>
+ <tool command="clang++.exe" id="org.tizen.nativecore.tool.sbi.gnu.cpp.linker.728521680" name="C++ Linker" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.linker">
+ <option defaultValue="false" id="sbi.gnu.cpp.link.option.strip.1601839229" name="Omit all symbol information (-s)" superClass="sbi.gnu.cpp.link.option.strip" valueType="boolean"/>
+ <option defaultValue="false" id="sbi.gnu.cpp.linker.option.shared_flag.core.1749752936" name="Linker.Shared" superClass="sbi.gnu.cpp.linker.option.shared_flag.core" valueType="boolean"/>
+ <option defaultValue="false" id="sbi.gnu.cpp.linker.option.noundefined.core.1932509556" name="Report unresolved symbol references (-Wl,--no-undefined)" superClass="sbi.gnu.cpp.linker.option.noundefined.core" valueType="boolean"/>
+ <option id="sbi.gnu.cpp.linker.option.frameworks_lflags.core.313611520" superClass="sbi.gnu.cpp.linker.option.frameworks_lflags.core" valueType="stringList">
+ <listOptionValue builtIn="false" value="${TC_LINKER_MISC}"/>
+ <listOptionValue builtIn="false" value="${RS_LINKER_MISC}"/>
+ <listOptionValue builtIn="false" value="-pie -lpthread "/>
+ <listOptionValue builtIn="false" value="--sysroot=&quot;${SBI_SYSROOT}&quot;"/>
+ <listOptionValue builtIn="false" value="-Xlinker --version-script=&quot;${PROJ_PATH}/.exportMap&quot;"/>
+ <listOptionValue builtIn="false" value="-L&quot;${SBI_SYSROOT}/usr/lib&quot;"/>
+ <listOptionValue builtIn="false" value="$(RS_LIBRARIES)"/>
+ </option>
+ <option id="gnu.cpp.link.option.paths.1364349475" superClass="gnu.cpp.link.option.paths" valueType="libPaths">
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/lib}&quot;"/>
+ </option>
+ <inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.1247956560" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
+ <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
+ <additionalInput kind="additionalinput" paths="$(LIBS)"/>
+ </inputType>
+ </tool>
+ <tool command="#{PLATFORM_DEFAULT_GCC_PREFIX}as.exe" id="org.tizen.nativeapp.tool.sbi.gnu.assembler.base.390097790" name="Assembler" superClass="org.tizen.nativeapp.tool.sbi.gnu.assembler.base">
+ <inputType id="cdt.managedbuild.tool.gnu.assembler.input.266597646" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
+ </tool>
+ <tool id="org.tizen.nativecore.tool.fnmapgen.1277387965" name="C FN-Map Generator" superClass="org.tizen.nativecore.tool.fnmapgen"/>
+ <tool id="org.tizen.nativecore.tool.fnmapgen.cpp.1816741642" name="C++ FN-Map Generator" superClass="org.tizen.nativecore.tool.fnmapgen.cpp"/>
+ <tool id="org.tizen.nativecore.tool.ast.760099901" name="C Static Analyzer" superClass="org.tizen.nativecore.tool.ast"/>
+ <tool id="org.tizen.nativecore.tool.ast.cpp.1114967902" name="C++ Static Analyzer" superClass="org.tizen.nativecore.tool.ast.cpp"/>
+ <tool id="org.tizen.nativecore.tool.sbi.gnu.archiver.mergelib.33034600" name="Archive Generator" superClass="org.tizen.nativecore.tool.sbi.gnu.archiver.mergelib"/>
+ <tool id="org.tizen.nativecore.tool.sbi.po.compiler.1210952332" name="PO Resource Compiler" superClass="org.tizen.nativecore.tool.sbi.po.compiler"/>
+ <tool id="org.tizen.nativecore.tool.sbi.edc.compiler.535263707" name="EDC Resource Compiler" superClass="org.tizen.nativecore.tool.sbi.edc.compiler"/>
+ </toolChain>
+ </folderInfo>
+ <sourceEntries>
+ <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="inc"/>
+ <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="res"/>
+ <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="shared"/>
+ <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
+ </sourceEntries>
+ </configuration>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
+ </cconfiguration>
+ <cconfiguration id="org.tizen.nativecore.config.sbi.gcc45.app.release.179616114">
+ <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="org.tizen.nativecore.config.sbi.gcc45.app.release.179616114" moduleId="org.eclipse.cdt.core.settings" name="Release">
+ <externalSettings/>
+ <extensions>
+ <extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
+ <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.MakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.tizen.nativecore.NativeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ </extensions>
+ </storageModule>
+ <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+ <configuration artifactName="position-finder-server" buildArtefactType="org.tizen.nativecore.buildArtefactType.app" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.tizen.nativecore.buildArtefactType.app,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release" description="" errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;" id="org.tizen.nativecore.config.sbi.gcc45.app.release.179616114" name="Release" parent="org.tizen.nativecore.config.sbi.gcc45.app.release">
+ <folderInfo id="org.tizen.nativecore.config.sbi.gcc45.app.release.179616114." name="/" resourcePath="">
+ <toolChain id="org.tizen.nativecore.toolchain.sbi.gcc45.app.release.1960180000" name="Tizen Native Toolchain" superClass="org.tizen.nativecore.toolchain.sbi.gcc45.app.release">
+ <targetPlatform binaryParser="org.eclipse.cdt.core.ELF" id="org.tizen.nativeide.target.sbi.gnu.platform.base.36335377" osList="linux,win32" superClass="org.tizen.nativeide.target.sbi.gnu.platform.base"/>
+ <builder buildPath="${workspace_loc:/position-finder-server}/Release" id="org.tizen.nativecore.target.sbi.gnu.builder.170709597" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Tizen Application Builder" superClass="org.tizen.nativecore.target.sbi.gnu.builder"/>
+ <tool command="arm-linux-gnueabi-ar.exe" id="org.tizen.nativecore.tool.sbi.gnu.archiver.483829480" name="Archiver" superClass="org.tizen.nativecore.tool.sbi.gnu.archiver"/>
+ <tool command="clang++.exe" id="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler.1154516438" name="C++ Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler">
+ <option id="gnu.cpp.compiler.option.optimization.level.230736465" name="Optimization Level" superClass="gnu.cpp.compiler.option.optimization.level" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/>
+ <option defaultValue="gnu.cpp.compiler.debugging.level.none" id="sbi.gnu.cpp.compiler.option.debugging.level.core.2084363250" name="Debug level" superClass="sbi.gnu.cpp.compiler.option.debugging.level.core" valueType="enumerated"/>
+ <option defaultValue="false" id="sbi.gnu.cpp.compiler.option.misc.pic.core.756506706" name="-fPIC option" superClass="sbi.gnu.cpp.compiler.option.misc.pic.core" valueType="boolean"/>
+ <option id="sbi.gnu.cpp.compiler.option.325585089" superClass="sbi.gnu.cpp.compiler.option" valueType="userObjs">
+ <listOptionValue builtIn="false" value="iot-headless-4.0-device.core_llvm40.armel"/>
+ </option>
+ <option id="sbi.gnu.cpp.compiler.option.frameworks_inc.core.2013252591" superClass="sbi.gnu.cpp.compiler.option.frameworks_inc.core" valueType="includePath">
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/libxml2&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/appcore-agent&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/appfw&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/base&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ckm&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/dbus-1.0&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/device&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/dlog&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ecore-1&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/efl-1&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/eina-1&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/eina-1/eina&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/eo-1&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/fontconfig&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/freetype2&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/gio-unix-2.0&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/glib-2.0&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/harfbuzz&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/iotcon&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/json-glib-1.0&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/media&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/minizip&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/network&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/storage&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/system&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/lib/dbus-1.0/include&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/lib/glib-2.0/include&quot;"/>
+ </option>
+ <option id="sbi.gnu.cpp.compiler.option.frameworks_cflags.core.1390483553" superClass="sbi.gnu.cpp.compiler.option.frameworks_cflags.core" valueType="stringList">
+ <listOptionValue builtIn="false" value="${TC_COMPILER_MISC}"/>
+ <listOptionValue builtIn="false" value="${RS_COMPILER_MISC}"/>
+ <listOptionValue builtIn="false" value=" -fPIE"/>
+ <listOptionValue builtIn="false" value="--sysroot=&quot;${SBI_SYSROOT}&quot;"/>
+ <listOptionValue builtIn="false" value="-mthumb"/>
+ </option>
+ <option id="gnu.cpp.compiler.option.include.paths.149679051" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
+ </option>
+ <option id="sbi.gnu.cpp.compiler.option.frameworks.core.647412967" superClass="sbi.gnu.cpp.compiler.option.frameworks.core" valueType="userObjs">
+ <listOptionValue builtIn="false" value="Native_API"/>
+ </option>
+ <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.928267857" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
+ </tool>
+ <tool command="clang.exe" id="org.tizen.nativecore.tool.sbi.gnu.c.compiler.1875402439" name="C Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.c.compiler">
+ <option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.option.optimization.level.691761107" name="Optimization Level" superClass="gnu.c.compiler.option.optimization.level" valueType="enumerated"/>
+ <option defaultValue="gnu.c.debugging.level.none" id="sbi.gnu.c.compiler.option.debugging.level.core.1589237797" name="Debug level" superClass="sbi.gnu.c.compiler.option.debugging.level.core" valueType="enumerated"/>
+ <option defaultValue="false" id="sbi.gnu.c.compiler.option.misc.pic.core.477215069" name="-fPIC option" superClass="sbi.gnu.c.compiler.option.misc.pic.core" valueType="boolean"/>
+ <option id="sbi.gnu.c.compiler.option.1803813611" superClass="sbi.gnu.c.compiler.option" valueType="userObjs">
+ <listOptionValue builtIn="false" value="iot-headless-4.0-device.core_llvm40.armel"/>
+ </option>
+ <option id="sbi.gnu.c.compiler.option.frameworks_inc.core.1134769974" superClass="sbi.gnu.c.compiler.option.frameworks_inc.core" valueType="includePath">
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/libxml2&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/appcore-agent&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/appfw&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/base&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ckm&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/dbus-1.0&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/device&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/dlog&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/ecore-1&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/efl-1&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/eina-1&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/eina-1/eina&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/eo-1&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/fontconfig&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/freetype2&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/gio-unix-2.0&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/glib-2.0&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/harfbuzz&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/iotcon&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/json-glib-1.0&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/media&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/minizip&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/network&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/storage&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/system&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/lib/dbus-1.0/include&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/lib/glib-2.0/include&quot;"/>
+ </option>
+ <option id="sbi.gnu.c.compiler.option.frameworks_cflags.core.788842717" superClass="sbi.gnu.c.compiler.option.frameworks_cflags.core" valueType="stringList">
+ <listOptionValue builtIn="false" value="${TC_COMPILER_MISC}"/>
+ <listOptionValue builtIn="false" value="${RS_COMPILER_MISC}"/>
+ <listOptionValue builtIn="false" value=" -fPIE"/>
+ <listOptionValue builtIn="false" value="--sysroot=&quot;${SBI_SYSROOT}&quot;"/>
+ <listOptionValue builtIn="false" value="-mthumb"/>
+ </option>
+ <option id="gnu.c.compiler.option.include.paths.492129243" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
+ </option>
+ <option id="sbi.gnu.c.compiler.option.frameworks.core.439730397" superClass="sbi.gnu.c.compiler.option.frameworks.core" valueType="userObjs">
+ <listOptionValue builtIn="false" value="Native_API"/>
+ </option>
+ <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.51152716" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
+ </tool>
+ <tool id="org.tizen.nativeide.tool.sbi.gnu.c.linker.base.46235731" name="C Linker" superClass="org.tizen.nativeide.tool.sbi.gnu.c.linker.base"/>
+ <tool command="clang++.exe" id="org.tizen.nativecore.tool.sbi.gnu.cpp.linker.354653383" name="C++ Linker" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.linker">
+ <option defaultValue="true" id="sbi.gnu.cpp.link.option.strip.1608542633" name="Omit all symbol information (-s)" superClass="sbi.gnu.cpp.link.option.strip" valueType="boolean"/>
+ <option defaultValue="false" id="sbi.gnu.cpp.linker.option.shared_flag.core.1002115734" name="Linker.Shared" superClass="sbi.gnu.cpp.linker.option.shared_flag.core" valueType="boolean"/>
+ <option defaultValue="false" id="sbi.gnu.cpp.linker.option.noundefined.core.1646943805" name="Report unresolved symbol references (-Wl,--no-undefined)" superClass="sbi.gnu.cpp.linker.option.noundefined.core" valueType="boolean"/>
+ <option id="sbi.gnu.cpp.linker.option.frameworks_lflags.core.1752102952" superClass="sbi.gnu.cpp.linker.option.frameworks_lflags.core" valueType="stringList">
+ <listOptionValue builtIn="false" value="${TC_LINKER_MISC}"/>
+ <listOptionValue builtIn="false" value="${RS_LINKER_MISC}"/>
+ <listOptionValue builtIn="false" value="-pie -lpthread "/>
+ <listOptionValue builtIn="false" value="--sysroot=&quot;${SBI_SYSROOT}&quot;"/>
+ <listOptionValue builtIn="false" value="-Xlinker --version-script=&quot;${PROJ_PATH}/.exportMap&quot;"/>
+ <listOptionValue builtIn="false" value="-L&quot;${SBI_SYSROOT}/usr/lib&quot;"/>
+ <listOptionValue builtIn="false" value="$(RS_LIBRARIES)"/>
+ </option>
+ <option id="gnu.cpp.link.option.paths.1111056597" superClass="gnu.cpp.link.option.paths" valueType="libPaths">
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/lib}&quot;"/>
+ </option>
+ <inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.1683294417" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
+ <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
+ <additionalInput kind="additionalinput" paths="$(LIBS)"/>
+ </inputType>
+ </tool>
+ <tool command="#{PLATFORM_DEFAULT_GCC_PREFIX}as.exe" id="org.tizen.nativeapp.tool.sbi.gnu.assembler.base.637918110" name="Assembler" superClass="org.tizen.nativeapp.tool.sbi.gnu.assembler.base">
+ <inputType id="cdt.managedbuild.tool.gnu.assembler.input.1503931658" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
+ </tool>
+ <tool id="org.tizen.nativecore.tool.fnmapgen.1963484779" name="C FN-Map Generator" superClass="org.tizen.nativecore.tool.fnmapgen"/>
+ <tool id="org.tizen.nativecore.tool.fnmapgen.cpp.114353044" name="C++ FN-Map Generator" superClass="org.tizen.nativecore.tool.fnmapgen.cpp"/>
+ <tool id="org.tizen.nativecore.tool.ast.1594230318" name="C Static Analyzer" superClass="org.tizen.nativecore.tool.ast"/>
+ <tool id="org.tizen.nativecore.tool.ast.cpp.146849397" name="C++ Static Analyzer" superClass="org.tizen.nativecore.tool.ast.cpp"/>
+ <tool id="org.tizen.nativecore.tool.sbi.gnu.archiver.mergelib.473439920" name="Archive Generator" superClass="org.tizen.nativecore.tool.sbi.gnu.archiver.mergelib"/>
+ <tool id="org.tizen.nativecore.tool.sbi.po.compiler.457887670" name="PO Resource Compiler" superClass="org.tizen.nativecore.tool.sbi.po.compiler"/>
+ <tool id="org.tizen.nativecore.tool.sbi.edc.compiler.1741951028" name="EDC Resource Compiler" superClass="org.tizen.nativecore.tool.sbi.edc.compiler"/>
+ </toolChain>
+ </folderInfo>
+ <sourceEntries>
+ <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="inc"/>
+ <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="res"/>
+ <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="shared"/>
+ <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
+ </sourceEntries>
+ </configuration>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
+ </cconfiguration>
+ </storageModule>
+ <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+ <project id="position-finder-server.org.tizen.nativecore.target.sbi.gcc45.app.2017096501" name="Tizen Native Application" projectType="org.tizen.nativecore.target.sbi.gcc45.app"/>
+ </storageModule>
+ <storageModule moduleId="scannerConfiguration">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+ <scannerConfigBuildInfo instanceId="org.tizen.nativecore.config.sbi.gcc45.app.release.179616114">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+ </scannerConfigBuildInfo>
+ <scannerConfigBuildInfo instanceId="org.tizen.nativecore.config.sbi.gcc45.app.debug.1045789686">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+ </scannerConfigBuildInfo>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
+</cproject>
diff --git a/.exportMap b/.exportMap
new file mode 100644
index 0000000..de30516
--- /dev/null
+++ b/.exportMap
@@ -0,0 +1,5 @@
+{
+ global: main;
+ _IO_*;
+ local: *;
+};
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..3449f54
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+.vsproject
+/Debug/
+/SA_Report/
diff --git a/.project b/.project
new file mode 100644
index 0000000..47ede70
--- /dev/null
+++ b/.project
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>position-finder-server</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
+ <triggers>full,incremental,</triggers>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.cdt.core.cnature</nature>
+ <nature>org.eclipse.cdt.core.ccnature</nature>
+ <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
+ <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
+ </natures>
+ <filteredResources>
+ <filter>
+ <id>1509686595052</id>
+ <name></name>
+ <type>26</type>
+ <matcher>
+ <id>org.eclipse.ui.ide.multiFilter</id>
+ <arguments>1.0-projectRelativePath-matches-false-false-*/.tpk</arguments>
+ </matcher>
+ </filter>
+ <filter>
+ <id>1509686595057</id>
+ <name></name>
+ <type>6</type>
+ <matcher>
+ <id>org.eclipse.ui.ide.multiFilter</id>
+ <arguments>1.0-name-matches-false-false-project_def.prop</arguments>
+ </matcher>
+ </filter>
+ </filteredResources>
+</projectDescription>
diff --git a/.tproject b/.tproject
new file mode 100644
index 0000000..f857534
--- /dev/null
+++ b/.tproject
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<tproject xmlns="http://www.tizen.org/tproject">
+ <platforms>
+ <platform>
+ <name>iot-headless-4.0</name>
+ </platform>
+ </platforms>
+ <package>
+ <blacklist/>
+ <resFallback autoGen="true"/>
+ </package>
+</tproject>
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100755
index 0000000..49fd759
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,81 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(${P_NAME} C)
+
+SET(INSTALL_EXEC_PREFIX "${INSTALL_PREFIX}/bin")
+SET(CMAKE_VERBOSE_MAKEFILE 0)
+
+SET(PROJECT_ROOT_DIR "${CMAKE_SOURCE_DIR}")
+SET(PROJECT_RESOURCES_DIR "${PROJECT_ROOT_DIR}/res")
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(APP_PKGS REQUIRED
+ dlog
+ aul
+ capi-appfw-application
+ capi-appfw-service-application
+ capi-system-peripheral-io
+ ecore
+ eina
+ iotcon
+ gio-2.0
+ libcurl
+ glib-2.0
+ json-glib-1.0
+ capi-system-info
+ capi-network-connection
+ capi-media-camera
+)
+
+ADD_DEFINITIONS(-DCBOR_FILE_IN_RES="${INSTALL_RESDIR}/${CBOR_FILE}")
+ADD_DEFINITIONS(-DCBOR_FILE_IN_DATA="${INSTALL_OWNER_DATADIR}/${CBOR_FILE}")
+ADD_DEFINITIONS(-DCONF_FILE="${INSTALL_RESDIR}/${CONF_FILE}")
+
+FOREACH (flag ${APP_PKGS_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -Wall -Winline -g -fno-builtin-malloc -fPIE")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
+
+INCLUDE_DIRECTORIES(${PROJECT_ROOT_DIR}/inc)
+
+ADD_EXECUTABLE(${PROJECT_NAME}
+ ${PROJECT_ROOT_DIR}/src/controller.c
+ ${PROJECT_ROOT_DIR}/src/controller_internal.c
+ ${PROJECT_ROOT_DIR}/src/controller_util.c
+ ${PROJECT_ROOT_DIR}/src/connectivity.c
+ ${PROJECT_ROOT_DIR}/src/connection_manager.c
+ ${PROJECT_ROOT_DIR}/src/webutil.c
+ ${PROJECT_ROOT_DIR}/src/resource.c
+ ${PROJECT_ROOT_DIR}/src/resource/resource_illuminance_sensor.c
+ ${PROJECT_ROOT_DIR}/src/resource/resource_infrared_motion_sensor.c
+ ${PROJECT_ROOT_DIR}/src/resource/resource_infrared_obstacle_avoidance_sensor.c
+ ${PROJECT_ROOT_DIR}/src/resource/resource_touch_sensor.c
+ ${PROJECT_ROOT_DIR}/src/resource/resource_ultrasonic_sensor.c
+ ${PROJECT_ROOT_DIR}/src/resource/resource_led.c
+ ${PROJECT_ROOT_DIR}/src/resource/resource_vibration_sensor.c
+ ${PROJECT_ROOT_DIR}/src/resource/resource_flame_sensor.c
+ ${PROJECT_ROOT_DIR}/src/resource/resource_rain_sensor.c
+ ${PROJECT_ROOT_DIR}/src/resource/resource_sound_detection_sensor.c
+ ${PROJECT_ROOT_DIR}/src/resource/resource_tilt_sensor.c
+ ${PROJECT_ROOT_DIR}/src/resource/resource_gas_detection_sensor.c
+ ${PROJECT_ROOT_DIR}/src/resource/resource_sound_level_sensor.c
+ ${PROJECT_ROOT_DIR}/src/resource/resource_adc_mcp3008.c
+ ${PROJECT_ROOT_DIR}/src/resource/resource_camera.c
+)
+
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} -lm)
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${APP_PKGS_LDFLAGS})
+
+Message("APP_LABEL : ${APP_LABEL}")
+
+CONFIGURE_FILE(${PROJECT_ROOT_DIR}/tizen-manifest.xml.in ${ORG_PREFIX}.${PROJECT_NAME}.xml @ONLY)
+# Install
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${INSTALL_EXEC_PREFIX})
+INSTALL(FILES ${ORG_PREFIX}.${PROJECT_NAME}.xml DESTINATION ${SYS_PACKAGES_DIR})
+INSTALL(FILES ${PROJECT_ROOT_DIR}/shared/res/default_icon.png DESTINATION ${SYS_ICONS_DIR} RENAME ${PROJECT_NAME}.png)
+INSTALL(FILES ${PROJECT_ROOT_DIR}/res/${CBOR_FILE} DESTINATION ${INSTALL_RESDIR})
+INSTALL(FILES ${PROJECT_ROOT_DIR}/res/${CONF_FILE} DESTINATION ${INSTALL_RESDIR})
+
+# End of a file
diff --git a/LICENSE.Flora b/LICENSE.Flora
new file mode 100644
index 0000000..4a0af40
--- /dev/null
+++ b/LICENSE.Flora
@@ -0,0 +1,206 @@
+Flora License
+
+Version 1.1, April, 2013
+
+http://floralicense.org/license/
+
+TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+1. Definitions.
+
+"License" shall mean the terms and conditions for use, reproduction,
+and distribution as defined by Sections 1 through 9 of this document.
+
+"Licensor" shall mean the copyright owner or entity authorized by
+the copyright owner that is granting the License.
+
+"Legal Entity" shall mean the union of the acting entity and
+all other entities that control, are controlled by, or are
+under common control with that entity. For the purposes of
+this definition, "control" means (i) the power, direct or indirect,
+to cause the direction or management of such entity,
+whether by contract or otherwise, or (ii) ownership of fifty percent (50%)
+or more of the outstanding shares, or (iii) beneficial ownership of
+such entity.
+
+"You" (or "Your") shall mean an individual or Legal Entity
+exercising permissions granted by this License.
+
+"Source" form shall mean the preferred form for making modifications,
+including but not limited to software source code, documentation source,
+and configuration files.
+
+"Object" form shall mean any form resulting from mechanical
+transformation or translation of a Source form, including but
+not limited to compiled object code, generated documentation,
+and conversions to other media types.
+
+"Work" shall mean the work of authorship, whether in Source or Object form,
+made available under the License, as indicated by a copyright notice
+that is included in or attached to the work (an example is provided
+in the Appendix below).
+
+"Derivative Works" shall mean any work, whether in Source or Object form,
+that is based on (or derived from) the Work and for which the editorial
+revisions, annotations, elaborations, or other modifications represent,
+as a whole, an original work of authorship. For the purposes of this License,
+Derivative Works shall not include works that remain separable from,
+or merely link (or bind by name) to the interfaces of, the Work and
+Derivative Works thereof.
+
+"Contribution" shall mean any work of authorship, including the original
+version of the Work and any modifications or additions to that Work or
+Derivative Works thereof, that is intentionally submitted to Licensor
+for inclusion in the Work by the copyright owner or by an individual or
+Legal Entity authorized to submit on behalf of the copyright owner.
+For the purposes of this definition, "submitted" means any form of
+electronic, verbal, or written communication sent to the Licensor or
+its representatives, including but not limited to communication on
+electronic mailing lists, source code control systems, and issue
+tracking systems that are managed by, or on behalf of, the Licensor
+for the purpose of discussing and improving the Work, but excluding
+communication that is conspicuously marked or otherwise designated
+in writing by the copyright owner as "Not a Contribution."
+
+"Contributor" shall mean Licensor and any individual or Legal Entity
+on behalf of whom a Contribution has been received by Licensor and
+subsequently incorporated within the Work.
+
+"Tizen Certified Platform" shall mean a software platform that complies
+with the standards set forth in the Tizen Compliance Specification
+and passes the Tizen Compliance Tests as defined from time to time
+by the Tizen Technical Steering Group and certified by the Tizen
+Association or its designated agent.
+
+2. Grant of Copyright License. Subject to the terms and conditions of
+this License, each Contributor hereby grants to You a perpetual,
+worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+copyright license to reproduce, prepare Derivative Works of,
+publicly display, publicly perform, sublicense, and distribute the
+Work and such Derivative Works in Source or Object form.
+
+3. Grant of Patent License. Subject to the terms and conditions of
+this License, each Contributor hereby grants to You a perpetual,
+worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+(except as stated in this section) patent license to make, have made,
+use, offer to sell, sell, import, and otherwise transfer the Work
+solely as incorporated into a Tizen Certified Platform, where such
+license applies only to those patent claims licensable by such
+Contributor that are necessarily infringed by their Contribution(s)
+alone or by combination of their Contribution(s) with the Work solely
+as incorporated into a Tizen Certified Platform to which such
+Contribution(s) was submitted. If You institute patent litigation
+against any entity (including a cross-claim or counterclaim
+in a lawsuit) alleging that the Work or a Contribution incorporated
+within the Work constitutes direct or contributory patent infringement,
+then any patent licenses granted to You under this License for that
+Work shall terminate as of the date such litigation is filed.
+
+4. Redistribution. You may reproduce and distribute copies of the
+Work or Derivative Works thereof pursuant to the copyright license
+above, in any medium, with or without modifications, and in Source or
+Object form, provided that You meet the following conditions:
+
+ 1. You must give any other recipients of the Work or Derivative Works
+ a copy of this License; and
+ 2. You must cause any modified files to carry prominent notices stating
+ that You changed the files; and
+ 3. You must retain, in the Source form of any Derivative Works that
+ You distribute, all copyright, patent, trademark, and attribution
+ notices from the Source form of the Work, excluding those notices
+ that do not pertain to any part of the Derivative Works; and
+ 4. If the Work includes a "NOTICE" text file as part of its distribution,
+ then any Derivative Works that You distribute must include a readable
+ copy of the attribution notices contained within such NOTICE file,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works, in at least one of the following places:
+ within a NOTICE text file distributed as part of the Derivative Works;
+ within the Source form or documentation, if provided along with the
+ Derivative Works; or, within a display generated by the Derivative Works,
+ if and wherever such third-party notices normally appear.
+ The contents of the NOTICE file are for informational purposes only
+ and do not modify the License. You may add Your own attribution notices
+ within Derivative Works that You distribute, alongside or as an addendum
+ to the NOTICE text from the Work, provided that such additional attribution
+ notices cannot be construed as modifying the License. You may add Your own
+ copyright statement to Your modifications and may provide additional or
+ different license terms and conditions for use, reproduction, or
+ distribution of Your modifications, or for any such Derivative Works
+ as a whole, provided Your use, reproduction, and distribution of
+ the Work otherwise complies with the conditions stated in this License
+ and your own copyright statement or terms and conditions do not conflict
+ the conditions stated in the License including section 3.
+
+5. Submission of Contributions. Unless You explicitly state otherwise,
+any Contribution intentionally submitted for inclusion in the Work
+by You to the Licensor shall be under the terms and conditions of
+this License, without any additional terms or conditions.
+Notwithstanding the above, nothing herein shall supersede or modify
+the terms of any separate license agreement you may have executed
+with Licensor regarding such Contributions.
+
+6. Trademarks. This License does not grant permission to use the trade
+names, trademarks, service marks, or product names of the Licensor,
+except as required for reasonable and customary use in describing the
+origin of the Work and reproducing the content of the NOTICE file.
+
+7. Disclaimer of Warranty. Unless required by applicable law or
+agreed to in writing, Licensor provides the Work (and each
+Contributor provides its Contributions) on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+implied, including, without limitation, any warranties or conditions
+of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+PARTICULAR PURPOSE. You are solely responsible for determining the
+appropriateness of using or redistributing the Work and assume any
+risks associated with Your exercise of permissions under this License.
+
+8. Limitation of Liability. In no event and under no legal theory,
+whether in tort (including negligence), contract, or otherwise,
+unless required by applicable law (such as deliberate and grossly
+negligent acts) or agreed to in writing, shall any Contributor be
+liable to You for damages, including any direct, indirect, special,
+incidental, or consequential damages of any character arising as a
+result of this License or out of the use or inability to use the
+Work (including but not limited to damages for loss of goodwill,
+work stoppage, computer failure or malfunction, or any and all
+other commercial damages or losses), even if such Contributor
+has been advised of the possibility of such damages.
+
+9. Accepting Warranty or Additional Liability. While redistributing
+the Work or Derivative Works thereof, You may choose to offer,
+and charge a fee for, acceptance of support, warranty, indemnity,
+or other liability obligations and/or rights consistent with this
+License. However, in accepting such obligations, You may act only
+on Your own behalf and on Your sole responsibility, not on behalf
+of any other Contributor, and only if You agree to indemnify,
+defend, and hold each Contributor harmless for any liability
+incurred by, or claims asserted against, such Contributor by reason
+of your accepting any such warranty or additional liability.
+
+END OF TERMS AND CONDITIONS
+
+APPENDIX: How to apply the Flora License to your work
+
+To apply the Flora License to your work, attach the following
+boilerplate notice, with the fields enclosed by brackets "[]"
+replaced with your own identifying information. (Don't include
+the brackets!) The text should be enclosed in the appropriate
+comment syntax for the file format. We also recommend that a
+file or class name and description of purpose be included on the
+same "printed page" as the copyright notice for easier
+identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Flora License, Version 1.1 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://floralicense.org/license/
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
diff --git a/inc/connection_manager.h b/inc/connection_manager.h
new file mode 100644
index 0000000..90e5fab
--- /dev/null
+++ b/inc/connection_manager.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ * Geunsun Lee <gs86.lee@samsung.com>
+ * Eunyoung Lee <ey928.lee@samsung.com>
+ * Junkyu Han <junkyu.han@samsung.com>
+ * Jeonghoon Park <jh1979.park@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __POSITION_FINDER_CONN_MGR_H__
+#define __POSITION_FINDER_CONN_MGR_H__
+
+int connection_manager_get_ip(const char **ip);
+int connection_manager_init(void);
+int connection_manager_fini(void);
+
+#endif /* __POSITION_FINDER_CONN_MGR_H__ */
+
diff --git a/inc/connectivity.h b/inc/connectivity.h
new file mode 100644
index 0000000..f35ed6c
--- /dev/null
+++ b/inc/connectivity.h
@@ -0,0 +1,164 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ * Geunsun Lee <gs86.lee@samsung.com>
+ * Eunyoung Lee <ey928.lee@samsung.com>
+ * Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __POSITION_FINDER_CONNECTIVITY_H__
+#define __POSITION_FINDER_CONNECTIVITY_H__
+
+typedef struct _connectivity_resource connectivity_resource_s;
+
+typedef enum {
+ CONNECTIVITY_PROTOCOL_DEFAULT = 0, /* default protocol */
+ CONNECTIVITY_PROTOCOL_IOTIVITY, /* IoTvity protocol */
+ CONNECTIVITY_PROTOCOL_HTTP, /* HTTP protocol */
+ CONNECTIVITY_PROTOCOL_MAX
+} connectivity_protocol_e;
+
+/**
+ * @brief Set connectivity protocol to communicate with other devices.
+ * @param[in] protocol_type protocol type to use
+ * @return 0 on success, otherwise a negative error value
+ * @see You should set protocol before call connectivity_set_resource(),
+ * otherwise IoTvitiy protocol will be set as default.
+ */
+extern int connectivity_set_protocol(connectivity_protocol_e protocol_type);
+
+/**
+ * @brief Create connectivity resource.
+ * @param[in] path The path of the resource
+ * @param[in] type The string data to insert into the resource types (e.g. "org.tizen.light")
+ * @param[out] out_resource_info A structure containing information about connectivity resource
+ * @return 0 on success, otherwise a negative error value
+ * @see uri_path length must be less than 128.
+ * @see You must destroy resource by calling connectivity_unset_resource() if resource is no longer needed.
+ */
+extern int connectivity_set_resource(const char *path, const char *type, connectivity_resource_s **out_resource_info);
+
+/**
+ * @brief Releases all resource about connectivity.
+ * @param[in] resource_info A structure containing information about connectivity resource
+ */
+extern void connectivity_unset_resource(connectivity_resource_s *resource);
+
+/**
+ * @brief Notifies a resource's value to observed devices or clouds.
+ * @param[in] resource_info A structure containing information about connectivity resource
+ * @param[in] key A key to be sended.
+ * @param[in] value A value to be sended.
+ * @return 0 on success, otherwise a negative error value
+ * @see If key is already exists, current value will be replaced with new value.
+ */
+extern int connectivity_notify_bool(connectivity_resource_s *resource_info, const char *key, bool value);
+
+/**
+ * @brief Notifies a resource's value to observed devices or clouds.
+ * @param[in] resource_info A structure containing information about connectivity resource
+ * @param[in] key A key to be sended.
+ * @param[in] value A value to be sended.
+ * @return 0 on success, otherwise a negative error value
+ * @see If key is already exists, current value will be replaced with new value.
+ */
+extern int connectivity_notify_int(connectivity_resource_s *resource_info, const char *key, int value);
+
+/**
+ * @brief Notifies a resource's value to observed devices or clouds.
+ * @param[in] resource_info A structure containing information about connectivity resource
+ * @param[in] key A key to be sended.
+ * @param[in] value A value to be sended.
+ * @return 0 on success, otherwise a negative error value
+ * @see If key is already exists, current value will be replaced with new value.
+ */
+extern int connectivity_notify_double(connectivity_resource_s *resource_info, const char *key, double value);
+
+/**
+ * @brief Notifies a resource's value to observed devices or clouds.
+ * @param[in] resource_info A structure containing information about connectivity resource
+ * @param[in] key A key to be sended.
+ * @param[in] value A value to be sended.
+ * @return 0 on success, otherwise a negative error value
+ * @see If key is already exists, current value will be replaced with new value.
+ */
+extern int connectivity_notify_string(connectivity_resource_s *resource_info, const char *key, const char *value);
+
+/* TODO : add comments for these functions */
+/**
+ * @brief Add a boolean type value to attributes for notifying to observed devices or clouds.
+ * @param[in] resource_info A structure containing information about connectivity resource
+ * @param[in] key A key to be sended.
+ * @param[in] value A value to be added.
+ * @return 0 on success, otherwise a negative error value
+ * @see If key is already exists, current value will be replaced with new value.
+ */
+extern int connectivity_attributes_add_bool(connectivity_resource_s *resource_info, const char *key, bool value);
+
+/**
+ * @brief Add a integer type value to attributes for notifying to observed devices or clouds.
+ * @param[in] resource_info A structure containing information about connectivity resource
+ * @param[in] key A key to be sended.
+ * @param[in] value A value to be added.
+ * @return 0 on success, otherwise a negative error value
+ * @see If key is already exists, current value will be replaced with new value.
+ */
+extern int connectivity_attributes_add_int(connectivity_resource_s *resource_info, const char *key, int value);
+
+/**
+ * @brief Add a double type value to attributes for notifying to observed devices or clouds.
+ * @param[in] resource_info A structure containing information about connectivity resource
+ * @param[in] key A key to be sended.
+ * @param[in] value A value to be added.
+ * @return 0 on success, otherwise a negative error value
+ * @see If key is already exists, current value will be replaced with new value.
+ */
+extern int connectivity_attributes_add_double(connectivity_resource_s *resource_info, const char *key, double value);
+
+/**
+ * @brief Add a string value to attributes for notifying to observed devices or clouds.
+ * @param[in] resource_info A structure containing information about connectivity resource
+ * @param[in] key A key to be sended.
+ * @param[in] value A value to be added.
+ * @return 0 on success, otherwise a negative error value
+ * @see If key is already exists, current value will be replaced with new value.
+ */
+extern int connectivity_attributes_add_string(connectivity_resource_s *resource_info, const char *key, const char *value);
+
+/**
+ * @brief Notifies values in the attributs to observed devices or clouds.
+ * @param[in] resource_info A structure containing information about connectivity resource
+ * @return 0 on success, otherwise a negative error value
+ */
+extern int connectivity_attributes_notify_all(connectivity_resource_s *resource_info);
+
+/**
+ * @brief Remove a value from attributes for notifying to observed devices or clouds.
+ * @param[in] resource_info A structure containing information about connectivity resource
+ * @param[in] key A key to be sended.
+ * @return 0 on success, otherwise a negative error value
+ * @see If key is already exists, current value will be replaced with new value.
+ */
+extern int connectivity_attributes_remove_value_by_key(connectivity_resource_s *resource_info, const char *key);
+
+/**
+ * @brief Remove all values from attributes for notifying to observed devices or clouds.
+ * @param[in] resource_info A structure containing information about connectivity resource
+ * @return 0 on success, otherwise a negative error value
+ */
+extern int connectivity_attributes_remove_all(connectivity_resource_s *resource_info);
+
+#endif /* __POSITION_FINDER_CONNECTIVITY_H__ */
diff --git a/inc/controller.h b/inc/controller.h
new file mode 100644
index 0000000..890735b
--- /dev/null
+++ b/inc/controller.h
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ * Geunsun Lee <gs86.lee@samsung.com>
+ * Eunyoung Lee <ey928.lee@samsung.com>
+ * Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __POSITION_FINDER_CONTROLLER_H__
+#define __POSITION_FINDER_CONTROLLER_H__
+
+#include "controller_internal.h"
+
+#endif /* __POSITION_FINDER_CONTROLLER_H__ */
diff --git a/inc/controller_internal.h b/inc/controller_internal.h
new file mode 100644
index 0000000..516266d
--- /dev/null
+++ b/inc/controller_internal.h
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ * Geunsun Lee <gs86.lee@samsung.com>
+ * Eunyoung Lee <ey928.lee@samsung.com>
+ * Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __POSITION_FINDER_CONTROLLER_INTERNAL_H__
+#define __POSITION_FINDER_CONTROLLER_INTERNAL_H__
+
+extern void controller_init_internal_functions(void);
+extern void controller_fini_internal_functions(void);
+
+#endif /* __POSITION_FINDER_CONTROLLER_INTERNAL_H__ */
diff --git a/inc/controller_util.h b/inc/controller_util.h
new file mode 100644
index 0000000..f36973a
--- /dev/null
+++ b/inc/controller_util.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ * Geunsun Lee <gs86.lee@samsung.com>
+ * Eunyoung Lee <ey928.lee@samsung.com>
+ * Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __POSITION_FINDER_CONTROLLER_UTIL_H__
+#define __POSITION_FINDER_CONTROLLER_UTIL_H__
+
+int controller_util_get_path(const char **path);
+int controller_util_get_address(const char **address);
+int controller_util_get_image_address(const char **image_upload);
+void controller_util_free(void);
+
+#endif /* __POSITION_FINDER_CONTROLLER_UTIL_H__ */
diff --git a/inc/log.h b/inc/log.h
new file mode 100644
index 0000000..e6ff608
--- /dev/null
+++ b/inc/log.h
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ * Geunsun Lee <gs86.lee@samsung.com>
+ * Eunyoung Lee <ey928.lee@samsung.com>
+ * Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __POSITION_FINDER_SERVER_H__
+#define __POSITION_FINDER_SERVER_H__
+
+#include <dlog.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "POSITION_FINDER_SERVER"
+
+#if !defined(_D)
+#define _D(fmt, arg...) dlog_print(DLOG_DEBUG, LOG_TAG, "[%s:%d] " fmt "\n", __func__, __LINE__, ##arg)
+#endif
+
+#if !defined(_I)
+#define _I(fmt, arg...) dlog_print(DLOG_INFO, LOG_TAG, "[%s:%d] " fmt "\n", __func__, __LINE__, ##arg)
+#endif
+
+#if !defined(_W)
+#define _W(fmt, arg...) dlog_print(DLOG_WARN, LOG_TAG, "[%s:%d] " fmt "\n", __func__, __LINE__, ##arg)
+#endif
+
+#if !defined(_E)
+#define _E(fmt, arg...) dlog_print(DLOG_ERROR, LOG_TAG, "[%s:%d] " fmt "\n", __func__, __LINE__, ##arg)
+#endif
+
+#define retvm_if(expr, val, fmt, arg...) do { \
+ if (expr) { \
+ _E(fmt, ##arg); \
+ _E("(%s) -> %s() return", #expr, __FUNCTION__); \
+ return val; \
+ } \
+} while (0)
+
+#define retv_if(expr, val) do { \
+ if (expr) { \
+ _E("(%s) -> %s() return", #expr, __FUNCTION__); \
+ return (val); \
+ } \
+} while (0)
+
+#define retm_if(expr, fmt, arg...) do { \
+ if (expr) { \
+ _E(fmt, ##arg); \
+ _E("(%s) -> %s() return", #expr, __FUNCTION__); \
+ return; \
+ } \
+} while (0)
+
+#define ret_if(expr) do { \
+ if (expr) { \
+ _E("(%s) -> %s() return", #expr, __FUNCTION__); \
+ return; \
+ } \
+} while (0)
+
+#define goto_if(expr, val) do { \
+ if (expr) { \
+ _E("(%s) -> goto", #expr); \
+ goto val; \
+ } \
+} while (0)
+
+#define break_if(expr) { \
+ if (expr) { \
+ _E("(%s) -> break", #expr); \
+ break; \
+ } \
+}
+
+#define continue_if(expr) { \
+ if (expr) { \
+ _E("(%s) -> continue", #expr); \
+ continue; \
+ } \
+}
+
+
+
+#endif /* __POSITION_FINDER_SERVER_H__ */
diff --git a/inc/resource.h b/inc/resource.h
new file mode 100755
index 0000000..f3ffe3c
--- /dev/null
+++ b/inc/resource.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ * Geunsun Lee <gs86.lee@samsung.com>
+ * Eunyoung Lee <ey928.lee@samsung.com>
+ * Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __POSITION_FINDER_RESOURCE_H__
+#define __POSITION_FINDER_RESOURCE_H__
+
+#include <peripheral_io.h>
+
+#include "resource_internal.h"
+#include "resource/resource_illuminance_sensor.h"
+#include "resource/resource_infrared_motion_sensor.h"
+#include "resource/resource_infrared_obstacle_avoidance_sensor.h"
+#include "resource/resource_touch_sensor.h"
+#include "resource/resource_ultrasonic_sensor.h"
+#include "resource/resource_led.h"
+#include "resource/resource_vibration_sensor.h"
+#include "resource/resource_flame_sensor.h"
+#include "resource/resource_rain_sensor.h"
+#include "resource/resource_sound_detection_sensor.h"
+#include "resource/resource_tilt_sensor.h"
+#include "resource/resource_gas_detection_sensor.h"
+#include "resource/resource_sound_level_sensor.h"
+#include "resource/resource_camera.h"
+
+#endif /* __POSITION_FINDER_RESOURCE_H__ */
diff --git a/inc/resource/resource_PCA9685.h b/inc/resource/resource_PCA9685.h
new file mode 100644
index 0000000..aa45477
--- /dev/null
+++ b/inc/resource/resource_PCA9685.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jeonghoon Park <jh1979.park@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __RESOURCE_PCA9685_H__
+#define __RESOURCE_PCA9685_H__
+
+#define PCA9685_CH_MAX 15
+
+int resource_pca9685_init(unsigned int ch);
+int resource_pca9685_fini(unsigned int ch);
+int resource_pca9685_set_frequency(unsigned int freq_hz);
+int resource_pca9685_set_value_to_channel(unsigned int channel, int on, int off);
+
+#endif /* __RESOURCE_PCA9685_H__ */
diff --git a/inc/resource/resource_adc_mcp3008.h b/inc/resource/resource_adc_mcp3008.h
new file mode 100644
index 0000000..b811c67
--- /dev/null
+++ b/inc/resource/resource_adc_mcp3008.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ * Geunsun Lee <gs86.lee@samsung.com>
+ * Eunyoung Lee <ey928.lee@samsung.com>
+ * Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __POSITION_FINDER_RESOURCE_ADC_MCP3008_H__
+#define __POSITION_FINDER_RESOURCE_ADC_MCP3008_H__
+
+int resource_adc_mcp3008_init(void);
+int resource_read_adc_mcp3008(int ch_num, unsigned int *out_value);
+void resource_adc_mcp3008_fini(void);
+
+#endif /* __POSITION_FINDER_RESOURCE_ADC_MCP3008_H__ */
+
diff --git a/inc/resource/resource_camera.h b/inc/resource/resource_camera.h
new file mode 100644
index 0000000..545e9b9
--- /dev/null
+++ b/inc/resource/resource_camera.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ * Geunsun Lee <gs86.lee@samsung.com>
+ * Eunyoung Lee <ey928.lee@samsung.com>
+ * Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <camera.h>
+
+#define MAX_IMAGE_FILE_LEN 256
+#define DEFAULT_FILE_PATH "/home/owner/media"
+
+typedef void (*capture_completed_cb)(const void *image, unsigned int size, void *user_data);
+
+int resource_capture_camera(capture_completed_cb capture_completed_cb, void *data);
+void resource_close_camera(void);
diff --git a/inc/resource/resource_flame_sensor.h b/inc/resource/resource_flame_sensor.h
new file mode 100644
index 0000000..f7510a5
--- /dev/null
+++ b/inc/resource/resource_flame_sensor.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ * Geunsun Lee <gs86.lee@samsung.com>
+ * Eunyoung Lee <ey928.lee@samsung.com>
+ * Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __POSITION_FINDER_RESOURCE_FLAME_SENSOR_H__
+#define __POSITION_FINDER_RESOURCE_FLAME_SENSOR_H__
+
+/**
+ * @brief Reads the value of gpio connected flame sensor(NS-FDSM).
+ * @param[in] pin_num The number of the gpio pin connected to the flame sensor
+ * @param[out] out_value The vaule of the gpio (zero or non-zero)
+ * @return 0 on success, otherwise a negative error value
+ *
+ * @see If the gpio pin is not open, creates gpio handle before reading the value of gpio.
+ */
+extern int resource_read_flame_sensor(int pin_num, uint32_t *out_value);
+
+#endif /* __POSITION_FINDER_RESOURCE_FLAME_SENSOR_H__ */
diff --git a/inc/resource/resource_flame_sensor_internal.h b/inc/resource/resource_flame_sensor_internal.h
new file mode 100644
index 0000000..6aa8c78
--- /dev/null
+++ b/inc/resource/resource_flame_sensor_internal.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ * Geunsun Lee <gs86.lee@samsung.com>
+ * Eunyoung Lee <ey928.lee@samsung.com>
+ * Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __POSITION_FINDER_RESOURCE_FLAME_SENSOR_INTERNAL_H__
+#define __POSITION_FINDER_RESOURCE_FLAME_SENSOR_INTERNAL_H__
+
+/**
+ * @brief Releases the gpio handle and changes the gpio pin state to the close(0).
+ * @param[in] pin_num The number of the gpio pin connected to the flame sensor
+ */
+extern void resource_close_flame_sensor(int pin_num);
+
+#endif /* __POSITION_FINDER_RESOURCE_FLAME_SENSOR_INTERNAL_H__ */
diff --git a/inc/resource/resource_gas_detection_sensor.h b/inc/resource/resource_gas_detection_sensor.h
new file mode 100644
index 0000000..8aead54
--- /dev/null
+++ b/inc/resource/resource_gas_detection_sensor.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ * Geunsun Lee <gs86.lee@samsung.com>
+ * Eunyoung Lee <ey928.lee@samsung.com>
+ * Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __POSITION_FINDER_RESOURCE_GAS_DETECTION_SENSOR_H__
+#define __POSITION_FINDER_RESOURCE_GAS_DETECTION_SENSOR_H__
+
+/**
+ * @brief Reads the value of gpio connected to the gas detection sensor(fc-22).
+ * @param[in] pin_num The number of the gpio pin connected to the digital pin of gas detection sensor
+ * @param[out] out_value The value of the gpio (zero or non-zero)
+ * @return 0 on success, otherwise a negative error value
+ * @see If the gpio pin is not open, creates gpio handle before reading the value of gpio.
+ */
+extern int resource_read_gas_detection_sensor(int pin_num, uint32_t *out_value);
+
+#endif /* __POSITION_FINDER_RESOURCE_GAS_DETECTION_SENSOR_H__ */
diff --git a/inc/resource/resource_gas_detection_sensor_internal.h b/inc/resource/resource_gas_detection_sensor_internal.h
new file mode 100644
index 0000000..9a91007
--- /dev/null
+++ b/inc/resource/resource_gas_detection_sensor_internal.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ * Geunsun Lee <gs86.lee@samsung.com>
+ * Eunyoung Lee <ey928.lee@samsung.com>
+ * Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __POSITION_FINDER_RESOURCE_GAS_DETECTION_SENSOR_INTERNAL_H__
+#define __POSITION_FINDER_RESOURCE_GAS_DETECTION_SENSOR_INTERNAL_H__
+
+/**
+ * @brief Releases the gpio handle and changes the gpio pin state to the close(0).
+ * @param[in] pin_num The number of the gpio pin connected to the gas detection sensor
+ */
+extern void resource_close_gas_detection_sensor(int pin_num);
+
+#endif /* __POSITION_FINDER_RESOURCE_GAS_DETECTION_SENSOR_INTERNAL_H__ */
diff --git a/inc/resource/resource_illuminance_sensor.h b/inc/resource/resource_illuminance_sensor.h
new file mode 100644
index 0000000..b22b1cc
--- /dev/null
+++ b/inc/resource/resource_illuminance_sensor.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ * Geunsun Lee <gs86.lee@samsung.com>
+ * Eunyoung Lee <ey928.lee@samsung.com>
+ * Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __POSITION_FINDER_RESOURCE_ILLUMINANCE_SENSOR_H__
+#define __POSITION_FINDER_RESOURCE_ILLUMINANCE_SENSOR_H__
+
+/**
+ * @brief Reads the value of i2c bus connected illuminance sensor.
+ * @param[in] i2c_bus The i2c bus number that the slave device is connected
+ * @param[out] out_value The value read by the illuminance sensor
+ * @return 0 on success, otherwise a negative error value
+ * @see If the i2c bus is not open, creates i2c handle before reading data from the i2c slave device.
+ */
+extern int resource_read_illuminance_sensor(int i2c_bus, uint32_t *out_value);
+
+#endif /* __POSITION_FINDER_RESOURCE_ILLUMINANCE_SENSOR_H__ */
+
diff --git a/inc/resource/resource_illuminance_sensor_internal.h b/inc/resource/resource_illuminance_sensor_internal.h
new file mode 100644
index 0000000..3193a5b
--- /dev/null
+++ b/inc/resource/resource_illuminance_sensor_internal.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ * Geunsun Lee <gs86.lee@samsung.com>
+ * Eunyoung Lee <ey928.lee@samsung.com>
+ * Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __POSITION_FINDER_RESOURCE_ILLUMINANCE_SENSOR_INTERNAL_H__
+#define __POSITION_FINDER_RESOURCE_ILLUMINANCE_SENSOR_INTERNAL_H__
+
+/**
+ * @brief Destory the i2c handle and changes the gpio pin state to the close(0).
+ */
+extern void resource_close_illuminance_sensor(void);
+
+#endif /* __POSITION_FINDER_RESOURCE_ILLUMINANCE_SENSOR_INTERNAL_H__ */
+
diff --git a/inc/resource/resource_infrared_motion_sensor.h b/inc/resource/resource_infrared_motion_sensor.h
new file mode 100644
index 0000000..65bdda7
--- /dev/null
+++ b/inc/resource/resource_infrared_motion_sensor.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ * Geunsun Lee <gs86.lee@samsung.com>
+ * Eunyoung Lee <ey928.lee@samsung.com>
+ * Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __POSITION_FINDER_RESOURCE_INFRARED_MOTION_SENSOR_H__
+#define __POSITION_FINDER_RESOURCE_INFRARED_MOTION_SENSOR_H__
+
+/**
+ * @brief Reads the value of gpio connected infrared motion sensor(HC-SR501).
+ * @param[in] pin_num The number of the gpio pin connected to the infrared motion sensor
+ * @param[out] out_value The value of the gpio (zero or non-zero)
+ * @return 0 on success, otherwise a negative error value
+ * @see If the gpio pin is not open, creates gpio handle before reading the value of gpio.
+ */
+extern int resource_read_infrared_motion_sensor(int pin_num, uint32_t *out_value);
+
+#endif /* __POSITION_FINDER_RESOURCE_INFRARED_MOTION_SENSOR_H__ */
diff --git a/inc/resource/resource_infrared_motion_sensor_internal.h b/inc/resource/resource_infrared_motion_sensor_internal.h
new file mode 100644
index 0000000..3737e15
--- /dev/null
+++ b/inc/resource/resource_infrared_motion_sensor_internal.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ * Geunsun Lee <gs86.lee@samsung.com>
+ * Eunyoung Lee <ey928.lee@samsung.com>
+ * Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __POSITION_FINDER_RESOURCE_INFRARED_MOTION_SENSOR_INTERNAL_H__
+#define __POSITION_FINDER_RESOURCE_INFRARED_MOTION_SENSOR_INTERNAL_H__
+
+/**
+ * @brief Releases the gpio handle and changes the gpio pin state to the close(0).
+ * @param[in] pin_num The number of the gpio pin connected to the infrared motion sensor
+ */
+extern void resource_close_infrared_motion_sensor(int pin_num);
+
+#endif /* __POSITION_FINDER_RESOURCE_INFRARED_MOTION_SENSOR_INTERNAL_H__ */
diff --git a/inc/resource/resource_infrared_obstacle_avoidance_sensor.h b/inc/resource/resource_infrared_obstacle_avoidance_sensor.h
new file mode 100644
index 0000000..549b135
--- /dev/null
+++ b/inc/resource/resource_infrared_obstacle_avoidance_sensor.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ * Geunsun Lee <gs86.lee@samsung.com>
+ * Eunyoung Lee <ey928.lee@samsung.com>
+ * Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __POSITION_FINDER_RESOURCE_INFRARED_OBSTACLE_AVOIDANCE_SENSOR_H__
+#define __POSITION_FINDER_RESOURCE_INFRARED_OBSTACLE_AVOIDANCE_SENSOR_H__
+
+/**
+ * @brief Reads the value of gpio connected infrared obstacle avoidance sensor.
+ * @param[in] pin_num The number of the gpio pin connected to the infrared obstacle avoidance sensor
+ * @param[out] out_value The value of the gpio (zero or non-zero)
+ * @return 0 on success, otherwise a negative error value
+ * @see If the gpio pin is not open, creates gpio handle before reading the value of gpio.
+ */
+extern int resource_read_infrared_obstacle_avoidance_sensor(int pin_num, uint32_t *out_value);
+
+#endif /* __POSITION_FINDER_RESOURCE_INFRARED_OBSTACLE_AVOIDANCE_SENSOR_H__ */
diff --git a/inc/resource/resource_infrared_obstacle_avoidance_sensor_internal.h b/inc/resource/resource_infrared_obstacle_avoidance_sensor_internal.h
new file mode 100644
index 0000000..f52cdf1
--- /dev/null
+++ b/inc/resource/resource_infrared_obstacle_avoidance_sensor_internal.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ * Geunsun Lee <gs86.lee@samsung.com>
+ * Eunyoung Lee <ey928.lee@samsung.com>
+ * Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __POSITION_FINDER_RESOURCE_INFRARED_OBSTACLE_AVOIDANCE_SENSOR_INTERNAL_H__
+#define __POSITION_FINDER_RESOURCE_INFRARED_OBSTACLE_AVOIDANCE_SENSOR_INTERNAL_H__
+
+/**
+ * @brief Releases the gpio handle and changes the gpio pin state to the close(0).
+ * @param[in] pin_num The number of the gpio pin connected to the infrared obstacle avoidance sensor
+ */
+extern void resource_close_infrared_obstacle_avoidance_sensor(int pin_num);
+
+#endif /* __POSITION_FINDER_RESOURCE_INFRARED_OBSTACLE_AVOIDANCE_SENSOR_INTERNAL_H__ */
diff --git a/inc/resource/resource_led.h b/inc/resource/resource_led.h
new file mode 100644
index 0000000..aef79ae
--- /dev/null
+++ b/inc/resource/resource_led.h
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ * Geunsun Lee <gs86.lee@samsung.com>
+ * Eunyoung Lee <ey928.lee@samsung.com>
+ * Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __POSITION_FINDER_RESOURCE_LED_H__
+#define __POSITION_FINDER_RESOURCE_LED_H__
+
+extern int resource_write_led(int pin_num, int write_value);
+
+#endif /* __POSITION_FINDER_RESOURCE_LED_H__ */
diff --git a/inc/resource/resource_led_internal.h b/inc/resource/resource_led_internal.h
new file mode 100644
index 0000000..7073f17
--- /dev/null
+++ b/inc/resource/resource_led_internal.h
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ * Geunsun Lee <gs86.lee@samsung.com>
+ * Eunyoung Lee <ey928.lee@samsung.com>
+ * Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __POSITION_FINDER_RESOURCE_LED_INTERNAL_H__
+#define __POSITION_FINDER_RESOURCE_LED_INTERNAL_H__
+
+extern void resource_close_led(int pin_num);
+
+#endif /* __POSITION_FINDER_RESOURCE_LED_INTERNAL_H__ */
diff --git a/inc/resource/resource_motor_driver_L298N.h b/inc/resource/resource_motor_driver_L298N.h
new file mode 100644
index 0000000..1cf7bae
--- /dev/null
+++ b/inc/resource/resource_motor_driver_L298N.h
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jeonghoon Park <jh1979.park@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __RESOURCE_MOTOR_DRIVER_L298N_H__
+#define __RESOURCE_MOTOR_DRIVER_L298N_H__
+
+/**
+ * This module is sample codes to handling DC motors in Tizen platform.
+ * HW is configured with L298N(motor driver) and PCA9685(PWM controller).
+ * To control motor, we use two GPIO pins of IoT board(e.g. RPi 3) connected
+ * with L298N and a PWM channel of PCA9685 connected with L298N
+ */
+
+/* Default GPIO pins of raspberry pi 3 connected with IN pins of L298N */
+#define DEFAULT_MOTOR1_PIN1 26
+#define DEFAULT_MOTOR1_PIN2 20
+
+#define DEFAULT_MOTOR2_PIN1 19
+#define DEFAULT_MOTOR2_PIN2 16
+
+#define DEFAULT_MOTOR3_PIN1 6
+#define DEFAULT_MOTOR3_PIN2 12
+
+#define DEFAULT_MOTOR4_PIN1 22
+#define DEFAULT_MOTOR4_PIN2 23
+
+/* Default channel numbers of PCA9685 with enable pins of L298N */
+#define DEFAULT_MOTOR1_EN_CH 1
+#define DEFAULT_MOTOR2_EN_CH 2
+#define DEFAULT_MOTOR3_EN_CH 3
+#define DEFAULT_MOTOR4_EN_CH 4
+
+
+/**
+ * @brief Enumeration for motor id.
+ */
+typedef enum {
+ MOTOR_ID_1,
+ MOTOR_ID_2,
+ MOTOR_ID_3,
+ MOTOR_ID_4,
+ MOTOR_ID_MAX
+} motor_id_e;
+
+/**
+ * @param[in] id The motor id
+ * @param[in] pin1 The first pin number to control motor
+ * @param[in] pin2 The second pin number to control motor
+ * @param[in] en_ch The enable channnel number to control PWM signal
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @before resource_set_motor_driver_L298N_speed() : Optional
+ */
+int resource_set_motor_driver_L298N_configuration(motor_id_e id,
+ unsigned int pin1, unsigned int pin2, unsigned en_ch);
+
+/**
+ * @param[in] id The motor id
+ * @param[in] speed The speed to control motor, 0 to stop motor,
+ * positive value to rotate clockwise and higher value to rotate more fast
+ * negative value to rotate couterclockwise and lower value to rotate more fast
+ * @return 0 on success, otherwise a negative error value
+ * @before resource_set_motor_driver_L298N_speed() : Optional
+ */
+int resource_set_motor_driver_L298N_speed(motor_id_e id, int speed);
+
+#endif /* __RESOURCE_MOTOR_DRIVER_L298N_H__ */
diff --git a/inc/resource/resource_motor_driver_L298N_internal.h b/inc/resource/resource_motor_driver_L298N_internal.h
new file mode 100644
index 0000000..fa5beb1
--- /dev/null
+++ b/inc/resource/resource_motor_driver_L298N_internal.h
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jeonghoon Park <jh1979.park@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __RESOURCE_MOTOR_DRIVER_L298N_INTERNAL_H__
+#define __RESOURCE_MOTOR_DRIVER_L298N_INTERNAL_H__
+
+void resource_close_motor_driver_L298N(motor_id_e id);
+void resource_close_motor_driver_L298N_all(void);
+
+#endif /* __RESOURCE_MOTOR_DRIVER_L298N_INTERNAL_H__ */
diff --git a/inc/resource/resource_rain_sensor.h b/inc/resource/resource_rain_sensor.h
new file mode 100755
index 0000000..162b4a2
--- /dev/null
+++ b/inc/resource/resource_rain_sensor.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ * Geunsun Lee <gs86.lee@samsung.com>
+ * Eunyoung Lee <ey928.lee@samsung.com>
+ * Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __POSITION_FINDER_RESOURCE_RAIN_SENSOR_H__
+#define __POSITION_FINDER_RESOURCE_RAIN_SENSOR_H__
+
+/**
+ * @brief Reads the value of gpio connected rain sensor(FC-37 + YL-38).
+ * @param[in] pin_num The number of the gpio pin connected to the rain sensor
+ * @param[out] out_value The vaule of the gpio (zero or non-zero)
+ * @return 0 on success, otherwise a negative error value
+ *
+ * @see If the gpio pin is not open, creates gpio handle before reading the value of gpio.
+ */
+extern int resource_read_rain_sensor(int pin_num, uint32_t *out_value);
+
+#endif /* __POSITION_FINDER_RESOURCE_RAIN_SENSOR_H__ */
diff --git a/inc/resource/resource_rain_sensor_internal.h b/inc/resource/resource_rain_sensor_internal.h
new file mode 100755
index 0000000..a9a45ea
--- /dev/null
+++ b/inc/resource/resource_rain_sensor_internal.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ * Geunsun Lee <gs86.lee@samsung.com>
+ * Eunyoung Lee <ey928.lee@samsung.com>
+ * Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __POSITION_FINDER_RESOURCE_RAIN_SENSOR_INTERNAL_H__
+#define __POSITION_FINDER_RESOURCE_RAIN_SENSOR_INTERNAL_H__
+
+/**
+ * @brief Releases the gpio handle and changes the gpio pin state to the close(0).
+ * @param[in] pin_num The number of the gpio pin connected to the rain sensor
+ */
+extern void resource_close_rain_sensor(int pin_num);
+
+#endif /* __POSITION_FINDER_RESOURCE_RAIN_SENSOR_INTERNAL_H__ */
diff --git a/inc/resource/resource_servo_motor.h b/inc/resource/resource_servo_motor.h
new file mode 100644
index 0000000..924d6cc
--- /dev/null
+++ b/inc/resource/resource_servo_motor.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jeonghoon Park <jh1979.park@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __RESOURCE_SERVO_MOTOR_H__
+#define __RESOURCE_SERVO_MOTOR_H__
+
+/**
+ * This module is sample codes to handling Servo motors in Tizen platform.
+ * HW is configured with PCA9685(PWM controller).
+ */
+
+/**
+ * @param[in] id The motor id
+ * @param[in] value The value to control servo motor
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @remarks Must adjust servo motor with some value before use to fit your system.
+ */
+int resource_set_servo_motor_value(unsigned int motor_id, int value);
+
+#endif /* __RESOURCE_SERVO_MOTOR_H__ */
diff --git a/inc/resource/resource_servo_motor_internal.h b/inc/resource/resource_servo_motor_internal.h
new file mode 100644
index 0000000..e038390
--- /dev/null
+++ b/inc/resource/resource_servo_motor_internal.h
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jeonghoon Park <jh1979.park@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __RESOURCE_SERVO_MOTOR_INTERNAL_H__
+#define __RESOURCE_SERVO_MOTOR_INTERNAL_H__
+
+void resource_close_servo_motor(unsigned int ch);
+void resource_close_servo_motor_all(void);
+
+#endif /* __RESOURCE_SERVO_MOTOR_INTERNAL_H__ */
diff --git a/inc/resource/resource_sound_detection_sensor.h b/inc/resource/resource_sound_detection_sensor.h
new file mode 100644
index 0000000..391ee75
--- /dev/null
+++ b/inc/resource/resource_sound_detection_sensor.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ * Geunsun Lee <gs86.lee@samsung.com>
+ * Eunyoung Lee <ey928.lee@samsung.com>
+ * Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __POSITION_FINDER_RESOURCE_SOUND_DETECTION_SENSOR_H__
+#define __POSITION_FINDER_RESOURCE_SOUND_DETECTION_SENSOR_H__
+
+/**
+ * @brief Reads the value of gpio connected sound detection sensor(NS-SDSM).
+ * @param[in] pin_num The number of the gpio pin connected to the sound detection sensor
+ * @param[out] out_value The vaule of the gpio (zero or non-zero)
+ * @return 0 on success, otherwise a negative error value
+ *
+ * @see If the gpio pin is not open, creates gpio handle before reading the value of gpio.
+ */
+extern int resource_read_sound_detection_sensor(int pin_num, uint32_t *out_value);
+
+#endif /* __POSITION_FINDER_RESOURCE_SOUND_DETECTION_SENSOR_H__ */
diff --git a/inc/resource/resource_sound_detection_sensor_internal.h b/inc/resource/resource_sound_detection_sensor_internal.h
new file mode 100644
index 0000000..88b8bdc
--- /dev/null
+++ b/inc/resource/resource_sound_detection_sensor_internal.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ * Geunsun Lee <gs86.lee@samsung.com>
+ * Eunyoung Lee <ey928.lee@samsung.com>
+ * Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __POSITION_FINDER_RESOURCE_SOUND_DETECTION_SENSOR_INTERNAL_H__
+#define __POSITION_FINDER_RESOURCE_SOUND_DETECTION_SENSOR_INTERNAL_H__
+
+/**
+ * @brief Releases the gpio handle and changes the gpio pin state to the close(0).
+ * @param[in] pin_num The number of the gpio pin connected to the sound detection sensor
+ */
+extern void resource_close_sound_detection_sensor(int pin_num);
+
+#endif /* __POSITION_FINDER_RESOURCE_SOUND_DETECTION_SENSOR_INTERNAL_H__ */
diff --git a/inc/resource/resource_sound_level_sensor.h b/inc/resource/resource_sound_level_sensor.h
new file mode 100644
index 0000000..b0c64d5
--- /dev/null
+++ b/inc/resource/resource_sound_level_sensor.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ * Geunsun Lee <gs86.lee@samsung.com>
+ * Eunyoung Lee <ey928.lee@samsung.com>
+ * Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __POSITION_FINDER_RESOURCE_SOUND_LEVEL_SENSOR_H__
+#define __POSITION_FINDER_RESOURCE_SOUND_LEVEL_SENSOR_H__
+
+ /**
+ * @brief Reads the value from sound level sensor through AD converter(MCP3008).
+ * @remarks We assume that only one AD converter is connected with device.
+ * @param[in] ch_num The number of channel connected to the sound level sensor with AD converter
+ * @param[out] out_value The value of a sound level
+ * @return 0 on success, otherwise a negative error value
+ *
+ */
+extern int resource_read_sound_level_sensor(int ch_num, unsigned int *out_value);
+
+#endif /* __POSITION_FINDER_RESOURCE_SOUND_LEVEL_SENSOR_H__ */
+
diff --git a/inc/resource/resource_sound_level_sensor_internal.h b/inc/resource/resource_sound_level_sensor_internal.h
new file mode 100644
index 0000000..ccc8830
--- /dev/null
+++ b/inc/resource/resource_sound_level_sensor_internal.h
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ * Geunsun Lee <gs86.lee@samsung.com>
+ * Eunyoung Lee <ey928.lee@samsung.com>
+ * Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __POSITION_FINDER_RESOURCE_SOUND_LEVEL_SENSOR_INTERNAL_H__
+#define __POSITION_FINDER_RESOURCE_SOUND_LEVEL_SENSOR_INTERNAL_H__
+
+extern void resource_close_sound_level_sensor(void);
+
+#endif /* __POSITION_FINDER_RESOURCE_SOUND_LEVEL_SENSOR_INTERNAL_H__ */
diff --git a/inc/resource/resource_tilt_sensor.h b/inc/resource/resource_tilt_sensor.h
new file mode 100644
index 0000000..a90d07d
--- /dev/null
+++ b/inc/resource/resource_tilt_sensor.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ * Geunsun Lee <gs86.lee@samsung.com>
+ * Eunyoung Lee <ey928.lee@samsung.com>
+ * Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __POSITION_FINDER_RESOURCE_TILT_SENSOR_H__
+#define __POSITION_FINDER_RESOURCE_TILT_SENSOR_H__
+
+/**
+ * @brief Reads the value of gpio connected tilt sensor(SZH-EK084).
+ * @param[in] pin_num The number of the gpio pin connected to the tilt sensor
+ * @param[out] out_value The vaule of the gpio (zero or non-zero)
+ * @return 0 on success, otherwise a negative error value
+ *
+ * @see If the gpio pin is not open, creates gpio handle before reading the value of gpio.
+ */
+extern int resource_read_tilt_sensor(int pin_num, uint32_t *out_value);
+
+#endif /* __POSITION_FINDER_RESOURCE_TILT_SENSOR_H__ */
diff --git a/inc/resource/resource_tilt_sensor_internal.h b/inc/resource/resource_tilt_sensor_internal.h
new file mode 100644
index 0000000..4468929
--- /dev/null
+++ b/inc/resource/resource_tilt_sensor_internal.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ * Geunsun Lee <gs86.lee@samsung.com>
+ * Eunyoung Lee <ey928.lee@samsung.com>
+ * Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __POSITION_FINDER_RESOURCE_TILT_SENSOR_INTERNAL_H__
+#define __POSITION_FINDER_RESOURCE_TILT_SENSOR_INTERNAL_H__
+
+/**
+ * @brief Releases the gpio handle and changes the gpio pin state to the close(0).
+ * @param[in] pin_num The number of the gpio pin connected to the tilt sensor
+ */
+extern void resource_close_tilt_sensor(int pin_num);
+
+#endif /* __POSITION_FINDER_RESOURCE_TILT_SENSOR_INTERNAL_H__ */
diff --git a/inc/resource/resource_touch_sensor.h b/inc/resource/resource_touch_sensor.h
new file mode 100644
index 0000000..a28df3f
--- /dev/null
+++ b/inc/resource/resource_touch_sensor.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ * Geunsun Lee <gs86.lee@samsung.com>
+ * Eunyoung Lee <ey928.lee@samsung.com>
+ * Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __POSITION_FINDER_RESOURCE_TOUCH_SENSOR_H__
+#define __POSITION_FINDER_RESOURCE_TOUCH_SENSOR_H__
+
+/**
+ * @brief Reads the value of gpio connected touch sensor.
+ * @param[in] pin_num The number of the gpio pin connected to the touch sensor
+ * @param[out] out_value The value of the gpio (zero or non-zero)
+ * @return 0 on success, otherwise a negative error value
+ * @see If the gpio pin is not open, creates gpio handle before reading the value of gpio.
+ */
+extern int resource_read_touch_sensor(int pin_num, uint32_t *out_value);
+
+#endif /* __POSITION_FINDER_RESOURCE_TOUCH_SENSOR_H__ */
diff --git a/inc/resource/resource_touch_sensor_internal.h b/inc/resource/resource_touch_sensor_internal.h
new file mode 100644
index 0000000..3bde69b
--- /dev/null
+++ b/inc/resource/resource_touch_sensor_internal.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ * Geunsun Lee <gs86.lee@samsung.com>
+ * Eunyoung Lee <ey928.lee@samsung.com>
+ * Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __POSITION_FINDER_RESOURCE_TOUCH_SENSOR_INTERNAL_H__
+#define __POSITION_FINDER_RESOURCE_TOUCH_SENSOR_INTERNAL_H__
+
+/**
+ * @brief Releases the gpio handle and changes the gpio pin state to the close(0).
+ * @param[in] pin_num The number of the gpio pin connected to the touch sensor
+ */
+extern void resource_close_touch_sensor(int pin_num);
+
+#endif /* __POSITION_FINDER_RESOURCE_TOUCH_SENSOR_INTERNAL_H__ */
diff --git a/inc/resource/resource_ultrasonic_sensor.h b/inc/resource/resource_ultrasonic_sensor.h
new file mode 100644
index 0000000..cfcfe64
--- /dev/null
+++ b/inc/resource/resource_ultrasonic_sensor.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ * Geunsun Lee <gs86.lee@samsung.com>
+ * Eunyoung Lee <ey928.lee@samsung.com>
+ * Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __POSITION_FINDER_RESOURCE_ULTRASONIC_SENSOR_H__
+#define __POSITION_FINDER_RESOURCE_ULTRASONIC_SENSOR_H__
+
+/**
+ * @brief Reads the value of gpio connected ultrasonic sensor(HC-SR04).
+ * @param[in] trig_pin_num The number of the gpio pin connected to the trig of the ultrasonic sensor
+ * @param[in] echo_pin_num The number of the gpio pin connected to the echo of the ultrasonic sensor
+ * @param[in] cb A callback function to be invoked when the gpio interrupt is triggered
+ * @param[in] data The data to be passed to the callback function
+ * @return 0 on success, otherwise a negative error value
+ * @see If the gpio pin is not open, creates gpio handle before reading the value of gpio.
+ */
+extern int resource_read_ultrasonic_sensor(int trig_pin_num, int echo_pin_num, resource_read_cb cb, void *data);
+
+#endif /* __POSITION_FINDER_RESOURCE_ULTRASONIC_SENSOR_H__ */
diff --git a/inc/resource/resource_ultrasonic_sensor_internal.h b/inc/resource/resource_ultrasonic_sensor_internal.h
new file mode 100644
index 0000000..efd5436
--- /dev/null
+++ b/inc/resource/resource_ultrasonic_sensor_internal.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ * Geunsun Lee <gs86.lee@samsung.com>
+ * Eunyoung Lee <ey928.lee@samsung.com>
+ * Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __POSITION_FINDER_RESOURCE_ULTRASONIC_SENSOR_INTERNAL_H__
+#define __POSITION_FINDER_RESOURCE_ULTRASONIC_SENSOR_INTERNAL_H__
+
+/**
+ * @brief Releases the gpio handle and changes the gpio pin state to the close(0).
+ * @param[in] trig_pin_num The number of the gpio pin connected to the trig of the ultrasonic sensor
+ * @param[in] echo_pin_num The number of the gpio pin connected to the echo of the ultrasonic sensor
+ */
+extern void resource_close_ultrasonic_sensor_trig(int trig_pin_num);
+extern void resource_close_ultrasonic_sensor_echo(int echo_pin_num);
+
+#endif /* __POSITION_FINDER_RESOURCE_ULTRASONIC_SENSOR_INTERNAL_H__ */
diff --git a/inc/resource/resource_vibration_sensor.h b/inc/resource/resource_vibration_sensor.h
new file mode 100644
index 0000000..042298a
--- /dev/null
+++ b/inc/resource/resource_vibration_sensor.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ * Geunsun Lee <gs86.lee@samsung.com>
+ * Eunyoung Lee <ey928.lee@samsung.com>
+ * Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __POSITION_FINDER_RESOURCE_VIBRATION_SENSOR_H__
+#define __POSITION_FINDER_RESOURCE_VIBRATION_SENSOR_H__
+
+/**
+ * @brief Reads the value of gpio connected vibration sensor(SZH-EKAD-131).
+ * @param[in] pin_num The number of the gpio pin connected to the vibration sensor
+ * @param[out] out_value The value of the gpio (zero or non-zero)
+ * @return 0 on success, otherwise a negative error value
+ * @see If the gpio pin is not open, creates gpio handle before reading the value of gpio.
+ */
+extern int resource_read_vibration_sensor(int pin_num, uint32_t *out_value);
+
+#endif /* __POSITION_FINDER_RESOURCE_VIBRATION_SENSOR_H__ */
diff --git a/inc/resource/resource_vibration_sensor_internal.h b/inc/resource/resource_vibration_sensor_internal.h
new file mode 100644
index 0000000..61f3c2e
--- /dev/null
+++ b/inc/resource/resource_vibration_sensor_internal.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ * Geunsun Lee <gs86.lee@samsung.com>
+ * Eunyoung Lee <ey928.lee@samsung.com>
+ * Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __POSITION_FINDER_RESOURCE_VIBRATION_SENSOR_INTERNAL_H__
+#define __POSITION_FINDER_RESOURCE_VIBRATION_SENSOR_INTERNAL_H__
+
+/**
+ * @brief Releases the gpio handle and changes the gpio pin state to the close(0).
+ * @param[in] pin_num The number of the gpio pin connected to the vibration sensor
+ */
+extern void resource_close_vibration_sensor(int pin_num);
+
+#endif /* __POSITION_FINDER_RESOURCE_VIBRATION_SENSOR_INTERNAL_H__ */
diff --git a/inc/resource_internal.h b/inc/resource_internal.h
new file mode 100755
index 0000000..df99356
--- /dev/null
+++ b/inc/resource_internal.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ * Geunsun Lee <gs86.lee@samsung.com>
+ * Eunyoung Lee <ey928.lee@samsung.com>
+ * Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __POSITION_FINDER_RESOURCE_INTERNAL_H__
+#define __POSITION_FINDER_RESOURCE_INTERNAL_H__
+
+#include <peripheral_io.h>
+
+#include "resource/resource_illuminance_sensor_internal.h"
+#include "resource/resource_infrared_motion_sensor_internal.h"
+#include "resource/resource_infrared_obstacle_avoidance_sensor_internal.h"
+#include "resource/resource_touch_sensor_internal.h"
+#include "resource/resource_ultrasonic_sensor_internal.h"
+#include "resource/resource_led_internal.h"
+#include "resource/resource_vibration_sensor_internal.h"
+#include "resource/resource_flame_sensor_internal.h"
+#include "resource/resource_rain_sensor_internal.h"
+#include "resource/resource_sound_detection_sensor_internal.h"
+#include "resource/resource_tilt_sensor_internal.h"
+#include "resource/resource_gas_detection_sensor_internal.h"
+#include "resource/resource_sound_level_sensor_internal.h"
+
+#define PIN_MAX 40
+
+struct _resource_s {
+ int opened;
+ peripheral_gpio_h sensor_h;
+ void (*close) (int);
+};
+typedef struct _resource_s resource_s;
+
+typedef void (*resource_read_cb)(double value, void *data);
+
+struct _resource_read_cb_s {
+ resource_read_cb cb;
+ void *data;
+ int pin_num;
+};
+typedef struct _resource_read_cb_s resource_read_s;
+
+extern resource_s *resource_get_info(int pin_num);
+extern void resource_close_all(void);
+
+#endif /* __POSITION_FINDER_RESOURCE_INTERNAL_H__ */
diff --git a/inc/webutil.h b/inc/webutil.h
new file mode 100644
index 0000000..a229e07
--- /dev/null
+++ b/inc/webutil.h
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ * Geunsun Lee <gs86.lee@samsung.com>
+ * Eunyoung Lee <ey928.lee@samsung.com>
+ * Junkyu Han <junkyu.han@samsung.com>
+ * Jeonghoon Park <jh1979.park@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __POSITION_FINDER_WEBUTIL_H__
+#define __POSITION_FINDER_WEBUTIL_H__
+
+typedef enum {
+ WEB_UTIL_SENSOR_NONE = 0,
+ WEB_UTIL_SENSOR_MOTION = (1 << 0), /* IR motion sensor */
+ WEB_UTIL_SENSOR_FLAME = (1 << 1), /* flame sensor */
+ WEB_UTIL_SENSOR_HUMIDITY = (1 << 2), /* humidity sensor */
+ WEB_UTIL_SENSOR_TEMPERATURE = (1 << 3), /* temperature sensor */
+ WEB_UTIL_SENSOR_VIB = (1 << 4), /* vibration sensor */
+ WEB_UTIL_SENSOR_CO2 = (1 << 5), /* CO2 sensor */
+ WEB_UTIL_SENSOR_SOUND = (1 << 6), /* noise sensor */
+ WEB_UTIL_SENSOR_TILT = (1 << 7), /* tilt sensor */
+ WEB_UTIL_SENSOR_LIGHT = (1 << 8), /* light sensor */
+ WEB_UTIL_SENSOR_COLLISION = (1 << 9), /* collision sensor */
+ WEB_UTIL_SENSOR_OBSTACLE = (1 << 10), /* obstacle avoidance sensor */
+ WEB_UTIL_SENSOR_ULTRASONIC_DISTANCE = (1 << 11), /* ultrasonic distance sensor */
+ WEB_UTIL_SENSOR_RAIN = (1 << 12), /* rain sensor */
+ WEB_UTIL_SENSOR_TOUCH = (1 << 13), /* touch sensor */
+ WEB_UTIL_SENSOR_GAS = (1 << 14), /* gas sensor */
+} web_util_sensor_type_e;
+
+typedef struct _web_util_sensor_data_s web_util_sensor_data_s;
+struct _web_util_sensor_data_s {
+ int motion;
+ int flame;
+ double humidity;
+ double temperature;
+ int virbration;
+ double co2;
+ int soundlevel;
+ int tilt;
+ int light;
+ int collision;
+ int obstacle;
+ double distance;
+ int rain;
+ int touch;
+ int gas;
+ web_util_sensor_type_e enabled_sensor;
+ const char *hash;
+ const char *ip_addr;
+};
+
+int web_util_noti_init(void);
+void web_util_noti_fini(void);
+int web_util_noti_post(const char *resource, const char *json_data);
+int web_util_noti_post_image_data(const char *url, const char *device_id,
+ const void *image_data, unsigned int image_size);
+int web_util_noti_get(const char *resource, char **res);
+
+int web_util_json_init(void);
+int web_util_json_fini(void);
+int web_util_json_begin(void);
+int web_util_json_end(void);
+int web_util_json_data_array_begin(void);
+int web_util_json_data_array_end(void);
+int web_util_json_add_int(const char* key, long long int value);
+int web_util_json_add_double(const char* key, double value);
+int web_util_json_add_boolean(const char* key, bool value);
+int web_util_json_add_string(const char* key, const char *value);
+int web_util_json_add_sensor_data(const char* sensorpi_id, web_util_sensor_data_s *sensor_data);
+char *web_util_get_json_string(void);
+
+#endif /* __POSITION_FINDER_WEBUTIL_H__ */
diff --git a/org.tizen.position-finder-server.manifest b/org.tizen.position-finder-server.manifest
new file mode 100644
index 0000000..af9b883
--- /dev/null
+++ b/org.tizen.position-finder-server.manifest
@@ -0,0 +1,5 @@
+<manifest>
+ <request>
+ <domain name="_" />
+ </request>
+</manifest>
diff --git a/packaging/org.tizen.position-finder-server.spec b/packaging/org.tizen.position-finder-server.spec
new file mode 100644
index 0000000..8f50c9b
--- /dev/null
+++ b/packaging/org.tizen.position-finder-server.spec
@@ -0,0 +1,100 @@
+%define P_NAME position-finder-server
+%define APP_LABEL "Position Finder Server"
+%define ORG_PREFIX org.tizen
+
+Name: %{ORG_PREFIX}.%{P_NAME}
+%define alias %{name}
+Summary: IoTivity Application
+Group: Applications/Core Applications
+Version: 0.0.1
+Release: 1
+License: Flora-1.1
+Provides: %{name} = %{version}-%{release}
+Source0: %{name}-%{version}.tar.gz
+
+BuildRequires: cmake
+BuildRequires: hash-signer
+BuildRequires: pkgconfig(capi-appfw-application)
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(libtzplatform-config)
+BuildRequires: pkgconfig(capi-appfw-service-application)
+BuildRequires: pkgconfig(capi-system-peripheral-io)
+BuildRequires: pkgconfig(ecore)
+BuildRequires: pkgconfig(eina)
+BuildRequires: pkgconfig(iotcon)
+BuildRequires: pkgconfig(gio-2.0)
+BuildRequires: pkgconfig(libcurl)
+BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: pkgconfig(json-glib-1.0)
+BuildRequires: pkgconfig(capi-system-info)
+BuildRequires: pkgconfig(capi-network-connection)
+BuildRequires: pkgconfig(capi-media-camera)
+
+%description
+Server for Position Finder
+
+%prep
+%setup -q
+
+%build
+
+%define _pkg_dir %{TZ_SYS_RO_APP}/%{alias}
+%define _pkg_shared_dir %{_pkg_dir}/shared
+%define _pkg_data_dir %{_pkg_dir}/data
+%define _pkg_rw_data_dir /home/owner/apps_rw/%{alias}/data
+%define _pkg_res_dir %{_pkg_dir}/res
+%define _sys_icons_dir %{_pkg_shared_dir}/res
+%define _sys_packages_dir %{TZ_SYS_RO_PACKAGES}
+%define _sys_license_dir %{TZ_SYS_SHARE}/license
+%define _cbor_file iotcon-test-svr-db-server.dat
+%define _conf_file pi.conf
+
+%ifarch %{arm}
+export CFLAGS="$CFLAGS -DTIZEN_BUILD_TARGET"
+export CXXFLAGS="$CXXFLAGS -DTIZEN_BUILD_TARGET"
+export FFLAGS="$FFLAGS -DTIZEN_BUILD_TARGET"
+%else
+export CFLAGS="$CFLAGS -DTIZEN_BUILD_EMULATOR"
+export CXXFLAGS="$CXXFLAGS -DTIZEN_BUILD_EMULATOR"
+export FFLAGS="$FFLAGS -DTIZEN_BUILD_EMULATOR"
+%endif
+
+cmake . -DP_NAME=%{P_NAME} \
+ -DORG_PREFIX=%{ORG_PREFIX} \
+ -DAPP_LABEL=%{APP_LABEL} \
+ -DINSTALL_PREFIX=%{_pkg_dir} \
+ -DINSTALL_OWNER_DATADIR=%{_pkg_rw_data_dir} \
+ -DINSTALL_RESDIR=%{_pkg_res_dir} \
+ -DSYS_ICONS_DIR=%{_sys_icons_dir} \
+ -DSYS_PACKAGES_DIR=%{_sys_packages_dir} \
+ -DCBOR_FILE=%{_cbor_file} \
+ -DCONF_FILE=%{_conf_file}
+make %{?jobs:-j%jobs}
+
+%install
+%make_install
+
+%define tizen_sign 1
+%define tizen_sign_base %{_pkg_dir}
+%define tizen_sign_level platform
+%define tizen_author_sign 1
+%define tizen_dist_sign 1
+#%find_lang position-finder-server
+
+%post
+/sbin/ldconfig
+chsmack -a "User::Pkg::%{alias}" %{_pkg_res_dir}/*.dat
+chmod 444 %{_pkg_res_dir}/*.dat
+
+%postun -p /sbin/ldconfig
+
+%files
+%{_pkg_res_dir}/*.dat
+%{_pkg_res_dir}/*.conf
+%manifest %{alias}.manifest
+%defattr(-,root,root,-)
+%{_pkg_dir}/bin/%{P_NAME}
+%{_sys_packages_dir}/%{alias}.xml
+%{_sys_icons_dir}/*.png
+%{_pkg_dir}/author-signature.xml
+%{_pkg_dir}/signature1.xml
diff --git a/project_def.prop b/project_def.prop
new file mode 100644
index 0000000..9826857
--- /dev/null
+++ b/project_def.prop
@@ -0,0 +1,11 @@
+APPNAME = position-finder-server
+
+type = app
+profile = iot-headless-4.0
+
+USER_SRCS = src/position-finder-server.c
+USER_DEFS =
+USER_INC_DIRS = inc
+USER_OBJS =
+USER_LIBS =
+USER_EDCS =
diff --git a/res/iotcon-test-svr-db-server.dat b/res/iotcon-test-svr-db-server.dat
new file mode 100644
index 0000000..d508b68
--- /dev/null
+++ b/res/iotcon-test-svr-db-server.dat
Binary files differ
diff --git a/res/pi.conf b/res/pi.conf
new file mode 100644
index 0000000..b7e63e9
--- /dev/null
+++ b/res/pi.conf
@@ -0,0 +1,4 @@
+[default]
+path=sensor-pi-1
+address=http://showiot.xyz/api/tt/data
+image_address=http://test.showiot.xyz/api/image/
diff --git a/settings b/settings
new file mode 100644
index 0000000..ceacdbb
--- /dev/null
+++ b/settings
@@ -0,0 +1,13 @@
+[ethernet_b827eb0b6458_cable]
+Name=Wired
+AutoConnect=true
+Modified=2016-07-25T19:49:54.191535Z
+IPv4.method=manual
+IPv6.method=auto
+IPv6.privacy=disabled
+IPv4.DHCP.LastAddress=10.113.216.216
+Nameservers.IPv4method=dhcp
+IPv4.netmask_prefixlen=24
+IPv4.local_address=10.113.62.234
+IPv4.gateway=10.113.62.1
+#connmanctl config ethernet_b827eb0b6458_cable --ipv4 manual 10.113.62.234 255.255.255.0 10.113.62.1
diff --git a/shared/res/default_icon.png b/shared/res/default_icon.png
new file mode 100755
index 0000000..9765b1b
--- /dev/null
+++ b/shared/res/default_icon.png
Binary files differ
diff --git a/src/connection_manager.c b/src/connection_manager.c
new file mode 100644
index 0000000..443cd1f
--- /dev/null
+++ b/src/connection_manager.c
@@ -0,0 +1,206 @@
+ /*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ * Geunsun Lee <gs86.lee@samsung.com>
+ * Eunyoung Lee <ey928.lee@samsung.com>
+ * Junkyu Han <junkyu.han@samsung.com>
+ * Jeonghoon Park <jh1979.park@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <net_connection.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "log.h"
+
+struct conn_mgr_s {
+ connection_h connection;
+ connection_type_e net_state;
+ connection_wifi_state_e wifi_state;
+ char *ip_addr;
+};
+
+struct conn_mgr_s conn_mgr = { 0, };
+
+static const char *__connection_error_to_string(connection_error_e error)
+{
+ switch (error) {
+ case CONNECTION_ERROR_NONE:
+ return "CONNECTION_ERROR_NONE";
+ case CONNECTION_ERROR_INVALID_PARAMETER:
+ return "CONNECTION_ERROR_INVALID_PARAMETER";
+ case CONNECTION_ERROR_OUT_OF_MEMORY:
+ return "CONNECTION_ERROR_OUT_OF_MEMORY";
+ case CONNECTION_ERROR_INVALID_OPERATION:
+ return "CONNECTION_ERROR_INVALID_OPERATION";
+ case CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED:
+ return "CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED";
+ case CONNECTION_ERROR_OPERATION_FAILED:
+ return "CONNECTION_ERROR_OPERATION_FAILED";
+ case CONNECTION_ERROR_ITERATOR_END:
+ return "CONNECTION_ERROR_ITERATOR_END";
+ case CONNECTION_ERROR_NO_CONNECTION:
+ return "CONNECTION_ERROR_NO_CONNECTION";
+ case CONNECTION_ERROR_NOW_IN_PROGRESS:
+ return "CONNECTION_ERROR_NOW_IN_PROGRESS";
+ case CONNECTION_ERROR_ALREADY_EXISTS:
+ return "CONNECTION_ERROR_ALREADY_EXISTS";
+ case CONNECTION_ERROR_OPERATION_ABORTED:
+ return "CONNECTION_ERROR_OPERATION_ABORTED";
+ case CONNECTION_ERROR_DHCP_FAILED:
+ return "CONNECTION_ERROR_DHCP_FAILED";
+ case CONNECTION_ERROR_INVALID_KEY:
+ return "CONNECTION_ERROR_INVALID_KEY";
+ case CONNECTION_ERROR_NO_REPLY:
+ return "CONNECTION_ERROR_NO_REPLY";
+ case CONNECTION_ERROR_PERMISSION_DENIED:
+ return "CONNECTION_ERROR_PERMISSION_DENIED";
+ case CONNECTION_ERROR_NOT_SUPPORTED:
+ return "CONNECTION_ERROR_NOT_SUPPORTED";
+ default:
+ return "CONNECTION_ERROR_UNKNOWN";
+ }
+}
+
+static void __conn_mgr_ip_changed_cb(const char* ipv4_address,
+ const char* ipv6_address, void* user_data)
+{
+ _D("ip changed from[%s] to[%s]", conn_mgr.ip_addr, ipv4_address);
+
+ if (conn_mgr.ip_addr) {
+ free(conn_mgr.ip_addr);
+ conn_mgr.ip_addr = strdup(ipv4_address);
+ }
+ return;
+}
+
+static void __conn_mgr_connection_changed_cb(connection_type_e type, void* user_data)
+{
+ int ret = CONNECTION_ERROR_NONE;
+ _D("connection changed from[%d] to[%d]", conn_mgr.net_state, type);
+
+ conn_mgr.net_state = type;
+ if (conn_mgr.net_state != CONNECTION_TYPE_WIFI) {
+ ret = connection_get_wifi_state(conn_mgr.connection, &conn_mgr.wifi_state);
+ if (CONNECTION_ERROR_NONE != ret)
+ _E("fail connection_get_wifi_state - [%s]",
+ __connection_error_to_string(ret));
+ else
+ _D("net_state[%d] - wifi_state[%d]",
+ conn_mgr.net_state, conn_mgr.wifi_state);
+ }
+
+ return;
+}
+
+int connection_manager_get_ip(const char **ip)
+{
+ int ret = CONNECTION_ERROR_NONE;
+
+ retv_if(conn_mgr.connection == NULL, -1);
+ retv_if(ip == NULL, -1);
+
+ if (conn_mgr.ip_addr) {
+ *ip = conn_mgr.ip_addr;
+ return 0;
+ }
+
+ if (conn_mgr.net_state == CONNECTION_TYPE_DISCONNECTED) {
+ _W("disconnected now");
+ if (conn_mgr.ip_addr) {
+ free(conn_mgr.ip_addr);
+ conn_mgr.ip_addr = NULL;
+ }
+ return -1;
+ }
+
+ ret = connection_get_ip_address(conn_mgr.connection,
+ CONNECTION_ADDRESS_FAMILY_IPV4, &conn_mgr.ip_addr);
+ if ((CONNECTION_ERROR_NONE != ret) || (conn_mgr.ip_addr == NULL)) {
+ _E("fail to connection_get_ip_address() - [%s]",
+ __connection_error_to_string(ret));
+ return -1;
+ }
+
+ return 0;
+}
+
+int connection_manager_init(void)
+{
+ int ret = CONNECTION_ERROR_NONE;
+ if (conn_mgr.connection) {
+ _W("connection manager is already initialized");
+ return 0;
+ }
+
+ ret = connection_create(&conn_mgr.connection);
+ if (CONNECTION_ERROR_NONE != ret) {
+ _E("fail to create connection - [%s]",
+ __connection_error_to_string(ret));
+ return -1;
+ }
+
+ ret = connection_get_type(conn_mgr.connection, &conn_mgr.net_state);
+ if (CONNECTION_ERROR_NONE != ret)
+ _E("fail connection_get_type - [%s]",
+ __connection_error_to_string(ret));
+
+ if (conn_mgr.net_state != CONNECTION_TYPE_DISCONNECTED) {
+ ret = connection_get_ip_address(conn_mgr.connection,
+ CONNECTION_ADDRESS_FAMILY_IPV4, &conn_mgr.ip_addr);
+ if ((CONNECTION_ERROR_NONE != ret) || (conn_mgr.ip_addr == NULL))
+ _E("fail to connection_get_ip_address() - [%s]",
+ __connection_error_to_string(ret));
+ }
+
+ ret = connection_set_type_changed_cb(conn_mgr.connection,
+ __conn_mgr_connection_changed_cb, NULL);
+ if (CONNECTION_ERROR_NONE != ret)
+ _E("fail connection_set_type_changed_cb - [%s]",
+ __connection_error_to_string(ret));
+
+ ret = connection_get_wifi_state(conn_mgr.connection, &conn_mgr.wifi_state);
+ if (CONNECTION_ERROR_NONE != ret)
+ _E("fail connection_get_wifi_state - [%s]",
+ __connection_error_to_string(ret));
+
+ ret = connection_set_ip_address_changed_cb(conn_mgr.connection,
+ __conn_mgr_ip_changed_cb, NULL);
+ if (CONNECTION_ERROR_NONE != ret)
+ _E("fail toconnection_set_ip_address_changed_cb - [%s]",
+ __connection_error_to_string(ret));
+
+ _D("net_state[%d], wifi_state[%d], ip address[%s]",
+ conn_mgr.net_state, conn_mgr.wifi_state, conn_mgr.ip_addr);
+
+ return 0;
+}
+
+int connection_manager_fini(void)
+{
+ if (conn_mgr.connection) {
+ int ret = 0;
+ ret = connection_destroy(conn_mgr.connection);
+ _D("connection_destroy - [%s]", __connection_error_to_string(ret));
+ conn_mgr.connection = NULL;
+ }
+
+ if (conn_mgr.ip_addr) {
+ free(conn_mgr.ip_addr);
+ conn_mgr.ip_addr = NULL;
+ }
+ return 0;
+}
diff --git a/src/connectivity.c b/src/connectivity.c
new file mode 100644
index 0000000..b9c32bb
--- /dev/null
+++ b/src/connectivity.c
@@ -0,0 +1,1272 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ * Geunsun Lee <gs86.lee@samsung.com>
+ * Eunyoung Lee <ey928.lee@samsung.com>
+ * Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <glib.h>
+#include <app_common.h>
+#include <iotcon.h>
+
+#include "log.h"
+#include "connectivity.h"
+#include "webutil.h"
+#include "controller_util.h"
+#include "connection_manager.h"
+
+#define DEFAULT_RESOURCE_TYPE "org.tizen.door"
+#define BUFSIZE 1024
+#define URI_PATH_LEN 64
+#define URI_PATH "/door/1"
+#define PATH "path"
+#define IOTCON_DB_FILENAME "iotcon-test-svr-db-server.dat"
+
+struct _connectivity_resource {
+ char *path;
+ char *type;
+ char *ip;
+ connectivity_protocol_e protocol_type;
+ GHashTable *value_hash;
+ union {
+ struct {
+ iotcon_resource_h res;
+ iotcon_observers_h observers;
+ } iotcon_data;
+ struct {
+ /* Nothing */
+ char *reserve;
+ } http_data;
+ } conn_data;
+};
+
+typedef enum {
+ DATA_VAL_TYPE_BOOL = 0,
+ DATA_VAL_TYPE_INT,
+ DATA_VAL_TYPE_DOUBLE,
+ DATA_VAL_TYPE_STRING
+} conn_data_val_type_e;
+
+typedef struct _conn_data_value_s {
+ conn_data_val_type_e type;
+ union {
+ bool b_val;
+ int i_val;
+ double d_val;
+ char *s_val;
+ };
+} conn_data_value_s;
+
+static connectivity_protocol_e ProtocolType = CONNECTIVITY_PROTOCOL_DEFAULT;
+static int connectivity_iotcon_intialized = 0;
+static int connectivity_http_intialized = 0;
+
+static void _print_iotcon_error(int err_no)
+{
+ switch (err_no) {
+ case IOTCON_ERROR_NOT_SUPPORTED:
+ _E("IOTCON_ERROR_NOT_SUPPORTED");
+ break;
+ case IOTCON_ERROR_PERMISSION_DENIED:
+ _E("IOTCON_ERROR_PERMISSION_DENIED");
+ break;
+ case IOTCON_ERROR_INVALID_PARAMETER:
+ _E("IOTCON_ERROR_INVALID_PARAMETER");
+ break;
+ default:
+ _E("Error : [%d]", err_no);
+ break;
+ }
+
+ return;
+}
+
+static void _copy_file(const char *in_filename, const char *out_filename)
+{
+ char buf[BUFSIZE] = { 0, };
+ size_t nread = 0;
+ FILE *in = NULL;
+ FILE *out = NULL;
+
+ ret_if(!in_filename);
+ ret_if(!out_filename);
+
+ in = fopen(in_filename, "r");
+ ret_if(!in);
+
+ out = fopen(out_filename, "w");
+ goto_if(!out, error);
+
+ rewind(in);
+ while ((nread = fread(buf, 1, sizeof(buf), in)) > 0) {
+ if (fwrite(buf, 1, nread, out) < nread) {
+ _E("critical error to copy a file");
+ break;
+ }
+ }
+
+ fclose(in);
+ fclose(out);
+
+ return;
+
+error:
+ fclose(in);
+ return;
+}
+
+static bool _query_cb(const char *key, const char *value, void *user_data)
+{
+ _D("Key : [%s], Value : [%s]", key, value);
+
+ return IOTCON_FUNC_CONTINUE;
+}
+
+static int _handle_query(iotcon_request_h request)
+{
+ iotcon_query_h query = NULL;
+ int ret = -1;
+
+ ret = iotcon_request_get_query(request, &query);
+ retv_if(IOTCON_ERROR_NONE != ret, -1);
+
+ if (query) iotcon_query_foreach(query, _query_cb, NULL);
+
+ return 0;
+}
+
+static int _handle_request_by_crud_type(iotcon_request_h request, connectivity_resource_s *resource_info)
+{
+ iotcon_request_type_e type;
+ int ret = -1;
+
+ ret = iotcon_request_get_request_type(request, &type);
+ retv_if(IOTCON_ERROR_NONE != ret, -1);
+
+ switch (type) {
+ case IOTCON_REQUEST_GET:
+ _I("Do not support 'get' query");
+ break;
+ case IOTCON_REQUEST_PUT:
+ _I("Do not support 'put' query");
+ break;
+ case IOTCON_REQUEST_POST:
+ _I("Do not support 'post' query");
+ break;
+ case IOTCON_REQUEST_DELETE:
+ _I("Do not support 'delete' query");
+ break;
+ default:
+ _E("Cannot reach here");
+ ret = -1;
+ break;
+ }
+ retv_if(0 != ret, -1);
+
+ return 0;
+}
+
+static int _handle_observer(iotcon_request_h request, iotcon_observers_h observers)
+{
+ iotcon_observe_type_e observe_type;
+ int ret = -1;
+ int observe_id = -1;
+
+ ret = iotcon_request_get_observe_type(request, &observe_type);
+ retv_if(IOTCON_ERROR_NONE != ret, -1);
+
+ if (IOTCON_OBSERVE_REGISTER == observe_type) {
+ ret = iotcon_request_get_observe_id(request, &observe_id);
+ retv_if(IOTCON_ERROR_NONE != ret, -1);
+
+ _I("Add an observer : %d", observe_id);
+
+ ret = iotcon_observers_add(observers, observe_id);
+ retv_if(IOTCON_ERROR_NONE != ret, -1);
+ } else if (IOTCON_OBSERVE_DEREGISTER == observe_type) {
+ ret = iotcon_request_get_observe_id(request, &observe_id);
+ retv_if(IOTCON_ERROR_NONE != ret, -1);
+
+ _I("Remove an observer : %d", observe_id);
+
+ ret = iotcon_observers_remove(observers, observe_id);
+ retv_if(IOTCON_ERROR_NONE != ret, -1);
+ }
+
+ return 0;
+}
+
+static int _send_response(iotcon_request_h request, iotcon_representation_h representation, iotcon_response_result_e result)
+{
+ int ret = -1;
+ iotcon_response_h response;
+
+ ret = iotcon_response_create(request, &response);
+ retv_if(IOTCON_ERROR_NONE != ret, -1);
+
+ ret = iotcon_response_set_result(response, result);
+ goto_if(IOTCON_ERROR_NONE != ret, error);
+
+ ret = iotcon_response_set_representation(response, representation);
+ goto_if(IOTCON_ERROR_NONE != ret, error);
+
+ ret = iotcon_response_send(response);
+ goto_if(IOTCON_ERROR_NONE != ret, error);
+
+ iotcon_response_destroy(response);
+
+ return 0;
+
+error:
+ iotcon_response_destroy(response);
+ return -1;
+}
+
+static void _request_resource_handler(iotcon_resource_h resource, iotcon_request_h request, void *user_data)
+{
+ connectivity_resource_s *resource_info = user_data;
+ int ret = -1;
+ char *host_address = NULL;
+
+ ret_if(!request);
+
+ ret = iotcon_request_get_host_address(request, &host_address);
+ goto_if(IOTCON_ERROR_NONE != ret, error);
+
+ _D("Host address : %s", host_address);
+
+ ret = _handle_query(request);
+ goto_if(IOTCON_ERROR_NONE != ret, error);
+
+ ret = _handle_request_by_crud_type(request, resource_info);
+ goto_if(0 != ret, error);
+
+ ret = _handle_observer(request, resource_info->conn_data.iotcon_data.observers);
+ goto_if(0 != ret, error);
+
+ return;
+
+error:
+ _send_response(request, NULL, IOTCON_RESPONSE_ERROR);
+ return;
+}
+
+static int __init_iotcon(connectivity_resource_s *resource_info)
+{
+ int ret = -1;
+ iotcon_resource_types_h resource_types = NULL;
+ iotcon_resource_interfaces_h ifaces = NULL;
+ uint8_t policies = IOTCON_RESOURCE_NO_POLICY;
+ char res_path[PATH_MAX] = {0,};
+ char data_path[PATH_MAX] = {0,};
+ char *prefix = NULL;
+
+ retv_if(!resource_info, -1);
+ retv_if(resource_info->protocol_type != CONNECTIVITY_PROTOCOL_IOTIVITY, -1);
+
+ prefix = app_get_resource_path();
+ retv_if(!prefix, -1);
+ snprintf(res_path, sizeof(res_path)-1, "%s%s", prefix, IOTCON_DB_FILENAME);
+ free(prefix);
+ prefix = NULL;
+
+ prefix = app_get_data_path();
+ retv_if(!prefix, -1);
+ snprintf(data_path, sizeof(data_path)-1, "%s%s", prefix, IOTCON_DB_FILENAME);
+ free(prefix);
+
+ _copy_file(res_path, data_path);
+
+ ret = iotcon_initialize(data_path);
+ retv_if(IOTCON_ERROR_NONE != ret, -1);
+
+ /* TODO : If we have to set device name, naming it more gorgeous one */
+ ret = iotcon_set_device_name(DEFAULT_RESOURCE_TYPE);
+ goto_if(IOTCON_ERROR_NONE != ret, error);
+
+ ret = iotcon_resource_types_create(&resource_types);
+ goto_if(IOTCON_ERROR_NONE != ret, error);
+
+ ret = iotcon_resource_types_add(resource_types, resource_info->type);
+ goto_if(IOTCON_ERROR_NONE != ret, error);
+
+ ret = iotcon_resource_interfaces_create(&ifaces);
+ goto_if(IOTCON_ERROR_NONE != ret, error);
+
+ ret = iotcon_resource_interfaces_add(ifaces, IOTCON_INTERFACE_DEFAULT);
+ goto_if(IOTCON_ERROR_NONE != ret, error);
+
+ ret = iotcon_resource_interfaces_add(ifaces, IOTCON_INTERFACE_BATCH);
+ goto_if(IOTCON_ERROR_NONE != ret, error);
+
+ policies =
+ IOTCON_RESOURCE_DISCOVERABLE |
+ IOTCON_RESOURCE_OBSERVABLE |
+ IOTCON_RESOURCE_SECURE;
+
+ ret = iotcon_resource_create(URI_PATH,
+ resource_types,
+ ifaces,
+ policies,
+ _request_resource_handler,
+ resource_info,
+ &resource_info->conn_data.iotcon_data.res);
+ goto_if(IOTCON_ERROR_NONE != ret, error);
+
+ ret = iotcon_observers_create(&resource_info->conn_data.iotcon_data.observers);
+ goto_if(IOTCON_ERROR_NONE != ret, error);
+
+ iotcon_resource_types_destroy(resource_types);
+ iotcon_resource_interfaces_destroy(ifaces);
+ connectivity_iotcon_intialized = 1;
+
+ return 0;
+
+error:
+ if (resource_types) iotcon_resource_types_destroy(resource_types);
+ if (ifaces) iotcon_resource_interfaces_destroy(ifaces);
+ if (resource_info->conn_data.iotcon_data.res) iotcon_resource_destroy(resource_info->conn_data.iotcon_data.res);
+ iotcon_deinitialize();
+ return -1;
+}
+
+static int __init_http(connectivity_resource_s *resource_info)
+{
+ int ret = 0;
+ ret = web_util_noti_init();
+ if (!ret)
+ connectivity_http_intialized = 1;
+
+ return ret;
+}
+
+#ifdef PRINT_DEBUG_DETAIL
+static bool __print_attributes_cb(iotcon_attributes_h attributes, const char *key, void *user_data)
+{
+ iotcon_type_e type = IOTCON_TYPE_NONE;
+
+ iotcon_attributes_get_type(attributes, key, &type);
+
+ switch (type) {
+ case IOTCON_TYPE_INT: {
+ int value = 0;
+ iotcon_attributes_get_int(attributes, key, &value);
+ _D("key[%s] - int value [%d]", key, value);
+ }
+ break;
+ case IOTCON_TYPE_BOOL: {
+ bool value = 0;
+ iotcon_attributes_get_bool(attributes, key, &value);
+ _D("key[%s] - bool value [%d]", key, value);
+ }
+ break;
+ case IOTCON_TYPE_DOUBLE: {
+ double value = 0;
+ iotcon_attributes_get_double(attributes, key, &value);
+ _D("key[%s] - double value [%lf]", key, value);
+ }
+ break;
+ case IOTCON_TYPE_STR: {
+ char *value = 0;
+ iotcon_attributes_get_str(attributes, key, &value);
+ _D("key[%s] - string value [%s]", key, value);
+ }
+ break;
+ case IOTCON_TYPE_NONE:
+ case IOTCON_TYPE_BYTE_STR:
+ case IOTCON_TYPE_NULL:
+ case IOTCON_TYPE_LIST:
+ case IOTCON_TYPE_ATTRIBUTES:
+ default:
+ _W("unhandled key[%s] type[%d]", key, type);
+ break;
+ }
+
+ return IOTCON_FUNC_CONTINUE;
+}
+#endif
+
+static void __print_attribute(iotcon_attributes_h attributes)
+{
+#ifdef PRINT_DEBUG_DETAIL
+ ret_if(!attributes);
+
+ iotcon_attributes_foreach(attributes, __print_attributes_cb, NULL);
+#endif
+ return;
+}
+
+static void _destroy_representation(iotcon_representation_h representation)
+{
+ ret_if(!representation);
+ iotcon_representation_destroy(representation);
+ return;
+}
+
+static iotcon_representation_h _create_representation_with_bool(connectivity_resource_s *resource_info, const char *key, bool value)
+{
+ iotcon_attributes_h attributes = NULL;
+ iotcon_representation_h representation = NULL;
+ char *uri_path = NULL;
+ int ret = -1;
+
+ ret = iotcon_resource_get_uri_path(resource_info->conn_data.iotcon_data.res, &uri_path);
+ retv_if(IOTCON_ERROR_NONE != ret, NULL);
+
+ ret = iotcon_representation_create(&representation);
+ retv_if(IOTCON_ERROR_NONE != ret, NULL);
+
+ ret = iotcon_attributes_create(&attributes);
+ goto_if(IOTCON_ERROR_NONE != ret, error);
+
+ ret = iotcon_representation_set_uri_path(representation, uri_path);
+ goto_if(IOTCON_ERROR_NONE != ret, error);
+
+ ret = iotcon_attributes_add_str(attributes, PATH, resource_info->path);
+ goto_if(IOTCON_ERROR_NONE != ret, error);
+
+ ret = iotcon_attributes_add_bool(attributes, key, value);
+ goto_if(IOTCON_ERROR_NONE != ret, error);
+
+ ret = iotcon_representation_set_attributes(representation, attributes);
+ goto_if(IOTCON_ERROR_NONE != ret, error);
+
+ iotcon_attributes_destroy(attributes);
+
+ return representation;
+
+error:
+ if (attributes) iotcon_attributes_destroy(attributes);
+ if (representation) iotcon_representation_destroy(representation);
+
+ return NULL;
+}
+
+static iotcon_representation_h _create_representation_with_int(connectivity_resource_s *resource_info, const char *key, int value)
+{
+ iotcon_attributes_h attributes = NULL;
+ iotcon_representation_h representation = NULL;
+ char *uri_path = NULL;
+ int ret = -1;
+
+ ret = iotcon_resource_get_uri_path(resource_info->conn_data.iotcon_data.res, &uri_path);
+ retv_if(IOTCON_ERROR_NONE != ret, NULL);
+
+ ret = iotcon_representation_create(&representation);
+ retv_if(IOTCON_ERROR_NONE != ret, NULL);
+
+ ret = iotcon_attributes_create(&attributes);
+ goto_if(IOTCON_ERROR_NONE != ret, error);
+
+ ret = iotcon_representation_set_uri_path(representation, uri_path);
+ goto_if(IOTCON_ERROR_NONE != ret, error);
+
+ ret = iotcon_attributes_add_str(attributes, PATH, resource_info->path);
+ goto_if(IOTCON_ERROR_NONE != ret, error);
+
+ ret = iotcon_attributes_add_int(attributes, key, value);
+ goto_if(IOTCON_ERROR_NONE != ret, error);
+
+ ret = iotcon_representation_set_attributes(representation, attributes);
+ goto_if(IOTCON_ERROR_NONE != ret, error);
+
+ iotcon_attributes_destroy(attributes);
+
+ return representation;
+
+error:
+ if (attributes) iotcon_attributes_destroy(attributes);
+ if (representation) iotcon_representation_destroy(representation);
+
+ return NULL;
+}
+
+static iotcon_representation_h _create_representation_with_double(connectivity_resource_s *resource_info, const char *key, double value)
+{
+ iotcon_attributes_h attributes = NULL;
+ iotcon_representation_h representation = NULL;
+ char *uri_path = NULL;
+ int ret = -1;
+
+ ret = iotcon_resource_get_uri_path(resource_info->conn_data.iotcon_data.res, &uri_path);
+ retv_if(IOTCON_ERROR_NONE != ret, NULL);
+
+ ret = iotcon_representation_create(&representation);
+ retv_if(IOTCON_ERROR_NONE != ret, NULL);
+
+ ret = iotcon_attributes_create(&attributes);
+ goto_if(IOTCON_ERROR_NONE != ret, error);
+
+ ret = iotcon_representation_set_uri_path(representation, uri_path);
+ goto_if(IOTCON_ERROR_NONE != ret, error);
+
+ ret = iotcon_attributes_add_str(attributes, PATH, resource_info->path);
+ goto_if(IOTCON_ERROR_NONE != ret, error);
+
+ ret = iotcon_attributes_add_double(attributes, key, value);
+ goto_if(IOTCON_ERROR_NONE != ret, error);
+
+ ret = iotcon_representation_set_attributes(representation, attributes);
+ goto_if(IOTCON_ERROR_NONE != ret, error);
+
+ iotcon_attributes_destroy(attributes);
+
+ return representation;
+
+error:
+ if (attributes) iotcon_attributes_destroy(attributes);
+ if (representation) iotcon_representation_destroy(representation);
+
+ return NULL;
+}
+
+static iotcon_representation_h _create_representation_with_string(connectivity_resource_s *resource_info, const char *key, const char *value)
+{
+ iotcon_attributes_h attributes = NULL;
+ iotcon_representation_h representation = NULL;
+ char *uri_path = NULL;
+ int ret = -1;
+
+ ret = iotcon_resource_get_uri_path(resource_info->conn_data.iotcon_data.res, &uri_path);
+ retv_if(IOTCON_ERROR_NONE != ret, NULL);
+
+ ret = iotcon_representation_create(&representation);
+ retv_if(IOTCON_ERROR_NONE != ret, NULL);
+
+ ret = iotcon_attributes_create(&attributes);
+ goto_if(IOTCON_ERROR_NONE != ret, error);
+
+ ret = iotcon_representation_set_uri_path(representation, uri_path);
+ goto_if(IOTCON_ERROR_NONE != ret, error);
+
+ ret = iotcon_attributes_add_str(attributes, PATH, resource_info->path);
+ goto_if(IOTCON_ERROR_NONE != ret, error);
+
+ ret = iotcon_attributes_add_str(attributes, key, (char *)value);
+ goto_if(IOTCON_ERROR_NONE != ret, error);
+
+ ret = iotcon_representation_set_attributes(representation, attributes);
+ goto_if(IOTCON_ERROR_NONE != ret, error);
+
+ iotcon_attributes_destroy(attributes);
+
+ return representation;
+
+error:
+ if (attributes) iotcon_attributes_destroy(attributes);
+ if (representation) iotcon_representation_destroy(representation);
+
+ return NULL;
+}
+
+static inline void __noti_by_http(void)
+{
+ char *json_data = NULL;
+
+ json_data = web_util_get_json_string();
+ if (json_data) {
+ const char *url = NULL;
+ controller_util_get_address(&url);
+ if (url)
+ web_util_noti_post(url, json_data);
+ else
+ _E("fail to get url");
+ free(json_data);
+ } else
+ _E("fail to get json_data");
+
+ return;
+}
+
+int connectivity_notify_bool(connectivity_resource_s *resource_info, const char *key, bool value)
+{
+ int ret = -1;
+
+ retv_if(!resource_info, -1);
+ retv_if(!key, -1);
+
+ _D("Notify key[%s], value[%d]", key, value);
+
+ switch (resource_info->protocol_type) {
+ case CONNECTIVITY_PROTOCOL_IOTIVITY:
+ retv_if(!resource_info->conn_data.iotcon_data.res, -1);
+ retv_if(!resource_info->conn_data.iotcon_data.observers, -1);
+ {
+ iotcon_representation_h representation;
+ representation = _create_representation_with_bool(resource_info, key, value);
+ retv_if(!representation, -1);
+ ret = iotcon_resource_notify(resource_info->conn_data.iotcon_data.res,
+ representation, resource_info->conn_data.iotcon_data.observers, IOTCON_QOS_LOW);
+ if (IOTCON_ERROR_NONE != ret) {
+ _W("There are some troubles for notifying value[%d]", ret);
+ _print_iotcon_error(ret);
+ return -1;
+ }
+ _destroy_representation(representation);
+ }
+ break;
+ case CONNECTIVITY_PROTOCOL_HTTP:
+ ret = web_util_json_init();
+ retv_if(ret, -1);
+
+ ret = web_util_json_begin();
+ retv_if(ret, -1);
+
+ web_util_json_add_string("SensorPiID", resource_info->path);
+ web_util_json_add_string("SensorPiType", resource_info->type);
+ web_util_json_add_string("SensorPiIP", resource_info->ip);
+ web_util_json_add_boolean(key, value);
+ web_util_json_end();
+
+ __noti_by_http();
+
+ web_util_json_fini();
+ break;
+ default:
+ _E("Unknown protocol type[%d]", resource_info->protocol_type);
+ return -1;
+ break;
+ }
+
+ return 0;
+}
+
+int connectivity_notify_int(connectivity_resource_s *resource_info, const char *key, int value)
+{
+ int ret = -1;
+
+ retv_if(!resource_info, -1);
+ retv_if(!key, -1);
+
+ _D("Notify key[%s], value[%d]", key, value);
+
+ switch (resource_info->protocol_type) {
+ case CONNECTIVITY_PROTOCOL_IOTIVITY:
+ retv_if(!resource_info->conn_data.iotcon_data.res, -1);
+ retv_if(!resource_info->conn_data.iotcon_data.observers, -1);
+ {
+ iotcon_representation_h representation;
+ representation = _create_representation_with_int(resource_info, key, value);
+ retv_if(!representation, -1);
+ ret = iotcon_resource_notify(resource_info->conn_data.iotcon_data.res,
+ representation, resource_info->conn_data.iotcon_data.observers, IOTCON_QOS_LOW);
+ if (IOTCON_ERROR_NONE != ret) {
+ _W("There are some troubles for notifying value[%d]", ret);
+ _print_iotcon_error(ret);
+ return -1;
+ }
+ _destroy_representation(representation);
+ }
+ break;
+ case CONNECTIVITY_PROTOCOL_HTTP:
+ ret = web_util_json_init();
+ retv_if(ret, -1);
+
+ ret = web_util_json_begin();
+ retv_if(ret, -1);
+
+ web_util_json_add_string("SensorPiID", resource_info->path);
+ web_util_json_add_string("SensorPiType", resource_info->type);
+ web_util_json_add_string("SensorPiIP", resource_info->ip);
+ web_util_json_add_int(key, value);
+ web_util_json_end();
+
+ __noti_by_http();
+
+ web_util_json_fini();
+ break;
+ default:
+ _E("Unknown protocol type[%d]", resource_info->protocol_type);
+ return -1;
+ break;
+ }
+ return 0;
+}
+
+int connectivity_notify_double(connectivity_resource_s *resource_info, const char *key, double value)
+{
+ int ret = -1;
+
+ retv_if(!resource_info, -1);
+ retv_if(!key, -1);
+
+ _D("Notify key[%s], value[%lf]", key, value);
+
+ switch (resource_info->protocol_type) {
+ case CONNECTIVITY_PROTOCOL_IOTIVITY:
+ retv_if(!resource_info->conn_data.iotcon_data.res, -1);
+ retv_if(!resource_info->conn_data.iotcon_data.observers, -1);
+ {
+ iotcon_representation_h representation;
+ representation = _create_representation_with_double(resource_info, key, value);
+ retv_if(!representation, -1);
+ ret = iotcon_resource_notify(resource_info->conn_data.iotcon_data.res,
+ representation, resource_info->conn_data.iotcon_data.observers, IOTCON_QOS_LOW);
+ if (IOTCON_ERROR_NONE != ret) {
+ _W("There are some troubles for notifying value[%d]", ret);
+ _print_iotcon_error(ret);
+ return -1;
+ }
+ _destroy_representation(representation);
+ }
+ break;
+ case CONNECTIVITY_PROTOCOL_HTTP:
+ ret = web_util_json_init();
+ retv_if(ret, -1);
+
+ ret = web_util_json_begin();
+ retv_if(ret, -1);
+
+ web_util_json_add_string("SensorPiID", resource_info->path);
+ web_util_json_add_string("SensorPiType", resource_info->type);
+ web_util_json_add_string("SensorPiIP", resource_info->ip);
+ web_util_json_add_double(key, value);
+ web_util_json_end();
+
+ __noti_by_http();
+
+ web_util_json_fini();
+ break;
+ default:
+ _E("Unknown protocol type[%d]", resource_info->protocol_type);
+ return -1;
+ break;
+ }
+ return 0;
+}
+
+int connectivity_notify_string(connectivity_resource_s *resource_info, const char *key, const char *value)
+{
+ int ret = -1;
+
+ retv_if(!resource_info, -1);
+ retv_if(!key, -1);
+ retv_if(!value, -1);
+
+ _D("Notify key[%s], value[%s]", key, value);
+
+ switch (resource_info->protocol_type) {
+ case CONNECTIVITY_PROTOCOL_IOTIVITY:
+ retv_if(!resource_info->conn_data.iotcon_data.res, -1);
+ retv_if(!resource_info->conn_data.iotcon_data.observers, -1);
+ {
+ iotcon_representation_h representation;
+ representation = _create_representation_with_string(resource_info, key, value);
+ retv_if(!representation, -1);
+ ret = iotcon_resource_notify(resource_info->conn_data.iotcon_data.res,
+ representation, resource_info->conn_data.iotcon_data.observers, IOTCON_QOS_LOW);
+ if (IOTCON_ERROR_NONE != ret) {
+ _W("There are some troubles for notifying value[%d]", ret);
+ _print_iotcon_error(ret);
+ return -1;
+ }
+ _destroy_representation(representation);
+ }
+ break;
+ case CONNECTIVITY_PROTOCOL_HTTP:
+ ret = web_util_json_init();
+ retv_if(ret, -1);
+
+ ret = web_util_json_begin();
+ retv_if(ret, -1);
+
+ web_util_json_add_string("SensorPiID", resource_info->path);
+ web_util_json_add_string("SensorPiType", resource_info->type);
+ web_util_json_add_string("SensorPiIP", resource_info->ip);
+ web_util_json_add_string(key, value);
+ web_util_json_end();
+
+ __noti_by_http();
+
+ web_util_json_fini();
+ break;
+ default:
+ _E("Unknown protocol type[%d]", resource_info->protocol_type);
+ return -1;
+ break;
+ }
+ return 0;
+}
+
+static void __hash_key_free(gpointer data)
+{
+ free(data);
+ return;
+}
+
+static void __hash_value_free(gpointer data)
+{
+ conn_data_value_s *value = data;
+ if (value && (value->type == DATA_VAL_TYPE_STRING))
+ free(value->s_val);
+ free(value);
+
+ return;
+}
+
+static int __add_value_to_hash(connectivity_resource_s *resource_info, const char *key, conn_data_value_s *value)
+{
+ retv_if(!resource_info, -1);
+ retv_if(!key, -1);
+ retv_if(!value, -1);
+
+ if (!resource_info->value_hash) {
+ resource_info->value_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
+ __hash_key_free, __hash_value_free);
+ retv_if(!resource_info->value_hash, -1);
+ }
+
+ g_hash_table_insert(resource_info->value_hash, strdup(key), value);
+
+ return 0;
+}
+
+int connectivity_attributes_add_bool(connectivity_resource_s *resource_info, const char *key, bool value)
+{
+ int ret = 0;
+ conn_data_value_s *data_value = NULL;
+
+ retv_if(!resource_info, -1);
+ retv_if(!key, -1);
+
+ _D("adding key[%s] - value[%d]", key, value);
+
+ data_value = malloc(sizeof(conn_data_value_s));
+ retv_if(!data_value, -1);
+
+ data_value->type = DATA_VAL_TYPE_BOOL;
+ data_value->b_val = value;
+
+ ret = __add_value_to_hash(resource_info, key, data_value);
+ if (ret) {
+ free(data_value);
+ return -1;
+ }
+
+ return 0;
+}
+
+int connectivity_attributes_add_int(connectivity_resource_s *resource_info, const char *key, int value)
+{
+ int ret = 0;
+ conn_data_value_s *data_value = NULL;
+
+ retv_if(!resource_info, -1);
+ retv_if(!key, -1);
+
+ _D("adding key[%s] - value[%d]", key, value);
+
+ data_value = malloc(sizeof(conn_data_value_s));
+ retv_if(!data_value, -1);
+
+ data_value->type = DATA_VAL_TYPE_INT;
+ data_value->i_val = value;
+
+ ret = __add_value_to_hash(resource_info, key, data_value);
+ if (ret) {
+ free(data_value);
+ return -1;
+ }
+
+ return 0;
+}
+
+int connectivity_attributes_add_double(connectivity_resource_s *resource_info, const char *key, double value)
+{
+ int ret = 0;
+ conn_data_value_s *data_value = NULL;
+
+ retv_if(!resource_info, -1);
+ retv_if(!key, -1);
+
+ _D("adding key[%s] - value[%lf]", key, value);
+
+ data_value = malloc(sizeof(conn_data_value_s));
+ retv_if(!data_value, -1);
+
+ data_value->type = DATA_VAL_TYPE_DOUBLE;
+ data_value->d_val = value;
+
+ ret = __add_value_to_hash(resource_info, key, data_value);
+ if (ret) {
+ free(data_value);
+ return -1;
+ }
+
+ return 0;
+}
+
+int connectivity_attributes_add_string(connectivity_resource_s *resource_info, const char *key, const char *value)
+{
+ int ret = 0;
+ conn_data_value_s *data_value = NULL;
+
+ retv_if(!resource_info, -1);
+ retv_if(!key, -1);
+ retv_if(!value, -1);
+
+ _D("adding key[%s] - value[%s]", key, value);
+
+ data_value = malloc(sizeof(conn_data_value_s));
+ retv_if(!data_value, -1);
+
+ data_value->type = DATA_VAL_TYPE_STRING;
+ data_value->s_val = strdup(value);
+
+ ret = __add_value_to_hash(resource_info, key, data_value);
+ if (ret) {
+ free(data_value->s_val);
+ free(data_value);
+ return -1;
+ }
+
+ return 0;
+}
+
+int connectivity_attributes_remove_value_by_key(connectivity_resource_s *resource_info, const char *key)
+{
+ retv_if(!resource_info, -1);
+ retv_if(!key, -1);
+
+ if (resource_info->value_hash)
+ g_hash_table_remove(resource_info->value_hash, key);
+
+ if (g_hash_table_size(resource_info->value_hash) == 0) {
+ g_hash_table_unref(resource_info->value_hash);
+ resource_info->value_hash = NULL;
+ }
+
+ return 0;
+}
+
+int connectivity_attributes_remove_all(connectivity_resource_s *resource_info)
+{
+ retv_if(!resource_info, -1);
+
+ if (resource_info->value_hash) {
+ g_hash_table_destroy(resource_info->value_hash);
+ resource_info->value_hash = NULL;
+ }
+
+ return 0;
+}
+
+static void __json_add_data_iter_cb(gpointer key, gpointer value, gpointer user_data)
+{
+ char *name = key;
+ conn_data_value_s *data = value;
+ int ret = 0;
+
+ ret_if(!name);
+ ret_if(!data);
+
+ switch (data->type) {
+ case DATA_VAL_TYPE_BOOL:
+ ret = web_util_json_add_boolean(name, data->b_val);
+ if (IOTCON_ERROR_NONE != ret)
+ _E("failed to add key[%s], value[%d]", name, data->b_val);
+ break;
+ case DATA_VAL_TYPE_INT:
+ ret = web_util_json_add_int(name, data->i_val);
+ if (IOTCON_ERROR_NONE != ret)
+ _E("failed to add key[%s], value[%d]", name, data->i_val);
+ break;
+ case DATA_VAL_TYPE_DOUBLE:
+ ret = web_util_json_add_double(name, data->d_val);
+ if (IOTCON_ERROR_NONE != ret)
+ _E("failed to add key[%s], value[%lf]", name, data->d_val);
+ break;
+ case DATA_VAL_TYPE_STRING:
+ ret = web_util_json_add_string(name, data->s_val);
+ if (IOTCON_ERROR_NONE != ret)
+ _E("failed to add key[%s], value[%s]", name, data->s_val);
+ break;
+ default:
+ _E("Unknown data type [%d]", data->type);
+ break;
+ }
+
+ return;
+}
+
+static void __attr_add_data_iter_cb(gpointer key, gpointer value, gpointer user_data)
+{
+ char *name = key;
+ conn_data_value_s *data = value;
+ iotcon_attributes_h attr = user_data;
+ int ret = 0;
+
+ ret_if(!name);
+ ret_if(!data);
+ ret_if(!attr);
+
+ switch (data->type) {
+ case DATA_VAL_TYPE_BOOL:
+ ret = iotcon_attributes_add_bool(attr, name, data->b_val);
+ if (IOTCON_ERROR_NONE != ret)
+ _E("failed to add key[%s], value[%d]", name, data->b_val);
+ break;
+ case DATA_VAL_TYPE_INT:
+ ret = iotcon_attributes_add_int(attr, name, data->i_val);
+ if (IOTCON_ERROR_NONE != ret)
+ _E("failed to add key[%s], value[%d]", name, data->i_val);
+ break;
+ case DATA_VAL_TYPE_DOUBLE:
+ ret = iotcon_attributes_add_double(attr, name, data->d_val);
+ if (IOTCON_ERROR_NONE != ret)
+ _E("failed to add key[%s], value[%lf]", name, data->d_val);
+ break;
+ case DATA_VAL_TYPE_STRING:
+ ret = iotcon_attributes_add_str(attr, name, data->s_val);
+ if (IOTCON_ERROR_NONE != ret)
+ _E("failed to add key[%s], value[%s]", name, data->s_val);
+ break;
+ default:
+ _E("Unknown data type [%d]", data->type);
+ break;
+ }
+
+ return;
+}
+
+static int __create_attributes(connectivity_resource_s *resource_info, iotcon_attributes_h *attributes)
+{
+ int ret = 0;
+ iotcon_attributes_h attr = NULL;
+
+ ret = iotcon_attributes_create(&attr);
+ if (IOTCON_ERROR_NONE != ret) {
+ _print_iotcon_error(ret);
+ return -1;
+ }
+
+ ret = iotcon_attributes_add_str(attr, PATH, resource_info->path);
+ if (IOTCON_ERROR_NONE != ret) {
+ _print_iotcon_error(ret);
+ iotcon_attributes_destroy(attr);
+ return -1;
+ }
+ if (resource_info->value_hash)
+ g_hash_table_foreach(resource_info->value_hash, __attr_add_data_iter_cb, attr);
+
+ *attributes = attr;
+
+ return 0;
+}
+
+int connectivity_attributes_notify_all(connectivity_resource_s *resource_info)
+{
+ int ret = 0;
+
+ retv_if(!resource_info, -1);
+
+ if (resource_info->value_hash == NULL) {
+ _W("You have nothing to notify now");
+ return 0;
+ }
+
+
+ switch (resource_info->protocol_type) {
+ case CONNECTIVITY_PROTOCOL_IOTIVITY:
+ retv_if(!resource_info->conn_data.iotcon_data.res, -1);
+ retv_if(!resource_info->conn_data.iotcon_data.observers, -1);
+ {
+ char *uri_path = NULL;
+ iotcon_representation_h representation = NULL;
+ iotcon_attributes_h attributes = NULL;
+ int iotcon_ret = 0;
+
+ iotcon_ret = iotcon_resource_get_uri_path(resource_info->conn_data.iotcon_data.res, &uri_path);
+ retv_if(IOTCON_ERROR_NONE != iotcon_ret, -1);
+
+ iotcon_ret = iotcon_representation_create(&representation);
+ retv_if(IOTCON_ERROR_NONE != iotcon_ret, -1);
+
+ iotcon_ret = iotcon_representation_set_uri_path(representation, uri_path);
+ if (IOTCON_ERROR_NONE != iotcon_ret) {
+ _print_iotcon_error(iotcon_ret);
+ ret = -1;
+ }
+
+ iotcon_ret = __create_attributes(resource_info, &attributes);
+ if (iotcon_ret) {
+ _E("failed to create attributes");
+ ret = -1;
+ }
+ __print_attribute(attributes);
+
+ iotcon_ret = iotcon_representation_set_attributes(representation, attributes);
+ if (IOTCON_ERROR_NONE != iotcon_ret) {
+ _print_iotcon_error(iotcon_ret);
+ ret = -1;
+ }
+
+ iotcon_ret = iotcon_resource_notify(resource_info->conn_data.iotcon_data.res, representation,
+ resource_info->conn_data.iotcon_data.observers, IOTCON_QOS_LOW);
+ if (IOTCON_ERROR_NONE != iotcon_ret) {
+ _print_iotcon_error(iotcon_ret);
+ ret = -1;
+ }
+
+ iotcon_representation_destroy(representation);
+ iotcon_attributes_destroy(attributes);
+ }
+ break;
+ case CONNECTIVITY_PROTOCOL_HTTP:
+ ret = web_util_json_init();
+ retv_if(ret, -1);
+
+ ret = web_util_json_begin();
+ retv_if(ret, -1);
+
+ web_util_json_add_string("SensorPiID", resource_info->path);
+ web_util_json_add_string("SensorPiType", resource_info->type);
+ web_util_json_add_string("SensorPiIP", resource_info->ip);
+ g_hash_table_foreach(resource_info->value_hash, __json_add_data_iter_cb, NULL);
+ web_util_json_end();
+
+ __noti_by_http();
+
+ web_util_json_fini();
+ break;
+ default:
+ break;
+ }
+
+ g_hash_table_destroy(resource_info->value_hash);
+ resource_info->value_hash = NULL;
+
+ return ret;
+}
+
+void connectivity_unset_resource(connectivity_resource_s *resource_info)
+{
+ ret_if(!resource_info);
+
+ switch (resource_info->protocol_type) {
+ case CONNECTIVITY_PROTOCOL_IOTIVITY:
+ if (resource_info->conn_data.iotcon_data.observers) iotcon_observers_destroy(resource_info->conn_data.iotcon_data.observers);
+ if (resource_info->conn_data.iotcon_data.res) iotcon_resource_destroy(resource_info->conn_data.iotcon_data.res);
+ iotcon_deinitialize();
+ connectivity_iotcon_intialized = 0;
+ break;
+ case CONNECTIVITY_PROTOCOL_HTTP:
+ web_util_noti_fini();
+ connectivity_http_intialized = 0;
+ break;
+ default:
+ break;
+ }
+
+ if (resource_info->path) free(resource_info->path);
+ if (resource_info->type) free(resource_info->type);
+ if (resource_info->ip) free(resource_info->ip);
+ free(resource_info);
+
+ return;
+}
+
+int connectivity_set_resource(const char *path, const char *type, connectivity_resource_s **out_resource_info)
+{
+ connectivity_resource_s *resource_info = NULL;
+ const char *ip = NULL;
+ int ret = -1;
+
+ retv_if(!path, -1);
+ retv_if(!type, -1);
+ retv_if(!out_resource_info, -1);
+
+ resource_info = calloc(1, sizeof(connectivity_resource_s));
+ retv_if(!resource_info, -1);
+
+ resource_info->path = strdup(path);
+ goto_if(!resource_info->path, error);
+
+ resource_info->type = strdup(type);
+ goto_if(!resource_info->type, error);
+
+ connection_manager_get_ip(&ip);
+ resource_info->ip = strdup(ip);
+ goto_if(!resource_info->ip, error);
+
+ resource_info->protocol_type = ProtocolType;
+
+ _D("Path[%s], Type[%s], protocol_type[%d]" , resource_info->path, resource_info->type, resource_info->protocol_type);
+
+ switch (resource_info->protocol_type) {
+ case CONNECTIVITY_PROTOCOL_DEFAULT:
+ _D("default protocol type is iotivity\n \
+ To set connectivity use connectivity_set_protocol_type() function");
+ resource_info->protocol_type = CONNECTIVITY_PROTOCOL_IOTIVITY;
+ case CONNECTIVITY_PROTOCOL_IOTIVITY:
+ ret = __init_iotcon(resource_info);
+ goto_if(ret, error);
+ break;
+ case CONNECTIVITY_PROTOCOL_HTTP:
+ ret = __init_http(resource_info);
+ goto_if(ret, error);
+ break;
+ default:
+ goto error;
+ break;
+ }
+
+ *out_resource_info = resource_info;
+
+ return 0;
+
+error:
+ if (resource_info->path) free(resource_info->path);
+ if (resource_info->type) free(resource_info->type);
+ if (resource_info->ip) free(resource_info->ip);
+ if (resource_info) free(resource_info);
+
+ return -1;
+}
+
+int connectivity_set_protocol(connectivity_protocol_e protocol_type)
+{
+ int ret = 0;
+ retv_if(protocol_type >= CONNECTIVITY_PROTOCOL_MAX, -1);
+
+ switch (protocol_type) {
+ case CONNECTIVITY_PROTOCOL_DEFAULT:
+ case CONNECTIVITY_PROTOCOL_IOTIVITY:
+ if (connectivity_iotcon_intialized) {
+ _E("protocol type[%d] aleady initialized", protocol_type);
+ return -1;
+ }
+ ProtocolType = CONNECTIVITY_PROTOCOL_IOTIVITY;
+ break;
+ case CONNECTIVITY_PROTOCOL_HTTP:
+ if (connectivity_http_intialized) {
+ _E("protocol type[%d] aleady initialized", protocol_type);
+ return -1;
+ }
+ ProtocolType = CONNECTIVITY_PROTOCOL_HTTP;
+ break;
+ default:
+ _E("unknown protocol type[%d]", protocol_type);
+ return -1;
+ break;
+ }
+
+ return ret;
+}
diff --git a/src/controller.c b/src/controller.c
new file mode 100644
index 0000000..7b35e9f
--- /dev/null
+++ b/src/controller.c
@@ -0,0 +1,216 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ * Geunsun Lee <gs86.lee@samsung.com>
+ * Eunyoung Lee <ey928.lee@samsung.com>
+ * Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <unistd.h>
+#include <glib.h>
+#include <Ecore.h>
+#include <tizen.h>
+#include <service_app.h>
+
+#include "log.h"
+#include "resource.h"
+#include "connectivity.h"
+#include "controller.h"
+#include "controller_util.h"
+#include "webutil.h"
+
+#define CONNECTIVITY_KEY "opened"
+#define SENSORING_TIME_INTERVAL 5.0f
+#define CAMERA_TIME_INTERVAL 2
+#define TEST_CAMERA_SAVE 0
+#define CAMERA_ENABLED 0
+
+typedef struct app_data_s {
+ Ecore_Timer *getter_timer;
+ connectivity_resource_s *resource_info;
+} app_data;
+
+static void __resource_camera_capture_completed_cb(const void *image, unsigned int size, void *user_data)
+{
+ /* TODO */
+ const char *path = NULL;
+ const char *url = NULL;
+
+ controller_util_get_path(&path);
+
+ controller_util_get_image_address(&url);
+
+ web_util_noti_post_image_data(url, path, image, size);
+
+#if TEST_CAMERA_SAVE
+ FILE *fp = NULL;
+ char *data_path = NULL;
+ char file[256];
+
+ data_path = app_get_data_path();
+
+ snprintf(file, sizeof(file), "%sjjoggoba.jpg", data_path);
+ free(data_path);
+ _D("File : %s", file);
+
+ fp = fopen(file, "w");
+ if (!fp) {
+ _E("Failed to open file: %s", file);
+ return;
+ }
+
+ if (fwrite(image, size, 1, fp) != 1) {
+ _E("Failed to write image to file");
+ return;
+ }
+
+ fclose(fp);
+#endif
+}
+
+static Eina_Bool control_sensors_cb(void *data)
+{
+ app_data *ad = data;
+ int value = 1;
+ int ret = 0;
+#if CAMERA_ENABLED
+ static unsigned int count = 0;
+
+ if (count % CAMERA_TIME_INTERVAL == 0) {
+ ret = resource_capture_camera(__resource_camera_capture_completed_cb, NULL);
+ if (ret < 0)
+ _E("Failed to capture camera");
+ }
+
+ count++;
+#endif
+
+ /* This is example, get value from sensors first */
+ if (connectivity_notify_int(ad->resource_info, "Motion", value) == -1)
+ _E("Cannot notify message");
+
+ return ECORE_CALLBACK_RENEW;
+}
+
+static bool service_app_create(void *data)
+{
+ app_data *ad = data;
+ int ret = -1;
+ const char *path = NULL;
+
+ /**
+ * No modification required!!!
+ * Access only when modifying internal functions.
+ */
+ controller_init_internal_functions();
+
+ /**
+ * Create a connectivity resource and registers the resource in server.
+ */
+ connectivity_set_protocol(CONNECTIVITY_PROTOCOL_HTTP);
+
+ controller_util_get_path(&path);
+ if (path == NULL) {
+ _E("Failed to get path");
+ return false;
+ }
+
+ ret = connectivity_set_resource(path, "org.tizen.door", &ad->resource_info);
+ if (ret == -1) _E("Cannot broadcast resource");
+
+ /**
+ * Creates a timer to call the given function in the given period of time.
+ * In the control_sensors_cb(), each sensor reads the measured value or writes a specific value to the sensor.
+ */
+ ad->getter_timer = ecore_timer_add(SENSORING_TIME_INTERVAL, control_sensors_cb, ad);
+ if (!ad->getter_timer) {
+ _E("Failed to add infrared motion getter timer");
+ return false;
+ }
+
+ return true;
+}
+
+static void service_app_terminate(void *data)
+{
+ app_data *ad = (app_data *)data;
+
+ if (ad->getter_timer)
+ ecore_timer_del(ad->getter_timer);
+
+
+ /**
+ * Releases the resource about connectivity.
+ */
+ connectivity_unset_resource(ad->resource_info);
+
+ /**
+ * No modification required!!!
+ * Access only when modifying internal functions.
+ */
+ controller_fini_internal_functions();
+
+ free(ad);
+}
+
+static void service_app_control(app_control_h app_control, void *data)
+{
+ // Todo: add your code here.
+}
+
+static void service_app_lang_changed(app_event_info_h event_info, void *user_data)
+{
+ /*APP_EVENT_LANGUAGE_CHANGED*/
+}
+
+static void service_app_region_changed(app_event_info_h event_info, void *user_data)
+{
+ /*APP_EVENT_REGION_FORMAT_CHANGED*/
+}
+
+static void service_app_low_battery(app_event_info_h event_info, void *user_data)
+{
+ /*APP_EVENT_LOW_BATTERY*/
+}
+
+static void service_app_low_memory(app_event_info_h event_info, void *user_data)
+{
+ /*APP_EVENT_LOW_MEMORY*/
+}
+
+int main(int argc, char* argv[])
+{
+ app_data *ad = NULL;
+ int ret = 0;
+ service_app_lifecycle_callback_s event_callback;
+ app_event_handler_h handlers[5] = {NULL, };
+
+ ad = calloc(1, sizeof(app_data));
+ retv_if(!ad, -1);
+
+ event_callback.create = service_app_create;
+ event_callback.terminate = service_app_terminate;
+ event_callback.app_control = service_app_control;
+
+ service_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, service_app_low_battery, &ad);
+ service_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, service_app_low_memory, &ad);
+ service_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, service_app_lang_changed, &ad);
+ service_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, service_app_region_changed, &ad);
+
+ ret = service_app_main(argc, argv, &event_callback, ad);
+
+ return ret;
+}
diff --git a/src/controller_internal.c b/src/controller_internal.c
new file mode 100644
index 0000000..410669e
--- /dev/null
+++ b/src/controller_internal.c
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ * Geunsun Lee <gs86.lee@samsung.com>
+ * Eunyoung Lee <ey928.lee@samsung.com>
+ * Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <iotcon.h>
+
+#include "log.h"
+#include "connectivity.h"
+#include "resource.h"
+#include "controller_util.h"
+#include "webutil.h"
+#include "connection_manager.h"
+
+void controller_init_internal_functions(void)
+{
+ connection_manager_init();
+ web_util_noti_init();
+ return;
+}
+
+void controller_fini_internal_functions(void)
+{
+ _I("Terminating...");
+ resource_close_all();
+ web_util_noti_fini();
+ connection_manager_fini();
+ controller_util_free();
+
+ return;
+}
diff --git a/src/controller_util.c b/src/controller_util.c
new file mode 100644
index 0000000..5bb65dc
--- /dev/null
+++ b/src/controller_util.c
@@ -0,0 +1,144 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ * Geunsun Lee <gs86.lee@samsung.com>
+ * Eunyoung Lee <ey928.lee@samsung.com>
+ * Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+#include <glib.h>
+#include <stdio.h>
+#include <app_common.h>
+#include "log.h"
+
+#define CONF_GROUP_DEFAULT_NAME "default"
+#define CONF_KEY_PATH_NAME "path"
+#define CONF_KEY_ADDRESS_NAME "address"
+#define CONF_KEY_IMAGE_UPLOAD_NAME "image_address"
+#define CONF_FILE_NAME "pi.conf"
+
+struct controller_util_s {
+ char *path;
+ char *address;
+ char *image_upload;
+};
+
+struct controller_util_s controller_util = { 0, };
+
+static int _read_conf_file(void)
+{
+ GKeyFile *gkf = NULL;
+ char conf_path[PATH_MAX] = {0,};
+ char *prefix = NULL;
+
+ gkf = g_key_file_new();
+ retv_if(!gkf, -1);
+
+ prefix = app_get_resource_path();
+ retv_if(!prefix, -1);
+ snprintf(conf_path, sizeof(conf_path)-1, "%s%s", prefix, CONF_FILE_NAME);
+ free(prefix);
+ prefix = NULL;
+
+ if (!g_key_file_load_from_file(gkf, conf_path, G_KEY_FILE_NONE, NULL)) {
+ _E("could not read config file %s", conf_path);
+ return -1;
+ }
+
+ controller_util.path = g_key_file_get_string(gkf,
+ CONF_GROUP_DEFAULT_NAME,
+ CONF_KEY_PATH_NAME,
+ NULL);
+ if (!controller_util.path)
+ _E("could not get the key string");
+
+ controller_util.address = g_key_file_get_string(gkf,
+ CONF_GROUP_DEFAULT_NAME,
+ CONF_KEY_ADDRESS_NAME,
+ NULL);
+ if (!controller_util.address)
+ _E("could not get the key string");
+
+ controller_util.image_upload = g_key_file_get_string(gkf,
+ CONF_GROUP_DEFAULT_NAME,
+ CONF_KEY_IMAGE_UPLOAD_NAME,
+ NULL);
+ if (!controller_util.image_upload)
+ _E("could not get the key string");
+
+ g_key_file_free(gkf);
+
+ return 0;
+}
+
+int controller_util_get_path(const char **path)
+{
+ retv_if(!path, -1);
+
+ if (!controller_util.path) {
+ int ret = -1;
+ ret = _read_conf_file();
+ retv_if(-1 == ret, -1);
+ }
+
+ *path = controller_util.path;
+
+ return 0;
+}
+
+int controller_util_get_address(const char **address)
+{
+ retv_if(!address, -1);
+
+ if (!controller_util.address) {
+ int ret = -1;
+ ret = _read_conf_file();
+ retv_if(-1 == ret, -1);
+ }
+
+ *address = controller_util.address;
+
+ return 0;
+}
+
+int controller_util_get_image_address(const char **image_upload)
+{
+ retv_if(!image_upload, -1);
+
+ if (!controller_util.image_upload) {
+ int ret = -1;
+ ret = _read_conf_file();
+ retv_if(-1 == ret, -1);
+ }
+
+ *image_upload = controller_util.image_upload;
+
+ return 0;
+}
+
+void controller_util_free(void)
+{
+ if (controller_util.path) {
+ free(controller_util.path);
+ controller_util.path = NULL;
+ }
+
+ if (controller_util.address) {
+ free(controller_util.address);
+ controller_util.address = NULL;
+ }
+}
diff --git a/src/resource.c b/src/resource.c
new file mode 100644
index 0000000..2354522
--- /dev/null
+++ b/src/resource.c
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ * Geunsun Lee <gs86.lee@samsung.com>
+ * Eunyoung Lee <ey928.lee@samsung.com>
+ * Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <peripheral_io.h>
+
+#include "log.h"
+#include "resource.h"
+
+static resource_s resource_info[PIN_MAX] = { {0, NULL, NULL}, };
+
+resource_s *resource_get_info(int pin_num)
+{
+ return &resource_info[pin_num];
+}
+
+void resource_close_all(void)
+{
+ int i = 0;
+ for (i = 0; i < PIN_MAX; i++) {
+ if (!resource_info[i].opened) continue;
+ _I("GPIO[%d] is closing...", i);
+
+ if (resource_info[i].close)
+ resource_info[i].close(i);
+ }
+ resource_close_illuminance_sensor();
+ resource_close_sound_level_sensor();
+}
diff --git a/src/resource/resource_PCA9685.c b/src/resource/resource_PCA9685.c
new file mode 100644
index 0000000..20a5545
--- /dev/null
+++ b/src/resource/resource_PCA9685.c
@@ -0,0 +1,249 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jeonghoon Park <jh1979.park@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <math.h>
+#include <peripheral_io.h>
+#include "log.h"
+#include "resource/resource_PCA9685.h"
+
+#define RPI3_I2C_BUS 1
+
+/* Registers/etc: */
+#define PCA9685_ADDRESS 0x40
+#define MODE1 0x00
+#define MODE2 0x01
+#define SUBADR1 0x02
+#define SUBADR2 0x03
+#define SUBADR3 0x04
+#define PRESCALE 0xFE
+#define LED0_ON_L 0x06
+#define LED0_ON_H 0x07
+#define LED0_OFF_L 0x08
+#define LED0_OFF_H 0x09
+#define ALL_LED_ON_L 0xFA
+#define ALL_LED_ON_H 0xFB
+#define ALL_LED_OFF_L 0xFC
+#define ALL_LED_OFF_H 0xFD
+
+/* Bits: */
+#define RESTART 0x80
+#define SLEEP 0x10
+#define ALLCALL 0x01
+#define INVRT 0x10
+#define OUTDRV 0x04
+
+typedef enum {
+ PCA9685_CH_STATE_NONE,
+ PCA9685_CH_STATE_USED,
+} pca9685_ch_state_e;
+
+static peripheral_i2c_h g_i2c_h = NULL;
+static unsigned int ref_count = 0;
+static pca9685_ch_state_e ch_state[PCA9685_CH_MAX + 1] = {PCA9685_CH_STATE_NONE, };
+
+int resource_pca9685_set_frequency(unsigned int freq_hz)
+{
+ int ret = PERIPHERAL_ERROR_NONE;
+ double prescale_value = 0.0;
+ int prescale = 0;
+ uint8_t oldmode = 0;
+ uint8_t newmode = 0;
+
+ prescale_value = 25000000.0; // 25MHz
+ prescale_value /= 4096.0; // 12-bit
+ prescale_value /= (double)freq_hz;
+ prescale_value -= 1.0;
+
+ prescale = (int)floor(prescale_value + 0.5);
+
+ ret = peripheral_i2c_read_register_byte(g_i2c_h, MODE1, &oldmode);
+ retvm_if(ret != PERIPHERAL_ERROR_NONE, -1, "failed to read register");
+
+ newmode = (oldmode & 0x7F) | 0x10; // sleep
+ ret = peripheral_i2c_write_register_byte(g_i2c_h, MODE1, newmode); // go to sleep
+ retvm_if(ret != PERIPHERAL_ERROR_NONE, -1, "failed to write register");
+
+ ret = peripheral_i2c_write_register_byte(g_i2c_h, PRESCALE, prescale);
+ retvm_if(ret != PERIPHERAL_ERROR_NONE, -1, "failed to write register");
+
+ ret = peripheral_i2c_write_register_byte(g_i2c_h, MODE1, oldmode);
+ retvm_if(ret != PERIPHERAL_ERROR_NONE, -1, "failed to write register");
+
+ usleep(500);
+
+ ret = peripheral_i2c_write_register_byte(g_i2c_h, MODE1, (oldmode | 0x80));
+ retvm_if(ret != PERIPHERAL_ERROR_NONE, -1, "failed to write register");
+
+ return 0;
+}
+
+int resource_pca9685_set_value_to_channel(unsigned int channel, int on, int off)
+{
+ int ret = PERIPHERAL_ERROR_NONE;
+ retvm_if(g_i2c_h == NULL, -1, "Not initialized yet");
+
+ retvm_if(ch_state[channel] == PCA9685_CH_STATE_NONE, -1,
+ "ch[%u] is not in used state", channel);
+
+ ret = peripheral_i2c_write_register_byte(g_i2c_h,
+ LED0_ON_L + 4*channel, on & 0xFF);
+ retvm_if(ret != PERIPHERAL_ERROR_NONE, -1, "failed to write register");
+
+ ret = peripheral_i2c_write_register_byte(g_i2c_h,
+ LED0_ON_H + 4*channel, on >> 8);
+ retvm_if(ret != PERIPHERAL_ERROR_NONE, -1, "failed to write register");
+
+ ret = peripheral_i2c_write_register_byte(g_i2c_h,
+ LED0_OFF_L + 4*channel, off & 0xFF);
+ retvm_if(ret != PERIPHERAL_ERROR_NONE, -1, "failed to write register");
+
+ ret = peripheral_i2c_write_register_byte(g_i2c_h,
+ LED0_OFF_H + 4*channel, off >> 8);
+ retvm_if(ret != PERIPHERAL_ERROR_NONE, -1, "failed to write register");
+
+ return 0;
+}
+
+static int resource_pca9685_set_value_to_all(int on, int off)
+{
+ int ret = PERIPHERAL_ERROR_NONE;
+ retvm_if(g_i2c_h == NULL, -1, "Not initialized yet");
+
+ ret = peripheral_i2c_write_register_byte(g_i2c_h,
+ ALL_LED_ON_L, on & 0xFF);
+ retvm_if(ret != PERIPHERAL_ERROR_NONE, -1, "failed to write register");
+
+ ret = peripheral_i2c_write_register_byte(g_i2c_h,
+ ALL_LED_ON_H, on >> 8);
+ retvm_if(ret != PERIPHERAL_ERROR_NONE, -1, "failed to write register");
+
+ ret = peripheral_i2c_write_register_byte(g_i2c_h,
+ ALL_LED_OFF_L, off & 0xFF);
+ retvm_if(ret != PERIPHERAL_ERROR_NONE, -1, "failed to write register");
+
+ ret = peripheral_i2c_write_register_byte(g_i2c_h,
+ ALL_LED_OFF_H, off >> 8);
+ retvm_if(ret != PERIPHERAL_ERROR_NONE, -1, "failed to write register");
+
+ return 0;
+}
+
+int resource_pca9685_init(unsigned int ch)
+{
+ uint8_t mode1 = 0;
+ int ret = PERIPHERAL_ERROR_NONE;
+
+ if (ch > PCA9685_CH_MAX) {
+ _E("channel[%u] is out of range", ch);
+ return -1;
+ }
+
+ if (ch_state[ch] == PCA9685_CH_STATE_USED) {
+ _E("channel[%u] is already in used state", ch);
+ return -1;
+ }
+
+ if (g_i2c_h)
+ goto PASS_OPEN_HANDLE;
+
+ ret = peripheral_i2c_open(RPI3_I2C_BUS, PCA9685_ADDRESS, &g_i2c_h);
+ if (ret != PERIPHERAL_ERROR_NONE) {
+ _E("failed to open pca9685-[bus:%d, addr:%d]",
+ RPI3_I2C_BUS, PCA9685_ADDRESS);
+ return -1;
+ }
+ ret = resource_pca9685_set_value_to_all(0, 0);
+ if (ret) {
+ _E("failed to reset all value to register");
+ goto ERROR;
+ }
+
+ ret = peripheral_i2c_write_register_byte(g_i2c_h, MODE2, OUTDRV);
+ if (ret != PERIPHERAL_ERROR_NONE) {
+ _E("failed to write register");
+ goto ERROR;
+ }
+
+ ret = peripheral_i2c_write_register_byte(g_i2c_h, MODE1, ALLCALL);
+ if (ret != PERIPHERAL_ERROR_NONE) {
+ _E("failed to write register");
+ goto ERROR;
+ }
+
+ usleep(500); // wait for oscillator
+
+ ret = peripheral_i2c_read_register_byte(g_i2c_h, MODE1, &mode1);
+ if (ret != PERIPHERAL_ERROR_NONE) {
+ _E("failed to read register");
+ goto ERROR;
+ }
+
+ mode1 = mode1 & (~SLEEP); // # wake up (reset sleep)
+ ret = peripheral_i2c_write_register_byte(g_i2c_h, MODE1, mode1);
+ if (ret != PERIPHERAL_ERROR_NONE) {
+ _E("failed to write register");
+ goto ERROR;
+ }
+
+ usleep(500); // wait for oscillator
+
+ ret = resource_pca9685_set_frequency(60);
+ if (ret) {
+ _E("failed to set frequency");
+ goto ERROR;
+ }
+
+PASS_OPEN_HANDLE:
+ ref_count++;
+ ch_state[ch] = PCA9685_CH_STATE_USED;
+ _D("pca9685 - ref_count[%u]", ref_count);
+ _D("sets ch[%u] used state", ch);
+
+ return 0;
+
+ERROR:
+ if (g_i2c_h)
+ peripheral_i2c_close(g_i2c_h);
+
+ g_i2c_h = NULL;
+ return -1;
+}
+
+int resource_pca9685_fini(unsigned int ch)
+{
+ if (ch_state[ch] == PCA9685_CH_STATE_NONE) {
+ _E("channel[%u] is not in used state", ch);
+ return -1;
+ }
+ resource_pca9685_set_value_to_channel(ch, 0, 0);
+ ch_state[ch] = PCA9685_CH_STATE_NONE;
+
+ ref_count--;
+ _D("ref count - %u", ref_count);
+
+ if (ref_count == 0 && g_i2c_h) {
+ _D("finalizing pca9685");
+ resource_pca9685_set_value_to_all(0, 0);
+ peripheral_i2c_close(g_i2c_h);
+ g_i2c_h = NULL;
+ }
+
+ return 0;
+}
diff --git a/src/resource/resource_adc_mcp3008.c b/src/resource/resource_adc_mcp3008.c
new file mode 100644
index 0000000..f170031
--- /dev/null
+++ b/src/resource/resource_adc_mcp3008.c
@@ -0,0 +1,208 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ * Geunsun Lee <gs86.lee@samsung.com>
+ * Eunyoung Lee <ey928.lee@samsung.com>
+ * Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <peripheral_io.h>
+#include <tizen.h>
+#include <system_info.h>
+#include <string.h>
+#include "log.h"
+
+
+#define MCP3008_SPEED 3600000
+#define MCP3008_BPW 8
+
+#define MCP3008_TX_WORD1 0x01 /* 0b00000001 */
+#define MCP3008_TX_CH0 0x80 /* 0b10000000 */
+#define MCP3008_TX_CH1 0x90 /* 0b10010000 */
+#define MCP3008_TX_CH2 0xA0 /* 0b10100000 */
+#define MCP3008_TX_CH3 0xB0 /* 0b10110000 */
+#define MCP3008_TX_CH4 0xC0 /* 0b11000000 */
+#define MCP3008_TX_CH5 0xD0 /* 0b11010000 */
+#define MCP3008_TX_CH6 0xE0 /* 0b11100000 */
+#define MCP3008_TX_CH7 0xF0 /* 0b11110000 */
+#define MCP3008_TX_WORD3 0x00 /* 0b00000000 */
+
+#define MCP3008_RX_WORD1_MASK 0x00 /* 0b00000000 */
+#define MCP3008_RX_WORD2_NULL_BIT_MASK 0x04 /* 0b00000100 */
+#define MCP3008_RX_WORD2_MASK 0x03 /* 0b00000011 */
+#define MCP3008_RX_WORD3_MASK 0xFF /* 0b11111111 */
+#define UINT10_VALIDATION_MASK 0x3FF
+
+#define MODEL_NAME_KEY "http://tizen.org/system/model_name"
+#define MODEL_NAME_RPI3 "rpi3"
+#define MODEL_NAME_ARTIK "artik"
+
+static peripheral_spi_h MCP3008_H = NULL;
+static unsigned int ref_count = 0;
+
+int resource_adc_mcp3008_init(void)
+{
+ int ret = 0;
+ int bus = -1;
+ char *model_name = NULL;
+
+ if (MCP3008_H) {
+ _D("SPI device aleady initialized [ref_count : %u]", ref_count);
+ ref_count++;
+ return 0;
+ }
+
+ system_info_get_platform_string(MODEL_NAME_KEY, &model_name);
+ if (!model_name) {
+ _E("fail to get model name");
+ return -1;
+ }
+
+ if (!strcmp(model_name, MODEL_NAME_RPI3)) {
+ bus = 0;
+ } else if (!strcmp(model_name, MODEL_NAME_ARTIK)) {
+ bus = 2;
+ } else {
+ _E("unknown model name : %s", model_name);
+ free(model_name);
+ return -1;
+ }
+ free(model_name);
+ model_name = NULL;
+
+ ret = peripheral_spi_open(bus, 0, &MCP3008_H);
+ if (PERIPHERAL_ERROR_NONE != ret) {
+ _E("spi open failed :%s ", get_error_message(ret));
+ return -1;
+ }
+
+ ret = peripheral_spi_set_mode(MCP3008_H, PERIPHERAL_SPI_MODE_0);
+ if (PERIPHERAL_ERROR_NONE != ret) {
+ _E("peripheral_spi_set_mode failed :%s ", get_error_message(ret));
+ goto error_after_open;
+ }
+ ret = peripheral_spi_set_bit_order(MCP3008_H, PERIPHERAL_SPI_BIT_ORDER_MSB);
+ if (PERIPHERAL_ERROR_NONE != ret) {
+ _E("peripheral_spi_set_bit_order failed :%s ", get_error_message(ret));
+ goto error_after_open;
+ }
+
+ ret = peripheral_spi_set_bits_per_word(MCP3008_H, MCP3008_BPW);
+ if (PERIPHERAL_ERROR_NONE != ret) {
+ _E("peripheral_spi_set_bits_per_word failed :%s ", get_error_message(ret));
+ goto error_after_open;
+ }
+
+ ret = peripheral_spi_set_frequency(MCP3008_H, MCP3008_SPEED);
+ if (PERIPHERAL_ERROR_NONE != ret) {
+ _E("peripheral_spi_set_frequency failed :%s ", get_error_message(ret));
+ goto error_after_open;
+ }
+
+ ref_count++;
+
+ return 0;
+
+error_after_open:
+ peripheral_spi_close(MCP3008_H);
+ MCP3008_H = NULL;
+ return -1;
+}
+
+
+int resource_read_adc_mcp3008(int ch_num, unsigned int *out_value)
+{
+ unsigned char rx[3] = {0, };
+ unsigned char tx[3] = {0, };
+ unsigned char rx_w1 = 0;
+ unsigned char rx_w2 = 0;
+ unsigned char rx_w2_nb = 0;
+ unsigned char rx_w3 = 0;
+ unsigned short int result = 0;
+
+ retv_if(MCP3008_H == NULL, -1);
+ retv_if(out_value == NULL, -1);
+ retv_if((ch_num < 0 || ch_num > 7), -1);
+
+ tx[0] = MCP3008_TX_WORD1;
+ switch (ch_num) {
+ case 0:
+ tx[1] = MCP3008_TX_CH0;
+ break;
+ case 1:
+ tx[1] = MCP3008_TX_CH1;
+ break;
+ case 2:
+ tx[1] = MCP3008_TX_CH2;
+ break;
+ case 3:
+ tx[1] = MCP3008_TX_CH3;
+ break;
+ case 4:
+ tx[1] = MCP3008_TX_CH4;
+ break;
+ case 5:
+ tx[1] = MCP3008_TX_CH5;
+ break;
+ case 6:
+ tx[1] = MCP3008_TX_CH6;
+ break;
+ case 7:
+ tx[1] = MCP3008_TX_CH7;
+ break;
+ default:
+ tx[1] = MCP3008_TX_CH0;
+ break;
+ }
+ tx[2] = MCP3008_TX_WORD3;
+
+ peripheral_spi_transfer(MCP3008_H, tx, rx, 3);
+
+ rx_w1 = rx[0] & MCP3008_RX_WORD1_MASK;
+ retv_if(rx_w1 != 0, -1);
+
+ rx_w2_nb = rx[1] & MCP3008_RX_WORD2_NULL_BIT_MASK;
+ retv_if(rx_w2_nb != 0, -1);
+
+ rx_w2 = rx[1] & MCP3008_RX_WORD2_MASK;
+ rx_w3 = rx[2] & MCP3008_RX_WORD3_MASK;
+
+ result = ((rx_w2 << 8) | (rx_w3)) & UINT10_VALIDATION_MASK;
+
+ // _D("%hu", result);
+
+ *out_value = result;
+
+ return 0;
+}
+
+void resource_adc_mcp3008_fini(void)
+{
+ if (MCP3008_H)
+ ref_count--;
+ else
+ return;
+
+ if (ref_count == 0) {
+ peripheral_spi_close(MCP3008_H);
+ MCP3008_H = NULL;
+ }
+
+ return;
+}
+
diff --git a/src/resource/resource_camera.c b/src/resource/resource_camera.c
new file mode 100644
index 0000000..64ae611
--- /dev/null
+++ b/src/resource/resource_camera.c
@@ -0,0 +1,233 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ * Geunsun Lee <gs86.lee@samsung.com>
+ * Eunyoung Lee <ey928.lee@samsung.com>
+ * Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <camera.h>
+#include <glib.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <tizen.h>
+
+#include "log.h"
+#include "resource/resource_camera.h"
+
+#define RESOLUTION_W 320
+#define RESOLUTION_H 240
+
+static int __init(void);
+static void __completed_cb(void *user_data);
+static bool __resolution_list_cb(int width, int height, void *user_data);
+static void __capturing_cb(camera_image_data_s *image, camera_image_data_s *postview,
+ camera_image_data_s *thumbnail, void *user_data);
+
+struct __camera_data {
+ camera_h cam_handle;
+ int resolution_w;
+ int resolution_h;
+ void *captured_file;
+ unsigned int image_size;
+ capture_completed_cb completed_cb;
+ void *completed_cb_data;
+};
+
+static struct __camera_data *camera_data = NULL;
+
+int resource_capture_camera(capture_completed_cb capture_completed, void *user_data)
+{
+ camera_state_e state;
+ int ret = CAMERA_ERROR_NONE;
+
+ if (camera_data == NULL) {
+ _I("Camera is not initialized");
+ ret = __init();
+ if (ret < 0) {
+ _E("Failed to initialize camera");
+ return -1;
+ }
+ }
+
+ ret = camera_get_state(camera_data->cam_handle, &state);
+ if (ret != CAMERA_ERROR_NONE) {
+ _E("Failed to get camera state");
+ return -1;
+ }
+
+ if (state >= CAMERA_STATE_CAPTURING) {
+ _D("Camera is now capturing");
+ return 0;
+ }
+
+ if (state != CAMERA_STATE_PREVIEW) {
+ _I("Preview is not started");
+ ret = camera_start_preview(camera_data->cam_handle);
+ if (ret != CAMERA_ERROR_NONE) {
+ _E("Failed to start preview");
+ return -1;
+ }
+ }
+
+ ret = camera_start_capture(camera_data->cam_handle, __capturing_cb, __completed_cb, camera_data);
+ if (ret != CAMERA_ERROR_NONE) {
+ _E("Failed to start capturing");
+ return -1;
+ }
+
+ camera_data->completed_cb = capture_completed;
+ camera_data->completed_cb_data = user_data;
+
+ return 0;
+}
+
+void resource_close_camera(void)
+{
+ if (camera_data == NULL)
+ return;
+
+ camera_stop_preview(camera_data->cam_handle);
+
+ camera_destroy(camera_data->cam_handle);
+ camera_data->cam_handle = NULL;
+
+ free(camera_data);
+ camera_data = NULL;
+}
+
+static void __capturing_cb(camera_image_data_s *image, camera_image_data_s *postview,
+ camera_image_data_s *thumbnail, void *user_data)
+{
+ struct __camera_data *camera_data = user_data;
+ if (image == NULL) {
+ _E("Image is NULL");
+ return;
+ }
+
+ camera_data->captured_file = malloc(image->size);
+ if (camera_data->captured_file == NULL)
+ return;
+
+ _D("Now is on Capturing: Image size[%d x %d]", image->width, image->height);
+
+ memcpy(camera_data->captured_file, image->data, image->size);
+ camera_data->image_size = image->size;
+
+ return;
+}
+
+static void __completed_cb(void *user_data)
+{
+ struct __camera_data *camera_data = user_data;
+ int ret = CAMERA_ERROR_NONE;
+
+ if (camera_data->completed_cb)
+ camera_data->completed_cb(camera_data->captured_file, camera_data->image_size, camera_data->completed_cb_data);
+
+ free(camera_data->captured_file);
+ camera_data->captured_file = NULL;
+
+ if (!camera_data->cam_handle) {
+ _E("Camera is NULL");
+ return;
+ }
+ _D("Capture is completed");
+
+ ret = camera_start_preview(camera_data->cam_handle);
+ if (ret != CAMERA_ERROR_NONE) {
+ _E("Failed to start preview");
+ return;
+ }
+
+ ret = camera_stop_preview(camera_data->cam_handle);
+ if (ret != CAMERA_ERROR_NONE) {
+ _E("Failed to stop preview");
+ return;
+ }
+
+ return;
+}
+
+static bool __resolution_list_cb(int width, int height, void *user_data)
+{
+ _D("Supported resolution - Width[%d], Height[%d]", width, height);
+
+ if (width > camera_data->resolution_w && width <= RESOLUTION_W &&
+ height > camera_data->resolution_h && height <= RESOLUTION_H) {
+ camera_data->resolution_w = width;
+ camera_data->resolution_h = height;
+ }
+ _D("Fixed Resolution is Width[%d], Height[%d]", camera_data->resolution_w, camera_data->resolution_h);
+
+ return true;
+}
+
+static int __init(void)
+{
+ int ret = CAMERA_ERROR_NONE;
+
+ camera_data = malloc(sizeof(struct __camera_data));
+ if (camera_data == NULL) {
+ _E("Failed to allocate Camera data");
+ return -1;
+ }
+ memset(camera_data, 0, sizeof(struct __camera_data));
+
+ ret = camera_create(CAMERA_DEVICE_CAMERA0, &(camera_data->cam_handle));
+ if (ret != CAMERA_ERROR_NONE) {
+ _E("Failed to create camera");
+ goto ERROR;
+ }
+
+ ret = camera_foreach_supported_capture_resolution(camera_data->cam_handle, __resolution_list_cb, NULL);
+ if (ret != CAMERA_ERROR_NONE) {
+ _E("Failed to foreach supported capture resolution");
+ goto ERROR;
+ }
+
+ ret = camera_set_preview_resolution(camera_data->cam_handle, camera_data->resolution_w, camera_data->resolution_h);
+ if (ret != CAMERA_ERROR_NONE) {
+ _E("Failed to set preview resolution");
+ goto ERROR;
+ }
+
+ ret = camera_set_capture_resolution(camera_data->cam_handle, camera_data->resolution_w, camera_data->resolution_h);
+ if (ret != CAMERA_ERROR_NONE) {
+ _E("Failed to set capture resolution");
+ goto ERROR;
+ }
+
+ ret = camera_set_capture_format(camera_data->cam_handle, CAMERA_PIXEL_FORMAT_JPEG);
+ if (ret != CAMERA_ERROR_NONE) {
+ _E("Failed to set capture resolution");
+ goto ERROR;
+ }
+
+ ret = camera_start_preview(camera_data->cam_handle);
+ if (ret != CAMERA_ERROR_NONE) {
+ _E("Failed to start preview[%d]", ret);
+ goto ERROR;
+ }
+
+ return 0;
+
+ERROR:
+ camera_destroy(camera_data->cam_handle);
+ free(camera_data);
+ return -1;
+}
+
diff --git a/src/resource/resource_flame_sensor.c b/src/resource/resource_flame_sensor.c
new file mode 100644
index 0000000..ec30f78
--- /dev/null
+++ b/src/resource/resource_flame_sensor.c
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ * Geunsun Lee <gs86.lee@samsung.com>
+ * Eunyoung Lee <ey928.lee@samsung.com>
+ * Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <peripheral_io.h>
+#include <sys/time.h>
+
+#include "log.h"
+#include "resource_internal.h"
+
+void resource_close_flame_sensor(int pin_num)
+{
+ if (!resource_get_info(pin_num)->opened) return;
+
+ _I("Flame Sensor is finishing...");
+ peripheral_gpio_close(resource_get_info(pin_num)->sensor_h);
+ resource_get_info(pin_num)->opened = 0;
+}
+
+int resource_read_flame_sensor(int pin_num, uint32_t *out_value)
+{
+ int ret = PERIPHERAL_ERROR_NONE;
+
+ if (!resource_get_info(pin_num)->opened) {
+ ret = peripheral_gpio_open(pin_num, &resource_get_info(pin_num)->sensor_h);
+ retv_if(!resource_get_info(pin_num)->sensor_h, -1);
+
+ ret = peripheral_gpio_set_direction(resource_get_info(pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_IN);
+ retv_if(ret != 0, -1);
+
+ resource_get_info(pin_num)->opened = 1;
+ resource_get_info(pin_num)->close = resource_close_flame_sensor;
+ }
+
+ /**
+ * This model(NS-FDSM) normally outputs 1, and outputs 0 as out_value when a flame is detected.
+ */
+ ret = peripheral_gpio_read(resource_get_info(pin_num)->sensor_h, out_value);
+ retv_if(ret < 0, -1);
+
+ *out_value = !*out_value;
+
+ return 0;
+}
diff --git a/src/resource/resource_gas_detection_sensor.c b/src/resource/resource_gas_detection_sensor.c
new file mode 100644
index 0000000..ebab0a0
--- /dev/null
+++ b/src/resource/resource_gas_detection_sensor.c
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ * Geunsun Lee <gs86.lee@samsung.com>
+ * Eunyoung Lee <ey928.lee@samsung.com>
+ * Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <peripheral_io.h>
+#include <sys/time.h>
+
+#include "log.h"
+#include "resource_internal.h"
+
+void resource_close_gas_detection_sensor(int pin_num)
+{
+ if (!resource_get_info(pin_num)->opened) return;
+
+ _I("Gas Detection Sensor is finishing...");
+ peripheral_gpio_close(resource_get_info(pin_num)->sensor_h);
+ resource_get_info(pin_num)->opened = 0;
+}
+
+int resource_read_gas_detection_sensor(int pin_num, uint32_t *out_value)
+{
+ int ret = PERIPHERAL_ERROR_NONE;
+
+ if (!resource_get_info(pin_num)->opened) {
+ ret = peripheral_gpio_open(pin_num, &resource_get_info(pin_num)->sensor_h);
+ retv_if(!resource_get_info(pin_num)->sensor_h, -1);
+
+ ret = peripheral_gpio_set_direction(resource_get_info(pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_IN);
+ retv_if(ret != 0, -1);
+
+ resource_get_info(pin_num)->opened = 1;
+ resource_get_info(pin_num)->close = resource_close_gas_detection_sensor;
+ }
+
+ /**
+ * This model(FC-22) normally outputs 1, and outputs 0 as out_value when a flame is detected.
+ */
+ ret = peripheral_gpio_read(resource_get_info(pin_num)->sensor_h, out_value);
+ retv_if(ret < 0, -1);
+
+ *out_value = !*out_value;
+
+ return 0;
+}
diff --git a/src/resource/resource_illuminance_sensor.c b/src/resource/resource_illuminance_sensor.c
new file mode 100644
index 0000000..1bbf662
--- /dev/null
+++ b/src/resource/resource_illuminance_sensor.c
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ * Geunsun Lee <gs86.lee@samsung.com>
+ * Eunyoung Lee <ey928.lee@samsung.com>
+ * Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <peripheral_io.h>
+#include <sys/time.h>
+
+#include "log.h"
+#include "resource_internal.h"
+
+#define I2C_PIN_MAX 28
+/* I2C */
+#define GY30_ADDR 0x23 /* Address of GY30 light sensor */
+#define GY30_CONT_HIGH_RES_MODE 0x10 /* Start measurement at 11x resolution. Measurement time is approx 120mx */
+#define GY30_CONSTANT_NUM (1.2)
+
+static struct {
+ int opened;
+ peripheral_i2c_h sensor_h;
+} resource_sensor_s;
+
+void resource_close_illuminance_sensor(void)
+{
+ if (!resource_sensor_s.opened) return;
+
+ _I("Illuminance Sensor is finishing...");
+ peripheral_i2c_close(resource_sensor_s.sensor_h);
+ resource_sensor_s.opened = 0;
+}
+
+int resource_read_illuminance_sensor(int i2c_bus, uint32_t *out_value)
+{
+ int ret = PERIPHERAL_ERROR_NONE;
+ unsigned char buf[10] = { 0, };
+
+ if (!resource_sensor_s.opened) {
+ ret = peripheral_i2c_open(i2c_bus, GY30_ADDR, &resource_sensor_s.sensor_h);
+ retv_if(!resource_sensor_s.sensor_h, -1);
+ resource_sensor_s.opened = 1;
+ }
+
+ buf[0] = GY30_CONT_HIGH_RES_MODE;
+ ret = peripheral_i2c_write(resource_sensor_s.sensor_h, buf, 1);
+ retv_if(ret < 0, -1);
+
+ ret = peripheral_i2c_read(resource_sensor_s.sensor_h, buf, 2);
+ retv_if(ret < 0, -1);
+
+ *out_value = (buf[0] << 8 | buf[1]) / GY30_CONSTANT_NUM; // Just Sum High 8bit and Low 8bit
+
+ _I("Illuminance Sensor Value : %d", *out_value);
+
+ return 0;
+}
diff --git a/src/resource/resource_infrared_motion_sensor.c b/src/resource/resource_infrared_motion_sensor.c
new file mode 100644
index 0000000..460fa45
--- /dev/null
+++ b/src/resource/resource_infrared_motion_sensor.c
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ * Geunsun Lee <gs86.lee@samsung.com>
+ * Eunyoung Lee <ey928.lee@samsung.com>
+ * Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <peripheral_io.h>
+#include <sys/time.h>
+
+#include "log.h"
+#include "resource_internal.h"
+
+void resource_close_infrared_motion_sensor(int pin_num)
+{
+ if (!resource_get_info(pin_num)->opened) return;
+
+ _I("Infrared Motion Sensor is finishing...");
+ peripheral_gpio_close(resource_get_info(pin_num)->sensor_h);
+ resource_get_info(pin_num)->opened = 0;
+}
+
+int resource_read_infrared_motion_sensor(int pin_num, uint32_t *out_value)
+{
+ int ret = PERIPHERAL_ERROR_NONE;
+
+ if (!resource_get_info(pin_num)->opened) {
+ ret = peripheral_gpio_open(pin_num, &resource_get_info(pin_num)->sensor_h);
+ retv_if(!resource_get_info(pin_num)->sensor_h, -1);
+
+ ret = peripheral_gpio_set_direction(resource_get_info(pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_IN);
+ retv_if(ret != 0, -1);
+
+ resource_get_info(pin_num)->opened = 1;
+ resource_get_info(pin_num)->close = resource_close_infrared_motion_sensor;
+ }
+
+ ret = peripheral_gpio_read(resource_get_info(pin_num)->sensor_h, out_value);
+ retv_if(ret < 0, -1);
+
+ return 0;
+}
diff --git a/src/resource/resource_infrared_obstacle_avoidance_sensor.c b/src/resource/resource_infrared_obstacle_avoidance_sensor.c
new file mode 100644
index 0000000..c5c43e8
--- /dev/null
+++ b/src/resource/resource_infrared_obstacle_avoidance_sensor.c
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ * Geunsun Lee <gs86.lee@samsung.com>
+ * Eunyoung Lee <ey928.lee@samsung.com>
+ * Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <peripheral_io.h>
+#include <sys/time.h>
+
+#include "log.h"
+#include "resource_internal.h"
+
+void resource_close_infrared_obstacle_avoidance_sensor(int pin_num)
+{
+ if (!resource_get_info(pin_num)->opened) return;
+
+ _I("Infrared Obstacle Avoidance Sensor is finishing...");
+ peripheral_gpio_close(resource_get_info(pin_num)->sensor_h);
+ resource_get_info(pin_num)->opened = 0;
+}
+
+int resource_read_infrared_obstacle_avoidance_sensor(int pin_num, uint32_t *out_value)
+{
+ int ret = PERIPHERAL_ERROR_NONE;
+
+ if (!resource_get_info(pin_num)->opened) {
+ ret = peripheral_gpio_open(pin_num, &resource_get_info(pin_num)->sensor_h);
+ retv_if(!resource_get_info(pin_num)->sensor_h, -1);
+
+ ret = peripheral_gpio_set_direction(resource_get_info(pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_IN);
+ retv_if(ret != 0, -1);
+
+ resource_get_info(pin_num)->opened = 1;
+ resource_get_info(pin_num)->close = resource_close_infrared_obstacle_avoidance_sensor;
+ }
+
+ ret = peripheral_gpio_read(resource_get_info(pin_num)->sensor_h, out_value);
+ retv_if(ret < 0, -1);
+
+ _I("Infrared Obstacle Avoidance Sensor Value : %d", *out_value);
+
+ *out_value = !*out_value;
+
+ return 0;
+}
diff --git a/src/resource/resource_led.c b/src/resource/resource_led.c
new file mode 100644
index 0000000..341b71f
--- /dev/null
+++ b/src/resource/resource_led.c
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ * Geunsun Lee <gs86.lee@samsung.com>
+ * Eunyoung Lee <ey928.lee@samsung.com>
+ * Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <peripheral_io.h>
+
+#include "log.h"
+#include "resource_internal.h"
+
+void resource_close_led(int pin_num)
+{
+ if (!resource_get_info(pin_num)->opened) return;
+
+ _I("LED is finishing...");
+ peripheral_gpio_close(resource_get_info(pin_num)->sensor_h);
+ resource_get_info(pin_num)->opened = 0;
+}
+
+int resource_write_led(int pin_num, int write_value)
+{
+ int ret = PERIPHERAL_ERROR_NONE;
+
+ if (!resource_get_info(pin_num)->opened) {
+ ret = peripheral_gpio_open(pin_num, &resource_get_info(pin_num)->sensor_h);
+ retv_if(!resource_get_info(pin_num)->sensor_h, -1);
+
+ ret = peripheral_gpio_set_direction(resource_get_info(pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_OUT_INITIALLY_LOW);
+ retv_if(ret != 0, -1);
+
+ resource_get_info(pin_num)->opened = 1;
+ resource_get_info(pin_num)->close = resource_close_led;
+ }
+
+ ret = peripheral_gpio_write(resource_get_info(pin_num)->sensor_h, write_value);
+ retv_if(ret < 0, -1);
+
+ _I("LED Value : %s", write_value ? "ON":"OFF");
+
+ return 0;
+}
diff --git a/src/resource/resource_motor_driver_L298N.c b/src/resource/resource_motor_driver_L298N.c
new file mode 100644
index 0000000..291b74b
--- /dev/null
+++ b/src/resource/resource_motor_driver_L298N.c
@@ -0,0 +1,333 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jeonghoon Park <jh1979.park@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+#include <peripheral_io.h>
+#include "log.h"
+#include "resource/resource_PCA9685.h"
+#include "resource/resource_motor_driver_L298N.h"
+
+typedef enum {
+ MOTOR_STATE_NONE,
+ MOTOR_STATE_CONFIGURED,
+ MOTOR_STATE_STOP,
+ MOTOR_STATE_FORWARD,
+ MOTOR_STATE_BACKWARD,
+} motor_state_e;
+
+typedef struct __motor_driver_s {
+ unsigned int pin_1;
+ unsigned int pin_2;
+ unsigned int en_ch;
+ motor_state_e motor_state;
+ peripheral_gpio_h pin1_h;
+ peripheral_gpio_h pin2_h;
+} motor_driver_s;
+
+static motor_driver_s g_md_h[MOTOR_ID_MAX] = {
+ {0, 0, 0, MOTOR_STATE_NONE, NULL, NULL},
+};
+
+
+/* see Principle section in http://wiki.sunfounder.cc/index.php?title=Motor_Driver_Module-L298N */
+
+static int __motor_brake_n_stop_by_id(motor_id_e id)
+{
+ int ret = PERIPHERAL_ERROR_NONE;
+ int motor1_v = 0;
+ int motor2_v = 0;
+
+ if (g_md_h[id].motor_state <= MOTOR_STATE_CONFIGURED) {
+ _E("motor[%d] are not initialized - state(%d)",
+ id, g_md_h[id].motor_state);
+ return -1;
+ }
+
+ if (g_md_h[id].motor_state == MOTOR_STATE_STOP) {
+ _D("motor[%d] is already stopped", id);
+ return 0;
+ }
+
+ if (g_md_h[id].motor_state == MOTOR_STATE_FORWARD) {
+ motor1_v = 0;
+ motor2_v = 0;
+ } else if (g_md_h[id].motor_state == MOTOR_STATE_BACKWARD) {
+ motor1_v = 1;
+ motor2_v = 1;
+ }
+
+ /* Brake DC motor */
+ ret = peripheral_gpio_write(g_md_h[id].pin1_h, motor1_v);
+ if (ret != PERIPHERAL_ERROR_NONE) {
+ _E("Failed to set value[%d] Motor[%d] pin 1", motor1_v, id);
+ return -1;
+ }
+
+ ret = peripheral_gpio_write(g_md_h[id].pin2_h, motor2_v);
+ if (ret != PERIPHERAL_ERROR_NONE) {
+ _E("Failed to set value[%d] Motor[%d] pin 2", motor2_v, id);
+ return -1;
+ }
+
+ /* set stop DC motor */
+ // need to stop motor or not?, it may stop motor to free running
+ resource_pca9685_set_value_to_channel(g_md_h[id].en_ch, 0, 0);
+
+ g_md_h[id].motor_state = MOTOR_STATE_STOP;
+
+ return 0;
+}
+
+static int __set_default_configuration_by_id(motor_id_e id)
+{
+ unsigned int pin_1, pin_2, en_ch;
+
+ switch (id) {
+ case MOTOR_ID_1:
+ pin_1 = DEFAULT_MOTOR1_PIN1;
+ pin_2 = DEFAULT_MOTOR1_PIN2;
+ en_ch = DEFAULT_MOTOR1_EN_CH;
+ break;
+ case MOTOR_ID_2:
+ pin_1 = DEFAULT_MOTOR2_PIN1;
+ pin_2 = DEFAULT_MOTOR2_PIN2;
+ en_ch = DEFAULT_MOTOR2_EN_CH;
+ break;
+ case MOTOR_ID_3:
+ pin_1 = DEFAULT_MOTOR3_PIN1;
+ pin_2 = DEFAULT_MOTOR3_PIN2;
+ en_ch = DEFAULT_MOTOR3_EN_CH;
+ break;
+ case MOTOR_ID_4:
+ pin_1 = DEFAULT_MOTOR4_PIN1;
+ pin_2 = DEFAULT_MOTOR4_PIN2;
+ en_ch = DEFAULT_MOTOR4_EN_CH;
+ break;
+ case MOTOR_ID_MAX:
+ default:
+ _E("Unkwon ID[%d]", id);
+ return -1;
+ break;
+ }
+
+ g_md_h[id].pin_1 = pin_1;
+ g_md_h[id].pin_2 = pin_2;
+ g_md_h[id].en_ch = en_ch;
+ g_md_h[id].motor_state = MOTOR_STATE_CONFIGURED;
+
+ return 0;
+}
+
+static int __fini_motor_by_id(motor_id_e id)
+{
+ retv_if(id == MOTOR_ID_MAX, -1);
+
+ if (g_md_h[id].motor_state <= MOTOR_STATE_CONFIGURED)
+ return 0;
+
+ if (g_md_h[id].motor_state > MOTOR_STATE_STOP)
+ __motor_brake_n_stop_by_id(id);
+
+ resource_pca9685_fini(g_md_h[id].en_ch);
+
+ if (g_md_h[id].pin1_h) {
+ peripheral_gpio_close(g_md_h[id].pin1_h);
+ g_md_h[id].pin1_h = NULL;
+ }
+
+ if (g_md_h[id].pin2_h) {
+ peripheral_gpio_close(g_md_h[id].pin2_h);
+ g_md_h[id].pin2_h = NULL;
+ }
+
+ g_md_h[id].motor_state = MOTOR_STATE_CONFIGURED;
+
+ return 0;
+}
+
+static int __init_motor_by_id(motor_id_e id)
+{
+ int ret = 0;
+
+ retv_if(id == MOTOR_ID_MAX, -1);
+
+ if (g_md_h[id].motor_state == MOTOR_STATE_NONE)
+ __set_default_configuration_by_id(id);
+
+ ret = resource_pca9685_init(g_md_h[id].en_ch);
+ if (ret) {
+ _E("failed to init PCA9685");
+ return -1;
+ }
+
+ /* open pins for Motor */
+ ret = peripheral_gpio_open(g_md_h[id].pin_1, &g_md_h[id].pin1_h);
+ if (ret == PERIPHERAL_ERROR_NONE)
+ peripheral_gpio_set_direction(g_md_h[id].pin1_h,
+ PERIPHERAL_GPIO_DIRECTION_OUT_INITIALLY_LOW);
+ else {
+ _E("failed to open Motor[%d] gpio pin1[%u]", id, g_md_h[id].pin_1);
+ goto ERROR;
+ }
+
+ ret = peripheral_gpio_open(g_md_h[id].pin_2, &g_md_h[id].pin2_h);
+ if (ret == PERIPHERAL_ERROR_NONE)
+ peripheral_gpio_set_direction(g_md_h[id].pin2_h,
+ PERIPHERAL_GPIO_DIRECTION_OUT_INITIALLY_LOW);
+ else {
+ _E("failed to open Motor[%d] gpio pin2[%u]", id, g_md_h[id].pin_2);
+ goto ERROR;
+ }
+
+ g_md_h[id].motor_state = MOTOR_STATE_STOP;
+
+ return 0;
+
+ERROR:
+ resource_pca9685_fini(g_md_h[id].en_ch);
+
+ if (g_md_h[id].pin1_h) {
+ peripheral_gpio_close(g_md_h[id].pin1_h);
+ g_md_h[id].pin1_h = NULL;
+ }
+
+ if (g_md_h[id].pin2_h) {
+ peripheral_gpio_close(g_md_h[id].pin2_h);
+ g_md_h[id].pin2_h = NULL;
+ }
+
+ return -1;
+}
+
+void resource_close_motor_driver_L298N(motor_id_e id)
+{
+ __fini_motor_by_id(id);
+ return;
+}
+
+void resource_close_motor_driver_L298N_all(void)
+{
+ int i;
+ for (i = MOTOR_ID_1; i < MOTOR_ID_MAX; i++)
+ __fini_motor_by_id(i);
+
+ return;
+}
+
+int resource_set_motor_driver_L298N_configuration(motor_id_e id,
+ unsigned int pin1, unsigned int pin2, unsigned en_ch)
+{
+
+ if (g_md_h[id].motor_state > MOTOR_STATE_CONFIGURED) {
+ _E("cannot set configuration motor[%d] in this state[%d]",
+ id, g_md_h[id].motor_state);
+ return -1;
+ }
+
+ g_md_h[id].pin_1 = pin1;
+ g_md_h[id].pin_2 = pin2;
+ g_md_h[id].en_ch = en_ch;
+ g_md_h[id].motor_state = MOTOR_STATE_CONFIGURED;
+
+ return 0;
+}
+
+int resource_set_motor_driver_L298N_speed(motor_id_e id, int speed)
+{
+ int ret = 0;
+ const int value_max = 4095;
+ int value = 0;
+ int e_state = MOTOR_STATE_NONE;
+ int motor_v_1 = 0;
+ int motor_v_2 = 0;
+
+ if (g_md_h[id].motor_state <= MOTOR_STATE_CONFIGURED) {
+ ret = __init_motor_by_id(id);
+ if (ret) {
+ _E("failed to __init_motor_by_id()");
+ return -1;
+ }
+ }
+
+ value = abs(speed);
+
+ if (value > value_max) {
+ value = value_max;
+ _D("max speed is %d", value_max);
+ }
+ _D("set speed %d", value);
+
+ if (speed == 0) {
+ /* brake and stop */
+ ret = __motor_brake_n_stop_by_id(id);
+ if (ret) {
+ _E("failed to stop motor[%d]", id);
+ return -1;
+ }
+ return 0; /* done */
+ }
+
+ if (speed > 0)
+ e_state = MOTOR_STATE_FORWARD; /* will be set forward */
+ else
+ e_state = MOTOR_STATE_BACKWARD; /* will be set backward */
+
+ if (g_md_h[id].motor_state == e_state)
+ goto SET_SPEED;
+ else {
+ /* brake and stop */
+ ret = __motor_brake_n_stop_by_id(id);
+ if (ret) {
+ _E("failed to stop motor[%d]", id);
+ return -1;
+ }
+ }
+
+ switch (e_state) {
+ case MOTOR_STATE_FORWARD:
+ motor_v_1 = 1;
+ motor_v_2 = 0;
+ break;
+ case MOTOR_STATE_BACKWARD:
+ motor_v_1 = 0;
+ motor_v_2 = 1;
+ break;
+ }
+ ret = peripheral_gpio_write(g_md_h[id].pin1_h, motor_v_1);
+ if (ret != PERIPHERAL_ERROR_NONE) {
+ _E("failed to set value[%d] Motor[%d] pin 1", motor_v_1, id);
+ return -1;
+ }
+
+ ret = peripheral_gpio_write(g_md_h[id].pin2_h, motor_v_2);
+ if (ret != PERIPHERAL_ERROR_NONE) {
+ _E("failed to set value[%d] Motor[%d] pin 2", motor_v_2, id);
+ return -1;
+ }
+
+SET_SPEED:
+ ret = resource_pca9685_set_value_to_channel(g_md_h[id].en_ch, 0, value);
+ if (ret) {
+ _E("failed to set speed - %d", speed);
+ return -1;
+ }
+
+ g_md_h[id].motor_state = e_state;
+
+ return 0;
+}
diff --git a/src/resource/resource_rain_sensor.c b/src/resource/resource_rain_sensor.c
new file mode 100755
index 0000000..b73003f
--- /dev/null
+++ b/src/resource/resource_rain_sensor.c
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ * Geunsun Lee <gs86.lee@samsung.com>
+ * Eunyoung Lee <ey928.lee@samsung.com>
+ * Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+#include <unistd.h>
+
+#include "log.h"
+#include "resource_internal.h"
+
+void resource_close_rain_sensor(int pin_num)
+{
+ if (!resource_get_info(pin_num)->opened) return;
+
+ _I("Rain Sensor is finishing...");
+ peripheral_gpio_close(resource_get_info(pin_num)->sensor_h);
+ resource_get_info(pin_num)->opened = 0;
+}
+
+int resource_read_rain_sensor(int pin_num, uint32_t *out_value)
+{
+ int ret = PERIPHERAL_ERROR_NONE;
+
+ if (!resource_get_info(pin_num)->opened) {
+ ret = peripheral_gpio_open(pin_num, &resource_get_info(pin_num)->sensor_h);
+ retv_if(!resource_get_info(pin_num)->sensor_h, -1);
+
+ ret = peripheral_gpio_set_direction(resource_get_info(pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_IN);
+ retv_if(ret != 0, -1);
+
+ resource_get_info(pin_num)->opened = 1;
+ resource_get_info(pin_num)->close = resource_close_flame_sensor;
+ }
+
+ /**
+ * This model(FC-37 + YL-38) normally outputs 1, and outputs 0 as out_value when a rain is detected.
+ */
+ ret = peripheral_gpio_read(resource_get_info(pin_num)->sensor_h, out_value);
+ retv_if(ret < 0, -1);
+
+ *out_value = !*out_value;
+
+ return 0;
+}
diff --git a/src/resource/resource_servo_motor.c b/src/resource/resource_servo_motor.c
new file mode 100644
index 0000000..e16df2e
--- /dev/null
+++ b/src/resource/resource_servo_motor.c
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jeonghoon Park <jh1979.park@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "log.h"
+#include "resource/resource_PCA9685.h"
+
+#define SERVO_MOTOR_MAX PCA9685_CH_MAX
+
+static int servo_motor_index[SERVO_MOTOR_MAX + 1] = {0, };
+
+static int resource_servo_motor_init(unsigned int ch)
+{
+ int ret = 0;
+ ret = resource_pca9685_init(ch);
+ if (ret) {
+ _E("failed to init PCA9685 with ch[%u]", ch);
+ return -1;
+ }
+ servo_motor_index[ch] = 1;
+
+ return 0;
+}
+
+void resource_close_servo_motor(unsigned int ch)
+{
+ if (servo_motor_index[ch] == 1) {
+ resource_pca9685_fini(ch);
+ servo_motor_index[ch] = 0;
+ }
+
+ return;
+}
+
+void resource_close_servo_motor_all(void)
+{
+ unsigned int i;
+
+ for (i = 0 ; i <= SERVO_MOTOR_MAX; i++)
+ resource_close_servo_motor(i);
+
+ return;
+}
+
+int resource_set_servo_motor_value(unsigned int motor_id, int value)
+{
+ int ret = 0;
+
+ if (motor_id > SERVO_MOTOR_MAX)
+ return -1;
+
+ if (servo_motor_index[motor_id] == 0) {
+ ret = resource_servo_motor_init(motor_id);
+ if (ret)
+ return -1;
+ }
+
+ ret = resource_pca9685_set_value_to_channel(motor_id, 0, value);
+
+ return ret;
+}
diff --git a/src/resource/resource_sound_detection_sensor.c b/src/resource/resource_sound_detection_sensor.c
new file mode 100644
index 0000000..c03c7b8
--- /dev/null
+++ b/src/resource/resource_sound_detection_sensor.c
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ * Geunsun Lee <gs86.lee@samsung.com>
+ * Eunyoung Lee <ey928.lee@samsung.com>
+ * Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <peripheral_io.h>
+#include <sys/time.h>
+
+#include "log.h"
+#include "resource_internal.h"
+
+void resource_close_sound_detection_sensor(int pin_num)
+{
+ if (!resource_get_info(pin_num)->opened) return;
+
+ _I("Sound Sensor is finishing...");
+ peripheral_gpio_close(resource_get_info(pin_num)->sensor_h);
+ resource_get_info(pin_num)->opened = 0;
+}
+
+int resource_read_sound_detection_sensor(int pin_num, uint32_t *out_value)
+{
+ int ret = PERIPHERAL_ERROR_NONE;
+
+ if (!resource_get_info(pin_num)->opened) {
+ ret = peripheral_gpio_open(pin_num, &resource_get_info(pin_num)->sensor_h);
+ retv_if(!resource_get_info(pin_num)->sensor_h, -1);
+
+ ret = peripheral_gpio_set_direction(resource_get_info(pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_IN);
+ retv_if(ret != 0, -1);
+
+ resource_get_info(pin_num)->opened = 1;
+ resource_get_info(pin_num)->close = resource_close_sound_detection_sensor;
+ }
+
+ /**
+ * This model(NS-SDSM) normally outputs 1, and outputs 0 as out_value when sound is detected.
+ */
+ ret = peripheral_gpio_read(resource_get_info(pin_num)->sensor_h, out_value);
+ retv_if(ret < 0, -1);
+
+ *out_value = !*out_value;
+
+ return 0;
+}
diff --git a/src/resource/resource_sound_level_sensor.c b/src/resource/resource_sound_level_sensor.c
new file mode 100644
index 0000000..9118862
--- /dev/null
+++ b/src/resource/resource_sound_level_sensor.c
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ * Geunsun Lee <gs86.lee@samsung.com>
+ * Eunyoung Lee <ey928.lee@samsung.com>
+ * Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <peripheral_io.h>
+#include <sys/time.h>
+
+#include "log.h"
+#include "resource/resource_adc_mcp3008.h"
+
+static bool initialized = false;
+
+void resource_close_sound_level_sensor(void)
+{
+ resource_adc_mcp3008_fini();
+ initialized = false;
+}
+
+int resource_read_sound_level_sensor(int ch_num, unsigned int *out_value)
+{
+ unsigned int read_value = 0;
+ int ret = 0;
+
+ if (!initialized) {
+ ret = resource_adc_mcp3008_init();
+ retv_if(ret != 0, -1);
+ initialized = true;
+ }
+ ret = resource_read_adc_mcp3008(ch_num, &read_value);
+ retv_if(ret != 0, -1);
+
+ *out_value = read_value;
+
+ return 0;
+}
+
diff --git a/src/resource/resource_tilt_sensor.c b/src/resource/resource_tilt_sensor.c
new file mode 100644
index 0000000..f47c3c7
--- /dev/null
+++ b/src/resource/resource_tilt_sensor.c
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ * Geunsun Lee <gs86.lee@samsung.com>
+ * Eunyoung Lee <ey928.lee@samsung.com>
+ * Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <peripheral_io.h>
+#include <sys/time.h>
+
+#include "log.h"
+#include "resource_internal.h"
+
+void resource_close_tilt_sensor(int pin_num)
+{
+ if (!resource_get_info(pin_num)->opened) return;
+
+ _I("Infrared Motion Sensor is finishing...");
+ peripheral_gpio_close(resource_get_info(pin_num)->sensor_h);
+ resource_get_info(pin_num)->opened = 0;
+}
+
+int resource_read_tilt_sensor(int pin_num, uint32_t *out_value)
+{
+ int ret = PERIPHERAL_ERROR_NONE;
+
+ if (!resource_get_info(pin_num)->opened) {
+ ret = peripheral_gpio_open(pin_num, &resource_get_info(pin_num)->sensor_h);
+ retv_if(!resource_get_info(pin_num)->sensor_h, -1);
+
+ ret = peripheral_gpio_set_direction(resource_get_info(pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_IN);
+ retv_if(ret != 0, -1);
+
+ resource_get_info(pin_num)->opened = 1;
+ resource_get_info(pin_num)->close = resource_close_tilt_sensor;
+ }
+
+ /**
+ * This model(SZH-EK084) normally outputs 1, and outputs 0 as out_value when the sensor is tilted.
+ */
+ ret = peripheral_gpio_read(resource_get_info(pin_num)->sensor_h, out_value);
+ retv_if(ret < 0, -1);
+
+ *out_value = !*out_value;
+
+ return 0;
+}
diff --git a/src/resource/resource_touch_sensor.c b/src/resource/resource_touch_sensor.c
new file mode 100644
index 0000000..fc946e4
--- /dev/null
+++ b/src/resource/resource_touch_sensor.c
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ * Geunsun Lee <gs86.lee@samsung.com>
+ * Eunyoung Lee <ey928.lee@samsung.com>
+ * Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <peripheral_io.h>
+#include <sys/time.h>
+
+#include "log.h"
+#include "resource_internal.h"
+
+void resource_close_touch_sensor(int pin_num)
+{
+ if (!resource_get_info(pin_num)->opened) return;
+
+ _I("Touch Sensor is finishing...");
+ peripheral_gpio_close(resource_get_info(pin_num)->sensor_h);
+ resource_get_info(pin_num)->opened = 0;
+}
+
+int resource_read_touch_sensor(int pin_num, uint32_t *out_value)
+{
+ int ret = PERIPHERAL_ERROR_NONE;
+
+ if (!resource_get_info(pin_num)->opened) {
+ _I("Touch sensor is initializing...");
+
+ ret = peripheral_gpio_open(pin_num, &resource_get_info(pin_num)->sensor_h);
+ retv_if(!resource_get_info(pin_num)->sensor_h, -1);
+
+ ret = peripheral_gpio_set_direction(resource_get_info(pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_IN);
+ retv_if(ret != 0, -1);
+
+ resource_get_info(pin_num)->opened = 1;
+ resource_get_info(pin_num)->close = resource_close_touch_sensor;
+ }
+
+ ret = peripheral_gpio_read(resource_get_info(pin_num)->sensor_h, out_value);
+ retv_if(ret < 0, -1);
+
+ _I("Touch Sensor Value : %d", *out_value);
+
+ return 0;
+}
diff --git a/src/resource/resource_ultrasonic_sensor.c b/src/resource/resource_ultrasonic_sensor.c
new file mode 100644
index 0000000..4a9b035
--- /dev/null
+++ b/src/resource/resource_ultrasonic_sensor.c
@@ -0,0 +1,157 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ * Geunsun Lee <gs86.lee@samsung.com>
+ * Eunyoung Lee <ey928.lee@samsung.com>
+ * Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <peripheral_io.h>
+#include <sys/time.h>
+#include <gio/gio.h>
+
+#include "log.h"
+#include "resource_internal.h"
+
+static resource_read_s *resource_read_info = NULL;
+static unsigned long long triggered_time = 0;
+
+void resource_close_ultrasonic_sensor_trig(int trig_pin_num)
+{
+ if (!resource_get_info(trig_pin_num)->opened) return;
+
+ _I("Ultrasonic sensor's trig is finishing...");
+
+ peripheral_gpio_close(resource_get_info(trig_pin_num)->sensor_h);
+ resource_get_info(trig_pin_num)->opened = 0;
+}
+
+void resource_close_ultrasonic_sensor_echo(int echo_pin_num)
+{
+ if (!resource_get_info(echo_pin_num)->opened) return;
+
+ _I("Ultrasonic sensor's echo is finishing...");
+
+ peripheral_gpio_close(resource_get_info(echo_pin_num)->sensor_h);
+ resource_get_info(echo_pin_num)->opened = 0;
+ free(resource_read_info);
+ resource_read_info = NULL;
+}
+
+static unsigned long long _get_timestamp(void)
+{
+ struct timespec t;
+ clock_gettime(CLOCK_REALTIME, &t);
+ return ((unsigned long long)(t.tv_sec)*1000000000LL + t.tv_nsec) / 1000;
+}
+
+static void _resource_read_ultrasonic_sensor_cb(peripheral_gpio_h gpio, peripheral_error_e error, void *user_data)
+{
+ float dist = 0;
+ uint32_t value;
+ unsigned long long returned_time = 0;
+ resource_read_s *resource_read_info = user_data;
+
+ ret_if(!resource_read_info);
+ ret_if(!resource_read_info->cb);
+
+ peripheral_gpio_read(gpio, &value);
+
+ if (value == 1) {
+ triggered_time = _get_timestamp();
+ } else if (value == 0) {
+ returned_time = _get_timestamp();
+ }
+
+ if (triggered_time > 0 && value == 0) {
+ dist = returned_time - triggered_time;
+ if (dist < 150 || dist > 25000) {
+ dist = -1;
+ } else {
+ dist = (dist * 34300) / 2000000;
+ }
+
+ resource_read_info->cb(dist, resource_read_info->data);
+ }
+}
+
+int resource_read_ultrasonic_sensor(int trig_pin_num, int echo_pin_num, resource_read_cb cb, void *data)
+{
+ int ret = 0;
+
+ triggered_time = 0;
+
+ if (resource_read_info == NULL) {
+ resource_read_info = calloc(1, sizeof(resource_read_s));
+ retv_if(!resource_read_info, -1);
+ } else {
+ peripheral_gpio_unset_interrupted_cb(resource_get_info(resource_read_info->pin_num)->sensor_h);
+ }
+ resource_read_info->cb = cb;
+ resource_read_info->data = data;
+ resource_read_info->pin_num = echo_pin_num;
+
+ if (!resource_get_info(trig_pin_num)->opened) {
+ _I("Ultrasonic sensor's trig is initializing...");
+
+ ret = peripheral_gpio_open(trig_pin_num, &resource_get_info(trig_pin_num)->sensor_h);
+ retv_if(!resource_get_info(trig_pin_num)->sensor_h, -1);
+
+ ret = peripheral_gpio_set_direction(resource_get_info(trig_pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_OUT_INITIALLY_LOW);
+ retv_if(ret != 0, -1);
+
+ resource_get_info(trig_pin_num)->opened = 1;
+ resource_get_info(trig_pin_num)->close = resource_close_ultrasonic_sensor_trig;
+ }
+
+ if (!resource_get_info(echo_pin_num)->opened) {
+ _I("Ultrasonic sensor's echo is initializing...");
+
+ ret = peripheral_gpio_open(echo_pin_num, &resource_get_info(echo_pin_num)->sensor_h);
+ retv_if(!resource_get_info(echo_pin_num)->sensor_h, -1);
+
+ ret = peripheral_gpio_set_direction(resource_get_info(echo_pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_IN);
+ retv_if(ret != 0, -1);
+
+ ret = peripheral_gpio_set_edge_mode(resource_get_info(echo_pin_num)->sensor_h, PERIPHERAL_GPIO_EDGE_BOTH);
+ retv_if(ret != 0, -1);
+
+ resource_get_info(echo_pin_num)->opened = 1;
+ resource_get_info(echo_pin_num)->close = resource_close_ultrasonic_sensor_echo;
+ }
+
+ if (resource_get_info(echo_pin_num)->sensor_h) {
+ ret = peripheral_gpio_set_interrupted_cb(resource_get_info(echo_pin_num)->sensor_h, _resource_read_ultrasonic_sensor_cb, resource_read_info);
+ retv_if(ret != 0, -1);
+ }
+
+ ret = peripheral_gpio_write(resource_get_info(trig_pin_num)->sensor_h, 0);
+ retv_if(ret < 0, -1);
+
+ usleep(20000);
+
+ ret = peripheral_gpio_write(resource_get_info(trig_pin_num)->sensor_h, 1);
+ retv_if(ret < 0, -1);
+
+ usleep(20000);
+
+ ret = peripheral_gpio_write(resource_get_info(trig_pin_num)->sensor_h, 0);
+ retv_if(ret < 0, -1);
+
+ return 0;
+}
diff --git a/src/resource/resource_vibration_sensor.c b/src/resource/resource_vibration_sensor.c
new file mode 100644
index 0000000..686e8f7
--- /dev/null
+++ b/src/resource/resource_vibration_sensor.c
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ * Geunsun Lee <gs86.lee@samsung.com>
+ * Eunyoung Lee <ey928.lee@samsung.com>
+ * Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <peripheral_io.h>
+#include <sys/time.h>
+
+#include "log.h"
+#include "resource_internal.h"
+
+void resource_close_vibration_sensor(int pin_num)
+{
+ if (!resource_get_info(pin_num)->opened) return;
+
+ _I("Vibration Sensor is finishing...");
+ peripheral_gpio_close(resource_get_info(pin_num)->sensor_h);
+ resource_get_info(pin_num)->opened = 0;
+}
+
+int resource_read_vibration_sensor(int pin_num, uint32_t *out_value)
+{
+ int ret = PERIPHERAL_ERROR_NONE;
+
+ if (!resource_get_info(pin_num)->opened) {
+ ret = peripheral_gpio_open(pin_num, &resource_get_info(pin_num)->sensor_h);
+ retv_if(!resource_get_info(pin_num)->sensor_h, -1);
+
+ ret = peripheral_gpio_set_direction(resource_get_info(pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_IN);
+ retv_if(ret != 0, -1);
+
+ resource_get_info(pin_num)->opened = 1;
+ resource_get_info(pin_num)->close = resource_close_vibration_sensor;
+ }
+
+ ret = peripheral_gpio_read(resource_get_info(pin_num)->sensor_h, out_value);
+ retv_if(ret < 0, -1);
+
+ return 0;
+}
diff --git a/src/webutil.c b/src/webutil.c
new file mode 100644
index 0000000..7afde87
--- /dev/null
+++ b/src/webutil.c
@@ -0,0 +1,695 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ * Geunsun Lee <gs86.lee@samsung.com>
+ * Eunyoung Lee <ey928.lee@samsung.com>
+ * Junkyu Han <junkyu.han@samsung.com>
+ * Jeonghoon Park <jh1979.park@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdbool.h>
+#include <curl/curl.h>
+#include <glib.h>
+#include <json-glib/json-glib.h>
+#include "log.h"
+#include "webutil.h"
+
+#define URI_PATH_LEN 64
+#define REQ_CON_TIMEOUT 5L
+#define REQ_TIMEOUT 7L
+
+typedef struct _wu_json_handle {
+ JsonBuilder *builder;
+ bool is_begin;
+ bool is_end;
+} wu_json_handle;
+
+static wu_json_handle Json_h = {NULL, false, false};
+
+static size_t _post_response_write_callback(char *ptr, size_t size, size_t nmemb, void *userdata)
+{
+ size_t res_size = 0;
+
+ res_size = size*nmemb;
+
+ if (res_size > 0)
+ _I("POST response : %s", ptr);
+ /* What should we do here, if response body has negative message? */
+
+ return res_size;
+}
+
+static size_t _get_response_write_callback(void *ptr, size_t size, size_t nmemb, void *data)
+{
+ size_t res_size = 0;
+ char **received = (char **)data;
+
+ res_size = size*nmemb;
+
+ if (received && res_size > 0)
+ *received = strndup((char *)ptr, size*nmemb);
+ else
+ _E("fail to get response [res size : %d]", res_size);
+
+ return res_size;
+}
+
+static int __curl_debug(CURL *handle, curl_infotype type,
+ char *data, size_t size, void *userptr)
+{
+ const char *prefix = NULL;
+ char *message = NULL;
+
+ switch (type) {
+ case CURLINFO_END:
+ return 0;
+ case CURLINFO_TEXT:
+ _D("== text Info: %s", data);
+ return 0;
+ case CURLINFO_HEADER_OUT:
+ prefix = "=> Send header:";
+ break;
+ case CURLINFO_DATA_OUT:
+ prefix = "=> Send data:";
+ break;
+ case CURLINFO_SSL_DATA_OUT:
+ prefix = "=> Send SSL data:";
+ break;
+ case CURLINFO_HEADER_IN:
+ prefix = "<= Recv header:";
+ break;
+ case CURLINFO_DATA_IN:
+ prefix = "<= Recv data:";
+ break;
+ case CURLINFO_SSL_DATA_IN:
+ prefix = "<= Recv SSL data:";
+ break;
+ }
+ message = g_strndup(data, size);
+ _D("%s %s", prefix, message);
+ g_free(message);
+ return 0;
+}
+
+static const char *_get_time_str(void)
+{
+ struct timeval val;
+ struct tm *ptm;
+ static char res_time[40] = {0, };
+
+ gettimeofday(&val, NULL);
+ ptm = localtime(&val.tv_sec);
+
+ // format : YY-MM-DD_hh:mm:ss:uuuuuu
+ snprintf(res_time, sizeof(res_time), "%04d-%02d-%02d_%02d:%02d:%02d:%06ld"
+ , ptm->tm_year + 1900, ptm->tm_mon + 1, ptm->tm_mday
+ , ptm->tm_hour, ptm->tm_min, ptm->tm_sec
+ , val.tv_usec);
+
+ return (const char *)res_time;
+}
+
+
+int web_util_noti_init(void)
+{
+ int ret = 0;
+ CURLcode result;
+ result = curl_global_init(CURL_GLOBAL_DEFAULT);
+ if (result != CURLE_OK) {
+ _E("curl_global_init() failed: %s",
+ curl_easy_strerror(result));
+ ret = -1;
+ }
+ return ret;
+}
+
+void web_util_noti_fini(void)
+{
+ curl_global_cleanup();
+ return;
+}
+
+int web_util_noti_post_image_data(const char *url, const char *device_id,
+ const void *image_data, unsigned int image_size)
+{
+ int ret = 0;
+ CURL *curl = NULL;
+ CURLcode response = CURLE_OK;
+ struct curl_httppost *formpost = NULL;
+ struct curl_httppost *lastptr = NULL;
+ char *filename = NULL;
+ char *post_url = NULL;
+
+ retv_if(url == NULL, -1);
+ retv_if(device_id == NULL, -1);
+ retv_if(image_data == NULL, -1);
+ retv_if(image_size == 0, -1);
+
+ curl = curl_easy_init();
+
+ if (!curl) {
+ _E("fail to init curl");
+ return -1;
+ }
+
+ filename = g_strdup_printf("%s_%s.jpg", device_id, _get_time_str());
+ post_url = g_strdup_printf("%s?id=%s", url, device_id);
+ _D("FileName: [%s], PostUrl: [%s]", filename, post_url);
+
+ curl_formadd(&formpost, &lastptr,
+ CURLFORM_COPYNAME, "content-type:",
+ CURLFORM_COPYCONTENTS, "multipart/form-data",
+ CURLFORM_END);
+
+ curl_formadd(&formpost, &lastptr,
+ CURLFORM_COPYNAME, "imageFile",
+ CURLFORM_BUFFER, filename,
+ CURLFORM_BUFFERPTR, image_data,
+ CURLFORM_BUFFERLENGTH, image_size,
+ CURLFORM_END);
+
+ curl_easy_setopt(curl, CURLOPT_URL, post_url);
+ curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
+
+ /* if CURLOPT_VERBOSE is enabled, __curl_debug() function will be called */
+ // curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
+ curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, __curl_debug);
+
+ // curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, REQ_CON_TIMEOUT);
+ // curl_easy_setopt(curl, CURLOPT_TIMEOUT, REQ_TIMEOUT);
+
+ response = curl_easy_perform(curl);
+
+ if (response != CURLE_OK) {
+ _E("curl_easy_perform() failed: %s",
+ curl_easy_strerror(response));
+ ret = -1;
+ }
+
+ curl_easy_cleanup(curl);
+ curl_formfree(formpost);
+ g_free(post_url);
+ g_free(filename);
+
+ return ret;
+}
+
+int web_util_noti_post(const char *resource, const char *json_data)
+{
+ int ret = 0;
+ CURL *curl = NULL;
+ CURLcode response = CURLE_OK;
+ struct curl_slist *headers = NULL;
+
+ retv_if(resource == NULL, -1);
+ retv_if(json_data == NULL, -1);
+
+ _I("server : %s", resource);
+ _I("json_data : %s", json_data);
+
+ curl = curl_easy_init();
+
+ if (!curl) {
+ _E("fail to init curl");
+ return -1;
+ }
+
+ headers = curl_slist_append(headers, "Accept: application/json");
+ headers = curl_slist_append(headers, "Content-Type: application/json");
+
+ curl_easy_setopt(curl, CURLOPT_URL, resource);
+ curl_easy_setopt(curl, CURLOPT_POST, 1L);
+ curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
+ curl_easy_setopt(curl, CURLOPT_POSTFIELDS, json_data);
+ curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, _post_response_write_callback);
+ curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, REQ_CON_TIMEOUT);
+ curl_easy_setopt(curl, CURLOPT_TIMEOUT, REQ_TIMEOUT);
+
+ response = curl_easy_perform(curl);
+
+ if (response != CURLE_OK) {
+ _E("curl_easy_perform() failed: %s",
+ curl_easy_strerror(response));
+ /* What should we do here, if response is kind of errors? */
+ ret = -1;
+ }
+
+ curl_slist_free_all(headers);
+ curl_easy_cleanup(curl);
+
+ return ret;
+}
+
+int web_util_noti_get(const char *resource, char **res)
+{
+ int ret = 0;
+ CURL *curl = NULL;
+ CURLcode response = CURLE_OK;
+
+ retv_if(resource == NULL, -1);
+
+ _I("GET to [%s]", resource);
+
+ curl = curl_easy_init();
+
+ if (!curl) {
+ _E("fail to init curl");
+ return -1;
+ }
+
+ curl_easy_setopt(curl, CURLOPT_URL, resource);
+ curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, _get_response_write_callback);
+ curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)res);
+ curl_easy_setopt(curl, CURLOPT_USERAGENT, "tizen-iot-agent/1.0");
+ curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, REQ_CON_TIMEOUT);
+
+ response = curl_easy_perform(curl);
+
+ if (response != CURLE_OK) {
+ _E("curl_easy_perform() failed: %s",
+ curl_easy_strerror(response));
+ /* What should we do here, if response is kind of errors? */
+ ret = -1;
+ }
+
+ curl_easy_cleanup(curl);
+
+ return ret;
+}
+
+int web_util_json_init(void)
+{
+ if (Json_h.builder)
+ g_object_unref(Json_h.builder);
+
+ Json_h.is_begin = false;
+ Json_h.is_end = false;
+ Json_h.builder = json_builder_new();
+ retv_if(Json_h.builder == NULL, -1);
+
+ return 0;
+}
+
+int web_util_json_fini(void)
+{
+
+ if (Json_h.builder) {
+ g_object_unref(Json_h.builder);
+ Json_h.builder = NULL;
+ }
+
+ Json_h.is_begin = false;
+ Json_h.is_end = false;
+
+ return 0;
+}
+
+int web_util_json_begin(void)
+{
+ retv_if(Json_h.builder == NULL, -1);
+ retv_if(Json_h.is_begin == true, -1);
+ retv_if(Json_h.is_end == true, -1);
+
+ Json_h.is_begin = true;
+
+ json_builder_begin_object(Json_h.builder);
+
+ return 0;
+}
+
+int web_util_json_end(void)
+{
+ retv_if(Json_h.builder == NULL, -1);
+ retv_if(Json_h.is_begin == false, -1);
+ retv_if(Json_h.is_end == true, -1);
+
+ json_builder_end_object(Json_h.builder);
+ Json_h.is_end = true;
+
+ return 0;
+}
+
+int web_util_json_add_int(const char* key, long long int value)
+{
+ retv_if(!key, -1);
+
+ if (Json_h.builder == NULL) {
+ _E("Handle for json is not initialized, call web_util_json_init() first");
+ return -1;
+ }
+
+ if (Json_h.is_begin == false) {
+ _E("json object has not begun, call web_util_json_begin() first");
+ return -1;
+ }
+
+ if (Json_h.is_end == true) {
+ _E("json object has already ended, call web_util_json_begin() first");
+ return -1;
+ }
+
+ json_builder_set_member_name(Json_h.builder, key);
+ json_builder_add_int_value(Json_h.builder, value);
+
+ return 0;
+}
+
+int web_util_json_add_double(const char* key, double value)
+{
+ retv_if(!key, -1);
+
+ if (Json_h.builder == NULL) {
+ _E("Handle for json is not initialized, call web_util_json_init() first");
+ return -1;
+ }
+
+ if (Json_h.is_begin == false) {
+ _E("json object has not begun, call web_util_json_begin() first");
+ return -1;
+ }
+
+ if (Json_h.is_end == true) {
+ _E("json object has already ended, call web_util_json_begin() first");
+ return -1;
+ }
+
+ json_builder_set_member_name(Json_h.builder, key);
+ json_builder_add_double_value(Json_h.builder, value);
+
+ return 0;
+}
+
+int web_util_json_add_boolean(const char* key, bool value)
+{
+ retv_if(!key, -1);
+
+ if (Json_h.builder == NULL) {
+ _E("Handle for json is not initialized, call web_util_json_init() first");
+ return -1;
+ }
+
+ if (Json_h.is_begin == false) {
+ _E("json object has not begun, call web_util_json_begin() first");
+ return -1;
+ }
+
+ if (Json_h.is_end == true) {
+ _E("json object has already ended, call web_util_json_begin() first");
+ return -1;
+ }
+
+ json_builder_set_member_name(Json_h.builder, key);
+ json_builder_add_boolean_value(Json_h.builder, value);
+
+ return 0;
+}
+
+int web_util_json_add_string(const char* key, const char *value)
+{
+ retv_if(!key, -1);
+
+ if (Json_h.builder == NULL) {
+ _E("Handle for json is not initialized, call web_util_json_init() first");
+ return -1;
+ }
+
+ if (Json_h.is_begin == false) {
+ _E("json object has not begun, call web_util_json_begin() first");
+ return -1;
+ }
+
+ if (Json_h.is_end == true) {
+ _E("json object has already ended, call web_util_json_begin() first");
+ return -1;
+ }
+
+ json_builder_set_member_name(Json_h.builder, key);
+ json_builder_add_string_value(Json_h.builder, value);
+
+ return 0;
+}
+
+int web_util_json_data_array_begin(void)
+{
+ int ret = 0;
+ retv_if(Json_h.builder == NULL, -1);
+
+ ret = web_util_json_begin();
+ retv_if(ret, -1);
+
+ json_builder_set_member_name(Json_h.builder, "SensorDataList");
+ json_builder_begin_array(Json_h.builder);
+
+ return 0;
+}
+
+int web_util_json_data_array_end(void)
+{
+ retv_if(Json_h.builder == NULL, -1);
+ retv_if(Json_h.is_begin == false, -1);
+ retv_if(Json_h.is_end == true, -1);
+
+ json_builder_end_array(Json_h.builder);
+ web_util_json_end();
+
+ return 0;
+}
+
+int web_util_json_add_sensor_data(const char* sensorpi_id, web_util_sensor_data_s *sensor_data)
+{
+ const char n_id[] = "SensorPiID";
+ const char n_motion[] = "Motion";
+ const char n_flame[] = "Flame";
+ const char n_hum[] = "Humidity";
+ const char n_temp[] = "Temperature";
+ const char n_vib[] = "Vibration";
+ const char n_co2[] = "CO2";
+ const char n_sound[] = "SoundLevel";
+ const char n_tilt[] = "Tilt";
+ const char n_light[] = "Light";
+ const char n_collision[] = "Collision";
+ const char n_obstacle[] = "Obstacle";
+ const char n_distance[] = "Distance";
+ const char n_rain[] = "Rain";
+ const char n_touch[] = "Touch";
+ const char n_gas[] = "Gas";
+ const char n_e_sensor[] = "SensorEnabled";
+ const char n_hash[] = "Hash";
+ const char n_ip[] = "SensorPiIP";
+
+ retv_if(!sensorpi_id, -1);
+ retv_if(Json_h.builder == NULL, -1);
+ retv_if(Json_h.is_begin == false, -1);
+ retv_if(Json_h.is_end == true, -1);
+ retv_if(sensor_data == NULL, -1);
+
+ /* JSON structure :
+ {
+ SensorPiID: string,
+ SensorPiIP: string,
+ Motion: boolean,
+ Flame: boolean,
+ Humidity: double,
+ Temperature: double,
+ Vibration: boolean,
+ CO2: double,
+ SoundLevel: int,
+ Tilt: int,
+ Light: int,
+ Collision: int,
+ Obstacle: int,
+ Distance: double,
+ Rain: int,
+ Touch: int,
+ Gas: int,
+ SensorEnabled: [Motion, ],
+ Hash: string,
+ }
+ */
+
+ json_builder_begin_object(Json_h.builder);
+
+ json_builder_set_member_name(Json_h.builder, n_id);
+ json_builder_add_string_value(Json_h.builder, sensorpi_id);
+
+ if (sensor_data->ip_addr) {
+ json_builder_set_member_name(Json_h.builder, n_ip);
+ json_builder_add_string_value(Json_h.builder, sensor_data->ip_addr);
+ }
+
+ if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_MOTION) {
+ json_builder_set_member_name(Json_h.builder, n_motion);
+ json_builder_add_int_value(Json_h.builder, sensor_data->motion);
+ }
+
+ if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_FLAME) {
+ json_builder_set_member_name(Json_h.builder, n_flame);
+ json_builder_add_int_value(Json_h.builder, sensor_data->flame);
+ }
+
+ if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_HUMIDITY) {
+ json_builder_set_member_name(Json_h.builder, n_hum);
+ json_builder_add_double_value(Json_h.builder, sensor_data->humidity);
+ }
+
+ if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_TEMPERATURE) {
+ json_builder_set_member_name(Json_h.builder, n_temp);
+ json_builder_add_double_value(Json_h.builder, sensor_data->temperature);
+ }
+
+ if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_VIB) {
+ json_builder_set_member_name(Json_h.builder, n_vib);
+ json_builder_add_int_value(Json_h.builder, sensor_data->virbration);
+ }
+
+ if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_CO2) {
+ json_builder_set_member_name(Json_h.builder, n_co2);
+ json_builder_add_double_value(Json_h.builder, sensor_data->co2);
+ }
+
+ if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_SOUND) {
+ json_builder_set_member_name(Json_h.builder, n_sound);
+ json_builder_add_int_value(Json_h.builder, sensor_data->soundlevel);
+ }
+
+ if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_TILT) {
+ json_builder_set_member_name(Json_h.builder, n_tilt);
+ json_builder_add_int_value(Json_h.builder, sensor_data->tilt);
+ }
+
+ if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_LIGHT) {
+ json_builder_set_member_name(Json_h.builder, n_light);
+ json_builder_add_int_value(Json_h.builder, sensor_data->light);
+ }
+
+ if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_COLLISION) {
+ json_builder_set_member_name(Json_h.builder, n_collision);
+ json_builder_add_int_value(Json_h.builder, sensor_data->collision);
+ }
+
+ if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_OBSTACLE) {
+ json_builder_set_member_name(Json_h.builder, n_obstacle);
+ json_builder_add_int_value(Json_h.builder, sensor_data->obstacle);
+ }
+
+ if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_ULTRASONIC_DISTANCE) {
+ json_builder_set_member_name(Json_h.builder, n_distance);
+ json_builder_add_double_value(Json_h.builder, sensor_data->distance);
+ }
+
+ if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_RAIN) {
+ json_builder_set_member_name(Json_h.builder, n_rain);
+ json_builder_add_int_value(Json_h.builder, sensor_data->rain);
+ }
+
+ if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_TOUCH) {
+ json_builder_set_member_name(Json_h.builder, n_touch);
+ json_builder_add_int_value(Json_h.builder, sensor_data->touch);
+ }
+
+ if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_GAS) {
+ json_builder_set_member_name(Json_h.builder, n_gas);
+ json_builder_add_int_value(Json_h.builder, sensor_data->gas);
+ }
+
+ json_builder_set_member_name(Json_h.builder, n_e_sensor);
+ json_builder_begin_array(Json_h.builder);
+
+ if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_MOTION)
+ json_builder_add_string_value(Json_h.builder, n_motion);
+
+ if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_FLAME)
+ json_builder_add_string_value(Json_h.builder, n_flame);
+
+ if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_HUMIDITY)
+ json_builder_add_string_value(Json_h.builder, n_hum);
+
+ if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_TEMPERATURE)
+ json_builder_add_string_value(Json_h.builder, n_temp);
+
+ if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_VIB)
+ json_builder_add_string_value(Json_h.builder, n_vib);
+
+ if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_CO2)
+ json_builder_add_string_value(Json_h.builder, n_co2);
+
+ if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_SOUND)
+ json_builder_add_string_value(Json_h.builder, n_sound);
+
+ if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_TILT)
+ json_builder_add_string_value(Json_h.builder, n_tilt);
+
+ if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_LIGHT)
+ json_builder_add_string_value(Json_h.builder, n_light);
+
+ if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_COLLISION)
+ json_builder_add_string_value(Json_h.builder, n_collision);
+
+ if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_OBSTACLE)
+ json_builder_add_string_value(Json_h.builder, n_obstacle);
+
+ if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_ULTRASONIC_DISTANCE)
+ json_builder_add_string_value(Json_h.builder, n_distance);
+
+ if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_RAIN)
+ json_builder_add_string_value(Json_h.builder, n_rain);
+
+ if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_TOUCH)
+ json_builder_add_string_value(Json_h.builder, n_touch);
+
+ if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_GAS)
+ json_builder_add_string_value(Json_h.builder, n_gas);
+
+ json_builder_end_array(Json_h.builder);
+
+ if (sensor_data->hash) {
+ json_builder_set_member_name(Json_h.builder, n_hash);
+ json_builder_add_string_value(Json_h.builder, sensor_data->hash);
+ }
+
+ json_builder_end_object(Json_h.builder);
+
+ return 0;
+}
+
+char *web_util_get_json_string(void)
+{
+ JsonGenerator *gen = NULL;
+ JsonNode *root = NULL;
+ char *str = NULL;
+
+ retv_if(Json_h.builder == NULL, NULL);
+ retv_if(Json_h.is_begin == false, NULL);
+ retv_if(Json_h.is_end == false, NULL);
+
+ root = json_builder_get_root(Json_h.builder);
+ retv_if(root == NULL, NULL);
+
+ gen = json_generator_new();
+ goto_if(gen == NULL, error_release_all);
+ json_generator_set_root(gen, root);
+
+ str = json_generator_to_data(gen, NULL);
+
+ return str;
+
+error_release_all:
+ if (root)
+ json_node_free(root);
+
+ return NULL;
+}
+
diff --git a/tizen-manifest.xml b/tizen-manifest.xml
new file mode 100644
index 0000000..4238b66
--- /dev/null
+++ b/tizen-manifest.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<manifest xmlns="http://tizen.org/ns/packages" api-version="4.0" package="org.tizen.position-finder-server" version="1.0.0">
+ <profile name="iot-headless"/>
+ <service-application appid="org.tizen.position-finder-server" exec="position-finder-server" multiple="false" nodisplay="true" taskmanage="false" type="capp">
+ <label>position-finder-server</label>
+ <icon>position-finder-server.png</icon>
+ </service-application>
+ <privileges>
+ <privilege>http://tizen.org/privilege/appdir.shareddata</privilege>
+ <privilege>http://tizen.org/privilege/network.get</privilege>
+ <privilege>http://tizen.org/privilege/internet</privilege>
+ <privilege>http://tizen.org/privilege/peripheralio</privilege>
+ </privileges>
+</manifest>
diff --git a/tizen-manifest.xml.in b/tizen-manifest.xml.in
new file mode 100644
index 0000000..e014ce2
--- /dev/null
+++ b/tizen-manifest.xml.in
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<manifest xmlns="http://tizen.org/ns/packages" api-version="4.0" package="@ORG_PREFIX@.@PROJECT_NAME@" version="1.0.0">
+ <profile name="mobile"/>
+ <author email="jinny.yoon@samsung.com" href="www.samsung.com">Jin Yoon</author>
+ <author email="gs86.lee@samsung.com" href="www.samsung.com">Geunsun Lee</author>
+ <author email="ey928.lee@samsung.com" href="www.samsung.com">Eunyoung Lee</author>
+ <author email="junkyu.han@samsung.com" href="www.samsung.com">Junkyu Han</author>
+ <service-application appid="@ORG_PREFIX@.@PROJECT_NAME@" auto-restart="false" exec="@PROJECT_NAME@" multiple="false" nodisplay="true" on-boot="false" taskmanage="false" type="capp">
+ <label>@APP_LABEL@</label>
+ <icon>@PROJECT_NAME@.png</icon>
+ </service-application>
+ <privileges>
+ <privilege>http://tizen.org/privilege/network.get</privilege>
+ <privilege>http://tizen.org/privilege/internet</privilege>
+ <privilege>http://tizen.org/privilege/peripheralio</privilege>
+ <privilege>http://tizen.org/privilege/camera</privilege>
+ </privileges>
+</manifest>