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