An extension of original API for working with GPS devices.
Dependents: A_TeseoLocationNEW A_TeseoLocation TeseoLocation
GPS_Provider Library
A controller-neutral API for working with GPS devices.
Overview
This library is an extension of the original API published on os.mbed.com
Besides the basic geo-location functionality, this extended API includes the following features:
- Geofencing
- Odometer
- Datalogging
Getting started
This GPS API is meant to be used for building projects on os.mbed.com
A good starting point is this page:
GPSProvider/GPSGeofence.h@3:ccd86d6bd3bc, 2019-02-14 (annotated)
- Committer:
- apalmieri
- Date:
- Thu Feb 14 11:07:42 2019 +0000
- Revision:
- 3:ccd86d6bd3bc
- Parent:
- 0:0a9c622571d7
Updates API comments and .json file
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
apalmieri | 0:0a9c622571d7 | 1 | /** |
apalmieri | 0:0a9c622571d7 | 2 | ****************************************************************************** |
apalmieri | 0:0a9c622571d7 | 3 | * @file GPSGeofence.h |
apalmieri | 0:0a9c622571d7 | 4 | * @author AST/CL |
apalmieri | 0:0a9c622571d7 | 5 | * @version V1.1.0 |
apalmieri | 0:0a9c622571d7 | 6 | * @date Jun, 2017 |
apalmieri | 0:0a9c622571d7 | 7 | * @brief . |
apalmieri | 0:0a9c622571d7 | 8 | ****************************************************************************** |
apalmieri | 0:0a9c622571d7 | 9 | * @attention |
apalmieri | 0:0a9c622571d7 | 10 | * |
apalmieri | 0:0a9c622571d7 | 11 | * <h2><center>© COPYRIGHT(c) 2017 STMicroelectronics</center></h2> |
apalmieri | 0:0a9c622571d7 | 12 | * |
apalmieri | 0:0a9c622571d7 | 13 | * Redistribution and use in source and binary forms, with or without modification, |
apalmieri | 0:0a9c622571d7 | 14 | * are permitted provided that the following conditions are met: |
apalmieri | 0:0a9c622571d7 | 15 | * 1. Redistributions of source code must retain the above copyright notice, |
apalmieri | 0:0a9c622571d7 | 16 | * this list of conditions and the following disclaimer. |
apalmieri | 0:0a9c622571d7 | 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
apalmieri | 0:0a9c622571d7 | 18 | * this list of conditions and the following disclaimer in the documentation |
apalmieri | 0:0a9c622571d7 | 19 | * and/or other materials provided with the distribution. |
apalmieri | 0:0a9c622571d7 | 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
apalmieri | 0:0a9c622571d7 | 21 | * may be used to endorse or promote products derived from this software |
apalmieri | 0:0a9c622571d7 | 22 | * without specific prior written permission. |
apalmieri | 0:0a9c622571d7 | 23 | * |
apalmieri | 0:0a9c622571d7 | 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
apalmieri | 0:0a9c622571d7 | 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
apalmieri | 0:0a9c622571d7 | 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
apalmieri | 0:0a9c622571d7 | 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
apalmieri | 0:0a9c622571d7 | 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
apalmieri | 0:0a9c622571d7 | 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
apalmieri | 0:0a9c622571d7 | 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
apalmieri | 0:0a9c622571d7 | 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
apalmieri | 0:0a9c622571d7 | 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
apalmieri | 0:0a9c622571d7 | 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
apalmieri | 0:0a9c622571d7 | 34 | * |
apalmieri | 0:0a9c622571d7 | 35 | ****************************************************************************** |
apalmieri | 0:0a9c622571d7 | 36 | */ |
apalmieri | 0:0a9c622571d7 | 37 | |
apalmieri | 0:0a9c622571d7 | 38 | #ifndef __GPS_GEOFENCE_H__ |
apalmieri | 0:0a9c622571d7 | 39 | #define __GPS_GEOFENCE_H__ |
apalmieri | 0:0a9c622571d7 | 40 | |
apalmieri | 3:ccd86d6bd3bc | 41 | /** |
apalmieri | 3:ccd86d6bd3bc | 42 | * For more information about Geofence, please refer to |
apalmieri | 3:ccd86d6bd3bc | 43 | * Teseo LIV-3F UM available at st.com |
apalmieri | 3:ccd86d6bd3bc | 44 | */ |
apalmieri | 3:ccd86d6bd3bc | 45 | |
apalmieri | 0:0a9c622571d7 | 46 | class GPSGeofence { |
apalmieri | 0:0a9c622571d7 | 47 | public: |
apalmieri | 0:0a9c622571d7 | 48 | |
apalmieri | 0:0a9c622571d7 | 49 | static const int NEVER_EXPIRE = -1; |
apalmieri | 0:0a9c622571d7 | 50 | |
apalmieri | 0:0a9c622571d7 | 51 | struct GeofenceCircle_t { |
apalmieri | 0:0a9c622571d7 | 52 | int id; |
apalmieri | 0:0a9c622571d7 | 53 | bool enabled; |
apalmieri | 0:0a9c622571d7 | 54 | int tolerance; |
apalmieri | 0:0a9c622571d7 | 55 | GPSProvider::LocationType_t lat; |
apalmieri | 0:0a9c622571d7 | 56 | GPSProvider::LocationType_t lon; |
apalmieri | 0:0a9c622571d7 | 57 | GPSProvider::LocationType_t radius; |
apalmieri | 0:0a9c622571d7 | 58 | int status; |
apalmieri | 0:0a9c622571d7 | 59 | }; |
apalmieri | 0:0a9c622571d7 | 60 | |
apalmieri | 0:0a9c622571d7 | 61 | /** |
apalmieri | 0:0a9c622571d7 | 62 | * Construct a GPSGeofence instance. |
apalmieri | 0:0a9c622571d7 | 63 | */ |
apalmieri | 0:0a9c622571d7 | 64 | GPSGeofence() : |
apalmieri | 0:0a9c622571d7 | 65 | _expirationDuration(-1), |
apalmieri | 0:0a9c622571d7 | 66 | _notificationResponsiveness(0), |
apalmieri | 0:0a9c622571d7 | 67 | _transitionTypes(0) { |
apalmieri | 0:0a9c622571d7 | 68 | } |
apalmieri | 0:0a9c622571d7 | 69 | |
apalmieri | 0:0a9c622571d7 | 70 | /** |
apalmieri | 0:0a9c622571d7 | 71 | * Construct a GPSGeofence instance. |
apalmieri | 0:0a9c622571d7 | 72 | */ |
apalmieri | 0:0a9c622571d7 | 73 | GPSGeofence(const GeofenceCircle_t &geofenceCircle) : |
apalmieri | 0:0a9c622571d7 | 74 | _geofenceCircle(geofenceCircle), |
apalmieri | 0:0a9c622571d7 | 75 | _expirationDuration(-1), |
apalmieri | 0:0a9c622571d7 | 76 | _notificationResponsiveness(0), |
apalmieri | 0:0a9c622571d7 | 77 | _transitionTypes(0) { |
apalmieri | 0:0a9c622571d7 | 78 | } |
apalmieri | 3:ccd86d6bd3bc | 79 | |
apalmieri | 3:ccd86d6bd3bc | 80 | /** |
apalmieri | 3:ccd86d6bd3bc | 81 | * Set the Geofence area. |
apalmieri | 3:ccd86d6bd3bc | 82 | */ |
apalmieri | 0:0a9c622571d7 | 83 | void setGeofenceCircle(const GeofenceCircle_t &geofenceCircle) { |
apalmieri | 0:0a9c622571d7 | 84 | _geofenceCircle.id = geofenceCircle.id; |
apalmieri | 0:0a9c622571d7 | 85 | _geofenceCircle.enabled = geofenceCircle.enabled; |
apalmieri | 0:0a9c622571d7 | 86 | _geofenceCircle.tolerance = geofenceCircle.tolerance; |
apalmieri | 0:0a9c622571d7 | 87 | _geofenceCircle.lat = geofenceCircle.lat; |
apalmieri | 0:0a9c622571d7 | 88 | _geofenceCircle.lon = geofenceCircle.lon; |
apalmieri | 0:0a9c622571d7 | 89 | _geofenceCircle.radius = geofenceCircle.radius; |
apalmieri | 0:0a9c622571d7 | 90 | _geofenceCircle.status = 0; |
apalmieri | 0:0a9c622571d7 | 91 | } |
apalmieri | 3:ccd86d6bd3bc | 92 | |
apalmieri | 3:ccd86d6bd3bc | 93 | /** |
apalmieri | 3:ccd86d6bd3bc | 94 | * Update the status of a Geofence area. |
apalmieri | 3:ccd86d6bd3bc | 95 | * Status can be one of the following: |
apalmieri | 3:ccd86d6bd3bc | 96 | * - Inside |
apalmieri | 3:ccd86d6bd3bc | 97 | * - Outside |
apalmieri | 3:ccd86d6bd3bc | 98 | * - Boundary |
apalmieri | 3:ccd86d6bd3bc | 99 | * - Unknown |
apalmieri | 3:ccd86d6bd3bc | 100 | */ |
apalmieri | 0:0a9c622571d7 | 101 | void updateGeofenceCircleStatus(int status) { |
apalmieri | 0:0a9c622571d7 | 102 | _geofenceCircle.status = status; |
apalmieri | 0:0a9c622571d7 | 103 | } |
apalmieri | 3:ccd86d6bd3bc | 104 | |
apalmieri | 3:ccd86d6bd3bc | 105 | /** |
apalmieri | 3:ccd86d6bd3bc | 106 | * Get the Geofence area. |
apalmieri | 3:ccd86d6bd3bc | 107 | */ |
apalmieri | 0:0a9c622571d7 | 108 | const GeofenceCircle_t & getGeofenceCircle(void) { |
apalmieri | 0:0a9c622571d7 | 109 | return _geofenceCircle; |
apalmieri | 0:0a9c622571d7 | 110 | } |
apalmieri | 3:ccd86d6bd3bc | 111 | |
apalmieri | 3:ccd86d6bd3bc | 112 | /** |
apalmieri | 3:ccd86d6bd3bc | 113 | * Set the expiration duration of geofence. |
apalmieri | 3:ccd86d6bd3bc | 114 | */ |
apalmieri | 0:0a9c622571d7 | 115 | virtual void setExpirationDuration (long durationMillis) { |
apalmieri | 0:0a9c622571d7 | 116 | _expirationDuration = durationMillis; |
apalmieri | 0:0a9c622571d7 | 117 | } |
apalmieri | 3:ccd86d6bd3bc | 118 | |
apalmieri | 3:ccd86d6bd3bc | 119 | /** |
apalmieri | 3:ccd86d6bd3bc | 120 | * Set the best-effort notification responsiveness of the geofence. |
apalmieri | 3:ccd86d6bd3bc | 121 | */ |
apalmieri | 0:0a9c622571d7 | 122 | virtual void setNotificationResponsiveness (int notificationResponsivenessMs) { |
apalmieri | 0:0a9c622571d7 | 123 | _notificationResponsiveness = notificationResponsivenessMs; |
apalmieri | 0:0a9c622571d7 | 124 | } |
apalmieri | 3:ccd86d6bd3bc | 125 | |
apalmieri | 3:ccd86d6bd3bc | 126 | /** |
apalmieri | 3:ccd86d6bd3bc | 127 | * Set the transition types of interest. |
apalmieri | 3:ccd86d6bd3bc | 128 | */ |
apalmieri | 0:0a9c622571d7 | 129 | virtual void setTransitionTypes(int transitionTypes) { |
apalmieri | 0:0a9c622571d7 | 130 | _transitionTypes = transitionTypes; |
apalmieri | 0:0a9c622571d7 | 131 | } |
apalmieri | 0:0a9c622571d7 | 132 | |
apalmieri | 0:0a9c622571d7 | 133 | protected: |
apalmieri | 0:0a9c622571d7 | 134 | GeofenceCircle_t _geofenceCircle; |
apalmieri | 0:0a9c622571d7 | 135 | long _expirationDuration; |
apalmieri | 0:0a9c622571d7 | 136 | int _notificationResponsiveness; |
apalmieri | 0:0a9c622571d7 | 137 | int _transitionTypes; |
apalmieri | 0:0a9c622571d7 | 138 | |
apalmieri | 0:0a9c622571d7 | 139 | private: |
apalmieri | 0:0a9c622571d7 | 140 | /* disallow copy constructor and assignment operators */ |
apalmieri | 0:0a9c622571d7 | 141 | GPSGeofence(const GPSGeofence&); |
apalmieri | 0:0a9c622571d7 | 142 | GPSGeofence & operator= (const GPSGeofence&); |
apalmieri | 0:0a9c622571d7 | 143 | }; |
apalmieri | 0:0a9c622571d7 | 144 | |
apalmieri | 0:0a9c622571d7 | 145 | #endif /* __GPS_GEOFENCE_H__ */ |