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/GPSProviderImplBase.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 | /* mbed Microcontroller Library |
apalmieri | 0:0a9c622571d7 | 2 | * Copyright (c) 2006-2014 ARM Limited |
apalmieri | 0:0a9c622571d7 | 3 | * |
apalmieri | 0:0a9c622571d7 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
apalmieri | 0:0a9c622571d7 | 5 | * you may not use this file except in compliance with the License. |
apalmieri | 0:0a9c622571d7 | 6 | * You may obtain a copy of the License at |
apalmieri | 0:0a9c622571d7 | 7 | * |
apalmieri | 0:0a9c622571d7 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
apalmieri | 0:0a9c622571d7 | 9 | * |
apalmieri | 0:0a9c622571d7 | 10 | * Unless required by applicable law or agreed to in writing, software |
apalmieri | 0:0a9c622571d7 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
apalmieri | 0:0a9c622571d7 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
apalmieri | 0:0a9c622571d7 | 13 | * See the License for the specific language governing permissions and |
apalmieri | 0:0a9c622571d7 | 14 | * limitations under the License. |
apalmieri | 0:0a9c622571d7 | 15 | */ |
apalmieri | 0:0a9c622571d7 | 16 | |
apalmieri | 0:0a9c622571d7 | 17 | #ifndef __GPS_PROVIDER_INSTANCE_BASE_H__ |
apalmieri | 0:0a9c622571d7 | 18 | #define __GPS_PROVIDER_INSTANCE_BASE_H__ |
apalmieri | 0:0a9c622571d7 | 19 | |
apalmieri | 0:0a9c622571d7 | 20 | #include "GPSProviderCommon.h" |
apalmieri | 0:0a9c622571d7 | 21 | #include "GPSProvider.h" |
apalmieri | 0:0a9c622571d7 | 22 | #include "GPSGeofence.h" |
apalmieri | 0:0a9c622571d7 | 23 | #include "GPSDatalog.h" |
apalmieri | 0:0a9c622571d7 | 24 | |
apalmieri | 0:0a9c622571d7 | 25 | class GPSProviderImplBase { |
apalmieri | 0:0a9c622571d7 | 26 | public: |
apalmieri | 0:0a9c622571d7 | 27 | virtual bool setPowerMode(GPSProvider::PowerMode_t power) = 0; |
apalmieri | 0:0a9c622571d7 | 28 | virtual void reset(void) = 0; |
apalmieri | 0:0a9c622571d7 | 29 | virtual void start(void) = 0; |
apalmieri | 0:0a9c622571d7 | 30 | virtual void stop(void) = 0; |
apalmieri | 0:0a9c622571d7 | 31 | virtual void process(void) = 0; |
apalmieri | 0:0a9c622571d7 | 32 | virtual void lpmGetImmediateLocation(void) = 0; |
apalmieri | 0:0a9c622571d7 | 33 | virtual uint32_t ioctl(uint32_t command, void *arg) = 0; |
apalmieri | 0:0a9c622571d7 | 34 | |
apalmieri | 0:0a9c622571d7 | 35 | /** [ST-GNSS ] - Enable verbose NMEA stream */ |
apalmieri | 0:0a9c622571d7 | 36 | virtual void setVerboseMode(int level) = 0; |
apalmieri | 0:0a9c622571d7 | 37 | |
apalmieri | 0:0a9c622571d7 | 38 | /** [ST-GNSS] - Geofencing API */ |
apalmieri | 0:0a9c622571d7 | 39 | virtual gps_provider_error_t enableGeofence(void) = 0; |
apalmieri | 0:0a9c622571d7 | 40 | virtual gps_provider_error_t configGeofences(GPSGeofence *geofences[], unsigned GeofenceCount) = 0; |
apalmieri | 0:0a9c622571d7 | 41 | virtual gps_provider_error_t geofenceReq(void) = 0; |
apalmieri | 0:0a9c622571d7 | 42 | |
apalmieri | 0:0a9c622571d7 | 43 | /** [ST-GNSS] - Datalogging API */ |
apalmieri | 0:0a9c622571d7 | 44 | virtual gps_provider_error_t enableDatalog(void) = 0; |
apalmieri | 0:0a9c622571d7 | 45 | virtual gps_provider_error_t configDatalog(GPSDatalog *datalog) = 0; |
apalmieri | 0:0a9c622571d7 | 46 | virtual gps_provider_error_t startDatalog(void) = 0; |
apalmieri | 0:0a9c622571d7 | 47 | virtual gps_provider_error_t stopDatalog(void) = 0; |
apalmieri | 0:0a9c622571d7 | 48 | virtual gps_provider_error_t eraseDatalog(void) = 0; |
apalmieri | 0:0a9c622571d7 | 49 | virtual gps_provider_error_t logReqStatus(void) = 0; |
apalmieri | 0:0a9c622571d7 | 50 | virtual gps_provider_error_t logReqQuery(GPSProvider::LogQueryParams_t &logReqQuery) = 0; |
apalmieri | 0:0a9c622571d7 | 51 | |
apalmieri | 0:0a9c622571d7 | 52 | /** [ST-GNSS] - Odometer API*/ |
apalmieri | 0:0a9c622571d7 | 53 | virtual gps_provider_error_t enableOdo(void) = 0; |
apalmieri | 0:0a9c622571d7 | 54 | virtual gps_provider_error_t startOdo(unsigned alarmDistance) = 0; |
apalmieri | 0:0a9c622571d7 | 55 | virtual gps_provider_error_t stopOdo(void) = 0; |
apalmieri | 0:0a9c622571d7 | 56 | virtual gps_provider_error_t resetOdo(void) = 0; |
apalmieri | 0:0a9c622571d7 | 57 | |
apalmieri | 0:0a9c622571d7 | 58 | virtual bool haveDeviceInfo(void) const { |
apalmieri | 0:0a9c622571d7 | 59 | return (deviceInfo != NULL); |
apalmieri | 0:0a9c622571d7 | 60 | } |
apalmieri | 0:0a9c622571d7 | 61 | virtual const char *getDeviceInfo(void) const { |
apalmieri | 0:0a9c622571d7 | 62 | return deviceInfo; |
apalmieri | 0:0a9c622571d7 | 63 | } |
apalmieri | 0:0a9c622571d7 | 64 | virtual bool locationAvailable(void) const { |
apalmieri | 0:0a9c622571d7 | 65 | return lastLocation.valid; |
apalmieri | 0:0a9c622571d7 | 66 | } |
apalmieri | 0:0a9c622571d7 | 67 | virtual const GPSProvider::LocationUpdateParams_t *getLastLocation(void) const { |
apalmieri | 0:0a9c622571d7 | 68 | return (lastLocation.valid) ? &lastLocation : NULL; |
apalmieri | 0:0a9c622571d7 | 69 | } |
apalmieri | 0:0a9c622571d7 | 70 | virtual void onLocationUpdate(GPSProvider::LocationUpdateCallback_t callback) { |
apalmieri | 0:0a9c622571d7 | 71 | locationCallback = callback; |
apalmieri | 0:0a9c622571d7 | 72 | } |
apalmieri | 0:0a9c622571d7 | 73 | /** [ST-GNSS] - Geofencing API */ |
apalmieri | 0:0a9c622571d7 | 74 | virtual bool isGeofencingSupported(void) { |
apalmieri | 0:0a9c622571d7 | 75 | return false; /* Requesting action from porters: override this API if this capability is supported. */ |
apalmieri | 0:0a9c622571d7 | 76 | } |
apalmieri | 0:0a9c622571d7 | 77 | void onGeofenceCfgMessage(GPSProvider::GeofenceCfgMessageCallback_t callback) { |
apalmieri | 0:0a9c622571d7 | 78 | geofenceCfgMessageCallback = callback; |
apalmieri | 0:0a9c622571d7 | 79 | } |
apalmieri | 0:0a9c622571d7 | 80 | void onGeofenceStatusMessage(GPSProvider::GeofenceStatusMessageCallback_t callback) { |
apalmieri | 0:0a9c622571d7 | 81 | geofenceStatusMessageCallback = callback; |
apalmieri | 0:0a9c622571d7 | 82 | } |
apalmieri | 0:0a9c622571d7 | 83 | /** [ST-GNSS] - Datalogging API */ |
apalmieri | 0:0a9c622571d7 | 84 | virtual bool isDataloggingSupported(void) { |
apalmieri | 0:0a9c622571d7 | 85 | return false; /* Requesting action from porters: override this API if this capability is supported. */ |
apalmieri | 0:0a9c622571d7 | 86 | } |
apalmieri | 0:0a9c622571d7 | 87 | virtual void onLogStatus(GPSProvider::LogStatusCallback_t callback) { |
apalmieri | 0:0a9c622571d7 | 88 | logStatusCallback = callback; |
apalmieri | 0:0a9c622571d7 | 89 | } |
apalmieri | 0:0a9c622571d7 | 90 | virtual void onLogQuery(GPSProvider::LogQueryCallback_t callback) { |
apalmieri | 0:0a9c622571d7 | 91 | logQueryCallback = callback; |
apalmieri | 0:0a9c622571d7 | 92 | } |
apalmieri | 0:0a9c622571d7 | 93 | /** [ST-GNSS] - Odometer API */ |
apalmieri | 0:0a9c622571d7 | 94 | virtual bool isOdometerSupported(void) { |
apalmieri | 0:0a9c622571d7 | 95 | return false; /* Requesting action from porters: override this API if this capability is supported. */ |
apalmieri | 0:0a9c622571d7 | 96 | } |
apalmieri | 0:0a9c622571d7 | 97 | virtual void onOdo(GPSProvider::OdoCallback_t callback) { |
apalmieri | 0:0a9c622571d7 | 98 | odoCallback = callback; |
apalmieri | 0:0a9c622571d7 | 99 | } |
apalmieri | 0:0a9c622571d7 | 100 | |
apalmieri | 0:0a9c622571d7 | 101 | protected: |
apalmieri | 0:0a9c622571d7 | 102 | GPSProvider::LocationUpdateParams_t lastLocation; |
apalmieri | 0:0a9c622571d7 | 103 | const char *deviceInfo; |
apalmieri | 0:0a9c622571d7 | 104 | GPSProvider::LocationUpdateCallback_t locationCallback; |
apalmieri | 0:0a9c622571d7 | 105 | |
apalmieri | 0:0a9c622571d7 | 106 | /** [ST-GNSS] - Geofencing API */ |
apalmieri | 0:0a9c622571d7 | 107 | GPSProvider::GeofenceStatusParams_t geofenceStatus; |
apalmieri | 0:0a9c622571d7 | 108 | GPSProvider::GeofenceCfgMessageCallback_t geofenceCfgMessageCallback; |
apalmieri | 0:0a9c622571d7 | 109 | GPSProvider::GeofenceStatusMessageCallback_t geofenceStatusMessageCallback; |
apalmieri | 0:0a9c622571d7 | 110 | |
apalmieri | 0:0a9c622571d7 | 111 | /** [ST-GNSS] - Datalogging API */ |
apalmieri | 0:0a9c622571d7 | 112 | GPSProvider::LogStatusCallback_t logStatusCallback; |
apalmieri | 0:0a9c622571d7 | 113 | GPSProvider::LogQueryCallback_t logQueryCallback; |
apalmieri | 0:0a9c622571d7 | 114 | |
apalmieri | 0:0a9c622571d7 | 115 | /** [ST-GNSS] - Ododmeter API */ |
apalmieri | 0:0a9c622571d7 | 116 | GPSProvider::OdoCallback_t odoCallback; |
apalmieri | 0:0a9c622571d7 | 117 | }; |
apalmieri | 0:0a9c622571d7 | 118 | |
apalmieri | 0:0a9c622571d7 | 119 | #endif /* __GPS_PROVIDER_INSTANCE_BASE_H__ */ |