Home | History | Annotate | Download | only in libloc_api
      1 /******************************************************************************
      2   @file:  loc_eng.h
      3   @brief:
      4 
      5   DESCRIPTION
      6     This file defines the global data structure used by this module.
      7 
      8   INITIALIZATION AND SEQUENCING REQUIREMENTS
      9 
     10   -----------------------------------------------------------------------------
     11 Copyright (c) 2009, QUALCOMM USA, INC.
     12 
     13 All rights reserved.
     14 
     15 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
     16 
     17          Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
     18 
     19          Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
     20 
     21          Neither the name of the QUALCOMM USA, INC.  nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
     22 
     23 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     24   -----------------------------------------------------------------------------
     25 
     26 ******************************************************************************/
     27 
     28 /*=====================================================================
     29 $Header: $
     30 $DateTime: $
     31 $Author: $
     32 ======================================================================*/
     33 
     34 #ifndef LOC_ENG_H
     35 #define LOC_ENG_H
     36 
     37 // Define boolean type to be used by libgps on loc api module
     38 typedef unsigned char boolean;
     39 
     40 #ifndef TRUE
     41 #define TRUE 1
     42 #endif
     43 
     44 #ifndef FALSE
     45 #define FALSE 0
     46 #endif
     47 
     48 #include <loc_eng_ioctl.h>
     49 #include <loc_eng_xtra.h>
     50 #include <hardware/gps.h>
     51 
     52 #define LOC_IOCTL_DEFAULT_TIMEOUT 1000 // 1000 milli-seconds
     53 
     54 enum {
     55     DEFERRED_ACTION_EVENT               = 0x01,
     56     DEFERRED_ACTION_DELETE_AIDING       = 0x02,
     57     DEFERRED_ACTION_AGPS_STATUS         = 0x04,
     58     DEFERRED_ACTION_AGPS_DATA_SUCCESS   = 0x08,
     59     DEFERRED_ACTION_AGPS_DATA_CLOSED    = 0x10,
     60     DEFERRED_ACTION_AGPS_DATA_FAILED    = 0x20,
     61     DEFERRED_ACTION_QUIT                = 0x40,
     62 };
     63 
     64 // Module data
     65 typedef struct
     66 {
     67     rpc_loc_client_handle_type  client_handle;
     68 
     69     gps_location_callback           location_cb;
     70     gps_status_callback             status_cb;
     71     gps_sv_status_callback          sv_status_cb;
     72     agps_status_callback            agps_status_cb;
     73     gps_nmea_callback               nmea_cb;
     74     gps_ni_notify_callback          ni_notify_cb;
     75     gps_acquire_wakelock            acquire_wakelock_cb;
     76     gps_release_wakelock            release_wakelock_cb;
     77     int                             agps_status;
     78 
     79     // used to defer stopping the GPS engine until AGPS data calls are done
     80     boolean                         agps_request_pending;
     81     boolean                         stop_request_pending;
     82     pthread_mutex_t                 deferred_stop_mutex;
     83 
     84     loc_eng_xtra_data_s_type        xtra_module_data;
     85 
     86     loc_eng_ioctl_data_s_type       ioctl_data;
     87 
     88     // data from loc_event_cb
     89     rpc_loc_event_mask_type         loc_event;
     90     rpc_loc_event_payload_u_type    loc_event_payload;
     91 
     92     // TBD:
     93     char                            agps_server_host[256];
     94     int                             agps_server_port;
     95     uint32                          agps_server_address;
     96     char                            apn_name[100];
     97     int                             position_mode;
     98     rpc_loc_server_connection_handle  conn_handle;
     99 
    100     // GPS engine status
    101     GpsStatusValue                  engine_status;
    102 
    103     // Aiding data information to be deleted, aiding data can only be deleted when GPS engine is off
    104     GpsAidingData                   aiding_data_for_deletion;
    105 
    106     // Data variables used by deferred action thread
    107     pthread_t                       deferred_action_thread;
    108     // Mutex used by deferred action thread
    109     pthread_mutex_t                 deferred_action_mutex;
    110     // Condition variable used by deferred action thread
    111     pthread_cond_t                  deferred_action_cond;
    112 
    113     // flags for pending events for deferred action thread
    114     int                             deferred_action_flags;
    115 } loc_eng_data_s_type;
    116 
    117 extern loc_eng_data_s_type loc_eng_data;
    118 
    119 #endif // LOC_ENG_H
    120