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@0:0a9c622571d7, 2018-11-09 (annotated)
- Committer:
- apalmieri
- Date:
- Fri Nov 09 17:09:12 2018 +0000
- Revision:
- 0:0a9c622571d7
- Child:
- 3:ccd86d6bd3bc
Initial commit
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 | 0:0a9c622571d7 | 41 | class GPSGeofence { |
apalmieri | 0:0a9c622571d7 | 42 | public: |
apalmieri | 0:0a9c622571d7 | 43 | |
apalmieri | 0:0a9c622571d7 | 44 | static const int NEVER_EXPIRE = -1; |
apalmieri | 0:0a9c622571d7 | 45 | |
apalmieri | 0:0a9c622571d7 | 46 | struct GeofenceCircle_t { |
apalmieri | 0:0a9c622571d7 | 47 | int id; |
apalmieri | 0:0a9c622571d7 | 48 | bool enabled; |
apalmieri | 0:0a9c622571d7 | 49 | int tolerance; |
apalmieri | 0:0a9c622571d7 | 50 | GPSProvider::LocationType_t lat; |
apalmieri | 0:0a9c622571d7 | 51 | GPSProvider::LocationType_t lon; |
apalmieri | 0:0a9c622571d7 | 52 | GPSProvider::LocationType_t radius; |
apalmieri | 0:0a9c622571d7 | 53 | int status; |
apalmieri | 0:0a9c622571d7 | 54 | }; |
apalmieri | 0:0a9c622571d7 | 55 | |
apalmieri | 0:0a9c622571d7 | 56 | /** |
apalmieri | 0:0a9c622571d7 | 57 | * Construct a GPSGeofence instance. |
apalmieri | 0:0a9c622571d7 | 58 | */ |
apalmieri | 0:0a9c622571d7 | 59 | GPSGeofence() : |
apalmieri | 0:0a9c622571d7 | 60 | _expirationDuration(-1), |
apalmieri | 0:0a9c622571d7 | 61 | _notificationResponsiveness(0), |
apalmieri | 0:0a9c622571d7 | 62 | _transitionTypes(0) { |
apalmieri | 0:0a9c622571d7 | 63 | } |
apalmieri | 0:0a9c622571d7 | 64 | |
apalmieri | 0:0a9c622571d7 | 65 | /** |
apalmieri | 0:0a9c622571d7 | 66 | * Construct a GPSGeofence instance. |
apalmieri | 0:0a9c622571d7 | 67 | */ |
apalmieri | 0:0a9c622571d7 | 68 | GPSGeofence(const GeofenceCircle_t &geofenceCircle) : |
apalmieri | 0:0a9c622571d7 | 69 | _geofenceCircle(geofenceCircle), |
apalmieri | 0:0a9c622571d7 | 70 | _expirationDuration(-1), |
apalmieri | 0:0a9c622571d7 | 71 | _notificationResponsiveness(0), |
apalmieri | 0:0a9c622571d7 | 72 | _transitionTypes(0) { |
apalmieri | 0:0a9c622571d7 | 73 | } |
apalmieri | 0:0a9c622571d7 | 74 | |
apalmieri | 0:0a9c622571d7 | 75 | void setGeofenceCircle(const GeofenceCircle_t &geofenceCircle) { |
apalmieri | 0:0a9c622571d7 | 76 | _geofenceCircle.id = geofenceCircle.id; |
apalmieri | 0:0a9c622571d7 | 77 | _geofenceCircle.enabled = geofenceCircle.enabled; |
apalmieri | 0:0a9c622571d7 | 78 | _geofenceCircle.tolerance = geofenceCircle.tolerance; |
apalmieri | 0:0a9c622571d7 | 79 | _geofenceCircle.lat = geofenceCircle.lat; |
apalmieri | 0:0a9c622571d7 | 80 | _geofenceCircle.lon = geofenceCircle.lon; |
apalmieri | 0:0a9c622571d7 | 81 | _geofenceCircle.radius = geofenceCircle.radius; |
apalmieri | 0:0a9c622571d7 | 82 | _geofenceCircle.status = 0; |
apalmieri | 0:0a9c622571d7 | 83 | } |
apalmieri | 0:0a9c622571d7 | 84 | |
apalmieri | 0:0a9c622571d7 | 85 | void updateGeofenceCircleStatus(int status) { |
apalmieri | 0:0a9c622571d7 | 86 | _geofenceCircle.status = status; |
apalmieri | 0:0a9c622571d7 | 87 | } |
apalmieri | 0:0a9c622571d7 | 88 | |
apalmieri | 0:0a9c622571d7 | 89 | const GeofenceCircle_t & getGeofenceCircle(void) { |
apalmieri | 0:0a9c622571d7 | 90 | return _geofenceCircle; |
apalmieri | 0:0a9c622571d7 | 91 | } |
apalmieri | 0:0a9c622571d7 | 92 | |
apalmieri | 0:0a9c622571d7 | 93 | virtual void setExpirationDuration (long durationMillis) { |
apalmieri | 0:0a9c622571d7 | 94 | _expirationDuration = durationMillis; |
apalmieri | 0:0a9c622571d7 | 95 | } |
apalmieri | 0:0a9c622571d7 | 96 | |
apalmieri | 0:0a9c622571d7 | 97 | virtual void setNotificationResponsiveness (int notificationResponsivenessMs) { |
apalmieri | 0:0a9c622571d7 | 98 | _notificationResponsiveness = notificationResponsivenessMs; |
apalmieri | 0:0a9c622571d7 | 99 | } |
apalmieri | 0:0a9c622571d7 | 100 | |
apalmieri | 0:0a9c622571d7 | 101 | virtual void setTransitionTypes(int transitionTypes) { |
apalmieri | 0:0a9c622571d7 | 102 | _transitionTypes = transitionTypes; |
apalmieri | 0:0a9c622571d7 | 103 | } |
apalmieri | 0:0a9c622571d7 | 104 | |
apalmieri | 0:0a9c622571d7 | 105 | protected: |
apalmieri | 0:0a9c622571d7 | 106 | GeofenceCircle_t _geofenceCircle; |
apalmieri | 0:0a9c622571d7 | 107 | long _expirationDuration; |
apalmieri | 0:0a9c622571d7 | 108 | int _notificationResponsiveness; |
apalmieri | 0:0a9c622571d7 | 109 | int _transitionTypes; |
apalmieri | 0:0a9c622571d7 | 110 | |
apalmieri | 0:0a9c622571d7 | 111 | private: |
apalmieri | 0:0a9c622571d7 | 112 | /* disallow copy constructor and assignment operators */ |
apalmieri | 0:0a9c622571d7 | 113 | GPSGeofence(const GPSGeofence&); |
apalmieri | 0:0a9c622571d7 | 114 | GPSGeofence & operator= (const GPSGeofence&); |
apalmieri | 0:0a9c622571d7 | 115 | }; |
apalmieri | 0:0a9c622571d7 | 116 | |
apalmieri | 0:0a9c622571d7 | 117 | #endif /* __GPS_GEOFENCE_H__ */ |