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