Tizen 2.0 Release tizen_2.0 accepted/tizen_2.0/20130215.201548 submit/tizen_2.0/20130215.192404
authorHyungKyu Song <hk76.song@samsung.com>
Fri, 15 Feb 2013 16:00:48 +0000 (01:00 +0900)
committerHyungKyu Song <hk76.song@samsung.com>
Fri, 15 Feb 2013 16:00:48 +0000 (01:00 +0900)
31 files changed:
CMakeLists.txt [new file with mode: 0644]
COPYING [new file with mode: 0644]
README [new file with mode: 0644]
inc/accelprocessor.h [new file with mode: 0644]
inc/baseprocessor.h [new file with mode: 0644]
inc/compassprocessor.h [new file with mode: 0644]
inc/gyroprocessor.h [new file with mode: 0644]
inc/lightprocessor.h [new file with mode: 0644]
inc/log.h [new file with mode: 0644]
inc/ms5607processors.h [new file with mode: 0644]
inc/proxiprocessor.h [new file with mode: 0644]
packaging/sensor-plugins-mfld-blackbay.changes [new file with mode: 0644]
packaging/sensor-plugins-mfld-blackbay.spec [new file with mode: 0644]
src/CMakeLists.txt [new file with mode: 0644]
src/accel_module.cpp [new file with mode: 0644]
src/accelprocessor.cpp [new file with mode: 0644]
src/baseprocessor.cpp [new file with mode: 0644]
src/compass_module.cpp [new file with mode: 0644]
src/compassprocessor.cpp [new file with mode: 0644]
src/gyro_module.cpp [new file with mode: 0644]
src/gyroprocessor.cpp [new file with mode: 0644]
src/lightprocessor.cpp [new file with mode: 0644]
src/lights_module.cpp [new file with mode: 0644]
src/ms5607processors.cpp [new file with mode: 0644]
src/pressure_module.cpp [new file with mode: 0644]
src/proxi_module.cpp [new file with mode: 0644]
src/proxiprocessor.cpp [new file with mode: 0644]
src/test_programs/CMakeLists.txt [new file with mode: 0644]
src/test_programs/client.cpp [new file with mode: 0644]
src/test_programs/reader.cpp [new file with mode: 0644]
src/test_programs/readme.txt [new file with mode: 0644]

diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644 (file)
index 0000000..eede785
--- /dev/null
@@ -0,0 +1,20 @@
+cmake_minimum_required(VERSION 2.6)
+project(sensor-plugins-mfld-blackbay CXX)
+
+# to install pkgconfig setup file.
+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 "0")
+set(PROJECT_RELEASE_VERSION "1")
+
+include(FindPkgConfig)
+pkg_check_modules(rpkgs REQUIRED sf_common sensor libudev vconf)
+add_definitions(${rpkgs_CFLAGS})
+
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/inc)
+ADD_SUBDIRECTORY(src)
+
diff --git a/COPYING b/COPYING
new file mode 100644 (file)
index 0000000..8add30a
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,504 @@
+                 GNU LESSER GENERAL PUBLIC LICENSE
+                      Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+     51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL.  It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+                           Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+  This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it.  You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+  When we speak of free software, we are referring to freedom of use,
+not price.  Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+  To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights.  These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+  For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you.  You must make sure that they, too, receive or can get the source
+code.  If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it.  And you must show them these terms so they know their rights.
+
+  We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+  To protect each distributor, we want to make it very clear that
+there is no warranty for the free library.  Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+\f
+  Finally, software patents pose a constant threat to the existence of
+any free program.  We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder.  Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+  Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License.  This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License.  We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+  When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library.  The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom.  The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+  We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License.  It also provides other free software developers Less
+of an advantage over competing non-free programs.  These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries.  However, the Lesser license provides advantages in certain
+special circumstances.
+
+  For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard.  To achieve this, non-free programs must be
+allowed to use the library.  A more frequent case is that a free
+library does the same job as widely used non-free libraries.  In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+  In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software.  For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+  Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.  Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library".  The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+\f
+                 GNU LESSER GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+  A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+  The "Library", below, refers to any such software library or work
+which has been distributed under these terms.  A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language.  (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+  "Source code" for a work means the preferred form of the work for
+making modifications to it.  For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+  Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it).  Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+  
+  1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+  You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+\f
+  2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) The modified work must itself be a software library.
+
+    b) You must cause the files modified to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    c) You must cause the whole of the work to be licensed at no
+    charge to all third parties under the terms of this License.
+
+    d) If a facility in the modified Library refers to a function or a
+    table of data to be supplied by an application program that uses
+    the facility, other than as an argument passed when the facility
+    is invoked, then you must make a good faith effort to ensure that,
+    in the event an application does not supply such function or
+    table, the facility still operates, and performs whatever part of
+    its purpose remains meaningful.
+
+    (For example, a function in a library to compute square roots has
+    a purpose that is entirely well-defined independent of the
+    application.  Therefore, Subsection 2d requires that any
+    application-supplied function or table used by this function must
+    be optional: if the application does not supply it, the square
+    root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library.  To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License.  (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.)  Do not make any other change in
+these notices.
+\f
+  Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+  This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+  4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+  If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library".  Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+  However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library".  The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+  When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library.  The
+threshold for this to be true is not precisely defined by law.
+
+  If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work.  (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+  Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+\f
+  6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+  You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License.  You must supply a copy of this License.  If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License.  Also, you must do one
+of these things:
+
+    a) Accompany the work with the complete corresponding
+    machine-readable source code for the Library including whatever
+    changes were used in the work (which must be distributed under
+    Sections 1 and 2 above); and, if the work is an executable linked
+    with the Library, with the complete machine-readable "work that
+    uses the Library", as object code and/or source code, so that the
+    user can modify the Library and then relink to produce a modified
+    executable containing the modified Library.  (It is understood
+    that the user who changes the contents of definitions files in the
+    Library will not necessarily be able to recompile the application
+    to use the modified definitions.)
+
+    b) Use a suitable shared library mechanism for linking with the
+    Library.  A suitable mechanism is one that (1) uses at run time a
+    copy of the library already present on the user's computer system,
+    rather than copying library functions into the executable, and (2)
+    will operate properly with a modified version of the library, if
+    the user installs one, as long as the modified version is
+    interface-compatible with the version that the work was made with.
+
+    c) Accompany the work with a written offer, valid for at
+    least three years, to give the same user the materials
+    specified in Subsection 6a, above, for a charge no more
+    than the cost of performing this distribution.
+
+    d) If distribution of the work is made by offering access to copy
+    from a designated place, offer equivalent access to copy the above
+    specified materials from the same place.
+
+    e) Verify that the user has already received a copy of these
+    materials or that you have already sent this user a copy.
+
+  For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it.  However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+  It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system.  Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+\f
+  7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+    a) Accompany the combined library with a copy of the same work
+    based on the Library, uncombined with any other library
+    facilities.  This must be distributed under the terms of the
+    Sections above.
+
+    b) Give prominent notice with the combined library of the fact
+    that part of it is a work based on the Library, and explaining
+    where to find the accompanying uncombined form of the same work.
+
+  8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License.  Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License.  However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+  9. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Library or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+  10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+\f
+  11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded.  In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+  13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation.  If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+\f
+  14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission.  For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this.  Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+                           NO WARRANTY
+
+  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+                    END OF TERMS AND CONDITIONS
+\f
+           How to Apply These Terms to Your New Libraries
+
+  If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change.  You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+  To apply these terms, attach the following notices to the library.  It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the library's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the
+  library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+  <signature of Ty Coon>, 1 April 1990
+  Ty Coon, President of Vice
+
+That's all there is to it!
+
+
diff --git a/README b/README
new file mode 100644 (file)
index 0000000..2c28d69
--- /dev/null
+++ b/README
@@ -0,0 +1 @@
+This is Medfield sensor plugins package.
diff --git a/inc/accelprocessor.h b/inc/accelprocessor.h
new file mode 100644 (file)
index 0000000..8d715ee
--- /dev/null
@@ -0,0 +1,52 @@
+/* Medfield sensor plugins
+ * Copyright (C) 2013 Intel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; version 2.1.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef ACCELPROCESSOR_H
+#define ACCELPROCESSOR_H
+
+#include "baseprocessor.h"
+class AccelProcessor : public BaseProcessor {
+public:
+     AccelProcessor();
+     virtual bool fill_values(unsigned int type, int &count,
+                              data_unit_idx_t &unit, data_accuracy &accuracy);
+
+     virtual int get_property(unsigned int property_level, base_property_struct &result);
+
+     void process_input_events(const std::vector <input_event *> &events);
+     void calculateOrientation();
+private:
+     /**Last readed X acceleration*/
+     float mX;
+
+     /**Last readed Y acceleration*/
+     float mY;
+
+     /**Last readed Z acceleration*/
+     float mZ;
+
+     /**Calculated pitch*/
+     float mBeta;
+
+     /**Calculated theta*/
+     float mGamma;
+
+     /** Current rotation_*/
+     rotation_event mRotation;
+};
+
+#endif
diff --git a/inc/baseprocessor.h b/inc/baseprocessor.h
new file mode 100644 (file)
index 0000000..25e5926
--- /dev/null
@@ -0,0 +1,215 @@
+/* Medfield sensor plugins
+ * Copyright (C) 2013 Intel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; version 2.1.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301USA
+ */
+
+#ifndef BASEPROCESSOR_H
+#define BASEPROCESSOR_H
+
+#include <sys/un.h>
+#include <netinet/in.h>
+#include <pthread.h>
+#include <cobject_type.h>
+#include <clist.h>
+#include <cmutex.h>
+#include <sf_common.h>
+#include <cmodule.h>
+#include <cworker.h>
+#include <csensor_module.h>
+#include <cfilter_module.h>
+#include <csensor_module.h>
+#include <cprocessor_module.h>
+#include "sensor.h"
+#include <vector>
+#include <linux/input.h>
+#include <string>
+
+class BaseProcessor: public cprocessor_module {
+public:
+     BaseProcessor();
+     virtual ~BaseProcessor();
+
+     virtual bool add_input(csensor_module *sensor);
+     virtual bool add_input(cfilter_module *filter);
+
+     virtual cprocessor_module *create_new(void);
+     virtual void destroy(cprocessor_module *module);
+
+     virtual const char *name(void);
+     virtual int version(void);
+     virtual int id(void);
+
+     virtual bool update_name(char *name);
+     virtual bool update_version(int version);
+     virtual bool update_id(int id);
+
+     virtual long value(char *port);
+     virtual long value(int id);
+
+     virtual bool add_callback_func(cmd_reg_t *param);
+     virtual bool remove_callback_func(cmd_reg_t *param);
+     virtual bool check_callback_event(cmd_reg_t *param);
+
+     virtual long set_cmd(int type , int property , long input_value);
+     virtual int get_property(unsigned int property_level , void *property_struct);
+     virtual int get_property(unsigned int property_level, base_property_struct &result);
+
+     /**
+      * @brief get_struct_value Base implementation will call fill_values with struct_type
+      * and copy values from mValues to client response struct
+      * @param struct_type type which should be returned.
+      * @param struct_values values should be put inside this. Type is really base_data_struct *
+      * @return
+      */
+     virtual int get_struct_value(unsigned int struct_type , void *struct_values);
+
+     /**
+      * @brief fill_values
+      * @param type which values should be returned. These are defined in sensor headers
+      * @param count this should be filled by implementation and set to amount of values
+      * @param unit unit of values. Must be filled by implementation
+      * @param accuracy accuracy of values. Must be filled by implementation
+      * returned by sensor. Values should be put to mValues array. This function will be
+      * called with mValueMutex held, so its safe to change values in array.
+      * @return true if reading ok, false otherwise
+      */
+     virtual bool fill_values(unsigned int type, int &count,
+                              data_unit_idx_t &unit, data_accuracy &accuracy) = 0;
+
+     /**
+      * @brief process_input_event this function will be called with readed input event.
+      * Base implementation handles events of EV_ABS and EV_REL type and puts values
+      * of these events to mValues array by event->code. This function is called with mValueMutex
+      * held.
+      * @param event event which was readed
+      */
+     virtual void process_input_events(const std::vector <input_event *> &events);
+
+     /**
+      * @brief start this function will be called by sensor framework when it wants to start
+      * this processor. Base implementation increases mStartCount and only calls
+      * cprocessor::module::start if this is first start. Before cprocessor::module::start
+      * is called enable() will be called (only in case first start).
+      * @return true if processor is started successfully or was previously started, false
+      * if starting fails
+      */
+     virtual bool start(void);
+
+
+     /**
+      * @brief stop this function will be called by sensor framework when it wants to start
+      * this processor. Base implementation increases mStartCount and only calls
+      * cprocessor::module::start if this is last stop
+      * @return true if processor is stopped successfully or was previously stopped, false
+      * if stopping fails
+      */
+     virtual bool stop(void);
+
+     /**
+      * @brief enable This function will be called when sensor should be started. Base implementation
+      * tries to find enable file from mSysfsPath path. If it finds it, writes 1 to it.
+      * Base implementation always returns true.
+      * @return true if enabling succeeds otherwise false.
+      *
+      */
+     virtual bool enable();
+
+     /**
+      * @brief disable This function will be called when sensor should be disabled. Base implementation
+      * tries to find enable file from mSysfsPath path. If it finds it, writes 0 to it.
+      * Base implementation always returns true.
+      * @return true if disabling succeeds otherwise false.
+      */
+     virtual bool disable();
+
+     /**
+      * @brief started this function will be called by sensor framework thread main loop
+      * this static function will call started() implementation of this class
+      * @return value which has been returned by started() function of this class.
+      */
+     static void *started(void *);
+
+protected:
+     /**
+      * @brief started this function will be called by started static function. This
+      * function should do sensors data processing. Base implementation reads input events from
+      * mFd file descriptor and feeds them to process_input_event
+      * @return
+      */
+     virtual void *started();
+
+     /**
+      * @brief find_input_device_by_name Search and open input device for sensor.
+      * Goes through devices under /dev/input and opens device which name matches
+      * to given parameter. Doesn't recurse to subdirs.
+      * @param inputName name returned by EVIOCGNAME ioctl for wanted device
+      * @return true if device found false otherwise
+      */
+     bool find_input_device_by_name(const char *inputName);
+
+     /**
+      * @brief find_input_device_by_name Search and open input device for sensor.
+      * This function uses sysfs to find device. This function fills mSysfsPath if
+      * device is found
+      * @param driver name of the driver for wanted input device
+      * @return true if device found false otherwise
+      */
+     const char* find_device_from_udev(const char *driver);
+
+     /**
+      * @brief writeToSysfs Writes information to device specific node in sysfs
+      * @param filename filename to write in sysfs. Not including path whics is taken from mSysfsPath
+      * @see find_device_from_udev
+      * @param buffer buffer to write
+      * @param count count of bytes to write
+      * @return false if mSysfsPath is empty or opening of file fails
+      */
+     bool writeToSysfs(const char *filename, const char *buffer, int count);
+
+     /**Id of sensor */
+     int mId;
+
+     /** Name of sensor*/
+     std::string mName;
+
+     /**Sensor driver version*/
+     int mVersion;
+
+     /**Values read from sensor, fill_values function should use this*/
+     float  mValues[6];
+
+     /** Mutex which protects mValues array*/
+     cmutex mValueMutex;
+
+     /** How many times this sensor has been started*/
+     int mStartCount;
+
+     /** Callback functions registered*/
+     std::vector <cmd_reg_t> mCallbacks;
+
+     /** File descriptor associated with sensor*/
+     int mFd;
+
+     /** How many input events are expected from sensor*/
+     unsigned int mInputEventCount;
+
+     /** Path in sysfs to this sensor*/
+     std::string mSysfsPath;
+
+     /** Supported callback events*/
+     std::vector <int> mSupportedEvents;
+};
+
+#endif
diff --git a/inc/compassprocessor.h b/inc/compassprocessor.h
new file mode 100644 (file)
index 0000000..f975dd2
--- /dev/null
@@ -0,0 +1,33 @@
+/* Medfield sensor plugins
+ * Copyright (C) 2013 Intel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; version 2.1.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301USA
+ */
+
+#ifndef COMPASSPROCESSOR_H
+#define COMPASSPROCESSOR_H
+
+#include "baseprocessor.h"
+
+class CompassProcessor : public BaseProcessor {
+public:
+     CompassProcessor();
+     virtual bool fill_values(unsigned int type, int &count,
+                              data_unit_idx_t &unit, data_accuracy &accuracy);
+
+     virtual int get_property(unsigned int property_level,
+                              base_property_struct &result);
+};
+
+#endif // COMPASSPROCESSOR_H
diff --git a/inc/gyroprocessor.h b/inc/gyroprocessor.h
new file mode 100644 (file)
index 0000000..0f7fc25
--- /dev/null
@@ -0,0 +1,35 @@
+/* Medfield sensor plugins
+ * Copyright (C) 2013 Intel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; version 2.1.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301USA
+ */
+
+#ifndef GYROPROCESSOR_H
+#define GYROPROCESSOR_H
+
+#include "baseprocessor.h"
+
+class GyroProcessor : public BaseProcessor {
+public:
+     GyroProcessor();
+     virtual bool fill_values(unsigned int type, int &count,
+                              data_unit_idx_t &unit, data_accuracy &accuracy);
+
+     virtual int get_property(unsigned int property_level,
+                              base_property_struct &result);
+
+     virtual void process_input_events(const std::vector <input_event *> &events);
+};
+
+#endif // GYROPROCESSOR_H
diff --git a/inc/lightprocessor.h b/inc/lightprocessor.h
new file mode 100644 (file)
index 0000000..cad23cc
--- /dev/null
@@ -0,0 +1,43 @@
+/* Medfield sensor plugins
+ * Copyright (C) 2013 Intel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; version 2.1.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301USA
+ */
+
+#ifndef LIGHTPROCESSOR_H
+#define LIGHTPROCESSOR_H
+
+#include "baseprocessor.h"
+
+class LightProcessor : public BaseProcessor {
+public:
+     LightProcessor();
+
+     virtual bool fill_values(unsigned int type, int &count,
+                              data_unit_idx_t &unit, data_accuracy &accuracy);
+
+     virtual int  get_property(unsigned int property_level,
+                               base_property_struct &result);
+
+     virtual bool enable();
+     virtual bool disable();
+     virtual void* started();
+private:
+     /** Lastly readed lux value*/
+     int mLuxValue;
+     /** Current index*/
+     int mIndex;
+};
+
+#endif // LIGHTPROCESSOR_H
diff --git a/inc/log.h b/inc/log.h
new file mode 100644 (file)
index 0000000..e77a12d
--- /dev/null
+++ b/inc/log.h
@@ -0,0 +1,29 @@
+/* Medfield sensor plugins
+ * Copyright (C) 2013 Intel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; version 2.1.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301USA
+ */
+
+#ifndef LOG_H
+#define LOG_H
+
+#include <stdio.h>
+
+#if 0
+#define DbgPrint(format,args...) fprintf(stderr,"%s %d:" format "\n", __PRETTY_FUNCTION__,__LINE__,##args)
+#else
+#define DbgPrint(format,args...) void (0)
+#endif
+
+#endif // LOG_H
diff --git a/inc/ms5607processors.h b/inc/ms5607processors.h
new file mode 100644 (file)
index 0000000..a1ca60d
--- /dev/null
@@ -0,0 +1,59 @@
+/* Medfield sensor plugins
+ * Copyright (C) 2013 Intel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; version 2.1.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301USA
+ */
+
+#ifndef MS5607PROCESSORS_H
+#define MS5607PROCESSORS_H
+
+#include "baseprocessor.h"
+
+enum pressure_data_id {
+     PRESSURE_BASE_DATA_SET = (BAROMETER_SENSOR<<16) | 0x0001,
+};
+
+
+class Ms5607Reader : public BaseProcessor {
+public:
+     Ms5607Reader();
+     virtual bool enable();
+     virtual void process_input_events(const std::vector <input_event *> &events);
+protected:
+     static int mCalibdata[8];
+     static int mAdc1;
+     static int mAdc2;
+     static long long int mDT;
+     static long long int mOFF;
+     static long long int mSENS;
+};
+
+
+class PressureProcessor : public Ms5607Reader {
+public:
+     PressureProcessor();
+
+     virtual bool fill_values(unsigned int type, int &count,
+                              data_unit_idx_t &unit, data_accuracy &accuracy);
+};
+
+class TemperatureProcessor : public Ms5607Reader {
+public:
+     TemperatureProcessor();
+
+     virtual bool fill_values(unsigned int type, int &count,
+                              data_unit_idx_t &unit, data_accuracy &accuracy);
+};
+
+#endif // MS5607PROCESSORS_H
diff --git a/inc/proxiprocessor.h b/inc/proxiprocessor.h
new file mode 100644 (file)
index 0000000..b7cc42d
--- /dev/null
@@ -0,0 +1,37 @@
+/* Medfield sensor plugins
+ * Copyright (C) 2013 Intel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; version 2.1.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301USA
+ */
+
+#ifndef PROXIPROCESSOR_H
+#define PROXIPROCESSOR_H
+
+#include "baseprocessor.h"
+
+class ProxiProcessor : public BaseProcessor {
+public:
+     ProxiProcessor();
+
+     virtual bool fill_values(unsigned int type, int &count,
+                              data_unit_idx_t &unit, data_accuracy &accuracy);
+
+     int get_property(unsigned int property_level,
+                      base_property_struct &result);
+     virtual bool enable();
+     virtual bool disable();
+     virtual void* started();
+};
+
+#endif // PROXIPROCESSOR_H
diff --git a/packaging/sensor-plugins-mfld-blackbay.changes b/packaging/sensor-plugins-mfld-blackbay.changes
new file mode 100644 (file)
index 0000000..17f381a
--- /dev/null
@@ -0,0 +1,32 @@
+* Wed Jan 30 2013 Telle-Tiia Pitkänen <telle-tiia.pitkanen@ixonos.com> submit/tizen_2.0/20130128.082005@ddba03f
+- Rename package to sensor-plugins-mfld-blackbay
+
+* Thu Jan 24 2013 Timo Toikkanen <timo.toikkanen@ixonos.com> accepted/tizen_2.0/20130111.182103@acd54f7
+- Fix for TZSP-4919
+- Updating changelog
+
+* Fri Jan 10 2013 Telle-Tiia Pitkänen <telle-tiia.pitkanen@ixonos.com> submit/trunk/20121023.061641@daf1aa1
+- Adding LGPLv2.1 license information
+
+* Mon Oct 22 2012 Telle-Tiia Pitkänen <telle-tiia.pitkanen@ixonos.com> submit/trunk/20121018.113436@82ffeba
+- Changing x-axis to negative for platform changes.
+
+* Thu Oct 18 2012 Telle-Tiia Pitkänen <telle-tiia.pitkanen@ixonos.com> submit/2.0_beta/20121005.062450@49bb12d
+- Revert axes change due changes in platform.
+- Merge "Changing sign in 'z' and 'y' axes to negative. TZSP-3064" into 2.0_beta
+- Changing sign in 'z' and 'y' axes to negative. TZSP-3064
+
+* Fri Oct 05 2012 Przemyslaw Marek <przemyslaw.marek@ixonos.com> submit/2.0_beta/20120905.095619@5bf021a
+- Changing sign in 'z' and 'y' axes to negative. TZSP-3064
+
+* Wed Sep 05 2012 Yan Yin <yan.yin@intel.com> submit/2.0_beta/20120831.083244@8b25b4a
+- change PRESSURE_SENSOR to BAROMETER_SENSOR for 2.0.
+
+* Mon Aug 06 2012 Miika Jarvinen <miika.jarvinen@ixonos.com> 9ede2fa
+[ Miika Jarvinen ]
+- Fix inverted landscape rotation
+
+* Tue Jul 10 2012 miika.jarvinen@ixonos.com <miika.jarvinen@ixonos.com> 3317897
+[ Miika Jarvinen ]
+-     Sensor framework plugins for blackbay device.
+
diff --git a/packaging/sensor-plugins-mfld-blackbay.spec b/packaging/sensor-plugins-mfld-blackbay.spec
new file mode 100644 (file)
index 0000000..d730ba4
--- /dev/null
@@ -0,0 +1,35 @@
+Name:       sensor-plugins-mfld-blackbay
+Summary:    Plugins for sensor framework on blackbay device
+Version:    0.1.0
+Release:    1
+Group:      System/Sensor Framework
+License:    LGPLv2.1
+Source0:    %{name}-%{version}.tar.gz
+Requires:   libsf-common
+Requires:   sensor
+Requires:   udev
+BuildRequires:  pkgconfig(sf_common)
+BuildRequires:  pkgconfig(sensor)
+BuildRequires:  pkgconfig(libudev)
+BuildRequires:  pkgconfig(vconf)
+BuildRequires:  cmake
+
+
+%description
+Plugins for sensor framework on blackbay device.
+
+%prep
+%setup -q -n %{name}-%{version}
+
+%build
+cmake . -DCMAKE_INSTALL_PREFIX="/usr"
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+%make_install
+
+
+%files
+%defattr(-,root,root,-)
+%{_libdir}/sensor_framework/*.so*
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
new file mode 100644 (file)
index 0000000..bf74dda
--- /dev/null
@@ -0,0 +1,59 @@
+cmake_minimum_required(VERSION 2.6)
+
+#add_definitions(-Wall -O3 -omit-frame-pointer)
+add_definitions(-Wall -g)
+#add_definitions(-Wall -g -DDEBUG)
+
+add_library(accelprocessor SHARED
+baseprocessor.cpp
+accelprocessor.cpp
+accel_module.cpp
+)
+
+add_library(compassprocessor SHARED
+baseprocessor.cpp
+compassprocessor.cpp
+compass_module.cpp
+)
+
+add_library(gyroprocessor SHARED
+baseprocessor.cpp
+gyroprocessor.cpp
+gyro_module.cpp
+)
+
+add_library(lightsprocessor SHARED
+baseprocessor.cpp
+lightprocessor.cpp
+lights_module.cpp
+)
+
+add_library(proxiprocessor SHARED
+baseprocessor.cpp
+proxiprocessor.cpp
+proxi_module.cpp
+)
+
+add_library(pressureprocessor SHARED
+baseprocessor.cpp
+ms5607processors.cpp
+pressure_module.cpp
+)
+
+
+target_link_libraries(accelprocessor ${rpkgs_LDFLAGS} ${GLES_LDFLAGS})
+target_link_libraries(compassprocessor ${rpkgs_LDFLAGS} ${GLES_LDFLAGS})
+target_link_libraries(gyroprocessor ${rpkgs_LDFLAGS} ${GLES_LDFLAGS})
+target_link_libraries(lightsprocessor ${rpkgs_LDFLAGS} ${GLES_LDFLAGS})
+target_link_libraries(proxiprocessor ${rpkgs_LDFLAGS} ${GLES_LDFLAGS})
+target_link_libraries(pressureprocessor ${rpkgs_LDFLAGS} ${GLES_LDFLAGS})
+
+
+install(TARGETS accelprocessor DESTINATION lib/sensor_framework)
+install(TARGETS compassprocessor DESTINATION lib/sensor_framework)
+install(TARGETS gyroprocessor DESTINATION lib/sensor_framework)
+install(TARGETS lightsprocessor DESTINATION lib/sensor_framework)
+install(TARGETS proxiprocessor DESTINATION lib/sensor_framework)
+install(TARGETS pressureprocessor DESTINATION lib/sensor_framework)
+
+ADD_SUBDIRECTORY(test_programs)
diff --git a/src/accel_module.cpp b/src/accel_module.cpp
new file mode 100644 (file)
index 0000000..175fd64
--- /dev/null
@@ -0,0 +1,27 @@
+/* Medfield sensor plugins
+ * Copyright (C) 2013 Intel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; version 2.1.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301USA
+ */
+
+#include "accelprocessor.h"
+
+cmodule *module_init(void *win, void *egl)
+{
+     return new AccelProcessor();
+}
+
+void module_exit(cmodule *inst)
+{
+}
diff --git a/src/accelprocessor.cpp b/src/accelprocessor.cpp
new file mode 100644 (file)
index 0000000..835297b
--- /dev/null
@@ -0,0 +1,216 @@
+/* Medfield sensor plugins
+ * Copyright (C) 2013 Intel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; version 2.1.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301USA
+ */
+
+#include "log.h"
+#include "accelprocessor.h"
+#include <sensor_accel.h>
+#include <vconf.h>
+#include <math.h>
+
+static const float XY_THRESHOLD = 2;
+
+static const float RADIAN_MULTIPLIER = 180/M_PI;
+
+static const int ROTATION_THD = 45;
+
+static const int ROTATION_0 = 0;
+static const int ROTATION_90 = 90;
+static const int ROTATION_180 = 180;
+static const int ROTATION_360 = 360;
+
+static const char *ROTATION_KEY = DEFAULT_SENSOR_KEY_PREFIX"10001";
+
+AccelProcessor::AccelProcessor():
+     mX(0),
+     mY(0),
+     mZ(0),
+     mBeta(0),
+     mGamma(0)
+{
+     mInputEventCount = 4;
+     find_input_device_by_name("accel");
+     BaseProcessor::find_device_from_udev("accel");
+     mSysfsPath.append("/lis3dh");
+     mName = "accel";
+
+     mSupportedEvents.push_back(ACCELEROMETER_EVENT_ROTATION_CHECK);
+     mSupportedEvents.push_back(ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME);
+     mSupportedEvents.push_back(ACCELEROMETER_EVENT_ORIENTATION_DATA_REPORT_ON_TIME);
+}
+
+bool AccelProcessor::fill_values(unsigned int type, int &count,
+                                 data_unit_idx_t &unit, data_accuracy &accuracy)
+{
+     DbgPrint("");
+     if (type == ACCELEROMETER_BASE_DATA_SET) {
+          mValues[0] = -mX;
+          mValues[1] = mY;
+          mValues[2] = mZ;
+          DbgPrint("Returning ACCELEROMETER_BASE_DATA_SET -mX, mY, mZ");
+          count = 3;
+          unit = IDX_UNIT_METRE_PER_SECOND_SQUARED;
+          accuracy = ACCURACY_GOOD;
+
+          return true;
+     }
+
+     if (type == ACCELEROMETER_ORIENTATION_DATA_SET) {
+          mValues[0] = 0;
+          mValues[1] = mBeta;
+          mValues[2] = mGamma;
+          count = 3;
+          unit = IDX_UNIT_DEGREE;
+          accuracy = ACCURACY_NORMAL;
+          return true;
+     }
+
+     return false;
+}
+
+int AccelProcessor::get_property(unsigned int property_level, base_property_struct &result)
+{
+     strcpy(result.sensor_name, "lis3dh");
+     strcpy(result.sensor_vendor, "st");
+
+     if (property_level == ACCELEROMETER_BASE_DATA_SET) {
+          result.sensor_unit_idx = IDX_UNIT_METRE_PER_SECOND_SQUARED;
+          result.sensor_min_range = -20;
+          result.sensor_max_range = 20;
+          result.sensor_resolution = 0.0002;
+     } else if (property_level == ACCELEROMETER_ORIENTATION_DATA_SET) {
+          result.sensor_unit_idx = IDX_UNIT_DEGREE;
+          result.sensor_min_range = ROTATION_0;
+          result.sensor_max_range = ROTATION_360;
+          result.sensor_resolution = 0.0002;
+     } else {
+          return -1;
+     }
+
+     return 0;
+}
+
+void AccelProcessor::calculateOrientation()
+{
+     double absx = mX < 0 ? -mX : mX;
+     double absy = mY < 0 ? -mY : mY;
+
+     double atan_value = 0;
+     if (mZ == 0 && mX == 0)
+          atan_value = 0;
+     else
+          atan_value = atan2(mZ,mX);
+
+     //Todo: Check if calculations could be avoided here
+     int angle = ((int) (atan_value * (RADIAN_MULTIPLIER)));
+
+
+     if (angle > 0 && angle <= 180) {
+          mGamma = (angle-ROTATION_90);
+     }
+
+     else if (angle <= 0 && angle >= -ROTATION_180) {
+          mGamma = -(ROTATION_90+(angle));
+     }
+
+     DbgPrint("Angle is %d and gamma %d\n",angle,mGamma);
+
+     double normZ = mZ / 9.8;
+     if ( normZ > 1.0 ) {
+          normZ = 1.0;
+     } else if ( normZ < -1.0 ) {
+          normZ = -1.0;
+     }
+
+     DbgPrint("Normalized zeta is %f\n",normZ);
+
+     mBeta = (int)( acos(normZ) *(RADIAN_MULTIPLIER));
+     if (mY > 0)
+          mBeta = -mBeta;
+
+     if (absx < XY_THRESHOLD && absy < XY_THRESHOLD ) {
+          DbgPrint("absx %f absy %f\n",absx,absy);
+          return;
+     }
+
+     angle = (int) (atan2(mY,mX)*RADIAN_MULTIPLIER);
+     DbgPrint("Angle between y and x is is %d",angle);
+     int section = (angle+ROTATION_180)/45;
+     DbgPrint("\n\nSection is %d\n\n",section);
+
+     /**************************
+      *  ->>>>> Read clockwise, number presents power button
+      *        5
+      *      6   4
+      *    7       3
+      *     0    2
+      *        1
+      *
+      */
+
+     if(section == 6 || section == 5) {
+          DbgPrint("Power button up");
+          mRotation.rotation = ROTATION_EVENT_0;
+          mRotation.rm[0] = ROTATION_PORTRAIT_TOP;
+          mRotation.rm[1] = ROTATION_LANDSCAPE_LEFT;
+     }
+
+     else if(section == 4 || section == 3) {
+          DbgPrint("Power button right");
+          mRotation.rotation = ROTATION_EVENT_270;
+          mRotation.rm[0] = ROTATION_LANDSCAPE_RIGHT;
+          mRotation.rm[1] = ROTATION_PORTRAIT_TOP;
+     }
+
+     else if (section ==  2 || section == 1) {
+          DbgPrint("Power button down");
+          mRotation.rotation = ROTATION_EVENT_180;
+          mRotation.rm[0] = ROTATION_PORTRAIT_BTM;
+          mRotation.rm[1] = ROTATION_LANDSCAPE_LEFT;
+     }
+
+     else {
+          DbgPrint("Power button left");
+          mRotation.rotation = ROTATION_EVENT_90;
+          mRotation.rm[0] = ROTATION_LANDSCAPE_LEFT;
+          mRotation.rm[1] = ROTATION_PORTRAIT_BTM;
+     }
+}
+
+void AccelProcessor::process_input_events(const std::vector <input_event *> &events)
+{
+     DbgPrint();
+
+     mValues[0] = -1;
+     mValues[1] = -1;
+     mValues[2] = -1;
+     BaseProcessor::process_input_events(events);
+
+     //Sensors input z and y value in negative from value
+     //expected from sensor framework
+     //and all values as integer (multiplied by 100)
+     mX = mValues[0] /= 100.0;
+     mY = mValues[1] /= -100.0;
+     mZ = mValues[2] /= -100.0;
+
+     accelerometer_rotate_state oldRotation = mRotation.rotation;
+     calculateOrientation();
+     if (oldRotation != mRotation.rotation) {
+          vconf_set_int(ROTATION_KEY, mRotation.rotation);
+     }
+}
+
+
diff --git a/src/baseprocessor.cpp b/src/baseprocessor.cpp
new file mode 100644 (file)
index 0000000..faf8c51
--- /dev/null
@@ -0,0 +1,480 @@
+/* Medfield sensor plugins
+ * Copyright (C) 2013 Intel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; version 2.1.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301USA
+ */
+
+#include <stdio.h>
+#include <limits.h>
+#include <dirent.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <linux/input.h>
+#include <errno.h>
+#include "baseprocessor.h"
+#include "log.h"
+#include <algorithm>
+#include <libudev.h>
+
+
+BaseProcessor::BaseProcessor():
+     mId(0),
+     mVersion(0),
+     mStartCount(0),
+     mFd(-1),
+     mInputEventCount(0)
+{
+     set_main(started,0,this);
+     memset(&mValues,0,sizeof(mValues));
+}
+
+BaseProcessor::~BaseProcessor()
+{
+     if (mFd != -1)
+          close(mFd);
+}
+
+bool BaseProcessor::add_input(csensor_module *sensor)
+{
+     DbgPrint("");
+     return true;
+}
+
+bool BaseProcessor::add_input(cfilter_module *filter)
+{
+     DbgPrint("");
+     return true;
+}
+
+cprocessor_module *BaseProcessor::create_new(void)
+{
+     DbgPrint("");
+     return this;
+}
+
+void BaseProcessor::destroy(cprocessor_module *module)
+{
+     DbgPrint("");
+}
+
+const char *BaseProcessor::name(void)
+{
+     DbgPrint("");
+     return mName.c_str();
+}
+
+int BaseProcessor::version(void)
+{
+     DbgPrint("");
+     return mVersion;
+}
+
+int BaseProcessor::id(void)
+{
+     DbgPrint("");
+     return mId;
+}
+
+bool BaseProcessor::update_name(char *name)
+{
+     DbgPrint("");
+     mName = name;
+     return true;
+}
+
+bool BaseProcessor::update_version(int version)
+{
+     DbgPrint("");
+     mVersion = version;
+     return true;
+}
+
+bool BaseProcessor::update_id(int id)
+{
+     DbgPrint("");
+     mId = id;
+     return true;
+}
+
+long BaseProcessor::value(char *port)
+{
+     DbgPrint("");
+     return 1;
+}
+
+long BaseProcessor::value(int id)
+{
+     DbgPrint("");
+     return 1;
+}
+
+
+bool BaseProcessor::add_callback_func(cmd_reg_t *param)
+{
+     DbgPrint("%s",mName.c_str());
+
+     if (!check_callback_event(param))
+          return false;
+
+     mCallbacks.push_back(*param);
+
+     return true;
+}
+
+
+
+bool operator==(const cmd_reg_t &a, const cmd_reg_t &b)
+{
+     return (a.type == b.type && a.event_type == b.event_type &&
+             a.interval == b.interval);
+}
+
+
+bool BaseProcessor::remove_callback_func(cmd_reg_t *toRemove)
+{
+     DbgPrint("");
+     std::vector<cmd_reg_t>::iterator iter;
+
+     iter = std::find(mCallbacks.begin(),mCallbacks.end(),*toRemove);
+
+     if (iter == mCallbacks.end())
+          return false;
+
+     mCallbacks.erase(iter,iter);
+
+
+     return true;
+}
+
+bool BaseProcessor::check_callback_event(cmd_reg_t *param)
+{
+     DbgPrint("");
+     if (!param)
+          return false;
+
+     std::vector<int>::const_iterator iter;
+
+     for (iter = mSupportedEvents.begin(); iter != mSupportedEvents.end(); iter++) {
+          if ((*iter) == param->event_type)
+               return true;
+     }
+
+     DbgPrint("Requested event was not found");
+     return false;
+}
+
+long BaseProcessor::set_cmd(int type , int property , long input_value)
+{
+     DbgPrint("");
+     return 0;
+
+}
+
+int BaseProcessor::get_property(unsigned int property_level , void *property_struct)
+{
+     DbgPrint("Name %s level %d ",mName.c_str(), property_level);
+
+     if (!property_struct)
+          return -1;
+
+     base_property_struct *result = (base_property_struct*) property_struct;
+     return get_property(property_level, *result );
+}
+
+int BaseProcessor::get_property(unsigned int property_level , base_property_struct &result)
+{
+     return -1;
+}
+
+int BaseProcessor::get_struct_value(unsigned int struct_type , void *struct_values)
+{
+     DbgPrint("");
+     int count;
+
+     mValueMutex.lock();
+
+     data_accuracy accuracy = ACCURACY_UNDEFINED;
+     data_unit_idx_t unit = IDX_UNDEFINED_UNIT;
+
+     if (!fill_values(struct_type, count, unit, accuracy)) {
+          DbgPrint("Fill values returned false");
+          mValueMutex.unlock();
+          return -3;
+     }
+
+     base_data_struct *result = (base_data_struct *)struct_values;
+
+     for (int i = 0; i < count; i++) {
+          result->values[i] = this->mValues[i];
+          DbgPrint("result [%d] is %f",i, result->values[i] );
+     }
+     result->values_num = count;
+     result->data_accuracy = accuracy;
+
+
+     mValueMutex.unlock();
+
+     return 0;
+
+}
+
+
+void* BaseProcessor::started(void *ctx)
+{
+     DbgPrint("");
+     return ((BaseProcessor *) ctx)->started();
+}
+
+void* BaseProcessor::started()
+{
+     DbgPrint("");
+     if (mFd != -1 && mInputEventCount) {
+          input_event *events = new input_event[mInputEventCount];
+          const ssize_t readByteCount = read(mFd, events, mInputEventCount * sizeof(input_event));
+          DbgPrint("%s Readed %d bytes",mName.c_str(),readByteCount);
+
+          //Ignore partial event reads
+          if (readByteCount > 0 && readByteCount % sizeof(input_event) == 0) {
+               const int readEventCount = readByteCount / sizeof(input_event);
+               std::vector <input_event *> eventVector;
+               DbgPrint("Count of events is %d",readEventCount);
+               for (int i = 0; i < readEventCount; i++) {
+                    eventVector.push_back(&(events[i]));
+               }
+
+
+               mValueMutex.lock();
+               process_input_events(eventVector);
+               mValueMutex.unlock();
+          }
+
+          delete [] events;
+     }
+     return (void *) cworker::STARTED;
+}
+
+void BaseProcessor::process_input_events(const std::vector<input_event*> &events)
+{
+     std::vector<input_event *>::const_iterator iterator;
+     for (iterator = events.begin(); iterator != events.end(); iterator++) {
+          const input_event& event = (**iterator);
+          switch(event.type) {
+          case EV_REL:
+          case EV_ABS:
+               DbgPrint("%s sensor got input code %d value %d\n",mName.c_str(), event.code, event.value);
+               if (event.code < sizeof(mValues)/sizeof(float))
+                    mValues[event.code] = event.value;
+               break;
+
+          case EV_SYN:
+               DbgPrint("Syn event");
+               break;
+
+          default:
+               DbgPrint("Unknown event type %d", event.type);
+
+          }
+     }
+}
+
+bool BaseProcessor::start(void)
+{
+     mStartCount++;
+
+     if (mStartCount > 1)
+          return true;
+
+     enable();
+
+     return cprocessor_module::start();
+}
+
+bool BaseProcessor::stop(void)
+{
+     DbgPrint();
+     if (mStartCount > 0)
+          mStartCount--;
+
+     if (mStartCount > 0)
+          return true;
+
+     return cprocessor_module::stop();
+}
+
+bool BaseProcessor::enable()
+{
+     writeToSysfs("enable","1",1);
+     return true;
+}
+
+
+bool BaseProcessor::disable()
+{
+     writeToSysfs("enable","0",1);
+     return true;
+}
+
+
+bool BaseProcessor::find_input_device_by_name(const char *inputName)
+{
+     const char *dirname = "/dev/input";
+     char devname[PATH_MAX];
+
+     char *filename;
+     DIR *dir;
+     struct dirent *de;
+
+     DbgPrint("");
+     mFd = -1;
+
+     dir = opendir(dirname);
+     if(dir == NULL)
+          return mFd;
+
+     memset(devname,0,PATH_MAX);
+     strcpy(devname, dirname);
+     filename = devname + strlen(devname);
+     *filename++ = '/';
+     strcpy(devname, dirname);
+     filename = devname + strlen(devname);
+     *filename++ = '/';
+
+     while ((de = readdir(dir))) {
+          if (de->d_type == DT_DIR)
+               continue;
+
+          strcpy(filename, de->d_name);
+          filename[strlen(de->d_name)] = 0;
+
+          mFd = open(devname,O_RDONLY);
+          if (mFd <= 0) {
+               DbgPrint("Not opened %s",devname);
+               continue;
+          }
+
+          char name[80];
+          if (ioctl(mFd, EVIOCGNAME(sizeof(name) - 1), &name) < 1) {
+               name[0] = '\0';
+               DbgPrint("Ioctl error");
+          } else
+               DbgPrint("Found device %s: %s",devname,name);
+
+          if (!strcmp(name, inputName)) {
+               DbgPrint("Found input device for sensor %s: %s",devname,name);
+               break;
+          } else {
+               close(mFd);
+               mFd = -1;
+          }
+     }
+
+     closedir(dir);
+
+     return mFd != -1;
+}
+
+const char *BaseProcessor::find_device_from_udev(const char *driver)
+{
+     udev_device *dev = NULL;
+     udev *udev = NULL;
+     udev_enumerate *enumerator = NULL;
+     bool result = false;
+     struct udev_list_entry *devices = NULL, *dev_list_entry = NULL;
+     const char *devicePath = "";
+
+     DbgPrint("");
+
+     mSysfsPath = "";
+
+     udev = udev_new();
+
+
+     if (udev == NULL) {
+          DbgPrint("Failed to initialize udev %d",errno);
+          return NULL;
+     }
+
+     enumerator = udev_enumerate_new(udev);
+
+     if (!enumerator) {
+          DbgPrint("Failed to initialize enumerator");
+          goto release_udev;
+     }
+
+     //This class is only meant to be used for sensors
+     //which are connected by i2c bus
+     udev_enumerate_add_match_subsystem(enumerator,"i2c");
+     udev_enumerate_add_match_property(enumerator,"DRIVER",driver);
+
+     if (udev_enumerate_scan_devices(enumerator) != 0) {
+          DbgPrint("Failed to scan devices");
+          goto release_enumerator;
+     }
+
+     devices = udev_enumerate_get_list_entry(enumerator);
+
+     udev_list_entry_foreach(dev_list_entry, devices) {
+
+          const char *path = udev_list_entry_get_name(dev_list_entry);
+          DbgPrint("Found device named: %s value",path);
+
+          dev = udev_device_new_from_syspath(udev,path);
+
+          if (dev) {
+               devicePath = udev_device_get_devpath(dev);
+               udev_device_unref(dev);
+               break;
+          }
+     }
+
+     mSysfsPath = "/sys";
+     mSysfsPath += devicePath;
+
+     result = true;
+
+release_enumerator:
+     udev_enumerate_unref(enumerator);
+release_udev:
+     udev_unref(udev);
+
+     return devicePath;
+}
+
+
+bool BaseProcessor::writeToSysfs(const char *filename, const char *buffer, int count)
+{
+     DbgPrint("%s",name());
+
+     if (!mSysfsPath.empty()) {
+          std::string fullpath = mSysfsPath;
+          fullpath.append("/");
+          fullpath.append(filename);
+          const char *cpath = fullpath.c_str();
+
+          DbgPrint("Trying to open sysfs file entry %s",cpath);
+          int fd = open(cpath,O_WRONLY);
+          if (fd > 0) {
+               DbgPrint("Sysfs file entry opened");
+               int writeCount = write(fd,buffer,count);
+               if (writeCount == count) {
+                    close(fd);
+                    return true;
+               }
+               close(fd);
+          }
+     }
+     DbgPrint("There was error opening sysfs file %s",strerror(errno));
+
+     return false;
+}
diff --git a/src/compass_module.cpp b/src/compass_module.cpp
new file mode 100644 (file)
index 0000000..05ef23c
--- /dev/null
@@ -0,0 +1,27 @@
+/* Medfield sensor plugins
+ * Copyright (C) 2013 Intel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; version 2.1.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301USA
+ */
+
+#include "compassprocessor.h"
+
+cmodule *module_init(void *win, void *egl)
+{
+     return new CompassProcessor();
+}
+
+void module_exit(cmodule *inst)
+{
+}
diff --git a/src/compassprocessor.cpp b/src/compassprocessor.cpp
new file mode 100644 (file)
index 0000000..4e0634e
--- /dev/null
@@ -0,0 +1,63 @@
+/* Medfield sensor plugins
+ * Copyright (C) 2013 Intel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; version 2.1.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "compassprocessor.h"
+#include "sensor_geomag.h"
+#include "log.h"
+
+CompassProcessor::CompassProcessor()
+{
+     DbgPrint("");
+     mName = "magnetometer";
+     mInputEventCount = 4;
+     find_input_device_by_name("hmc5883");
+     BaseProcessor::find_device_from_udev("compass");
+     mSysfsPath += "/hmc5883";
+     mSupportedEvents.push_back(GEOMAGNETIC_EVENT_RAW_DATA_REPORT_ON_TIME);
+}
+
+bool CompassProcessor::fill_values(unsigned int type, int &count,
+                                   data_unit_idx_t &unit, data_accuracy &accuracy)
+{
+     if (type == GEOMAGNETIC_RAW_DATA_SET) {
+          count = 3;
+          unit = IDX_UNIT_MICRO_TESLA;
+          accuracy = ACCURACY_GOOD;
+          return true;
+     }
+
+     return false;
+}
+
+int CompassProcessor::get_property(unsigned int property_level,
+                                   base_property_struct &result)
+{
+     strcpy(result.sensor_name, "hmc5883");
+     strcpy(result.sensor_vendor,"Honeywell");
+     if (property_level == GEOMAGNETIC_RAW_DATA_SET) {
+          result.sensor_unit_idx = IDX_UNIT_MICRO_TESLA;
+          result.sensor_min_range = 0;
+          result.sensor_max_range = 1000;
+          result.sensor_resolution = 1;
+     } else {
+          return -1;
+     }
+
+
+     return 0;
+}
diff --git a/src/gyro_module.cpp b/src/gyro_module.cpp
new file mode 100644 (file)
index 0000000..287bb95
--- /dev/null
@@ -0,0 +1,27 @@
+/* Medfield sensor plugins
+ * Copyright (C) 2013 Intel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; version 2.1.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301USA
+ */
+
+#include "gyroprocessor.h"
+
+cmodule *module_init(void *win, void *egl)
+{
+     return new GyroProcessor();
+}
+
+void module_exit(cmodule *inst)
+{
+}
diff --git a/src/gyroprocessor.cpp b/src/gyroprocessor.cpp
new file mode 100644 (file)
index 0000000..dff0954
--- /dev/null
@@ -0,0 +1,76 @@
+/* Medfield sensor plugins
+ * Copyright (C) 2013 Intel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; version 2.1.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301USA
+ */
+
+#include "gyroprocessor.h"
+#include "log.h"
+
+GyroProcessor::GyroProcessor()
+{
+     DbgPrint();
+     mName = "gyro";
+     mInputEventCount = 4;
+     find_input_device_by_name("gyro");
+     find_device_from_udev("gyro");
+     mSupportedEvents.push_back(GYROSCOPE_EVENT_RAW_DATA_REPORT_ON_TIME);
+}
+
+bool GyroProcessor::fill_values(unsigned int type, int &count,
+                                data_unit_idx_t &unit, data_accuracy &accuracy)
+{
+     DbgPrint();
+     if (type == GYRO_BASE_DATA_SET) {
+          count = 3;
+          accuracy = ACCURACY_GOOD;
+          unit = IDX_UNDEFINED_UNIT;
+
+          return true;
+     }
+     DbgPrint("Values not processed");
+     return false;
+}
+
+int GyroProcessor::get_property(unsigned int property_level,
+                                base_property_struct &result)
+{
+     strcpy(result.sensor_name,"mpu3050");
+     strcpy(result.sensor_vendor,"invensense");
+     if (property_level == GYROSCOPE_EVENT_RAW_DATA_REPORT_ON_TIME) {
+          result.sensor_unit_idx = IDX_UNDEFINED_UNIT;
+          result.sensor_min_range = 0;
+          result.sensor_max_range = 1;
+          result.sensor_resolution = 0.001;
+     } else {
+          return -1;
+     }
+
+     return 0;
+}
+
+void GyroProcessor::process_input_events(const std::vector <input_event *> &events)
+{
+     DbgPrint();
+     BaseProcessor::process_input_events(events);
+
+     //Sensor input all x and z values in negative from value
+     //expected from sensor framework
+     //and all axis as integer as integer (multiplied by 1000)
+
+     mValues[0] /= -1000.0;
+     mValues[1] /= 1000.0;
+     mValues[2] /= -1000.0;
+
+}
diff --git a/src/lightprocessor.cpp b/src/lightprocessor.cpp
new file mode 100644 (file)
index 0000000..2cec8d7
--- /dev/null
@@ -0,0 +1,160 @@
+/* Medfield sensor plugins
+ * Copyright (C) 2013 Intel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; version 2.1.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301USA
+ */
+
+#include "lightprocessor.h"
+#include "sensor.h"
+#include "log.h"
+#include "fcntl.h"
+#include "poll.h"
+#include "vconf.h"
+
+const char *LIGHT_INDEX_KEY = DEFAULT_SENSOR_KEY_PREFIX"40001";
+
+LightProcessor::LightProcessor()
+{
+     DbgPrint("%p",this);
+     mName = "light";
+
+     mSupportedEvents.push_back(LIGHT_EVENT_CHANGE_LEVEL);
+     mSupportedEvents.push_back(LIGHT_EVENT_LEVEL_DATA_REPORT_ON_TIME);
+     mSupportedEvents.push_back(LIGHT_EVENT_LUX_DATA_REPORT_ON_TIME);
+}
+
+bool LightProcessor::fill_values(unsigned int type, int &count,
+                                 data_unit_idx_t &unit, data_accuracy &accuracy)
+{
+     DbgPrint("%u",type);
+
+
+
+     switch (type) {
+     case LIGHT_LUX_DATA_SET:
+          count = 1;
+          mValues[0] = mLuxValue;
+          accuracy = ACCURACY_GOOD;
+          unit = IDX_UNIT_LUX;
+          break;
+     case LIGHT_BASE_DATA_SET:
+          count = 1;
+          mValues[0] = mIndex;
+          accuracy = ACCURACY_NORMAL;
+          unit = IDX_UNIT_LEVEL_1_TO_10;
+          return true;
+     default:
+          return false;
+     }
+
+     return true;
+}
+
+int LightProcessor::get_property(unsigned int property_level,
+                                 base_property_struct &result)
+{
+     strcpy(result.sensor_name,"ltr502");
+     strcpy(result.sensor_vendor,"Lite-On");
+
+     if (property_level == LIGHT_BASE_DATA_SET) {
+          result.sensor_unit_idx = IDX_UNIT_LEVEL_1_TO_10;
+          result.sensor_min_range = 1;
+          result.sensor_max_range = 10;
+          result.sensor_resolution = 0.0002;
+     } else if (property_level == LIGHT_LUX_DATA_SET) {
+          result.sensor_unit_idx = IDX_UNIT_LUX;
+          result.sensor_min_range = 0;
+          result.sensor_max_range = 10000;
+          result.sensor_resolution = 1;
+     } else {
+          return -1;
+     }
+
+     return 0;
+}
+
+bool LightProcessor::enable()
+{
+     DbgPrint("");
+     if (mFd <=  0) {
+          mFd = open("/dev/ltr502als_lsensor", O_RDONLY);
+     }
+
+     if (mFd > 0) {
+          ioctl(mFd,0,1);
+          return true;
+     }
+
+     DbgPrint("Opening sensor file failed");
+
+     return false;
+}
+
+bool LightProcessor::disable()
+{
+     if (mFd > 0) {
+          ioctl(mFd,0,0);
+          return true;
+     }
+
+     return false;
+}
+
+static int luxToIndex(int luminance)
+{
+     static const int luxValues[10] = {
+          10, 50, 100, 150, 250,
+          300, 400, 1000, 2000, 3000
+     };
+
+     for (unsigned int i = 0; i < sizeof(luxValues)/sizeof(int); i++) {
+          if (luxValues[i] >= luminance)
+               return i+1;
+     }
+
+     return 10;
+}
+
+void* LightProcessor::started()
+{
+     DbgPrint();
+     pollfd pollInfo;
+     pollInfo.fd = mFd;
+     pollInfo.events = POLLIN;
+     if(poll(&pollInfo,1,2000)){
+          DbgPrint("HAVE POLLIN");
+          int value;
+          int readCount = read(mFd,&value,sizeof(int));
+          if (readCount != sizeof(int)) {
+               return (void *) cworker::STARTED;
+          }
+
+          int oldIndex = mIndex;
+          int currentIndex = luxToIndex(value);
+
+          mValueMutex.lock();
+          mLuxValue = value;
+          mIndex = currentIndex;
+          mValueMutex.unlock();
+
+          if (currentIndex != oldIndex) {
+               vconf_set_int(LIGHT_INDEX_KEY, currentIndex);
+               DbgPrint("Notifying change old %d new %d", oldIndex, currentIndex);
+          }
+
+          DbgPrint("Readed value %d",value);
+     }
+
+     return (void *) cworker::STARTED;
+}
diff --git a/src/lights_module.cpp b/src/lights_module.cpp
new file mode 100644 (file)
index 0000000..b422ee4
--- /dev/null
@@ -0,0 +1,27 @@
+/* Medfield sensor plugins
+ * Copyright (C) 2013 Intel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; version 2.1.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301USA
+ */
+
+#include "lightprocessor.h"
+
+cmodule *module_init(void *win, void *egl)
+{
+     return new LightProcessor();
+}
+
+void module_exit(cmodule *inst)
+{
+}
diff --git a/src/ms5607processors.cpp b/src/ms5607processors.cpp
new file mode 100644 (file)
index 0000000..597fd09
--- /dev/null
@@ -0,0 +1,129 @@
+/* Medfield sensor plugins
+ * Copyright (C) 2013 Intel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; version 2.1.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301USA
+ */
+
+#include "ms5607processors.h"
+#include "log.h"
+#include <fstream>
+#include <iostream>
+
+
+const int UNSET = -1;
+const int BUFSIZE = 128;
+
+int Ms5607Reader::mCalibdata [] = {UNSET, UNSET,UNSET,UNSET,
+                                   UNSET,UNSET,UNSET,UNSET
+                                  };
+int Ms5607Reader::mAdc1 = 0;
+int Ms5607Reader::mAdc2 = 0;
+long long int Ms5607Reader::mDT = 0;
+long long int Ms5607Reader::mOFF = 0;
+long long int Ms5607Reader::mSENS = 0;
+
+Ms5607Reader::Ms5607Reader()
+{
+     DbgPrint();
+     find_input_device_by_name("ms5607_pressure");
+     find_device_from_udev("baro");
+     mInputEventCount = 2;
+}
+
+bool Ms5607Reader::enable()
+{
+     if (BaseProcessor::enable()) {
+          const int maxLines = sizeof(mCalibdata)/sizeof(mCalibdata[0]);
+
+          if (mCalibdata[0] == UNSET) {
+               std::string tmp = mSysfsPath;
+               tmp.append("/coeff");
+               std::fstream f(tmp.c_str(),std::ios::in);
+
+               int goodLines = 0;
+               while (f.good() && goodLines < maxLines) {
+                    std::string name;
+                    int value;
+                    f >> name >> value;
+                    if (f.fail())
+                         continue;
+
+                    mCalibdata[goodLines++] = value;
+               }
+
+               if (goodLines != maxLines) {
+                    mCalibdata[0] = UNSET;
+                    disable();
+                    return -1;
+               }
+
+               f.close();
+          }
+
+     }
+
+     for (int i = 0; i < 8; i++)
+          std::cout <<i <<" " <<mCalibdata[i] <<"\n";
+
+     return 0;
+}
+
+void Ms5607Reader::process_input_events(const std::vector <input_event *> &events)
+{
+     BaseProcessor::process_input_events(events);
+     if (events.size() == 2) {
+          mAdc1 = mValues[0];
+          mAdc2 = mValues[1];
+
+          //These calculations are from mail
+          mDT = mAdc2 - (mCalibdata[5] <<8);
+          mOFF = (((long long) mCalibdata[2]) <<17) + ((mCalibdata[4]*mDT)>>6);
+          mSENS = (((long long)mCalibdata[1]) <<16) + ((mCalibdata[3] * mDT) >>7);
+
+     }
+}
+
+TemperatureProcessor::TemperatureProcessor()
+{
+     mName = "Temperature";
+}
+
+bool TemperatureProcessor::fill_values(unsigned int type, int &count,
+                                       data_unit_idx_t &unit,
+                                       data_accuracy &accuracy)
+{
+     count = 1;
+     accuracy = ACCURACY_NORMAL;
+
+     //This calculation was received in mail
+     mValues[0] = (2000 + (mDT * (mCalibdata[6]) >>23)) / 100.0;
+     return true;
+}
+
+PressureProcessor::PressureProcessor()
+{
+     mName = "Pressure";
+}
+
+bool PressureProcessor::fill_values(unsigned int type, int &count,
+                                    data_unit_idx_t &unit,
+                                    data_accuracy &accuracy)
+{
+     count = 1;
+     accuracy = ACCURACY_NORMAL;
+
+     //This calculation was received in mail
+     mValues[0] = (((mAdc1 * (mSENS >>21)) - mOFF) >> 15) / 100000.0;
+     return true;
+}
diff --git a/src/pressure_module.cpp b/src/pressure_module.cpp
new file mode 100644 (file)
index 0000000..7fdff7d
--- /dev/null
@@ -0,0 +1,27 @@
+/* Medfield sensor plugins
+ * Copyright (C) 2013 Intel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; version 2.1.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301USA
+ */
+
+#include "ms5607processors.h"
+
+cmodule *module_init(void *win, void *egl)
+{
+     return new PressureProcessor();
+}
+
+void module_exit(cmodule *inst)
+{
+}
diff --git a/src/proxi_module.cpp b/src/proxi_module.cpp
new file mode 100644 (file)
index 0000000..19bc250
--- /dev/null
@@ -0,0 +1,27 @@
+/* Medfield sensor plugins
+ * Copyright (C) 2013 Intel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; version 2.1.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301USA
+ */
+
+#include "proxiprocessor.h"
+
+cmodule *module_init(void *win, void *egl)
+{
+     return new ProxiProcessor();
+}
+
+void module_exit(cmodule *inst)
+{
+}
diff --git a/src/proxiprocessor.cpp b/src/proxiprocessor.cpp
new file mode 100644 (file)
index 0000000..42b8a97
--- /dev/null
@@ -0,0 +1,120 @@
+/* Medfield sensor plugins
+ * Copyright (C) 2013 Intel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; version 2.1.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301USA
+ */
+
+#include "proxiprocessor.h"
+#include "sensor.h"
+#include "log.h"
+#include "fcntl.h"
+#include "poll.h"
+#include <vconf.h>
+#include <errno.h>
+
+const char *PROXI_CHANGED_KEY = DEFAULT_SENSOR_KEY_PREFIX"80001";
+
+ProxiProcessor::ProxiProcessor()
+{
+     DbgPrint("%p",this);
+     mName = "proxi";
+     mSupportedEvents.push_back(PROXIMITY_EVENT_CHANGE_STATE);
+     mSupportedEvents.push_back(PROXIMITY_EVENT_STATE_REPORT_ON_TIME);
+}
+
+bool ProxiProcessor::fill_values(unsigned int type, int &count,
+                                 data_unit_idx_t &unit, data_accuracy &accuracy)
+{
+     DbgPrint("%u",type);
+
+
+     switch (type) {
+     case PROXIMITY_BASE_DATA_SET:
+          count = 1;
+          accuracy = ACCURACY_GOOD;
+          unit = IDX_UNIT_STATE_ON_OFF;
+          return true;
+     }
+
+     return false;
+}
+
+int ProxiProcessor::get_property(unsigned int property_level,
+                                 base_property_struct &result)
+{
+     strcpy(result.sensor_name,"ltr502");
+     strcpy(result.sensor_vendor, "Lite-On");
+
+     if (property_level == PROXIMITY_BASE_DATA_SET) {
+          result.sensor_unit_idx = IDX_UNIT_STATE_ON_OFF;
+          result.sensor_min_range = 0;
+          result.sensor_max_range = 1;
+          result.sensor_resolution = 6;
+     } else {
+          return -1;
+     }
+
+     return 0;
+}
+
+bool ProxiProcessor::enable()
+{
+     DbgPrint("");
+     if (mFd <=  0) {
+          mFd = open("/dev/ltr502als_psensor", O_RDONLY);
+     }
+
+     if (mFd > 0) {
+          ioctl(mFd,0,1);
+          return true;
+     }
+     DbgPrint("Opening sensor file failed");
+
+     return false;
+}
+
+bool ProxiProcessor::disable()
+{
+     if (mFd > 0) {
+          ioctl(mFd,0,0);
+          return true;
+     }
+
+     return false;
+}
+
+void* ProxiProcessor::started()
+{
+     pollfd pollInfo;
+     pollInfo.fd = mFd;
+     pollInfo.events = POLLIN;
+     if (poll(&pollInfo,1,-1)){
+          DbgPrint("Poll completed");
+          int value;
+          int result = read(mFd,&value,sizeof(int));
+          if (result > 0) {
+            mValueMutex.lock();
+            mValues[0] = value != 0 ? 1 : 0;
+            mValueMutex.unlock();
+            vconf_set_int(PROXI_CHANGED_KEY,value);
+
+            DbgPrint("Readed value %d",value);
+          }
+          else {
+              DbgPrint("File read error %d",errno);
+          }
+     }
+
+     return (void *) cworker::STARTED;
+}
diff --git a/src/test_programs/CMakeLists.txt b/src/test_programs/CMakeLists.txt
new file mode 100644 (file)
index 0000000..ed99d70
--- /dev/null
@@ -0,0 +1,35 @@
+cmake_minimum_required(VERSION 2.6)
+project(sensors_testers CXX)
+
+# to install pkgconfig setup file.
+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 "0")
+set(PROJECT_RELEASE_VERSION "1")
+
+include(FindPkgConfig)
+pkg_check_modules(rpkgs REQUIRED sf_common sensor libudev vconf)
+add_definitions(${rpkgs_CFLAGS})
+
+ADD_EXECUTABLE(reader reader.cpp
+
+../accel_module.cpp
+../accelprocessor.cpp
+../baseprocessor.cpp
+../compassprocessor.cpp
+../gyroprocessor.cpp
+../lightprocessor.cpp
+../ms5607processors.cpp
+../proxiprocessor.cpp
+)
+target_link_libraries(reader ${rpkgs_LDFLAGS})
+
+pkg_check_modules(cpkgs REQUIRED sf_common sensor vconf)
+ADD_EXECUTABLE(client client.cpp)
+
+target_link_libraries(client ${cpkgs_LDFLAGS})
+
diff --git a/src/test_programs/client.cpp b/src/test_programs/client.cpp
new file mode 100644 (file)
index 0000000..e95ec4e
--- /dev/null
@@ -0,0 +1,150 @@
+/* Medfield sensor plugins
+ * Copyright (C) 2013 Intel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; version 2.1.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301USA
+ */
+
+#include <sensor.h>
+#include <sensor_accel.h>
+#include <sensor_light.h>
+#include <sensor_geomag.h>
+
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <glib.h>
+
+
+#define LOGERR(fmt,args...) fprintf(stderr,fmt "\n",##args)
+#define LOGENTRY(format,args...) LOGERR("%s " format,__func__,##args)
+
+static int sf_handle;
+
+static void sensor_callback(unsigned int type, sensor_event_data_t *event, void *data)
+{
+     LOGENTRY("");
+     if (type == ACCELEROMETER_EVENT_ROTATION_CHECK) {
+          LOGERR("ACCELEROMETER_EVENT_ROTATION_CHECK");
+          int  cb_event_data = (*(int *)(event->event_data));
+          if (cb_event_data == ROTATION_LANDSCAPE_LEFT )
+               LOGERR("ROTATION_LANDSCAPE_LEFT\n");
+          else if (cb_event_data == ROTATION_LANDSCAPE_RIGHT)
+               LOGERR("ROTATION_LANDSCAPE_RIGHT\n");
+          else if (cb_event_data == ROTATION_PORTRAIT_TOP )
+               LOGERR("ROTATION_PORTRAIT_TOP\n");
+          else if (cb_event_data == ROTATION_PORTRAIT_BTM )
+               LOGERR("ROTATION_PORTRAIT_BTM\n");
+     }
+
+     else if (type == LIGHT_EVENT_CHANGE_LEVEL ) {
+          int  cb_event_data = (*(int *)(event->event_data));
+          LOGERR("LIGHT_EVENT_CHANGE_LEVEL %d",cb_event_data);
+     }
+
+     else if (type == PROXIMITY_EVENT_CHANGE_STATE) {
+          int  cb_event_data = (*(int *)(event->event_data));
+          LOGERR("PROXIMITY_EVENT_CHANGE_STATE %d",cb_event_data);
+     }
+     else {
+          sensor_data_t data;
+          memcpy(&data,event->event_data,event->event_data_size);
+          for (int i = 0; i < data.values_num; i++)
+               LOGERR("%d: %f",i,data.values[i]);
+     }
+
+
+}
+
+static int connect_sfsvc(sensor_type_t sensor, int data_event, int report_event)
+{
+     int sf_state = -1;
+     int err = 0;
+
+     LOGERR("Here");
+     sensor_properties_t props;
+     sf_get_properties(sensor, &props);
+     LOGERR("Sensor name: %s", props.sensor_name);
+
+     sensor_data_t data;
+     //memset(&data,0,sizeof(data));
+
+     /* connect with sensor fw */
+     LOGERR("connect with sensor fw");
+     sf_handle = sf_connect(sensor);
+     if (sf_handle < 0) {
+          LOGERR("sensor attach fail");
+          return -1;
+     }
+     sf_state = sf_start(sf_handle, 0);
+     if (sf_state < 0) {
+          LOGERR("sensor attach fail");
+          sf_disconnect(sf_handle);
+          sf_handle = -1;
+          return -2;
+     }
+     err =  sf_start(sf_handle, 0);
+     sleep(1);
+     if (err == 0) {
+          err = sf_get_data(sf_handle,data_event, &data);
+          if (err == 0) {
+               LOGERR("sf_get_data values:", data.values[0]);
+               for (int i =0; i <data.values_num; i++)
+                    LOGERR("%d: %f\n",i, data.values[i]);
+               LOGERR("Values end");
+               err = sf_register_event(sf_handle,report_event,NULL,sensor_callback,NULL);
+               if (err)
+                    LOGERR("Error registering for event %d",err);
+          } else {
+               LOGERR("sf_get_data value fail", err);
+          }
+     } else {
+          LOGERR("sf_start failed %d", err);
+     }
+
+
+     return 0;
+}
+
+int main(int argc, char **argv)
+{
+     GMainLoop *mainloop;
+     const char *errormsg = "Give sensor to listen (accel, light, proxi, compass, gyro)";
+     mainloop = g_main_loop_new (NULL, FALSE);
+     if (argc == 1) {
+          LOGERR("%s",errormsg);
+          return 1;
+     }
+
+     if (strcmp(argv[1],"accel") == 0) {
+          connect_sfsvc(ACCELEROMETER_SENSOR, ACCELEROMETER_BASE_DATA_SET, ACCELEROMETER_EVENT_ROTATION_CHECK );
+     }
+
+     else if (strcmp(argv[1],"light") ==  0)
+          connect_sfsvc(LIGHT_SENSOR, LIGHT_BASE_DATA_SET,LIGHT_EVENT_CHANGE_LEVEL );
+     else if (strcmp(argv[1],"proxi") ==  0)
+          connect_sfsvc(PROXIMITY_SENSOR, PROXIMITY_BASE_DATA_SET,PROXIMITY_EVENT_CHANGE_STATE );
+     else if (strcmp(argv[1],"compass") ==  0)
+          connect_sfsvc(GEOMAGNETIC_SENSOR, GEOMAGNETIC_RAW_DATA_SET,GEOMAGNETIC_EVENT_RAW_DATA_REPORT_ON_TIME );
+     else if (strcmp(argv[1],"gyro") ==  0)
+          connect_sfsvc(GYROSCOPE_SENSOR, GYRO_BASE_DATA_SET,GYROSCOPE_EVENT_RAW_DATA_REPORT_ON_TIME );
+     else {
+          LOGERR("%s",errormsg);
+          return 1;
+     }
+
+     g_main_loop_run(mainloop);
+     int err = sf_disconnect(sf_handle);
+     LOGERR("Disconnect error %d",err);
+     g_main_loop_unref(mainloop);
+}
diff --git a/src/test_programs/reader.cpp b/src/test_programs/reader.cpp
new file mode 100644 (file)
index 0000000..b0ebf1d
--- /dev/null
@@ -0,0 +1,91 @@
+/* Medfield sensor plugins
+ * Copyright (C) 2013 Intel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; version 2.1.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301USA
+ */
+
+#include "lightprocessor.h"
+#include "compassprocessor.h"
+#include "proxiprocessor.h"
+#include "accelprocessor.h"
+#include "gyroprocessor.h"
+#include "ms5607processors.h"
+#include <stdlib.h>
+#include <iostream>
+#include <string>
+
+using namespace std;
+
+int main(int argc, char **argv)
+{
+     BaseProcessor *processor = 0;
+     int event = 0;
+
+     if (argc > 1) {
+          string name = argv[1];
+          if (name == "compass") {
+               processor = new CompassProcessor();
+               event = GEOMAGNETIC_RAW_DATA_SET;
+          } else if (name == "light") {
+               processor = new LightProcessor();
+               event = LIGHT_BASE_DATA_SET;
+          }
+
+          else if (name == "proxi") {
+               processor = new ProxiProcessor();
+               event = PROXIMITY_BASE_DATA_SET;
+          }
+
+          else if (name == "accel") {
+               processor = new AccelProcessor();
+               event = ACCELEROMETER_BASE_DATA_SET;
+          }
+
+          else if (name == "gyro") {
+               processor = new GyroProcessor();
+               event = GYRO_BASE_DATA_SET;
+          } else if (name == "pressure") {
+               processor = new PressureProcessor();
+               event = PRESSURE_BASE_DATA_SET;
+          } else if (name == "temperature") {
+               processor = new TemperatureProcessor();
+               event = PRESSURE_BASE_DATA_SET;
+          }
+     }
+
+     if (!processor) {
+          cout <<"Give processor name: compass, light, proxi, accel,"
+               <<"gyro, pressure, temperature";
+          return 1;
+     }
+
+     processor->enable();
+
+     int i = 0;
+     while (true) {
+          //std::cerr <<"Going to read" <<processor;
+          BaseProcessor::started(processor);
+          //std::cerr <<"Return from read\n";
+          sleep(0.1);
+          base_data_struct result;
+
+          processor->get_struct_value(event,&result);
+          cerr <<"Values from sensor:  \n";
+          for (int i =0; i <result.values_num; i++)
+               cerr <<i <<":" <<result.values[i] <<"\n";
+          cerr <<"Values end\n";
+          //break;
+
+     }
+}
diff --git a/src/test_programs/readme.txt b/src/test_programs/readme.txt
new file mode 100644 (file)
index 0000000..5b1bfff
--- /dev/null
@@ -0,0 +1,9 @@
+These are example applications which can be used to
+check sensor values.
+
+Reader program uses directly sensor processor sources
+to retrieve values.
+
+Client program uses sensor framework to values.
+
+Both programs takes as a argument name of sensor.