An extension of original API for working with GPS devices.

Committer:
apalmieri
Date:
Tue Jun 13 15:19:49 2017 +0000
Revision:
8:47fa213225c3
Child:
9:708266cd594b
Add draft Geofence API

Who changed what in which revision?

UserRevisionLine numberNew contents of line
apalmieri 8:47fa213225c3 1 /* mbed Microcontroller Library
apalmieri 8:47fa213225c3 2 * Copyright (c) 2006-2014 ARM Limited
apalmieri 8:47fa213225c3 3 *
apalmieri 8:47fa213225c3 4 * Licensed under the Apache License, Version 2.0 (the "License");
apalmieri 8:47fa213225c3 5 * you may not use this file except in compliance with the License.
apalmieri 8:47fa213225c3 6 * You may obtain a copy of the License at
apalmieri 8:47fa213225c3 7 *
apalmieri 8:47fa213225c3 8 * http://www.apache.org/licenses/LICENSE-2.0
apalmieri 8:47fa213225c3 9 *
apalmieri 8:47fa213225c3 10 * Unless required by applicable law or agreed to in writing, software
apalmieri 8:47fa213225c3 11 * distributed under the License is distributed on an "AS IS" BASIS,
apalmieri 8:47fa213225c3 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
apalmieri 8:47fa213225c3 13 * See the License for the specific language governing permissions and
apalmieri 8:47fa213225c3 14 * limitations under the License.
apalmieri 8:47fa213225c3 15 */
apalmieri 8:47fa213225c3 16
apalmieri 8:47fa213225c3 17 #ifndef __GPS_GEOFENCE_H__
apalmieri 8:47fa213225c3 18 #define __GPS_GEOFENCE_H__
apalmieri 8:47fa213225c3 19
apalmieri 8:47fa213225c3 20 class GPSProvider;
apalmieri 8:47fa213225c3 21
apalmieri 8:47fa213225c3 22 class GPSGeofence {
apalmieri 8:47fa213225c3 23 public:
apalmieri 8:47fa213225c3 24 enum {
apalmieri 8:47fa213225c3 25 GEOFENCE_TRANSITION_DWELL = 1,
apalmieri 8:47fa213225c3 26 GEOFENCE_TRANSITION_ENTER = 2,
apalmieri 8:47fa213225c3 27 GEOFENCE_TRANSITION_EXIT = 4,
apalmieri 8:47fa213225c3 28 };
apalmieri 8:47fa213225c3 29
apalmieri 8:47fa213225c3 30 static const int NEVER_EXPIRE = -1;
apalmieri 8:47fa213225c3 31
apalmieri 8:47fa213225c3 32 static const int GEOFENCE_ID_MAX_SIZE = 32;
apalmieri 8:47fa213225c3 33
apalmieri 8:47fa213225c3 34 /**
apalmieri 8:47fa213225c3 35 * Construct a GPSGeofence instance.
apalmieri 8:47fa213225c3 36 */
apalmieri 8:47fa213225c3 37 GPSGeofence() :
apalmieri 8:47fa213225c3 38 _expirationDuration(-1),
apalmieri 8:47fa213225c3 39 _notificationResponsiveness(0),
apalmieri 8:47fa213225c3 40 _transitionTypes(0) {
apalmieri 8:47fa213225c3 41
apalmieri 8:47fa213225c3 42 memset(_geofenceId, 0, GEOFENCE_ID_MAX_SIZE);
apalmieri 8:47fa213225c3 43 }
apalmieri 8:47fa213225c3 44
apalmieri 8:47fa213225c3 45 virtual void setGeofenceRegion(GPSProvider::LocationType_t lat,
apalmieri 8:47fa213225c3 46 GPSProvider::LocationType_t lon,
apalmieri 8:47fa213225c3 47 GPSProvider::LocationType_t radius) {
apalmieri 8:47fa213225c3 48 _lat = lat;
apalmieri 8:47fa213225c3 49 _lon = lon;
apalmieri 8:47fa213225c3 50 _radius = radius;
apalmieri 8:47fa213225c3 51 }
apalmieri 8:47fa213225c3 52
apalmieri 8:47fa213225c3 53 virtual void setExpirationDuration (long durationMillis) = 0;
apalmieri 8:47fa213225c3 54
apalmieri 8:47fa213225c3 55 virtual void setNotificationResponsiveness (int notificationResponsivenessMs) {
apalmieri 8:47fa213225c3 56 _notificationResponsiveness = notificationResponsivenessMs;
apalmieri 8:47fa213225c3 57 }
apalmieri 8:47fa213225c3 58
apalmieri 8:47fa213225c3 59 virtual void setGeofenceId(const char *geofenceId) {
apalmieri 8:47fa213225c3 60 if(strlen(geofenceId) > GEOFENCE_ID_MAX_SIZE) {
apalmieri 8:47fa213225c3 61 return;
apalmieri 8:47fa213225c3 62 }
apalmieri 8:47fa213225c3 63 memcpy(_geofenceId, geofenceId, strlen(geofenceId));
apalmieri 8:47fa213225c3 64 }
apalmieri 8:47fa213225c3 65
apalmieri 8:47fa213225c3 66 virtual void setTransitionTypes(int transitionTypes) {
apalmieri 8:47fa213225c3 67 _transitionTypes = transitionTypes;
apalmieri 8:47fa213225c3 68 }
apalmieri 8:47fa213225c3 69
apalmieri 8:47fa213225c3 70 protected:
apalmieri 8:47fa213225c3 71 char _geofenceId[GEOFENCE_ID_MAX_SIZE];
apalmieri 8:47fa213225c3 72 GPSProvider::LocationType_t _lat;
apalmieri 8:47fa213225c3 73 GPSProvider::LocationType_t _lon;
apalmieri 8:47fa213225c3 74 GPSProvider::LocationType_t _radius;
apalmieri 8:47fa213225c3 75 long _expirationDuration;
apalmieri 8:47fa213225c3 76 int _notificationResponsiveness;
apalmieri 8:47fa213225c3 77 int _transitionTypes;
apalmieri 8:47fa213225c3 78
apalmieri 8:47fa213225c3 79 private:
apalmieri 8:47fa213225c3 80 /* disallow copy constructor and assignment operators */
apalmieri 8:47fa213225c3 81 GPSGeofence(const GPSGeofence&);
apalmieri 8:47fa213225c3 82 GPSGeofence & operator= (const GPSGeofence&);
apalmieri 8:47fa213225c3 83 };
apalmieri 8:47fa213225c3 84
apalmieri 8:47fa213225c3 85 #endif /* __GPS_GEOFENCE_H__ */