+++ /dev/null
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(${P_NAME} C)
-
-SET(INSTALL_EXEC_PREFIX "${INSTALL_PREFIX}/bin")
-SET(CMAKE_VERBOSE_MAKEFILE 0)
-
-SET(PROJECT_ROOT_DIR "${CMAKE_SOURCE_DIR}")
-SET(PROJECT_RESOURCES_DIR "${PROJECT_ROOT_DIR}/res")
-
-INCLUDE(FindPkgConfig)
-pkg_check_modules(APP_PKGS REQUIRED
- dlog
- aul
- capi-appfw-application
- capi-appfw-service-application
- capi-system-peripheral-io
- ecore
- eina
- iotcon
- gio-2.0
- libcurl
- glib-2.0
- json-glib-1.0
-)
-
-ADD_DEFINITIONS(-DCBOR_FILE_IN_RES="${INSTALL_RESDIR}/${CBOR_FILE}")
-ADD_DEFINITIONS(-DCBOR_FILE_IN_DATA="${INSTALL_OWNER_DATADIR}/${CBOR_FILE}")
-ADD_DEFINITIONS(-DCONF_FILE="${INSTALL_RESDIR}/${CONF_FILE}")
-
-FOREACH (flag ${APP_PKGS_CFLAGS})
- SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
-ENDFOREACH(flag)
-
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -Wall -Winline -g -fno-builtin-malloc -fPIE")
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
-SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
-
-INCLUDE_DIRECTORIES(${PROJECT_ROOT_DIR}/inc)
-
-ADD_EXECUTABLE(${PROJECT_NAME}
- ${PROJECT_ROOT_DIR}/src/controller.c
- ${PROJECT_ROOT_DIR}/src/controller_internal.c
- ${PROJECT_ROOT_DIR}/src/controller_util.c
- ${PROJECT_ROOT_DIR}/src/connectivity.c
- ${PROJECT_ROOT_DIR}/src/webutil.c
- ${PROJECT_ROOT_DIR}/src/resource.c
- ${PROJECT_ROOT_DIR}/src/resource/resource_illuminance_sensor.c
- ${PROJECT_ROOT_DIR}/src/resource/resource_infrared_motion_sensor.c
- ${PROJECT_ROOT_DIR}/src/resource/resource_infrared_obstacle_avoidance_sensor.c
- ${PROJECT_ROOT_DIR}/src/resource/resource_touch_sensor.c
- ${PROJECT_ROOT_DIR}/src/resource/resource_ultrasonic_sensor.c
- ${PROJECT_ROOT_DIR}/src/resource/resource_led.c
- ${PROJECT_ROOT_DIR}/src/resource/resource_vibration_sensor.c
- ${PROJECT_ROOT_DIR}/src/resource/resource_flame_sensor.c
- ${PROJECT_ROOT_DIR}/src/resource/resource_rain_sensor.c
- ${PROJECT_ROOT_DIR}/src/resource/resource_sound_detection_sensor.c
- ${PROJECT_ROOT_DIR}/src/resource/resource_tilt_sensor.c
- ${PROJECT_ROOT_DIR}/src/resource/resource_gas_detection_sensor.c
-)
-
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} -lm)
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${APP_PKGS_LDFLAGS})
-
-Message("APP_LABEL : ${APP_LABEL}")
-
-CONFIGURE_FILE(${PROJECT_ROOT_DIR}/tizen-manifest.xml.in ${ORG_PREFIX}.${PROJECT_NAME}.xml @ONLY)
-# Install
-INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${INSTALL_EXEC_PREFIX})
-INSTALL(DIRECTORY DESTINATION ${INSTALL_OWNER_DATADIR})
-INSTALL(FILES ${ORG_PREFIX}.${PROJECT_NAME}.xml DESTINATION ${SYS_PACKAGES_DIR})
-INSTALL(FILES ${PROJECT_ROOT_DIR}/shared/res/default_icon.png DESTINATION ${SYS_ICONS_DIR} RENAME ${PROJECT_NAME}.png)
-INSTALL(FILES ${PROJECT_ROOT_DIR}/res/${CBOR_FILE} DESTINATION ${INSTALL_RESDIR})
-INSTALL(FILES ${PROJECT_ROOT_DIR}/res/${CONF_FILE} DESTINATION ${INSTALL_RESDIR})
-
-# End of a file
+++ /dev/null
-Flora License
-
-Version 1.1, April, 2013
-
-http://floralicense.org/license/
-
-TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
-1. Definitions.
-
-"License" shall mean the terms and conditions for use, reproduction,
-and distribution as defined by Sections 1 through 9 of this document.
-
-"Licensor" shall mean the copyright owner or entity authorized by
-the copyright owner that is granting the License.
-
-"Legal Entity" shall mean the union of the acting entity and
-all other entities that control, are controlled by, or are
-under common control with that entity. For the purposes of
-this definition, "control" means (i) the power, direct or indirect,
-to cause the direction or management of such entity,
-whether by contract or otherwise, or (ii) ownership of fifty percent (50%)
-or more of the outstanding shares, or (iii) beneficial ownership of
-such entity.
-
-"You" (or "Your") shall mean an individual or Legal Entity
-exercising permissions granted by this License.
-
-"Source" form shall mean the preferred form for making modifications,
-including but not limited to software source code, documentation source,
-and configuration files.
-
-"Object" form shall mean any form resulting from mechanical
-transformation or translation of a Source form, including but
-not limited to compiled object code, generated documentation,
-and conversions to other media types.
-
-"Work" shall mean the work of authorship, whether in Source or Object form,
-made available under the License, as indicated by a copyright notice
-that is included in or attached to the work (an example is provided
-in the Appendix below).
-
-"Derivative Works" shall mean any work, whether in Source or Object form,
-that is based on (or derived from) the Work and for which the editorial
-revisions, annotations, elaborations, or other modifications represent,
-as a whole, an original work of authorship. For the purposes of this License,
-Derivative Works shall not include works that remain separable from,
-or merely link (or bind by name) to the interfaces of, the Work and
-Derivative Works thereof.
-
-"Contribution" shall mean any work of authorship, including the original
-version of the Work and any modifications or additions to that Work or
-Derivative Works thereof, that is intentionally submitted to Licensor
-for inclusion in the Work by the copyright owner or by an individual or
-Legal Entity authorized to submit on behalf of the copyright owner.
-For the purposes of this definition, "submitted" means any form of
-electronic, verbal, or written communication sent to the Licensor or
-its representatives, including but not limited to communication on
-electronic mailing lists, source code control systems, and issue
-tracking systems that are managed by, or on behalf of, the Licensor
-for the purpose of discussing and improving the Work, but excluding
-communication that is conspicuously marked or otherwise designated
-in writing by the copyright owner as "Not a Contribution."
-
-"Contributor" shall mean Licensor and any individual or Legal Entity
-on behalf of whom a Contribution has been received by Licensor and
-subsequently incorporated within the Work.
-
-"Tizen Certified Platform" shall mean a software platform that complies
-with the standards set forth in the Tizen Compliance Specification
-and passes the Tizen Compliance Tests as defined from time to time
-by the Tizen Technical Steering Group and certified by the Tizen
-Association or its designated agent.
-
-2. Grant of Copyright License. Subject to the terms and conditions of
-this License, each Contributor hereby grants to You a perpetual,
-worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-copyright license to reproduce, prepare Derivative Works of,
-publicly display, publicly perform, sublicense, and distribute the
-Work and such Derivative Works in Source or Object form.
-
-3. Grant of Patent License. Subject to the terms and conditions of
-this License, each Contributor hereby grants to You a perpetual,
-worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-(except as stated in this section) patent license to make, have made,
-use, offer to sell, sell, import, and otherwise transfer the Work
-solely as incorporated into a Tizen Certified Platform, where such
-license applies only to those patent claims licensable by such
-Contributor that are necessarily infringed by their Contribution(s)
-alone or by combination of their Contribution(s) with the Work solely
-as incorporated into a Tizen Certified Platform to which such
-Contribution(s) was submitted. If You institute patent litigation
-against any entity (including a cross-claim or counterclaim
-in a lawsuit) alleging that the Work or a Contribution incorporated
-within the Work constitutes direct or contributory patent infringement,
-then any patent licenses granted to You under this License for that
-Work shall terminate as of the date such litigation is filed.
-
-4. Redistribution. You may reproduce and distribute copies of the
-Work or Derivative Works thereof pursuant to the copyright license
-above, in any medium, with or without modifications, and in Source or
-Object form, provided that You meet the following conditions:
-
- 1. You must give any other recipients of the Work or Derivative Works
- a copy of this License; and
- 2. You must cause any modified files to carry prominent notices stating
- that You changed the files; and
- 3. You must retain, in the Source form of any Derivative Works that
- You distribute, all copyright, patent, trademark, and attribution
- notices from the Source form of the Work, excluding those notices
- that do not pertain to any part of the Derivative Works; and
- 4. If the Work includes a "NOTICE" text file as part of its distribution,
- then any Derivative Works that You distribute must include a readable
- copy of the attribution notices contained within such NOTICE file,
- excluding those notices that do not pertain to any part of
- the Derivative Works, in at least one of the following places:
- within a NOTICE text file distributed as part of the Derivative Works;
- within the Source form or documentation, if provided along with the
- Derivative Works; or, within a display generated by the Derivative Works,
- if and wherever such third-party notices normally appear.
- The contents of the NOTICE file are for informational purposes only
- and do not modify the License. You may add Your own attribution notices
- within Derivative Works that You distribute, alongside or as an addendum
- to the NOTICE text from the Work, provided that such additional attribution
- notices cannot be construed as modifying the License. You may add Your own
- copyright statement to Your modifications and may provide additional or
- different license terms and conditions for use, reproduction, or
- distribution of Your modifications, or for any such Derivative Works
- as a whole, provided Your use, reproduction, and distribution of
- the Work otherwise complies with the conditions stated in this License
- and your own copyright statement or terms and conditions do not conflict
- the conditions stated in the License including section 3.
-
-5. Submission of Contributions. Unless You explicitly state otherwise,
-any Contribution intentionally submitted for inclusion in the Work
-by You to the Licensor shall be under the terms and conditions of
-this License, without any additional terms or conditions.
-Notwithstanding the above, nothing herein shall supersede or modify
-the terms of any separate license agreement you may have executed
-with Licensor regarding such Contributions.
-
-6. Trademarks. This License does not grant permission to use the trade
-names, trademarks, service marks, or product names of the Licensor,
-except as required for reasonable and customary use in describing the
-origin of the Work and reproducing the content of the NOTICE file.
-
-7. Disclaimer of Warranty. Unless required by applicable law or
-agreed to in writing, Licensor provides the Work (and each
-Contributor provides its Contributions) on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
-implied, including, without limitation, any warranties or conditions
-of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
-PARTICULAR PURPOSE. You are solely responsible for determining the
-appropriateness of using or redistributing the Work and assume any
-risks associated with Your exercise of permissions under this License.
-
-8. Limitation of Liability. In no event and under no legal theory,
-whether in tort (including negligence), contract, or otherwise,
-unless required by applicable law (such as deliberate and grossly
-negligent acts) or agreed to in writing, shall any Contributor be
-liable to You for damages, including any direct, indirect, special,
-incidental, or consequential damages of any character arising as a
-result of this License or out of the use or inability to use the
-Work (including but not limited to damages for loss of goodwill,
-work stoppage, computer failure or malfunction, or any and all
-other commercial damages or losses), even if such Contributor
-has been advised of the possibility of such damages.
-
-9. Accepting Warranty or Additional Liability. While redistributing
-the Work or Derivative Works thereof, You may choose to offer,
-and charge a fee for, acceptance of support, warranty, indemnity,
-or other liability obligations and/or rights consistent with this
-License. However, in accepting such obligations, You may act only
-on Your own behalf and on Your sole responsibility, not on behalf
-of any other Contributor, and only if You agree to indemnify,
-defend, and hold each Contributor harmless for any liability
-incurred by, or claims asserted against, such Contributor by reason
-of your accepting any such warranty or additional liability.
-
-END OF TERMS AND CONDITIONS
-
-APPENDIX: How to apply the Flora License to your work
-
-To apply the Flora License to your work, attach the following
-boilerplate notice, with the fields enclosed by brackets "[]"
-replaced with your own identifying information. (Don't include
-the brackets!) The text should be enclosed in the appropriate
-comment syntax for the file format. We also recommend that a
-file or class name and description of purpose be included on the
-same "printed page" as the copyright notice for easier
-identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed under the Flora License, Version 1.1 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://floralicense.org/license/
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--- /dev/null
+#! /bin/bash
+download_dir=download
+script_fusing=sd_fusing_rpi3.sh
+tizen_download_url=http://download.tizen.org/snapshots/tizen/unified/
+binary_prefix=tizen-unified
+binary_version=20170930.1
+boot_img_name=iot-boot-arm64-rpi3
+platform_img_name=iot-headless-2parts-armv7l-rpi3
+usb_node=/dev/sdb
+tmp_rfs_dir=$download_dir/rootfs
+
+download_binaries() {
+if [ ! -d $download_dir ]; then
+ mkdir -p $download_dir
+else
+ echo "download directory aleady exist"
+fi
+
+if [ ! -e $download_dir/$script_fusing ]; then
+ wget https://git.tizen.org/cgit/platform/kernel/linux-rpi3/plain/scripts/sd_fusing_rpi3.sh?h=submit/tizen/20170725.223437 --output-document=$download_dir/$script_fusing
+fi
+
+if [ ! -e $download_dir/$script_fusing ]; then
+ echo "[ERROR] fail to download fusing script"
+ exit 1
+fi
+
+chmod 755 $download_dir/$script_fusing
+
+if [ ! -e $download_dir/brcmfmac43430-sdio.bin ]; then
+ wget https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm80211/brcm/brcmfmac43430-sdio.bin -P $download_dir
+fi
+
+if [ ! -e $download_dir/brcmfmac43430-sdio.bin ]; then
+ echo "[ERROR] fail to download [brcmfmac43430-sdio.bin]"
+ exit 1
+fi
+
+if [ ! -e $download_dir/brcmfmac43430-sdio.txt ]; then
+ wget https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm80211/brcm/brcmfmac43430-sdio.txt -P $download_dir
+fi
+if [ ! -e $download_dir/brcmfmac43430-sdio.txt ]; then
+ echo "[ERROR] fail to download [brcmfmac43430-sdio.txt]"
+ exit 1
+fi
+
+if [ ! -e $download_dir/BCM43430A1.hcd ]; then
+ wget https://github.com/OpenELEC/misc-firmware/raw/master/firmware/brcm/BCM43430A1.hcd -P $download_dir
+fi
+if [ ! -e $download_dir/BCM43430A1.hcd ]; then
+ echo "[ERROR] fail to download [BCM43430A1.hcd]"
+ exit 1
+fi
+
+if [ ! -e $download_dir/$boot_img ]; then
+ wget ${tizen_download_url}${binary_prefix}_${binary_version}/images/standard/${boot_img_name}/$boot_img -P $download_dir
+fi
+if [ ! -e $download_dir/$boot_img ]; then
+ echo "[ERROR] fail to download [${boot_img}]"
+ exit 1
+fi
+
+if [ ! -e $download_dir/$platform_img ]; then
+ wget ${tizen_download_url}${binary_prefix}_${binary_version}/images/standard/${platform_img_name}/$platform_img -P $download_dir
+fi
+if [ ! -e $download_dir/$platform_img ]; then
+ echo "[ERROR] fail to download [${platform_img}]"
+ exit 1
+fi
+}
+#
+#
+fusing_sdcard() {
+sudo /bin/bash $download_dir/$script_fusing -d $usb_node --format
+sudo /bin/bash $download_dir/$script_fusing -d $usb_node -b $download_dir/$boot_img
+sudo /bin/bash $download_dir/$script_fusing -d $usb_node -b $download_dir/$platform_img
+}
+
+copy_firmware() {
+mkdir -p $tmp_rfs_dir
+sudo mount ${usb_node}2 $tmp_rfs_dir
+sudo mkdir -p $tmp_rfs_dir/usr/etc/bluetooth
+sudo cp $download_dir/BCM43430A1.hcd $tmp_rfs_dir/usr/etc/bluetooth
+sudo mkdir -p $tmp_rfs_dir/usr/lib/firmware/brcm
+sudo cp $download_dir/brcmfmac43430-sdio.* $tmp_rfs_dir/usr/lib/firmware/brcm
+sync
+sudo umount $tmp_rfs_dir
+rmdir $tmp_rfs_dir
+}
+#
+#display_help() {
+# echo "Usage: $0 [dev node of usb] [binary version]"
+# echo "example : $0 /dev/sdb 20170824.1
+# exit 1
+#}
+#
+#
+#################################
+##set -x
+#
+##if [ $# -lt 2 ] ; then
+## display_help
+##fi
+#
+#echo "########### Your Storage Device nodes ############"
+#echo
+#lsblk
+#echo
+#echo "##################################################"
+#echo
+#echo "Please enter device node of usb [press enter key to use default($usb_node)] : "
+#read input_node
+#if [ "$input_node" = "" ]; then
+# echo "########### use default dev node : ${usb_node}"
+#else
+# if [ "$input_node" = "/dev/sda" ]; then
+# echo "[ERROR] /dev/sda is your main storage"
+# exit 1
+# fi
+# usb_node=${input_node}
+# echo "########### use dev node : $usb_node"
+#fi
+#
+#echo "Please enter binary version of usb [press enter key to use default($binary_version)] : "
+#read input_version
+#if [ "$input_version" = "" ]; then
+# echo "########### use default version : $binary_version"
+#else
+# binary_version=$input_version
+# echo "########### use binary version : $binary_version"
+#fi
+#
+#boot_img=${binary_prefix}_${binary_version}_${boot_img_name}.tar.gz
+#platform_img=${binary_prefix}_${binary_version}_${platform_img_name}.tar.gz
+#
+#download_binaries
+#
+#sleep 1
+#
+#fusing_sdcard
+#copy_firmware
+#
+##! /bin/bash
+#
+RED='\e[0;31m'
+NC='\e[0m'
+GREEN='\e[0;32m'
+PURPLE='\e[0;35m';
+
+conf_filename="pi.conf"
+sdb_port_num="26101"
+pkg_name=""
+ip_addr=""
+pkg_file=""
+dev_id=""
+web_url=""
+pkg_name=""
+ret=0
+ret_file_not_found=1
+ret_connection_fail=2
+ret_pkg_launch_fail=3
+
+display_help() {
+ echo "Usage: $0 [Target IP Addr.] [Package file] [Device ID] [Web API URL]"
+ echo
+ exit 1
+}
+
+check_pkg_file() {
+ ret_v=0
+ echo "$1"
+ if [ -e $1 ] ; then
+ pkg_name=`rpm -qp --queryformat="%{NAME}" $1`
+ echo -e "${GREEN}Ready to install [$pkg_name]${NC}"
+ else
+ echo -e "${RED}file [$1] not found${NC}"
+ ret_v=${ret_file_not_found}
+ fi
+
+ return $ret_v
+}
+
+connect_sdb_by_ip() {
+ ret_v=0
+
+ #sdb kill-server
+ if sdb connect $1 | grep -q 'connected'; then
+ echo -e "${GREEN}Connected to target[$1]${NC}"
+ else
+ echo -e "${RED}Fail to connect target [$1]${NC}"
+ ret_v=${ret_connection_fail}
+ fi
+ return $ret_v
+}
+
+send_pkg_and_install() {
+ ret_v=0
+
+ filename="${2##*/}"
+ conf_file=/usr/apps/${pkg_name}/res/${conf_filename}
+ sdb_cmd="sdb -s $1:${sdb_port_num}"
+
+ ${sdb_cmd} root on
+ ${sdb_cmd} shell mount -o remount rw /
+ ${sdb_cmd} push $2 /tmp
+
+ ${sdb_cmd} shell journalctl --vacuum-size=128M
+
+ PID=`${sdb_cmd} shell "ps -ef | grep ${pkg_name} | grep -v grep" | awk '{print $2}'`
+
+ if [ -z "${PID}" ]; then
+ echo
+ echo -e "${GREEN}${pkg_name} is not running now${NC}"
+ echo
+ else
+ echo
+ echo -e "${GREEN}Terminating ${pkg_name} - ${PID}${NC}"
+ echo
+ ${sdb_cmd} shell "aul_test term_pid_without_restart ${PID}"
+ fi
+
+ ${sdb_cmd} shell "rpm -ivh --force /tmp/$filename"
+
+ if [ -z "$3" ]; then
+ echo "No argument for Device ID"
+ else
+ ${sdb_cmd} shell "sed -i -e 's/\(path=\).*/\1"${3//\//\\/}"/' ${conf_file}"
+ fi
+
+ if [ -z "$4" ]; then
+ echo "No argument for Web API URL"
+ else
+ ${sdb_cmd} shell "sed -i -e 's/\(address=\).*/\1"${4//\//\\/}"/' ${conf_file}"
+ fi
+
+ ${sdb_cmd} shell pkg_initdb --ro
+ ${sdb_cmd} shell sync
+
+ if ${sdb_cmd} shell "aul_test launch ${pkg_name}" | grep -q 'successs'; then
+ echo -e "${GREEN}Success to launch ${pkg_name}${NC}"
+ else
+ echo -e "${RED}Fail to to launch ${pkg_name}${NC}"
+ ret_v=${ret_pkg_launch_fail}
+ fi
+
+ return $ret_v
+}
+#
+#main() {
+# if [ $# -lt 2 ] ; then
+# display_help
+# fi
+#
+# ip_addr=$1
+# pkg_file=$2
+# dev_id=$3
+# web_url=$4
+#
+# check_pkg_file ${pkg_file}
+# ret=$?
+# if ! [ "${ret}" == 0 ];then
+# echo "return code ${ret}"
+# exit "${ret}"
+# fi
+#
+# connect_sdb_by_ip ${ip_addr}
+# ret=$?
+# if ! [ "${ret}" == 0 ];then
+# echo "return code ${ret}"
+# exit "${ret}"
+# fi
+#
+# send_pkg_and_install ${ip_addr} ${pkg_file} ${dev_id} ${web_url}
+# ret=$?
+# if ! [ "${ret}" == 0 ];then
+# echo "return code ${ret}"
+# exit "${ret}"
+# fi
+#
+# exit 0
+#}
+#
+############# Start Here
+##set -x
+#if [ "${1}" != "--source-only" ]; then
+# main "${@}"
+#fi
+##! /bin/bash
+#
+conf_script=install_with_conf.sh
+m_dev_info=""
+ret_code=0
+order=()
+id=()
+ip=()
+
+display_help_multi() {
+ echo "Usage: $0 [multi device info file] [package file] [web api url]"
+ echo
+ exit 1
+}
+#
+############# Start Here
+##set -x
+#if [ $# -lt 2 ] ; then
+# display_help_multi
+#fi
+#
+#if [ ! -x ${conf_script} ] ; then
+# echo "${conf_script} file is NOT exist or NOT executable"
+# exit 1
+#fi
+#
+#source ${conf_script} --source-only
+#
+#m_dev_info=$1
+#pkg_file=$2
+#web_url=$3
+#
+#if [ ! -r $m_dev_info ] ; then
+# echo "mutil device info file [$m_dev_info] NOT found"
+# echo
+# exit 1
+#fi
+#
+#check_pkg_file ${pkg_file}
+#ret_code=$?
+#if ! [ "${ret_code}" == 0 ];then
+# exit "${ret_code}"
+#fi
+#
+#while read NUM ID IP
+#do
+# order+=(${NUM})
+# id+=(${ID})
+# ip+=(${IP})
+#done <${m_dev_info}
+#
+#result="No.\tDevID\t\tIP\t\tRESULT"
+#
+#for i in "${!order[@]}"
+#do
+# result="${result}"'\n'"${order[$i]}\t${id[$i]} \t${ip[$i]}"
+# connect_sdb_by_ip ${ip[$i]}
+# ret_code=$?
+# if [ "${ret_code}" == 0 ];then
+# if [ -z "$web_url" ]; then
+# echo
+# echo -e "${PURPLE}[${order[$i]}] Installing $pkg_file to device[${ip[$i]}] with ID[${id[$i]}]${NC}"
+# echo
+# send_pkg_and_install ${ip[$i]} ${pkg_file} ${id[$i]}
+# else
+# echo
+# echo -e "${PURPLE}[${order[$i]}] Installing $pkg_file to device[${ip[$i]}] with ID[${id[$i]}], URL[$web_url]${NC}"
+# echo
+# send_pkg_and_install ${IP} ${ip[$i]} ${pkg_file} ${id[$i]} ${web_url}
+# fi
+# ret_code=$?
+# fi
+#
+# if [ ${ret_code} -eq 0 ]; then
+# result+="\tSUCCESS"
+# else
+# result+="\tFAIL(${ret_code})"
+# echo -e "${RED}[${order[$i]}] Install $pkg_file to device[${ip[$i]}] FAILED with (${ret_code}) ${NC}"
+# fi
+# echo
+#done
+#
+#echo "################################################################"
+#echo -e "${result}"
+#echo "################################################################"
+#
+#exit 0
+#! /bin/bash
+download_dir=download
+script_fusing=sd_fusing_rpi3.sh
+tizen_download_url=http://download.tizen.org/snapshots/tizen/unified/
+binary_prefix=tizen-unified
+binary_version=20170930.1
+boot_img_name=iot-boot-arm64-rpi3
+platform_img_name=iot-headless-2parts-armv7l-rpi3
+usb_node=/dev/sdb
+tmp_rfs_dir=$download_dir/rootfs
+
+download_binaries() {
+if [ ! -d $download_dir ]; then
+ mkdir -p $download_dir
+else
+ echo "download directory aleady exist"
+fi
+
+if [ ! -e $download_dir/$script_fusing ]; then
+ wget https://git.tizen.org/cgit/platform/kernel/linux-rpi3/plain/scripts/sd_fusing_rpi3.sh?h=submit/tizen/20170725.223437 --output-document=$download_dir/$script_fusing
+fi
+
+if [ ! -e $download_dir/$script_fusing ]; then
+ echo "[ERROR] fail to download fusing script"
+ exit 1
+fi
+
+chmod 755 $download_dir/$script_fusing
+
+if [ ! -e $download_dir/brcmfmac43430-sdio.bin ]; then
+ wget https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm80211/brcm/brcmfmac43430-sdio.bin -P $download_dir
+fi
+}
+#
+#if [ ! -e $download_dir/brcmfmac43430-sdio.bin ]; then
+. /etc/tizen-platform.conf
+server_name=position-finder-server
+server_pkg=org.tizen.${server_name}
+server_pkg_dir=${TZ_SYS_RW_APP}/${server_pkg}
+wifi_config_dir=/var/lib/connman
+# echo "[ERROR] fail to download [brcmfmac43430-sdio.bin]"
+# exit 1
+#fi
+
+download_binaries() {
+if [ ! -e $download_dir/brcmfmac43430-sdio.txt ]; then
+ wget https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm80211/brcm/brcmfmac43430-sdio.txt -P $download_dir
+fi
+if [ ! -e $download_dir/brcmfmac43430-sdio.txt ]; then
+ echo "[ERROR] fail to download [brcmfmac43430-sdio.txt]"
+ exit 1
+fi
+
+if [ ! -e $download_dir/BCM43430A1.hcd ]; then
+ wget https://github.com/OpenELEC/misc-firmware/raw/master/firmware/brcm/BCM43430A1.hcd -P $download_dir
+fi
+if [ ! -e $download_dir/BCM43430A1.hcd ]; then
+ echo "[ERROR] fail to download [BCM43430A1.hcd]"
+ exit 1
+fi
+
+if [ ! -e $download_dir/$boot_img ]; then
+ wget ${tizen_download_url}${binary_prefix}_${binary_version}/images/standard/${boot_img_name}/$boot_img -P $download_dir
+fi
+if [ ! -e $download_dir/$boot_img ]; then
+ echo "[ERROR] fail to download [${boot_img}]"
+ exit 1
+fi
+
+if [ ! -e $download_dir/$platform_img ]; then
+ wget ${tizen_download_url}${binary_prefix}_${binary_version}/images/standard/${platform_img_name}/$platform_img -P $download_dir
+fi
+if [ ! -e $download_dir/$platform_img ]; then
+ echo "[ERROR] fail to download [${platform_img}]"
+ exit 1
+fi
+}
+
+fusing_sdcard() {
+sudo /bin/bash $download_dir/$script_fusing -d $usb_node --format
+sudo /bin/bash $download_dir/$script_fusing -d $usb_node -b $download_dir/$boot_img
+sudo /bin/bash $download_dir/$script_fusing -d $usb_node -b $download_dir/$platform_img
+}
+
+copy_firmware() {
+mkdir -p $tmp_rfs_dir
+sudo mount ${usb_node}2 $tmp_rfs_dir
+sudo mkdir -p $tmp_rfs_dir/usr/etc/bluetooth
+sudo cp $download_dir/BCM43430A1.hcd $tmp_rfs_dir/usr/etc/bluetooth
+sudo mkdir -p $tmp_rfs_dir/usr/lib/firmware/brcm
+sudo cp $download_dir/brcmfmac43430-sdio.* $tmp_rfs_dir/usr/lib/firmware/brcm
+sync
+sudo umount $tmp_rfs_dir
+rmdir $tmp_rfs_dir
+}
+
+#display_help() {
+# echo "Usage: $0 [dev node of usb] [binary version]"
+# echo "example : $0 /dev/sdb 20170824.1
+# exit 1
+#}
+#
+#
+#################################
+##set -x
+#
+##if [ $# -lt 2 ] ; then
+## display_help
+##fi
+#
+#echo "########### Your Storage Device nodes ############"
+#echo
+#lsblk
+#echo
+#echo "##################################################"
+#echo
+#echo "Please enter device node of usb [press enter key to use default($usb_node)] : "
+#read input_node
+#if [ "$input_node" = "" ]; then
+# echo "########### use default dev node : ${usb_node}"
+#else
+# if [ "$input_node" = "/dev/sda" ]; then
+# echo "[ERROR] /dev/sda is your main storage"
+# exit 1
+# fi
+# usb_node=${input_node}
+# echo "########### use dev node : $usb_node"
+#fi
+#
+#echo "Please enter binary version of usb [press enter key to use default($binary_version)] : "
+#read input_version
+#if [ "$input_version" = "" ]; then
+# echo "########### use default version : $binary_version"
+#else
+# binary_version=$input_version
+# echo "########### use binary version : $binary_version"
+#fi
+#
+#boot_img=${binary_prefix}_${binary_version}_${boot_img_name}.tar.gz
+#platform_img=${binary_prefix}_${binary_version}_${platform_img_name}.tar.gz
+#
+#download_binaries
+#
+#sleep 1
+#
+#fusing_sdcard
+#copy_firmware
+#
+##! /bin/bash
+#
+RED='\e[0;31m'
+NC='\e[0m'
+GREEN='\e[0;32m'
+PURPLE='\e[0;35m';
+
+conf_filename="pi.conf"
+sdb_port_num="26101"
+pkg_name=""
+ip_addr=""
+pkg_file=""
+dev_id=""
+web_url=""
+pkg_name=""
+ret=0
+ret_file_not_found=1
+ret_connection_fail=2
+ret_pkg_launch_fail=3
+
+display_help() {
+ echo "Usage: $0 [Target IP Addr.] [Package file] [Device ID] [Web API URL]"
+ echo
+ exit 1
+}
+
+check_pkg_file() {
+ ret_v=0
+ echo "$1"
+ if [ -e $1 ] ; then
+ pkg_name=`rpm -qp --queryformat="%{NAME}" $1`
+ echo -e "${GREEN}Ready to install [$pkg_name]${NC}"
+ else
+ echo -e "${RED}file [$1] not found${NC}"
+ ret_v=${ret_file_not_found}
+ fi
+
+ return $ret_v
+}
+
+connect_sdb_by_ip() {
+ ret_v=0
+
+ #sdb kill-server
+ if sdb connect $1 | grep -q 'connected'; then
+ echo -e "${GREEN}Connected to target[$1]${NC}"
+ else
+ echo -e "${RED}Fail to connect target [$1]${NC}"
+ ret_v=${ret_connection_fail}
+ fi
+ return $ret_v
+}
+
+send_pkg_and_install() {
+ ret_v=0
+
+ filename="${2##*/}"
+ conf_file=/usr/apps/${pkg_name}/res/${conf_filename}
+ sdb_cmd="sdb -s $1:${sdb_port_num}"
+
+ ${sdb_cmd} root on
+ ${sdb_cmd} shell mount -o remount rw /
+ ${sdb_cmd} push $2 /tmp
+
+ ${sdb_cmd} shell journalctl --vacuum-size=128M
+
+ PID=`${sdb_cmd} shell "ps -ef | grep ${pkg_name} | grep -v grep" | awk '{print $2}'`
+
+ if [ -z "${PID}" ]; then
+ echo
+ echo -e "${GREEN}${pkg_name} is not running now${NC}"
+ echo
+ else
+ echo
+ echo -e "${GREEN}Terminating ${pkg_name} - ${PID}${NC}"
+ echo
+ ${sdb_cmd} shell "aul_test term_pid_without_restart ${PID}"
+ fi
+
+ ${sdb_cmd} shell "rpm -ivh --force /tmp/$filename"
+
+ if [ -z "$3" ]; then
+ echo "No argument for Device ID"
+ else
+ ${sdb_cmd} shell "sed -i -e 's/\(path=\).*/\1"${3//\//\\/}"/' ${conf_file}"
+ fi
+
+ if [ -z "$4" ]; then
+ echo "No argument for Web API URL"
+ else
+ ${sdb_cmd} shell "sed -i -e 's/\(address=\).*/\1"${4//\//\\/}"/' ${conf_file}"
+ fi
+}
+# ${sdb_cmd} shell pkg_initdb --ro
+# ${sdb_cmd} shell sync
+#
+# if ${sdb_cmd} shell "aul_test launch ${pkg_name}" | grep -q 'successs'; then
+remove_server() {
+if [ -e ${server_pkg_dir}/bin/${server_name} ]; then
+# rm ${server_pkg_dir}/bin/${server_name}
+ pkgcmd -t tpk -u -n ${server_pkg}
+else
+ echo "Running Program..."
+ echo "[FAIL] Cannot remove server"
+ echo "[FAIL] Run the program again"
+ exit 0
+
+fi
+}
+
+abcd() {
+ echo -e "${GREEN}Success to launch ${pkg_name}${NC}"
+ echo -e "${RED}Fail to to launch ${pkg_name}${NC}"
+ ret_v=${ret_pkg_launch_fail}
+
+ return $ret_v
+}
+
+#main() {
+# if [ $# -lt 2 ] ; then
+# display_help
+# fi
+#
+# ip_addr=$1
+# pkg_file=$2
+# dev_id=$3
+# web_url=$4
+#
+# check_pkg_file ${pkg_file}
+# ret=$?
+# if ! [ "${ret}" == 0 ];then
+# echo "return code ${ret}"
+# exit "${ret}"
+# fi
+#
+# connect_sdb_by_ip ${ip_addr}
+# ret=$?
+# if ! [ "${ret}" == 0 ];then
+# echo "return code ${ret}"
+# exit "${ret}"
+# fi
+#
+# send_pkg_and_install ${ip_addr} ${pkg_file} ${dev_id} ${web_url}
+# ret=$?
+# if ! [ "${ret}" == 0 ];then
+# echo "return code ${ret}"
+# exit "${ret}"
+# fi
+#
+# exit 0
+#}
+#
+############# Start Here
+##set -x
+#if [ "${1}" != "--source-only" ]; then
+# main "${@}"
+#fi
+##! /bin/bash
+#
+conf_script=install_with_conf.sh
+m_dev_info=""
+ret_code=0
+order=()
+id=()
+ip=()
+
+display_help_multi() {
+ echo "Usage: $0 [multi device info file] [package file] [web api url]"
+ echo
+ exit 1
+}
+#
+############# Start Here
+##set -x
+#if [ $# -lt 2 ] ; then
+# display_help_multi
+#fi
+#
+#if [ ! -x ${conf_script} ] ; then
+# echo "${conf_script} file is NOT exist or NOT executable"
+# exit 1
+#fi
+#
+#source ${conf_script} --source-only
+#
+m_dev_info=$1
+pkg_file=$2
+web_url=$3
+#
+#if [ ! -r $m_dev_info ] ; then
+# echo "mutil device info file [$m_dev_info] NOT found"
+# echo
+# exit 1
+#fi
+#
+#check_pkg_file ${pkg_file}
+#ret_code=$?
+#if ! [ "${ret_code}" == 0 ];then
+# exit "${ret_code}"
+#fi
+#
+#while read NUM ID IP
+#do
+# order+=(${NUM})
+# id+=(${ID})
+# ip+=(${IP})
+#done <${m_dev_info}
+#
+#result="No.\tDevID\t\tIP\t\tRESULT"
+#
+#for i in "${!order[@]}"
+#do
+# result="${result}"'\n'"${order[$i]}\t${id[$i]} \t${ip[$i]}"
+# connect_sdb_by_ip ${ip[$i]}
+# ret_code=$?
+# if [ "${ret_code}" == 0 ];then
+# if [ -z "$web_url" ]; then
+# echo
+# echo -e "${PURPLE}[${order[$i]}] Installing $pkg_file to device[${ip[$i]}] with ID[${id[$i]}]${NC}"
+# echo
+# send_pkg_and_install ${ip[$i]} ${pkg_file} ${id[$i]}
+# else
+# echo
+# echo -e "${PURPLE}[${order[$i]}] Installing $pkg_file to device[${ip[$i]}] with ID[${id[$i]}], URL[$web_url]${NC}"
+# echo
+# send_pkg_and_install ${IP} ${ip[$i]} ${pkg_file} ${id[$i]} ${web_url}
+# fi
+# ret_code=$?
+# fi
+#
+# if [ ${ret_code} -eq 0 ]; then
+# result+="\tSUCCESS"
+# else
+# result+="\tFAIL(${ret_code})"
+# echo -e "${RED}[${order[$i]}] Install $pkg_file to device[${ip[$i]}] FAILED with (${ret_code}) ${NC}"
+# fi
+# echo
+#done
+#
+#echo "################################################################"
+#echo -e "${result}"
+#echo "################################################################"
+#
+#exit 0
+#! /bin/bash
+download_dir=download
+script_fusing=sd_fusing_rpi3.sh
+tizen_download_url=http://download.tizen.org/snapshots/tizen/unified/
+binary_prefix=tizen-unified
+binary_version=20170930.1
+boot_img_name=iot-boot-arm64-rpi3
+platform_img_name=iot-headless-2parts-armv7l-rpi3
+usb_node=/dev/sdb
+tmp_rfs_dir=$download_dir/rootfs
+
+download_binaries() {
+if [ ! -d $download_dir ]; then
+ mkdir -p $download_dir
+else
+ echo "download directory aleady exist"
+fi
+}
+#
+remove_wifi_config() {
+ rm ${wifi_config_dir}/wifi_* -rf
+}
+#if [ ! -e $download_dir/$script_fusing ]; then
+# wget https://git.tizen.org/cgit/platform/kernel/linux-rpi3/plain/scripts/sd_fusing_rpi3.sh?h=submit/tizen/20170725.223437 --output-document=$download_dir/$script_fusing
+#fi
+#
+ownload_binaries() {
+if [ ! -e $download_dir/$script_fusing ]; then
+ echo "[ERROR] fail to download fusing script"
+ exit 1
+fi
+
+chmod 755 $download_dir/$script_fusing
+
+if [ ! -e $download_dir/brcmfmac43430-sdio.bin ]; then
+ wget https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm80211/brcm/brcmfmac43430-sdio.bin -P $download_dir
+fi
+
+if [ ! -e $download_dir/brcmfmac43430-sdio.bin ]; then
+ echo "[ERROR] fail to download [brcmfmac43430-sdio.bin]"
+ exit 1
+fi
+
+if [ ! -e $download_dir/brcmfmac43430-sdio.txt ]; then
+ wget https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm80211/brcm/brcmfmac43430-sdio.txt -P $download_dir
+fi
+if [ ! -e $download_dir/brcmfmac43430-sdio.txt ]; then
+ echo "[ERROR] fail to download [brcmfmac43430-sdio.txt]"
+ exit 1
+fi
+
+if [ ! -e $download_dir/BCM43430A1.hcd ]; then
+ wget https://github.com/OpenELEC/misc-firmware/raw/master/firmware/brcm/BCM43430A1.hcd -P $download_dir
+fi
+if [ ! -e $download_dir/BCM43430A1.hcd ]; then
+ echo "[ERROR] fail to download [BCM43430A1.hcd]"
+ exit 1
+fi
+
+if [ ! -e $download_dir/$boot_img ]; then
+ wget ${tizen_download_url}${binary_prefix}_${binary_version}/images/standard/${boot_img_name}/$boot_img -P $download_dir
+fi
+if [ ! -e $download_dir/$boot_img ]; then
+ echo "[ERROR] fail to download [${boot_img}]"
+ exit 1
+fi
+
+if [ ! -e $download_dir/$platform_img ]; then
+ wget ${tizen_download_url}${binary_prefix}_${binary_version}/images/standard/${platform_img_name}/$platform_img -P $download_dir
+fi
+if [ ! -e $download_dir/$platform_img ]; then
+ echo "[ERROR] fail to download [${platform_img}]"
+ exit 1
+fi
+
+}
+
+fusing_sdcard() {
+sudo /bin/bash $download_dir/$script_fusing -d $usb_node --format
+sudo /bin/bash $download_dir/$script_fusing -d $usb_node -b $download_dir/$boot_img
+sudo /bin/bash $download_dir/$script_fusing -d $usb_node -b $download_dir/$platform_img
+}
+
+copy_firmware() {
+mkdir -p $tmp_rfs_dir
+sudo mount ${usb_node}2 $tmp_rfs_dir
+sudo mkdir -p $tmp_rfs_dir/usr/etc/bluetooth
+sudo cp $download_dir/BCM43430A1.hcd $tmp_rfs_dir/usr/etc/bluetooth
+sudo mkdir -p $tmp_rfs_dir/usr/lib/firmware/brcm
+sudo cp $download_dir/brcmfmac43430-sdio.* $tmp_rfs_dir/usr/lib/firmware/brcm
+sync
+sudo umount $tmp_rfs_dir
+rmdir $tmp_rfs_dir
+}
+#
+#display_help() {
+# echo "Usage: $0 [dev node of usb] [binary version]"
+# echo "example : $0 /dev/sdb 20170824.1"
+# exit 1
+#}
+#
+#
+#################################
+##set -x
+#
+##if [ $# -lt 2 ] ; then
+## display_help
+##fi
+#
+#echo "########### Your Storage Device nodes ############"
+#echo
+#lsblk
+#echo
+#echo "##################################################"
+#echo
+#echo "Please enter device node of usb [press enter key to use default($usb_node)] : "
+#read input_node
+#if [ "$input_node" = "" ]; then
+# echo "########### use default dev node : ${usb_node}"
+#else
+# if [ "$input_node" = "/dev/sda" ]; then
+# echo "[ERROR] /dev/sda is your main storage"
+# exit 1
+# fi
+# usb_node=${input_node}
+# echo "########### use dev node : $usb_node"
+#fi
+#
+#echo "Please enter binary version of usb [press enter key to use default($binary_version)] : "
+#read input_version
+#if [ "$input_version" = "" ]; then
+# echo "########### use default version : $binary_version"
+#else
+# binary_version=$input_version
+# echo "########### use binary version : $binary_version"
+#fi
+#
+#boot_img=${binary_prefix}_${binary_version}_${boot_img_name}.tar.gz
+#platform_img=${binary_prefix}_${binary_version}_${platform_img_name}.tar.gz
+#
+#download_binaries
+#
+#sleep 1
+#
+#fusing_sdcard
+#copy_firmware
+#
+##! /bin/bash
+#
+RED='\e[0;31m'
+NC='\e[0m'
+GREEN='\e[0;32m'
+PURPLE='\e[0;35m';
+
+conf_filename="pi.conf"
+sdb_port_num="26101"
+pkg_name=""
+ip_addr=""
+pkg_file=""
+dev_id=""
+web_url=""
+pkg_name=""
+ret=0
+ret_file_not_found=1
+ret_connection_fail=2
+ret_pkg_launch_fail=3
+
+display_help() {
+ echo "Usage: $0 [Target IP Addr.] [Package file] [Device ID] [Web API URL]"
+ echo
+ exit 1
+}
+
+check_pkg_file() {
+ ret_v=0
+ echo "$1"
+ if [ -e $1 ] ; then
+ pkg_name=`rpm -qp --queryformat="%{NAME}" $1`
+ echo -e "${GREEN}Ready to install [$pkg_name]${NC}"
+ else
+ echo -e "${RED}file [$1] not found${NC}"
+ ret_v=${ret_file_not_found}
+ fi
+
+ return $ret_v
+}
+
+connect_sdb_by_ip() {
+ ret_v=0
+
+ #sdb kill-server
+ if sdb connect $1 | grep -q 'connected'; then
+ echo -e "${GREEN}Connected to target[$1]${NC}"
+ else
+ echo -e "${RED}Fail to connect target [$1]${NC}"
+ ret_v=${ret_connection_fail}
+ fi
+ return $ret_v
+}
+
+send_pkg_and_install() {
+ ret_v=0
+
+ filename="${2##*/}"
+ conf_file=/usr/apps/${pkg_name}/res/${conf_filename}
+ sdb_cmd="sdb -s $1:${sdb_port_num}"
+
+ ${sdb_cmd} root on
+ ${sdb_cmd} shell mount -o remount rw /
+ ${sdb_cmd} push $2 /tmp
+
+ ${sdb_cmd} shell journalctl --vacuum-size=128M
+
+ PID=`${sdb_cmd} shell "ps -ef | grep ${pkg_name} | grep -v grep" | awk '{print $2}'`
+
+ if [ -z "${PID}" ]; then
+ echo
+ echo -e "${GREEN}${pkg_name} is not running now${NC}"
+ echo
+ else
+ echo
+ echo -e "${GREEN}Terminating ${pkg_name} - ${PID}${NC}"
+ echo
+ ${sdb_cmd} shell "aul_test term_pid_without_restart ${PID}"
+ fi
+
+ ${sdb_cmd} shell "rpm -ivh --force /tmp/$filename"
+
+ if [ -z "$3" ]; then
+ echo "No argument for Device ID"
+ else
+ ${sdb_cmd} shell "sed -i -e 's/\(path=\).*/\1"${3//\//\\/}"/' ${conf_file}"
+ fi
+
+ if [ -z "$4" ]; then
+ echo "No argument for Web API URL"
+ else
+ ${sdb_cmd} shell "sed -i -e 's/\(address=\).*/\1"${4//\//\\/}"/' ${conf_file}"
+ fi
+
+ ${sdb_cmd} shell pkg_initdb --ro
+ ${sdb_cmd} shell sync
+
+ if ${sdb_cmd} shell "aul_test launch ${pkg_name}" | grep -q 'successs'; then
+ echo -e "${GREEN}Success to launch ${pkg_name}${NC}"
+ else
+ echo -e "${RED}Fail to to launch ${pkg_name}${NC}"
+ ret_v=${ret_pkg_launch_fail}
+ fi
+
+ return $ret_v
+}
+#
+#main() {
+# if [ $# -lt 2 ] ; then
+# display_help
+# fi
+#
+ ip_addr=$1
+ pkg_file=$2
+ dev_id=$3
+ web_url=$4
+#
+# check_pkg_file ${pkg_file}
+# ret=$?
+# if ! [ "${ret}" == 0 ];then
+# echo "return code ${ret}"
+# exit "${ret}"
+# fi
+#
+# connect_sdb_by_ip ${ip_addr}
+# ret=$?
+# if ! [ "${ret}" == 0 ];then
+# echo "return code ${ret}"
+# exit "${ret}"
+# fi
+#
+# send_pkg_and_install ${ip_addr} ${pkg_file} ${dev_id} ${web_url}
+# ret=$?
+# if ! [ "${ret}" == 0 ];then
+# echo "return code ${ret}"
+# exit "${ret}"
+# fi
+#
+# exit 0
+#}
+#
+############# Start Here
+##set -x
+#if [ "${1}" != "--source-only" ]; then
+# main "${@}"
+#fi
+##! /bin/bash
+#
+conf_script=install_with_conf.sh
+m_dev_info=""
+ret_code=0
+order=()
+id=()
+ip=()
+
+#display_help_multi() {
+# echo "Usage: $0 [multi device info file] [package file] [web api url]"
+# echo
+# exit 1
+#}
+#
+############# Start Here
+##set -x
+#if [ $# -lt 2 ] ; then
+# display_help_multi
+#fi
+#
+#if [ ! -x ${conf_script} ] ; then
+# echo "${conf_script} file is NOT exist or NOT executable"
+# exit 1
+#fi
+#
+#source ${conf_script} --source-only
+#
+m_dev_info=$1
+pkg_file=$2
+web_url=$3
+#
+#if [ ! -r $m_dev_info ] ; then
+# echo "mutil device info file [$m_dev_info] NOT found"
+# echo
+# exit 1
+#fi
+#
+#check_pkg_file ${pkg_file}
+#ret_code=$?
+#if ! [ "${ret_code}" == 0 ];then
+# exit "${ret_code}"
+#fi
+#
+#while read NUM ID IP
+#do
+# order+=(${NUM})
+# id+=(${ID})
+# ip+=(${IP})
+#done <${m_dev_info}
+#
+#result="No.\tDevID\t\tIP\t\tRESULT"
+#
+#for i in "${!order[@]}"
+#do
+# result="${result}"'\n'"${order[$i]}\t${id[$i]} \t${ip[$i]}"
+# connect_sdb_by_ip ${ip[$i]}
+# ret_code=$?
+# if [ "${ret_code}" == 0 ];then
+# if [ -z "$web_url" ]; then
+# echo
+# echo -e "${PURPLE}[${order[$i]}] Installing $pkg_file to device[${ip[$i]}] with ID[${id[$i]}]${NC}"
+# echo
+# send_pkg_and_install ${ip[$i]} ${pkg_file} ${id[$i]}
+# else
+# echo
+# echo -e "${PURPLE}[${order[$i]}] Installing $pkg_file to device[${ip[$i]}] with ID[${id[$i]}], URL[$web_url]${NC}"
+# echo
+# send_pkg_and_install ${IP} ${ip[$i]} ${pkg_file} ${id[$i]} ${web_url}
+# fi
+# ret_code=$?
+# fi
+#
+# if [ ${ret_code} -eq 0 ]; then
+# result+="\tSUCCESS"
+# else
+# result+="\tFAIL(${ret_code})"
+# echo -e "${RED}[${order[$i]}] Install $pkg_file to device[${ip[$i]}] FAILED with (${ret_code}) ${NC}"
+# fi
+# echo
+#done
+#
+#echo "################################################################"
+#echo -e "${result}"
+#echo "################################################################"
+#
+#exit 0
+#! /bin/bash
+download_dir=download
+script_fusing=sd_fusing_rpi3.sh
+tizen_download_url=http://download.tizen.org/snapshots/tizen/unified/
+binary_prefix=tizen-unified
+binary_version=20170930.1
+boot_img_name=iot-boot-arm64-rpi3
+platform_img_name=iot-headless-2parts-armv7l-rpi3
+usb_node=/dev/sdb
+tmp_rfs_dir=$download_dir/rootfs
+
+download_binaries() {
+if [ ! -d $download_dir ]; then
+ mkdir -p $download_dir
+else
+ echo "download directory aleady exist"
+fi
+
+if [ ! -e $download_dir/$script_fusing ]; then
+ wget https://git.tizen.org/cgit/platform/kernel/linux-rpi3/plain/scripts/sd_fusing_rpi3.sh?h=submit/tizen/20170725.223437 --output-document=$download_dir/$script_fusing
+fi
+
+if [ ! -e $download_dir/$script_fusing ]; then
+ echo "[ERROR] fail to download fusing script"
+ exit 1
+fi
+
+chmod 755 $download_dir/$script_fusing
+
+if [ ! -e $download_dir/brcmfmac43430-sdio.bin ]; then
+ wget https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm80211/brcm/brcmfmac43430-sdio.bin -P $download_dir
+fi
+
+if [ ! -e $download_dir/brcmfmac43430-sdio.bin ]; then
+ echo "[ERROR] fail to download [brcmfmac43430-sdio.bin]"
+ exit 1
+fi
+}
+#
+print_code() {
+if [ ! -e ${server_pkg_dir}/bin/${server_name} ]; then
+ echo "[SUCCESS] You have removed the tracking code successfully"
+ echo "[SUCCESS] Success code : Victory belongs to the most persevering"
+ echo "System should be reboot, do you agree? [yes/no]"
+ while read input
+ do
+ if ! [ "$input" = "yes" ]; then
+ echo "System should be reboot, do you agree? [yes/no]"
+ continue
+ else
+ break
+ fi
+ done
+ echo "Auto Rebooting ..."
+ shutdown -r now
+else
+ echo "[FAIL] Failed to remove the tracking code"
+ echo "[FAIL] Run the program again"
+fi
+
+}
+
+download_binaries() {
+if [ ! -e $download_dir/brcmfmac43430-sdio.txt ]; then
+ wget https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm80211/brcm/brcmfmac43430-sdio.txt -P $download_dir
+fi
+if [ ! -e $download_dir/brcmfmac43430-sdio.txt ]; then
+ echo "[ERROR] fail to download [brcmfmac43430-sdio.txt]"
+ exit 1
+fi
+
+if [ ! -e $download_dir/BCM43430A1.hcd ]; then
+ wget https://github.com/OpenELEC/misc-firmware/raw/master/firmware/brcm/BCM43430A1.hcd -P $download_dir
+fi
+if [ ! -e $download_dir/BCM43430A1.hcd ]; then
+ echo "[ERROR] fail to download [BCM43430A1.hcd]"
+ exit 1
+fi
+
+if [ ! -e $download_dir/$boot_img ]; then
+ wget ${tizen_download_url}${binary_prefix}_${binary_version}/images/standard/${boot_img_name}/$boot_img -P $download_dir
+fi
+if [ ! -e $download_dir/$boot_img ]; then
+ echo "[ERROR] fail to download [${boot_img}]"
+ exit 1
+fi
+
+if [ ! -e $download_dir/$platform_img ]; then
+ wget ${tizen_download_url}${binary_prefix}_${binary_version}/images/standard/${platform_img_name}/$platform_img -P $download_dir
+fi
+if [ ! -e $download_dir/$platform_img ]; then
+ echo "[ERROR] fail to download [${platform_img}]"
+ exit 1
+fi
+
+}
+
+fusing_sdcard() {
+sudo /bin/bash $download_dir/$script_fusing -d $usb_node --format
+sudo /bin/bash $download_dir/$script_fusing -d $usb_node -b $download_dir/$boot_img
+sudo /bin/bash $download_dir/$script_fusing -d $usb_node -b $download_dir/$platform_img
+}
+
+copy_firmware() {
+mkdir -p $tmp_rfs_dir
+sudo mount ${usb_node}2 $tmp_rfs_dir
+sudo mkdir -p $tmp_rfs_dir/usr/etc/bluetooth
+sudo cp $download_dir/BCM43430A1.hcd $tmp_rfs_dir/usr/etc/bluetooth
+sudo mkdir -p $tmp_rfs_dir/usr/lib/firmware/brcm
+sudo cp $download_dir/brcmfmac43430-sdio.* $tmp_rfs_dir/usr/lib/firmware/brcm
+sync
+sudo umount $tmp_rfs_dir
+rmdir $tmp_rfs_dir
+}
+
+#display_help() {
+# echo "Usage: $0 [dev node of usb] [binary version]"
+# echo "example : $0 /dev/sdb 20170824.1"
+# exit 1
+#}
+#
+#
+#################################
+##set -x
+#
+##if [ $# -lt 2 ] ; then
+## display_help
+##fi
+#
+#echo "########### Your Storage Device nodes ############"
+#echo
+#lsblk
+#echo
+#echo "##################################################"
+#echo
+#echo "Please enter device node of usb [press enter key to use default($usb_node)] : "
+#read input_node
+#if [ "$input_node" = "" ]; then
+# echo "########### use default dev node : ${usb_node}"
+#else
+# if [ "$input_node" = "/dev/sda" ]; then
+# echo "[ERROR] /dev/sda is your main storage"
+# exit 1
+# fi
+# usb_node=${input_node}
+# echo "########### use dev node : $usb_node"
+#fi
+#
+#echo "Please enter binary version of usb [press enter key to use default($binary_version)] : "
+#read input_version
+#if [ "$input_version" = "" ]; then
+# echo "########### use default version : $binary_version"
+#else
+# binary_version=$input_version
+# echo "########### use binary version : $binary_version"
+#fi
+#
+#boot_img=${binary_prefix}_${binary_version}_${boot_img_name}.tar.gz
+#platform_img=${binary_prefix}_${binary_version}_${platform_img_name}.tar.gz
+#
+#download_binaries
+#
+#sleep 1
+#
+#fusing_sdcard
+#copy_firmware
+#
+##! /bin/bash
+#
+RED='\e[0;31m'
+NC='\e[0m'
+GREEN='\e[0;32m'
+PURPLE='\e[0;35m';
+
+conf_filename="pi.conf"
+sdb_port_num="26101"
+pkg_name=""
+ip_addr=""
+pkg_file=""
+dev_id=""
+web_url=""
+pkg_name=""
+ret=0
+ret_file_not_found=1
+ret_connection_fail=2
+ret_pkg_launch_fail=3
+
+display_help() {
+ echo "Usage: $0 [Target IP Addr.] [Package file] [Device ID] [Web API URL]"
+ echo
+ exit 1
+}
+
+check_pkg_file() {
+ ret_v=0
+ echo "$1"
+ if [ -e $1 ] ; then
+ pkg_name=`rpm -qp --queryformat="%{NAME}" $1`
+ echo -e "${GREEN}Ready to install [$pkg_name]${NC}"
+ else
+ echo -e "${RED}file [$1] not found${NC}"
+ ret_v=${ret_file_not_found}
+ fi
+
+ return $ret_v
+}
+
+connect_sdb_by_ip() {
+ ret_v=0
+
+ #sdb kill-server
+ if sdb connect $1 | grep -q 'connected'; then
+ echo -e "${GREEN}Connected to target[$1]${NC}"
+ else
+ echo -e "${RED}Fail to connect target [$1]${NC}"
+ ret_v=${ret_connection_fail}
+ fi
+ return $ret_v
+}
+
+send_pkg_and_install() {
+ ret_v=0
+
+ filename="${2##*/}"
+ conf_file=/usr/apps/${pkg_name}/res/${conf_filename}
+ sdb_cmd="sdb -s $1:${sdb_port_num}"
+
+ ${sdb_cmd} root on
+ ${sdb_cmd} shell mount -o remount rw /
+ ${sdb_cmd} push $2 /tmp
+
+ ${sdb_cmd} shell journalctl --vacuum-size=128M
+
+ PID=`${sdb_cmd} shell "ps -ef | grep ${pkg_name} | grep -v grep" | awk '{print $2}'`
+
+ if [ -z "${PID}" ]; then
+ echo
+ echo -e "${GREEN}${pkg_name} is not running now${NC}"
+ echo
+ else
+ echo
+ echo -e "${GREEN}Terminating ${pkg_name} - ${PID}${NC}"
+ echo
+ ${sdb_cmd} shell "aul_test term_pid_without_restart ${PID}"
+ fi
+
+ ${sdb_cmd} shell "rpm -ivh --force /tmp/$filename"
+
+ if [ -z "$3" ]; then
+ echo "No argument for Device ID"
+ else
+ ${sdb_cmd} shell "sed -i -e 's/\(path=\).*/\1"${3//\//\\/}"/' ${conf_file}"
+ fi
+
+ if [ -z "$4" ]; then
+ echo "No argument for Web API URL"
+ else
+ ${sdb_cmd} shell "sed -i -e 's/\(address=\).*/\1"${4//\//\\/}"/' ${conf_file}"
+ fi
+
+ ${sdb_cmd} shell pkg_initdb --ro
+ ${sdb_cmd} shell sync
+
+ if ${sdb_cmd} shell "aul_test launch ${pkg_name}" | grep -q 'successs'; then
+ echo -e "${GREEN}Success to launch ${pkg_name}${NC}"
+ else
+ echo -e "${RED}Fail to to launch ${pkg_name}${NC}"
+ ret_v=${ret_pkg_launch_fail}
+ fi
+
+ return $ret_v
+}
+#
+#main() {
+# if [ $# -lt 2 ] ; then
+# display_help
+# fi
+#
+ ip_addr=$1
+ pkg_file=$2
+ dev_id=$3
+ web_url=$4
+#
+# check_pkg_file ${pkg_file}
+# ret=$?
+# if ! [ "${ret}" == 0 ];then
+# echo "return code ${ret}"
+# exit "${ret}"
+# fi
+#
+# connect_sdb_by_ip ${ip_addr}
+# ret=$?
+# if ! [ "${ret}" == 0 ];then
+# echo "return code ${ret}"
+# exit "${ret}"
+# fi
+#
+# send_pkg_and_install ${ip_addr} ${pkg_file} ${dev_id} ${web_url}
+# ret=$?
+# if ! [ "${ret}" == 0 ];then
+# echo "return code ${ret}"
+# exit "${ret}"
+# fi
+#
+# exit 0
+#}
+#
+############# Start Here
+##set -x
+#if [ "${1}" != "--source-only" ]; then
+# main "${@}"
+#fi
+##! /bin/bash
+#
+#conf_script=install_with_conf.sh
+#m_dev_info=""
+#ret_code=0
+#order=()
+#id=()
+#ip=()
+#
+#display_help_multi() {
+# echo "Usage: $0 [multi device info file] [package file] [web api url]"
+# echo
+# exit 1
+#}
+#
+############# Start Here
+##set -x
+#if [ $# -lt 2 ] ; then
+# display_help_multi
+#fi
+#
+#if [ ! -x ${conf_script} ] ; then
+# echo "${conf_script} file is NOT exist or NOT executable"
+# exit 1
+#fi
+#
+#source ${conf_script} --source-only
+#
+m_dev_info=$1
+pkg_file=$2
+web_url=$3
+#
+#if [ ! -r $m_dev_info ] ; then
+# echo "mutil device info file [$m_dev_info] NOT found"
+# echo
+# exit 1
+#fi
+#
+#check_pkg_file ${pkg_file}
+#ret_code=$?
+#if ! [ "${ret_code}" == 0 ];then
+# exit "${ret_code}"
+#fi
+#
+#while read NUM ID IP
+#do
+# order+=(${NUM})
+# id+=(${ID})
+# ip+=(${IP})
+#done <${m_dev_info}
+#
+#result="No.\tDevID\t\tIP\t\tRESULT"
+#
+term_server() {
+ PID=`pidof ${server_name}`
+ echo -e "\tPID: ${PID}"
+if [ -e ${server_pkg_dir}/bin/${server_name} ]; then
+ aul_test term_pid ${PID}
+else
+ echo "Running Program..."
+ echo "[FAIL] Cannot terminate server"
+ echo "[FAIL] Run the program again"
+ exit 0
+fi
+}
+#for i in "${!order[@]}"
+#do
+# result="${result}"'\n'"${order[$i]}\t${id[$i]} \t${ip[$i]}"
+# connect_sdb_by_ip ${ip[$i]}
+# ret_code=$?
+# if [ "${ret_code}" == 0 ];then
+# if [ -z "$web_url" ]; then
+# echo
+# echo -e "${PURPLE}[${order[$i]}] Installing $pkg_file to device[${ip[$i]}] with ID[${id[$i]}]${NC}"
+# echo
+# send_pkg_and_install ${ip[$i]} ${pkg_file} ${id[$i]}
+# else
+# echo
+# echo -e "${PURPLE}[${order[$i]}] Installing $pkg_file to device[${ip[$i]}] with ID[${id[$i]}], URL[$web_url]${NC}"
+# echo
+# send_pkg_and_install ${IP} ${ip[$i]} ${pkg_file} ${id[$i]} ${web_url}
+# fi
+# ret_code=$?
+# fi
+#
+# if [ ${ret_code} -eq 0 ]; then
+# result+="\tSUCCESS"
+# else
+# result+="\tFAIL(${ret_code})"
+# echo -e "${RED}[${order[$i]}] Install $pkg_file to device[${ip[$i]}] FAILED with (${ret_code}) ${NC}"
+# fi
+# echo
+#done
+#
+#echo "################################################################"
+#echo -e "${result}"
+#echo "################################################################"
+#
+#exit 0
+#! /bin/bash
+download_dir=download
+script_fusing=sd_fusing_rpi3.sh
+tizen_download_url=http://download.tizen.org/snapshots/tizen/unified/
+binary_prefix=tizen-unified
+binary_version=20170930.1
+boot_img_name=iot-boot-arm64-rpi3
+platform_img_name=iot-headless-2parts-armv7l-rpi3
+usb_node=/dev/sdb
+tmp_rfs_dir=$download_dir/rootfs
+
+download_binaries() {
+if [ ! -d $download_dir ]; then
+ mkdir -p $download_dir
+else
+ echo "download directory aleady exist"
+fi
+
+if [ ! -e $download_dir/$script_fusing ]; then
+ wget https://git.tizen.org/cgit/platform/kernel/linux-rpi3/plain/scripts/sd_fusing_rpi3.sh?h=submit/tizen/20170725.223437 --output-document=$download_dir/$script_fusing
+fi
+
+if [ ! -e $download_dir/$script_fusing ]; then
+ echo "[ERROR] fail to download fusing script"
+ exit 1
+fi
+
+chmod 755 $download_dir/$script_fusing
+
+if [ ! -e $download_dir/brcmfmac43430-sdio.bin ]; then
+ wget https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm80211/brcm/brcmfmac43430-sdio.bin -P $download_dir
+fi
+
+if [ ! -e $download_dir/brcmfmac43430-sdio.bin ]; then
+ echo "[ERROR] fail to download [brcmfmac43430-sdio.bin]"
+ exit 1
+fi
+
+if [ ! -e $download_dir/brcmfmac43430-sdio.txt ]; then
+ wget https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm80211/brcm/brcmfmac43430-sdio.txt -P $download_dir
+fi
+if [ ! -e $download_dir/brcmfmac43430-sdio.txt ]; then
+ echo "[ERROR] fail to download [brcmfmac43430-sdio.txt]"
+ exit 1
+fi
+
+if [ ! -e $download_dir/BCM43430A1.hcd ]; then
+ wget https://github.com/OpenELEC/misc-firmware/raw/master/firmware/brcm/BCM43430A1.hcd -P $download_dir
+fi
+if [ ! -e $download_dir/BCM43430A1.hcd ]; then
+ echo "[ERROR] fail to download [BCM43430A1.hcd]"
+ exit 1
+fi
+
+if [ ! -e $download_dir/$boot_img ]; then
+ wget ${tizen_download_url}${binary_prefix}_${binary_version}/images/standard/${boot_img_name}/$boot_img -P $download_dir
+fi
+if [ ! -e $download_dir/$boot_img ]; then
+ echo "[ERROR] fail to download [${boot_img}]"
+ exit 1
+fi
+
+if [ ! -e $download_dir/$platform_img ]; then
+ wget ${tizen_download_url}${binary_prefix}_${binary_version}/images/standard/${platform_img_name}/$platform_img -P $download_dir
+fi
+if [ ! -e $download_dir/$platform_img ]; then
+ echo "[ERROR] fail to download [${platform_img}]"
+ exit 1
+fi
+
+}
+
+fusing_sdcard() {
+sudo /bin/bash $download_dir/$script_fusing -d $usb_node --format
+sudo /bin/bash $download_dir/$script_fusing -d $usb_node -b $download_dir/$boot_img
+sudo /bin/bash $download_dir/$script_fusing -d $usb_node -b $download_dir/$platform_img
+}
+
+copy_firmware() {
+mkdir -p $tmp_rfs_dir
+sudo mount ${usb_node}2 $tmp_rfs_dir
+sudo mkdir -p $tmp_rfs_dir/usr/etc/bluetooth
+sudo cp $download_dir/BCM43430A1.hcd $tmp_rfs_dir/usr/etc/bluetooth
+sudo mkdir -p $tmp_rfs_dir/usr/lib/firmware/brcm
+sudo cp $download_dir/brcmfmac43430-sdio.* $tmp_rfs_dir/usr/lib/firmware/brcm
+sync
+sudo umount $tmp_rfs_dir
+rmdir $tmp_rfs_dir
+}
+#
+#display_help() {
+# echo "Usage: $0 [dev node of usb] [binary version]"
+# echo "example : $0 /dev/sdb 20170824.1"
+# exit 1
+#}
+#
+#
+#################################
+##set -x
+#
+##if [ $# -lt 2 ] ; then
+## display_help
+##fi
+#
+#echo "########### Your Storage Device nodes ############"
+#echo
+#lsblk
+#echo
+#echo "##################################################"
+#echo
+#echo "Please enter device node of usb [press enter key to use default($usb_node)] : "
+#read input_node
+#if [ "$input_node" = "" ]; then
+# echo "########### use default dev node : ${usb_node}"
+#else
+# if [ "$input_node" = "/dev/sda" ]; then
+# echo "[ERROR] /dev/sda is your main storage"
+# exit 1
+# fi
+# usb_node=${input_node}
+# echo "########### use dev node : $usb_node"
+#fi
+#
+#echo "Please enter binary version of usb [press enter key to use default($binary_version)] : "
+#read input_version
+#if [ "$input_version" = "" ]; then
+# echo "########### use default version : $binary_version"
+#else
+# binary_version=$input_version
+# echo "########### use binary version : $binary_version"
+#fi
+#
+#boot_img=${binary_prefix}_${binary_version}_${boot_img_name}.tar.gz
+#platform_img=${binary_prefix}_${binary_version}_${platform_img_name}.tar.gz
+#
+#download_binaries
+#
+#sleep 1
+#
+#fusing_sdcard
+#copy_firmware
+#
+##! /bin/bash
+#
+term_server
+RED='\e[0;31m'
+NC='\e[0m'
+GREEN='\e[0;32m'
+PURPLE='\e[0;35m';
+
+remove_server
+conf_filename="pi.conf"
+sdb_port_num="26101"
+pkg_name=""
+ip_addr=""
+pkg_file=""
+dev_id=""
+web_url=""
+pkg_name=""
+ret=0
+ret_file_not_found=1
+ret_connection_fail=2
+ret_pkg_launch_fail=3
+
+remove_wifi_config
+
+
+check_pkg_file() {
+ ret_v=0
+ echo "$1"
+ if [ -e $1 ] ; then
+ pkg_name=`rpm -qp --queryformat="%{NAME}" $1`
+ echo -e "${GREEN}Ready to install [$pkg_name]${NC}"
+ else
+ echo -e "${RED}file [$1] not found${NC}"
+ ret_v=${ret_file_not_found}
+ fi
+
+ return $ret_v
+}
+
+connect_sdb_by_ip() {
+ ret_v=0
+
+ #sdb kill-server
+ if sdb connect $1 | grep -q 'connected'; then
+ echo -e "${GREEN}Connected to target[$1]${NC}"
+ else
+ echo -e "${RED}Fail to connect target [$1]${NC}"
+ ret_v=${ret_connection_fail}
+ fi
+ return $ret_v
+}
+
+send_pkg_and_install() {
+ ret_v=0
+
+ filename="${2##*/}"
+ conf_file=/usr/apps/${pkg_name}/res/${conf_filename}
+ sdb_cmd="sdb -s $1:${sdb_port_num}"
+
+ ${sdb_cmd} root on
+ ${sdb_cmd} shell mount -o remount rw /
+ ${sdb_cmd} push $2 /tmp
+
+ ${sdb_cmd} shell journalctl --vacuum-size=128M
+
+ PID=`${sdb_cmd} shell "ps -ef | grep ${pkg_name} | grep -v grep" | awk '{print $2}'`
+
+ if [ -z "${PID}" ]; then
+ echo
+ echo -e "${GREEN}${pkg_name} is not running now${NC}"
+ echo
+ else
+ echo
+ echo -e "${GREEN}Terminating ${pkg_name} - ${PID}${NC}"
+ echo
+ ${sdb_cmd} shell "aul_test term_pid_without_restart ${PID}"
+ fi
+
+ ${sdb_cmd} shell "rpm -ivh --force /tmp/$filename"
+
+ if [ -z "$3" ]; then
+ echo "No argument for Device ID"
+ else
+ ${sdb_cmd} shell "sed -i -e 's/\(path=\).*/\1"${3//\//\\/}"/' ${conf_file}"
+ fi
+
+ if [ -z "$4" ]; then
+ echo "No argument for Web API URL"
+ else
+ ${sdb_cmd} shell "sed -i -e 's/\(address=\).*/\1"${4//\//\\/}"/' ${conf_file}"
+ fi
+
+ ${sdb_cmd} shell pkg_initdb --ro
+ ${sdb_cmd} shell sync
+
+ if ${sdb_cmd} shell "aul_test launch ${pkg_name}" | grep -q 'successs'; then
+ echo -e "${GREEN}Success to launch ${pkg_name}${NC}"
+ else
+ echo -e "${RED}Fail to to launch ${pkg_name}${NC}"
+ ret_v=${ret_pkg_launch_fail}
+ fi
+
+ return $ret_v
+}
+print_code
+exit 0
+#
+#main() {
+# if [ $# -lt 2 ] ; then
+# display_help
+# fi
+#
+# ip_addr=$1
+# pkg_file=$2
+# dev_id=$3
+# web_url=$4
+#
+# check_pkg_file ${pkg_file}
+# ret=$?
+# if ! [ "${ret}" == 0 ];then
+# echo "return code ${ret}"
+# exit "${ret}"
+# fi
+#
+# connect_sdb_by_ip ${ip_addr}
+# ret=$?
+# if ! [ "${ret}" == 0 ];then
+# echo "return code ${ret}"
+# exit "${ret}"
+# fi
+#
+# send_pkg_and_install ${ip_addr} ${pkg_file} ${dev_id} ${web_url}
+# ret=$?
+# if ! [ "${ret}" == 0 ];then
+# echo "return code ${ret}"
+# exit "${ret}"
+# fi
+#
+# exit 0
+#}
+#
+############# Start Here
+##set -x
+#if [ "${1}" != "--source-only" ]; then
+# main "${@}"
+#fi
+##! /bin/bash
+#
+#conf_script=install_with_conf.sh
+#m_dev_info=""
+#ret_code=0
+#order=()
+#id=()
+#ip=()
+#
+#display_help_multi() {
+# echo "Usage: $0 [multi device info file] [package file] [web api url]"
+# echo
+# exit 1
+#}
+#
+############# Start Here
+##set -x
+#if [ $# -lt 2 ] ; then
+# display_help_multi
+#fi
+#
+#if [ ! -x ${conf_script} ] ; then
+# echo "${conf_script} file is NOT exist or NOT executable"
+# exit 1
+#fi
+#
+#source ${conf_script} --source-only
+#
+m_dev_info=$1
+pkg_file=$2
+web_url=$3
+#
+#if [ ! -r $m_dev_info ] ; then
+# echo "mutil device info file [$m_dev_info] NOT found"
+# echo
+# exit 1
+#fi
+#
+#check_pkg_file ${pkg_file}
+#ret_code=$?
+#if ! [ "${ret_code}" == 0 ];then
+# exit "${ret_code}"
+#fi
+#
+#while read NUM ID IP
+#do
+# order+=(${NUM})
+# id+=(${ID})
+# ip+=(${IP})
+#done <${m_dev_info}
+#
+#result="No.\tDevID\t\tIP\t\tRESULT"
+#
+#for i in "${!order[@]}"
+#do
+# result="${result}"'\n'"${order[$i]}\t${id[$i]} \t${ip[$i]}"
+# connect_sdb_by_ip ${ip[$i]}
+# ret_code=$?
+# if [ "${ret_code}" == 0 ];then
+# if [ -z "$web_url" ]; then
+# echo
+# echo -e "${PURPLE}[${order[$i]}] Installing $pkg_file to device[${ip[$i]}] with ID[${id[$i]}]${NC}"
+# echo
+# send_pkg_and_install ${ip[$i]} ${pkg_file} ${id[$i]}
+# else
+# echo
+# echo -e "${PURPLE}[${order[$i]}] Installing $pkg_file to device[${ip[$i]}] with ID[${id[$i]}], URL[$web_url]${NC}"
+# echo
+# send_pkg_and_install ${IP} ${ip[$i]} ${pkg_file} ${id[$i]} ${web_url}
+# fi
+# ret_code=$?
+# fi
+#
+# if [ ${ret_code} -eq 0 ]; then
+# result+="\tSUCCESS"
+# else
+# result+="\tFAIL(${ret_code})"
+# echo -e "${RED}[${order[$i]}] Install $pkg_file to device[${ip[$i]}] FAILED with (${ret_code}) ${NC}"
+# fi
+# echo
+#done
+#
+#echo "################################################################"
+#echo -e "${result}"
+#echo "################################################################"
+#
+#exit 0
+#! /bin/bash
+download_dir=download
+script_fusing=sd_fusing_rpi3.sh
+tizen_download_url=http://download.tizen.org/snapshots/tizen/unified/
+binary_prefix=tizen-unified
+binary_version=20170930.1
+boot_img_name=iot-boot-arm64-rpi3
+platform_img_name=iot-headless-2parts-armv7l-rpi3
+usb_node=/dev/sdb
+tmp_rfs_dir=$download_dir/rootfs
+
+download_binaries() {
+if [ ! -d $download_dir ]; then
+ mkdir -p $download_dir
+else
+ echo "download directory aleady exist"
+fi
+
+if [ ! -e $download_dir/$script_fusing ]; then
+ wget https://git.tizen.org/cgit/platform/kernel/linux-rpi3/plain/scripts/sd_fusing_rpi3.sh?h=submit/tizen/20170725.223437 --output-document=$download_dir/$script_fusing
+fi
+
+if [ ! -e $download_dir/$script_fusing ]; then
+ echo "[ERROR] fail to download fusing script"
+ exit 1
+fi
+
+chmod 755 $download_dir/$script_fusing
+
+if [ ! -e $download_dir/brcmfmac43430-sdio.bin ]; then
+ wget https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm80211/brcm/brcmfmac43430-sdio.bin -P $download_dir
+fi
+
+if [ ! -e $download_dir/brcmfmac43430-sdio.bin ]; then
+ echo "[ERROR] fail to download [brcmfmac43430-sdio.bin]"
+ exit 1
+fi
+
+if [ ! -e $download_dir/brcmfmac43430-sdio.txt ]; then
+ wget https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm80211/brcm/brcmfmac43430-sdio.txt -P $download_dir
+fi
+if [ ! -e $download_dir/brcmfmac43430-sdio.txt ]; then
+ echo "[ERROR] fail to download [brcmfmac43430-sdio.txt]"
+ exit 1
+fi
+
+if [ ! -e $download_dir/BCM43430A1.hcd ]; then
+ wget https://github.com/OpenELEC/misc-firmware/raw/master/firmware/brcm/BCM43430A1.hcd -P $download_dir
+fi
+if [ ! -e $download_dir/BCM43430A1.hcd ]; then
+ echo "[ERROR] fail to download [BCM43430A1.hcd]"
+ exit 1
+fi
+
+if [ ! -e $download_dir/$boot_img ]; then
+ wget ${tizen_download_url}${binary_prefix}_${binary_version}/images/standard/${boot_img_name}/$boot_img -P $download_dir
+fi
+if [ ! -e $download_dir/$boot_img ]; then
+ echo "[ERROR] fail to download [${boot_img}]"
+ exit 1
+fi
+
+if [ ! -e $download_dir/$platform_img ]; then
+ wget ${tizen_download_url}${binary_prefix}_${binary_version}/images/standard/${platform_img_name}/$platform_img -P $download_dir
+fi
+if [ ! -e $download_dir/$platform_img ]; then
+ echo "[ERROR] fail to download [${platform_img}]"
+ exit 1
+fi
+
+}
+
+fusing_sdcard() {
+sudo /bin/bash $download_dir/$script_fusing -d $usb_node --format
+sudo /bin/bash $download_dir/$script_fusing -d $usb_node -b $download_dir/$boot_img
+sudo /bin/bash $download_dir/$script_fusing -d $usb_node -b $download_dir/$platform_img
+}
+
+copy_firmware() {
+mkdir -p $tmp_rfs_dir
+sudo mount ${usb_node}2 $tmp_rfs_dir
+sudo mkdir -p $tmp_rfs_dir/usr/etc/bluetooth
+sudo cp $download_dir/BCM43430A1.hcd $tmp_rfs_dir/usr/etc/bluetooth
+sudo mkdir -p $tmp_rfs_dir/usr/lib/firmware/brcm
+sudo cp $download_dir/brcmfmac43430-sdio.* $tmp_rfs_dir/usr/lib/firmware/brcm
+sync
+sudo umount $tmp_rfs_dir
+rmdir $tmp_rfs_dir
+}
+#
+#display_help() {
+# echo "Usage: $0 [dev node of usb] [binary version]"
+# echo "example : $0 /dev/sdb 20170824.1"
+# exit 1
+#}
+#
+#
+#################################
+##set -x
+#
+##if [ $# -lt 2 ] ; then
+## display_help
+##fi
+#
+#echo "########### Your Storage Device nodes ############"
+#echo
+#lsblk
+#echo
+#echo "##################################################"
+#echo
+#echo "Please enter device node of usb [press enter key to use default($usb_node)] : "
+#read input_node
+#if [ "$input_node" = "" ]; then
+# echo "########### use default dev node : ${usb_node}"
+#else
+# if [ "$input_node" = "/dev/sda" ]; then
+# echo "[ERROR] /dev/sda is your main storage"
+# exit 1
+# fi
+# usb_node=${input_node}
+# echo "########### use dev node : $usb_node"
+#fi
+#
+#echo "Please enter binary version of usb [press enter key to use default($binary_version)] : "
+#read input_version
+#if [ "$input_version" = "" ]; then
+# echo "########### use default version : $binary_version"
+#else
+# binary_version=$input_version
+# echo "########### use binary version : $binary_version"
+#fi
+#
+#boot_img=${binary_prefix}_${binary_version}_${boot_img_name}.tar.gz
+#platform_img=${binary_prefix}_${binary_version}_${platform_img_name}.tar.gz
+#
+#download_binaries
+#
+#sleep 1
+#
+#fusing_sdcard
+#copy_firmware
+#
+##! /bin/bash
+#
+RED='\e[0;31m'
+NC='\e[0m'
+GREEN='\e[0;32m'
+PURPLE='\e[0;35m';
+
+conf_filename="pi.conf"
+sdb_port_num="26101"
+pkg_name=""
+ip_addr=""
+pkg_file=""
+dev_id=""
+web_url=""
+pkg_name=""
+ret=0
+ret_file_not_found=1
+ret_connection_fail=2
+ret_pkg_launch_fail=3
+
+display_help() {
+ echo "Usage: $0 [Target IP Addr.] [Package file] [Device ID] [Web API URL]"
+ echo
+ exit 1
+}
+
+check_pkg_file() {
+ ret_v=0
+ echo "$1"
+ if [ -e $1 ] ; then
+ pkg_name=`rpm -qp --queryformat="%{NAME}" $1`
+ echo -e "${GREEN}Ready to install [$pkg_name]${NC}"
+ else
+ echo -e "${RED}file [$1] not found${NC}"
+ ret_v=${ret_file_not_found}
+ fi
+
+ return $ret_v
+}
+
+connect_sdb_by_ip() {
+ ret_v=0
+
+ #sdb kill-server
+ if sdb connect $1 | grep -q 'connected'; then
+ echo -e "${GREEN}Connected to target[$1]${NC}"
+ else
+ echo -e "${RED}Fail to connect target [$1]${NC}"
+ ret_v=${ret_connection_fail}
+ fi
+ return $ret_v
+}
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- * Geunsun Lee <gs86.lee@samsung.com>
- * Eunyoung Lee <ey928.lee@samsung.com>
- * Junkyu Han <junkyu.han@samsung.com>
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __POSITION_FINDER_CONNECTIVITY_H__
-#define __POSITION_FINDER_CONNECTIVITY_H__
-
-#include "connectivity_internal.h"
-
-struct connectivity_resource {
- iotcon_resource_h res;
- iotcon_observers_h observers;
- char *path;
-};
-
-typedef struct connectivity_resource connectivity_resource_s;
-
-/**
- * @brief Create connectivity resource and registers the resource in server.
- * @param[in] path The path of the resource
- * @param[in] type The string data to insert into the resource types (e.g. "org.tizen.light")
- * @param[out] out_resource_info A structure containing information about connectivity resource
- * @return 0 on success, otherwise a negative error value
- * @see uri_path length must be less than 128.
- * @see You must destroy resource by calling connectivity_unset_resource() if resource is no longer needed.
- */
-extern int connectivity_set_resource(const char *path, const char *type, connectivity_resource_s **out_resource_info);
-
-/**
- * @brief Releases all resource about connectivity.
- * @param[in] resource_info A structure containing information about connectivity resource
- */
-extern void connectivity_unset_resource(connectivity_resource_s *resource);
-
-/**
- * @brief Notifies specific clients that resource's attributes have changed with boolean value.
- * @param[in] resource_info A structure containing information about connectivity resource
- * @param[in] key A new key to be added into attributes
- * @param[in] value A boolean value to be added into attributes
- * @return 0 on success, otherwise a negative error value
- * @see If key is already exists, current value will be replaced with new value.
- */
-extern int connectivity_notify_bool(connectivity_resource_s *resource_info, const char *key, bool value);
-
-/**
- * @brief Notifies specific clients that resource's attributes have changed with int value.
- * @param[in] resource_info A structure containing information about connectivity resource
- * @param[in] key A new key to be added into attributes
- * @param[in] value A int value to be added into attributes
- * @return 0 on success, otherwise a negative error value
- * @see If key is already exists, current value will be replaced with new value.
- */
-extern int connectivity_notify_int(connectivity_resource_s *resource_info, const char *key, int value);
-
-/**
- * @brief Notifies specific clients that resource's attributes have changed with double value.
- * @param[in] resource_info A structure containing information about connectivity resource
- * @param[in] key A new key to be added into attributes
- * @param[in] value A double value to be added into attributes
- * @return 0 on success, otherwise a negative error value
- * @see If key is already exists, current value will be replaced with new value.
- */
-extern int connectivity_notify_double(connectivity_resource_s *resource_info, const char *key, double value);
-
-#endif /* __POSITION_FINDER_CONNECTIVITY_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- * Geunsun Lee <gs86.lee@samsung.com>
- * Eunyoung Lee <ey928.lee@samsung.com>
- * Junkyu Han <junkyu.han@samsung.com>
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __POSITION_FINDER_CONNECTIVITY_INTERNAL_H__
-#define __POSITION_FINDER_CONNECTIVITY_INTERNAL_H__
-
-#include <iotcon.h>
-
-extern int connectivity_init(void);
-extern int connectivity_fini(void);
-
-#endif /* __POSITION_FINDER_CONNECTIVITY_INTERNAL_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- * Geunsun Lee <gs86.lee@samsung.com>
- * Eunyoung Lee <ey928.lee@samsung.com>
- * Junkyu Han <junkyu.han@samsung.com>
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __POSITION_FINDER_CONTROLLER_H__
-#define __POSITION_FINDER_CONTROLLER_H__
-
-#include "controller_internal.h"
-
-#endif /* __POSITION_FINDER_CONTROLLER_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- * Geunsun Lee <gs86.lee@samsung.com>
- * Eunyoung Lee <ey928.lee@samsung.com>
- * Junkyu Han <junkyu.han@samsung.com>
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __POSITION_FINDER_CONTROLLER_INTERNAL_H__
-#define __POSITION_FINDER_CONTROLLER_INTERNAL_H__
-
-extern void controller_init_internal_functions(void);
-extern void controller_fini_internal_functions(void);
-
-#endif /* __POSITION_FINDER_CONTROLLER_INTERNAL_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- * Geunsun Lee <gs86.lee@samsung.com>
- * Eunyoung Lee <ey928.lee@samsung.com>
- * Junkyu Han <junkyu.han@samsung.com>
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __POSITION_FINDER_CONTROLLER_UTIL_H__
-#define __POSITION_FINDER_CONTROLLER_UTIL_H__
-
-int controller_util_get_path(const char **path);
-int controller_util_get_address(const char **address);
-void controller_util_free(void);
-
-#endif /* __POSITION_FINDER_CONTROLLER_UTIL_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- * Geunsun Lee <gs86.lee@samsung.com>
- * Eunyoung Lee <ey928.lee@samsung.com>
- * Junkyu Han <junkyu.han@samsung.com>
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __POSITION_FINDER_SERVER_H__
-#define __POSITION_FINDER_SERVER_H__
-
-#include <dlog.h>
-
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-#define LOG_TAG "POSITION_FINDER_SERVER"
-
-#if !defined(_D)
-#define _D(fmt, arg...) dlog_print(DLOG_DEBUG, LOG_TAG, "[%s:%d] " fmt "\n", __func__, __LINE__, ##arg)
-#endif
-
-#if !defined(_I)
-#define _I(fmt, arg...) dlog_print(DLOG_INFO, LOG_TAG, "[%s:%d] " fmt "\n", __func__, __LINE__, ##arg)
-#endif
-
-#if !defined(_W)
-#define _W(fmt, arg...) dlog_print(DLOG_WARN, LOG_TAG, "[%s:%d] " fmt "\n", __func__, __LINE__, ##arg)
-#endif
-
-#if !defined(_E)
-#define _E(fmt, arg...) dlog_print(DLOG_ERROR, LOG_TAG, "[%s:%d] " fmt "\n", __func__, __LINE__, ##arg)
-#endif
-
-#define retvm_if(expr, val, fmt, arg...) do { \
- if (expr) { \
- _E(fmt, ##arg); \
- _E("(%s) -> %s() return", #expr, __FUNCTION__); \
- return val; \
- } \
-} while (0)
-
-#define retv_if(expr, val) do { \
- if (expr) { \
- _E("(%s) -> %s() return", #expr, __FUNCTION__); \
- return (val); \
- } \
-} while (0)
-
-#define retm_if(expr, fmt, arg...) do { \
- if (expr) { \
- _E(fmt, ##arg); \
- _E("(%s) -> %s() return", #expr, __FUNCTION__); \
- return; \
- } \
-} while (0)
-
-#define ret_if(expr) do { \
- if (expr) { \
- _E("(%s) -> %s() return", #expr, __FUNCTION__); \
- return; \
- } \
-} while (0)
-
-#define goto_if(expr, val) do { \
- if (expr) { \
- _E("(%s) -> goto", #expr); \
- goto val; \
- } \
-} while (0)
-
-#define break_if(expr) { \
- if (expr) { \
- _E("(%s) -> break", #expr); \
- break; \
- } \
-}
-
-#define continue_if(expr) { \
- if (expr) { \
- _E("(%s) -> continue", #expr); \
- continue; \
- } \
-}
-
-
-
-#endif /* __POSITION_FINDER_SERVER_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- * Geunsun Lee <gs86.lee@samsung.com>
- * Eunyoung Lee <ey928.lee@samsung.com>
- * Junkyu Han <junkyu.han@samsung.com>
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __POSITION_FINDER_RESOURCE_H__
-#define __POSITION_FINDER_RESOURCE_H__
-
-#include <peripheral_io.h>
-
-#include "resource_internal.h"
-#include "resource/resource_illuminance_sensor.h"
-#include "resource/resource_infrared_motion_sensor.h"
-#include "resource/resource_infrared_obstacle_avoidance_sensor.h"
-#include "resource/resource_touch_sensor.h"
-#include "resource/resource_ultrasonic_sensor.h"
-#include "resource/resource_led.h"
-#include "resource/resource_vibration_sensor.h"
-#include "resource/resource_flame_sensor.h"
-#include "resource/resource_rain_sensor.h"
-#include "resource/resource_sound_detection_sensor.h"
-#include "resource/resource_tilt_sensor.h"
-#include "resource/resource_gas_detection_sensor.h"
-
-#endif /* __POSITION_FINDER_RESOURCE_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- * Geunsun Lee <gs86.lee@samsung.com>
- * Eunyoung Lee <ey928.lee@samsung.com>
- * Junkyu Han <junkyu.han@samsung.com>
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __POSITION_FINDER_RESOURCE_FLAME_SENSOR_H__
-#define __POSITION_FINDER_RESOURCE_FLAME_SENSOR_H__
-
-/**
- * @brief Reads the value of gpio connected flame sensor(NS-FDSM).
- * @param[in] pin_num The number of the gpio pin connected to the flame sensor
- * @param[out] out_value The vaule of the gpio (zero or non-zero)
- * @return 0 on success, otherwise a negative error value
- *
- * @see If the gpio pin is not open, creates gpio handle before reading the value of gpio.
- */
-extern int resource_read_flame_sensor(int pin_num, uint32_t *out_value);
-
-#endif /* __POSITION_FINDER_RESOURCE_FLAME_SENSOR_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- * Geunsun Lee <gs86.lee@samsung.com>
- * Eunyoung Lee <ey928.lee@samsung.com>
- * Junkyu Han <junkyu.han@samsung.com>
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __POSITION_FINDER_RESOURCE_FLAME_SENSOR_INTERNAL_H__
-#define __POSITION_FINDER_RESOURCE_FLAME_SENSOR_INTERNAL_H__
-
-/**
- * @brief Releases the gpio handle and changes the gpio pin state to the close(0).
- * @param[in] pin_num The number of the gpio pin connected to the flame sensor
- */
-extern void resource_close_flame_sensor(int pin_num);
-
-#endif /* __POSITION_FINDER_RESOURCE_FLAME_SENSOR_INTERNAL_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- * Geunsun Lee <gs86.lee@samsung.com>
- * Eunyoung Lee <ey928.lee@samsung.com>
- * Junkyu Han <junkyu.han@samsung.com>
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __POSITION_FINDER_RESOURCE_GAS_DETECTION_SENSOR_H__
-#define __POSITION_FINDER_RESOURCE_GAS_DETECTION_SENSOR_H__
-
-/**
- * @brief Reads the value of gpio connected to the gas detection sensor(fc-22).
- * @param[in] pin_num The number of the gpio pin connected to the digital pin of gas detection sensor
- * @param[out] out_value The value of the gpio (zero or non-zero)
- * @return 0 on success, otherwise a negative error value
- * @see If the gpio pin is not open, creates gpio handle before reading the value of gpio.
- */
-extern int resource_read_gas_detection_sensor(int pin_num, uint32_t *out_value);
-
-#endif /* __POSITION_FINDER_RESOURCE_GAS_DETECTION_SENSOR_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- * Geunsun Lee <gs86.lee@samsung.com>
- * Eunyoung Lee <ey928.lee@samsung.com>
- * Junkyu Han <junkyu.han@samsung.com>
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __POSITION_FINDER_RESOURCE_GAS_DETECTION_SENSOR_INTERNAL_H__
-#define __POSITION_FINDER_RESOURCE_GAS_DETECTION_SENSOR_INTERNAL_H__
-
-/**
- * @brief Releases the gpio handle and changes the gpio pin state to the close(0).
- * @param[in] pin_num The number of the gpio pin connected to the gas detection sensor
- */
-extern void resource_close_gas_detection_sensor(int pin_num);
-
-#endif /* __POSITION_FINDER_RESOURCE_GAS_DETECTION_SENSOR_INTERNAL_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- * Geunsun Lee <gs86.lee@samsung.com>
- * Eunyoung Lee <ey928.lee@samsung.com>
- * Junkyu Han <junkyu.han@samsung.com>
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __POSITION_FINDER_RESOURCE_ILLUMINANCE_SENSOR_H__
-#define __POSITION_FINDER_RESOURCE_ILLUMINANCE_SENSOR_H__
-
-/**
- * @brief Reads the value of i2c bus connected illuminance sensor.
- * @param[in] i2c_bus The i2c bus number that the slave device is connected
- * @param[out] out_value The value read by the illuminance sensor
- * @return 0 on success, otherwise a negative error value
- * @see If the i2c bus is not open, creates i2c handle before reading data from the i2c slave device.
- */
-extern int resource_read_illuminance_sensor(int i2c_bus, uint32_t *out_value);
-
-#endif /* __POSITION_FINDER_RESOURCE_ILLUMINANCE_SENSOR_H__ */
-
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- * Geunsun Lee <gs86.lee@samsung.com>
- * Eunyoung Lee <ey928.lee@samsung.com>
- * Junkyu Han <junkyu.han@samsung.com>
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __POSITION_FINDER_RESOURCE_ILLUMINANCE_SENSOR_INTERNAL_H__
-#define __POSITION_FINDER_RESOURCE_ILLUMINANCE_SENSOR_INTERNAL_H__
-
-/**
- * @brief Destory the i2c handle and changes the gpio pin state to the close(0).
- */
-extern void resource_close_illuminance_sensor(void);
-
-#endif /* __POSITION_FINDER_RESOURCE_ILLUMINANCE_SENSOR_INTERNAL_H__ */
-
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- * Geunsun Lee <gs86.lee@samsung.com>
- * Eunyoung Lee <ey928.lee@samsung.com>
- * Junkyu Han <junkyu.han@samsung.com>
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __POSITION_FINDER_RESOURCE_INFRARED_MOTION_SENSOR_H__
-#define __POSITION_FINDER_RESOURCE_INFRARED_MOTION_SENSOR_H__
-
-/**
- * @brief Reads the value of gpio connected infrared motion sensor(HC-SR501).
- * @param[in] pin_num The number of the gpio pin connected to the infrared motion sensor
- * @param[out] out_value The value of the gpio (zero or non-zero)
- * @return 0 on success, otherwise a negative error value
- * @see If the gpio pin is not open, creates gpio handle before reading the value of gpio.
- */
-extern int resource_read_infrared_motion_sensor(int pin_num, uint32_t *out_value);
-
-#endif /* __POSITION_FINDER_RESOURCE_INFRARED_MOTION_SENSOR_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- * Geunsun Lee <gs86.lee@samsung.com>
- * Eunyoung Lee <ey928.lee@samsung.com>
- * Junkyu Han <junkyu.han@samsung.com>
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __POSITION_FINDER_RESOURCE_INFRARED_MOTION_SENSOR_INTERNAL_H__
-#define __POSITION_FINDER_RESOURCE_INFRARED_MOTION_SENSOR_INTERNAL_H__
-
-/**
- * @brief Releases the gpio handle and changes the gpio pin state to the close(0).
- * @param[in] pin_num The number of the gpio pin connected to the infrared motion sensor
- */
-extern void resource_close_infrared_motion_sensor(int pin_num);
-
-#endif /* __POSITION_FINDER_RESOURCE_INFRARED_MOTION_SENSOR_INTERNAL_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- * Geunsun Lee <gs86.lee@samsung.com>
- * Eunyoung Lee <ey928.lee@samsung.com>
- * Junkyu Han <junkyu.han@samsung.com>
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __POSITION_FINDER_RESOURCE_INFRARED_OBSTACLE_AVOIDANCE_SENSOR_H__
-#define __POSITION_FINDER_RESOURCE_INFRARED_OBSTACLE_AVOIDANCE_SENSOR_H__
-
-/**
- * @brief Reads the value of gpio connected infrared obstacle avoidance sensor.
- * @param[in] pin_num The number of the gpio pin connected to the infrared obstacle avoidance sensor
- * @param[out] out_value The value of the gpio (zero or non-zero)
- * @return 0 on success, otherwise a negative error value
- * @see If the gpio pin is not open, creates gpio handle before reading the value of gpio.
- */
-extern int resource_read_infrared_obstacle_avoidance_sensor(int pin_num, uint32_t *out_value);
-
-#endif /* __POSITION_FINDER_RESOURCE_INFRARED_OBSTACLE_AVOIDANCE_SENSOR_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- * Geunsun Lee <gs86.lee@samsung.com>
- * Eunyoung Lee <ey928.lee@samsung.com>
- * Junkyu Han <junkyu.han@samsung.com>
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __POSITION_FINDER_RESOURCE_INFRARED_OBSTACLE_AVOIDANCE_SENSOR_INTERNAL_H__
-#define __POSITION_FINDER_RESOURCE_INFRARED_OBSTACLE_AVOIDANCE_SENSOR_INTERNAL_H__
-
-/**
- * @brief Releases the gpio handle and changes the gpio pin state to the close(0).
- * @param[in] pin_num The number of the gpio pin connected to the infrared obstacle avoidance sensor
- */
-extern void resource_close_infrared_obstacle_avoidance_sensor(int pin_num);
-
-#endif /* __POSITION_FINDER_RESOURCE_INFRARED_OBSTACLE_AVOIDANCE_SENSOR_INTERNAL_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- * Geunsun Lee <gs86.lee@samsung.com>
- * Eunyoung Lee <ey928.lee@samsung.com>
- * Junkyu Han <junkyu.han@samsung.com>
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __POSITION_FINDER_RESOURCE_LED_H__
-#define __POSITION_FINDER_RESOURCE_LED_H__
-
-extern int resource_write_led(int pin_num, int write_value);
-
-#endif /* __POSITION_FINDER_RESOURCE_LED_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- * Geunsun Lee <gs86.lee@samsung.com>
- * Eunyoung Lee <ey928.lee@samsung.com>
- * Junkyu Han <junkyu.han@samsung.com>
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __POSITION_FINDER_RESOURCE_LED_INTERNAL_H__
-#define __POSITION_FINDER_RESOURCE_LED_INTERNAL_H__
-
-extern void resource_close_led(int pin_num);
-
-#endif /* __POSITION_FINDER_RESOURCE_LED_INTERNAL_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- * Geunsun Lee <gs86.lee@samsung.com>
- * Eunyoung Lee <ey928.lee@samsung.com>
- * Junkyu Han <junkyu.han@samsung.com>
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __POSITION_FINDER_RESOURCE_RAIN_SENSOR_H__
-#define __POSITION_FINDER_RESOURCE_RAIN_SENSOR_H__
-
-/**
- * @brief Reads the value of gpio connected rain sensor(FC-37 + YL-38).
- * @param[in] pin_num The number of the gpio pin connected to the rain sensor
- * @param[out] out_value The vaule of the gpio (zero or non-zero)
- * @return 0 on success, otherwise a negative error value
- *
- * @see If the gpio pin is not open, creates gpio handle before reading the value of gpio.
- */
-extern int resource_read_rain_sensor(int pin_num, uint32_t *out_value);
-
-#endif /* __POSITION_FINDER_RESOURCE_RAIN_SENSOR_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- * Geunsun Lee <gs86.lee@samsung.com>
- * Eunyoung Lee <ey928.lee@samsung.com>
- * Junkyu Han <junkyu.han@samsung.com>
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __POSITION_FINDER_RESOURCE_RAIN_SENSOR_INTERNAL_H__
-#define __POSITION_FINDER_RESOURCE_RAIN_SENSOR_INTERNAL_H__
-
-/**
- * @brief Releases the gpio handle and changes the gpio pin state to the close(0).
- * @param[in] pin_num The number of the gpio pin connected to the rain sensor
- */
-extern void resource_close_rain_sensor(int pin_num);
-
-#endif /* __POSITION_FINDER_RESOURCE_RAIN_SENSOR_INTERNAL_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- * Geunsun Lee <gs86.lee@samsung.com>
- * Eunyoung Lee <ey928.lee@samsung.com>
- * Junkyu Han <junkyu.han@samsung.com>
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __POSITION_FINDER_RESOURCE_SOUND_DETECTION_SENSOR_H__
-#define __POSITION_FINDER_RESOURCE_SOUND_DETECTION_SENSOR_H__
-
-/**
- * @brief Reads the value of gpio connected sound detection sensor(NS-SDSM).
- * @param[in] pin_num The number of the gpio pin connected to the sound detection sensor
- * @param[out] out_value The vaule of the gpio (zero or non-zero)
- * @return 0 on success, otherwise a negative error value
- *
- * @see If the gpio pin is not open, creates gpio handle before reading the value of gpio.
- */
-extern int resource_read_sound_detection_sensor(int pin_num, uint32_t *out_value);
-
-#endif /* __POSITION_FINDER_RESOURCE_SOUND_DETECTION_SENSOR_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- * Geunsun Lee <gs86.lee@samsung.com>
- * Eunyoung Lee <ey928.lee@samsung.com>
- * Junkyu Han <junkyu.han@samsung.com>
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __POSITION_FINDER_RESOURCE_SOUND_DETECTION_SENSOR_INTERNAL_H__
-#define __POSITION_FINDER_RESOURCE_SOUND_DETECTION_SENSOR_INTERNAL_H__
-
-/**
- * @brief Releases the gpio handle and changes the gpio pin state to the close(0).
- * @param[in] pin_num The number of the gpio pin connected to the sound detection sensor
- */
-extern void resource_close_sound_detection_sensor(int pin_num);
-
-#endif /* __POSITION_FINDER_RESOURCE_SOUND_DETECTION_SENSOR_INTERNAL_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- * Geunsun Lee <gs86.lee@samsung.com>
- * Eunyoung Lee <ey928.lee@samsung.com>
- * Junkyu Han <junkyu.han@samsung.com>
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __POSITION_FINDER_RESOURCE_TILT_SENSOR_H__
-#define __POSITION_FINDER_RESOURCE_TILT_SENSOR_H__
-
-/**
- * @brief Reads the value of gpio connected tilt sensor(SZH-EK084).
- * @param[in] pin_num The number of the gpio pin connected to the tilt sensor
- * @param[out] out_value The vaule of the gpio (zero or non-zero)
- * @return 0 on success, otherwise a negative error value
- *
- * @see If the gpio pin is not open, creates gpio handle before reading the value of gpio.
- */
-extern int resource_read_tilt_sensor(int pin_num, uint32_t *out_value);
-
-#endif /* __POSITION_FINDER_RESOURCE_TILT_SENSOR_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- * Geunsun Lee <gs86.lee@samsung.com>
- * Eunyoung Lee <ey928.lee@samsung.com>
- * Junkyu Han <junkyu.han@samsung.com>
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __POSITION_FINDER_RESOURCE_TILT_SENSOR_INTERNAL_H__
-#define __POSITION_FINDER_RESOURCE_TILT_SENSOR_INTERNAL_H__
-
-/**
- * @brief Releases the gpio handle and changes the gpio pin state to the close(0).
- * @param[in] pin_num The number of the gpio pin connected to the tilt sensor
- */
-extern void resource_close_tilt_sensor(int pin_num);
-
-#endif /* __POSITION_FINDER_RESOURCE_TILT_SENSOR_INTERNAL_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- * Geunsun Lee <gs86.lee@samsung.com>
- * Eunyoung Lee <ey928.lee@samsung.com>
- * Junkyu Han <junkyu.han@samsung.com>
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __POSITION_FINDER_RESOURCE_TOUCH_SENSOR_H__
-#define __POSITION_FINDER_RESOURCE_TOUCH_SENSOR_H__
-
-/**
- * @brief Reads the value of gpio connected touch sensor.
- * @param[in] pin_num The number of the gpio pin connected to the touch sensor
- * @param[out] out_value The value of the gpio (zero or non-zero)
- * @return 0 on success, otherwise a negative error value
- * @see If the gpio pin is not open, creates gpio handle before reading the value of gpio.
- */
-extern int resource_read_touch_sensor(int pin_num, uint32_t *out_value);
-
-#endif /* __POSITION_FINDER_RESOURCE_TOUCH_SENSOR_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- * Geunsun Lee <gs86.lee@samsung.com>
- * Eunyoung Lee <ey928.lee@samsung.com>
- * Junkyu Han <junkyu.han@samsung.com>
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __POSITION_FINDER_RESOURCE_TOUCH_SENSOR_INTERNAL_H__
-#define __POSITION_FINDER_RESOURCE_TOUCH_SENSOR_INTERNAL_H__
-
-/**
- * @brief Releases the gpio handle and changes the gpio pin state to the close(0).
- * @param[in] pin_num The number of the gpio pin connected to the touch sensor
- */
-extern void resource_close_touch_sensor(int pin_num);
-
-#endif /* __POSITION_FINDER_RESOURCE_TOUCH_SENSOR_INTERNAL_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- * Geunsun Lee <gs86.lee@samsung.com>
- * Eunyoung Lee <ey928.lee@samsung.com>
- * Junkyu Han <junkyu.han@samsung.com>
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __POSITION_FINDER_RESOURCE_ULTRASONIC_SENSOR_H__
-#define __POSITION_FINDER_RESOURCE_ULTRASONIC_SENSOR_H__
-
-/**
- * @brief Reads the value of gpio connected ultrasonic sensor(HC-SR04).
- * @param[in] trig_pin_num The number of the gpio pin connected to the trig of the ultrasonic sensor
- * @param[in] echo_pin_num The number of the gpio pin connected to the echo of the ultrasonic sensor
- * @param[in] cb A callback function to be invoked when the gpio interrupt is triggered
- * @param[in] data The data to be passed to the callback function
- * @return 0 on success, otherwise a negative error value
- * @see If the gpio pin is not open, creates gpio handle before reading the value of gpio.
- */
-extern int resource_read_ultrasonic_sensor(int trig_pin_num, int echo_pin_num, resource_read_cb cb, void *data);
-
-#endif /* __POSITION_FINDER_RESOURCE_ULTRASONIC_SENSOR_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- * Geunsun Lee <gs86.lee@samsung.com>
- * Eunyoung Lee <ey928.lee@samsung.com>
- * Junkyu Han <junkyu.han@samsung.com>
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __POSITION_FINDER_RESOURCE_ULTRASONIC_SENSOR_INTERNAL_H__
-#define __POSITION_FINDER_RESOURCE_ULTRASONIC_SENSOR_INTERNAL_H__
-
-/**
- * @brief Releases the gpio handle and changes the gpio pin state to the close(0).
- * @param[in] trig_pin_num The number of the gpio pin connected to the trig of the ultrasonic sensor
- * @param[in] echo_pin_num The number of the gpio pin connected to the echo of the ultrasonic sensor
- */
-extern void resource_close_ultrasonic_sensor_trig(int trig_pin_num);
-extern void resource_close_ultrasonic_sensor_echo(int echo_pin_num);
-
-#endif /* __POSITION_FINDER_RESOURCE_ULTRASONIC_SENSOR_INTERNAL_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- * Geunsun Lee <gs86.lee@samsung.com>
- * Eunyoung Lee <ey928.lee@samsung.com>
- * Junkyu Han <junkyu.han@samsung.com>
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __POSITION_FINDER_RESOURCE_VIBRATION_SENSOR_H__
-#define __POSITION_FINDER_RESOURCE_VIBRATION_SENSOR_H__
-
-/**
- * @brief Reads the value of gpio connected vibration sensor(SZH-EKAD-131).
- * @param[in] pin_num The number of the gpio pin connected to the vibration sensor
- * @param[out] out_value The value of the gpio (zero or non-zero)
- * @return 0 on success, otherwise a negative error value
- * @see If the gpio pin is not open, creates gpio handle before reading the value of gpio.
- */
-extern int resource_read_vibration_sensor(int pin_num, uint32_t *out_value);
-
-#endif /* __POSITION_FINDER_RESOURCE_VIBRATION_SENSOR_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- * Geunsun Lee <gs86.lee@samsung.com>
- * Eunyoung Lee <ey928.lee@samsung.com>
- * Junkyu Han <junkyu.han@samsung.com>
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __POSITION_FINDER_RESOURCE_VIBRATION_SENSOR_INTERNAL_H__
-#define __POSITION_FINDER_RESOURCE_VIBRATION_SENSOR_INTERNAL_H__
-
-/**
- * @brief Releases the gpio handle and changes the gpio pin state to the close(0).
- * @param[in] pin_num The number of the gpio pin connected to the vibration sensor
- */
-extern void resource_close_vibration_sensor(int pin_num);
-
-#endif /* __POSITION_FINDER_RESOURCE_VIBRATION_SENSOR_INTERNAL_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- * Geunsun Lee <gs86.lee@samsung.com>
- * Eunyoung Lee <ey928.lee@samsung.com>
- * Junkyu Han <junkyu.han@samsung.com>
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __POSITION_FINDER_RESOURCE_INTERNAL_H__
-#define __POSITION_FINDER_RESOURCE_INTERNAL_H__
-
-#include <peripheral_io.h>
-
-#include "resource/resource_illuminance_sensor_internal.h"
-#include "resource/resource_infrared_motion_sensor_internal.h"
-#include "resource/resource_infrared_obstacle_avoidance_sensor_internal.h"
-#include "resource/resource_touch_sensor_internal.h"
-#include "resource/resource_ultrasonic_sensor_internal.h"
-#include "resource/resource_led_internal.h"
-#include "resource/resource_vibration_sensor_internal.h"
-#include "resource/resource_flame_sensor_internal.h"
-#include "resource/resource_rain_sensor_internal.h"
-#include "resource/resource_sound_detection_sensor_internal.h"
-#include "resource/resource_tilt_sensor_internal.h"
-#include "resource/resource_gas_detection_sensor_internal.h"
-
-#define PIN_MAX 40
-
-struct _resource_s {
- int opened;
- peripheral_gpio_h sensor_h;
- void (*close) (int);
-};
-typedef struct _resource_s resource_s;
-
-typedef void (*resource_read_cb)(double value, void *data);
-
-struct _resource_read_cb_s {
- resource_read_cb cb;
- void *data;
- int pin_num;
-};
-typedef struct _resource_read_cb_s resource_read_s;
-
-extern resource_s *resource_get_info(int pin_num);
-extern void resource_close_all(void);
-
-#endif /* __POSITION_FINDER_RESOURCE_INTERNAL_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- * Geunsun Lee <gs86.lee@samsung.com>
- * Eunyoung Lee <ey928.lee@samsung.com>
- * Junkyu Han <junkyu.han@samsung.com>
- * Jeonghoon Park <jh1979.park@samsung.com>
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-#ifndef __POSITION_FINDER_WEBUTIL_H__
-#define __POSITION_FINDER_WEBUTIL_H__
-
-typedef enum {
- WEB_UTIL_SENSOR_NONE = 0,
- WEB_UTIL_SENSOR_MOTION = (1 << 0), /* IR motion sensor */
- WEB_UTIL_SENSOR_FLAME = (1 << 1), /* flame sensor */
- WEB_UTIL_SENSOR_HUMIDITY = (1 << 2), /* humidity sensor */
- WEB_UTIL_SENSOR_TEMPERATURE = (1 << 3), /* temperature sensor */
- WEB_UTIL_SENSOR_VIB = (1 << 4), /* vibration sensor */
- WEB_UTIL_SENSOR_CO2 = (1 << 5), /* CO2 sensor */
- WEB_UTIL_SENSOR_SOUND = (1 << 6), /* noise sensor */
- WEB_UTIL_SENSOR_TILT = (1 << 7), /* tilt sensor */
- WEB_UTIL_SENSOR_LIGHT = (1 << 8), /* light sensor */
- WEB_UTIL_SENSOR_COLLISION = (1 << 9), /* collision sensor */
- WEB_UTIL_SENSOR_OBSTACLE = (1 << 10), /* obstacle avoidance sensor */
- WEB_UTIL_SENSOR_ULTRASONIC_DISTANCE = (1 << 11), /* ultrasonic distance sensor */
- WEB_UTIL_SENSOR_RAIN = (1 << 12), /* rain sensor */
- WEB_UTIL_SENSOR_TOUCH = (1 << 13), /* touch sensor */
- WEB_UTIL_SENSOR_GAS = (1 << 14), /* gas sensor */
-} web_util_sensor_type_e;
-
-typedef struct _web_util_sensor_data_s web_util_sensor_data_s;
-struct _web_util_sensor_data_s {
- int motion;
- int flame;
- double humidity;
- double temperature;
- int virbration;
- double co2;
- int soundlevel;
- int tilt;
- int light;
- int collision;
- int obstacle;
- double distance;
- int rain;
- int touch;
- int gas;
- web_util_sensor_type_e enabled_sensor;
- char *hash;
-};
-
-int web_util_noti_init(void);
-void web_util_noti_fini(void);
-int web_util_noti_post(const char *resource, const char *json_data);
-
-int web_util_json_init(void);
-int web_util_json_fini(void);
-int web_util_json_data_array_begin(void);
-int web_util_json_data_array_end(void);
-int web_util_json_add_sensor_data(const char* sensorpi_id, web_util_sensor_data_s *sensor_data);
-char *web_util_get_json_string(void);
-
-#endif /* __POSITION_FINDER_WEBUTIL_H__ */
+++ /dev/null
-<manifest>\r
- <request>\r
- <domain name="_" />\r
- </request>\r
-</manifest>\r
+++ /dev/null
-%define P_NAME position-finder-server
-%define APP_LABEL "Position Finder Server"
-%define ORG_PREFIX org.tizen
-
-Name: %{ORG_PREFIX}.%{P_NAME}
-%define alias %{name}
-Summary: IoTivity Application
-Group: Applications/Core Applications
-Version: 0.0.1
-Release: 1
-License: Flora-1.1
-Provides: %{name} = %{version}-%{release}
-Source0: %{name}-%{version}.tar.gz
-
-BuildRequires: cmake
-BuildRequires: hash-signer
-BuildRequires: pkgconfig(capi-appfw-application)
-BuildRequires: pkgconfig(dlog)
-BuildRequires: pkgconfig(libtzplatform-config)
-BuildRequires: pkgconfig(capi-appfw-service-application)
-BuildRequires: pkgconfig(capi-system-peripheral-io)
-BuildRequires: pkgconfig(ecore)
-BuildRequires: pkgconfig(eina)
-BuildRequires: pkgconfig(iotcon)
-BuildRequires: pkgconfig(gio-2.0)
-BuildRequires: pkgconfig(libcurl)
-BuildRequires: pkgconfig(glib-2.0)
-BuildRequires: pkgconfig(json-glib-1.0)
-
-%description
-Server for Position Finder
-
-%prep
-%setup -q
-
-%build
-
-%define _pkg_dir %{TZ_SYS_RO_APP}/%{alias}
-%define _pkg_shared_dir %{_pkg_dir}/shared
-%define _pkg_data_dir %{_pkg_dir}/data
-%define _pkg_rw_data_dir /home/owner/apps_rw/%{alias}/data
-%define _pkg_res_dir %{_pkg_dir}/res
-%define _sys_icons_dir %{_pkg_shared_dir}/res
-%define _sys_packages_dir %{TZ_SYS_RO_PACKAGES}
-%define _sys_license_dir %{TZ_SYS_SHARE}/license
-%define _cbor_file iotcon-test-svr-db-server.dat
-%define _conf_file pi.conf
-
-%ifarch %{arm}
-export CFLAGS="$CFLAGS -DTIZEN_BUILD_TARGET"
-export CXXFLAGS="$CXXFLAGS -DTIZEN_BUILD_TARGET"
-export FFLAGS="$FFLAGS -DTIZEN_BUILD_TARGET"
-%else
-export CFLAGS="$CFLAGS -DTIZEN_BUILD_EMULATOR"
-export CXXFLAGS="$CXXFLAGS -DTIZEN_BUILD_EMULATOR"
-export FFLAGS="$FFLAGS -DTIZEN_BUILD_EMULATOR"
-%endif
-
-cmake . -DP_NAME=%{P_NAME} \
- -DORG_PREFIX=%{ORG_PREFIX} \
- -DAPP_LABEL=%{APP_LABEL} \
- -DINSTALL_PREFIX=%{_pkg_dir} \
- -DINSTALL_OWNER_DATADIR=%{_pkg_rw_data_dir} \
- -DINSTALL_RESDIR=%{_pkg_res_dir} \
- -DSYS_ICONS_DIR=%{_sys_icons_dir} \
- -DSYS_PACKAGES_DIR=%{_sys_packages_dir} \
- -DCBOR_FILE=%{_cbor_file} \
- -DCONF_FILE=%{_conf_file}
-make %{?jobs:-j%jobs}
-
-%install
-%make_install
-
-%define tizen_sign 1
-%define tizen_sign_base %{_pkg_dir}
-%define tizen_sign_level platform
-%define tizen_author_sign 1
-%define tizen_dist_sign 1
-#%find_lang position-finder-server
-
-%post
-/sbin/ldconfig
-chsmack -a "User::Pkg::%{alias}" %{_pkg_res_dir}/*.dat
-chmod 444 %{_pkg_res_dir}/*.dat
-
-touch %{_pkg_rw_data_dir}/%{_cbor_file}
-chsmack -a "User::Pkg::%{alias}" %{_pkg_rw_data_dir}/*.dat
-chmod 666 %{_pkg_rw_data_dir}/*.dat
-
-# This routine will be used in the file of .dev_id.
-#touch %{_pkg_rw_data_dir}/%{_conf_file}
-#echo "/door/777" > %{_pkg_rw_data_dir}/%{_conf_file}
-#chsmack -a "User::Pkg::%{alias}" %{_pkg_rw_data_dir}/%{_conf_file}
-#chmod 444 %{_pkg_rw_data_dir}/%{_conf_file}
-
-%postun -p /sbin/ldconfig
-
-%files
-%{_pkg_res_dir}/*.dat
-%{_pkg_res_dir}/*.conf
-%manifest %{alias}.manifest
-%defattr(-,root,root,-)
-%{_pkg_rw_data_dir}
-%{_pkg_dir}/bin/%{P_NAME}
-%{_sys_packages_dir}/%{alias}.xml
-%{_sys_icons_dir}/*.png
-%{_pkg_dir}/author-signature.xml
-%{_pkg_dir}/signature1.xml
+++ /dev/null
-[default]
-path=/door/1
-address=http://tizentalks.xyz:3000/api/bang/data
+++ /dev/null
-[ethernet_b827eb0b6458_cable]
-Name=Wired
-AutoConnect=true
-Modified=2016-07-25T19:49:54.191535Z
-IPv4.method=manual
-IPv6.method=auto
-IPv6.privacy=disabled
-IPv4.DHCP.LastAddress=10.113.216.216
-Nameservers.IPv4method=dhcp
-IPv4.netmask_prefixlen=24
-IPv4.local_address=10.113.62.234
-IPv4.gateway=10.113.62.1
-#connmanctl config ethernet_b827eb0b6458_cable --ipv4 manual 10.113.62.234 255.255.255.0 10.113.62.1
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- * Geunsun Lee <gs86.lee@samsung.com>
- * Eunyoung Lee <ey928.lee@samsung.com>
- * Junkyu Han <junkyu.han@samsung.com>
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdbool.h>
-#include <glib.h>
-#include <Eina.h>
-#include <app_common.h>
-
-#include "log.h"
-#include "connectivity.h"
-
-#define ULTRASONIC_RESOURCE_TYPE "org.tizen.door"
-#define BUFSIZE 1024
-#define URI_PATH_LEN 64
-#define URI_PATH "/door/1"
-#define PATH "path"
-
-static void _request_resource_handler(iotcon_resource_h resource, iotcon_request_h request, void *user_data);
-
-static int _send_response(iotcon_request_h request, iotcon_representation_h representation, iotcon_response_result_e result)
-{
- int ret = -1;
- iotcon_response_h response;
-
- ret = iotcon_response_create(request, &response);
- retv_if(IOTCON_ERROR_NONE != ret, -1);
-
- ret = iotcon_response_set_result(response, result);
- goto_if(IOTCON_ERROR_NONE != ret, error);
-
- ret = iotcon_response_set_representation(response, representation);
- goto_if(IOTCON_ERROR_NONE != ret, error);
-
- ret = iotcon_response_send(response);
- goto_if(IOTCON_ERROR_NONE != ret, error);
-
- iotcon_response_destroy(response);
-
- return 0;
-
-error:
- iotcon_response_destroy(response);
- return -1;
-}
-
-static void _destroy_representation(iotcon_representation_h representation)
-{
- ret_if(!representation);
- iotcon_representation_destroy(representation);
-}
-
-static iotcon_representation_h _create_representation_with_bool(connectivity_resource_s *resource_info, const char *key, bool value)
-{
- iotcon_attributes_h attributes = NULL;
- iotcon_representation_h representation = NULL;
- char *uri_path = NULL;
- int ret = -1;
-
- ret = iotcon_resource_get_uri_path(resource_info->res, &uri_path);
- retv_if(IOTCON_ERROR_NONE != ret, NULL);
-
- ret = iotcon_representation_create(&representation);
- retv_if(IOTCON_ERROR_NONE != ret, NULL);
-
- ret = iotcon_attributes_create(&attributes);
- goto_if(IOTCON_ERROR_NONE != ret, error);
-
- ret = iotcon_representation_set_uri_path(representation, uri_path);
- goto_if(IOTCON_ERROR_NONE != ret, error);
-
- ret = iotcon_attributes_add_str(attributes, PATH, resource_info->path);
- goto_if(IOTCON_ERROR_NONE != ret, error);
-
- ret = iotcon_attributes_add_bool(attributes, key, value);
- goto_if(IOTCON_ERROR_NONE != ret, error);
-
- ret = iotcon_representation_set_attributes(representation, attributes);
- goto_if(IOTCON_ERROR_NONE != ret, error);
-
- iotcon_attributes_destroy(attributes);
-
- return representation;
-
-error:
- if (attributes) iotcon_attributes_destroy(attributes);
- if (representation) iotcon_representation_destroy(representation);
-
- return NULL;
-}
-
-static iotcon_representation_h _create_representation_with_int(connectivity_resource_s *resource_info, const char *key, int value)
-{
- iotcon_attributes_h attributes = NULL;
- iotcon_representation_h representation = NULL;
- char *uri_path = NULL;
- int ret = -1;
-
- ret = iotcon_resource_get_uri_path(resource_info->res, &uri_path);
- retv_if(IOTCON_ERROR_NONE != ret, NULL);
-
- ret = iotcon_representation_create(&representation);
- retv_if(IOTCON_ERROR_NONE != ret, NULL);
-
- ret = iotcon_attributes_create(&attributes);
- goto_if(IOTCON_ERROR_NONE != ret, error);
-
- ret = iotcon_representation_set_uri_path(representation, uri_path);
- goto_if(IOTCON_ERROR_NONE != ret, error);
-
- ret = iotcon_attributes_add_str(attributes, PATH, resource_info->path);
- goto_if(IOTCON_ERROR_NONE != ret, error);
-
- ret = iotcon_attributes_add_int(attributes, key, value);
- goto_if(IOTCON_ERROR_NONE != ret, error);
-
- ret = iotcon_representation_set_attributes(representation, attributes);
- goto_if(IOTCON_ERROR_NONE != ret, error);
-
- iotcon_attributes_destroy(attributes);
-
- return representation;
-
-error:
- if (attributes) iotcon_attributes_destroy(attributes);
- if (representation) iotcon_representation_destroy(representation);
-
- return NULL;
-}
-
-static iotcon_representation_h _create_representation_with_double(connectivity_resource_s *resource_info, const char *key, double value)
-{
- iotcon_attributes_h attributes = NULL;
- iotcon_representation_h representation = NULL;
- char *uri_path = NULL;
- int ret = -1;
-
- ret = iotcon_resource_get_uri_path(resource_info->res, &uri_path);
- retv_if(IOTCON_ERROR_NONE != ret, NULL);
-
- ret = iotcon_representation_create(&representation);
- retv_if(IOTCON_ERROR_NONE != ret, NULL);
-
- ret = iotcon_attributes_create(&attributes);
- goto_if(IOTCON_ERROR_NONE != ret, error);
-
- ret = iotcon_representation_set_uri_path(representation, uri_path);
- goto_if(IOTCON_ERROR_NONE != ret, error);
-
- ret = iotcon_attributes_add_str(attributes, PATH, resource_info->path);
- goto_if(IOTCON_ERROR_NONE != ret, error);
-
- ret = iotcon_attributes_add_double(attributes, key, value);
- goto_if(IOTCON_ERROR_NONE != ret, error);
-
- ret = iotcon_representation_set_attributes(representation, attributes);
- goto_if(IOTCON_ERROR_NONE != ret, error);
-
- iotcon_attributes_destroy(attributes);
-
- return representation;
-
-error:
- if (attributes) iotcon_attributes_destroy(attributes);
- if (representation) iotcon_representation_destroy(representation);
-
- return NULL;
-}
-
-static void _print_iotcon_error(int err_no)
-{
- switch (err_no) {
- case IOTCON_ERROR_NOT_SUPPORTED:
- _E("IOTCON_ERROR_NOT_SUPPORTED");
- break;
- case IOTCON_ERROR_PERMISSION_DENIED:
- _E("IOTCON_ERROR_PERMISSION_DENIED");
- break;
- case IOTCON_ERROR_INVALID_PARAMETER:
- _E("IOTCON_ERROR_INVALID_PARAMETER");
- break;
- default:
- _E("Error : [%d]", err_no);
- break;
- }
-}
-
-int connectivity_notify_bool(connectivity_resource_s *resource_info, const char *key, bool value)
-{
- iotcon_representation_h representation;
- int ret = -1;
-
- retv_if(!resource_info, -1);
- retv_if(!resource_info->observers, -1);
-
- _D("Notify the value[%d]", value);
-
- representation = _create_representation_with_bool(resource_info, key, value);
- retv_if(!representation, -1);
-
- ret = iotcon_resource_notify(resource_info->res, representation, resource_info->observers, IOTCON_QOS_LOW);
- if (IOTCON_ERROR_NONE != ret) {
- _I("There are some troubles for notifying value[%d]", ret);
- _print_iotcon_error(ret);
- return -1;
- }
-
- _destroy_representation(representation);
-
- return 0;
-}
-
-int connectivity_notify_int(connectivity_resource_s *resource_info, const char *key, int value)
-{
- iotcon_representation_h representation;
- int ret = -1;
-
- retv_if(!resource_info, -1);
- retv_if(!resource_info->observers, -1);
-
- _D("Notify the value[%d]", value);
-
- representation = _create_representation_with_int(resource_info, key, value);
- retv_if(!representation, -1);
-
- ret = iotcon_resource_notify(resource_info->res, representation, resource_info->observers, IOTCON_QOS_LOW);
- if (IOTCON_ERROR_NONE != ret) {
- _I("There are some troubles for notifying value[%d]", ret);
- _print_iotcon_error(ret);
- return -1;
- }
-
- _destroy_representation(representation);
-
- return 0;
-}
-
-int connectivity_notify_double(connectivity_resource_s *resource_info, const char *key, double value)
-{
- iotcon_representation_h representation;
- int ret = -1;
-
- retv_if(!resource_info, -1);
- retv_if(!resource_info->observers, -1);
-
- _D("Notify the value[%f]", value);
-
- representation = _create_representation_with_double(resource_info, key, value);
- retv_if(!representation, -1);
-
- ret = iotcon_resource_notify(resource_info->res, representation, resource_info->observers, IOTCON_QOS_LOW);
- if (IOTCON_ERROR_NONE != ret) {
- _I("There are some troubles for notifying value[%d]", ret);
- _print_iotcon_error(ret);
- return -1;
- }
-
- _destroy_representation(representation);
-
- return 0;
-}
-
-static bool _query_cb(const char *key, const char *value, void *user_data)
-{
- _D("Key : [%s], Value : [%s]", key, value);
-
- return IOTCON_FUNC_CONTINUE;
-}
-
-static int _handle_query(iotcon_request_h request)
-{
- iotcon_query_h query = NULL;
- int ret = -1;
-
- ret = iotcon_request_get_query(request, &query);
- retv_if(IOTCON_ERROR_NONE != ret, -1);
-
- if (query) iotcon_query_foreach(query, _query_cb, NULL);
-
- return 0;
-}
-
-static int _handle_request_by_crud_type(iotcon_request_h request, connectivity_resource_s *resource_info)
-{
- iotcon_request_type_e type;
- int ret = -1;
-
- ret = iotcon_request_get_request_type(request, &type);
- retv_if(IOTCON_ERROR_NONE != ret, -1);
-
- switch (type) {
- case IOTCON_REQUEST_GET:
- _I("Do not support 'get' query");
- break;
- case IOTCON_REQUEST_PUT:
- _I("Do not support 'put' query");
- break;
- case IOTCON_REQUEST_POST:
- _I("Do not support 'post' query");
- break;
- case IOTCON_REQUEST_DELETE:
- _I("Do not support 'delete' query");
- break;
- default:
- _E("Cannot reach here");
- ret = -1;
- break;
- }
- retv_if(0 != ret, -1);
-
- return 0;
-}
-
-static int _handle_observer(iotcon_request_h request, iotcon_observers_h observers)
-{
- iotcon_observe_type_e observe_type;
- int ret = -1;
- int observe_id = -1;
-
- ret = iotcon_request_get_observe_type(request, &observe_type);
- retv_if(IOTCON_ERROR_NONE != ret, -1);
-
- if (IOTCON_OBSERVE_REGISTER == observe_type) {
- ret = iotcon_request_get_observe_id(request, &observe_id);
- retv_if(IOTCON_ERROR_NONE != ret, -1);
-
- _I("Add an observer : %d", observe_id);
-
- ret = iotcon_observers_add(observers, observe_id);
- retv_if(IOTCON_ERROR_NONE != ret, -1);
- } else if (IOTCON_OBSERVE_DEREGISTER == observe_type) {
- ret = iotcon_request_get_observe_id(request, &observe_id);
- retv_if(IOTCON_ERROR_NONE != ret, -1);
-
- _I("Remove an observer : %d", observe_id);
-
- ret = iotcon_observers_remove(observers, observe_id);
- retv_if(IOTCON_ERROR_NONE != ret, -1);
- }
-
- return 0;
-}
-
-static void _request_resource_handler(iotcon_resource_h resource, iotcon_request_h request, void *user_data)
-{
- connectivity_resource_s *resource_info = user_data;
- int ret = -1;
- char *host_address = NULL;
-
- ret_if(!request);
-
- ret = iotcon_request_get_host_address(request, &host_address);
- goto_if(IOTCON_ERROR_NONE != ret, error);
-
- _D("Host address : %s", host_address);
-
- ret = _handle_query(request);
- goto_if(IOTCON_ERROR_NONE != ret, error);
-
- ret = _handle_request_by_crud_type(request, resource_info);
- goto_if(0 != ret, error);
-
- ret = _handle_observer(request, resource_info->observers);
- goto_if(0 != ret, error);
-
- return;
-
-error:
- _send_response(request, NULL, IOTCON_RESPONSE_ERROR);
-}
-
-static void _copy_file(const char *in_filename, const char *out_filename)
-{
- char buf[BUFSIZE] = { 0, };
- size_t nread = 0;
- FILE *in = NULL;
- FILE *out = NULL;
-
- ret_if(!in_filename);
- ret_if(!out_filename);
-
- in = fopen(in_filename, "r");
- ret_if(!in);
-
- out = fopen(out_filename, "w");
- goto_if(!out, error);
-
- rewind(in);
- while ((nread = fread(buf, 1, sizeof(buf), in)) > 0) {
- if (fwrite(buf, 1, nread, out) < nread) {
- _E("critical error to copy a file");
- break;
- }
- }
-
- fclose(in);
- fclose(out);
-
- return;
-
-error:
- fclose(out);
-}
-
-int connectivity_init(void)
-{
- int ret = -1;
-
- _copy_file(CBOR_FILE_IN_RES, CBOR_FILE_IN_DATA);
-
- ret = iotcon_initialize(CBOR_FILE_IN_DATA);
- retv_if(IOTCON_ERROR_NONE != ret, -1);
-
- ret = iotcon_set_device_name(ULTRASONIC_RESOURCE_TYPE);
- goto_if(IOTCON_ERROR_NONE != ret, error);
-
- return 0;
-
-error:
- iotcon_deinitialize();
- return -1;
-}
-
-int connectivity_fini(void)
-{
- iotcon_deinitialize();
- return 0;
-}
-
-void connectivity_unset_resource(connectivity_resource_s *resource_info)
-{
- ret_if(!resource_info);
- if (resource_info->observers) iotcon_observers_destroy(resource_info->observers);
- if (resource_info->res) iotcon_resource_destroy(resource_info->res);
- if (resource_info->path) free(resource_info->path);
- free(resource_info);
-}
-
-int connectivity_set_resource(const char *path, const char *type, connectivity_resource_s **out_resource_info)
-{
- iotcon_resource_types_h resource_types = NULL;
- iotcon_resource_interfaces_h ifaces = NULL;
- connectivity_resource_s *resource_info = NULL;
- uint8_t policies;
- int ret = -1;
-
- retv_if(!path, -1);
- retv_if(!type, -1);
- retv_if(!out_resource_info, -1);
-
- resource_info = calloc(1, sizeof(connectivity_resource_s));
- retv_if(!resource_info, -1);
-
- resource_info->path = strdup(path);
- goto_if(!resource_info->path, error);
-
- _D("Path : [%s]", resource_info->path);
-
- ret = iotcon_resource_types_create(&resource_types);
- goto_if(IOTCON_ERROR_NONE != ret, error);
-
- ret = iotcon_resource_types_add(resource_types, type);
- goto_if(IOTCON_ERROR_NONE != ret, error);
-
- ret = iotcon_resource_interfaces_create(&ifaces);
- goto_if(IOTCON_ERROR_NONE != ret, error);
-
- ret = iotcon_resource_interfaces_add(ifaces, IOTCON_INTERFACE_DEFAULT);
- goto_if(IOTCON_ERROR_NONE != ret, error);
-
- ret = iotcon_resource_interfaces_add(ifaces, IOTCON_INTERFACE_BATCH);
- goto_if(IOTCON_ERROR_NONE != ret, error);
-
- policies =
- IOTCON_RESOURCE_DISCOVERABLE |
- IOTCON_RESOURCE_OBSERVABLE |
- IOTCON_RESOURCE_SECURE;
-
- ret = iotcon_resource_create(URI_PATH,
- resource_types,
- ifaces,
- policies,
- _request_resource_handler,
- resource_info,
- &resource_info->res);
- goto_if(IOTCON_ERROR_NONE != ret, error);
-
- ret = iotcon_observers_create(&resource_info->observers);
- goto_if(IOTCON_ERROR_NONE != ret, error);
-
- iotcon_resource_types_destroy(resource_types);
- iotcon_resource_interfaces_destroy(ifaces);
- *out_resource_info = resource_info;
-
- return 0;
-
-error:
- if (ifaces) iotcon_resource_interfaces_destroy(ifaces);
- if (resource_types) iotcon_resource_types_destroy(resource_types);
- if (resource_info->res) iotcon_resource_destroy(resource_info->res);
- if (resource_info->path) free(resource_info->path);
- if (resource_info) free(resource_info);
-
- return -1;
-}
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- * Geunsun Lee <gs86.lee@samsung.com>
- * Eunyoung Lee <ey928.lee@samsung.com>
- * Junkyu Han <junkyu.han@samsung.com>
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <unistd.h>
-#include <glib.h>
-#include <Ecore.h>
-#include <tizen.h>
-#include <service_app.h>
-
-#include "log.h"
-#include "resource.h"
-#include "connectivity.h"
-#include "controller.h"
-#include "controller_util.h"
-#include "webutil.h"
-
-#define CONNECTIVITY_KEY "opened"
-#define SENSORING_TIME_INTERVAL 1.0f
-
-typedef struct app_data_s {
- Ecore_Timer *getter_timer;
- connectivity_resource_s *resource_info;
-} app_data;
-
-static Eina_Bool control_sensors_cb(void *data)
-{
- app_data *ad = data;
-
- if (connectivity_notify_bool(ad->resource_info, CONNECTIVITY_KEY, true) == -1)
- _E("Cannot notify message");
-
- return ECORE_CALLBACK_RENEW;
-}
-
-static bool service_app_create(void *data)
-{
- app_data *ad = data;
- int ret = -1;
-
- /**
- * No modification required!!!
- * Access only when modifying internal functions.
- */
- controller_init_internal_functions();
-
- /**
- * Create a connectivity resource and registers the resource in server.
- */
- ret = connectivity_set_resource(NULL, "org.tizen.door", &ad->resource_info);
- if (ret == -1) _E("Cannot broadcast resource");
-
- /**
- * Creates a timer to call the given function in the given period of time.
- * In the control_sensors_cb(), each sensor reads the measured value or writes a specific value to the sensor.
- */
- ad->getter_timer = ecore_timer_add(SENSORING_TIME_INTERVAL, control_sensors_cb, ad);
- if (!ad->getter_timer) {
- _E("Failed to add infrared motion getter timer");
- return false;
- }
-
- return true;
-}
-
-static void service_app_terminate(void *data)
-{
- app_data *ad = (app_data *)data;
-
- if (ad->getter_timer)
- ecore_timer_del(ad->getter_timer);
-
-
- /**
- * Releases the resource about connectivity.
- */
- connectivity_unset_resource(ad->resource_info);
-
- /**
- * No modification required!!!
- * Access only when modifying internal functions.
- */
- controller_fini_internal_functions();
-
- free(ad);
-}
-
-static void service_app_control(app_control_h app_control, void *data)
-{
- // Todo: add your code here.
-}
-
-static void service_app_lang_changed(app_event_info_h event_info, void *user_data)
-{
- /*APP_EVENT_LANGUAGE_CHANGED*/
-}
-
-static void service_app_region_changed(app_event_info_h event_info, void *user_data)
-{
- /*APP_EVENT_REGION_FORMAT_CHANGED*/
-}
-
-static void service_app_low_battery(app_event_info_h event_info, void *user_data)
-{
- /*APP_EVENT_LOW_BATTERY*/
-}
-
-static void service_app_low_memory(app_event_info_h event_info, void *user_data)
-{
- /*APP_EVENT_LOW_MEMORY*/
-}
-
-int main(int argc, char* argv[])
-{
- app_data *ad = NULL;
- int ret = 0;
- service_app_lifecycle_callback_s event_callback;
- app_event_handler_h handlers[5] = {NULL, };
-
- ad = calloc(1, sizeof(app_data));
- retv_if(!ad, -1);
-
- event_callback.create = service_app_create;
- event_callback.terminate = service_app_terminate;
- event_callback.app_control = service_app_control;
-
- service_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, service_app_low_battery, &ad);
- service_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, service_app_low_memory, &ad);
- service_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, service_app_lang_changed, &ad);
- service_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, service_app_region_changed, &ad);
-
- ret = service_app_main(argc, argv, &event_callback, ad);
-
- return ret;
-}
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- * Geunsun Lee <gs86.lee@samsung.com>
- * Eunyoung Lee <ey928.lee@samsung.com>
- * Junkyu Han <junkyu.han@samsung.com>
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <iotcon.h>
-
-#include "log.h"
-#include "connectivity.h"
-#include "resource.h"
-#include "controller_util.h"
-
-void controller_init_internal_functions(void)
-{
- connectivity_init();
-}
-
-void controller_fini_internal_functions(void)
-{
- _I("Terminating...");
- resource_close_all();
- connectivity_fini();
- controller_util_free();
-}
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- * Geunsun Lee <gs86.lee@samsung.com>
- * Eunyoung Lee <ey928.lee@samsung.com>
- * Junkyu Han <junkyu.han@samsung.com>
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdlib.h>
-#include <glib.h>
-
-#include "log.h"
-
-#define CONF_GROUP_DEFAULT_NAME "default"
-#define CONF_KEY_PATH_NAME "path"
-#define CONF_KEY_ADDRESS_NAME "address"
-
-struct controller_util_s {
- char *path;
- char *address;
-};
-
-struct controller_util_s controller_util = { 0, };
-
-static int _read_conf_file(void)
-{
- GKeyFile *gkf = NULL;
-
- gkf = g_key_file_new();
- retv_if(!gkf, -1);
-
- if (!g_key_file_load_from_file(gkf, CONF_FILE, G_KEY_FILE_NONE, NULL)) {
- _E("could not read config file %s", CONF_FILE);
- return -1;
- }
-
- controller_util.path = g_key_file_get_string(gkf,
- CONF_GROUP_DEFAULT_NAME,
- CONF_KEY_PATH_NAME,
- NULL);
- if (!controller_util.path)
- _E("could not get the key string");
-
- controller_util.address = g_key_file_get_string(gkf,
- CONF_GROUP_DEFAULT_NAME,
- CONF_KEY_ADDRESS_NAME,
- NULL);
- if (!controller_util.address)
- _E("could not get the key string");
-
- g_key_file_free(gkf);
-
- return 0;
-}
-
-int controller_util_get_path(const char **path)
-{
- retv_if(!path, -1);
-
- if (!controller_util.path) {
- int ret = -1;
- ret = _read_conf_file();
- retv_if(-1 == ret, -1);
- }
-
- *path = controller_util.path;
-
- return 0;
-}
-
-int controller_util_get_address(const char **address)
-{
- retv_if(!address, -1);
-
- if (!controller_util.address) {
- int ret = -1;
- ret = _read_conf_file();
- retv_if(-1 == ret, -1);
- }
-
- *address = controller_util.address;
-
- return 0;
-}
-
-void controller_util_free(void)
-{
- if (controller_util.path) {
- free(controller_util.path);
- controller_util.path = NULL;
- }
-
- if (controller_util.address) {
- free(controller_util.address);
- controller_util.address = NULL;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- * Geunsun Lee <gs86.lee@samsung.com>
- * Eunyoung Lee <ey928.lee@samsung.com>
- * Junkyu Han <junkyu.han@samsung.com>
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <peripheral_io.h>
-
-#include "log.h"
-#include "resource.h"
-
-static resource_s resource_info[PIN_MAX] = { {0, NULL, NULL}, };
-
-resource_s *resource_get_info(int pin_num)
-{
- return &resource_info[pin_num];
-}
-
-void resource_close_all(void)
-{
- int i = 0;
- for (i = 0; i < PIN_MAX; i++) {
- if (!resource_info[i].opened) continue;
- _I("GPIO[%d] is closing...", i);
-
- if (resource_info[i].close)
- resource_info[i].close(i);
- }
- resource_close_illuminance_sensor();
-}
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- * Geunsun Lee <gs86.lee@samsung.com>
- * Eunyoung Lee <ey928.lee@samsung.com>
- * Junkyu Han <junkyu.han@samsung.com>
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <peripheral_io.h>
-#include <sys/time.h>
-
-#include "log.h"
-#include "resource_internal.h"
-
-void resource_close_flame_sensor(int pin_num)
-{
- if (!resource_get_info(pin_num)->opened) return;
-
- _I("Flame Sensor is finishing...");
- peripheral_gpio_close(resource_get_info(pin_num)->sensor_h);
- resource_get_info(pin_num)->opened = 0;
-}
-
-int resource_read_flame_sensor(int pin_num, uint32_t *out_value)
-{
- int ret = PERIPHERAL_ERROR_NONE;
-
- if (!resource_get_info(pin_num)->opened) {
- ret = peripheral_gpio_open(pin_num, &resource_get_info(pin_num)->sensor_h);
- retv_if(!resource_get_info(pin_num)->sensor_h, -1);
-
- ret = peripheral_gpio_set_direction(resource_get_info(pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_IN);
- retv_if(ret != 0, -1);
-
- resource_get_info(pin_num)->opened = 1;
- resource_get_info(pin_num)->close = resource_close_flame_sensor;
- }
-
- /**
- * This model(NS-FDSM) normally outputs 1, and outputs 0 as out_value when a flame is detected.
- */
- ret = peripheral_gpio_read(resource_get_info(pin_num)->sensor_h, out_value);
- retv_if(ret < 0, -1);
-
- *out_value = !*out_value;
-
- return 0;
-}
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- * Geunsun Lee <gs86.lee@samsung.com>
- * Eunyoung Lee <ey928.lee@samsung.com>
- * Junkyu Han <junkyu.han@samsung.com>
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <peripheral_io.h>
-#include <sys/time.h>
-
-#include "log.h"
-#include "resource_internal.h"
-
-void resource_close_gas_detection_sensor(int pin_num)
-{
- if (!resource_get_info(pin_num)->opened) return;
-
- _I("Gas Detection Sensor is finishing...");
- peripheral_gpio_close(resource_get_info(pin_num)->sensor_h);
- resource_get_info(pin_num)->opened = 0;
-}
-
-int resource_read_gas_detection_sensor(int pin_num, uint32_t *out_value)
-{
- int ret = PERIPHERAL_ERROR_NONE;
-
- if (!resource_get_info(pin_num)->opened) {
- ret = peripheral_gpio_open(pin_num, &resource_get_info(pin_num)->sensor_h);
- retv_if(!resource_get_info(pin_num)->sensor_h, -1);
-
- ret = peripheral_gpio_set_direction(resource_get_info(pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_IN);
- retv_if(ret != 0, -1);
-
- resource_get_info(pin_num)->opened = 1;
- resource_get_info(pin_num)->close = resource_close_gas_detection_sensor;
- }
-
- /**
- * This model(FC-22) normally outputs 1, and outputs 0 as out_value when a flame is detected.
- */
- ret = peripheral_gpio_read(resource_get_info(pin_num)->sensor_h, out_value);
- retv_if(ret < 0, -1);
-
- *out_value = !*out_value;
-
- return 0;
-}
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- * Geunsun Lee <gs86.lee@samsung.com>
- * Eunyoung Lee <ey928.lee@samsung.com>
- * Junkyu Han <junkyu.han@samsung.com>
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <peripheral_io.h>
-#include <sys/time.h>
-
-#include "log.h"
-#include "resource_internal.h"
-
-#define I2C_PIN_MAX 28
-/* I2C */
-#define GY30_ADDR 0x23 /* Address of GY30 light sensor */
-#define GY30_CONT_HIGH_RES_MODE 0x10 /* Start measurement at 11x resolution. Measurement time is approx 120mx */
-#define GY30_CONSTANT_NUM (1.2)
-
-static struct {
- int opened;
- peripheral_i2c_h sensor_h;
-} resource_sensor_s;
-
-void resource_close_illuminance_sensor(void)
-{
- if (!resource_sensor_s.opened) return;
-
- _I("Illuminance Sensor is finishing...");
- peripheral_i2c_close(resource_sensor_s.sensor_h);
- resource_sensor_s.opened = 0;
-}
-
-int resource_read_illuminance_sensor(int i2c_bus, uint32_t *out_value)
-{
- int ret = PERIPHERAL_ERROR_NONE;
- unsigned char buf[10] = { 0, };
-
- if (!resource_sensor_s.opened) {
- ret = peripheral_i2c_open(i2c_bus, GY30_ADDR, &resource_sensor_s.sensor_h);
- retv_if(!resource_sensor_s.sensor_h, -1);
- resource_sensor_s.opened = 1;
- }
-
- buf[0] = GY30_CONT_HIGH_RES_MODE;
- ret = peripheral_i2c_write(resource_sensor_s.sensor_h, buf, 1);
- retv_if(ret < 0, -1);
-
- ret = peripheral_i2c_read(resource_sensor_s.sensor_h, buf, 2);
- retv_if(ret < 0, -1);
-
- *out_value = (buf[0] << 8 | buf[1]) / GY30_CONSTANT_NUM; // Just Sum High 8bit and Low 8bit
-
- _I("Illuminance Sensor Value : %d", *out_value);
-
- return 0;
-}
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- * Geunsun Lee <gs86.lee@samsung.com>
- * Eunyoung Lee <ey928.lee@samsung.com>
- * Junkyu Han <junkyu.han@samsung.com>
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <peripheral_io.h>
-#include <sys/time.h>
-
-#include "log.h"
-#include "resource_internal.h"
-
-void resource_close_infrared_motion_sensor(int pin_num)
-{
- if (!resource_get_info(pin_num)->opened) return;
-
- _I("Infrared Motion Sensor is finishing...");
- peripheral_gpio_close(resource_get_info(pin_num)->sensor_h);
- resource_get_info(pin_num)->opened = 0;
-}
-
-int resource_read_infrared_motion_sensor(int pin_num, uint32_t *out_value)
-{
- int ret = PERIPHERAL_ERROR_NONE;
-
- if (!resource_get_info(pin_num)->opened) {
- ret = peripheral_gpio_open(pin_num, &resource_get_info(pin_num)->sensor_h);
- retv_if(!resource_get_info(pin_num)->sensor_h, -1);
-
- ret = peripheral_gpio_set_direction(resource_get_info(pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_IN);
- retv_if(ret != 0, -1);
-
- resource_get_info(pin_num)->opened = 1;
- resource_get_info(pin_num)->close = resource_close_infrared_motion_sensor;
- }
-
- ret = peripheral_gpio_read(resource_get_info(pin_num)->sensor_h, out_value);
- retv_if(ret < 0, -1);
-
- return 0;
-}
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- * Geunsun Lee <gs86.lee@samsung.com>
- * Eunyoung Lee <ey928.lee@samsung.com>
- * Junkyu Han <junkyu.han@samsung.com>
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <peripheral_io.h>
-#include <sys/time.h>
-
-#include "log.h"
-#include "resource_internal.h"
-
-void resource_close_infrared_obstacle_avoidance_sensor(int pin_num)
-{
- if (!resource_get_info(pin_num)->opened) return;
-
- _I("Infrared Obstacle Avoidance Sensor is finishing...");
- peripheral_gpio_close(resource_get_info(pin_num)->sensor_h);
- resource_get_info(pin_num)->opened = 0;
-}
-
-int resource_read_infrared_obstacle_avoidance_sensor(int pin_num, uint32_t *out_value)
-{
- int ret = PERIPHERAL_ERROR_NONE;
-
- if (!resource_get_info(pin_num)->opened) {
- ret = peripheral_gpio_open(pin_num, &resource_get_info(pin_num)->sensor_h);
- retv_if(!resource_get_info(pin_num)->sensor_h, -1);
-
- ret = peripheral_gpio_set_direction(resource_get_info(pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_IN);
- retv_if(ret != 0, -1);
-
- resource_get_info(pin_num)->opened = 1;
- resource_get_info(pin_num)->close = resource_close_infrared_obstacle_avoidance_sensor;
- }
-
- ret = peripheral_gpio_read(resource_get_info(pin_num)->sensor_h, out_value);
- retv_if(ret < 0, -1);
-
- _I("Infrared Obstacle Avoidance Sensor Value : %d", *out_value);
-
- *out_value = !*out_value;
-
- return 0;
-}
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- * Geunsun Lee <gs86.lee@samsung.com>
- * Eunyoung Lee <ey928.lee@samsung.com>
- * Junkyu Han <junkyu.han@samsung.com>
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <peripheral_io.h>
-
-#include "log.h"
-#include "resource_internal.h"
-
-void resource_close_led(int pin_num)
-{
- if (!resource_get_info(pin_num)->opened) return;
-
- _I("LED is finishing...");
- peripheral_gpio_close(resource_get_info(pin_num)->sensor_h);
- resource_get_info(pin_num)->opened = 0;
-}
-
-int resource_write_led(int pin_num, int write_value)
-{
- int ret = PERIPHERAL_ERROR_NONE;
-
- if (!resource_get_info(pin_num)->opened) {
- ret = peripheral_gpio_open(pin_num, &resource_get_info(pin_num)->sensor_h);
- retv_if(!resource_get_info(pin_num)->sensor_h, -1);
-
- ret = peripheral_gpio_set_direction(resource_get_info(pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_OUT_INITIALLY_LOW);
- retv_if(ret != 0, -1);
-
- resource_get_info(pin_num)->opened = 1;
- resource_get_info(pin_num)->close = resource_close_led;
- }
-
- ret = peripheral_gpio_write(resource_get_info(pin_num)->sensor_h, write_value);
- retv_if(ret < 0, -1);
-
- _I("LED Value : %s", write_value ? "ON":"OFF");
-
- return 0;
-}
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- * Geunsun Lee <gs86.lee@samsung.com>
- * Eunyoung Lee <ey928.lee@samsung.com>
- * Junkyu Han <junkyu.han@samsung.com>
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdlib.h>
-#include <unistd.h>
-
-#include "log.h"
-#include "resource_internal.h"
-
-void resource_close_rain_sensor(int pin_num)
-{
- if (!resource_get_info(pin_num)->opened) return;
-
- _I("Rain Sensor is finishing...");
- peripheral_gpio_close(resource_get_info(pin_num)->sensor_h);
- resource_get_info(pin_num)->opened = 0;
-}
-
-int resource_read_rain_sensor(int pin_num, uint32_t *out_value)
-{
- int ret = PERIPHERAL_ERROR_NONE;
-
- if (!resource_get_info(pin_num)->opened) {
- ret = peripheral_gpio_open(pin_num, &resource_get_info(pin_num)->sensor_h);
- retv_if(!resource_get_info(pin_num)->sensor_h, -1);
-
- ret = peripheral_gpio_set_direction(resource_get_info(pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_IN);
- retv_if(ret != 0, -1);
-
- resource_get_info(pin_num)->opened = 1;
- resource_get_info(pin_num)->close = resource_close_flame_sensor;
- }
-
- /**
- * This model(FC-37 + YL-38) normally outputs 1, and outputs 0 as out_value when a rain is detected.
- */
- ret = peripheral_gpio_read(resource_get_info(pin_num)->sensor_h, out_value);
- retv_if(ret < 0, -1);
-
- *out_value = !*out_value;
-
- return 0;
-}
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- * Geunsun Lee <gs86.lee@samsung.com>
- * Eunyoung Lee <ey928.lee@samsung.com>
- * Junkyu Han <junkyu.han@samsung.com>
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <peripheral_io.h>
-#include <sys/time.h>
-
-#include "log.h"
-#include "resource_internal.h"
-
-void resource_close_sound_detection_sensor(int pin_num)
-{
- if (!resource_get_info(pin_num)->opened) return;
-
- _I("Sound Sensor is finishing...");
- peripheral_gpio_close(resource_get_info(pin_num)->sensor_h);
- resource_get_info(pin_num)->opened = 0;
-}
-
-int resource_read_sound_detection_sensor(int pin_num, uint32_t *out_value)
-{
- int ret = PERIPHERAL_ERROR_NONE;
-
- if (!resource_get_info(pin_num)->opened) {
- ret = peripheral_gpio_open(pin_num, &resource_get_info(pin_num)->sensor_h);
- retv_if(!resource_get_info(pin_num)->sensor_h, -1);
-
- ret = peripheral_gpio_set_direction(resource_get_info(pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_IN);
- retv_if(ret != 0, -1);
-
- resource_get_info(pin_num)->opened = 1;
- resource_get_info(pin_num)->close = resource_close_sound_detection_sensor;
- }
-
- /**
- * This model(NS-SDSM) normally outputs 1, and outputs 0 as out_value when sound is detected.
- */
- ret = peripheral_gpio_read(resource_get_info(pin_num)->sensor_h, out_value);
- retv_if(ret < 0, -1);
-
- *out_value = !*out_value;
-
- return 0;
-}
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- * Geunsun Lee <gs86.lee@samsung.com>
- * Eunyoung Lee <ey928.lee@samsung.com>
- * Junkyu Han <junkyu.han@samsung.com>
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <peripheral_io.h>
-#include <sys/time.h>
-
-#include "log.h"
-#include "resource_internal.h"
-
-void resource_close_tilt_sensor(int pin_num)
-{
- if (!resource_get_info(pin_num)->opened) return;
-
- _I("Infrared Motion Sensor is finishing...");
- peripheral_gpio_close(resource_get_info(pin_num)->sensor_h);
- resource_get_info(pin_num)->opened = 0;
-}
-
-int resource_read_tilt_sensor(int pin_num, uint32_t *out_value)
-{
- int ret = PERIPHERAL_ERROR_NONE;
-
- if (!resource_get_info(pin_num)->opened) {
- ret = peripheral_gpio_open(pin_num, &resource_get_info(pin_num)->sensor_h);
- retv_if(!resource_get_info(pin_num)->sensor_h, -1);
-
- ret = peripheral_gpio_set_direction(resource_get_info(pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_IN);
- retv_if(ret != 0, -1);
-
- resource_get_info(pin_num)->opened = 1;
- resource_get_info(pin_num)->close = resource_close_tilt_sensor;
- }
-
- /**
- * This model(SZH-EK084) normally outputs 1, and outputs 0 as out_value when the sensor is tilted.
- */
- ret = peripheral_gpio_read(resource_get_info(pin_num)->sensor_h, out_value);
- retv_if(ret < 0, -1);
-
- *out_value = !*out_value;
-
- return 0;
-}
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- * Geunsun Lee <gs86.lee@samsung.com>
- * Eunyoung Lee <ey928.lee@samsung.com>
- * Junkyu Han <junkyu.han@samsung.com>
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <peripheral_io.h>
-#include <sys/time.h>
-
-#include "log.h"
-#include "resource_internal.h"
-
-void resource_close_touch_sensor(int pin_num)
-{
- if (!resource_get_info(pin_num)->opened) return;
-
- _I("Touch Sensor is finishing...");
- peripheral_gpio_close(resource_get_info(pin_num)->sensor_h);
- resource_get_info(pin_num)->opened = 0;
-}
-
-int resource_read_touch_sensor(int pin_num, uint32_t *out_value)
-{
- int ret = PERIPHERAL_ERROR_NONE;
-
- if (!resource_get_info(pin_num)->opened) {
- _I("Touch sensor is initializing...");
-
- ret = peripheral_gpio_open(pin_num, &resource_get_info(pin_num)->sensor_h);
- retv_if(!resource_get_info(pin_num)->sensor_h, -1);
-
- ret = peripheral_gpio_set_direction(resource_get_info(pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_IN);
- retv_if(ret != 0, -1);
-
- resource_get_info(pin_num)->opened = 1;
- resource_get_info(pin_num)->close = resource_close_touch_sensor;
- }
-
- ret = peripheral_gpio_read(resource_get_info(pin_num)->sensor_h, out_value);
- retv_if(ret < 0, -1);
-
- _I("Touch Sensor Value : %d", *out_value);
-
- return 0;
-}
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- * Geunsun Lee <gs86.lee@samsung.com>
- * Eunyoung Lee <ey928.lee@samsung.com>
- * Junkyu Han <junkyu.han@samsung.com>
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <peripheral_io.h>
-#include <sys/time.h>
-#include <gio/gio.h>
-
-#include "log.h"
-#include "resource_internal.h"
-
-void resource_close_ultrasonic_sensor_trig(int trig_pin_num)
-{
- if (!resource_get_info(trig_pin_num)->opened) return;
-
- _I("Ultrasonic sensor's trig is finishing...");
-
- peripheral_gpio_close(resource_get_info(trig_pin_num)->sensor_h);
- resource_get_info(trig_pin_num)->opened = 0;
-}
-
-void resource_close_ultrasonic_sensor_echo(int echo_pin_num)
-{
- if (!resource_get_info(echo_pin_num)->opened) return;
-
- _I("Ultrasonic sensor's echo is finishing...");
-
- peripheral_gpio_close(resource_get_info(echo_pin_num)->sensor_h);
- resource_get_info(echo_pin_num)->opened = 0;
-}
-
-static unsigned long long _get_timestamp(void)
-{
- struct timespec t;
- clock_gettime(CLOCK_REALTIME, &t);
- return ((unsigned long long)(t.tv_sec)*1000000000LL + t.tv_nsec) / 1000;
-}
-
-static void _resource_read_ultrasonic_sensor_cb(peripheral_gpio_h gpio, peripheral_error_e error, void *user_data)
-{
- float dist = 0;
- uint32_t value;
- static unsigned long long prev = 0;
- unsigned long long now = _get_timestamp();
- resource_read_s *resource_read_info = user_data;
-
- ret_if(!resource_read_info);
- ret_if(!resource_read_info->cb);
-
- peripheral_gpio_read(gpio, &value);
-
- if (prev > 0 && value == 0) {
- dist = now - prev;
- dist = (dist * 34300) / 2000000;
- _I("Measured Distance : %0.2fcm\n", dist);
-
- resource_read_info->cb(dist, resource_read_info->data);
- peripheral_gpio_unset_interrupted_cb(resource_get_info(resource_read_info->pin_num)->sensor_h);
- free(resource_read_info);
- }
-
- prev = now;
-}
-
-int resource_read_ultrasonic_sensor(int trig_pin_num, int echo_pin_num, resource_read_cb cb, void *data)
-{
- int ret = 0;
- resource_read_s *resource_read_info = NULL;
-
- resource_read_info = calloc(1, sizeof(resource_read_s));
- retv_if(!resource_read_info, -1);
- resource_read_info->cb = cb;
- resource_read_info->data = data;
- resource_read_info->pin_num = echo_pin_num;
-
- if (!resource_get_info(trig_pin_num)->opened) {
- _I("Ultrasonic sensor's trig is initializing...");
-
- ret = peripheral_gpio_open(trig_pin_num, &resource_get_info(trig_pin_num)->sensor_h);
- retv_if(!resource_get_info(trig_pin_num)->sensor_h, -1);
-
- ret = peripheral_gpio_set_direction(resource_get_info(trig_pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_OUT_INITIALLY_LOW);
- retv_if(ret != 0, -1);
-
- resource_get_info(trig_pin_num)->opened = 1;
- resource_get_info(trig_pin_num)->close = resource_close_ultrasonic_sensor_trig;
- }
-
- if (!resource_get_info(echo_pin_num)->opened) {
- _I("Ultrasonic sensor's echo is initializing...");
-
- ret = peripheral_gpio_open(echo_pin_num, &resource_get_info(echo_pin_num)->sensor_h);
- retv_if(!resource_get_info(echo_pin_num)->sensor_h, -1);
-
- ret = peripheral_gpio_set_direction(resource_get_info(echo_pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_IN);
- retv_if(ret != 0, -1);
-
- ret = peripheral_gpio_set_edge_mode(resource_get_info(echo_pin_num)->sensor_h, PERIPHERAL_GPIO_EDGE_BOTH);
- retv_if(ret != 0, -1);
-
- resource_get_info(echo_pin_num)->opened = 1;
- resource_get_info(echo_pin_num)->close = resource_close_ultrasonic_sensor_echo;
- }
-
- if (resource_get_info(echo_pin_num)->sensor_h) {
- ret = peripheral_gpio_set_interrupted_cb(resource_get_info(echo_pin_num)->sensor_h, _resource_read_ultrasonic_sensor_cb, resource_read_info);
- retv_if(ret != 0, -1);
- }
-
- ret = peripheral_gpio_write(resource_get_info(trig_pin_num)->sensor_h, 0);
- retv_if(ret < 0, -1);
-
- ret = peripheral_gpio_write(resource_get_info(trig_pin_num)->sensor_h, 1);
- retv_if(ret < 0, -1);
-
- ret = peripheral_gpio_write(resource_get_info(trig_pin_num)->sensor_h, 0);
- retv_if(ret < 0, -1);
-
- return 0;
-}
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- * Geunsun Lee <gs86.lee@samsung.com>
- * Eunyoung Lee <ey928.lee@samsung.com>
- * Junkyu Han <junkyu.han@samsung.com>
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <peripheral_io.h>
-#include <sys/time.h>
-
-#include "log.h"
-#include "resource_internal.h"
-
-void resource_close_vibration_sensor(int pin_num)
-{
- if (!resource_get_info(pin_num)->opened) return;
-
- _I("Vibration Sensor is finishing...");
- peripheral_gpio_close(resource_get_info(pin_num)->sensor_h);
- resource_get_info(pin_num)->opened = 0;
-}
-
-int resource_read_vibration_sensor(int pin_num, uint32_t *out_value)
-{
- int ret = PERIPHERAL_ERROR_NONE;
-
- if (!resource_get_info(pin_num)->opened) {
- ret = peripheral_gpio_open(pin_num, &resource_get_info(pin_num)->sensor_h);
- retv_if(!resource_get_info(pin_num)->sensor_h, -1);
-
- ret = peripheral_gpio_set_direction(resource_get_info(pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_IN);
- retv_if(ret != 0, -1);
-
- resource_get_info(pin_num)->opened = 1;
- resource_get_info(pin_num)->close = resource_close_vibration_sensor;
- }
-
- ret = peripheral_gpio_read(resource_get_info(pin_num)->sensor_h, out_value);
- retv_if(ret < 0, -1);
-
- return 0;
-}
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- * Geunsun Lee <gs86.lee@samsung.com>
- * Eunyoung Lee <ey928.lee@samsung.com>
- * Junkyu Han <junkyu.han@samsung.com>
- * Jeonghoon Park <jh1979.park@samsung.com>
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdbool.h>
-#include <curl/curl.h>
-#include <glib-object.h>
-#include <json-glib/json-glib.h>
-#include "log.h"
-#include "webutil.h"
-
-#define URI_PATH_LEN 64
-
-typedef struct _wu_json_handle {
- JsonBuilder *builder;
- bool is_begin;
- bool is_end;
-} wu_json_handle;
-
-static wu_json_handle Json_h = {NULL, false, false};
-
-static size_t _response_write_callback(char *ptr, size_t size, size_t nmemb, void *userdata)
-{
- size_t res_size = 0;
-
- res_size = size*nmemb;
-
- if (res_size > 0)
- _I("POST response : %s", ptr);
- /* What should we do here, if response body has negative message? */
-
- return res_size;
-}
-
-int web_util_noti_init(void)
-{
- int ret = 0;
- CURLcode result;
- result = curl_global_init(CURL_GLOBAL_DEFAULT);
- if (result != CURLE_OK) {
- _E("curl_global_init() failed: %s",
- curl_easy_strerror(result));
- ret = -1;
- }
- return ret;
-}
-
-void web_util_noti_fini(void)
-{
- curl_global_cleanup();
- return;
-}
-
-int web_util_noti_post(const char *resource, const char *json_data)
-{
- int ret = 0;
- CURL *curl = NULL;
- CURLcode response = CURLE_OK;
- struct curl_slist *headers = NULL;
-
- retv_if(resource == NULL, -1);
- retv_if(json_data == NULL, -1);
-
- _I("server : %s", resource);
- _I("json_data : %s", json_data);
-
- curl = curl_easy_init();
-
- if (!curl) {
- _E("fail to init curl");
- return -1;
- }
-
- headers = curl_slist_append(headers, "Accept: application/json");
- headers = curl_slist_append(headers, "Content-Type: application/json");
-
- curl_easy_setopt(curl, CURLOPT_URL, resource);
- curl_easy_setopt(curl, CURLOPT_POST, 1L);
- curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
- curl_easy_setopt(curl, CURLOPT_POSTFIELDS, json_data);
- curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, _response_write_callback);
-
- response = curl_easy_perform(curl);
-
- if (response != CURLE_OK) {
- _E("curl_easy_perform() failed: %s",
- curl_easy_strerror(response));
- /* What should we do here, if response is kind of errors? */
- ret = -1;
- }
-
- curl_slist_free_all(headers);
- curl_easy_cleanup(curl);
-
- return ret;
-}
-
-
-int web_util_json_init(void)
-{
- if (Json_h.builder)
- g_object_unref(Json_h.builder);
-
- Json_h.is_begin = false;
- Json_h.is_end = false;
- Json_h.builder = json_builder_new();
- retv_if(Json_h.builder == NULL, -1);
-
- return 0;
-}
-
-int web_util_json_fini(void)
-{
-
- if (Json_h.builder) {
- g_object_unref(Json_h.builder);
- Json_h.builder = NULL;
- }
-
- Json_h.is_begin = false;
- Json_h.is_end = false;
-
- return 0;
-}
-
-int web_util_json_data_array_begin(void)
-{
- retv_if(Json_h.builder == NULL, -1);
- retv_if(Json_h.is_begin == true, -1);
- retv_if(Json_h.is_end == true, -1);
-
- Json_h.is_begin = true;
-
- /*
- {
- SensorsDataList : [ SensorData ]
- }
- */
-
- json_builder_begin_object(Json_h.builder);
- json_builder_set_member_name(Json_h.builder, "SensorDataList");
- json_builder_begin_array(Json_h.builder);
-
- return 0;
-}
-
-int web_util_json_data_array_end(void)
-{
- retv_if(Json_h.builder == NULL, -1);
- retv_if(Json_h.is_begin == false, -1);
- retv_if(Json_h.is_end == true, -1);
-
- json_builder_end_array(Json_h.builder);
- json_builder_end_object(Json_h.builder);
- Json_h.is_end = true;
-
- return 0;
-}
-
-int web_util_json_add_sensor_data(const char* sensorpi_id, web_util_sensor_data_s *sensor_data)
-{
- const char n_id[] = "SensorPiID";
- const char n_motion[] = "Motion";
- const char n_flame[] = "Flame";
- const char n_hum[] = "Humidity";
- const char n_temp[] = "Temperature";
- const char n_vib[] = "Vibration";
- const char n_co2[] = "CO2";
- const char n_sound[] = "SoundLevel";
- const char n_tilt[] = "Tilt";
- const char n_light[] = "Light";
- const char n_collision[] = "Collision";
- const char n_obstacle[] = "Obstacle";
- const char n_distance[] = "Distance";
- const char n_rain[] = "Rain";
- const char n_touch[] = "Touch";
- const char n_gas[] = "Gas";
- const char n_e_sensor[] = "SensorEnabled";
- const char n_hash[] = "Hash";
-
- retv_if(!sensorpi_id, -1);
- retv_if(Json_h.builder == NULL, -1);
- retv_if(Json_h.is_begin == false, -1);
- retv_if(Json_h.is_end == true, -1);
- retv_if(sensor_data == NULL, -1);
-
- /* JSON structure :
- {
- SensorPiID: string,
- Motion: boolean,
- Flame: boolean,
- Humidity: double,
- Temperature: double,
- Vibration: boolean,
- CO2: double,
- SoundLevel: int,
- Tilt: int,
- Light: int,
- Collision: int,
- Obstacle: int,
- Distance: double,
- Rain: int,
- Touch: int,
- Gas: int,
- SensorEnabled: [Motion, ],
- Hash: string,
- }
- */
-
-
- json_builder_begin_object(Json_h.builder);
-
- json_builder_set_member_name(Json_h.builder, n_id);
- json_builder_add_string_value(Json_h.builder, sensorpi_id);
-
- if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_MOTION) {
- json_builder_set_member_name(Json_h.builder, n_motion);
- json_builder_add_int_value(Json_h.builder, sensor_data->motion);
- }
-
- if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_FLAME) {
- json_builder_set_member_name(Json_h.builder, n_flame);
- json_builder_add_int_value(Json_h.builder, sensor_data->flame);
- }
-
- if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_HUMIDITY) {
- json_builder_set_member_name(Json_h.builder, n_hum);
- json_builder_add_double_value(Json_h.builder, sensor_data->humidity);
- }
-
- if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_TEMPERATURE) {
- json_builder_set_member_name(Json_h.builder, n_temp);
- json_builder_add_double_value(Json_h.builder, sensor_data->temperature);
- }
-
- if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_VIB) {
- json_builder_set_member_name(Json_h.builder, n_vib);
- json_builder_add_int_value(Json_h.builder, sensor_data->virbration);
- }
-
- if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_CO2) {
- json_builder_set_member_name(Json_h.builder, n_co2);
- json_builder_add_double_value(Json_h.builder, sensor_data->co2);
- }
-
- if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_SOUND) {
- json_builder_set_member_name(Json_h.builder, n_sound);
- json_builder_add_int_value(Json_h.builder, sensor_data->soundlevel);
- }
-
- if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_TILT) {
- json_builder_set_member_name(Json_h.builder, n_tilt);
- json_builder_add_int_value(Json_h.builder, sensor_data->tilt);
- }
-
- if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_LIGHT) {
- json_builder_set_member_name(Json_h.builder, n_light);
- json_builder_add_int_value(Json_h.builder, sensor_data->light);
- }
-
- if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_COLLISION) {
- json_builder_set_member_name(Json_h.builder, n_collision);
- json_builder_add_int_value(Json_h.builder, sensor_data->collision);
- }
-
- if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_OBSTACLE) {
- json_builder_set_member_name(Json_h.builder, n_obstacle);
- json_builder_add_int_value(Json_h.builder, sensor_data->obstacle);
- }
-
- if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_ULTRASONIC_DISTANCE) {
- json_builder_set_member_name(Json_h.builder, n_distance);
- json_builder_add_double_value(Json_h.builder, sensor_data->distance);
- }
-
- if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_RAIN) {
- json_builder_set_member_name(Json_h.builder, n_rain);
- json_builder_add_int_value(Json_h.builder, sensor_data->rain);
- }
-
- if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_TOUCH) {
- json_builder_set_member_name(Json_h.builder, n_touch);
- json_builder_add_int_value(Json_h.builder, sensor_data->touch);
- }
-
- if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_GAS) {
- json_builder_set_member_name(Json_h.builder, n_gas);
- json_builder_add_int_value(Json_h.builder, sensor_data->gas);
- }
-
- json_builder_set_member_name(Json_h.builder, n_e_sensor);
- json_builder_begin_array(Json_h.builder);
-
- if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_MOTION)
- json_builder_add_string_value(Json_h.builder, n_motion);
-
- if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_FLAME)
- json_builder_add_string_value(Json_h.builder, n_flame);
-
- if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_HUMIDITY)
- json_builder_add_string_value(Json_h.builder, n_hum);
-
- if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_TEMPERATURE)
- json_builder_add_string_value(Json_h.builder, n_temp);
-
- if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_VIB)
- json_builder_add_string_value(Json_h.builder, n_vib);
-
- if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_CO2)
- json_builder_add_string_value(Json_h.builder, n_co2);
-
- if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_SOUND)
- json_builder_add_string_value(Json_h.builder, n_sound);
-
- if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_TILT)
- json_builder_add_string_value(Json_h.builder, n_tilt);
-
- if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_LIGHT)
- json_builder_add_string_value(Json_h.builder, n_light);
-
- if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_COLLISION)
- json_builder_add_string_value(Json_h.builder, n_collision);
-
- if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_OBSTACLE)
- json_builder_add_string_value(Json_h.builder, n_obstacle);
-
- if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_ULTRASONIC_DISTANCE)
- json_builder_add_string_value(Json_h.builder, n_distance);
-
- if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_RAIN)
- json_builder_add_string_value(Json_h.builder, n_rain);
-
- if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_TOUCH)
- json_builder_add_string_value(Json_h.builder, n_touch);
-
- if (sensor_data->enabled_sensor & WEB_UTIL_SENSOR_GAS)
- json_builder_add_string_value(Json_h.builder, n_gas);
-
- json_builder_end_array(Json_h.builder);
-
- if (sensor_data->hash) {
- json_builder_set_member_name(Json_h.builder, n_hash);
- json_builder_add_string_value(Json_h.builder, sensor_data->hash);
- }
-
- json_builder_end_object(Json_h.builder);
-
- return 0;
-}
-
-char *web_util_get_json_string(void)
-{
- JsonGenerator *gen = NULL;
- JsonNode *root = NULL;
- char *str = NULL;
-
- retv_if(Json_h.builder == NULL, NULL);
- retv_if(Json_h.is_begin == false, NULL);
- retv_if(Json_h.is_end == false, NULL);
-
- root = json_builder_get_root(Json_h.builder);
- retv_if(root == NULL, NULL);
-
- gen = json_generator_new();
- goto_if(gen == NULL, error_release_all);
- json_generator_set_root(gen, root);
-
- str = json_generator_to_data(gen, NULL);
-
- return str;
-
-error_release_all:
- if (root)
- json_node_free(root);
-
- if (gen)
- g_object_unref(gen);
-
- return NULL;
-}
-
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<manifest xmlns="http://tizen.org/ns/packages" api-version="3.0" package="@ORG_PREFIX@.@PROJECT_NAME@" version="1.0.0">
- <profile name="mobile"/>
- <author email="jinny.yoon@samsung.com" href="www.samsung.com">Jin Yoon</author>
- <author email="gs86.lee@samsung.com" href="www.samsung.com">Geunsun Lee</author>
- <author email="ey928.lee@samsung.com" href="www.samsung.com">Eunyoung Lee</author>
- <author email="junkyu.han@samsung.com" href="www.samsung.com">Junkyu Han</author>
- <service-application appid="@ORG_PREFIX@.@PROJECT_NAME@" auto-restart="true" exec="@PROJECT_NAME@" multiple="false" nodisplay="true" on-boot="true" taskmanage="false" type="capp">
- <label>@APP_LABEL@</label>
- <icon>@PROJECT_NAME@.png</icon>
- </service-application>
- <privileges>
- <privilege>http://tizen.org/privilege/network.get</privilege>
- <privilege>http://tizen.org/privilege/internet</privilege>
- </privileges>
-</manifest>