Home | History | Annotate | Download | only in core
      1 /* Copyright (c) 2013-2017 The Linux Foundation. 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 The Linux Foundation 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 #ifndef GPS_EXTENDED_H
     30 #define GPS_EXTENDED_H
     31 
     32 /**
     33  * @file
     34  * @brief C++ declarations for GPS types
     35  */
     36 
     37 #include <gps_extended_c.h>
     38 #if defined(USE_GLIB) || defined(OFF_TARGET)
     39 #include <string.h>
     40 #endif
     41 
     42 #ifdef __cplusplus
     43 extern "C" {
     44 #endif /* __cplusplus */
     45 
     46 
     47 
     48 struct LocPosMode
     49 {
     50     LocPositionMode mode;
     51     LocGpsPositionRecurrence recurrence;
     52     uint32_t min_interval;
     53     uint32_t preferred_accuracy;
     54     uint32_t preferred_time;
     55     bool share_position;
     56     char credentials[14];
     57     char provider[8];
     58     LocPosMode(LocPositionMode m, LocGpsPositionRecurrence recr,
     59                uint32_t gap, uint32_t accu, uint32_t time,
     60                bool sp, const char* cred, const char* prov) :
     61         mode(m), recurrence(recr),
     62         min_interval(gap < GPS_MIN_POSSIBLE_FIX_INTERVAL_MS ?
     63                      GPS_MIN_POSSIBLE_FIX_INTERVAL_MS : gap),
     64         preferred_accuracy(accu), preferred_time(time),
     65         share_position(sp) {
     66         memset(credentials, 0, sizeof(credentials));
     67         memset(provider, 0, sizeof(provider));
     68         if (NULL != cred) {
     69             memcpy(credentials, cred, sizeof(credentials)-1);
     70         }
     71         if (NULL != prov) {
     72             memcpy(provider, prov, sizeof(provider)-1);
     73         }
     74     }
     75 
     76     inline LocPosMode() :
     77         mode(LOC_POSITION_MODE_MS_BASED),
     78         recurrence(LOC_GPS_POSITION_RECURRENCE_PERIODIC),
     79         min_interval(GPS_DEFAULT_FIX_INTERVAL_MS),
     80         preferred_accuracy(50), preferred_time(120000),
     81         share_position(true) {
     82         memset(credentials, 0, sizeof(credentials));
     83         memset(provider, 0, sizeof(provider));
     84     }
     85 
     86     inline bool equals(const LocPosMode &anotherMode) const
     87     {
     88         return anotherMode.mode == mode &&
     89             anotherMode.recurrence == recurrence &&
     90             anotherMode.min_interval == min_interval &&
     91             anotherMode.preferred_accuracy == preferred_accuracy &&
     92             anotherMode.preferred_time == preferred_time &&
     93             !strncmp(anotherMode.credentials, credentials, sizeof(credentials)-1) &&
     94             !strncmp(anotherMode.provider, provider, sizeof(provider)-1);
     95     }
     96 
     97     void logv() const;
     98 };
     99 
    100 
    101 #ifdef __cplusplus
    102 }
    103 #endif /* __cplusplus */
    104 
    105 #endif /* GPS_EXTENDED_H */
    106 
    107