An extension of original API for working with GPS devices.

Committer:
apalmieri
Date:
Mon Jun 19 13:48:56 2017 +0000
Revision:
10:013af7b8c22a
Parent:
9:708266cd594b
Typo in header comment

Who changed what in which revision?

UserRevisionLine numberNew contents of line
apalmieri 9:708266cd594b 1 /**
apalmieri 9:708266cd594b 2 ******************************************************************************
apalmieri 10:013af7b8c22a 3 * @file GPSGeofence.h
apalmieri 9:708266cd594b 4 * @author AST/CL
apalmieri 9:708266cd594b 5 * @version V1.1.0
apalmieri 9:708266cd594b 6 * @date Jun, 2017
apalmieri 9:708266cd594b 7 * @brief .
apalmieri 9:708266cd594b 8 ******************************************************************************
apalmieri 9:708266cd594b 9 * @attention
apalmieri 8:47fa213225c3 10 *
apalmieri 9:708266cd594b 11 * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
apalmieri 8:47fa213225c3 12 *
apalmieri 9:708266cd594b 13 * Redistribution and use in source and binary forms, with or without modification,
apalmieri 9:708266cd594b 14 * are permitted provided that the following conditions are met:
apalmieri 9:708266cd594b 15 * 1. Redistributions of source code must retain the above copyright notice,
apalmieri 9:708266cd594b 16 * this list of conditions and the following disclaimer.
apalmieri 9:708266cd594b 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
apalmieri 9:708266cd594b 18 * this list of conditions and the following disclaimer in the documentation
apalmieri 9:708266cd594b 19 * and/or other materials provided with the distribution.
apalmieri 9:708266cd594b 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
apalmieri 9:708266cd594b 21 * may be used to endorse or promote products derived from this software
apalmieri 9:708266cd594b 22 * without specific prior written permission.
apalmieri 8:47fa213225c3 23 *
apalmieri 9:708266cd594b 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
apalmieri 9:708266cd594b 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
apalmieri 9:708266cd594b 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
apalmieri 9:708266cd594b 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
apalmieri 9:708266cd594b 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
apalmieri 9:708266cd594b 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
apalmieri 9:708266cd594b 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
apalmieri 9:708266cd594b 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
apalmieri 9:708266cd594b 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
apalmieri 9:708266cd594b 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
apalmieri 9:708266cd594b 34 *
apalmieri 9:708266cd594b 35 ******************************************************************************
apalmieri 8:47fa213225c3 36 */
apalmieri 8:47fa213225c3 37
apalmieri 8:47fa213225c3 38 #ifndef __GPS_GEOFENCE_H__
apalmieri 8:47fa213225c3 39 #define __GPS_GEOFENCE_H__
apalmieri 8:47fa213225c3 40
apalmieri 8:47fa213225c3 41 class GPSProvider;
apalmieri 8:47fa213225c3 42
apalmieri 8:47fa213225c3 43 class GPSGeofence {
apalmieri 8:47fa213225c3 44 public:
apalmieri 8:47fa213225c3 45 enum {
apalmieri 8:47fa213225c3 46 GEOFENCE_TRANSITION_DWELL = 1,
apalmieri 8:47fa213225c3 47 GEOFENCE_TRANSITION_ENTER = 2,
apalmieri 8:47fa213225c3 48 GEOFENCE_TRANSITION_EXIT = 4,
apalmieri 8:47fa213225c3 49 };
apalmieri 8:47fa213225c3 50
apalmieri 8:47fa213225c3 51 static const int NEVER_EXPIRE = -1;
apalmieri 8:47fa213225c3 52
apalmieri 8:47fa213225c3 53 static const int GEOFENCE_ID_MAX_SIZE = 32;
apalmieri 8:47fa213225c3 54
apalmieri 8:47fa213225c3 55 /**
apalmieri 8:47fa213225c3 56 * Construct a GPSGeofence instance.
apalmieri 8:47fa213225c3 57 */
apalmieri 8:47fa213225c3 58 GPSGeofence() :
apalmieri 8:47fa213225c3 59 _expirationDuration(-1),
apalmieri 8:47fa213225c3 60 _notificationResponsiveness(0),
apalmieri 8:47fa213225c3 61 _transitionTypes(0) {
apalmieri 8:47fa213225c3 62
apalmieri 8:47fa213225c3 63 memset(_geofenceId, 0, GEOFENCE_ID_MAX_SIZE);
apalmieri 8:47fa213225c3 64 }
apalmieri 8:47fa213225c3 65
apalmieri 8:47fa213225c3 66 virtual void setGeofenceRegion(GPSProvider::LocationType_t lat,
apalmieri 8:47fa213225c3 67 GPSProvider::LocationType_t lon,
apalmieri 8:47fa213225c3 68 GPSProvider::LocationType_t radius) {
apalmieri 8:47fa213225c3 69 _lat = lat;
apalmieri 8:47fa213225c3 70 _lon = lon;
apalmieri 8:47fa213225c3 71 _radius = radius;
apalmieri 8:47fa213225c3 72 }
apalmieri 8:47fa213225c3 73
apalmieri 8:47fa213225c3 74 virtual void setExpirationDuration (long durationMillis) = 0;
apalmieri 8:47fa213225c3 75
apalmieri 8:47fa213225c3 76 virtual void setNotificationResponsiveness (int notificationResponsivenessMs) {
apalmieri 8:47fa213225c3 77 _notificationResponsiveness = notificationResponsivenessMs;
apalmieri 8:47fa213225c3 78 }
apalmieri 8:47fa213225c3 79
apalmieri 8:47fa213225c3 80 virtual void setGeofenceId(const char *geofenceId) {
apalmieri 8:47fa213225c3 81 if(strlen(geofenceId) > GEOFENCE_ID_MAX_SIZE) {
apalmieri 8:47fa213225c3 82 return;
apalmieri 8:47fa213225c3 83 }
apalmieri 8:47fa213225c3 84 memcpy(_geofenceId, geofenceId, strlen(geofenceId));
apalmieri 8:47fa213225c3 85 }
apalmieri 8:47fa213225c3 86
apalmieri 8:47fa213225c3 87 virtual void setTransitionTypes(int transitionTypes) {
apalmieri 8:47fa213225c3 88 _transitionTypes = transitionTypes;
apalmieri 8:47fa213225c3 89 }
apalmieri 8:47fa213225c3 90
apalmieri 8:47fa213225c3 91 protected:
apalmieri 8:47fa213225c3 92 char _geofenceId[GEOFENCE_ID_MAX_SIZE];
apalmieri 8:47fa213225c3 93 GPSProvider::LocationType_t _lat;
apalmieri 8:47fa213225c3 94 GPSProvider::LocationType_t _lon;
apalmieri 8:47fa213225c3 95 GPSProvider::LocationType_t _radius;
apalmieri 8:47fa213225c3 96 long _expirationDuration;
apalmieri 8:47fa213225c3 97 int _notificationResponsiveness;
apalmieri 8:47fa213225c3 98 int _transitionTypes;
apalmieri 8:47fa213225c3 99
apalmieri 8:47fa213225c3 100 private:
apalmieri 8:47fa213225c3 101 /* disallow copy constructor and assignment operators */
apalmieri 8:47fa213225c3 102 GPSGeofence(const GPSGeofence&);
apalmieri 8:47fa213225c3 103 GPSGeofence & operator= (const GPSGeofence&);
apalmieri 8:47fa213225c3 104 };
apalmieri 8:47fa213225c3 105
apalmieri 8:47fa213225c3 106 #endif /* __GPS_GEOFENCE_H__ */