diff options
author | boyeon-son <bson1012@gmail.com> | 2018-09-10 12:15:48 +0900 |
---|---|---|
committer | boyeon-son <bson1012@gmail.com> | 2018-09-10 12:15:48 +0900 |
commit | 069c8fa8e1d9bb7af6ceeed1f2f1c667ace75b22 (patch) | |
tree | 096597fd9e579d116a7f20b2500c87968843be45 | |
parent | 6d3a92feab8113df67520283a45954e8eef3c17e (diff) | |
download | st-things-light-069c8fa8e1d9bb7af6ceeed1f2f1c667ace75b22.tar.gz st-things-light-069c8fa8e1d9bb7af6ceeed1f2f1c667ace75b22.tar.bz2 st-things-light-069c8fa8e1d9bb7af6ceeed1f2f1c667ace75b22.zip |
Initialize Smart Things Light project
-rwxr-xr-x | .cproject | 370 | ||||
-rwxr-xr-x | .exportMap | 5 | ||||
-rwxr-xr-x | .project | 46 | ||||
-rwxr-xr-x | .smartthingsapp | 0 | ||||
-rwxr-xr-x | .tproject | 12 | ||||
-rwxr-xr-x | LICENSE.APLv2 | 202 | ||||
-rwxr-xr-x | NOTICE | 3 | ||||
-rwxr-xr-x | inc/log.h | 96 | ||||
-rwxr-xr-x | inc/resource/resource_infrared_motion_sensor.h | 35 | ||||
-rwxr-xr-x | inc/resource/resource_led.h | 24 | ||||
-rwxr-xr-x | inc/sensor-data.h | 49 | ||||
-rwxr-xr-x | inc/st_things.h | 299 | ||||
-rwxr-xr-x | inc/st_things_types.h | 319 | ||||
-rwxr-xr-x | lib/liboicdastack.so | bin | 0 -> 499340 bytes | |||
-rwxr-xr-x | lib/libsdkapi.so | bin | 0 -> 79944 bytes | |||
-rwxr-xr-x | project_def.prop | 11 | ||||
-rwxr-xr-x | res/device_def.json | 97 | ||||
-rwxr-xr-x | shared/res/motion-light-smartthings.png | bin | 0 -> 57662 bytes | |||
-rwxr-xr-x | src/controller.c | 391 | ||||
-rwxr-xr-x | src/resource/resource_infrared_motion_sensor.c | 66 | ||||
-rwxr-xr-x | src/resource/resource_led.c | 68 | ||||
-rwxr-xr-x | src/sensor-data.c | 192 | ||||
-rwxr-xr-x | tizen-manifest.xml | 17 |
23 files changed, 2302 insertions, 0 deletions
diff --git a/.cproject b/.cproject new file mode 100755 index 0000000..eb7092d --- /dev/null +++ b/.cproject @@ -0,0 +1,370 @@ +<?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.212678085"> + <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="org.tizen.nativecore.config.sbi.gcc45.app.debug.212678085" 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="motionlightst" 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.212678085" name="Debug" parent="org.tizen.nativecore.config.sbi.gcc45.app.debug"> + <folderInfo id="org.tizen.nativecore.config.sbi.gcc45.app.debug.212678085." name="/" resourcePath=""> + <toolChain id="org.tizen.nativecore.toolchain.sbi.gcc45.app.debug.1462926713" 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.226675057" osList="linux,win32" superClass="org.tizen.nativeide.target.sbi.gnu.platform.base"/> + <builder autoBuildTarget="all" buildPath="${workspace_loc:/motion-light-smarthings}/Debug" enableAutoBuild="true" id="org.tizen.nativecore.target.sbi.gnu.builder.1825198608" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Tizen Application Builder" superClass="org.tizen.nativecore.target.sbi.gnu.builder"/> + <tool command="arm-linux-gnueabi-ar" id="org.tizen.nativecore.tool.sbi.gnu.archiver.1807670337" name="Archiver" superClass="org.tizen.nativecore.tool.sbi.gnu.archiver"/> + <tool command="clang++" id="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler.1467354887" name="C++ Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler"> + <option id="gnu.cpp.compiler.option.optimization.level.1383957918" 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.1632407084" 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.871341268" name="-fPIC option" superClass="sbi.gnu.cpp.compiler.option.misc.pic.core" valueType="boolean"/> + <option id="sbi.gnu.cpp.compiler.option.1304986764" name="Tizen-Target" 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.481216764" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.cpp.compiler.option.frameworks_inc.core" valueType="includePath"> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libxml2""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appcore-agent""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appfw""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/base""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ckm""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dbus-1.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/device""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dlog""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ecore-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efl-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1/eina""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eo-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/gio-unix-2.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/glib-2.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/iotcon""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/minizip""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/network""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/storage""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/system""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/dbus-1.0/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/glib-2.0/include""/> + </option> + <option id="sbi.gnu.cpp.compiler.option.frameworks_cflags.core.1495290878" name="Tizen-Frameworks-Other-Cflags" 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="${SBI_SYSROOT}""/> + <listOptionValue builtIn="false" value="-mthumb"/> + </option> + <option id="gnu.cpp.compiler.option.include.paths.449630281" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath"> + <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc}""/> + </option> + <option id="sbi.gnu.cpp.compiler.option.frameworks.core.1135115511" name="Tizen-Frameworks" superClass="sbi.gnu.cpp.compiler.option.frameworks.core" valueType="userObjs"> + <listOptionValue builtIn="false" value="Native_API"/> + <listOptionValue builtIn="false" value="iot-things"/> + </option> + <option id="sbi.gnu.cpp.compiler.option.preprocessor.def.deprecation.1389021824" name="Defined symbols (-D)" 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.1754522889" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/> + </tool> + <tool command="clang" id="org.tizen.nativecore.tool.sbi.gnu.c.compiler.351886267" 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.725973962" 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.1838517852" 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.743880440" name="-fPIC option" superClass="sbi.gnu.c.compiler.option.misc.pic.core" valueType="boolean"/> + <option id="sbi.gnu.c.compiler.option.788889674" name="Tizen-Target" 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.729698322" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.c.compiler.option.frameworks_inc.core" valueType="includePath"> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libxml2""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appcore-agent""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appfw""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/base""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ckm""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dbus-1.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/device""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dlog""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ecore-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efl-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1/eina""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eo-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/gio-unix-2.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/glib-2.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/iotcon""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/minizip""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/network""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/storage""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/system""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/dbus-1.0/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/glib-2.0/include""/> + </option> + <option id="sbi.gnu.c.compiler.option.frameworks_cflags.core.1921111222" name="Tizen-Frameworks-Other-Cflags" 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="${SBI_SYSROOT}""/> + <listOptionValue builtIn="false" value="-mthumb"/> + </option> + <option id="gnu.c.compiler.option.include.paths.991673271" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath"> + <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc}""/> + </option> + <option id="sbi.gnu.c.compiler.option.frameworks.core.177782124" name="Tizen-Frameworks" superClass="sbi.gnu.c.compiler.option.frameworks.core" valueType="userObjs"> + <listOptionValue builtIn="false" value="Native_API"/> + <listOptionValue builtIn="false" value="iot-things"/> + </option> + <option id="sbi.gnu.c.compiler.option.preprocessor.def.symbols.deprecation.1050476680" name="Defined symbols (-D)" 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.1839643222" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/> + </tool> + <tool id="org.tizen.nativeide.tool.sbi.gnu.c.linker.base.775167376" name="C Linker" superClass="org.tizen.nativeide.tool.sbi.gnu.c.linker.base"/> + <tool command="clang++" id="org.tizen.nativecore.tool.sbi.gnu.cpp.linker.599812434" name="C++ Linker" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.linker"> + <option defaultValue="false" id="sbi.gnu.cpp.link.option.strip.929249314" 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.18288993" 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.1594639368" 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.1458335468" name="Tizen-Frameworks-Other-Lflags" 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="${SBI_SYSROOT}""/> + <listOptionValue builtIn="false" value="-Xlinker --version-script="${PROJ_PATH}/.exportMap""/> + <listOptionValue builtIn="false" value="-L"${SBI_SYSROOT}/usr/lib""/> + <listOptionValue builtIn="false" value="-L"${SBI_SYSROOT}/../iot-things-4.0-device.core/usr/lib""/> + <listOptionValue builtIn="false" value="$(RS_LIBRARIES)"/> + </option> + <option id="gnu.cpp.link.option.paths.1238625478" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" valueType="libPaths"> + <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/lib}""/> + </option> + <option id="gnu.cpp.link.option.libs.33710617" name="Libraries (-l)" superClass="gnu.cpp.link.option.libs" valueType="libs"> + <listOptionValue builtIn="false" value="oicdastack"/> + <listOptionValue builtIn="false" value="sdkapi"/> + </option> + <inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.699356208" 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" id="org.tizen.nativeapp.tool.sbi.gnu.assembler.base.1723491220" name="Assembler" superClass="org.tizen.nativeapp.tool.sbi.gnu.assembler.base"> + <inputType id="cdt.managedbuild.tool.gnu.assembler.input.580775704" superClass="cdt.managedbuild.tool.gnu.assembler.input"/> + </tool> + <tool id="org.tizen.nativecore.tool.fnmapgen.285516242" name="C FN-Map Generator" superClass="org.tizen.nativecore.tool.fnmapgen"/> + <tool id="org.tizen.nativecore.tool.fnmapgen.cpp.1945877137" name="C++ FN-Map Generator" superClass="org.tizen.nativecore.tool.fnmapgen.cpp"/> + <tool id="org.tizen.nativecore.tool.ast.1720796871" name="C Static Analyzer" superClass="org.tizen.nativecore.tool.ast"/> + <tool id="org.tizen.nativecore.tool.ast.cpp.1747365794" name="C++ Static Analyzer" superClass="org.tizen.nativecore.tool.ast.cpp"/> + <tool id="org.tizen.nativecore.tool.sbi.gnu.archiver.mergelib.1983989319" name="Archive Generator" superClass="org.tizen.nativecore.tool.sbi.gnu.archiver.mergelib"/> + <tool id="org.tizen.nativecore.tool.sbi.po.compiler.134154162" name="PO Resource Compiler" superClass="org.tizen.nativecore.tool.sbi.po.compiler"/> + <tool id="org.tizen.nativecore.tool.sbi.edc.compiler.2044023683" 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.1735623417"> + <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="org.tizen.nativecore.config.sbi.gcc45.app.release.1735623417" 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="motion-light-smarthings" 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.1735623417" name="Release" parent="org.tizen.nativecore.config.sbi.gcc45.app.release"> + <folderInfo id="org.tizen.nativecore.config.sbi.gcc45.app.release.1735623417." name="/" resourcePath=""> + <toolChain id="org.tizen.nativecore.toolchain.sbi.gcc45.app.release.1431331488" 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.1283080576" osList="linux,win32" superClass="org.tizen.nativeide.target.sbi.gnu.platform.base"/> + <builder buildPath="${workspace_loc:/motion-light-smarthings}/Release" id="org.tizen.nativecore.target.sbi.gnu.builder.1585063422" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Tizen Application Builder" superClass="org.tizen.nativecore.target.sbi.gnu.builder"/> + <tool command="arm-linux-gnueabi-ar" id="org.tizen.nativecore.tool.sbi.gnu.archiver.953101983" name="Archiver" superClass="org.tizen.nativecore.tool.sbi.gnu.archiver"/> + <tool command="clang++" id="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler.1867916040" name="C++ Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler"> + <option id="gnu.cpp.compiler.option.optimization.level.1218735419" 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.1603503965" 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.135015916" name="-fPIC option" superClass="sbi.gnu.cpp.compiler.option.misc.pic.core" valueType="boolean"/> + <option id="sbi.gnu.cpp.compiler.option.765373059" name="Tizen-Target" 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.78271810" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.cpp.compiler.option.frameworks_inc.core" valueType="includePath"> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libxml2""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appcore-agent""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appfw""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/base""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ckm""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dbus-1.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/device""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dlog""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ecore-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efl-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1/eina""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eo-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/gio-unix-2.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/glib-2.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/iotcon""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/minizip""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/network""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/storage""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/system""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/dbus-1.0/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/glib-2.0/include""/> + </option> + <option id="sbi.gnu.cpp.compiler.option.frameworks_cflags.core.1219025028" name="Tizen-Frameworks-Other-Cflags" 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="${SBI_SYSROOT}""/> + <listOptionValue builtIn="false" value="-mthumb"/> + </option> + <option id="gnu.cpp.compiler.option.include.paths.133149113" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath"> + <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc}""/> + </option> + <option id="sbi.gnu.cpp.compiler.option.frameworks.core.952816959" name="Tizen-Frameworks" superClass="sbi.gnu.cpp.compiler.option.frameworks.core" valueType="userObjs"> + <listOptionValue builtIn="false" value="Native_API"/> + <listOptionValue builtIn="false" value="iot-things"/> + </option> + <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.982066039" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/> + </tool> + <tool command="clang" id="org.tizen.nativecore.tool.sbi.gnu.c.compiler.359095659" 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.248183276" 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.1666010430" 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.123326421" name="-fPIC option" superClass="sbi.gnu.c.compiler.option.misc.pic.core" valueType="boolean"/> + <option id="sbi.gnu.c.compiler.option.62987079" name="Tizen-Target" 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.1861841862" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.c.compiler.option.frameworks_inc.core" valueType="includePath"> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libxml2""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appcore-agent""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/appfw""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/base""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ckm""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dbus-1.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/device""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/dlog""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/ecore-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/efl-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eina-1/eina""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/eo-1""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/gio-unix-2.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/glib-2.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/iotcon""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/json-glib-1.0""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/media""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/minizip""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/network""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/storage""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/system""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/dbus-1.0/include""/> + <listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/lib/glib-2.0/include""/> + </option> + <option id="sbi.gnu.c.compiler.option.frameworks_cflags.core.6346726" name="Tizen-Frameworks-Other-Cflags" 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="${SBI_SYSROOT}""/> + <listOptionValue builtIn="false" value="-mthumb"/> + </option> + <option id="gnu.c.compiler.option.include.paths.49718267" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath"> + <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc}""/> + </option> + <option id="sbi.gnu.c.compiler.option.frameworks.core.981607999" name="Tizen-Frameworks" superClass="sbi.gnu.c.compiler.option.frameworks.core" valueType="userObjs"> + <listOptionValue builtIn="false" value="Native_API"/> + <listOptionValue builtIn="false" value="iot-things"/> + </option> + <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1929824433" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/> + </tool> + <tool id="org.tizen.nativeide.tool.sbi.gnu.c.linker.base.2124861013" name="C Linker" superClass="org.tizen.nativeide.tool.sbi.gnu.c.linker.base"/> + <tool command="clang++" id="org.tizen.nativecore.tool.sbi.gnu.cpp.linker.2038117295" name="C++ Linker" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.linker"> + <option defaultValue="true" id="sbi.gnu.cpp.link.option.strip.406535656" 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.173516568" 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.1728174629" 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.1734977125" name="Tizen-Frameworks-Other-Lflags" 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="${SBI_SYSROOT}""/> + <listOptionValue builtIn="false" value="-Xlinker --version-script="${PROJ_PATH}/.exportMap""/> + <listOptionValue builtIn="false" value="-L"${SBI_SYSROOT}/usr/lib""/> + <listOptionValue builtIn="false" value="-L"${SBI_SYSROOT}/../iot-things-4.0-device.core/usr/lib""/> + <listOptionValue builtIn="false" value="$(RS_LIBRARIES)"/> + </option> + <option id="gnu.cpp.link.option.paths.459689398" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" valueType="libPaths"> + <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/lib}""/> + </option> + <option id="gnu.cpp.link.option.libs.1551089630" name="Libraries (-l)" superClass="gnu.cpp.link.option.libs" valueType="libs"> + <listOptionValue builtIn="false" value="oicdastack"/> + <listOptionValue builtIn="false" value="sdkapi"/> + </option> + <inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.109006333" 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" id="org.tizen.nativeapp.tool.sbi.gnu.assembler.base.1079587972" name="Assembler" superClass="org.tizen.nativeapp.tool.sbi.gnu.assembler.base"> + <inputType id="cdt.managedbuild.tool.gnu.assembler.input.629693868" superClass="cdt.managedbuild.tool.gnu.assembler.input"/> + </tool> + <tool id="org.tizen.nativecore.tool.fnmapgen.2098631023" name="C FN-Map Generator" superClass="org.tizen.nativecore.tool.fnmapgen"/> + <tool id="org.tizen.nativecore.tool.fnmapgen.cpp.1583574814" name="C++ FN-Map Generator" superClass="org.tizen.nativecore.tool.fnmapgen.cpp"/> + <tool id="org.tizen.nativecore.tool.ast.1656148823" name="C Static Analyzer" superClass="org.tizen.nativecore.tool.ast"/> + <tool id="org.tizen.nativecore.tool.ast.cpp.1430430437" name="C++ Static Analyzer" superClass="org.tizen.nativecore.tool.ast.cpp"/> + <tool id="org.tizen.nativecore.tool.sbi.gnu.archiver.mergelib.1020471514" name="Archive Generator" superClass="org.tizen.nativecore.tool.sbi.gnu.archiver.mergelib"/> + <tool id="org.tizen.nativecore.tool.sbi.po.compiler.392248676" name="PO Resource Compiler" superClass="org.tizen.nativecore.tool.sbi.po.compiler"/> + <tool id="org.tizen.nativecore.tool.sbi.edc.compiler.813437093" 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="motion-light-smarthings.org.tizen.nativecore.target.sbi.gcc45.app.1315804593" 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.debug.212678085"> + <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/> + </scannerConfigBuildInfo> + <scannerConfigBuildInfo instanceId="org.tizen.nativecore.config.sbi.gcc45.app.release.1735623417"> + <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/> + </scannerConfigBuildInfo> + </storageModule> + <storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/> + <storageModule moduleId="refreshScope"/> + <storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/> +</cproject> diff --git a/.exportMap b/.exportMap new file mode 100755 index 0000000..de30516 --- /dev/null +++ b/.exportMap @@ -0,0 +1,5 @@ +{ + global: main; + _IO_*; + local: *; +}; diff --git a/.project b/.project new file mode 100755 index 0000000..5e2b7f8 --- /dev/null +++ b/.project @@ -0,0 +1,46 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>motion-light-smartthings</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>0</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>0</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/.smartthingsapp b/.smartthingsapp new file mode 100755 index 0000000..e69de29 --- /dev/null +++ b/.smartthingsapp diff --git a/.tproject b/.tproject new file mode 100755 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/LICENSE.APLv2 b/LICENSE.APLv2 new file mode 100755 index 0000000..d645695 --- /dev/null +++ b/LICENSE.APLv2 @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + 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. + + 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, + 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 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 in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) 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 + + (d) 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. + + 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 Apache License to your work. + + To apply the Apache 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 Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + 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. @@ -0,0 +1,3 @@ +Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved. +Except as noted, this software is licensed under Apache License, Version 2. +Please, see the LICENSE.APLv2 file for Apache License, Version 2 terms and conditions. diff --git a/inc/log.h b/inc/log.h new file mode 100755 index 0000000..9ba2c4b --- /dev/null +++ b/inc/log.h @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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 __MOTION_LIGTH_LOG_H__ +#define __MOTION_LIGTH_LOG_H__ + +#include <dlog.h> + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "MOTION_LIGHT_APP" + +#define _E(fmt, args...) dlog_print(DLOG_ERROR, LOG_TAG, "%s : %s(%d) > "fmt"\n", rindex(__FILE__, '/') + 1, __func__, __LINE__, ##args) +#define _W(fmt, args...) dlog_print(DLOG_WARN, LOG_TAG, "%s : %s(%d) > "fmt"\n", rindex(__FILE__, '/') + 1, __func__, __LINE__, ##args) +#define _I(fmt, args...) dlog_print(DLOG_INFO, LOG_TAG, "%s : %s(%d) > "fmt"\n", rindex(__FILE__, '/') + 1, __func__, __LINE__, ##args) +#define _D(fmt, args...) dlog_print(DLOG_DEBUG, LOG_TAG, "%s : %s(%d) > "fmt"\n", rindex(__FILE__, '/') + 1, __func__, __LINE__, ##args) + +#define FN_CALL dlog_print(DLOG_DEBUG, LOG_TAG, ">>>>>>>> %s() called\n", __func__) +#define FN_END dlog_print(DLOG_DEBUG, LOG_TAG, "<<<<<<<< %s() ended\n", __func__) + + +#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; \ + } \ +} + +#ifdef __cplusplus +} +#endif + +#endif /* __MOTION_LIGTH_LOG_H__ */ + diff --git a/inc/resource/resource_infrared_motion_sensor.h b/inc/resource/resource_infrared_motion_sensor.h new file mode 100755 index 0000000..612db3f --- /dev/null +++ b/inc/resource/resource_infrared_motion_sensor.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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); + +/** + * @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(void); + +#endif /* __POSITION_FINDER_RESOURCE_INFRARED_MOTION_SENSOR_H__ */ diff --git a/inc/resource/resource_led.h b/inc/resource/resource_led.h new file mode 100755 index 0000000..44b058a --- /dev/null +++ b/inc/resource/resource_led.h @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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); + +extern void resource_close_led(void); + +#endif /* __POSITION_FINDER_RESOURCE_LED_H__ */ diff --git a/inc/sensor-data.h b/inc/sensor-data.h new file mode 100755 index 0000000..e6fe1b5 --- /dev/null +++ b/inc/sensor-data.h @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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 __SENSOR_DATA_H__ +#define __SENSOR_DATA_H__ + +#include <stdbool.h> + +typedef enum { + SENSOR_DATA_TYPE_NONE = 0, + SENSOR_DATA_TYPE_INT, + SENSOR_DATA_TYPE_UINT, + SENSOR_DATA_TYPE_BOOL, + SENSOR_DATA_TYPE_DOUBLE, + SENSOR_DATA_TYPE_STR, +} sensor_data_type_e; + +typedef struct __sensor_data_s sensor_data; + +sensor_data *sensor_data_new(sensor_data_type_e type); +void sensor_data_free(sensor_data *data); + +int sensor_data_set_int(sensor_data *data, int value); +int sensor_data_set_uint(sensor_data *data, unsigned int value); +int sensor_data_set_bool(sensor_data *data, bool value); +int sensor_data_set_double(sensor_data *data, double value); +int sensor_data_set_string(sensor_data *data, const char *value, unsigned int size); + +int sensor_data_get_int(sensor_data *data, int *value); +int sensor_data_get_uint(sensor_data *data, unsigned int *value); +int sensor_data_get_bool(sensor_data *data, bool *value); +int sensor_data_get_double(sensor_data *data, double *value); +int sensor_data_get_string(sensor_data *data, const char **value); + +#endif /* __SENSOR_DATA_H__ */ + diff --git a/inc/st_things.h b/inc/st_things.h new file mode 100755 index 0000000..92015d7 --- /dev/null +++ b/inc/st_things.h @@ -0,0 +1,299 @@ +/* **************************************************************** + * + * Copyright 2017 Samsung Electronics All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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 __ST_THINGS_H__ +#define __ST_THINGS_H__ + +#include <stdint.h> +#include <stdbool.h> + +#ifdef __ST_THINGS_RTOS__ +#include <st_things/st_things_types.h> +#else +#include "st_things_types.h" +#endif // __ST_THINGS_RTOS__ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @brief Set prefix paths (ReadOnly and ReadWrite) for configuration files for the device. + * This is Optional API, and should be used if relative location is used in + * filePath variable in JSON Configuration file. + * @param[in] ro_path Prefix Path for Read Only directory location. + * @param[in] rw_path Prefix Path for Read Write directory location. + * @return @c 0 on success, otherwise a negative error value + * @retval #ST_THINGS_ERROR_NONE Successful + * @retval #ST_THINGS_ERROR_INVALID_PARAMETER Invalid parameter(both ro_path and rw_path are NULL). + * @retval #ST_THINGS_ERROR_OPERATION_FAILED Operation failed + * @retval #ST_THINGS_ERROR_STACK_ALREADY_INITIALIZED Stack already initialized. + * To set Prefix Paths, stack should be deinitilized first by calling st_things_deinitialize(). + * @retval #ST_THINGS_ERROR_STACK_RUNNING Stack is currently running. + * To set Prefix Paths, stack should be stopped first by calling st_things_stop() + * and then deinitialized by calling st_things_deinitialize(). + */ +int st_things_set_configuration_prefix_path(const char* ro_path, const char* rw_path); + +/** + * @brief Initializes things stack and returns whether easy-setup is completed or not. + * Easy-setup enable users to acquire the ownership of things and to connect the things with the cloud. + * After performing easy-setup, users can access things from anywhere through the cloud. + * In things stack, easy-setup is a primary and the first operation to be performed on the thing. + * Application running on the thing can know whether easy-setup is done already or not. + * If easy-setup is done, app can start the things stack by calling st_things_start(). + * If easy-setup is not done, app can either wait for the user interaction before starting the things stack or + * start the things stack directly without waiting for any events(This case is for those things which doesn't + * support input capability and for all other unknown cases). + * To use a new json file after initialization, stack should be deinitialized + * and stopped(if its started already). + * @param[in] json_path Path to Json file which defines a thing. Definition includes the device information, + * resources and their properties, configuration info for connectivity and easy-setup, etc. + * @param[out] easysetup_complete Indicates whether easysetup is completed already or not. + * @return @c 0 on success, otherwise a negative error value + * @retval #ST_THINGS_ERROR_NONE Successful + * @retval #ST_THINGS_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ST_THINGS_ERROR_OPERATION_FAILED Operation failed + * @retval #ST_THINGS_ERROR_STACK_ALREADY_INITIALIZED Stack already initialized. + * To initialize again, stack should be deinitilized first by calling st_things_deinitialize(). + * @retval #ST_THINGS_ERROR_STACK_RUNNING Stack is currently running. + * To initialize again, stack should be stopped first by calling st_things_stop() + * and then deinitialized by calling st_things_deinitialize(). + */ +int st_things_initialize(const char *json_path, bool *easysetup_complete); + +/** + * @brief Deinitializes things stack. + * Stack should have been initialized before calling this API. + * @return @c 0 on success, otherwise a negative error value + * @retval #ST_THINGS_ERROR_NONE Successful + * @retval #ST_THINGS_ERROR_OPERATION_FAILED Operation failed + * @retval #ST_THINGS_ERROR_STACK_NOT_INITIALIZED Stack is not initialized. + * Initialize the stack by calling st_things_initialize(). + * @retval #ST_THINGS_ERROR_STACK_RUNNING Stack is currently running. + * Before deinitialize, stack needs to be stopped by calling st_things_stop(). + */ +int st_things_deinitialize(void); + +/** + * @brief Callback for handling GET request. + * @param[in] req_msg GET request message. + * @param[out] resp_rep Representation that will be set to payload of response. + * @return @c true in case of success, otherwise @c false + */ +typedef bool (*st_things_get_request_cb)(st_things_get_request_message_s *req_msg, st_things_representation_s *resp_rep); + +/** + * @brief Callback for handling SET(POST) request. + * @param[in] req_msg SET request message. + * @param[out] resp_rep Representation that will be set to payload of response. + * @return @c true in case of success, otherwise @c false + */ +typedef bool (*st_things_set_request_cb)(st_things_set_request_message_s *req_msg, st_things_representation_s *resp_rep); + +/** + * @brief Callback registration function for handling request messages. + * @details The callbacks ensure that a request message will be carried with one of the resource uris from json file of st_things_start(). + * @remarks Only one callback function can be set with this API.\n + * If multiple callbacks are set, the last one is registered only.\n + * And the callbacks are called in the internal thread, which is not detached,\n + * so application should return it to get the next callbacks. + * @param[in] get_cb Reference of the callback function to handle GET request. + * @param[in] set_cb Reference of the callback function to handle SET(POST) request. + * @return @c 0 on success, otherwise a negative error value + * @retval #ST_THINGS_ERROR_NONE Successful + * @retval #ST_THINGS_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ST_THINGS_ERROR_OPERATION_FAILED Operation failed + */ +int st_things_register_request_cb(st_things_get_request_cb get_cb, st_things_set_request_cb set_cb); + +/** + * @brief Starts things stack. + * Parses the thing definition(whose path is passed to st_things_initialize(), configures the thing, + * creates the resources and prepares it for easy-setup. + * If easy-setup is not done yet, onboarding will be started using either SoftAP or BLE connection. + * Onboarding creates an ad-hoc network between the thing and the client for performing easy-setup. + * If easy-setup is already done, thing will be connected with the cloud. + * Application can know whether easy-setup is done or not through st_things_initialize API. + * Stack should have been initialized before calling this API. + * @return @c 0 on success, otherwise a negative error value + * @retval #ST_THINGS_ERROR_NONE Successful. + * It is also used for the case that the stack is started already. + * @retval #ST_THINGS_ERROR_OPERATION_FAILED Operation failed + * @retval #ST_THINGS_ERROR_STACK_NOT_INITIALIZED Stack is not initialized. + * Initialize the stack by calling st_things_initialize(). + */ +int st_things_start(void); + +/** + * @brief Stops things stack. + * Removes all the data being used internally and releases all the memory allocated for the stack. + * Stack should have been initialized and started before calling this API. + * @return @c 0 on success, otherwise a negative error value + * @retval #ST_THINGS_ERROR_NONE Successful + * @retval #ST_THINGS_ERROR_OPERATION_FAILED Operation failed + * @retval #ST_THINGS_ERROR_STACK_NOT_INITIALIZED Stack is not initialized. + * Initialize the stack by calling st_things_initialize(). + * @retval #ST_THINGS_ERROR_STACK_NOT_STARTED Stack is not started. + * Start the stack by calling st_things_start(). + */ +int st_things_stop(void); + +/** + * @brief Callback for getting user's opinion regarding device reset. + * @return @c true to confirm, otherwise @c to deny + */ +typedef bool (*st_things_reset_confirm_cb)(void); + +/** + * @brief Callback for carrying the result of reset. + * @param[in] is_success Result of Stack-reset. (true : success, false : failure) + */ +typedef void (*st_things_reset_result_cb)(bool is_success); + +/** + * @brief Callback registration function for Reset-Confirmation and Reset-Result functions. + * @remarks Only one callback function can be set with this API.\n + * If multiple callbacks are set, the last one is registered only.\n + And the callbacks are called in the internal thread, which is not detached,\n + * so application should return it to get the next callbacks. + * @param[in] confirm_cb Callback function that will be called to get the user's input when reset is triggered. + * @param[in] result_cb Callback function that will be called after the reset process is done. + * This parameter can be NULL if notification for result of reset is not needed. + * @return @c 0 on success, otherwise a negative error value + * @retval #ST_THINGS_ERROR_NONE Successful + * @retval #ST_THINGS_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ST_THINGS_ERROR_OPERATION_FAILED Operation failed + */ +int st_things_register_reset_cb(st_things_reset_confirm_cb confirm_cb, st_things_reset_result_cb result_cb); + +/** + * @brief Reset all the data related to security and cloud being used in the stack. + * Stack should have been initialized and started before calling this API. + * @return @c 0 on success, otherwise a negative error value + * @retval #ST_THINGS_ERROR_NONE Successful + * @retval #ST_THINGS_ERROR_OPERATION_FAILED Operation failed + * @retval #ST_THINGS_ERROR_STACK_NOT_INITIALIZED Stack is not intialized. + * Initialize the stack by calling st_things_initialize(). + * @retval #ST_THINGS_ERROR_STACK_NOT_STARTED Stack is not started. + * Start the stack by calling st_things_start(). + */ +int st_things_reset(void); + +/** + * @brief Callback for carrying the randomly generated PIN info. + * @details Device should show the PIN on display. + * @param[in] pin_data PIN data in string format. + * @param[in] pin_size Length of the PIN String. + */ +typedef void (*st_things_pin_generated_cb)(const char *pin_data, const size_t pin_size); + +/** + * @brief Callback for informing the application to close the PIN display. + */ +typedef void (*st_things_pin_display_close_cb)(void); + +/** + * @brief Callback registration function for getting randomly generated PIN for the PIN-Based Ownership Transfer Request. + * @remarks Only one callback function can be set with this API.\n + * If multiple callbacks are set, the last one is registered only.\n + * And the callbacks are called in the internal thread, which is not detached,\n + * so application should return it to get the next callbacks. + * @param[in] generated_cb Callback function that will be called when device receives a Ownership Transfer request from client. + * @param[in] close_cb Callback function that will be called when Ownership Transfer is done so device can stop showing PIN on display. + * This parameter can be NULL if stop triggering is not needed. + * @return @c 0 on success, otherwise a negative error value + * @retval #ST_THINGS_ERROR_NONE Successful + * @retval #ST_THINGS_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ST_THINGS_ERROR_OPERATION_FAILED Operation failed + */ +int st_things_register_pin_handling_cb(st_things_pin_generated_cb generated_cb, st_things_pin_display_close_cb close_cb); + +/** + * @brief Callback for getting user's input regarding mutual verification. + * @return @c true true in cse of confirmed, otherwise @c false + */ +typedef bool (*st_things_user_confirm_cb)(void); + +/** + * @brief Callback registration function for getting user confirmation for MUTUAL VERIFICATION BASED JUST WORK Ownership transfer. + * @remarks Only one callback function can be set with this API.\n + * If multiple callbacks are set, the last one is registered only.\n + * And the callbacks are called in the internal thread, which is not detached,\n + * so application should return it to get the next callbacks. + * @param[in] confirm_cb Callback function that will be called when device receives a confirm request from client. + * @return @c 0 on success, otherwise a negative error value + * @retval #ST_THINGS_ERROR_NONE Successful + * @retval #ST_THINGS_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ST_THINGS_ERROR_OPERATION_FAILED Operation failed + */ +int st_things_register_user_confirm_cb(st_things_user_confirm_cb confirm_cb); + +/** + * @brief Callback for getting the current state of ST Things. + * @param[in] things_status ST Things State + */ +typedef void (*st_things_status_change_cb)(st_things_status_e things_status); + +/** + * @brief Callback registration function for getting notified when ST Things state changes. + * @remarks Only one callback function can be set with this API.\n + * If multiple callbacks are set, the last one is registered only.\n + * And the callbacks are called in the internal thread, which is not detached,\n + * so application should return it to get the next callbacks. + * @param[in] status_cb Refernce of the callback function to get ST Things status + * @return @c 0 on success, otherwise a negative error value + * @retval #ST_THINGS_ERROR_NONE Successful + * @retval #ST_THINGS_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ST_THINGS_ERROR_OPERATION_FAILED Operation failed + */ +int st_things_register_things_status_change_cb(st_things_status_change_cb status_cb); + +/** + * @brief Notify the observers of a specific resource. + * Stack should have been initialized and started before calling this API. + * @param[in] resource_uri Resource URI of the resource which will be notified to observers. + * @return @c 0 on success, otherwise a negative error value + * @retval #ST_THINGS_ERROR_NONE Successful + * @retval #ST_THINGS_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ST_THINGS_ERROR_OPERATION_FAILED Operation failed + * @retval #ST_THINGS_ERROR_STACK_NOT_INITIALIZED Stack is not intialized. + * Initialize the stack by calling st_things_initialize(). + * @retval #ST_THINGS_ERROR_STACK_NOT_STARTED Stack is not started. + * Start the stack by calling st_things_start(). + */ +int st_things_notify_observers(const char *resource_uri); + +/** + * @brief Create an instance of representation. + * @remarks To destroy an instance, st_things_destroy_representation_inst() should be used. + * @return a pointer of the created representation, otherwise a null pointer if the memory is insufficient. + */ +st_things_representation_s *st_things_create_representation_inst(void); + +/** + * @brief Destroy an instance of representation. + * @param[in] rep Representation that will be destroyed. + */ +void st_things_destroy_representation_inst(st_things_representation_s *rep); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __ST_THINGS_H__ */ diff --git a/inc/st_things_types.h b/inc/st_things_types.h new file mode 100755 index 0000000..e1f20f6 --- /dev/null +++ b/inc/st_things_types.h @@ -0,0 +1,319 @@ +/* **************************************************************** + * + * Copyright 2017 Samsung Electronics All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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 __ST_THINGS_TYPES_H__ +#define __ST_THINGS_TYPES_H__ + +#include <stdint.h> +#include <stdlib.h> +#include <stdbool.h> + +/** + * @brief Enumeration for ST Things error code. + */ +typedef enum { + ST_THINGS_ERROR_NONE = 0, /**< Successful */ + ST_THINGS_ERROR_INVALID_PARAMETER = -1, /**< Invalid parameter (If parameter is null or empty)*/ + ST_THINGS_ERROR_OPERATION_FAILED = -2, /**< Operation Failed */ + ST_THINGS_ERROR_STACK_NOT_INITIALIZED = -3, /**< Stack is not yet initialized*/ + ST_THINGS_ERROR_STACK_ALREADY_INITIALIZED = -4, /**< Stack is already initialized*/ + ST_THINGS_ERROR_STACK_NOT_STARTED = -5, /**< Stack is not yet started*/ + ST_THINGS_ERROR_STACK_RUNNING = -6, /**< Stack is currently running*/ +} st_things_error_e; + +/** + * @brief Enumeration for ST Things status. + */ +typedef enum { + ST_THINGS_STATUS_INIT = 0, /**< Initial state of ST Things */ + ST_THINGS_STATUS_ES_STARTED, /**< Easy-setup is started */ + ST_THINGS_STATUS_ES_DONE, /**< Easy-setup is done */ + ST_THINGS_STATUS_ES_FAILED_ON_OWNERSHIP_TRANSFER, /**< Easy-setup failed due to Ownership-Transfer failure */ + ST_THINGS_STATUS_CONNECTING_TO_AP, /**< Connecting to target Wi-Fi access point */ + ST_THINGS_STATUS_CONNECTED_TO_AP, /**< Connected to target Wi-Fi access point */ + ST_THINGS_STATUS_CONNECTING_TO_AP_FAILED, /**< Failed to connect to target Wi-Fi access point */ + ST_THINGS_STATUS_REGISTERING_TO_CLOUD, /**< Trying to Sign-up/Sign-in/Publish-Resource(s) to Cloud */ + ST_THINGS_STATUS_REGISTERED_TO_CLOUD, /**< Publish resource(s) to cloud is complete. Now the Thing is ready to be controlled via Cloud */ + ST_THINGS_STATUS_REGISTERING_FAILED_ON_SIGN_IN, /**< Failed to sign-in to Cloud */ + ST_THINGS_STATUS_REGISTERING_FAILED_ON_PUB_RES /**< Failed to publish resources to Cloud */ +} st_things_status_e; + +/** + * @brief Structure for Representation. + */ +typedef struct _st_things_representation +{ + void* payload; /**< Payload of representation */ + + /** + * @brief API for getting the value of string type property with a key. + * @remarks This API will return deep-copied string value as out parameter, so application must free it after use. + * @param[in] rep Instance of Representation. + * @param[in] key Property Name which represents the value. + * @param[out] value String value + * @return @c true if value exist, otherwise @c false + */ + bool (*get_str_value) (struct _st_things_representation* rep, const char* key, char** value); + + /** + * @brief API for getting the value of boolean type property with a key. + * @param[in] rep Instance of Representation. + * @param[in] key Property Name which represents the value. + * @param[out] value Bool value + * @return @c true if value exist, otherwise @c false + */ + bool (*get_bool_value) (struct _st_things_representation* rep, const char* key, bool* value); + + /** + * @brief API for getting the value of integer type property with a key. + * @param[in] rep Instance of Representation. + * @param[in] key Property Name which represents the value. + * @param[out] value Integer value + * @return @c true if value exist, otherwise @c false + */ + bool (*get_int_value) (struct _st_things_representation* rep, const char* key, int64_t* value); + + /** + * @brief API for getting the value of double type property with a key. + * @param[in] rep Instance of Representation. + * @param[in] key Property Name which represents the value. + * @param[out] value Double value + * @return @c true if value exist, otherwise @c false + */ + bool (*get_double_value) (struct _st_things_representation* rep, const char* key, double* value); + + /** + * @brief API for getting the value of byte array type property with a key. + * @remarks This API will return deep-copied byte value as out parameter, so application must free it after use. + * @param[in] rep Instance of Representation. + * @param[in] key Property Name which represents the value. + * @param[out] value Byte value + * @param[out] size Size of Byte value + * @return @c true if value exist, otherwise @c false + */ + bool (*get_byte_value) (struct _st_things_representation* rep, const char* key, uint8_t** value, size_t* size); + + /** + * @brief API for getting the value of object type property with a key. + * @remarks This API will return deep-copied object value as out parameter, so application must free it after use.\n + * To free an object, st_things_destroy_representation_inst() in st_things.h should be used. + * @param[in] rep Instance of Representation. + * @param[in] key Property Name which represents the value. + * @param[out] value Object value + * @return @c true if value exist, otherwise @c false + */ + bool (*get_object_value) (struct _st_things_representation* rep, const char* key, struct _st_things_representation** value); + + /** + * @brief API for setting the value of string type property with a key. + * @remarks This API will deep-copy the string value inside, so application still has an ownership of memory for the string value. + * @param[in] rep Instance of Representation. + * @param[in] key Property Name which will represent the value. + * @param[in] value String value. + * @return @c true if setting value is successful, otherwise @c false + */ + bool (*set_str_value) (struct _st_things_representation* rep, const char* key, const char* value); + + /** + * @brief API for setting the value of boolean type property with a key. + * @param[in] rep Instance of Representation. + * @param[in] key Property Name which will represent the value. + * @param[in] value Bool value. + * @return @c true if setting value is successful, otherwise @c false + */ + bool (*set_bool_value) (struct _st_things_representation* rep, const char* key, bool value); + + /** + * @brief API for setting the value of integer type property with a key. + * @param[in] rep Instance of Representation. + * @param[in] key Property Name which will represent the value. + * @param[in] value Integer value. + * @return @c true if setting value is successful, otherwise @c false + */ + bool (*set_int_value) (struct _st_things_representation* rep, const char* key, int64_t value); + + /** + * @brief API for setting the value of double type property with a key. + * @param[in] rep Instance of Representation. + * @param[in] key Property Name which will represent the value. + * @param[in] value Double value. + * @return @c true if setting value is successful, otherwise @c false + */ + bool (*set_double_value) (struct _st_things_representation* rep, const char* key, double value); + + /** + * @brief API for setting the value of byte array type property with a key. + * @remarks This API will deep-copy the byte value inside, so application still has an ownership of memory for the byte value. + * @param[in] rep Instance of Representation. + * @param[in] key Property Name which will represent the value. + * @param[in] value Byte value. + * @param[in] size Size of Byte value. + * @return @c true if setting value is successful, otherwise @c false + */ + bool (*set_byte_value) (struct _st_things_representation* rep, const char* key, const uint8_t* value, size_t size); + + /** + * @brief API for setting the value of object type property with a key. + * @remarks This API will deep-copy the object value inside, so application still has an ownership of memory for the object value. + * @param[in] rep Instance of Representation. + * @param[in] key Property Name which will represent the value. + * @param[in] value Object value. + * @return @c true if value exist, otherwise @c false + */ + bool (*set_object_value) (struct _st_things_representation* rep, const char* key, const struct _st_things_representation* value); + + /** + * @brief API for getting the value of string array type property with a key. + * @remarks This API will return deep-copied array value as out parameter, so application must free it after use. + * @param[in] rep Instance of Representation. + * @param[in] key Property Name which will represent the array type of value. + * @param[out] array Reference of the string array to where the value will be copied. + * @param[out] length Total number of elements in the array. + * @return @c true if value exist, otherwise @c false + */ + bool (*get_str_array_value) (struct _st_things_representation* rep, const char* key, char*** array, size_t* length); + + /** + * @brief API for getting the value of integer array type property with a key. + * @remarks This API will return deep-copied array value as out parameter, so application must free it after use. + * @param[in] rep Instance of Representation. + * @param[in] key Property Name which will represent the array type of value. + * @param[out] array Reference of the integer array where the value will be copied. + * @param[out] length Total number of elements in the array. + * @return @c true if value exist, otherwise @c false + */ + bool (*get_int_array_value) (struct _st_things_representation* rep, const char* key, int64_t** array, size_t* length); + + /** + * @brief API for getting the value of double array type property with a key. + * @remarks This API will return deep-copied array value as out parameter, so application must free it after use. + * @param[in] rep Instance of Representation. + * @param[in] key Property Name which will represent the array type of value. + * @param[out] array Reference of the double array where the value will be copied. + * @param[out] length Total number of elements in the array. + * @return @c true if value exist, otherwise @c false + */ + bool (*get_double_array_value) (struct _st_things_representation* rep, const char* key, double** array, size_t* length); + + /** + * @brief API for getting the value of object array type property with a key. + * @remarks This API will return deep-copied array value as out parameter, so application must free it after use.\n + * To free each object in array, st_things_destroy_representation_inst() in st_things.h should be used. + * @param[in] rep Instance of Representation. + * @param[in] key Property Name which represents the array type of value. + * @param[out] array Reference of the object array where the value will be copied. + * @param[out] length Total number of elements in the array. + * @return @c true if value exist, otherwise @c false + */ + bool (*get_object_array_value) (struct _st_things_representation* rep, const char* key, struct _st_things_representation*** array, size_t* length); + + /** + * @brief API for setting the value of string array type property with a key. + * @remarks This API will deep-copy the array value inside, so application still has an ownership of memory for the array value. + * @param[in] rep Instance of Representation. + * @param[in] key Property Name which represents the value. + * @param[in] array String array type value. + * @param[in] length Total number of elements in the array. + * @return @c true if setting value is successful, otherwise @c false + */ + bool (*set_str_array_value) (struct _st_things_representation* rep, const char* key, const char** array, size_t length); + + /** + * @brief API for setting the value of integer array type property with a key. + * @remarks This API will deep-copy the array value inside, so application still has an ownership of memory for the array value. + * @param[in] rep Instance of Representation. + * @param[in] key Property Name which represents the value. + * @param[in] array Integer array type value. + * @param[in] length Total number of elements in the array. + * @return @c true if setting value is successful, otherwise @c false + */ + bool (*set_int_array_value) (struct _st_things_representation* rep, const char* key, const int64_t* array, size_t length); + + /** + * @brief API for setting the value of double array type property with a key. + * @remarks This API will deep-copy the array value inside, so application still has an ownership of memory for the array value. + * @param[in] rep Instance of Representation. + * @param[in] key Property Name which represents the value. + * @param[in] array Double array type value. + * @param[in] length Total number of elements in the array. + * @return @c true if setting value is successful, otherwise @c false + */ + bool (*set_double_array_value) (struct _st_things_representation* rep, const char* key, const double* array, size_t length); + + /** + * @brief API for setting the value of object array type property with a key. + * @remarks This API will deep-copy the array value inside, so application still has an ownership of memory for the array value. + * @param[in] rep Instance of Representation. + * @param[in] key Property Name which represents the value. + * @param[in] array Object array type value. + * @param[in] length Total number of elements in the array. + * @return @c true if setting value is successful, otherwise @c false + */ + bool (*set_object_array_value) (struct _st_things_representation* rep, const char* key, const struct _st_things_representation** array, size_t length); + +} st_things_representation_s; + +/** + * @brief Structure for representing the Get Request Message. + */ +typedef struct _st_things_get_request_message +{ + char* resource_uri; /**< Resource URI */ + char* query; /**< One or more query parameters of the request message. Ex: key1=value1;key2=value2;... */ + char* property_key; /**< One or more property key that application needs to set a value for response. Ex: key1;key2;... */ + + /** + * @brief API for getting the value of a specific query from the query parameters of the request. + * @param[in] req_msg Instance of get request message. + * @param[in] key Name of the query.(ex: key1, key2, etc) + * @param[out] value Value of the query.(value1, value2, etc) + * @return @c true if query exist, otherwise @c false + */ + bool (*get_query_value) (struct _st_things_get_request_message* req_msg, const char* key, char** value); + + /** + * @brief API for checking whether the request has a specific property key or not. + * @param[in] req_msg Instance of get request message. + * @param[in] key Name of the property. + * @return @c true if the property key exists, otherwise @c false + */ + bool (*has_property_key) (struct _st_things_get_request_message* req_msg, const char* key); + +} st_things_get_request_message_s; + +/** + * @brief Structure for representing the Set Request Message. + */ +typedef struct _st_things_set_request_message +{ + char* resource_uri; /**< Resource URI */ + char* query; /**< One or more query parameters of the request message. Ex: key1=value1?key2=value2?... */ + struct _st_things_representation* rep; /**< Representation of the set request message */ + + /** + * @brief API for getting the value of a specific query from the query parameters of the request. + * @param[in] req_msg Instance of request message. + * @param[in] key Name of the query.(ex: key1, key2, etc) + * @param[out] value Value of the query.(value1, value2, etc) + * @return @c true if query exist, otherwise @c false + */ + bool (*get_query_value) (struct _st_things_set_request_message* req_msg, const char* key, char** value); + +} st_things_set_request_message_s; + +#endif /* __ST_THINGS_TYPES_H__ */ diff --git a/lib/liboicdastack.so b/lib/liboicdastack.so Binary files differnew file mode 100755 index 0000000..4a5cc91 --- /dev/null +++ b/lib/liboicdastack.so diff --git a/lib/libsdkapi.so b/lib/libsdkapi.so Binary files differnew file mode 100755 index 0000000..47ca354 --- /dev/null +++ b/lib/libsdkapi.so diff --git a/project_def.prop b/project_def.prop new file mode 100755 index 0000000..2d97874 --- /dev/null +++ b/project_def.prop @@ -0,0 +1,11 @@ +APPNAME = motion-light-smartthings + +type = app +profile = iot-headless-4.0 + +USER_SRCS = src/motion-light-smartthings.c +USER_DEFS = +USER_INC_DIRS = inc, inc/sdk +USER_OBJS = +USER_LIBS = lib/liboicdastack.so, lib/libsdkapi.so +USER_EDCS = diff --git a/res/device_def.json b/res/device_def.json new file mode 100755 index 0000000..0242a23 --- /dev/null +++ b/res/device_def.json @@ -0,0 +1,97 @@ +{ + "device": [ + { + "specification": { + "device": { + "deviceType": "x.wwst.d.basic", + "deviceName": "***TODO: ENTER YOUR DEVICE NAME***", + "specVersion": "core.1.1.0", + "dataModelVersion": "res.1.1.0" + }, + "platform": { + "manufacturerName": "***TODO: ENTER YOUR MNID***", + "manufacturerUrl": "http://www.samsung.com/sec/", + "manufacturingDate": "2017-11-29", + "modelNumber": "NWSP-01", + "platformVersion": "1.0", + "osVersion": "1.0", + "hardwareVersion": "1.0", + "firmwareVersion": "1.0", + "vendorId": "***TODO: ENTER YOUR VID***" + } + }, + "resources": { + "single": [ + { + "uri": "/capability/switch/main/0", + "types": [ + "x.com.st.powerswitch" + ], + "interfaces": [ + "oic.if.a", + "oic.if.baseline" + ], + "policy": 3 + }, + { + "uri": "/capability/motionSensor/main/0", + "types": [ + "oic.r.sensor.motion" + ], + "interfaces": [ + "oic.if.s", + "oic.if.baseline" + ], + "policy": 3 + } + ] + } + } + ], + "resourceTypes": [ + { + "type": "x.com.st.powerswitch", + "properties": [ + { + "key": "power", + "type": 3, + "mandatory": true, + "rw": 3 + } + ] + }, + { + "type": "oic.r.sensor.motion", + "properties": [ + { + "key": "value", + "type": 0, + "mandatory": false, + "rw": 1 + } + ] + } + ], + "configuration": { + "easySetup": { + "connectivity": { + "type": 1, + "softAP": { + "setupId": "***TODO: ENTER YOUR SETUP ID***", + "artik": false + } + }, + "ownershipTransferMethod": 2 + }, + "wifi": { + "interfaces": 15, + "frequency": 1 + }, + "filePath": { + "svrdb": "artikserversecured.dat", + "provisioning": "provisioning.dat", + "certificate": "certificate.pem", + "privateKey": "privatekey.der" + } + } +}
\ No newline at end of file diff --git a/shared/res/motion-light-smartthings.png b/shared/res/motion-light-smartthings.png Binary files differnew file mode 100755 index 0000000..9765b1b --- /dev/null +++ b/shared/res/motion-light-smartthings.png diff --git a/src/controller.c b/src/controller.c new file mode 100755 index 0000000..1c55e50 --- /dev/null +++ b/src/controller.c @@ -0,0 +1,391 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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 <tizen.h> +#include <service_app.h> +#include <string.h> +#include <stdlib.h> +#include <Ecore.h> + +#include "st_things.h" +#include "log.h" +#include "resource/resource_infrared_motion_sensor.h" +#include "resource/resource_led.h" +#include "sensor-data.h" + +#define JSON_NAME "device_def.json" +#define SENSOR_MOTION_URI "/capability/motionSensor/main/0" +#define SENSOR_MOTION_KEY "value" +#define SENSOR_LED_URI "/capability/switch/main/0" +#define SENSOR_LED_KEY "power" +#define SENSOR_LED_INIT "off" + +#define LED_ON "on" +#define LED_OFF "off" + +#define USE_ST_SDK + +typedef struct app_data_s { + Ecore_Timer *getter_motion; + sensor_data *motion_data; + sensor_data *led_data; +} app_data; + +static app_data *g_ad = NULL; + +static Eina_Bool __change_motion_sensor_data(void *data) +{ + uint32_t value = 0; + + // Get value from motion sensor + int ret = resource_read_infrared_motion_sensor(46, &value); + + if (ret != 0) _E("Cannot read sensor value"); + + sensor_data_set_bool(g_ad->motion_data, value); + + _D("Detected motion value is: %d", value); + + // Notify observers of the Motion sensor resource + st_things_notify_observers(SENSOR_MOTION_URI); + + return ECORE_CALLBACK_RENEW; +} + +static int __change_led_data(void *data, char *state) { + int ret = 0; + app_data *ad = data; + + retv_if(!ad, -1); + retv_if(!ad->led_data, -1); + + sensor_data_set_string(g_ad->led_data, state, strlen(state)); + + if (0 == strcmp(state, LED_ON)) { + ret = resource_write_led(130, 1); + } else { + ret = resource_write_led(130, 0); + } + + retv_if(ret != 0, -1); + + // Notify observers of the LED resource + st_things_notify_observers(SENSOR_LED_URI); + + return 0; +} + +static bool __handle_get_request_on_motion (st_things_get_request_message_s* req_msg, st_things_representation_s* resp_rep) +{ + if (req_msg->has_property_key(req_msg, SENSOR_MOTION_KEY)) { + bool value = false; + + sensor_data_get_bool(g_ad->motion_data, &value); + + // Update the response representation about the Motion sensor property which is sent to the client + resp_rep->set_bool_value(resp_rep, SENSOR_MOTION_KEY, value); + + _D("Value : %d", value); + + return true; + } else { + _E("not supported property"); + + return false; + } +} + +static bool __handle_get_request_on_led (st_things_get_request_message_s* req_msg, st_things_representation_s* resp_rep) +{ + if (req_msg->has_property_key(req_msg, SENSOR_LED_KEY)) { + const char *str = NULL; + + sensor_data_get_string(g_ad->led_data, &str); + + if (!str) { + str = SENSOR_LED_INIT; + } + + // Update the response representation about the LED property which is sent to the client + resp_rep->set_str_value(resp_rep, SENSOR_LED_KEY, str); + + _D("Power : %s", str); + + return true; + } else { + _E("not supported property"); + + return false; + } +} + +static bool __handle_set_request_on_led (st_things_set_request_message_s* req_msg, st_things_representation_s* resp_rep) +{ + int ret = 0; + char *str = NULL; + + if (req_msg->rep->get_str_value(req_msg->rep, SENSOR_LED_KEY, &str)) { + retv_if(!str, false); + + _D("set [%s:%s] == %s", SENSOR_LED_URI, SENSOR_LED_KEY, str); + + // Update the response representation about the LED property which is sent to the client + resp_rep->set_str_value(resp_rep, SENSOR_LED_KEY, str); + + // Turn on LED light + ret = __change_led_data(g_ad, strdup(str)); + + retv_if(ret != 0, false); + } else { + _E("cannot get a string value"); + + return false; + + } + + free(str); + + return true; +} + +void gathering_start(void *data) +{ + app_data *ad = data; + ret_if(!ad); + + if (ad->getter_motion) + ecore_timer_del(ad->getter_motion); + + ad->getter_motion = ecore_timer_add(1.0f, __change_motion_sensor_data, ad); + + if (!ad->getter_motion) { + _E("Failed to add infrared motion getter timer"); + } + + return; +} + +static bool handle_reset_request(void) +{ + _D("Received a request for RESET."); + return false; +} + +static void handle_reset_result(bool result) +{ + _D("Reset %s.\n", result ? "succeeded" : "failed"); +} + +static bool handle_ownership_transfer_request(void) +{ + _D("Received a request for Ownership-transfer."); + return true; +} + +static void handle_things_status_change(st_things_status_e things_status) +{ + _D("Things status is changed: %d\n", things_status); + + if (things_status == ST_THINGS_STATUS_REGISTERED_TO_CLOUD) + ecore_main_loop_thread_safe_call_async(gathering_start, g_ad); +} + +static bool handle_get_request(st_things_get_request_message_s* req_msg, st_things_representation_s* resp_rep) +{ + bool ret = false; + + _D("resource_uri [%s]", req_msg->resource_uri); + retv_if(!g_ad, false); + + if (0 == strcmp(req_msg->resource_uri, SENSOR_MOTION_URI)) { + _D("query : %s, property: %s", req_msg->query, req_msg->property_key); + + // Call get request function for motion sensor + ret = __handle_get_request_on_motion(req_msg, resp_rep); + } else if (0 == strcmp(req_msg->resource_uri, SENSOR_LED_URI)) { + _D("query : %s, property: %s", req_msg->query, req_msg->property_key); + + // Call get request function for LED + ret = __handle_get_request_on_led(req_msg, resp_rep); + } else { + _E("not supported uri"); + } + + return ret; +} + +static bool handle_set_request(st_things_set_request_message_s* req_msg, st_things_representation_s* resp_rep) +{ + bool ret = false; + + _D("resource_uri [%s]", req_msg->resource_uri); + retv_if(!g_ad, false); + + if (0 == strcmp(req_msg->resource_uri, SENSOR_LED_URI)) { + // Call set request function for LED + ret = __handle_set_request_on_led(req_msg, resp_rep); + } else { + _E("not supported uri"); + } + + return ret; +} + +static int __things_init(void) +{ + bool easysetup_complete = false; + char app_json_path[128] = {'\0', }; + char *app_res_path = NULL; + char *app_data_path = NULL; + + app_res_path = app_get_resource_path(); + if (!app_res_path) { + _E("app_res_path is NULL!!"); + return -1; + } + + app_data_path = app_get_data_path(); + if (!app_data_path) { + _E("app_data_path is NULL!!"); + free(app_res_path); + return -1; + } + + // Specify the read-only and read-write path + if (0 != st_things_set_configuration_prefix_path(app_res_path, app_data_path)) { + _E("st_things_set_configuration_prefix_path() failed!!"); + free(app_res_path); + free(app_data_path); + return -1; + } + free(app_data_path); + + snprintf(app_json_path, sizeof(app_json_path), "%s%s", app_res_path, JSON_NAME); + free(app_res_path); + + // Specify the device configuration JSON file and change the status of easysetup_complete + if (0 != st_things_initialize(app_json_path, &easysetup_complete)) { + _E("st_things_initialize() failed!!"); + return -1; + } + + _D("easysetup_complete:[%d] ", easysetup_complete); + + // Register callback for handling request get (handle_get_request) and request set (handle_set_request) messages + st_things_register_request_cb(handle_get_request, handle_set_request); + // Register callback for reset confirmation (handle_reset_request) and reset result(handle_reset_result) functions + st_things_register_reset_cb(handle_reset_request, handle_reset_result); + // Register callback for getting user confirmation for ownership transfer (handle_ownership_transfer_request) + st_things_register_user_confirm_cb(handle_ownership_transfer_request); + // Register callback for getting notified when ST Things state changes (handle_things_status_change) + st_things_register_things_status_change_cb(handle_things_status_change); + + return 0; +} + +static int __things_deinit(void) +{ + st_things_deinitialize(); + return 0; +} + +static int __things_start(void) +{ + st_things_start(); + return 0; +} + +static int __things_stop(void) +{ + st_things_stop(); + return 0; +} + +static bool service_app_create(void *user_data) +{ + app_data *ad = user_data; + + // Declare new sensor data for Motion data + ad->motion_data = sensor_data_new(SENSOR_DATA_TYPE_BOOL); + + if (!ad->motion_data) + return false; + + // Declare new sensor data for LED data + ad->led_data = sensor_data_new(SENSOR_DATA_TYPE_STR); + + if (!ad->led_data) + return false; + + sensor_data_set_string(g_ad->led_data, SENSOR_LED_INIT, strlen(SENSOR_LED_INIT)); + + if (__things_init()) + return false; + + return true; +} + +static void service_app_control(app_control_h app_control, void *user_data) +{ + __things_start(); +} + +static void service_app_terminate(void *user_data) +{ + app_data *ad = (app_data *)user_data; + + // Delete ecore timer + if (ad->getter_motion) + ecore_timer_del(ad->getter_motion); + + // Stop and deinitialize things + __things_stop(); + __things_deinit(); + + // Turn off LED light with __set_led() + __change_led_data(ad, LED_OFF); + + // Free sensor Motion & LED data + sensor_data_free(ad->motion_data); + sensor_data_free(ad->led_data); + + // Close Motion and LED resources + resource_close_infrared_motion_sensor(); + resource_close_led(); + + // Free app data + free(ad); + + FN_END; +} + +int main(int argc, char *argv[]) +{ + app_data *ad = NULL; + service_app_lifecycle_callback_s event_callback; + + ad = calloc(1, sizeof(app_data)); + retv_if(!ad, -1); + + g_ad = ad; + + event_callback.create = service_app_create; + event_callback.terminate = service_app_terminate; + event_callback.app_control = service_app_control; + + return service_app_main(argc, argv, &event_callback, ad); +} + diff --git a/src/resource/resource_infrared_motion_sensor.c b/src/resource/resource_infrared_motion_sensor.c new file mode 100755 index 0000000..d0605e6 --- /dev/null +++ b/src/resource/resource_infrared_motion_sensor.c @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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" + +static peripheral_gpio_h g_sensor_h = NULL; +static int g_pin_num = -1; + +void resource_close_infrared_motion_sensor(void) +{ + if (!g_sensor_h) return; + + _I("Infrared Motion Sensor is finishing..."); + + peripheral_gpio_close(g_sensor_h); + + g_sensor_h = NULL; + g_pin_num = -1; +} + +int resource_read_infrared_motion_sensor(int pin_num, uint32_t *out_value) +{ + int ret = PERIPHERAL_ERROR_NONE; + + if (!g_sensor_h) { + peripheral_gpio_h temp = NULL; + + ret = peripheral_gpio_open(pin_num, &temp); + retv_if(ret, -1); + + ret = peripheral_gpio_set_direction(temp, PERIPHERAL_GPIO_DIRECTION_IN); + if (ret) { + peripheral_gpio_close(temp); + _E("peripheral_gpio_set_direction failed."); + return -1; + } + + g_sensor_h = temp; + g_pin_num = pin_num; + } + + if (g_pin_num != pin_num) { + _E("Invalid pin number."); + return -1; + } + + ret = peripheral_gpio_read(g_sensor_h, out_value); + retv_if(ret < 0, -1); + + return 0; +} diff --git a/src/resource/resource_led.c b/src/resource/resource_led.c new file mode 100755 index 0000000..242cf73 --- /dev/null +++ b/src/resource/resource_led.c @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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" + +static peripheral_gpio_h g_sensor_h = NULL; +static int g_pin_num = -1; + +void resource_close_led(void) +{ + if (!g_sensor_h) return; + + _I("LED is finishing..."); + + peripheral_gpio_close(g_sensor_h); + + g_sensor_h = NULL; + g_pin_num = -1; +} + +int resource_write_led(int pin_num, int write_value) +{ + int ret = PERIPHERAL_ERROR_NONE; + + if (!g_sensor_h) { + peripheral_gpio_h temp = NULL; + + ret = peripheral_gpio_open(pin_num, &temp); + retv_if(ret, -1); + + ret = peripheral_gpio_set_direction(temp, PERIPHERAL_GPIO_DIRECTION_OUT_INITIALLY_LOW); + if (ret) { + peripheral_gpio_close(temp); + _E("peripheral_gpio_set_direction failed."); + return -1; + } + + g_sensor_h = temp; + g_pin_num = pin_num; + } + + if (g_pin_num != pin_num) { + _E("Invalid pin number."); + return -1; + } + + ret = peripheral_gpio_write(g_sensor_h, write_value); + retv_if(ret < 0, -1); + + _I("LED Value : %s", write_value ? "ON":"OFF"); + + return 0; +} diff --git a/src/sensor-data.c b/src/sensor-data.c new file mode 100755 index 0000000..950aab0 --- /dev/null +++ b/src/sensor-data.c @@ -0,0 +1,192 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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 <pthread.h> +#include "log.h" +#include "sensor-data.h" + +struct __sensor_data_s { + sensor_data_type_e type; + union { + int int_val; + unsigned int uint_val; + bool b_val; + double d_val; + char *str_val; + } value; + pthread_mutex_t mutex; +}; + +sensor_data *sensor_data_new(sensor_data_type_e type) +{ + sensor_data *data = NULL; + retv_if(type == SENSOR_DATA_TYPE_NONE, NULL); + + data = calloc(1, sizeof(sensor_data)); + retv_if(type == SENSOR_DATA_TYPE_NONE, NULL); + + data->type = type; + pthread_mutex_init(&data->mutex, NULL); + + return data; +} + +void sensor_data_free(sensor_data *data) +{ + ret_if(!data); + + if (data->type == SENSOR_DATA_TYPE_STR) { + pthread_mutex_lock(&data->mutex); + free(data->value.str_val); + data->value.str_val = NULL; + pthread_mutex_unlock(&data->mutex); + } + pthread_mutex_destroy(&data->mutex); + + free(data); +} + +int sensor_data_set_int(sensor_data *data, int value) +{ + retv_if(!data, -1); + retv_if(data->type != SENSOR_DATA_TYPE_INT, -1); + + pthread_mutex_lock(&data->mutex); + data->value.int_val = value; + pthread_mutex_unlock(&data->mutex); + + return 0; +} + +int sensor_data_set_uint(sensor_data *data, unsigned int value) +{ + retv_if(!data, -1); + retv_if(data->type != SENSOR_DATA_TYPE_UINT, -1); + + pthread_mutex_lock(&data->mutex); + data->value.uint_val = value; + pthread_mutex_unlock(&data->mutex); + + return 0; +} + +int sensor_data_set_bool(sensor_data *data, bool value) +{ + retv_if(!data, -1); + retv_if(data->type != SENSOR_DATA_TYPE_BOOL, -1); + + pthread_mutex_lock(&data->mutex); + data->value.b_val = value; + pthread_mutex_unlock(&data->mutex); + + return 0; +} + +int sensor_data_set_double(sensor_data *data, double value) +{ + retv_if(!data, -1); + retv_if(data->type != SENSOR_DATA_TYPE_DOUBLE, -1); + + pthread_mutex_lock(&data->mutex); + data->value.d_val = value; + pthread_mutex_unlock(&data->mutex); + + return 0; +} + +int sensor_data_set_string(sensor_data *data, const char *value, unsigned int size) +{ + char *temp = NULL; + retv_if(!data, -1); + retv_if(data->type != SENSOR_DATA_TYPE_STR, -1); + retv_if(!value, -1); + retv_if(size == 0, -1); + + temp = strndup(value, size); + pthread_mutex_lock(&data->mutex); + free(data->value.str_val); + data->value.str_val = temp; + pthread_mutex_unlock(&data->mutex); + + return 0; +} + +int sensor_data_get_int(sensor_data *data, int *value) +{ + retv_if(!data, -1); + retv_if(!value, -1); + retv_if(data->type != SENSOR_DATA_TYPE_INT, -1); + + pthread_mutex_lock(&data->mutex); + *value = data->value.int_val; + pthread_mutex_unlock(&data->mutex); + + return 0; +} + +int sensor_data_get_uint(sensor_data *data, unsigned int *value) +{ + retv_if(!data, -1); + retv_if(!value, -1); + retv_if(data->type != SENSOR_DATA_TYPE_UINT, -1); + + pthread_mutex_lock(&data->mutex); + *value = data->value.uint_val; + pthread_mutex_unlock(&data->mutex); + + return 0; +} + +int sensor_data_get_bool(sensor_data *data, bool *value) +{ + retv_if(!data, -1); + retv_if(!value, -1); + retv_if(data->type != SENSOR_DATA_TYPE_BOOL, -1); + + pthread_mutex_lock(&data->mutex); + *value = data->value.b_val; + pthread_mutex_unlock(&data->mutex); + + return 0; +} + +int sensor_data_get_double(sensor_data *data, double *value) +{ + retv_if(!data, -1); + retv_if(!value, -1); + retv_if(data->type != SENSOR_DATA_TYPE_DOUBLE, -1); + + pthread_mutex_lock(&data->mutex); + *value = data->value.d_val; + pthread_mutex_unlock(&data->mutex); + + return 0; +} + +int sensor_data_get_string(sensor_data *data, const char **value) +{ + retv_if(!data, -1); + retv_if(!value, -1); + retv_if(data->type != SENSOR_DATA_TYPE_STR, -1); + + pthread_mutex_lock(&data->mutex); + *value = data->value.str_val; + pthread_mutex_unlock(&data->mutex); + + return 0; +} + diff --git a/tizen-manifest.xml b/tizen-manifest.xml new file mode 100755 index 0000000..1439455 --- /dev/null +++ b/tizen-manifest.xml @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<manifest xmlns="http://tizen.org/ns/packages" api-version="4.0" package="org.tizen.motionlightst" version="1.0.0"> + <profile name="iot-headless"/> + <service-application appid="org.tizen.motionlightst" auto-restart="false" exec="motionlightst" multiple="false" nodisplay="true" on-boot="false" taskmanage="false" type="capp"> + <label>motionlightst</label> + <icon>motion-light-smartthings.png</icon> + <background-category value="background-network"/> + </service-application> + <privileges> + <privilege>http://tizen.org/privilege/network.get</privilege> + <privilege>http://tizen.org/privilege/network.set</privilege> + <privilege>http://tizen.org/privilege/internet</privilege> + <privilege>http://tizen.org/privilege/alarm.set</privilege> + <privilege>http://tizen.org/privilege/network.profile</privilege> + <privilege>http://tizen.org/privilege/peripheralio</privilege> + </privileges> +</manifest> |