EngInc/rrsensorapi.h
changeset 3 93fff7023be8
equal deleted inserted replaced
2:e1e28b0273b0 3:93fff7023be8
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors: Juha Kauppinen, Mika Hokkanen
       
    13 * 
       
    14 * Description: Photo Browser
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef RRSENSORAPI_H
       
    19 #define RRSENSORAPI_H
       
    20 
       
    21 //  INCLUDES
       
    22 #include <e32std.h>
       
    23 #include <e32base.h>
       
    24 
       
    25 const TInt KMaxSensorName = 128;
       
    26 
       
    27 // CLASS DECLARATION
       
    28 
       
    29 /**
       
    30 *  TRRSensorInfo.
       
    31 *  Contains info of sensor
       
    32 *
       
    33 *  iSensorId identifies individual sensors
       
    34 *
       
    35 *  iSensorCategory can have following values:
       
    36 *  0x10010FFF for sensor server internal sensors and
       
    37 *  0x10010321 for external sensors.
       
    38 *
       
    39 *  iSensorName contains string name of sensor. This
       
    40 *  can be used e.g. to show name of sensor to user.
       
    41 *
       
    42 *  @lib rrsensorapi.lib
       
    43 */
       
    44 class TRRSensorInfo
       
    45     {
       
    46     public:
       
    47     TInt iSensorCategory;
       
    48     TInt iSensorId;
       
    49     TBuf<KMaxSensorName> iSensorName;
       
    50     };
       
    51 
       
    52 /**
       
    53 *  TRRSensorEvent
       
    54 *  Data obtained from sensor 
       
    55 *  --------------------------------------------------------------------------
       
    56 *  E.g. to sensor server internal Accelerator sensor id: 0x10273024
       
    57 *  these fields contain following information:
       
    58 *  iSensorData1 = acceleration in axis X
       
    59 *  iSensorData2 = acceleration in axis Y
       
    60 *  iSensorData3 = acceleration in axis Z
       
    61 *  --------------------------------------------------------------------------
       
    62 *  Data from external sensors may vary.
       
    63 *
       
    64 *  @lib rrsensorapi.lib
       
    65 */
       
    66 class TRRSensorEvent
       
    67     {
       
    68     public:
       
    69     TInt iSensorData1;
       
    70     TInt iSensorData2;
       
    71     TInt iSensorData3;
       
    72     };
       
    73 
       
    74 
       
    75 /**
       
    76 *  MRRSensorDataListener
       
    77 *  Callback function for receiving sensor
       
    78 *  data events
       
    79 *
       
    80 *  TRRSensorInfo identifies sensor that created the event.
       
    81 *
       
    82 *  TTRRSensorEvent contains data about created event.
       
    83 *
       
    84 *  @lib rrsensorapi.lib
       
    85 */
       
    86 class MRRSensorDataListener
       
    87     {
       
    88     public:
       
    89         virtual void HandleDataEventL( TRRSensorInfo aSensor, 
       
    90                                        TRRSensorEvent aEvent ) = 0;
       
    91     };
       
    92 
       
    93 /**
       
    94 *  CRRSensorApi
       
    95 *  User access to sensor server
       
    96 *  data events
       
    97 *  @lib rrsensorapi.lib
       
    98 */
       
    99 class CRRSensorApi : public CBase
       
   100 {
       
   101 public:
       
   102     /**
       
   103     * Create new sensor access
       
   104     * @param TRRSensorInfo identifing desired sensor.
       
   105     * @return CRRSensorApi*
       
   106     */
       
   107 	IMPORT_C static CRRSensorApi* NewL( TRRSensorInfo aSensor );
       
   108 	
       
   109     /**
       
   110     * Retrieve list of available sensors
       
   111     * @param RArray<TRRSensorInfo>& upon completion
       
   112     *        contains list of available sensors.
       
   113     * @return void
       
   114     */
       
   115     IMPORT_C static void FindSensorsL( RArray<TRRSensorInfo>& aSensorInfoArray );
       
   116 	
       
   117     /**
       
   118     * Register data listener
       
   119     * @param MRRSensorDataListener* register this pointer as sensor
       
   120     *        event listener.
       
   121     * @return void
       
   122     */
       
   123     virtual void AddDataListener( MRRSensorDataListener* aListener ) = 0;
       
   124 	
       
   125     /**
       
   126     * Remove data listener
       
   127     * @param void
       
   128     * @return void
       
   129     */
       
   130     virtual void RemoveDataListener() = 0;
       
   131 
       
   132     /**
       
   133     * Send sensor specific command.
       
   134     * This feature is intended for future use and
       
   135     * is not currently supported.
       
   136     *
       
   137     * @param TInt& aCommand identify of command.
       
   138     *        TInt& aValue desired value for command.
       
   139     * @return TInt error code
       
   140     */
       
   141 	virtual TInt SensorCommand( TInt& aCommand, TInt& aValue ) = 0;
       
   142     
       
   143 };
       
   144 
       
   145 #endif  //RRSENSORAPI_H
       
   146 
       
   147 //  End of File