1ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo/* Copyright (c) 2013, The Linux Foundation. All rights reserved. 2ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * 3ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * Redistribution and use in source and binary forms, with or without 4ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * modification, are permitted provided that the following conditions are 5ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * met: 6ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * * Redistributions of source code must retain the above copyright 7ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * notice, this list of conditions and the following disclaimer. 8ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * * Redistributions in binary form must reproduce the above 9ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * copyright notice, this list of conditions and the following 10ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * disclaimer in the documentation and/or other materials provided 11ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * with the distribution. 12ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * * Neither the name of The Linux Foundation nor the names of its 13ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * contributors may be used to endorse or promote products derived 14ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * from this software without specific prior written permission. 15ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * 16ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo */ 28ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo 29ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#ifndef GPS_EXTENDED_H 30ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define GPS_EXTENDED_H 31ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo 32ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#ifdef __cplusplus 33ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russoextern "C" { 34ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#endif /* __cplusplus */ 35ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo 36ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#include <gps_extended_c.h> 37ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo 38ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russostruct LocPosMode 39ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo{ 40ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo LocPositionMode mode; 41ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo GpsPositionRecurrence recurrence; 42ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo uint32_t min_interval; 43ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo uint32_t preferred_accuracy; 44ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo uint32_t preferred_time; 45ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo char credentials[14]; 46ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo char provider[8]; 47ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo LocPosMode(LocPositionMode m, GpsPositionRecurrence recr, 48ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo uint32_t gap, uint32_t accu, uint32_t time, 49ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo const char* cred, const char* prov) : 50ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo mode(m), recurrence(recr), 51ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo min_interval(gap < MIN_POSSIBLE_FIX_INTERVAL ? MIN_POSSIBLE_FIX_INTERVAL : gap), 52ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo preferred_accuracy(accu), preferred_time(time) { 53ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo memset(credentials, 0, sizeof(credentials)); 54ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo memset(provider, 0, sizeof(provider)); 55ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo if (NULL != cred) { 56ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo memcpy(credentials, cred, sizeof(credentials)-1); 57ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo } 58ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo if (NULL != prov) { 59ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo memcpy(provider, prov, sizeof(provider)-1); 60ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo } 61ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo } 62ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo 63ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo inline LocPosMode() : 64ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo mode(LOC_POSITION_MODE_MS_BASED), 65ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo recurrence(GPS_POSITION_RECURRENCE_PERIODIC), 66ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo min_interval(MIN_POSSIBLE_FIX_INTERVAL), 67ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo preferred_accuracy(50), preferred_time(120000) { 68ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo memset(credentials, 0, sizeof(credentials)); 69ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo memset(provider, 0, sizeof(provider)); 70ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo } 71ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo 72ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo inline bool equals(const LocPosMode &anotherMode) const 73ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo { 74ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo return anotherMode.mode == mode && 75ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo anotherMode.recurrence == recurrence && 76ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo anotherMode.min_interval == min_interval && 77ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo anotherMode.preferred_accuracy == preferred_accuracy && 78ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo anotherMode.preferred_time == preferred_time && 79ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo !strncmp(anotherMode.credentials, credentials, sizeof(credentials)-1) && 80ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo !strncmp(anotherMode.provider, provider, sizeof(provider)-1); 81ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo } 82ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo 83ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo void logv() const; 84ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo}; 85ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo 86ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo 87ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#ifdef __cplusplus 88ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo} 89ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#endif /* __cplusplus */ 90ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo 91ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#endif /* GPS_EXTENDED_H */ 92ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo 93