--- /dev/null
+Taesoo Jun <steve.jun@samsung.com>
+Jonghoon Han <jonghoon.han@samsung.com>
+JuHyun Kim <jh8212.kim@samsung.com>
+
--- /dev/null
+cmake_minimum_required(VERSION 2.6)
+project(sensor_framework_main CXX)
+
+include(FindPkgConfig)
+pkg_check_modules(rpkgs REQUIRED sf_common vconf)
+add_definitions(${rpkgs_CFLAGS})
+
+# to install pkgconfig setup file.
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(EXEC_PREFIX "\${prefix}")
+SET(LIBDIR "\${prefix}/lib")
+SET(INCLUDEDIR "\${prefix}/include")
+SET(VERSION 1.0)
+
+set(PROJECT_MAJOR_VERSION "0")
+set(PROJECT_MINOR_VERSION "2")
+set(PROJECT_RELEASE_VERSION "1")
+set(CMAKE_VERBOSE_MAKEFILE OFF)
+
+add_definitions(-Wall -O3 -omit-frame-pointer)
+add_definitions(-Wall -g -D_DEBUG)
+
+FIND_PROGRAM(UNAME NAMES uname)
+EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH")
+IF("${ARCH}" MATCHES "^arm.*")
+ ADD_DEFINITIONS("-DTARGET")
+ MESSAGE("add -DTARGET")
+ELSE("${ARCH}" MATCHES "^arm.*")
+ ADD_DEFINITIONS("-DSIMULATOR")
+ MESSAGE("add -DSIMULATOR")
+ENDIF("${ARCH}" MATCHES "^arm.*")
+
+add_subdirectory(server)
+
+IF("${ARCH}" MATCHES "^arm.*")
+ CONFIGURE_FILE(sf_sensor.conf.in sf_sensor.conf @ONLY)
+ CONFIGURE_FILE(sf_filter.conf.in sf_filter.conf @ONLY)
+ CONFIGURE_FILE(sf_processor.conf.in sf_processor.conf @ONLY)
+ CONFIGURE_FILE(sf_data_stream.conf.in sf_data_stream.conf @ONLY)
+ install(FILES
+ sf_sensor.conf
+ sf_filter.conf
+ sf_processor.conf
+ sf_data_stream.conf
+ DESTINATION etc)
+ELSE("${ARCH}" MATCHES "^arm.*")
+ CONFIGURE_FILE(sf_sensor_sim.conf.in sf_sensor.conf @ONLY)
+ CONFIGURE_FILE(sf_filter_sim.conf.in sf_filter.conf @ONLY)
+ CONFIGURE_FILE(sf_processor_sim.conf.in sf_processor.conf @ONLY)
+ CONFIGURE_FILE(sf_data_stream_sim.conf.in sf_data_stream.conf @ONLY)
+ install(FILES
+ sf_sensor.conf
+ sf_filter.conf
+ sf_processor.conf
+ sf_data_stream.conf
+ DESTINATION etc)
+ENDIF("${ARCH}" MATCHES "^arm.*")
+
+install(PROGRAMS sfsvc DESTINATION /etc/rc.d/init.d)
--- /dev/null
+Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+\r
+ Apache License\r
+ Version 2.0, January 2004\r
+ http://www.apache.org/licenses/\r
+\r
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\r
+\r
+ 1. Definitions.\r
+\r
+ "License" shall mean the terms and conditions for use, reproduction,\r
+ and distribution as defined by Sections 1 through 9 of this document.\r
+\r
+ "Licensor" shall mean the copyright owner or entity authorized by\r
+ the copyright owner that is granting the License.\r
+\r
+ "Legal Entity" shall mean the union of the acting entity and all\r
+ other entities that control, are controlled by, or are under common\r
+ control with that entity. For the purposes of this definition,\r
+ "control" means (i) the power, direct or indirect, to cause the\r
+ direction or management of such entity, whether by contract or\r
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the\r
+ outstanding shares, or (iii) beneficial ownership of such entity.\r
+\r
+ "You" (or "Your") shall mean an individual or Legal Entity\r
+ exercising permissions granted by this License.\r
+\r
+ "Source" form shall mean the preferred form for making modifications,\r
+ including but not limited to software source code, documentation\r
+ source, and configuration files.\r
+\r
+ "Object" form shall mean any form resulting from mechanical\r
+ transformation or translation of a Source form, including but\r
+ not limited to compiled object code, generated documentation,\r
+ and conversions to other media types.\r
+\r
+ "Work" shall mean the work of authorship, whether in Source or\r
+ Object form, made available under the License, as indicated by a\r
+ copyright notice that is included in or attached to the work\r
+ (an example is provided in the Appendix below).\r
+\r
+ "Derivative Works" shall mean any work, whether in Source or Object\r
+ form, that is based on (or derived from) the Work and for which the\r
+ editorial revisions, annotations, elaborations, or other modifications\r
+ represent, as a whole, an original work of authorship. For the purposes\r
+ of this License, Derivative Works shall not include works that remain\r
+ separable from, or merely link (or bind by name) to the interfaces of,\r
+ the Work and Derivative Works thereof.\r
+\r
+ "Contribution" shall mean any work of authorship, including\r
+ the original version of the Work and any modifications or additions\r
+ to that Work or Derivative Works thereof, that is intentionally\r
+ submitted to Licensor for inclusion in the Work by the copyright owner\r
+ or by an individual or Legal Entity authorized to submit on behalf of\r
+ the copyright owner. For the purposes of this definition, "submitted"\r
+ means any form of electronic, verbal, or written communication sent\r
+ to the Licensor or its representatives, including but not limited to\r
+ communication on electronic mailing lists, source code control systems,\r
+ and issue tracking systems that are managed by, or on behalf of, the\r
+ Licensor for the purpose of discussing and improving the Work, but\r
+ excluding communication that is conspicuously marked or otherwise\r
+ designated in writing by the copyright owner as "Not a Contribution."\r
+\r
+ "Contributor" shall mean Licensor and any individual or Legal Entity\r
+ on behalf of whom a Contribution has been received by Licensor and\r
+ subsequently incorporated within the Work.\r
+\r
+ 2. Grant of Copyright License. Subject to the terms and conditions of\r
+ this License, each Contributor hereby grants to You a perpetual,\r
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+ copyright license to reproduce, prepare Derivative Works of,\r
+ publicly display, publicly perform, sublicense, and distribute the\r
+ Work and such Derivative Works in Source or Object form.\r
+\r
+ 3. Grant of Patent License. Subject to the terms and conditions of\r
+ this License, each Contributor hereby grants to You a perpetual,\r
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+ (except as stated in this section) patent license to make, have made,\r
+ use, offer to sell, sell, import, and otherwise transfer the Work,\r
+ where such license applies only to those patent claims licensable\r
+ by such Contributor that are necessarily infringed by their\r
+ Contribution(s) alone or by combination of their Contribution(s)\r
+ with the Work to which such Contribution(s) was submitted. If You\r
+ institute patent litigation against any entity (including a\r
+ cross-claim or counterclaim in a lawsuit) alleging that the Work\r
+ or a Contribution incorporated within the Work constitutes direct\r
+ or contributory patent infringement, then any patent licenses\r
+ granted to You under this License for that Work shall terminate\r
+ as of the date such litigation is filed.\r
+\r
+ 4. Redistribution. You may reproduce and distribute copies of the\r
+ Work or Derivative Works thereof in any medium, with or without\r
+ modifications, and in Source or Object form, provided that You\r
+ meet the following conditions:\r
+\r
+ (a) You must give any other recipients of the Work or\r
+ Derivative Works a copy of this License; and\r
+\r
+ (b) You must cause any modified files to carry prominent notices\r
+ stating that You changed the files; and\r
+\r
+ (c) You must retain, in the Source form of any Derivative Works\r
+ that You distribute, all copyright, patent, trademark, and\r
+ attribution notices from the Source form of the Work,\r
+ excluding those notices that do not pertain to any part of\r
+ the Derivative Works; and\r
+\r
+ (d) If the Work includes a "NOTICE" text file as part of its\r
+ distribution, then any Derivative Works that You distribute must\r
+ include a readable copy of the attribution notices contained\r
+ within such NOTICE file, excluding those notices that do not\r
+ pertain to any part of the Derivative Works, in at least one\r
+ of the following places: within a NOTICE text file distributed\r
+ as part of the Derivative Works; within the Source form or\r
+ documentation, if provided along with the Derivative Works; or,\r
+ within a display generated by the Derivative Works, if and\r
+ wherever such third-party notices normally appear. The contents\r
+ of the NOTICE file are for informational purposes only and\r
+ do not modify the License. You may add Your own attribution\r
+ notices within Derivative Works that You distribute, alongside\r
+ or as an addendum to the NOTICE text from the Work, provided\r
+ that such additional attribution notices cannot be construed\r
+ as modifying the License.\r
+\r
+ You may add Your own copyright statement to Your modifications and\r
+ may provide additional or different license terms and conditions\r
+ for use, reproduction, or distribution of Your modifications, or\r
+ for any such Derivative Works as a whole, provided Your use,\r
+ reproduction, and distribution of the Work otherwise complies with\r
+ the conditions stated in this License.\r
+\r
+ 5. Submission of Contributions. Unless You explicitly state otherwise,\r
+ any Contribution intentionally submitted for inclusion in the Work\r
+ by You to the Licensor shall be under the terms and conditions of\r
+ this License, without any additional terms or conditions.\r
+ Notwithstanding the above, nothing herein shall supersede or modify\r
+ the terms of any separate license agreement you may have executed\r
+ with Licensor regarding such Contributions.\r
+\r
+ 6. Trademarks. This License does not grant permission to use the trade\r
+ names, trademarks, service marks, or product names of the Licensor,\r
+ except as required for reasonable and customary use in describing the\r
+ origin of the Work and reproducing the content of the NOTICE file.\r
+\r
+ 7. Disclaimer of Warranty. Unless required by applicable law or\r
+ agreed to in writing, Licensor provides the Work (and each\r
+ Contributor provides its Contributions) on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\r
+ implied, including, without limitation, any warranties or conditions\r
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\r
+ PARTICULAR PURPOSE. You are solely responsible for determining the\r
+ appropriateness of using or redistributing the Work and assume any\r
+ risks associated with Your exercise of permissions under this License.\r
+\r
+ 8. Limitation of Liability. In no event and under no legal theory,\r
+ whether in tort (including negligence), contract, or otherwise,\r
+ unless required by applicable law (such as deliberate and grossly\r
+ negligent acts) or agreed to in writing, shall any Contributor be\r
+ liable to You for damages, including any direct, indirect, special,\r
+ incidental, or consequential damages of any character arising as a\r
+ result of this License or out of the use or inability to use the\r
+ Work (including but not limited to damages for loss of goodwill,\r
+ work stoppage, computer failure or malfunction, or any and all\r
+ other commercial damages or losses), even if such Contributor\r
+ has been advised of the possibility of such damages.\r
+\r
+ 9. Accepting Warranty or Additional Liability. While redistributing\r
+ the Work or Derivative Works thereof, You may choose to offer,\r
+ and charge a fee for, acceptance of support, warranty, indemnity,\r
+ or other liability obligations and/or rights consistent with this\r
+ License. However, in accepting such obligations, You may act only\r
+ on Your own behalf and on Your sole responsibility, not on behalf\r
+ of any other Contributor, and only if You agree to indemnify,\r
+ defend, and hold each Contributor harmless for any liability\r
+ incurred by, or claims asserted against, such Contributor by reason\r
+ of your accepting any such warranty or additional liability.\r
+\r
+ END OF TERMS AND CONDITIONS\r
+\r
+ APPENDIX: How to apply the Apache License to your work.\r
+\r
+ To apply the Apache License to your work, attach the following\r
+ boilerplate notice, with the fields enclosed by brackets "[]"\r
+ replaced with your own identifying information. (Don't include\r
+ the brackets!) The text should be enclosed in the appropriate\r
+ comment syntax for the file format. We also recommend that a\r
+ file or class name and description of purpose be included on the\r
+ same "printed page" as the copyright notice for easier\r
+ identification within third-party archives.\r
+\r
+ Copyright [yyyy] [name of copyright owner]\r
+\r
+ Licensed under the Apache License, Version 2.0 (the "License");\r
+ you may not use this file except in compliance with the License.\r
+ You may obtain a copy of the License at\r
+\r
+ http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+ Unless required by applicable law or agreed to in writing, software\r
+ distributed under the License is distributed on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ See the License for the specific language governing permissions and\r
+ limitations under the License.\r
+\r
--- /dev/null
+sensor-framework (0.2.5-37) unstable; urgency=low
+
+ * version sync
+ * Git: 165.213.180.114:/pkgs/s/sensor-framework
+ * Tag: sensor-framework_0.2.5-37
+
+ -- JuHyun Kim <jh8212.kim@samsung.com> Thu, 15 Dec 2011 10:54:03 +0900
+
+sensor-framework (0.1.1-1) unstable; urgency=low
+
+ * Initial Release.
+ * Git: 165.213.180.114:/pkgs/s/sensor-framework
+ * Tag: sensor-framework_0.1.1-1
+
+ -- JuHyun Kim <jh8212.kim@samsung.com> Wed, 07 Dec 2011 12:50:05 +0900
--- /dev/null
+Source: sensor-framework
+Section: misc
+Priority: extra
+Maintainer: Jonghoon Han <jonghoon.han@samsung.com>, Juhyun Kim <jh8212.kim@samsung.com>, Taesoo Jun <steve.jun@samsung.com>
+Build-Depends: libsf-common-dev, libslp-setting-dev
+Standards-Version: 0.1.0
+Homepage: N/A
+
+Package: sensor-framework
+Section: misc
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}, libsf-common-0
+Description: Sensor framework
+ Sensor framework
+
+Package: sensor-framework-dbg
+Section: debug
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}, sensor-framework(= ${Source-Version})
+Description:Sensor server debug for sensor framework(unstripped)
+ Easy Sensor server for SLP(not recommended)
--- /dev/null
+usr/bin
+usr/sbin
--- /dev/null
+CMakeLists.txt
--- /dev/null
+#!/usr/bin/make -f
+# -*- makefile -*-
+# Sample debian/rules that uses debhelper.
+# This file was originally written by Joey Hess and Craig Small.
+# As a special exception, when this file is copied by dh-make into a
+# dh-make output file, you may use that output file without restriction.
+# This special exception was added by Craig Small in version 0.37 of dh-make.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+CFLAGS ?= -Wall -g
+CXXFLAGS ?= -Wall -g
+LDFLAGS ?=
+PREFIX ?= /usr
+DATADIR ?= /opt
+
+ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
+ CFLAGS += -O0
+ CXXFLAGS += -O0
+else
+ CFLAGS += -O2
+ CXXFLAGS += -O2 -std=c++0x
+endif
+
+LDFLAGS += -Wl,--rpath=$(PREFIX)/lib -Wl,--as-needed
+
+configure: configure-stamp
+configure-stamp:
+ dh_testdir
+ # Add here commands to configure the package.
+ CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" LDFLAGS="$(LDFLAGS)" cmake . -DCMAKE_INSTALL_PREFIX=$(PREFIX)
+
+ touch configure-stamp
+
+build: build-stamp
+
+build-stamp: configure-stamp
+ dh_testdir
+ dh_buildinfo generate cat
+
+ # Add here commands to compile the package.
+ $(MAKE)
+ #docbook-to-man debian/wavplayer.sgml > wavplayer.1
+
+ for f in `find $(CURDIR)/debian/ -name "*.in"`; do \
+ cat $$f > $${f%.in}; \
+ sed -i -e "s#@PREFIX@#$(PREFIX)#g" $${f%.in}; \
+ sed -i -e "s#@DATADIR@#$(DATADIR)#g" $${f%.in}; \
+ done
+
+
+ touch $@
+
+clean:
+ dh_testdir
+ dh_testroot
+ rm -f build-stamp configure-stamp
+
+ # Add here commands to clean up after the build process.
+ -$(MAKE) clean
+ rm -rf CMakeCache.txt
+ rm -rf CMakeFiles
+ rm -rf cmake_install.cmake
+ rm -rf Makefile
+ rm -rf install_manifest.txt
+ rm -rf *.so
+ rm -rf sf_*.conf
+
+ rm -rf server/CMakeFiles
+ rm -rf server/cmake_install.cmake
+ rm -rf server/Makefile
+
+
+ for f in `find $(CURDIR)/debian/ -name "*.in"`; do \
+ rm -f $${f%.in}; \
+ done
+
+ dh_clean
+
+install: build
+ dh_testdir
+ dh_testroot
+ dh_clean -k
+ dh_installdirs
+
+ # Add here commands to install the package into debian/wavplayer.
+ $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install
+ mkdir -p $(CURDIR)/debian/tmp/etc/rc.d/rc3.d/
+ mkdir -p $(CURDIR)/debian/tmp/etc/rc.d/rc4.d/
+ ln -s ../init.d/sfsvc $(CURDIR)/debian/tmp/etc/rc.d/rc3.d/S40sfsvc
+ ln -s ../init.d/sfsvc $(CURDIR)/debian/tmp/etc/rc.d/rc4.d/S40sfsvc
+
+
+# Build architecture-independent files here.
+binary-indep: build install
+# We have nothing to do by default.
+
+# Build architecture-dependent files here.
+binary-arch: build install
+ dh_testdir
+ dh_testroot
+ dh_installchangelogs
+ dh_installdocs
+ dh_buildinfo install
+ dh_installexamples
+ dh_install --sourcedir=debian/tmp
+# dh_installmenu
+# dh_installdebconf
+# dh_installlogrotate
+# dh_installemacsen
+# dh_installpam
+# dh_installmime
+# dh_python
+# dh_installinit
+# dh_installcron
+# dh_installinfo
+ dh_installman
+ dh_link
+ dh_strip --dbg-package=sensor-framework-dbg
+ dh_compress
+ dh_fixperms
+# dh_perl
+ dh_makeshlibs
+ dh_installdeb
+ dh_shlibdeps
+ dh_gencontrol
+ dh_md5sums
+ dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install configure
--- /dev/null
+@PREFIX@/bin/*
+@PREFIX@/etc/*
+/etc/rc.d/*
--- /dev/null
+#!/bin/sh
+if [ ${USER} = "root" ];then
+ # change file owner
+ # 1.libraries
+ # 2.executables
+ #chown root:root /usr/bin/sf_server
+ #chown root:root /etc/rc.d/init.d/sfsvc
+ #chown root:root /etc/rc.d/rc3.d/S72sfsvc
+ # 3.configurations
+ chown root:root /usr/etc/sf_sensor*
+ chown root:root /usr/etc/sf_filter*
+ chown root:root /usr/etc/sf_processor*
+ chown root:root /usr/etc/sf_data_stream*
+ #4. vconf key generation
+ vconftool set -t int memory/sensor/10001 0 -i
+ vconftool set -t int memory/sensor/10002 0 -i
+ vconftool set -t int memory/sensor/10004 0 -i
+ vconftool set -t int memory/sensor/10008 0 -i
+ vconftool set -t int memory/sensor/20001 0 -i
+ vconftool set -t int memory/sensor/20002 0 -i
+ vconftool set -t int memory/sensor/20004 0 -i
+ vconftool set -t int memory/sensor/200001 0 -i
+ vconftool set -t int memory/sensor/40001 0 -i
+ vconftool set -t int memory/sensor/40002 0 -i
+ vconftool set -t int memory/sensor/800001 0 -i
+ vconftool set -t int memory/sensor/800002 0 -i
+ vconftool set -t int memory/sensor/800004 0 -i
+ vconftool set -t int memory/sensor/800008 0 -i
+ vconftool set -t int memory/sensor/800010 0 -i
+ vconftool set -t int memory/sensor/800020 0 -i
+ vconftool set -t int memory/sensor/800040 0 -i
+ vconftool set -t int memory/sensor/80001 0 -i
+ vconftool set -t int memory/sensor/80002 0 -i
+fi
+# change file permissions
+# 1.libraries
+# 2.executables
+#chmod 700 /usr/bin/sf_server
+#chmod 700 /etc/rc.d/init.d/sfsvc
+#chmod 700 /etc/rc.d/rc3.d/S72sfsvc
+# 3.configurations
+chmod 644 /usr/etc/sf_sensor*
+chmod 644 /usr/etc/sf_filter*
+chmod 644 /usr/etc/sf_processor*
+chmod 644 /usr/etc/sf_data_stream*
--- /dev/null
+Name: sensor-framework
+Summary: Sensor framework
+Version: 0.2.5
+Release: 1
+Group: TO_BE/FILLED_IN
+License: LGPL
+Source0: %{name}-%{version}.tar.gz
+
+Requires(post): /usr/bin/vconftool
+
+BuildRequires: cmake
+BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: pkgconfig(sf_common)
+BuildRequires: pkgconfig(vconf)
+%description
+Sensor framework
+
+%prep
+%setup -q
+
+%build
+cmake . -DCMAKE_INSTALL_PREFIX=/usr
+
+make %{?jobs:-j%jobs}
+
+%install
+%make_install
+
+%post
+vconftool set -t int memory/sensor/10001 0 -i
+vconftool set -t int memory/sensor/10002 0 -i
+vconftool set -t int memory/sensor/10004 0 -i
+vconftool set -t int memory/sensor/10008 0 -i
+vconftool set -t int memory/sensor/20001 0 -i
+vconftool set -t int memory/sensor/20002 0 -i
+vconftool set -t int memory/sensor/20004 0 -i
+vconftool set -t int memory/sensor/200001 0 -i
+vconftool set -t int memory/sensor/40001 0 -i
+vconftool set -t int memory/sensor/40002 0 -i
+vconftool set -t int memory/sensor/800001 0 -i
+vconftool set -t int memory/sensor/800002 0 -i
+vconftool set -t int memory/sensor/800004 0 -i
+vconftool set -t int memory/sensor/800008 0 -i
+vconftool set -t int memory/sensor/800010 0 -i
+vconftool set -t int memory/sensor/800020 0 -i
+vconftool set -t int memory/sensor/800040 0 -i
+vconftool set -t int memory/sensor/80001 0 -i
+vconftool set -t int memory/sensor/80002 0 -i
+
+%files
+%defattr(-,root,root,-)
+/usr/bin/sf_server
+%{_sysconfdir}/rc.d/init.d/sfsvc
+%attr(0644,root,root)/usr/etc/sf_data_stream.conf
+%attr(0644,root,root)/usr/etc/sf_filter.conf
+%attr(0644,root,root)/usr/etc/sf_processor.conf
+%attr(0644,root,root)/usr/etc/sf_sensor.conf
+
--- /dev/null
+cmake_minimum_required(VERSION 2.6)
+project(sf_server CXX)
+
+#add_definitions(-Wall -g -DUSE_FILE_DEBUG)
+#add_definitions(-Wall -g -D_DEBUG)
+##add_definitions(-Wall -g -pg)
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
+
+add_executable(${PROJECT_NAME}
+ src/cserver.cpp
+ src/csensor_catalog.cpp
+ src/cfilter_catalog.cpp
+ src/cprocessor_catalog.cpp
+ src/cdata_stream.cpp
+ src/resource_str.cpp
+ src/ctrim.cpp
+ src/ccatalog.cpp
+ src/main.cpp
+)
+
+target_link_libraries(${PROJECT_NAME} ${rpkgs_LDFLAGS})
+set(CMAKE_CXX_FLAGS "-ldl -lpthread ${CMAKE_CXX_FLAGS}")
+
+
+install(TARGETS ${PROJECT_NAME} DESTINATION bin)
--- /dev/null
+/*
+ * sensor-framework
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: JuHyun Kim <jh8212.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+
+#if !defined(_CATALOG_CLASS_H_)
+#define _CATALOG_CLASS_H_
+
+
+
+class ccatalog
+{
+public:
+ enum ccatalog_splitter_id {
+ SPLITTER_FOR_CONF_FILE = 0x00,
+ SPLITTER_FOR_CPU_INFO = 0x01,
+ };
+
+ ccatalog();
+ virtual ~ccatalog();
+
+ bool load(const char *conf_file , char splitter_id = SPLITTER_FOR_CONF_FILE);
+ bool is_loaded(void);
+ bool unload(void);
+
+ char *value(char *group, char *name);
+ char *value(char *group, char *name, int idx);
+ int count_of_values(char *group, char *name);
+
+ void *iterate_init(void);
+ void *iterate_next(void *handle);
+ void *iterate_prev(void *handle);
+ char *iterate_get_name(void *handle);
+
+private:
+ struct desc_t : public clist {
+ char *name;
+ char *value;
+ };
+
+ struct group_t : public clist {
+ char *name;
+ int attr_cnt;
+
+ desc_t *head;
+ desc_t *tail;
+ };
+
+ group_t *m_head;
+ group_t *m_tail;
+};
+
+
+
+#endif
+//! End of a file
--- /dev/null
+/*
+ * sensor-framework
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: JuHyun Kim <jh8212.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+
+class cdata_stream : public clist
+{
+public:
+ enum value_type_t {
+ SENSOR = 0x01,
+ FILTER = 0x02,
+ PROCESSOR = 0x03,
+ };
+
+ static const int SF_DATA_STREAM = ctype::UNKNOWN + 40;
+
+ cdata_stream();
+ virtual ~cdata_stream();
+
+ static bool create(char *conf);
+ static void destroy(void);
+
+ char *name(void);
+ int id(void);
+
+ bool update_name(char *name);
+ bool update_id(int id);
+
+ bool start(void);
+ bool stop(void);
+
+ bool add_event_callback(void *(*handler)(cprocessor_module *, void *), void *data, bool (*rm_cb_data)(void *) = NULL);
+ bool rm_event_callback(void *(*handler)(cprocessor_module *, void*), void *data);
+ void wakeup_all_client(void);
+
+ long value(value_type_t type, char *port);
+ long value(value_type_t type, int id);
+ int get_struct_value(value_type_t type, unsigned int struct_id , void *struct_values);
+
+ static cdata_stream *search_stream(char *name);
+ static cdata_stream *search_stream(int id);
+
+ bool add_callback_func(cmd_reg_t *param);
+ bool remove_callback_func(cmd_reg_t * param);
+ bool check_callback_event(cmd_reg_t * param);
+
+ cprocessor_module *my_processor(void);
+ cfilter_module *my_filter(void);
+
+ long set_cmd(int type , int property , long input_value);
+ int get_property(unsigned int property_level , void *property_data );
+
+private:
+ struct filter_list_t : public clist {
+ cfilter_module *filter;
+ };
+
+ struct processor_list_t : public clist {
+ cprocessor_module *processor;
+ };
+
+ cprocessor_module *select_processor(void);
+ cfilter_module *select_filter(void);
+
+ processor_list_t *composite_processor(char *value);
+ filter_list_t *composite_filter(char *value, int multi_chek);
+
+ cfilter_module *search_filter(char *name);
+ cprocessor_module *search_processor(char *name);
+
+ filter_list_t *m_filter_head;
+ filter_list_t *m_filter_tail;
+
+ processor_list_t *m_processor_head;
+ processor_list_t *m_processor_tail;
+
+ char *m_name;
+ int m_id;
+
+ int m_client;
+
+ static cdata_stream *m_head;
+ static cdata_stream *m_tail;
+ static ccatalog m_catalog;
+
+ pthread_mutex_t mutex_lock;
+};
+
+
+
+//! End of a file
--- /dev/null
+/*
+ * sensor-framework
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: JuHyun Kim <jh8212.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+
+class cfilter_catalog : public ccatalog
+{
+public:
+ static const int SF_FILTER_CATALOG = ctype::UNKNOWN + 50;
+ cfilter_catalog();
+ virtual ~cfilter_catalog();
+
+ bool create(char *file);
+ void destroy(void);
+
+private:
+};
+
+
+
+//! End of a file
--- /dev/null
+/*
+ * sensor-framework
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: JuHyun Kim <jh8212.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+
+class cprocessor_catalog : public ccatalog
+{
+public:
+ cprocessor_catalog();
+ virtual ~cprocessor_catalog();
+
+ bool create(char *file);
+ void destroy(void);
+
+private:
+};
+
+
+
+//! End of a file
--- /dev/null
+/*
+ * sensor-framework
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: JuHyun Kim <jh8212.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+
+class csensor_catalog : public ccatalog
+{
+public:
+ static const int SF_FILTER_CATALOG = ctype::UNKNOWN + 60;
+ csensor_catalog();
+ virtual ~csensor_catalog();
+
+ bool create(char *conf_file);
+ void destroy(void);
+
+private:
+};
+
+
+//! End of a file
--- /dev/null
+/*
+ * sensor-framework
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: JuHyun Kim <jh8212.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+
+
+class cserver
+{
+public:
+ enum {
+ MAX_CMD_COUNT = 256,
+ };
+
+ cserver();
+ virtual ~cserver();
+
+
+ void sf_main_loop(void);
+
+private:
+
+ struct client_ctx_t {
+ ctype *module;
+ int client_state;
+ unsigned int reg_state;
+ };
+
+ static void *cb_ipc_worker(void *data);
+ static void *cb_ipc_start(void *data);
+ static void *cb_ipc_stop(void *data);
+
+ void command_handler(void *cmd_item, void *ctx);
+
+ //! Attach
+ static void *cmd_hello(void *cmd_item, void *data);
+ //! Detach
+ static void *cmd_byebye(void *cmd_item, void *data);
+ //! Get value
+ static void *cmd_get_value(void *cmd_item, void *data);
+ //! Wait event
+ static void *cmd_wait_event(void *cmd_item, void *data);
+ //! Start
+ static void *cmd_start(void *cmd_item, void *data);
+ //! Stop
+ static void *cmd_stop(void *cmd_item, void *data);
+ //! Register lib_callback
+ static void *cmd_register_event(void *cmd_item, void *data);
+ //! Set cmd
+ static void *cmd_set_value(void *cmd_item, void *data);
+ //! Get property
+ static void *cmd_get_property(void *cmd_item, void *data);
+ //! Get struct_data
+ static void *cmd_get_struct(void *cmd_item, void *data);
+
+
+ static void *cb_event_handler(cprocessor_module *, void *);
+ static void cb_rm_cb_data(void *);
+
+
+ cmd_func_t m_cmd_handler[CMD_LAST];
+};
+
+
+
+//! End of a file
--- /dev/null
+/*
+ * sensor-framework
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: JuHyun Kim <jh8212.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+
+#if !defined(_TRIM_CLASS_H_)
+#define _TRIM_CLASS_H_
+
+
+
+class ctrim
+{
+public:
+ ctrim(void);
+ virtual ~ctrim(void);
+
+ static char *ltrim(char *str);
+ static int rtrim(char *str);
+};
+
+
+
+#endif
+//! End of a file
--- /dev/null
+/*
+ * sensor-framework
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: JuHyun Kim <jh8212.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+
+extern const char *STR_CMD_QUEUE;
+extern const char *STR_SF_IPC_SOCKET;
+extern const char *STR_PATH;
+extern const char *STR_ID;
+extern const char *STR_VERSION;
+extern const char *STR_NAME;
+extern const char *STR_DISABLE;
+extern const char *STR_YES;
+extern const char *STR_OVERRIDE;
+extern const char *STR_POLL;
+extern const char *STR_MULTI_STREAM;
+extern const char *STR_FILTER_INPUT;
+extern const char *STR_PROCESSOR_INPUT;
+extern const char *STR_TOKEN_DELIMETER;
+
+//! End of a file
--- /dev/null
+/*
+ * sensor-framework
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: JuHyun Kim <jh8212.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <common.h>
+#include <cobject_type.h>
+#include <ctrim.h>
+#include <clist.h>
+#include <ccatalog.h>
+#define TMP_BUF_SIZE 512
+
+ccatalog::ccatalog()
+: m_head(NULL)
+, m_tail(NULL)
+{
+}
+
+ccatalog::~ccatalog()
+{
+ if (m_head) unload();
+}
+
+bool ccatalog::load(const char *conf_file , char splitter_id)
+{
+ FILE *fp;
+ group_t *grp = NULL;
+ desc_t *desc;
+ char line_buffer[TMP_BUF_SIZE];
+ char tmp_buffer[TMP_BUF_SIZE];
+ int rtrim_num;
+ int split_num = 0;
+ int group_name_check = 0;
+ char name[TMP_BUF_SIZE];
+ char value[TMP_BUF_SIZE];
+ char *ptr;
+
+ switch (splitter_id ) {
+ case SPLITTER_FOR_CONF_FILE:
+ case '=':
+ break;
+ case SPLITTER_FOR_CPU_INFO:
+ case ':':
+ if ( !m_head ) {
+ try {
+ grp = new group_t;
+ } catch (...) {
+ ERR("No memory");
+ return false;
+ }
+ m_head = m_tail = grp;
+ grp->name = strdup("CPU_INFO_TABLE");
+ if (!grp->name) {
+ ERR("Failed to allocate buffer for the tmp_buffer\n");
+ delete grp;
+ return false;
+ }
+ DBG("grp->name : %s\n",grp->name);
+ grp->attr_cnt = 0;
+
+ grp->head = NULL;
+ grp->tail = NULL;
+ } else {
+ ERR("already CPU_INFO_TABLE exist !! cannot make again\n");
+ return false;
+ }
+ break;
+
+ default:
+ ERR("fail does not support splitter idx : %x",splitter_id);
+ return false;
+ }
+
+ fp = fopen(conf_file, "r");
+ if (!fp) {
+ return false;
+ }
+
+ while (fgets(line_buffer, TMP_BUF_SIZE, fp)) {
+ ptr = ctrim::ltrim(line_buffer);
+ if (*ptr == '#') {
+ continue;
+ }
+ DBG("read line_buffer : %s\n",line_buffer);
+
+ /* Replcate the last character if it was new line. */
+ if ( (ptr[strlen(ptr)-1] == '\n') || (ptr[strlen(ptr)-1] == '\r')) ptr[strlen(ptr)-1] = '\0';
+
+ rtrim_num = ctrim::rtrim(ptr);
+
+ switch (splitter_id ) {
+ case SPLITTER_FOR_CONF_FILE:
+ case '=':
+ group_name_check = sscanf(ptr, "[%[^]] ", tmp_buffer);
+ break;
+ case SPLITTER_FOR_CPU_INFO:
+ case ':':
+ group_name_check = 0;
+ break;
+ }
+
+ if (group_name_check == 1) {
+ /* We have previous group, Just link it to the end of group list */
+ DBG("check tmp_buffer : %s\n",tmp_buffer);
+ if (grp) {
+ if (m_tail) {
+ grp->link(clist::AFTER, m_tail);
+ m_tail = grp;
+ } else {
+ m_head = m_tail = grp;
+ }
+ }
+
+ try {
+ grp = new group_t;
+ } catch (...) {
+ ERR("No memory");
+ fclose(fp);
+ return false;
+ }
+
+ grp->name = strdup(tmp_buffer);
+ DBG("grp->name : %s\n",grp->name);
+ if (!grp->name) {
+ ERR("Failed to allocate buffer for the tmp_buffer\n");
+ delete grp;
+ fclose(fp);
+ return false;
+ }
+ grp->attr_cnt = 0;
+ grp->head = NULL;
+ grp->tail = NULL;
+ continue;
+ }
+
+ switch (splitter_id ) {
+ case SPLITTER_FOR_CONF_FILE:
+ case '=':
+ split_num = sscanf(ptr, "%[^=]=%[^\n]", name, value);
+ break;
+ case SPLITTER_FOR_CPU_INFO:
+ case ':':
+ split_num = sscanf(ptr, "%[^:]:%[^\n]", name, value);
+ DBG("split_num : %d , raw_name : [start]%s[end] , raw_value : [start]%s[end]\n",split_num ,name , value);
+ break;
+ default:
+ ERR("fail does not support splitter idx : %x",splitter_id);
+ split_num = 0;
+ break;
+ }
+
+ if ( (split_num == 2) && (grp!=NULL) ) {
+ try {
+ desc = new desc_t;
+ } catch (...) {
+ ERR("Failed to allocate new description\n");
+ free(grp->name);
+ delete grp;
+ fclose(fp);
+ return false;
+ }
+
+ ptr = ctrim::ltrim(name);
+ rtrim_num = ctrim::rtrim(ptr);
+ desc->name = strdup(ptr);
+ DBG("desc->name :%s[end]\n",desc->name);
+
+ if (!desc->name) {
+ ERR("Failed to allocate buffer for the name\n");
+ free(grp->name);
+ delete grp;
+ delete desc;
+ fclose(fp);
+ return false;
+ }
+
+ ptr = ctrim::ltrim(value);
+ rtrim_num = ctrim::rtrim(ptr);
+ desc->value = strdup(ptr);
+ DBG("desc->value :%s[end]\n",desc->value);
+
+ if (!desc->value) {
+ ERR("Failed to allocate buffer for the value\n");
+ free(grp->name);
+ delete grp;
+ free(desc->name);
+ delete desc;
+ fclose(fp);
+ return false;
+ }
+
+ if (grp->tail) {
+ desc->link(clist::AFTER, grp->tail);
+ grp->tail = desc;
+ } else {
+ grp->head = grp->tail = desc;
+ }
+
+ grp->attr_cnt ++;
+ continue;
+ }
+ }
+
+ if (m_tail != grp) {
+ if (m_tail && grp != NULL) {
+ grp->link(clist::AFTER, m_tail);
+ m_tail = grp;
+ } else {
+ m_tail = m_head = grp;
+ }
+ }
+
+ fclose(fp);
+ return true;
+}
+
+bool ccatalog::is_loaded(void)
+{
+ return (m_head != NULL) ? true : false ;
+}
+
+bool ccatalog::unload(void)
+{
+ group_t *grp;
+ group_t *next_grp;
+ desc_t *desc;
+ desc_t *next_desc;
+
+ grp = m_head;
+ while (grp) {
+ next_grp = (group_t*)grp->next();
+ desc = grp->head;
+ while (desc) {
+ next_desc = (desc_t*)desc->next();
+ free(desc->name);
+ free(desc->value);
+ delete desc;
+ desc = next_desc;
+ }
+ free(grp->name);
+ delete grp;
+ grp = next_grp;
+ }
+ m_head = NULL;
+ m_tail = NULL;
+ return true;
+}
+
+char *ccatalog::value(char *group, char *name)
+{
+ group_t *grp;
+
+ grp = m_head;
+ while (grp) {
+ if (!strncmp(group, grp->name, strlen(grp->name))) {
+ break;
+ }
+ grp = (group_t*)grp->next();
+ }
+
+ if (grp) {
+ desc_t *desc;
+ desc = grp->head;
+
+ while (desc) {
+ if (!strncmp(name, desc->name, sizeof(desc->name))) {
+ return desc->value;
+ }
+ desc = (desc_t*)desc->next();
+ }
+ }
+
+ return NULL;
+}
+
+char *ccatalog::value(char *group, char *name, int idx)
+{
+ group_t *grp;
+ grp = m_head;
+ while (grp) {
+ if (!strcmp(group, grp->name)) {
+ break;
+ }
+ grp = (group_t*)grp->next();
+ }
+
+ if (grp) {
+ register int i;
+ desc_t *desc;
+ desc = grp->head;
+ i = 0;
+ while (desc) {
+ if (!strcmp(name, desc->name)) {
+ if (i == idx) {
+ return desc->value;
+ }
+ i ++;
+ }
+ desc = (desc_t *)desc->next();
+ }
+ }
+
+ return NULL;
+}
+
+int ccatalog::count_of_values(char *group, char *name)
+{
+ group_t *grp;
+ register int count = 0;
+ grp = m_head;
+ while (grp) {
+ if (!strcmp(group, grp->name)) {
+ break;
+ }
+ grp = (group_t*)grp->next();
+ }
+
+ if (grp) {
+ desc_t *desc;
+ desc = grp->head;
+
+ while (desc) {
+ if (!strcmp(name, desc->name)) {
+ count ++;
+ }
+ desc = (desc_t *)desc->next();
+ }
+ }
+ return count;
+}
+
+void *ccatalog::iterate_init(void)
+{
+ return (void*)m_head;
+}
+
+void *ccatalog::iterate_next(void *handle)
+{
+ group_t *grp = (group_t*)handle;
+ return grp->next();
+}
+
+void *ccatalog::iterate_prev(void *handle)
+{
+ group_t *grp = (group_t*)handle;
+ return grp->prev();
+}
+
+char *ccatalog::iterate_get_name(void *handle)
+{
+ group_t *grp = (group_t*)handle;
+ return grp->name;
+}
+//! End of a file
--- /dev/null
+/*
+ * sensor-framework
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: JuHyun Kim <jh8212.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+
+
+#include <stdio.h>
+#include <errno.h>
+#include <dlfcn.h>
+#include <pthread.h>
+#include <signal.h>
+
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/stat.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <unistd.h>
+#include <sys/un.h>
+
+#include <common.h>
+#include <cobject_type.h>
+
+#include <clist.h>
+#include <ccatalog.h>
+
+#include <cmutex.h>
+#include <cmodule.h>
+
+#include <cpacket.h>
+#include <csync.h>
+#include <cworker.h>
+#include <cipc_worker.h>
+#include <csock.h>
+#include <ctrim.h>
+
+#include <sf_common.h>
+
+#include <csensor_module.h>
+#include <cfilter_module.h>
+#include <cprocessor_module.h>
+#include <cdata_stream.h>
+
+#include <resource_str.h>
+
+#define PROCESSOR_NAME_LENGTH 50
+
+cdata_stream *cdata_stream::m_head = NULL;
+cdata_stream *cdata_stream::m_tail = NULL;
+
+ccatalog cdata_stream::m_catalog;
+
+
+
+cdata_stream::cdata_stream()
+: m_filter_head(NULL)
+, m_filter_tail(NULL)
+, m_processor_head(NULL)
+, m_processor_tail(NULL)
+, m_name(NULL)
+, m_id(0)
+, m_client(0)
+, mutex_lock(PTHREAD_MUTEX_INITIALIZER)
+{
+ if (!m_head) {
+ m_head = m_tail = this;
+ } else {
+ if(!clist::link(clist::AFTER, m_tail))
+ m_head = m_tail = this;
+ else
+ m_tail = this;
+ }
+ ctype::set_type(SF_DATA_STREAM);
+}
+
+
+
+cdata_stream::~cdata_stream()
+{
+ cdata_stream *prev;
+ cdata_stream *next;
+ processor_list_t *processor;
+ processor_list_t *next_processor;
+ filter_list_t *filter;
+ filter_list_t *next_filter;
+
+
+ prev = (cdata_stream*)clist::prev();
+ next = (cdata_stream*)clist::next();
+
+ if (m_tail == this) {
+ m_tail = next;
+ }
+
+ if (m_head == this) {
+ m_head = prev;
+ }
+
+ clist::unlink();
+
+ processor = m_processor_head;
+ while (processor) {
+ next_processor = (processor_list_t*)processor->next();
+
+ processor->unlink();
+ processor->processor->destroy(processor->processor);
+ delete processor;
+
+ processor = next_processor;
+ }
+
+
+ filter = m_filter_head;
+ while (filter) {
+ next_filter = (filter_list_t*)filter->next();
+
+ filter->unlink();
+ filter->filter->destroy(filter->filter);
+ delete filter;
+
+ filter = next_filter;
+ }
+
+ if (m_name) free(m_name);
+}
+
+
+cfilter_module *cdata_stream::search_filter(char *name)
+{
+ filter_list_t *iterator;
+
+ iterator = m_filter_head;
+ while (iterator) {
+
+ if (!strcmp(name, iterator->filter->name())) {
+ break;
+ }
+
+ iterator = (filter_list_t*)iterator->next();
+ }
+
+ return iterator ? iterator->filter : NULL ;
+}
+
+
+
+cprocessor_module *cdata_stream::search_processor(char *name)
+{
+ processor_list_t *iterator;
+
+ iterator = m_processor_head;
+
+ while (iterator) {
+ if (!strcmp(name, iterator->processor->name())) {
+ break;
+ }
+
+ iterator = (processor_list_t*)iterator->next();
+ }
+
+ return iterator ? iterator->processor : NULL ;
+}
+
+
+
+cdata_stream::processor_list_t *cdata_stream::composite_processor(char *value)
+{
+ cprocessor_module *processor = NULL;
+ cfilter_module *filter;
+ char *save_ptr = NULL;
+ processor_list_t *item;
+ cmodule *module;
+ char *token;
+ int rtrim_num;
+ char proc_name[PROCESSOR_NAME_LENGTH] = {0,};
+
+ //! Name
+ token = strtok_r(value, STR_TOKEN_DELIMETER, &save_ptr);
+ if (!token) {
+ return NULL;
+ }
+ token = ctrim::ltrim(token);
+ rtrim_num = ctrim::rtrim(token);
+ processor = (cprocessor_module*)cmodule::search_module(token);
+ if (!processor) {
+ return NULL;
+ }
+ //! Get a new name
+ token = strtok_r(NULL, STR_TOKEN_DELIMETER, &save_ptr);
+ if (!token) {
+ return NULL;
+ }
+ token = ctrim::ltrim(token);
+ rtrim_num = ctrim::rtrim(token);
+ processor = processor->create_new();
+ if (!processor) {
+ return NULL;
+ }
+ DBG("composite_processor : new name : %s\n",token);
+
+ if (processor->update_name(token) == false) {
+ ERR("Failed to update name\n");
+ //! NOTE: This has no problem :)
+ processor->destroy(processor);
+ return NULL;
+ }
+
+ snprintf(proc_name, PROCESSOR_NAME_LENGTH, "%s", token);
+ while((token = strtok_r(NULL, STR_TOKEN_DELIMETER, &save_ptr)) != NULL) {
+
+ token = ctrim::ltrim(token);
+ rtrim_num = ctrim::rtrim(token);
+
+ DBG("Searching module : %s\n", token);
+
+ module = cmodule::search_module(token);
+ if (module) {
+ if (module->type() == csensor_module::SF_PLUGIN_SENSOR) {
+ if (processor->add_input((csensor_module*)module) == false) {
+ ERR("Failed to add an input\n");
+ continue;
+ }
+ DBG("Successfully added\n");
+ } else if (module->type() == cfilter_module::SF_PLUGIN_FILTER) {
+ if (processor->add_input((cfilter_module*)module) == false) {
+ ERR("Failed to add an input\n");
+ continue;
+ }
+ DBG("Successfully added\n");
+ } else {
+ ERR("Invalid type\n");
+ }
+ } else {
+ DBG("Search %s in data_stream pool\n", token);
+ filter = search_filter(token);
+ if (filter) {
+ DBG("Oooooleh found %s\n", token);
+ if(processor->add_input(filter) == false) {
+ ERR("Failed to add an input\n");
+ }
+ }
+ }
+ }
+
+ try {
+ item = new processor_list_t;
+ } catch (...) {
+ processor->destroy(processor);
+ return NULL;
+ }
+
+ item->processor = processor;
+
+ return item;
+}
+
+
+
+cdata_stream::filter_list_t *cdata_stream::composite_filter(char *value, int multi_check)
+{
+ cfilter_module *filter = NULL;
+ cmodule *module;
+ char *token;
+ char *save_ptr = NULL;
+ int rtrim_num;
+
+ //! Name
+ token = strtok_r(value, STR_TOKEN_DELIMETER, &save_ptr);
+ if (!token) {
+ return NULL;
+ }
+
+ token = ctrim::ltrim(token);
+ rtrim_num = ctrim::rtrim(token);
+
+ DBG("Given module name : %s\n", token);
+ filter = (cfilter_module*)cmodule::search_module(token);
+ if (!filter) {
+ return NULL;
+ }
+
+ //! Get a new name
+ token = strtok_r(NULL, STR_TOKEN_DELIMETER, &save_ptr);
+ if (!token) {
+ ERR("No name\n");
+ return NULL;
+ }
+
+ token = ctrim::ltrim(token);
+ rtrim_num = ctrim::rtrim(token);
+
+ DBG("Created module name %s\n", token);
+ filter = filter->create_new();
+ if (!filter) {
+ ERR("Failed to create new filter\n");
+ return NULL;
+ }
+
+ if (filter->update_name(token) == false) {
+ ERR("Failed to update name %s\n", token);
+ filter->destroy(filter);
+ return NULL;
+ }
+
+ while((token = strtok_r(NULL, STR_TOKEN_DELIMETER, &save_ptr)) != NULL) {
+
+ token = ctrim::ltrim(token);
+ rtrim_num = ctrim::rtrim(token);
+
+ DBG("Search module : %s\n", token);
+ module = cmodule::search_module(token);
+ if (!module) {
+ ERR("There is no %s sensor\n", token);
+ continue;
+ }
+
+ if (module->type() != csensor_module::SF_PLUGIN_SENSOR) {
+ ERR("Type is not matched\n");
+ continue;
+ }
+
+ if (filter->add_input((csensor_module*)module) == false) {
+ ERR("Failed to set input sensor_module(%s)\n",module->name());
+ } else {
+ DBG("added OK, sensor_module : %s \n",module->name());
+ if ( multi_check != 1 ) break;
+ }
+ }
+
+ filter_list_t *item;
+ try {
+ item = new filter_list_t;
+ } catch (...) {
+ filter->destroy(filter);
+ return NULL;
+ }
+
+ item->filter = filter;
+ return item;
+}
+
+
+
+bool cdata_stream::create(char *conf)
+{
+ void *handle;
+ char *name;
+ char *value;
+ processor_list_t *processor;
+ filter_list_t *filter;
+ int idx;
+ int multi_stream_state;
+
+ if (m_catalog.load(conf) == false) {
+ if ( m_catalog.is_loaded() ) {
+ DBG("The catalog is already loaded , so first unload it");
+ m_catalog.unload();
+ }
+ ERR("Failed to load a configuration file\n");
+ return false;
+ }
+
+ handle = m_catalog.iterate_init();
+ while (handle) {
+ name = m_catalog.iterate_get_name(handle);
+ handle = m_catalog.iterate_next(handle);
+ if (!name)
+ continue;
+
+ value = m_catalog.value(name, (char*)STR_DISABLE);
+ if (value && !strcasecmp(value, (char*)STR_YES)) {
+ ERR("%s data stream is disabled\n", name);
+ continue;
+ }
+ cdata_stream *data_stream;
+
+ try {
+ data_stream = new cdata_stream;
+ } catch (...) {
+ ERR("No memory");
+ continue;
+ }
+
+ if (!data_stream->update_name(name)) {
+ ERR("Failed to update data_stream name\n");
+ }
+
+ value = m_catalog.value(name, (char*)STR_ID);
+ if (value) {
+ if (!data_stream->update_id(atoi(value))) {
+ ERR("Failed to update the id of data_stream\n");
+ }
+ }
+
+ value = m_catalog.value(name, (char*)STR_MULTI_STREAM);
+ if (value && !strcasecmp(value, (char*)STR_DISABLE)) {
+ DBG("Disable multi-data_stream composite\n");
+ multi_stream_state = 0;
+ } else {
+ DBG("Enable multi-data_stream composite\n");
+ multi_stream_state = 1;
+ }
+
+
+ idx = 0;
+ while ((value = m_catalog.value(name, (char*)STR_FILTER_INPUT, idx))) {
+ filter = data_stream->composite_filter(value, multi_stream_state);
+ if (filter) {
+ if (!data_stream->m_filter_head && !data_stream->m_filter_tail) {
+ data_stream->m_filter_head = data_stream->m_filter_tail = filter;
+ } else {
+ filter->link(clist::AFTER, data_stream->m_filter_tail);
+ data_stream->m_filter_tail = filter;
+ }
+ if ( multi_stream_state != 1 ) break;
+ }
+ idx ++;
+ }
+
+ idx = 0;
+ while ((value = m_catalog.value(name, (char*)STR_PROCESSOR_INPUT, idx))) {
+ processor = data_stream->composite_processor(value);
+ if (processor) {
+ if (!data_stream->m_processor_head && !data_stream->m_processor_tail) {
+ data_stream->m_processor_head = data_stream->m_processor_tail = processor;
+ } else {
+ processor->link(clist::AFTER, data_stream->m_processor_tail);
+ data_stream->m_processor_tail = processor;
+ }
+ if ( multi_stream_state != 1 ) break;
+ }
+ idx ++;
+ }
+ if ( !data_stream->m_processor_head ) {
+ ERR("There is no available processor or filter in the pool for data_stream :%s",name);
+ delete data_stream;
+ } else {
+ DBG("Construct ok data_stream : %s",name);
+ data_stream->link(clist::AFTER, m_tail);
+ m_tail = data_stream;
+ }
+ }
+
+ DBG("Finished registeration , unload data_stream.conf ");
+ m_catalog.unload();
+
+ return true;
+}
+
+
+
+void cdata_stream::destroy(void)
+{
+ if (m_catalog.is_loaded()) {
+ m_catalog.unload();
+ }
+}
+
+
+
+char *cdata_stream::name(void)
+{
+ return m_name;
+}
+
+
+
+int cdata_stream::id(void)
+{
+ return m_id;
+}
+
+
+
+bool cdata_stream::update_name(char *name)
+{
+ char *new_name;
+
+ new_name = strdup(name);
+ if (!new_name) {
+ ERR("No memory\n");
+ return false;
+ }
+
+ if (m_name) free(m_name);
+ m_name = new_name;
+ return true;
+}
+
+
+
+bool cdata_stream::update_id(int id)
+{
+ m_id = id;
+ return true;
+}
+
+
+
+cprocessor_module *cdata_stream::select_processor(void)
+{
+ cprocessor_module *processor;
+
+ if (!m_processor_head) {
+ return NULL;
+ }
+
+ processor = m_processor_head->processor;
+ return processor;
+}
+
+
+
+cfilter_module *cdata_stream::select_filter(void)
+{
+ cfilter_module *filter;
+
+ if (!m_filter_head) {
+ return NULL;
+ }
+
+ filter = m_filter_head->filter;
+ return filter;
+}
+
+
+
+bool cdata_stream::start(void)
+{
+ cprocessor_module *processor;
+
+ pthread_mutex_lock(&mutex_lock);
+ if (m_client > 0) {
+ DBG("m_client > 0\n");
+ m_client++;
+ pthread_mutex_unlock(&mutex_lock);
+ return true;
+ }
+
+ DBG("Select processor\n");
+ processor = select_processor();
+ if (!processor)
+ {
+ pthread_mutex_unlock(&mutex_lock);
+ return false;
+ }
+
+ DBG("Processor starting\n");
+
+ if(processor->start())
+ {
+ m_client++;
+ pthread_mutex_unlock(&mutex_lock);
+ return true;
+ }
+ else
+ {
+
+ DBG("Processor already started\n");
+ pthread_mutex_unlock(&mutex_lock);
+ return false;
+ }
+}
+
+
+
+bool cdata_stream::stop(void)
+{
+ cprocessor_module *processor;
+
+ pthread_mutex_lock(&mutex_lock);
+ if (m_client > 1) {
+ m_client--;
+ pthread_mutex_unlock(&mutex_lock);
+ return true;
+ }
+
+ DBG("Select processor for stop\n");
+ processor = select_processor();
+ if (!processor)
+ {
+ pthread_mutex_unlock(&mutex_lock);
+ return false;
+ }
+
+ DBG("Processor stop\n");
+ if( processor->stop())
+ {
+ m_client--;
+ pthread_mutex_unlock(&mutex_lock);
+ DBG("processor stop successed\n");
+ return true;
+ }
+ else
+ {
+ m_client = 0;
+ DBG("processor stop failed\n");
+ pthread_mutex_unlock(&mutex_lock);
+ return false;
+ }
+}
+
+
+
+bool cdata_stream::add_event_callback(void *(*handler)(cprocessor_module *, void *), void *data, bool (*rm_cb_data)(void *))
+{
+ cprocessor_module *processor;
+
+ processor = select_processor();
+ if (!processor) return false;
+
+ return processor->add_event_callback(handler, data, rm_cb_data);
+}
+
+
+
+bool cdata_stream::rm_event_callback(void *(*handler)(cprocessor_module *, void*), void *data)
+{
+ cprocessor_module *processor;
+
+ processor = select_processor();
+ if (!processor) return false;
+
+ return processor->rm_event_callback(handler, data);
+}
+
+
+
+void cdata_stream::wakeup_all_client(void)
+{
+ cprocessor_module *processor;
+
+ processor = select_processor();
+ if (!processor) return;
+
+ processor->wakeup_all_client();
+}
+
+
+
+long cdata_stream::value(value_type_t type, char *port)
+{
+ long ret = -EINVAL;
+ cfilter_module *filter;
+ cprocessor_module *processor;
+
+ switch (type) {
+ case cdata_stream::FILTER:
+ filter = select_filter();
+ if (!filter) {
+ ERR("No filter selected\n");
+ return -EFAULT;
+ }
+ ret = filter->value(port);
+ break;
+ case cdata_stream::PROCESSOR:
+ processor = select_processor();
+ if (!processor) {
+ ERR("No processor selected\n");
+ return -EFAULT;
+ }
+ ret = processor->value(port);
+ break;
+ case cdata_stream::SENSOR:
+ default:
+ ERR("Unsupported\n");
+ break;
+ }
+
+ return ret;
+}
+
+
+
+long cdata_stream::value(value_type_t type, int id)
+{
+ long ret = 0;
+ cfilter_module *filter;
+ cprocessor_module *processor;
+
+ switch (type) {
+ case cdata_stream::FILTER:
+ filter = select_filter();
+ if (!filter) {
+ ERR("No filter selected\n");
+ return -1;
+ }
+ ret = filter->value(id);
+ break;
+ case cdata_stream::PROCESSOR:
+ processor = select_processor();
+ if (!processor) {
+ ERR("No processor selected\n");
+ return -1;
+ }
+ ret = processor->value(id);
+ break;
+ case cdata_stream::SENSOR:
+ default:
+ ERR("Unsupported\n");
+ break;
+ }
+
+ return ret;
+}
+
+int cdata_stream::get_struct_value(value_type_t type, unsigned int struct_id , void *struct_values){
+ int ret = 0;
+ cfilter_module *filter;
+ cprocessor_module *processor;
+
+ switch (type) {
+ case cdata_stream::FILTER:
+ filter = select_filter();
+ if (!filter) {
+ ERR("No filter selected\n");
+ return -1;
+ }
+ ret = filter->get_struct_value(struct_id , struct_values);
+ break;
+ case cdata_stream::PROCESSOR:
+ processor = select_processor();
+ if (!processor) {
+ ERR("No processor selected\n");
+ return -1;
+ }
+ ret = processor->get_struct_value(struct_id , struct_values);
+ break;
+
+ default:
+ ERR("Unsupported\n");
+ break;
+ }
+
+ return ret;
+}
+
+
+cdata_stream *cdata_stream::search_stream(char *name)
+{
+ if ( !name ) {
+ ERR("Error name ptr check (%s)", __FUNCTION__);
+ return NULL;
+ }
+ cdata_stream *item;
+ item = cdata_stream::m_head;
+ while (item) {
+ if ( item->name() && !strcmp(name, item->name()) ) {
+ break;
+ }
+ else if ( item == item->m_tail ) {
+ item = NULL;
+ break;
+ }
+
+ item = (cdata_stream*)item->next();
+ }
+
+ return item;
+}
+
+
+
+cdata_stream *cdata_stream::search_stream(int id)
+{
+ cdata_stream *item;
+ item = cdata_stream::m_head;
+ while (item) {
+ if (item->id() == id) {
+ break;
+ }
+ else if ( item == item->m_tail ) {
+ item = NULL;
+ break;
+ }
+
+ item = (cdata_stream*)item->next();
+ }
+
+ return item;
+}
+
+cprocessor_module *cdata_stream::my_processor(void)
+{
+ cprocessor_module *processor;
+
+ processor = select_processor();
+
+ if (!processor) {
+ ERR("No processor selected\n");
+ return NULL;
+ }
+
+ return processor;
+
+}
+
+cfilter_module *cdata_stream::my_filter(void)
+{
+ cfilter_module *filter;
+
+ filter = select_filter();
+
+ if (!filter) {
+ ERR("No filter selected\n");
+ return NULL;
+ }
+
+ return filter;
+
+}
+
+bool cdata_stream::add_callback_func(cmd_reg_t * param)
+{
+ cprocessor_module *processor;
+ processor = select_processor();
+
+ if (!processor) {
+ ERR("There is no processor !!");
+ return false;
+ }
+
+ return processor->add_callback_func(param);
+}
+
+bool cdata_stream::remove_callback_func(cmd_reg_t * param)
+{
+ cprocessor_module *processor;
+ processor = select_processor();
+
+ if (!processor) {
+ ERR("There is no processor !!");
+ return false;
+ }
+
+ return processor->remove_callback_func(param);
+}
+
+bool cdata_stream::check_callback_event(cmd_reg_t * param)
+{
+ cprocessor_module *processor;
+ processor = select_processor();
+
+ if (!processor) {
+ ERR("There is no processor !!");
+ return false;
+ }
+
+ return processor->check_callback_event(param);
+}
+
+long cdata_stream::set_cmd(int type , int property , long input_value)
+{
+ cprocessor_module *processor;
+ processor = select_processor();
+
+ if (!processor) {
+ ERR("There is no processor !!");
+ return -1;
+ }
+
+ return processor->set_cmd(type , property , input_value);
+
+}
+
+int cdata_stream::get_property(unsigned int property_level , void *property_data )
+{
+ cprocessor_module *processor;
+ processor = select_processor();
+
+ if (!processor) {
+ ERR("There is no processor !!");
+ return -1;
+ }
+
+ return processor->get_property(property_level , property_data);
+
+}
+
+
+//! End of a file
--- /dev/null
+/*
+ * sensor-framework
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: JuHyun Kim <jh8212.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <dlfcn.h>
+#include <string.h>
+
+#include <sys/un.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+#include <common.h>
+#include <cobject_type.h>
+
+#include <clist.h>
+#include <cmutex.h>
+#include <ccatalog.h>
+#include <csync.h>
+#include <cworker.h>
+#include <cipc_worker.h>
+#include <csock.h>
+#include <cpacket.h>
+#include <sf_common.h>
+#include <cmodule.h>
+#include <csensor_module.h>
+#include <cfilter_module.h>
+#include <cfilter_catalog.h>
+
+#include <resource_str.h>
+
+
+
+cfilter_catalog::cfilter_catalog()
+{
+}
+
+
+
+cfilter_catalog::~cfilter_catalog()
+{
+}
+
+
+
+bool cfilter_catalog::create(char *file)
+{
+ void *handle;
+ char *name;
+ char *value;
+ cmodule *module;
+
+ if (ccatalog::load(file) == false) {
+ if ( ccatalog::is_loaded() ) {
+ DBG("The catalog is already loaded , so first unload it");
+ ccatalog::unload();
+ }
+ ERR("Failed to load a catalog file\n");
+ return false;
+ }
+
+ handle = ccatalog::iterate_init();
+ while (handle) {
+ name = ccatalog::iterate_get_name(handle);
+ handle = ccatalog::iterate_next(handle);
+ if (!name) {
+ ERR("Name is null\n");
+ continue;
+ }
+
+ value = ccatalog::value(name, (char*)STR_DISABLE);
+ if (value && !strcasecmp(value, STR_YES)) {
+ ERR("%s is disabled\n", name);
+ continue;
+ }
+
+ value = ccatalog::value(name, (char*)STR_PATH);
+ if (!value) {
+ ERR("Module path is not defined\n");
+ continue;
+ }
+
+ module = cfilter_module::register_module(value, NULL, NULL);
+ if (!module) {
+ ERR("Failed to register a module %s\n", name);
+ continue;
+ }
+
+ value = ccatalog::value(name, (char*)STR_OVERRIDE);
+ if (value && !strcasecmp(value, STR_YES)) {
+ DBG("Let's override module description\n");
+
+ if (module->update_name(name) == false) {
+ ERR("Failed to update module name\n");
+ }
+
+ value = ccatalog::value(name, (char*)STR_ID);
+ if (value) {
+ if (module->update_id(atoi(value)) == false) {
+ ERR("Failed to update ID\n");
+ }
+ }
+
+ value = ccatalog::value(name, (char*)STR_VERSION);
+ if (value) {
+ if (module->update_version(atoi(value)) == false) {
+ ERR("Failed to update version\n");
+ }
+ }
+ }
+ }
+
+ DBG("Finished registeration , unload filter.conf ");
+ ccatalog::unload();
+
+ return true;
+}
+
+
+
+void cfilter_catalog::destroy(void)
+{
+ if ( ccatalog::is_loaded() ) {
+ ccatalog::unload();
+ }
+}
+
+
+
+//! End of a file
--- /dev/null
+/*
+ * sensor-framework
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: JuHyun Kim <jh8212.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <dlfcn.h>
+#include <string.h>
+
+#include <sys/un.h>
+#include <arpa/inet.h>
+#include <netinet/in.h>
+
+#include <common.h>
+
+#include <cobject_type.h>
+#include <clist.h>
+#include <cmutex.h>
+#include <ccatalog.h>
+#include <cmodule.h>
+#include <csync.h>
+#include <cworker.h>
+#include <cipc_worker.h>
+#include <csock.h>
+#include <cpacket.h>
+#include <sf_common.h>
+
+#include <csensor_module.h>
+#include <cfilter_module.h>
+#include <cprocessor_module.h>
+#include <cprocessor_catalog.h>
+
+#include <resource_str.h>
+
+
+cprocessor_catalog::cprocessor_catalog()
+{
+}
+
+
+
+cprocessor_catalog::~cprocessor_catalog()
+{
+}
+
+
+
+bool cprocessor_catalog::create(char *file)
+{
+ void *handle;
+ char *name;
+ char *value;
+ cmodule *module;
+
+ if (ccatalog::load(file) == false) {
+ if ( ccatalog::is_loaded() ) {
+ DBG("The catalog is already loaded , so first unload it");
+ ccatalog::unload();
+ }
+ ERR("Failed to load a catalog file\n");
+ return false;
+ }
+
+ handle = ccatalog::iterate_init();
+ while (handle) {
+ name = ccatalog::iterate_get_name(handle);
+ handle = ccatalog::iterate_next(handle);
+ if (!name) {
+ ERR("Name is null\n");
+ continue;
+ }
+
+ value = ccatalog::value(name, (char*)STR_DISABLE);
+ if (value && !strcasecmp(value, STR_YES)) {
+ ERR("%s is disabled\n", name);
+ continue;
+ }
+
+ value = ccatalog::value(name, (char*)STR_PATH);
+ if (!value) {
+ ERR("Module path is not defined\n");
+ continue;
+ }
+
+ module = cprocessor_module::register_module(value, NULL, NULL);
+ if (!module) {
+ ERR("Failed to register a module %s\n", name);
+ continue;
+ }
+
+ value = ccatalog::value(name, (char*)STR_OVERRIDE);
+ if (value && !strcasecmp(value, STR_YES)) {
+ DBG("Let's override module description\n");
+
+ if (module->update_name(name) == false) {
+ ERR("Failed to update module name\n");
+ }
+
+ value = ccatalog::value(name, (char*)STR_ID);
+ if (value) {
+ if (module->update_id(atoi(value)) == false) {
+ ERR("Failed to update ID\n");
+ }
+ }
+
+ value = ccatalog::value(name, (char*)STR_VERSION);
+ if (value) {
+ if (module->update_version(atoi(value)) == false) {
+ ERR("Failed to update version\n");
+ }
+ }
+ }
+ }
+
+ DBG("Finished registeration , unload processor.conf ");
+ ccatalog::unload();
+
+ return true;
+}
+
+
+
+void cprocessor_catalog::destroy(void)
+{
+ if ( ccatalog::is_loaded() ) {
+ ccatalog::unload();
+ }
+}
+
+
+
+//! End of a file
--- /dev/null
+/*
+ * sensor-framework
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: JuHyun Kim <jh8212.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+
+#include <sys/un.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+#include <common.h>
+
+#include <cobject_type.h>
+
+#include <clist.h>
+#include <cmutex.h>
+#include <cpacket.h>
+#include <csync.h>
+#include <cworker.h>
+#include <cipc_worker.h>
+#include <csock.h>
+
+#include <sf_common.h>
+#include <cmodule.h>
+#include <ccatalog.h>
+#include <csensor_module.h>
+#include <csensor_catalog.h>
+
+#include <resource_str.h>
+
+
+#define MAX_LINE 512
+
+
+
+csensor_catalog::csensor_catalog()
+{
+}
+
+
+
+csensor_catalog::~csensor_catalog()
+{
+}
+
+
+
+bool csensor_catalog::create(char *file)
+{
+ void *handle;
+ char *name;
+ char *value;
+ cmodule *module;
+
+ if (ccatalog::load(file) == false) {
+ if ( ccatalog::is_loaded() ) {
+ DBG("The catalog is already loaded , so first unload it");
+ ccatalog::unload();
+ }
+ ERR("Failed to load a catalog file\n");
+ return false;
+ }
+
+ handle = ccatalog::iterate_init();
+ while (handle) {
+ name = ccatalog::iterate_get_name(handle);
+ handle = ccatalog::iterate_next(handle);
+ if (!name) {
+ ERR("Name is null\n");
+ continue;
+ }
+
+ value = ccatalog::value(name, (char*)STR_DISABLE);
+ if (value && !strcasecmp(value, STR_YES)) {
+ ERR("%s is disabled\n", name);
+ continue;
+ }
+
+ value = ccatalog::value(name, (char*)STR_PATH);
+ if (!value) {
+ ERR("Module path is not defined\n");
+ continue;
+ }
+
+ module = csensor_module::register_module(value, NULL, NULL);
+ if (!module) {
+ ERR("Failed to register a module %s\n", name);
+ continue;
+ }
+
+ value = ccatalog::value(name, (char*)STR_OVERRIDE);
+ if (value && !strcasecmp(value, STR_YES)) {
+ DBG("Let's override module description [%s]\n", name);
+
+ if (module->update_name(name) == false) {
+ ERR("Failed to update module name\n");
+ }
+
+ value = ccatalog::value(name, (char*)STR_ID);
+ if (value) {
+ if (module->update_id(atoi(value)) == false) {
+ ERR("Failed to update ID\n");
+ }
+ }
+
+ value = ccatalog::value(name, (char*)STR_VERSION);
+ if (value) {
+ if (module->update_version(atoi(value)) == false) {
+ ERR("Failed to update version\n");
+ }
+ }
+
+ value = ccatalog::value(name, (char*)STR_POLL);
+ if (value) {
+ csensor_module *sensor;
+ sensor = (csensor_module*)module;
+ if (sensor->update_polling_interval(atoi(value)) == false) {
+ ERR("Failed to update polling interval\n");
+ }
+ }
+ }
+ }
+
+ DBG("Finished registeration , unload sensor.conf ");
+ ccatalog::unload();
+
+ return true;
+}
+
+
+
+void csensor_catalog::destroy(void)
+{
+ if ( ccatalog::is_loaded() ) {
+ ccatalog::unload();
+ }
+}
+
+
+
+
+//! End of a file
--- /dev/null
+/*
+ * sensor-framework
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: JuHyun Kim <jh8212.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+
+
+#include <stdio.h>
+#include <errno.h>
+#include <dlfcn.h>
+#include <pthread.h>
+#include <string.h>
+
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/stat.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <unistd.h>
+#include <sys/un.h>
+#include <fcntl.h>
+#include <time.h>
+
+#include <common.h>
+
+#include <cobject_type.h>
+
+#include <csync.h>
+
+#include <clist.h>
+#include <cmutex.h>
+
+#include <cworker.h>
+#include <cipc_worker.h>
+#include <csock.h>
+
+#include <cmodule.h>
+#include <cpacket.h>
+#include <sf_common.h>
+
+#include <ccatalog.h>
+
+#include <csensor_module.h>
+#include <cfilter_module.h>
+#include <cprocessor_module.h>
+#include <cdata_stream.h>
+
+#include <cserver.h>
+#include <resource_str.h>
+
+#include <glib.h>
+
+
+cserver::cserver()
+{
+ memset(m_cmd_handler, '\0', sizeof(cmd_func_t) * CMD_LAST);
+ m_cmd_handler[CMD_HELLO] = cmd_hello;
+ m_cmd_handler[CMD_BYEBYE] = cmd_byebye;
+ m_cmd_handler[CMD_GET_VALUE] = cmd_get_value;
+ m_cmd_handler[CMD_WAIT_EVENT] = cmd_wait_event;
+ m_cmd_handler[CMD_START] = cmd_start;
+ m_cmd_handler[CMD_STOP] = cmd_stop;
+ m_cmd_handler[CMD_REG] = cmd_register_event;
+ m_cmd_handler[CMD_SET_VALUE] = cmd_set_value;
+ m_cmd_handler[CMD_GET_PROPERTY] = cmd_get_property;
+ m_cmd_handler[CMD_GET_STRUCT] = cmd_get_struct;
+}
+
+
+
+cserver::~cserver()
+{
+}
+
+void *cserver::cmd_hello(void *cmd_item, void *data)
+{
+ cmd_queue_item_t *queue_item = (cmd_queue_item_t*)cmd_item;
+ csock::thread_arg_t *arg = queue_item->arg;
+ client_ctx_t *ctx;
+ cmd_hello_t *payload;
+ csock ipc(arg->client_handle, csock::SOCK_TCP);
+ ipc.set_on_close(false);
+ cpacket *packet = queue_item->packet;
+ cmd_done_t *return_payload;
+ cfilter_module *filter;
+ csensor_module *sensor;
+ cdata_stream *stream;
+ long value = -1;
+
+ DBG("CMD_HELLO Handler invoked\n");
+ ctx = (client_ctx_t*)arg->client_ctx;
+ payload = (cmd_hello_t*)queue_item->packet->data();
+
+ DBG("Hello %d, %s\n", payload->id, payload->name);
+
+ if (payload->id != ID_UNKNOWN) {
+ ctx->module = (ctype*)cmodule::search_module(payload->id);
+ if (!ctx->module)
+ ctx->module = (ctype*)cdata_stream::search_stream(payload->id);
+
+ } else {
+ ctx->module = (ctype*)cmodule::search_module(payload->name);
+ if (!ctx->module)
+ ctx->module = (ctype*)cdata_stream::search_stream(payload->name);
+ }
+
+ if (!ctx->module) {
+ ERR("There is no proper module found (%s)\n", __FUNCTION__ );
+ value = -1;
+ } else {
+ DBG("ctx->module->type() = [%d]\n");
+ switch (ctx->module->type()) {
+ case csensor_module::SF_PLUGIN_SENSOR:
+ sensor = (csensor_module*)ctx->module;
+ value = sensor->get_sensor_type();
+ break;
+
+ case cdata_stream::SF_DATA_STREAM:
+ stream = (cdata_stream *)ctx->module;
+ filter = stream->my_filter();
+ if (filter) {
+ value = filter->get_sensor_type();
+ } else {
+ value = ID_UNKNOWN;
+ }
+ break;
+
+ default :
+ value = ID_UNKNOWN;
+ break;
+
+ }
+
+ }
+
+ ctx->client_state = 0;
+
+ packet->set_cmd(CMD_DONE);
+ packet->set_payload_size(sizeof(cmd_done_t));
+ return_payload = (cmd_done_t*)packet->data();
+
+ if ( !return_payload ) {
+ ERR("Error return_payload ptr check (%s) , retry to send using dummy packet\n", __FUNCTION__);
+ cpacket dummy_packet(sizeof(cmd_done_t)+4);
+ cmd_done_t *dummy_payload;
+ dummy_packet.set_cmd(CMD_DONE);
+ dummy_packet.set_payload_size(sizeof(cmd_done_t));
+ dummy_payload = (cmd_done_t*)dummy_packet.data();
+ if ( !dummy_payload ) {
+ ERR("Error second dummy_payload ptr check");
+ return (void *)NULL;
+ }
+
+ dummy_payload->value = value;
+
+ if (ipc.send( dummy_packet.packet(), dummy_packet.size()) == false) {
+ ERR("Failed to send a dummy value packet (%s)\n",__FUNCTION__);
+ return (void *)NULL;
+ }
+
+ return (void *)NULL;
+ }
+ return_payload->value = value;
+
+ DBG("Send value %ld\n", value);
+ if (ipc.send(queue_item->packet->packet(), queue_item->packet->size()) == false) {
+ ERR("Failed to send a value packet (%s)\n",__FUNCTION__);
+ return (void *)NULL;
+ }
+
+ return (void *)NULL;
+}
+
+
+
+void *cserver::cmd_byebye(void *cmd_item, void *data)
+{
+ cmd_queue_item_t *queue_item = (cmd_queue_item_t*)cmd_item;
+ csock::thread_arg_t *arg = queue_item->arg;
+ client_ctx_t *ctx;
+ cprocessor_module *processor;
+ cfilter_module *filter;
+ csensor_module *sensor;
+ cdata_stream *stream;
+ cpacket *packet = queue_item->packet;
+ csock ipc(arg->client_handle, csock::SOCK_TCP);
+ ipc.set_on_close(false);
+
+ ctx = (client_ctx_t*)arg->client_ctx;
+
+ if (arg->worker->state() != cipc_worker::START) {
+ ERR("Client disconnected (%s)\n",__FUNCTION__);
+ return (void*)NULL;
+ }
+
+ DBG("CMD_BYEBYE Handler invoked ctx->client_state = %d\n",ctx->client_state);
+
+ if (ctx->client_state > 0) {
+ if ( !ctx->module ) {
+ ERR("Error ctx->module ptr check");
+ goto out;
+ }
+ switch (ctx->module->type()) {
+ case csensor_module::SF_PLUGIN_SENSOR:
+ sensor = (csensor_module*)ctx->module;
+ DBG("Server does not received cmd_stop before detach!! forced stop, sensor_type : %d\n", sensor->get_sensor_type());
+ sensor->stop();
+ ctx->client_state --;
+ break;
+
+ case cprocessor_module::SF_PLUGIN_PROCESSOR:
+ processor = (cprocessor_module*)ctx->module;
+ DBG("Server does not received cmd_stop before detach!! forced stop, processor\n" );
+ processor->stop();
+ processor->wakeup_all_client();
+ ctx->client_state -- ;
+ break;
+
+ case cfilter_module::SF_PLUGIN_FILTER:
+ filter = (cfilter_module *)ctx->module;
+ DBG("Server does not received cmd_stop before detach!! forced stop, filter_type : %d\n", filter->get_sensor_type());
+ filter->stop();
+ ctx->client_state -- ;
+ break;
+
+ case cdata_stream::SF_DATA_STREAM:
+ stream = (cdata_stream*)ctx->module;
+ DBG("doesnot recevied cmd_stop before detach!! forced stop, stream_name : %s stop\n", stream->name());
+ stream->stop();
+ stream->wakeup_all_client();
+ ctx->client_state -- ;
+ break;
+
+ default:
+ ERR("Unknown type (%s)\n",__FUNCTION__);
+ break;
+ }
+ }
+
+out:
+
+ packet->set_cmd(CMD_DONE);
+
+ if (ipc.send(packet->packet(), packet->size()) == false) {
+ ERR("Failed to send reply packet (%s)\n", __FUNCTION__);
+ return (void*)NULL;
+ }
+
+ arg->worker->stop();
+
+ return (void *)NULL;
+}
+
+
+
+void *cserver::cmd_start(void *cmd_item, void *data)
+{
+ cmd_queue_item_t *queue_item = (cmd_queue_item_t*)cmd_item;
+ csock::thread_arg_t *arg = queue_item->arg;
+ client_ctx_t *ctx = (client_ctx_t*)arg->client_ctx;
+ cpacket *packet = queue_item->packet;
+ csock ipc(arg->client_handle, csock::SOCK_TCP);
+ cmd_done_t *return_payload;
+ long value = 0;
+
+ ipc.set_on_close(false);
+
+ if (arg->worker->state() != cipc_worker::START) {
+ ERR("Client disconnected (%s)\n",__FUNCTION__);
+ value = -1;
+ goto out;
+ }
+
+ DBG("CMD_START Handler invoked ctx->client_state = %d\n", ctx->client_state);
+
+ if ( !(ctx->module) ) {
+ ERR("Error ctx->module ptr check(%s)", __FUNCTION__);
+ value = -1;
+ goto out;
+ }
+
+ if (ctx->module->type() == cprocessor_module::SF_PLUGIN_PROCESSOR) {
+ cprocessor_module *processor = (cprocessor_module*)ctx->module;
+ DBG("Invoke Processor start\n");
+ if (ctx->client_state > 0) {
+ ERR("This module has already started\n");
+ }
+ else {
+ if ( processor->start() )
+ ctx->client_state ++ ;
+ else
+ value = -3;
+ }
+ } else if (ctx->module->type() == cdata_stream::SF_DATA_STREAM) {
+ cdata_stream *stream = (cdata_stream*)ctx->module;
+ DBG("Invoke Stream start for [%s]\n",stream->name());
+ if (ctx->client_state > 0) {
+ ERR("This module has already started\n");
+ }
+ else {
+ if ( stream->start())
+ ctx->client_state++ ;
+ else
+ value = -3;
+ }
+ } else if (ctx->module->type() == csensor_module::SF_PLUGIN_SENSOR) {
+ csensor_module *sensor = (csensor_module*)ctx->module;
+ DBG("Invoke Sensor start\n");
+ if (ctx->client_state > 0) {
+ ERR("This module has already started\n");
+ }
+ else {
+ if ( sensor->start() )
+ ctx->client_state ++ ;
+ else
+ value = -3;
+ }
+ } else if (ctx->module->type() == cfilter_module::SF_PLUGIN_FILTER) {
+ cfilter_module *filter = (cfilter_module*)ctx->module;
+ DBG("Invoke Filter start\n");
+ if (ctx->client_state > 0) {
+ ERR("This module has already started\n");
+ }
+ else {
+ if ( filter->start() )
+ ctx->client_state ++ ;
+ else
+ value = -3;
+ }
+ } else {
+ ERR("This module has no start operation (%s)\n",__FUNCTION__);
+ }
+
+out:
+
+ packet->set_cmd(CMD_DONE);
+ packet->set_payload_size(sizeof(cmd_done_t));
+ return_payload = (cmd_done_t*)packet->data();
+
+ if ( !return_payload ) {
+ ERR("Error return_payload ptr check (%s) , retry to send using dummy packet\n", __FUNCTION__);
+ cpacket dummy_packet(sizeof(cmd_done_t)+4);
+ cmd_done_t *dummy_payload;
+ dummy_packet.set_cmd(CMD_DONE);
+ dummy_packet.set_payload_size(sizeof(cmd_done_t));
+ dummy_payload = (cmd_done_t*)dummy_packet.data();
+ if ( !dummy_payload ) {
+ ERR("Error second dummy_payload ptr check");
+ return (void *)NULL;
+ }
+ dummy_payload->value = value;
+
+ if (ipc.send( dummy_packet.packet(), dummy_packet.size()) == false)
+ ERR("Failed to send a dummy value packet (%s)\n",__FUNCTION__);
+
+ return (void *)NULL;
+ }
+
+ return_payload->value = value;
+
+ DBG("Send value %ld\n", value);
+
+ if (ipc.send(queue_item->packet->packet(), queue_item->packet->size()) == false)
+ ERR("Failed to send a value packet (%s)\n",__FUNCTION__);
+
+ return (void*)NULL;
+}
+
+
+
+
+
+void *cserver::cmd_stop(void *cmd_item, void *data)
+{
+ cmd_queue_item_t *queue_item = (cmd_queue_item_t*)cmd_item;
+ csock::thread_arg_t *arg = queue_item->arg;
+ client_ctx_t *ctx = (client_ctx_t*)arg->client_ctx;
+ csock ipc(arg->client_handle, csock::SOCK_TCP);
+ ipc.set_on_close(false);
+
+ if (arg->worker->state() != cipc_worker::START) {
+ ERR("Client disconnected (%s)\n",__FUNCTION__);
+ return (void*)NULL;
+ }
+
+ DBG("CMD_STOP Handler invoked ctx->client_state = %d\n", ctx->client_state);
+
+ if ( !(ctx->module) ) {
+ ERR("Error ctx->module ptr check(%s)", __FUNCTION__);
+ return (void*)NULL;
+ }
+
+ if (ctx->module->type() == cprocessor_module::SF_PLUGIN_PROCESSOR) {
+ cprocessor_module *processor = (cprocessor_module*)ctx->module;
+ //! Before stopping processor, we need to wakeup the clients
+ DBG("Invoke Processor stop\n");
+ if (ctx->client_state < 1) {
+ ERR("This module has already stopped\n");
+ }
+ else {
+ if (processor->stop() ) {
+ processor->wakeup_all_client();
+ ctx->client_state --;
+ }
+ }
+ } else if (ctx->module->type() == cdata_stream::SF_DATA_STREAM) {
+ cdata_stream *stream = (cdata_stream*)ctx->module;
+ //! Before stopping stream, we need to wakeup the clients
+ DBG("Invoke Stream stop\n");
+ if (ctx->client_state < 1) {
+ ERR("This module has already stopped\n");
+ }
+ else {
+ DBG("Now stop %s \n", stream->name());
+ if (stream->stop() ) {
+ stream->wakeup_all_client();
+ ctx->client_state --;
+ }
+ }
+ } else if (ctx->module->type() == csensor_module::SF_PLUGIN_SENSOR) {
+ csensor_module *sensor = (csensor_module*)ctx->module;
+ DBG("Invoke Sensor stop\n");
+ if (ctx->client_state < 1) {
+ ERR("This module has already stopped\n");
+ }
+ else {
+ if (sensor->stop() ) {
+ ctx->client_state --;
+ }
+ }
+ } else if (ctx->module->type() == cfilter_module::SF_PLUGIN_FILTER) {
+ cfilter_module *filter = (cfilter_module*)ctx->module;
+ DBG("Invoke Filter stop\n");
+ if (ctx->client_state < 1) {
+ ERR("This module has already stopped\n");
+ }
+ else {
+ if (filter->stop() ) {
+ ctx->client_state --;
+ }
+ }
+ } else {
+ ERR("This module has no stop operation (%s)\n",__FUNCTION__);
+ }
+
+ return (void*)NULL;
+}
+
+
+
+void *cserver::cmd_wait_event(void *cmd_item, void *data)
+{
+ cmd_queue_item_t *queue_item = (cmd_queue_item_t*)cmd_item;
+ csock::thread_arg_t *arg = queue_item->arg;
+ client_ctx_t *ctx = (client_ctx_t*)arg->client_ctx;
+ cpacket *packet = queue_item->packet;
+ long return_value =0;
+
+ if (arg->worker->state() != cipc_worker::START) {
+ ERR("Client disconnected (%s)\n",__FUNCTION__);
+ return (void*)NULL;
+ }
+
+ DBG("CMD_WAIT_EVENT Handler invoked\n");
+
+ if ( !(ctx->module) ) {
+ ERR("Error ctx->module ptr check(%s)", __FUNCTION__);
+ goto out;
+ }
+
+ if (ctx->module->type() == cdata_stream::SF_DATA_STREAM) {
+ cdata_stream *data_stream;
+ data_stream = (cdata_stream*)ctx->module;
+ data_stream->add_event_callback(cb_event_handler, arg, NULL);
+ DBG("Add event callback for data stream\n");
+ return (void*)NULL;
+
+ } else if (ctx->module->type() == cprocessor_module::SF_PLUGIN_PROCESSOR) {
+ cprocessor_module *processor;
+ processor = (cprocessor_module*)ctx->module;
+ processor->add_event_callback(cb_event_handler, arg, NULL);
+ DBG("Add event callback for processor\n");
+ return (void*)NULL;
+
+ } else if (ctx->module->type() == cfilter_module::SF_PLUGIN_FILTER) {
+ cfilter_module *filter;
+ filter = (cfilter_module*)ctx->module;
+ filter->is_data_ready(true);
+ DBG("wait to ready for data in filter\n");
+
+ } else if (ctx->module->type() == csensor_module::SF_PLUGIN_SENSOR) {
+ csensor_module *sensor;
+ sensor = (csensor_module*)ctx->module;
+ sensor->is_data_ready(true);
+ DBG("wait to ready for data in sensor\n");
+
+ } else {
+ return_value = -1; //! Unknown status
+ ERR("Unsupported command for the attached module (%s)\n",__FUNCTION__);
+ }
+
+out:
+
+ csock ipc(arg->client_handle, csock::SOCK_TCP);
+ cmd_done_t *payload;
+ ipc.set_on_close(false);
+
+ packet->set_cmd(CMD_DONE);
+ packet->set_payload_size(sizeof(cmd_done_t));
+ payload = (cmd_done_t*)packet->data();
+ payload->value = return_value;
+ if (ipc.send(packet->packet(), packet->size()) == false) {
+ ERR("Failed to send a packet (%s)\n",__FUNCTION__);
+ }
+
+ return (void*)NULL;
+}
+
+
+
+void *cserver::cmd_get_value(void *cmd_item, void *data)
+{
+ cmd_queue_item_t *queue_item = (cmd_queue_item_t*)cmd_item;
+ csock::thread_arg_t *arg = queue_item->arg;
+ client_ctx_t *ctx = (client_ctx_t*)arg->client_ctx;
+ cmd_get_value_t *payload;
+ cmd_done_t *return_payload;
+ csock ipc(arg->client_handle, csock::SOCK_TCP);
+ ipc.set_on_close(false);
+ cpacket *packet = queue_item->packet;
+ long value = -1;
+
+ if (arg->worker->state() != cipc_worker::START) {
+ ERR("Client disconnected (%s)\n",__FUNCTION__);
+ return (void*)NULL;
+ }
+
+ DBG("CMD_GET_VALUE Handler invoked\n");
+
+ payload = (cmd_get_value_t*)packet->data();
+
+ if ( !(ctx->module) ) {
+ ERR("Error ctx->module ptr check(%s)", __FUNCTION__);
+ goto out;
+ }
+
+ if (ctx->module->type() == cfilter_module::SF_PLUGIN_FILTER) {
+ if(payload->id != -1 ) {
+ value = ((cfilter_module*)ctx->module)->value(payload->id);
+ } else {
+ value = ((cfilter_module*)ctx->module)->value(payload->port);
+ }
+ } else if (ctx->module->type() == csensor_module::SF_PLUGIN_SENSOR) {
+ if(payload->id != -1 ) {
+ value = ((csensor_module*)ctx->module)->value(payload->id);
+ } else {
+ value = ((csensor_module*)ctx->module)->value(payload->port);
+ }
+
+ } else if (ctx->module->type() == cprocessor_module::SF_PLUGIN_PROCESSOR) {
+ if(payload->id != -1 ) {
+ value = ((cprocessor_module*)ctx->module)->value(payload->id);
+ } else {
+ value = ((cprocessor_module*)ctx->module)->value(payload->port);
+ }
+ } else if (ctx->module->type() == cdata_stream::SF_DATA_STREAM) {
+ if(payload->id != -1 ) {
+ value = ((cdata_stream*)ctx->module)->value(cdata_stream::PROCESSOR, payload->id);
+ } else {
+ value = ((cdata_stream*)ctx->module)->value(cdata_stream::PROCESSOR, payload->port);
+ }
+ }
+
+out:
+
+ packet->set_cmd(CMD_DONE);
+ packet->set_payload_size(sizeof(cmd_done_t));
+ return_payload = (cmd_done_t*)packet->data();
+
+ if ( !return_payload ) {
+ ERR("Error return_payload ptr check (%s) , retry to send using dummy packet\n", __FUNCTION__);
+ cpacket dummy_packet(sizeof(cmd_done_t)+4);
+ cmd_done_t *dummy_payload;
+ dummy_packet.set_cmd(CMD_DONE);
+ dummy_packet.set_payload_size(sizeof(cmd_done_t));
+ dummy_payload = (cmd_done_t*)dummy_packet.data();
+ if ( !dummy_payload ) {
+ ERR("Error second dummy_payload ptr check");
+ return (void *)NULL;
+ }
+ dummy_payload->value = value;
+
+ if (ipc.send( dummy_packet.packet(), dummy_packet.size()) == false) {
+ ERR("Failed to send a dummy value packet (%s)\n",__FUNCTION__);
+ return (void *)NULL;
+ }
+
+ return (void *)NULL;
+ }
+
+ return_payload->value = value;
+
+ DBG("Send value %ld\n", value);
+ if (ipc.send(queue_item->packet->packet(), queue_item->packet->size()) == false) {
+ ERR("Failed to send a value packet (%s)\n",__FUNCTION__);
+ return (void *)NULL;
+ }
+
+ return (void *)NULL;
+}
+
+void *cserver::cmd_register_event(void *cmd_item, void *data)
+{
+ cmd_queue_item_t *queue_item = (cmd_queue_item_t*)cmd_item;
+ csock::thread_arg_t *arg = queue_item->arg;
+ client_ctx_t *ctx = (client_ctx_t*)arg->client_ctx;
+ cmd_reg_t *payload;
+ cmd_done_t *return_payload;
+ csock ipc(arg->client_handle, csock::SOCK_TCP);
+ ipc.set_on_close(false);
+ cpacket *packet = queue_item->packet;
+ long value = -1;
+
+ DBG("CMD_REG Handler invoked\n");
+
+ payload = (cmd_reg_t*)packet->data();
+
+ if ( !(ctx->module) ) {
+ ERR("Error ctx->module ptr check(%s)", __FUNCTION__);
+ goto out;
+ }
+
+ DBG("ctx->module->type() = [%d] cdata_stream::SF_DATA_STREAM = [%d]\n", ctx->module->type(),cdata_stream::SF_DATA_STREAM);
+ if ( ctx->module->type() == cdata_stream::SF_DATA_STREAM ) {
+ cdata_stream *data_stream;
+ data_stream = (cdata_stream*)ctx->module;
+
+ switch( payload->type ){
+ case REG_ADD:
+ DBG("CMD_REG_ADD callback func");
+ if ( data_stream->add_callback_func(payload) ) {
+ ctx->reg_state = (ctx->reg_state) | (payload->event_type) ;
+ DBG("REG_ADD current(final) reg_state : %x , payload_evet_type : %x",ctx->reg_state , payload->event_type);
+ value = REG_DONE;
+ }
+ break;
+ case REG_DEL:
+ DBG("CMD_REG_DEL callback func");
+ if ( data_stream->remove_callback_func(payload) ) {
+ ctx->reg_state = (ctx->reg_state) ^ (payload->event_type & 0xFFFF) ;
+ DBG("REG_DEL current(final) reg_state : %x , payload_evet_type : %x",ctx->reg_state , payload->event_type);
+ value = REG_DONE;
+ }
+ break;
+
+ case REG_CHK:
+ DBG("CMD_REG_CHK callback func");
+ if ( data_stream->check_callback_event(payload) ) {
+ value = REG_DONE;
+ }
+ break;
+
+ default:
+ ERR("unsupported reg_cmd type : %d\n" , payload->type );
+ break;
+ }
+ } else {
+
+ ERR("Not supported module type (%s)\n",__FUNCTION__);
+
+ }
+
+out:
+
+ packet->set_cmd(CMD_DONE);
+ packet->set_payload_size(sizeof(cmd_done_t));
+ return_payload = (cmd_done_t*)packet->data();
+
+ if ( !return_payload ) {
+ ERR("Error return_payload ptr check (%s) , retry to send using dummy packet\n", __FUNCTION__);
+ cpacket dummy_packet(sizeof(cmd_done_t)+4);
+ cmd_done_t *dummy_payload;
+ dummy_packet.set_cmd(CMD_DONE);
+ dummy_packet.set_payload_size(sizeof(cmd_done_t));
+ dummy_payload = (cmd_done_t*)dummy_packet.data();
+ if ( !dummy_payload ) {
+ ERR("Error second dummy_payload ptr check");
+ return (void *)NULL;
+ }
+ dummy_payload->value = value;
+
+ if (ipc.send( dummy_packet.packet(), dummy_packet.size()) == false) {
+ ERR("Failed to send a dummy value packet (%s)\n",__FUNCTION__);
+ return (void *)NULL;
+ }
+
+ return (void *)NULL;
+ }
+
+ return_payload->value = value;
+
+ DBG("Send value %ld\n", value);
+ if (ipc.send(queue_item->packet->packet(), queue_item->packet->size()) == false) {
+ ERR("Failed to send a value packet (%s)\n",__FUNCTION__);
+ return (void *)NULL;
+ }
+
+ return (void *)NULL;
+}
+
+void *cserver::cmd_set_value(void *cmd_item, void *data)
+{
+ cmd_queue_item_t *queue_item = (cmd_queue_item_t*)cmd_item;
+ csock::thread_arg_t *arg = queue_item->arg;
+ client_ctx_t *ctx = (client_ctx_t*)arg->client_ctx;
+ cmd_set_value_t *payload;
+ cmd_done_t *return_payload;
+ csock ipc(arg->client_handle, csock::SOCK_TCP);
+ ipc.set_on_close(false);
+ cpacket *packet = queue_item->packet;
+ long value = -1;
+
+ if (arg->worker->state() != cipc_worker::START) {
+ ERR("Client disconnected (%s)\n",__FUNCTION__);
+ return (void*)NULL;
+ }
+
+ DBG("CMD_SET_VALUE Handler invoked\n");
+
+ payload = (cmd_set_value_t*)packet->data();
+
+ if ( !(ctx->module) ) {
+ ERR("Error ctx->module ptr check(%s)", __FUNCTION__);
+ goto out;
+ }
+
+ if (ctx->module->type() == cprocessor_module::SF_PLUGIN_PROCESSOR) {
+ cprocessor_module *processor;
+ processor = (cprocessor_module*)ctx->module;
+ value = processor->set_cmd(payload->sensor_type, payload->property, payload->value);
+
+ } else if (ctx->module->type() == cdata_stream::SF_DATA_STREAM) {
+ cdata_stream *data_stream;
+ data_stream = (cdata_stream*)ctx->module;
+ value = data_stream->set_cmd(payload->sensor_type, payload->property, payload->value);
+
+ }
+
+out:
+ packet->set_cmd(CMD_DONE);
+ packet->set_payload_size(sizeof(cmd_done_t));
+ return_payload = (cmd_done_t*)packet->data();
+ if ( !return_payload ) {
+ ERR("Error return_payload ptr check (%s) , retry to send using dummy packet\n", __FUNCTION__);
+ cpacket dummy_packet(sizeof(cmd_done_t)+4);
+ cmd_done_t *dummy_payload;
+ dummy_packet.set_cmd(CMD_DONE);
+ dummy_packet.set_payload_size(sizeof(cmd_done_t));
+ dummy_payload = (cmd_done_t*)dummy_packet.data();
+ if ( !dummy_payload ) {
+ ERR("Error second dummy_payload ptr check");
+ return (void *)NULL;
+ }
+ dummy_payload->value = value;
+
+ if (ipc.send( dummy_packet.packet(), dummy_packet.size()) == false) {
+ ERR("Failed to send a dummy value packet (%s)\n",__FUNCTION__);
+ return (void *)NULL;
+ }
+
+ return (void *)NULL;
+ }
+ return_payload->value = value;
+
+ DBG("Send value %ld\n", value);
+ if (ipc.send(queue_item->packet->packet(), queue_item->packet->size()) == false) {
+ ERR("Failed to send a value packet (%s)\n",__FUNCTION__);
+ return (void *)NULL;
+ }
+
+ return (void *)NULL;
+}
+
+void *cserver::cmd_get_property(void *cmd_item, void *data)
+{
+ cmd_queue_item_t *queue_item = (cmd_queue_item_t*)cmd_item;
+ csock::thread_arg_t *arg = queue_item->arg;
+ client_ctx_t *ctx = (client_ctx_t*)arg->client_ctx;
+ cmd_get_property_t *payload;
+ cmd_return_property_t *return_payload;
+ csock ipc(arg->client_handle, csock::SOCK_TCP);
+ ipc.set_on_close(false);
+ cpacket *packet = queue_item->packet;
+
+ int state = -1;
+ unsigned int get_property_level = 0;
+ size_t get_property_size = 0;
+ void *return_property_struct = NULL;
+
+ base_property_struct return_base_property;
+
+ if (arg->worker->state() != cipc_worker::START) {
+ ERR("Client disconnected (%s)\n",__FUNCTION__);
+ return (void*)NULL;
+ }
+
+ DBG("CMD_SET_VALUE Handler invoked\n");
+
+ payload = (cmd_get_property_t*)packet->data();
+ get_property_level = payload->get_level;
+
+
+ if ( !(ctx->module) ) {
+ ERR("Error ctx->module ptr check(%s)", __FUNCTION__);
+ goto out;
+ }
+
+ if (ctx->module->type() == cdata_stream::SF_DATA_STREAM) {
+ cdata_stream *data_stream;
+ data_stream = (cdata_stream*)ctx->module;
+
+ if ( (get_property_level & 0xFFFF) == 1 ) {
+ get_property_size = sizeof(base_property_struct);
+ state = data_stream->get_property(get_property_level, (void*)&return_base_property);
+ if ( state != 0 ) {
+ ERR("data_stream get_property fail");
+ goto out;
+ }
+ return_property_struct = (void*)&return_base_property;
+ }
+ }
+
+out:
+
+ packet->set_cmd(CMD_GET_PROPERTY);
+ packet->set_payload_size(sizeof(cmd_return_property_t) + get_property_size + 4);
+ return_payload = (cmd_return_property_t*)packet->data();
+
+ if ( !return_payload ) {
+ ERR("Error return_payload ptr check (%s) , retry to send using dummy packet\n", __FUNCTION__);
+ cpacket dummy_packet(sizeof(cmd_return_property_t)+4);
+ cmd_return_property_t *dummy_payload;
+ dummy_packet.set_cmd(CMD_GET_PROPERTY);
+ dummy_packet.set_payload_size(sizeof(cmd_return_property_t));
+ dummy_payload = (cmd_return_property_t*)dummy_packet.data();
+ if ( !dummy_payload ) {
+ ERR("Error second dummy_payload ptr check");
+ return (void *)NULL;
+ }
+ dummy_payload->state = -1;
+
+ if (ipc.send( dummy_packet.packet(), dummy_packet.size()) == false) {
+ ERR("Failed to send a dummy value packet (%s)\n",__FUNCTION__);
+ return (void *)NULL;
+ }
+
+ return (void *)NULL;
+ }
+
+
+ return_payload->state = state;
+ return_payload->property_struct_size = get_property_size;
+ if ( return_property_struct && (get_property_size!=0) ) {
+ memcpy(return_payload->property_struct , return_property_struct , get_property_size );
+ }
+
+
+ DBG("Send get_property state %d\n", state);
+ if (ipc.send(queue_item->packet->packet(), queue_item->packet->size()) == false) {
+ ERR("Failed to send a value packet (%s)\n",__FUNCTION__);
+ return (void *)NULL;
+ }
+
+ return (void *)NULL;
+}
+
+void *cserver::cmd_get_struct(void *cmd_item, void *data)
+{
+ cmd_queue_item_t *queue_item = (cmd_queue_item_t*)cmd_item;
+ csock::thread_arg_t *arg = queue_item->arg;
+ client_ctx_t *ctx = (client_ctx_t*)arg->client_ctx;
+ cmd_get_data_t *payload;
+ cmd_get_struct_t *return_payload;
+ csock ipc(arg->client_handle, csock::SOCK_TCP);
+ ipc.set_on_close(false);
+ cpacket *packet = queue_item->packet;
+ int state = -1;
+
+ unsigned int struct_data_id = 0;
+ size_t struct_data_size = 0;
+ void *return_struct_data = NULL;
+
+ base_data_struct base_return_data;
+
+ if (arg->worker->state() != cipc_worker::START) {
+ ERR("Client disconnected (%s)\n",__FUNCTION__);
+ return (void*)NULL;
+ }
+
+ DBG("CMD_GET_VALUE Handler invoked\n");
+
+ payload = (cmd_get_data_t*)packet->data();
+ struct_data_id = payload->data_id;
+
+ if ( !(ctx->module) ) {
+ ERR("Error ctx->module ptr check(%s)", __FUNCTION__);
+ goto out;
+ }
+
+ if (ctx->module->type() == cdata_stream::SF_DATA_STREAM) {
+ cdata_stream *data_stream;
+ data_stream = (cdata_stream*)ctx->module;
+ if ( ( (struct_data_id&0xFFFF) > 0) && ( (struct_data_id&0xFFFF) < 10) ) {
+ struct_data_size = sizeof(base_data_struct);
+ state = data_stream->get_struct_value(cdata_stream::PROCESSOR , struct_data_id, (void*)&base_return_data);
+ if ( state != 0 ) {
+ ERR("data_stream cmd_get_struct fail");
+ goto out;
+ }
+ return_struct_data = (void*)&base_return_data;
+ }
+ } else {
+ ERR("Does not support module type for cmd_get_struct , current module_type : %d\n", ctx->module->type());
+ }
+
+out:
+
+ packet->set_cmd(CMD_GET_STRUCT);
+ packet->set_payload_size(sizeof(cmd_get_struct_t) + struct_data_size +4);
+ return_payload = (cmd_get_struct_t*)packet->data();
+
+ if ( !return_payload ) {
+ ERR("Error return_payload ptr check (%s) , retry to send using dummy packet\n", __FUNCTION__);
+ cpacket dummy_packet(sizeof(cmd_get_struct_t)+4);
+ cmd_get_struct_t *dummy_payload;
+ dummy_packet.set_cmd(CMD_GET_STRUCT);
+ dummy_packet.set_payload_size(sizeof(cmd_get_struct_t));
+ dummy_payload = (cmd_get_struct_t*)dummy_packet.data();
+ if ( !dummy_payload ) {
+ ERR("Error second dummy_payload ptr check");
+ return (void *)NULL;
+ }
+
+ dummy_payload->state = -1;
+
+ if (ipc.send( dummy_packet.packet(), dummy_packet.size()) == false) {
+ ERR("Failed to send a dummy value packet (%s)\n",__FUNCTION__);
+ return (void *)NULL;
+ }
+
+ return (void *)NULL;
+ }
+
+ return_payload->state = state;
+ return_payload->data_struct_size = struct_data_size;
+
+ if (return_struct_data && (struct_data_size!=0 ) ) {
+ memcpy(return_payload->data_struct , return_struct_data , struct_data_size);
+ }
+
+ DBG("Send get_property state %d\n", state);
+ if (ipc.send(queue_item->packet->packet(), queue_item->packet->size()) == false) {
+ ERR("Failed to send a value packet (%s)\n",__FUNCTION__);
+ return (void *)NULL;
+ }
+
+ return (void *)NULL;
+}
+
+
+
+void *cserver::cb_ipc_start(void *data)
+{
+ csock::thread_arg_t *arg = (csock::thread_arg_t*)data;
+ client_ctx_t *ctx;
+
+ try {
+ ctx = new client_ctx_t;
+ } catch (...) {
+ ERR("Failed to get memory for ctx (%s)\n",__FUNCTION__);
+ arg->client_ctx = NULL;
+ return (void*)cipc_worker::TERMINATE;
+ }
+
+ DBG("IPC Worker started %d\n", pthread_self());
+
+ ctx->client_state = -1;
+ ctx->module = NULL;
+ ctx->reg_state = 0x00;
+ arg->client_ctx = (void*)ctx;
+ return (void*)NULL;
+}
+
+
+
+void *cserver::cb_ipc_stop(void *data)
+{
+ client_ctx_t *ctx;
+ cprocessor_module *processor;
+ cfilter_module *filter;
+ csensor_module *sensor;
+ cdata_stream *stream;
+
+ cmd_reg_t forced_reg_cmd;
+ int i,j;
+ unsigned int reg_state_check_mask;
+ unsigned int masked_check_state;
+ unsigned int reg_sensor_type;
+
+ DBG("IPC Worker stopped %d\n", pthread_self());
+ csock::thread_arg_t *arg = (csock::thread_arg_t*)data;
+
+ ctx = (client_ctx_t*)arg->client_ctx;
+
+ if ( !ctx ) {
+ ERR("Error ctx ptr check (%s)\n",__FUNCTION__);
+ arg->client_ctx = NULL;
+ return (void*)cipc_worker::TERMINATE;
+ }
+
+ if ( !(ctx->module) ) {
+ ERR("Error ctx->module ptr check (%s)\n",__FUNCTION__);
+
+ arg->client_ctx = NULL;
+ delete ctx;
+
+ return (void*)cipc_worker::TERMINATE;
+ }
+
+ DBG("Check registeration state : %x", ctx->reg_state);
+ if ((ctx->reg_state & 0xFFFF) != 0x00 ) {
+ ERR("Connection broken before the call_back_func unregisted, reg_state : %x",ctx->reg_state);
+ reg_sensor_type = (ctx->reg_state) & (~0xFFFF) ;
+ forced_reg_cmd.type = REG_DEL;
+ switch (ctx->module->type()) {
+ case cdata_stream::SF_DATA_STREAM:
+ stream = (cdata_stream*)ctx->module;
+ for (i=0; i<16; i=i+4) {
+ reg_state_check_mask = (0xF << i);
+ if ( (reg_state_check_mask & ctx->reg_state) == 0x00 ) continue;
+ masked_check_state = (reg_state_check_mask & ctx->reg_state);
+ for (j=0; j<4; j++) {
+ if ( ( (masked_check_state >> (i+j)) & 0x0001 ) == 0x0001 ) {
+ forced_reg_cmd.event_type = (reg_sensor_type | ( 0x0001 << (i+j)));
+ if ( !(stream->remove_callback_func(&forced_reg_cmd)) ) {
+ ERR("Error forced unregisteration for cmd_type : %x , cmd_event : %x",forced_reg_cmd.type ,forced_reg_cmd.event_type);
+ }
+ }
+ }
+ }
+ break;
+ default:
+ ERR("forced unregisteration fail , not supported type (%s)\n",__FUNCTION__);
+ break;
+ }
+ }
+
+ if (ctx->client_state > 0) {
+ switch (ctx->module->type()) {
+ case csensor_module::SF_PLUGIN_SENSOR:
+ sensor = (csensor_module*)ctx->module;
+ ERR("Server does not received cmd_stop before connection broken!! forced stop, sensor_type : %d\n", sensor->get_sensor_type());
+ sensor->stop();
+ break;
+
+ case cprocessor_module::SF_PLUGIN_PROCESSOR:
+ processor = (cprocessor_module*)ctx->module;
+ ERR("Server does not received cmd_stop before connection broken!! forced stop, processor\n" );
+ processor->stop();
+ processor->wakeup_all_client();
+ break;
+
+ case cfilter_module::SF_PLUGIN_FILTER:
+ filter = (cfilter_module *)ctx->module;
+ ERR("Server does not received cmd_stop before connection broken!! forced stop, filter_type : %d\n", filter->get_sensor_type());
+ filter->stop();
+ break;
+
+ case cdata_stream::SF_DATA_STREAM:
+ stream = (cdata_stream*)ctx->module;
+ ERR("doesnot recevied cmd_stop before connection broken!! forced stop, stream_name : %s stop\n", stream->name());
+ stream->stop();
+ stream->wakeup_all_client();
+ break;
+
+ default:
+ ERR("Unknown type (%s)\n",__FUNCTION__);
+ break;
+ }
+ }
+
+ arg->client_ctx = NULL;
+ delete ctx;
+
+ return (void*)cipc_worker::TERMINATE;
+}
+
+
+
+void *cserver::cb_ipc_worker(void *data)
+{
+ cmd_queue_item_t *cmd_item;
+ cpacket *packet;
+ csock::thread_arg_t *arg = (csock::thread_arg_t*)data;
+ csock ipc(arg->client_handle, csock::SOCK_TCP);
+ client_ctx_t *ctx;
+ ipc.set_on_close(false);
+ cserver serverobj;
+
+ ctx = (client_ctx_t*)arg->client_ctx;
+
+ DBG("IPC Worker started %d\n", pthread_self());
+
+ try {
+ packet = new cpacket(MAX_DATA_STREAM_SIZE);
+ } catch (...) {
+ return (void*)cipc_worker::TERMINATE;
+ }
+
+ DBG("Wait for a packet\n");
+
+ if (ipc.recv(packet->packet(), packet->header_size()) == false) {
+ DBG("recv failed\n");
+ delete packet;
+ return (void*)cipc_worker::TERMINATE;
+ }
+
+ DBG("Packet received (%d, %d)\n", packet->version(), packet->cmd());
+
+ if ( !( (unsigned int)packet->payload_size() < MAX_DATA_STREAM_SIZE) ) {
+ ERR("Error received packet size check (%s)\n",__FUNCTION__);
+ delete packet;
+ return (void*)cipc_worker::TERMINATE;
+
+ }
+
+ if (ipc.recv((char*)packet->packet() + packet->header_size(), packet->payload_size()) == false)
+ {
+ delete packet;
+ return (void*)cipc_worker::TERMINATE;
+ }
+
+ try {
+ cmd_item = new cmd_queue_item_t;
+ } catch (...) {
+ delete packet;
+ return (void*)cipc_worker::TERMINATE;
+ }
+
+ cmd_item->packet = packet;
+ cmd_item->arg = arg;
+
+ serverobj.command_handler(cmd_item, NULL);
+
+ return (void *)cipc_worker::START;
+}
+
+
+
+
+
+void *cserver::cb_event_handler(cprocessor_module *processor, void *data)
+{
+ csock::thread_arg_t *arg = (csock::thread_arg_t *)data;
+ cpacket packet(sizeof(cmd_done_t)+4);
+ cmd_done_t *payload;
+ csock ipc(arg->client_handle , csock::SOCK_TCP);
+ ipc.set_on_close(false);
+
+ DBG("Wait event handler invoked\n");
+ if (arg->worker->state() != cipc_worker::START) {
+ ERR("Client disconnected\n");
+ return (void*)NULL;
+ }
+
+ packet.set_cmd(CMD_DONE);
+ packet.set_version(PROTOCOL_VERSION);
+ packet.set_payload_size(sizeof(cmd_done_t));
+ payload = (cmd_done_t*)packet.data();
+ payload->value = arg->worker->state();
+
+ if (ipc.send(packet.packet(), packet.size()) == false) {
+ ERR("Failed to send a packet (%s)\n",__FUNCTION__);
+ return (void*)NULL;
+ }
+
+ return (void*)NULL;
+}
+
+
+
+void cserver::cb_rm_cb_data(void *cb)
+{
+ DbgPrint("nop\n");
+ return;
+}
+
+
+void cserver::command_handler(void *cmd_item, void *data)
+{
+ cmd_queue_item_t *queue_item = (cmd_queue_item_t*)cmd_item;
+ cpacket *packet;
+ int cmd= CMD_NONE;
+ void *ret;
+
+ packet = queue_item->packet;
+ cmd = packet->cmd();
+
+
+ if ( !(cmd > 0 && cmd < CMD_LAST) )
+ {
+ ERR("cmd < 0 or cmd > CMD_LAST");
+ }
+ else
+ {
+ ret = m_cmd_handler[cmd] ? m_cmd_handler[cmd](cmd_item, NULL) : NULL;
+ }
+
+ delete queue_item->packet;
+ delete queue_item;
+
+}
+
+
+void cserver::sf_main_loop(void)
+{
+ static GMainLoop *mainloop;
+ csock *ipc = NULL;
+
+ mainloop = g_main_loop_new(NULL, FALSE);
+
+ try {
+ ipc = new csock((char*)STR_SF_IPC_SOCKET, csock::SOCK_TCP|csock::SOCK_WORKER, 0, 1);
+ } catch (int ErrNo) {
+ ERR("ipc class create fail , errno : %d , errstr : %s\n",ErrNo, strerror(ErrNo));
+ return ;
+ }
+
+ ipc->set_worker(cb_ipc_start, cb_ipc_worker, cb_ipc_stop);
+ ipc->wait_for_client();
+
+ g_main_loop_run(mainloop);
+ g_main_loop_unref(mainloop);
+
+ return;
+}
+
+
+
+//! End of a file
--- /dev/null
+/*
+ * sensor-framework
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: JuHyun Kim <jh8212.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+
+#include <ctrim.h>
+
+#include <common.h>
+
+ctrim::ctrim(void)
+{
+}
+
+
+
+ctrim::~ctrim(void)
+{
+}
+
+
+char *ctrim::ltrim(char *str)
+{
+ unsigned int index = 0;
+
+ while ((str[index] == ' ')||(str[index] == '\t')) index ++;
+ return &str[index];
+}
+
+
+
+int ctrim::rtrim(char *str)
+{
+ int len;
+ int org_len;
+
+ org_len = len = strlen(str) - 1;
+
+ while ((str[len] == ' ')||(str[len] == '\t')) len --;
+ str[len + 1] = (char)NULL;
+
+ return org_len - len;
+}
+
+
+
+//! End of a file
--- /dev/null
+/*
+ * sensor-framework
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: JuHyun Kim <jh8212.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+
+#include <getopt.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <dlfcn.h>
+#include <pthread.h>
+#include <string.h>
+#include <signal.h>
+
+#include <string.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/stat.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <unistd.h>
+#include <sys/un.h>
+#include <fcntl.h>
+
+
+#include <common.h>
+
+#include <cobject_type.h>
+
+#include <cmutex.h>
+#include <clist.h>
+#include <cmodule.h>
+#include <csync.h>
+
+#include <cworker.h>
+#include <cipc_worker.h>
+#include <csock.h>
+#include <cpacket.h>
+#include <sf_common.h>
+
+#include <ccatalog.h>
+#include <csensor_catalog.h>
+#include <cfilter_catalog.h>
+#include <cprocessor_catalog.h>
+
+#include <csensor_module.h>
+#include <cfilter_module.h>
+#include <cprocessor_module.h>
+#include <cdata_stream.h>
+
+#include <cserver.h>
+#include <cutil.h>
+
+#include <resource_str.h>
+
+#include <vconf.h>
+
+#if !defined(PATH_MAX)
+#define PATH_MAX 256
+#endif
+
+extern char *optarg;
+extern int optind, opterr, optopt;
+
+static cserver server;
+
+inline static int daemonize(void)
+{
+ pid_t pid;
+
+ pid = fork();
+ if (pid < 0)
+ return -1;
+ else if (pid != 0)
+ exit(0);
+
+ setsid();
+ chdir("/");
+
+ close(0);
+ close(1);
+ close(2);
+
+ open("/dev/null", O_RDONLY);
+ open("/dev/null", O_RDWR);
+ dup(1);
+
+ return 0;
+}
+
+
+int main(int argc, char *argv[])
+{
+ csensor_catalog *sensor_catalog = NULL;
+ cfilter_catalog *filter_catalog = NULL;
+ cprocessor_catalog *processor_catalog = NULL;
+ cdata_stream dstream;
+ char dstream_file[PATH_MAX] = { 0, };
+ int opt;
+
+ if ( argc > 1) {
+ while ((opt = getopt(argc, argv, "bs:f:p:d:h")) != -1) {
+ DBG("input opt : %c , opterr : %d , optind : %d , optopt : %d\n",(char)opt , opterr , optind , optopt);
+ if (opt == 'b' ) {
+ {
+ daemonize();
+ }
+ } else if (opt == 's' ) {
+ if (sensor_catalog) {
+ INFO("Sensors are already loaded\n");
+ continue;
+ }
+
+ try {
+ sensor_catalog = new csensor_catalog;
+ } catch (...) {
+ ERR("csensor_catalog class create fail\n");
+ if (filter_catalog) delete filter_catalog;
+ if (processor_catalog) delete processor_catalog;
+ return -1;
+ }
+
+ DBG("Sensor : %s\n", optarg);
+ if (sensor_catalog->create(optarg) == false) {
+ ERR("sensor_catalog create fail\n");
+ delete sensor_catalog;
+ if (filter_catalog) delete filter_catalog;
+ if (processor_catalog) delete processor_catalog;
+ return -1;
+ }
+ } else if (opt == 'f' ) {
+ if (filter_catalog) {
+ INFO("Filters are already loaded\n");
+ continue;
+ }
+
+ try {
+ filter_catalog = new cfilter_catalog;
+ } catch (...) {
+ ERR("cfilter_catalog class create fail\n");
+ if (sensor_catalog) delete sensor_catalog;
+ if (processor_catalog) delete processor_catalog;
+ return -1;
+ }
+
+ DBG("Filter : %s\n", optarg);
+ if (filter_catalog->create(optarg) == false) {
+ ERR("filter_catalog create fail\n");
+ delete filter_catalog;
+ if (sensor_catalog) delete sensor_catalog;
+ if (processor_catalog) delete processor_catalog;
+ return -1;
+ }
+ } else if (opt == 'p' ) {
+ if (processor_catalog) {
+ INFO("Processors are already loaded\n");
+ continue;
+ }
+
+ try {
+ processor_catalog = new cprocessor_catalog;
+ } catch (...) {
+ ERR("cprocessor_catalog class create fail\n");
+ if (sensor_catalog) delete sensor_catalog;
+ if (filter_catalog) delete filter_catalog;
+ return -1;
+ }
+
+ DBG("Processor : %s\n", optarg);
+ if (processor_catalog->create(optarg) == false) {
+ ERR("processor_catalog create fail\n");
+ delete processor_catalog;
+ if (sensor_catalog) delete sensor_catalog;
+ if (filter_catalog) delete filter_catalog;
+ return -1;
+ }
+
+ } else if (opt == 'd' ) {
+ if (strlen(dstream_file)) {
+ INFO("Data stream is already loaded\n");
+ continue;
+ }
+ DBG("Data stream file %s\n", optarg);
+ if( strlen(optarg) < PATH_MAX )
+ {
+ strncpy(dstream_file, optarg,strlen(optarg));
+ dstream_file[strlen(optarg)] = '\0';
+ }
+ else {
+ ERR("Data stream file name string too long\n");
+ if (sensor_catalog) delete sensor_catalog;
+ if (filter_catalog) delete filter_catalog;
+ if (processor_catalog) delete processor_catalog;
+ return -1;
+ }
+
+
+ } else if (opt == 'h' ) {
+ printf("Daemon process of the sensor framework v0.1\n");
+ printf(" -h) This screen\n");
+ printf(" -s) Set the sensor catalog file\n");
+ printf(" -f) Set the filter catalog file\n");
+ printf(" -p) Set the processor catalog file\n");
+ printf(" -d) Set the datastream catalog file\n");
+ printf(" -b) Make a daemon\n");
+ if (sensor_catalog) delete sensor_catalog;
+ if (filter_catalog) delete filter_catalog;
+ if (processor_catalog) delete processor_catalog;
+ return 0;
+ }
+ }
+ }else {
+ DBG("No option just run by default\n");
+
+ daemonize();
+
+ try {
+ sensor_catalog = new csensor_catalog;
+ } catch (...) {
+ DbgPrint("csensor_catalog class create fail\n");
+ if (filter_catalog) delete filter_catalog;
+ if (processor_catalog) delete processor_catalog;
+ return -1;
+ }
+
+ strncpy(dstream_file, "/usr/etc/sf_sensor.conf",strlen("/usr/etc/sf_sensor.conf"));
+ dstream_file[strlen("/usr/etc/sf_sensor.conf")] = '\0';
+
+ if (sensor_catalog->create(dstream_file) == false) {
+ ERR("sensor_catalog create fail\n");
+ delete sensor_catalog;
+ if (filter_catalog) delete filter_catalog;
+ if (processor_catalog) delete processor_catalog;
+ return -1;
+ }
+
+ try {
+ filter_catalog = new cfilter_catalog;
+ } catch (...) {
+ ERR("cfilter_catalog class create fail\n");
+ if (sensor_catalog) delete sensor_catalog;
+ if (processor_catalog) delete processor_catalog;
+ return -1;
+ }
+
+ strncpy(dstream_file, "/usr/etc/sf_filter.conf",strlen("/usr/etc/sf_filter.conf"));
+ dstream_file[strlen("/usr/etc/sf_filter.conf")] = '\0';
+
+ if (filter_catalog->create(dstream_file) == false) {
+ ERR("filter_catalog create fail\n");
+ delete filter_catalog;
+ if (sensor_catalog) delete sensor_catalog;
+ if (processor_catalog) delete processor_catalog;
+ return -1;
+ }
+
+ try {
+ processor_catalog = new cprocessor_catalog;
+ } catch (...) {
+ ERR("cprocessor_catalog class create fail\n");
+ if (sensor_catalog) delete sensor_catalog;
+ if (filter_catalog) delete filter_catalog;
+ return -1;
+ }
+
+ strncpy(dstream_file, "/usr/etc/sf_processor.conf",strlen("/usr/etc/sf_processor.conf"));
+ dstream_file[strlen("/usr/etc/sf_processor.conf")] = '\0';
+
+ if (processor_catalog->create(dstream_file) == false) {
+ ERR("processor_catalog create fail\n");
+ delete processor_catalog;
+ if (sensor_catalog) delete sensor_catalog;
+ if (filter_catalog) delete filter_catalog;
+ return -1;
+ }
+
+ strncpy(dstream_file, "/usr/etc/sf_data_stream.conf",strlen("/usr/etc/sf_data_stream.conf"));
+ dstream_file[strlen("/usr/etc/sf_data_stream.conf")] = '\0';
+ }
+
+ if (dstream.create(dstream_file) == false) {
+ if (processor_catalog) {
+ processor_catalog->destroy();
+ delete processor_catalog;
+ }
+
+ if (filter_catalog) {
+ filter_catalog->destroy();
+ delete filter_catalog;
+ }
+
+ if (sensor_catalog) {
+ sensor_catalog->destroy();
+ delete sensor_catalog;
+ }
+
+ ERR("Failed to build a data stream, missing configurations?\n");
+ return -1;
+ }
+
+ vconf_set_int ("memory/hibernation/sfsvc_ready", 1);
+
+ server.sf_main_loop();
+
+ if (processor_catalog) {
+ processor_catalog->destroy();
+ delete processor_catalog;
+ }
+
+ if (filter_catalog) {
+ filter_catalog->destroy();
+ delete filter_catalog;
+ }
+
+ if (sensor_catalog) {
+ sensor_catalog->destroy();
+ delete sensor_catalog;
+ }
+
+ INFO("sf_server terminated\n");
+ return 0;
+}
+
+
+
+//! End of a file
--- /dev/null
+/*
+ * sensor-framework
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: JuHyun Kim <jh8212.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+
+
+#include <resource_str.h>
+
+const char *STR_CMD_QUEUE = "cmd_queue";
+
+const char *STR_SF_IPC_SOCKET = "/tmp/sf_socket";
+
+const char *STR_PATH = "path";
+const char *STR_ID = "id";
+const char *STR_VERSION = "vesrion";
+const char *STR_NAME = "name";
+const char *STR_OVERRIDE = "override";
+const char *STR_YES = "yes";
+const char *STR_DISABLE = "disable";
+const char *STR_POLL = "poll";
+
+const char *STR_MULTI_STREAM ="multi_stream";
+const char *STR_FILTER_INPUT = "filter_input";
+const char *STR_PROCESSOR_INPUT = "processor_input";
+const char *STR_TOKEN_DELIMETER = ",\n";
+
+//! End of a file
--- /dev/null
+[accel_datastream]
+multi_stream=disable
+filter_input=bma023_filter, bma023_filter, bma023_sensor
+processor_input=bma023_processor, bma023_processor, bma023_filter
+processor_input=kr3dm_processor, kr3dm_processor, kr3dm_sensor
+version=1
+id=2211
+override=yes
+disable=no
+
+[geomag_datastream]
+multi_stream=disable
+filter_input=ak8973b_filter, ak8973b_filter, ak8973b_sensor
+filter_input=ak8975_filter, ak8975_filter, ak8975_sensor
+filter_input=yas529_filter, yas529_filter, yas529_sensor
+processor_input=ak8973b_processor, ak8973b_processor, ak8973b_filter
+processor_input=ak8975_processor, ak8975_processor, ak8975_filter, kr3dm_sensor
+processor_input=yas529_processor, yas529_processor, yas529_filter, bma023_sensor
+version=1
+id=2212
+override=yes
+disable=no
+
+[lumin_datastream]
+multi_stream=disable
+filter_input=gp2ap002ambi_filter, gp2ap002ambi_filter, gp2ap002ambi_sensor
+filter_input=cm3623ambi_filter, cm3623ambi_filter, cm3623ambi_sensor
+filter_input=tmd2711ambi_filter, tmd2711ambi_filter, tmd2711ambi_sensor
+processor_input=gp2ap002ambi_processor, gp2ap002ambi_processor, gp2ap002ambi_filter
+processor_input=gp2ap020ambi_processor, gp2ap020ambi_processor, gp2ap020ambi_sensor
+processor_input=cm3623ambi_processor, cm3623ambi_processor, cm3623ambi_filter
+processor_input=tmd2711ambi_processor, tmd2711ambi_processor, tmd2711ambi_filter
+version=1
+id=2213
+override=yes
+disable=no
+
+[proxi_datastream]
+multi_stream=disable
+filter_input=gp2ap002proxi_filter, gp2ap002proxi_filter, gp2ap002proxi_sensor
+filter_input=cm3623proxi_filter, cm3623proxi_filter, cm3623proxi_sensor
+filter_input=tmd2711proxi_filter, tmd2711proxi_filter, tmd2711proxi_sensor
+processor_input=gp2ap002proxi_processor, gp2ap002proxi_processor, gp2ap002proxi_filter
+processor_input=gp2ap020proxi_processor, gp2ap020proxi_processor, gp2ap020proxi_sensor
+processor_input=cm3623proxi_processor, cm3623proxi_processor, cm3623proxi_filter
+processor_input=tmd2711proxi_processor, tmd2711proxi_processor, tmd2711proxi_filter
+version=1
+id=2214
+override=yes
+disable=no
+
+[motion_datastream]
+multi_stream=disable
+filter_input=motion_filter, motion_filter, bma023_sensor, kr3dm_sensor, l3g4200d_sensor
+processor_input=motion_processor, motion_processor, motion_filter
+version=1
+id=2209
+override=yes
+disable=no
+
+[gyro_datastream]
+multi_stream=disable
+filter_input=mpu3050_filter, mpu3050_filter
+processor_input=mpu3050_processor, mpu3050_processor, mpu3050_filter, bma023_sensor
+processor_input=l3g4200d_processor, l3g4200d_processor, l3g4200d_sensor
+version=1
+id=2210
+override=yes
+disable=no
--- /dev/null
+[accel_datastream]
+multi_stream=disable
+filter_input=accel_sim_filter, accel_sim_filter, accel_sim_sensor
+processor_input=accel_sim_processor, accel_sim_processor, accel_sim_filter
+version=1
+id=2211
+override=yes
+disable=no
+
+[geomag_datastream]
+multi_stream=disable
+filter_input=geo_sim_filter, geo_sim_filter, geo_sim_sensor
+processor_input=geo_sim_processor, geo_sim_processor, geo_sim_filter
+version=1
+id=2212
+override=yes
+disable=no
+
+[lumin_datastream]
+multi_stream=disable
+filter_input=light_sim_filter, light_sim_filter, light_sim_sensor
+processor_input=light_sim_processor, light_sim_processor, light_sim_filter
+version=1
+id=2213
+override=yes
+disable=no
+
+[proxi_datastream]
+multi_stream=disable
+filter_input=proxi_sim_filter, proxi_sim_filter, proxi_sim_sensor
+processor_input=proxi_sim_processor, proxi_sim_processor, proxi_sim_filter
+version=1
+id=2214
+override=yes
+disable=no
+
+[motion_datastream]
+multi_stream=disable
+filter_input=motion_filter, motion_filter, accel_sim_sensor, gyro_sim_sensor
+processor_input=motion_sim_processor, motion_sim_processor, motion_filter
+version=1
+id=2209
+override=yes
+disable=no
+
+[gyro_datastream]
+multi_stream=disable
+processor_input=gyro_sim_processor, gyro_sim_processor, gyro_sim_sensor
+version=1
+id=2210
+override=yes
+disable=no
--- /dev/null
+[bma023_filter]
+path=/usr/lib/sensor_framework/libbma023_filter.so
+id=1223
+version=1
+disable=no
+override=yes
+
+[ak8973b_filter]
+path=/usr/lib/sensor_framework/libak8973b_filter.so
+id=1224
+version=1
+disable=no
+override=yes
+
+[yas529_filter]
+path=/usr/lib/sensor_framework/libyas529_filter.so
+id=1225
+version=1
+disable=no
+override=yes
+
+[gp2ap002ambi_filter]
+path=/usr/lib/sensor_framework/libgp2ap002ambi_filter.so
+id=1226
+version=1
+disable=no
+override=yes
+
+[gp2ap002proxi_filter]
+path=/usr/lib/sensor_framework/libgp2ap002proxi_filter.so
+id=1227
+version=1
+disable=no
+override=yes
+
+[cm3623ambi_filter]
+path=/usr/lib/sensor_framework/libcm3623ambi_filter.so
+id=1228
+version=1
+disable=no
+override=yes
+
+[cm3623proxi_filter]
+path=/usr/lib/sensor_framework/libcm3623proxi_filter.so
+id=1229
+version=1
+disable=no
+override=yes
+
+[motion_filter]
+path=/usr/lib/sensor_framework/libmotion_filter.so
+id=1221
+version=1
+disable=no
+override=yes
+
+[tmd2711ambi_filter]
+path=/usr/lib/sensor_framework/libtmd2711ambi_filter.so
+id=1220
+version=1
+disable=no
+override=yes
+
+[tmd2711proxi_filter]
+path=/usr/lib/sensor_framework/libtmd2711proxi_filter.so
+id=1219
+version=1
+disable=no
+override=yes
+
+[ak8975_filter]
+path=/usr/lib/sensor_framework/libak8975_filter.so
+id=1218
+version=1
+disable=no
+override=yes
--- /dev/null
+[accel_sim_filter]
+path=/usr/lib/sensor_framework/libaccel_sim_filter.so
+id=1223
+version=1
+disable=no
+override=yes
+
+[light_sim_filter]
+path=/usr/lib/sensor_framework/liblight_sim_filter.so
+id=1226
+version=1
+disable=no
+override=yes
+
+[proxi_sim_filter]
+path=/usr/lib/sensor_framework/libproxi_sim_filter.so
+id=1227
+version=1
+disable=no
+override=yes
+
+[motion_filter]
+path=/usr/lib/sensor_framework/libmotion_filter.so
+id=1221
+version=1
+disable=no
+override=yes
+
+[geo_sim_filter]
+path=/usr/lib/sensor_framework/libgeo_sim_filter.so
+id=1218
+version=1
+disable=no
+override=yes
--- /dev/null
+[bma023_processor]
+path=/usr/lib/sensor_framework/libbma023_processor.so
+id=2114
+version=1
+override=yes
+disable=no
+
+[ak8973b_processor]
+path=/usr/lib/sensor_framework/libak8973b_processor.so
+id=2115
+version=1
+override=yes
+disable=no
+
+[yas529_processor]
+path=/usr/lib/sensor_framework/libyas529_processor.so
+id=2116
+version=1
+override=yes
+disable=no
+
+[gp2ap002ambi_processor]
+path=/usr/lib/sensor_framework/libgp2ap002ambi_processor.so
+id=2117
+version=1
+override=yes
+disable=no
+
+[gp2ap002proxi_processor]
+path=/usr/lib/sensor_framework/libgp2ap002proxi_processor.so
+id=2118
+version=1
+override=yes
+disable=no
+
+[gp2ap020ambi_processor]
+path=/usr/lib/sensor_framework/libgp2ap020ambi_processor.so
+id=2117
+version=1
+override=yes
+disable=no
+
+[gp2ap020proxi_processor]
+path=/usr/lib/sensor_framework/libgp2ap020proxi_processor.so
+id=2118
+version=1
+override=yes
+disable=no
+
+[cm3623ambi_processor]
+path=/usr/lib/sensor_framework/libcm3623ambi_processor.so
+id=2119
+version=1
+override=yes
+disable=no
+
+[cm3623proxi_processor]
+path=/usr/lib/sensor_framework/libcm3623proxi_processor.so
+id=2113
+version=1
+override=yes
+disable=no
+
+[motion_processor]
+path=/usr/lib/sensor_framework/libmotion_processor.so
+id=2111
+version=1
+override=yes
+disable=no
+
+[kr3dm_processor]
+path=/usr/lib/sensor_framework/libkr3dm_processor.so
+id=2120
+version=1
+override=yes
+disable=no
+
+[l3g4200d_processor]
+path=/usr/lib/sensor_framework/libl3g4200d_processor.so
+id=2121
+version=1
+override=yes
+disable=no
+
+[tmd2711ambi_processor]
+path=/usr/lib/sensor_framework/libtmd2711ambi_processor.so
+id=2122
+version=1
+override=yes
+disable=no
+
+[tmd2711proxi_processor]
+path=/usr/lib/sensor_framework/libtmd2711proxi_processor.so
+id=2123
+version=1
+override=yes
+disable=no
+
+[ak8975_processor]
+path=/usr/lib/sensor_framework/libak8975_processor.so
+id=2124
+version=1
+override=yes
+disable=no
--- /dev/null
+[accel_sim_processor]
+path=/usr/lib/sensor_framework/libaccel_sim_processor.so
+id=2114
+version=1
+override=yes
+disable=no
+
+[light_sim_processor]
+path=/usr/lib/sensor_framework/liblight_sim_processor.so
+id=2117
+version=1
+override=yes
+disable=no
+
+[proxi_sim_processor]
+path=/usr/lib/sensor_framework/libproxi_sim_processor.so
+id=2118
+version=1
+override=yes
+disable=no
+
+[motion_sim_processor]
+path=/usr/lib/sensor_framework/libmotion_sim_processor.so
+id=2111
+version=1
+override=yes
+disable=no
+
+[gyro_sim_processor]
+path=/usr/lib/sensor_framework/libgyro_sim_processor.so
+id=2121
+version=1
+override=yes
+disable=no
+
+[geo_sim_processor]
+path=/usr/lib/sensor_framework/libgeo_sim_processor.so
+id=2124
+version=1
+override=yes
+disable=no
--- /dev/null
+[bma023_sensor]
+disable=no
+override=yes
+path=/usr/lib/sensor_framework/libbma023.so
+id=1114
+version=1
+poll=10
+
+[ak8973b_sensor]
+disable=no
+override=yes
+path=/usr/lib/sensor_framework/libak8973b.so
+id=1115
+version=1
+poll=100
+
+[yas529_sensor]
+disable=no
+override=yes
+path=/usr/lib/sensor_framework/libyas529.so
+id=1116
+version=1
+poll=90
+
+[gp2ap002ambi_sensor]
+disable=no
+override=yes
+path=/usr/lib/sensor_framework/libgp2ap002ambi.so
+id=1117
+version=1
+poll=490
+
+[gp2ap002proxi_sensor]
+disable=no
+override=yes
+path=/usr/lib/sensor_framework/libgp2ap002proxi.so
+id=1118
+version=1
+poll=90
+
+[gp2ap020ambi_sensor]
+disable=no
+override=yes
+path=/usr/lib/sensor_framework/libgp2ap020ambi.so
+id=1117
+version=1
+poll=490
+
+[gp2ap020proxi_sensor]
+disable=no
+override=yes
+path=/usr/lib/sensor_framework/libgp2ap020proxi.so
+id=1118
+version=1
+poll=90
+
+[cm3623ambi_sensor]
+disable=no
+override=yes
+path=/usr/lib/sensor_framework/libcm3623ambi.so
+id=1119
+version=1
+poll=490
+
+[cm3623proxi_sensor]
+disable=no
+override=yes
+path=/usr/lib/sensor_framework/libcm3623proxi.so
+id=1113
+version=1
+poll=90
+
+[kr3dm_sensor]
+disable=no
+override=yes
+path=/usr/lib/sensor_framework/libkr3dm.so
+id=1112
+version=1
+poll=10
+
+[l3g4200d_sensor]
+disable=no
+override=yes
+path=/usr/lib/sensor_framework/libl3g4200d.so
+id=1111
+version=1
+poll=18
+
+[tmd2711ambi_sensor]
+disable=no
+override=yes
+path=/usr/lib/sensor_framework/libtmd2711ambi.so
+id=1110
+version=1
+poll=490
+
+[tmd2711proxi_sensor]
+disable=no
+override=yes
+path=/usr/lib/sensor_framework/libtmd2711proxi.so
+id=1109
+version=1
+poll=90
+
+[ak8975_sensor]
+disable=no
+override=yes
+path=/usr/lib/sensor_framework/libak8975.so
+id=1108
+version=1
+poll=100
--- /dev/null
+[accel_sim_sensor]
+disable=no
+override=yes
+path=/usr/lib/sensor_framework/libaccel_sim.so
+id=1114
+version=1
+poll=10
+
+[light_sim_sensor]
+disable=no
+override=yes
+path=/usr/lib/sensor_framework/liblight_sim.so
+id=1117
+version=1
+poll=490
+
+[proxi_sim_sensor]
+disable=no
+override=yes
+path=/usr/lib/sensor_framework/libproxi_sim.so
+id=1118
+version=1
+poll=90
+
+[gyro_sim_sensor]
+disable=no
+override=yes
+path=/usr/lib/sensor_framework/libgyro_sim.so
+id=1111
+version=1
+poll=100
+
+[geo_sim_sensor]
+disable=no
+override=yes
+path=/usr/lib/sensor_framework/libgeo_sim.so
+id=1108
+version=1
+poll=100
--- /dev/null
+#!/bin/sh
+
+echo "[rc3.d] sf-svc RC3 script"
+
+if [ -x /usr/bin/sf_server ]; then
+ /usr/bin/sf_server -s /usr/etc/sf_sensor.conf -f /usr/etc/sf_filter.conf -p /usr/etc/sf_processor.conf -d /usr/etc/sf_data_stream.conf &
+fi
+
+if [ -f /opt/etc/.hib_capturing ]; then
+#add waitting for widget-screen, request from booting-TF (for Normal Boot) )
+ echo "Fast boot"
+ else
+ echo "waitting for widget-screen about 17s"
+fi
+