summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHelmut Schmidt <Helmut.3.Schmidt@continental-corporation.com>2014-07-10 14:52:28 +0200
committerHelmut Schmidt <Helmut.3.Schmidt@continental-corporation.com>2014-07-10 14:52:28 +0200
commit1c8f6cabbae3c8c4cf2b15bc3a9fe9f7c778d12c (patch)
treecff4f85ad739111379ea923f857b30ee229a33e3
parent3b5b8229821db9a6d3cde48c146f188e9f40f629 (diff)
downloadpositioning-1c8f6cabbae3c8c4cf2b15bc3a9fe9f7c778d12c.tar.gz
GT-3012 changes as decided in 02-July-2014 conference call
-rwxr-xr-xbuild-all.sh4
-rw-r--r--gnss-service/api/gnss-ext.h121
-rw-r--r--gnss-service/src/globals.h2
-rw-r--r--gnss-service/src/gnss-ext.c45
-rw-r--r--gnss-service/src/gnss-use-gpsd.c165
-rw-r--r--gnss-service/test/gnss-service-client.c34
6 files changed, 362 insertions, 9 deletions
diff --git a/build-all.sh b/build-all.sh
index bfe68e2..a8c0f1a 100755
--- a/build-all.sh
+++ b/build-all.sh
@@ -21,9 +21,9 @@
# Compiler Flags
#--------------------------------------------------------------------------
# modify the following flags as needed:
-GNSS_SERVICE_FLAGS='-DWITH_DLT=OFF -DWITH_GPSD=OFF -DWITH_REPLAYER=ON -DWITH_TESTS=ON'
+GNSS_SERVICE_FLAGS='-DWITH_DLT=OFF -DWITH_GPSD=ON -DWITH_REPLAYER=OFF -DWITH_TESTS=ON'
SENSORS_SERVICE_FLAGS='-DWITH_DLT=OFF -DWITH_REPLAYER=ON -DWITH_IPHONE=OFF -DWITH_TESTS=ON'
-ENHANCED_POSITION_SERVICE_FLAGS='-DWITH_DLT=OFF -DWITH_GPSD=OFF -DWITH_REPLAYER=ON -DWITH_IPHONE=OFF -DWITH_TESTS=ON'
+ENHANCED_POSITION_SERVICE_FLAGS='-DWITH_DLT=OFF -DWITH_GPSD=ON -DWITH_REPLAYER=OFF -DWITH_IPHONE=OFF -DWITH_TESTS=ON'
LOG_REPLAYER_FLAGS='-DWITH_DLT=OFF -DWITH_TESTS=ON'
#--------------------------------------------------------------------------
diff --git a/gnss-service/api/gnss-ext.h b/gnss-service/api/gnss-ext.h
index 18439e3..66fd427 100644
--- a/gnss-service/api/gnss-ext.h
+++ b/gnss-service/api/gnss-ext.h
@@ -58,11 +58,11 @@ typedef enum {
*/
typedef enum {
GNSS_FIX_STATUS_NO, /**< GNSS has no fix, i.e. position, velocity, time cannot be determined */
+ GNSS_FIX_STATUS_TIME, /**< GNSS can only determine the time, but not position and velocity */
GNSS_FIX_STATUS_2D, /**< GNSS has a 2D fix, i.e. the horizontal position can be determined but not the altitude.
This implies that also velocity and time are available. */
- GNSS_FIX_STATUS_3D, /**< GNSS has a 3D fix, i.e. position can be determined including the altitude.
+ GNSS_FIX_STATUS_3D /**< GNSS has a 3D fix, i.e. position can be determined including the altitude.
This implies that also velocity and time are available. */
- GNSS_FIX_STATUS_TIME /**< GNSS can only determine the time, but not position and velocity */
} EGNSSFixStatus;
/**
@@ -168,6 +168,7 @@ typedef struct {
/**
* Provides the UTC (Coordinated Universal Time) date part.
+ * Note: the uncommon numbering of day and month is chosen to be compatible with the struct tm from the standard C-Library
*/
typedef struct {
uint8_t day; /**< Day fraction of the UTC time. Unit: [day]. Number between 1 and 31 */
@@ -210,10 +211,11 @@ typedef enum {
GNSS_SATELLITE_SYSTEM_VALID = 0x00000001, /**< Validity bit for field TGNSSSatelliteDetail::system. */
GNSS_SATELLITE_ID_VALID = 0x00000002, /**< Validity bit for field TGNSSSatelliteDetail::satelliteId. */
GNSS_SATELLITE_AZIMUTH_VALID = 0x00000004, /**< Validity bit for field TGNSSSatelliteDetail::azimuth. */
- GNSS_SATELLITE_ELEVATION_VALIDLID = 0x00000008, /**< Validity bit for field TGNSSSatelliteDetail::elevation. */
+ GNSS_SATELLITE_ELEVATION_VALID = 0x00000008, /**< Validity bit for field TGNSSSatelliteDetail::elevation. */
GNSS_SATELLITE_SNR_VALID = 0x00000010, /**< Validity bit for field TGNSSSatelliteDetail::SNR. */
GNSS_SATELLITE_USED_VALID = 0x00000020, /**< Validity bit for field TGNSSSatelliteDetail::statusBits::GNSS_SATELLITE_USED. */
GNSS_SATELLITE_EPHEMERIS_AVAILABLE_VALID = 0x00000040, /**< Validity bit for field TGNSSSatelliteDetail::statusBits::GNSS_SATELLITE_EPHEMERIS_AVAILABLE. */
+ GNSS_SATELLITE_RESIDUAL_VALID = 0x00000080, /**< Validity bit for field TGNSSSatelliteDetail::posResidual. */
} EGNSSSatelliteDetailValidityBits;
/**
@@ -234,12 +236,87 @@ typedef struct {
uint16_t SNR; /**< SNR (C/No) in dBHz. Range 0 to 99, null when not tracking */
uint32_t statusBits; /**< Bit mask of additional status flags.
[bitwise or'ed @ref EGNSSSatelliteFlag values]. */
+ int16_t posResidual; /**< Residual in m of position calculation. Range -999 to +999, 0 if not tracking */
uint32_t validityBits; /**< Bit mask indicating the validity of each corresponding value.
[bitwise or'ed @ref EGNSSSatelliteDetailValidityBits values].
Must be checked before usage. */
} TGNSSSatelliteDetail;
/**
+ * TGNSSLocation::validityBits provides information about the currently valid signals
+ * of the GNSS position and velocity including status and accuracy data.
+ * It is a or'ed bitmask of the EGNSSLocationValidityBits values.
+ */
+typedef enum {
+ //position
+ GNSS_LOCATION_LATITUDE_VALID = 0x00000001, /**< Validity bit for field TGNSSLocation::latitude. */
+ GNSS_LOCATION_LONGITUDE_VALID = 0x00000002, /**< Validity bit for field TGNSSLocation::longitude. */
+ GNSS_LOCATION_ALTITUDEMSL_VALID = 0x00000004, /**< Validity bit for field TGNSSLocation::altitudeMSL. */
+ GNSS_LOCATION_ALTITUDEELL_VALID = 0x00000008, /**< Validity bit for field TGNSSLocation::altitudeEll. */
+ //velocity
+ GNSS_LOCATION_HSPEED_VALID = 0x00000010, /**< Validity bit for field TGNSSLocation::hSpeed. */
+ GNSS_LOCATION_VSPEED_VALID = 0x00000020, /**< Validity bit for field TGNSSLocation::vSpeed. */
+ GNSS_LOCATION_HEADING_VALID = 0x00000040, /**< Validity bit for field TGNSSLocation::heading. */
+ //quality parameters: satellite constellation
+ GNSS_LOCATION_PDOP_VALID = 0x00000080, /**< Validity bit for field TGNSSLocation::pdop. */
+ GNSS_LOCATION_HDOP_VALID = 0x00000100, /**< Validity bit for field TGNSSLocation::hdop. */
+ GNSS_LOCATION_VDOP_VALID = 0x00000200, /**< Validity bit for field TGNSSLocation::vdop. */
+
+ GNSS_LOCATION_USAT_VALID = 0x00000400, /**< Validity bit for field TGNSSLocation::usedSatellites. */
+ GNSS_LOCATION_TSAT_VALID = 0x00000800, /**< Validity bit for field TGNSSLocation::trackedSatellites. */
+ GNSS_LOCATION_VSAT_VALID = 0x00001000, /**< Validity bit for field TGNSSLocation::visibleSatellites. */
+ //quality parameters: error estimates
+ GNSS_LOCATION_SHPOS_VALID = 0x00002000, /**< Validity bit for field TGNSSLocation::sigmaHPosition. */
+ GNSS_LOCATION_SALT_VALID = 0x00004000, /**< Validity bit for field TGNSSLocation::sigmaAltitude. */
+ GNSS_LOCATION_SHSPEED_VALID = 0x00008000, /**< Validity bit for field TGNSSLocation::sigmaHSpeed. */
+ GNSS_LOCATION_SVSPEED_VALID = 0x00010000, /**< Validity bit for field TGNSSLocation::sigmaVSpeed. */
+ GNSS_LOCATION_SHEADING_VALID = 0x00020000, /**< Validity bit for field TGNSSLocation::sigmaHeading. */
+ //quality parameters: overall GNSS fix status
+ GNSS_LOCATION_STAT_VALID = 0x00040000, /**< Validity bit for field TGNSSLocation::fixStatus. */
+ GNSS_LOCATION_TYPE_VALID = 0x00080000, /**< Validity bit for field TGNSSLocation::fixTypeBits. */
+} EGNSSLocationValidityBits;
+
+/**
+ * GNSS location, i.e. position and velocity including status and accuracy.
+ * This data structure provides all GNSS information which is typically needed
+ * for positioning applications such as GNSS/Dead Reckoning sensor fusion.
+ */
+typedef struct {
+ uint64_t timestamp; /**< Timestamp of the acquisition of the position data. [ms] */
+ //position
+ double latitude; /**< Latitude in WGS84 in degrees. */
+ double longitude; /**< Longitude in WGS84 in degrees. */
+ float altitudeMSL; /**< Altitude above mean sea level (geoid) */
+ float altitudeEll; /**< Altitude above WGS84 ellipsoid */
+ //velocity
+ float hSpeed; /**< Horizontal speed [m/s]. */
+ float vSpeed; /**< Vertical speed [m/s]. */
+ float heading; /**< GNSS course angle [degree] (0 => north, 90 => east, 180 => south, 270 => west, no negative values). */
+ //quality parameters: satellite constellation
+ float pdop; /**< The positional (3D) dilution of precision. [Note: pdop^2 = hdop^2+vdop^2] */
+ float hdop; /**< The horizontal (2D) dilution of precision. */
+ float vdop; /**< The vertical (altitude) dilution of precision. */
+ uint16_t usedSatellites; /**< Number of satellites used for the GNSS fix. */
+ uint16_t trackedSatellites; /**< Number of satellites from which a signal is received. */
+ uint16_t visibleSatellites; /**< Number of satellites expected to be receiveable, i.e. above horizon or elevation mask. */
+ //quality parameters: error estimates
+ float sigmaHPosition; /**< Standard error estimate of the horizontal position in [m]. */
+ float sigmaAltitude; /**< Standard error estimate of altitude in [m]. */
+ float sigmaHSpeed; /**< Standard error estimate of horizontal speed in [m/s]. */
+ float sigmaVSpeed; /**< Standard error estimate of vertical speed in [m/s]. */
+ float sigmaHeading; /**< Standard error estimate of horizontal heading/course in [degree]. */
+ //quality parameters: overall GNSS fix status
+ EGNSSFixStatus fixStatus; /**< Value representing the GNSS mode. */
+ uint32_t fixTypeBits; /**< Bit mask indicating the sources actually used for the GNSS calculation.
+ [bitwise or'ed @ref EGNSSFixType values]. */
+
+ uint32_t validityBits; /**< Bit mask indicating the validity of each corresponding value.
+ [bitwise or'ed @ref EGNSSLocationValidityBits values].
+ Must be checked before usage. */
+} TGNSSLocation;
+
+
+/**
* Callback type for extended GNSS accuracy.
* Use this type of callback if you want to register for extended GNSS accuracy data.
* This callback may return buffered data (numElements >1) for different reasons
@@ -302,6 +379,18 @@ typedef void (*GNSSUTCDateCallback)(const TUTCDate date[], const TUTCTime time[]
typedef void (*GNSSSatelliteDetailCallback)(const TGNSSSatelliteDetail satelliteDetail[], uint16_t numElements);
/**
+ * Callback type for GNSS position, velocity, accuracy.
+ * Use this type of callback if you want to register for GNSS position, velocity, accuracy.
+ * This callback may return buffered data (numElements >1) for different reasons
+ * for (large) portions of data buffered at startup
+ * for data buffered during regular operation e.g. for performance optimization (reduction of callback invocation frequency)
+ * If the array contains (numElements >1), the elements will be ordered with rising timestamps
+ * @param time pointer to an array of TGNSSLocation with size numElements
+ * @param numElements: allowed range: >=1. If numElements >1, buffered data are provided.
+ */
+typedef void (*GNSSLocationCallback)(const TGNSSLocation location[], uint16_t numElements);
+
+/**
* Initialization of the extended GNSS service.
* Must be called before using the extended GNSS service to set up the service.
* @return True if initialization has been successfull.
@@ -467,6 +556,32 @@ bool gnssExtendedRegisterSatelliteDetailCallback(GNSSSatelliteDetailCallback cal
bool gnssExtendedDeregisterSatelliteDetailCallback(GNSSSatelliteDetailCallback callback);
/**
+ * Method to get the GNSS position, velocity, accuracy at a specific point in time.
+ * All valid flags are updated. The data is only guaranteed to be updated when the valid flag is true.
+ * @param positionVelocityAccuracy After calling the method current GNSS position, velocity, accuracy are written into this parameter.
+ * @return Is true if data can be provided and false otherwise, e.g. missing initialization
+ */
+bool gnssExtendedGetLocation(TGNSSLocation* location);
+
+/**
+ * Register GNSS position, velocity, accuracy callback.
+ * The callback will be invoked when new date data is available from the GNSS receiver.
+ * The valid flags is updated. The data is only guaranteed to be updated when the valid flag is true.
+ * @param callback The callback which should be registered.
+ * @return True if callback has been registered successfully.
+ */
+bool gnssExtendedRegisterLocationCallback(GNSSLocationCallback callback);
+
+/**
+ * Deregister GNSS position, velocity, accuracy callback.
+ * After calling this method no new data will be delivered to the client.
+ * @param callback The callback which should be deregistered.
+ * @return True if callback has been deregistered successfully.
+ */
+bool gnssExtendedDeregisterLocationCallback(GNSSLocationCallback callback);
+
+
+/**
* Provides the precision timing information as signaled by the GNSS PPS signal.
* For accurate timing the 1 PPS (pulse per second) signal from the GNSS receiver is used within the positioning framework.
* The PPS is a hardware signal which is a UTC synchronized pulse.
diff --git a/gnss-service/src/globals.h b/gnss-service/src/globals.h
index 4e252c4..8978003 100644
--- a/gnss-service/src/globals.h
+++ b/gnss-service/src/globals.h
@@ -35,6 +35,7 @@ extern TGNSSPosition gPosition;
extern TGNSSCourse gCourse;
extern TGNSSAccuracy gAccuracy;
extern TGNSSSatelliteDetail gSatelliteDetail; //TODO: buffer full set of satellite details for one point in time
+extern TGNSSLocation gLocation;
extern TGNSSSimpleConfiguration gConfiguration;
extern const TGnssMetaData gMetaData;
@@ -43,5 +44,6 @@ extern GNSSPositionCallback cbPosition;
extern GNSSCourseCallback cbCourse;
extern GNSSAccuracyCallback cbAccuracy;
extern GNSSSatelliteDetailCallback cbSatelliteDetail;
+extern GNSSLocationCallback cbLocation;
#endif /* GLOBALS_H */
diff --git a/gnss-service/src/gnss-ext.c b/gnss-service/src/gnss-ext.c
index 8f88c07..ef9b088 100644
--- a/gnss-service/src/gnss-ext.c
+++ b/gnss-service/src/gnss-ext.c
@@ -25,6 +25,9 @@ GNSSAccuracyCallback cbAccuracy = 0;
TGNSSSatelliteDetail gSatelliteDetail; //TODO: buffer full set of satellite details for one point in time
GNSSSatelliteDetailCallback cbSatelliteDetail = 0;
+TGNSSLocation gLocation;
+GNSSLocationCallback cbLocation = 0;
+
bool gnssExtendedInit()
{
return true;
@@ -120,3 +123,45 @@ bool gnssExtendedGetSatelliteDetails(TGNSSSatelliteDetail* satelliteDetails, uin
return true;
}
+
+bool gnssExtendedRegisterLocationCallback(GNSSLocationCallback callback)
+{
+ if(cbLocation != 0)
+ {
+ return false; //if already registered
+ }
+
+ pthread_mutex_lock(&mutexCb);
+ cbLocation = callback;
+ pthread_mutex_unlock(&mutexCb);
+
+ return true;
+}
+
+bool gnssExtendedDeregisterLocationCallback(GNSSLocationCallback callback)
+{
+ if(cbLocation == callback && callback != 0)
+ {
+ pthread_mutex_lock(&mutexCb);
+ cbLocation = 0;
+ pthread_mutex_unlock(&mutexCb);
+
+ return true;
+ }
+
+ return false;
+}
+
+bool gnssExtendedGetLocation(TGNSSLocation* location)
+{
+ if(!location)
+ {
+ return false;
+ }
+
+ pthread_mutex_lock(&mutexData);
+ *location = gLocation;
+ pthread_mutex_unlock(&mutexData);
+
+ return true;
+} \ No newline at end of file
diff --git a/gnss-service/src/gnss-use-gpsd.c b/gnss-service/src/gnss-use-gpsd.c
index dbbcaeb..3717fde 100644
--- a/gnss-service/src/gnss-use-gpsd.c
+++ b/gnss-service/src/gnss-use-gpsd.c
@@ -197,10 +197,10 @@ bool extractPosition(struct gps_data_t* pGpsData, TGNSSPosition* pPosition)
if(pGpsData->set & LATLON_SET)
{
- pPosition->validityBits |= GNSS_ACCURACY_SLAT_VALID;
+ pPosition->validityBits |= GNSS_POSITION_LATITUDE_VALID;
pPosition->latitude = pGpsData->fix.latitude;
- pPosition->validityBits |= GNSS_ACCURACY_SLON_VALID;
+ pPosition->validityBits |= GNSS_POSITION_LONGITUDE_VALID;
pPosition->longitude = pGpsData->fix.longitude;
LOG_DEBUG(gContext,"Latitude: %lf", pPosition->latitude);
@@ -209,7 +209,7 @@ bool extractPosition(struct gps_data_t* pGpsData, TGNSSPosition* pPosition)
if((pGpsData->set & ALTITUDE_SET) && (pGpsData->fix.mode == MODE_3D))
{
- pPosition->validityBits |= GNSS_ACCURACY_SALT_VALID;
+ pPosition->validityBits |= GNSS_POSITION_ALTITUDE_VALID;
pPosition->altitude = (float)pGpsData->fix.altitude;
LOG_DEBUG(gContext,"Altitude: %lf", pPosition->altitude);
@@ -272,6 +272,160 @@ bool extractCourse(struct gps_data_t* pGpsData, TGNSSCourse* pCourse)
return true;
}
+
+bool extractLocation(struct gps_data_t* pGpsData, TGNSSLocation* pLocation)
+{
+ static float oldHSpeed = 0;
+ static float oldVSpeed = 0;
+ static float oldHeading = 0;
+ static EGNSSFixStatus oldFixStatus = GNSS_FIX_STATUS_NO;
+ static uint16_t oldUsedSatellites = 0;
+ static uint16_t oldVisibleSatellites = 0;
+
+ bool positionAvailable = false;
+ bool velocityAvailable = false;
+ bool fixStatusChanged = false;
+ bool satellitesChanged = false;
+
+ if(!pGpsData || !pLocation)
+ {
+ return false;
+ }
+
+ pLocation->validityBits = 0;
+
+ pLocation->timestamp = pGpsData->fix.time;
+
+ if( ((pGpsData->set & LATLON_SET) || (pGpsData->set & ALTITUDE_SET)) &&
+ (pGpsData->set & MODE_SET) &&
+ ((pGpsData->fix.mode == MODE_2D) || (pGpsData->fix.mode == MODE_3D)) )
+ {
+ positionAvailable = true;
+
+ if(pGpsData->set & LATLON_SET)
+ {
+ pLocation->validityBits |= GNSS_LOCATION_LATITUDE_VALID;
+ pLocation->latitude = pGpsData->fix.latitude;
+
+ pLocation->validityBits |= GNSS_LOCATION_LONGITUDE_VALID;
+ pLocation->longitude = pGpsData->fix.longitude;
+
+ LOG_DEBUG(gContext,"Latitude: %lf", pLocation->latitude);
+ LOG_DEBUG(gContext,"Longitude: %lf", pLocation->longitude);
+ }
+
+ if((pGpsData->set & ALTITUDE_SET) && (pGpsData->fix.mode == MODE_3D))
+ {
+ pLocation->validityBits |= GNSS_LOCATION_ALTITUDEMSL_VALID;
+ pLocation->altitudeMSL = (float)pGpsData->fix.altitude;
+
+ LOG_DEBUG(gContext,"Altitude: %lf", pLocation->altitudeMSL);
+ }
+ }
+
+ if( ((pGpsData->set & SPEED_SET) && (oldHSpeed != (float)pGpsData->fix.speed)) ||
+ ((pGpsData->set & CLIMB_SET) && (oldVSpeed != (float)pGpsData->fix.climb)) ||
+ ((pGpsData->set & TRACK_SET) && (oldHeading != (float)pGpsData->fix.track)) )
+ {
+
+ velocityAvailable = true;
+
+ if(pGpsData->set & SPEED_SET)
+ {
+ oldHSpeed = pLocation->hSpeed;
+ pLocation->hSpeed = (float)pGpsData->fix.speed;
+ pLocation->validityBits |= GNSS_LOCATION_HSPEED_VALID;
+ LOG_DEBUG(gContext,"Speed: %lf", pLocation->hSpeed);
+ }
+
+ if(pGpsData->set & CLIMB_SET)
+ {
+ oldVSpeed = pLocation->vSpeed;
+ pLocation->vSpeed = (float)pGpsData->fix.climb;
+ pLocation->validityBits |= GNSS_LOCATION_VSPEED_VALID;
+ LOG_DEBUG(gContext,"Climb: %lf", pLocation->vSpeed);
+ }
+
+ if(pGpsData->set & TRACK_SET)
+ {
+ oldHeading = pLocation->heading;
+ pLocation->heading = (float)pGpsData->fix.track;
+ pLocation->validityBits |= GNSS_LOCATION_HEADING_VALID;
+ LOG_DEBUG(gContext,"Heading: %lf", pLocation->heading);
+ }
+ }
+
+ fixStatusChanged = (oldFixStatus != convertToFixStatus(pGpsData->fix.mode));
+
+ satellitesChanged = ((oldUsedSatellites != (uint16_t)pGpsData->satellites_used) ||
+ (oldVisibleSatellites != (uint16_t)pGpsData->satellites_visible));
+
+ if(((pGpsData->set & MODE_SET) && fixStatusChanged) ||
+ (pGpsData->set & DOP_SET) ||
+ ((pGpsData->set & SATELLITE_SET) && satellitesChanged))
+ {
+ oldFixStatus = pLocation->fixStatus;
+ pLocation->fixStatus = convertToFixStatus(pGpsData->fix.mode);
+ pLocation->validityBits |= GNSS_LOCATION_STAT_VALID;
+ LOG_DEBUG(gContext,"FixStatus: %d", (int)pLocation->fixStatus);
+
+ //fixTypeBits: hardcoded
+ pLocation->fixTypeBits |= GNSS_FIX_TYPE_SINGLE_FREQUENCY;
+ pLocation->validityBits |= GNSS_LOCATION_TYPE_VALID;
+
+ pLocation->pdop = (float)pGpsData->dop.pdop;
+ pLocation->validityBits |= GNSS_LOCATION_PDOP_VALID;
+ LOG_DEBUG(gContext,"pdop: %lf", pLocation->pdop);
+
+ pLocation->hdop = (float)pGpsData->dop.hdop;
+ pLocation->validityBits |= GNSS_LOCATION_HDOP_VALID;
+ LOG_DEBUG(gContext,"hdop: %lf", pLocation->hdop);
+
+ pLocation->vdop = (float)pGpsData->dop.vdop;
+ pLocation->validityBits |= GNSS_LOCATION_VDOP_VALID;
+ LOG_DEBUG(gContext,"vdop: %lf", pLocation->vdop);
+
+ pLocation->sigmaHPosition = (float)pGpsData->fix.epx;
+ pLocation->validityBits |= GNSS_LOCATION_SHPOS_VALID;
+ LOG_DEBUG(gContext,"sigmaHorPosition: %lf", pLocation->sigmaHPosition);
+
+ pLocation->sigmaHSpeed = (float)pGpsData->fix.eps;
+ pLocation->validityBits |= GNSS_LOCATION_SHSPEED_VALID;
+ LOG_DEBUG(gContext,"sigmaHorSpeed: %lf", pLocation->sigmaHSpeed);
+
+ pLocation->sigmaHeading = (float)pGpsData->fix.epd;
+ pLocation->validityBits |= GNSS_LOCATION_SHEADING_VALID;
+ LOG_DEBUG(gContext,"sigmaHeading: %lf", pLocation->sigmaHeading);
+
+ if(pGpsData->satellites_used >= 0)
+ {
+ oldUsedSatellites = pLocation->usedSatellites;
+ pLocation->usedSatellites = (uint16_t)pGpsData->satellites_used;
+ pLocation->validityBits |= GNSS_LOCATION_USAT_VALID;
+ LOG_DEBUG(gContext,"Used Satellites: %d", pLocation->usedSatellites);
+ }
+
+ if(pGpsData->satellites_visible >= 0)
+ {
+ oldVisibleSatellites = pLocation->visibleSatellites;
+ pLocation->visibleSatellites = (uint16_t)pGpsData->satellites_visible;
+ pLocation->validityBits |= GNSS_LOCATION_VSAT_VALID;
+ LOG_DEBUG(gContext,"Visible Satellites: %d", pLocation->visibleSatellites);
+ }
+ }
+
+ if (positionAvailable || velocityAvailable || fixStatusChanged || satellitesChanged)
+ {
+ if(cbLocation != 0)
+ {
+ cbLocation(pLocation,1);
+ }
+ }
+
+ return true;
+}
+
+
void *listen( void *ptr )
{
char* server = "localhost";
@@ -332,6 +486,11 @@ void *listen( void *ptr )
LOG_ERROR_MSG(gContext,"error extracting accuracy");
}
+ if(!extractLocation(&gpsdata,&gLocation))
+ {
+ LOG_ERROR_MSG(gContext,"error extracting positionVelocityAccuracy");
+ }
+
pthread_mutex_unlock(&mutexData);
}
}
diff --git a/gnss-service/test/gnss-service-client.c b/gnss-service/test/gnss-service-client.c
index 969bfdc..a2da4cf 100644
--- a/gnss-service/test/gnss-service-client.c
+++ b/gnss-service/test/gnss-service-client.c
@@ -59,7 +59,7 @@ static void cbCourse(const TGNSSCourse course[], uint16_t numElements)
for (i = 0; i<numElements; i++)
{
- LOG_INFO(gCtx,"Course Updatee[%d/%d]: speed=%f heading=%f climb=%f",
+ LOG_INFO(gCtx,"Course Update[%d/%d]: speed=%f heading=%f climb=%f",
i+1,
numElements,
course[i].speed,
@@ -90,6 +90,36 @@ static void cbAccuracy(const TGNSSAccuracy accuracy[], uint16_t numElements)
}
}
+static void cbLocation(const TGNSSLocation location[], uint16_t numElements)
+{
+ int i;
+ if(location == NULL || numElements < 1)
+ {
+ LOG_ERROR_MSG(gCtx,"cbLocation failed!");
+ return;
+ }
+
+ for (i = 0; i<numElements; i++)
+ {
+ LOG_INFO(gCtx,"Location Update[%d/%d]: timestamp=%llu latitude=%.5f longitude=%.5f altitudeMSL=%.1f hSpeed=%.1f heading=%.1f\n hdop=%.1f usedSatellites=%d sigmaHPosition=%.1f sigmaHSpeed=%.1f sigmaHeading=%.1f fixStatus=%d fixTypeBits=0x%08X",
+ i+1,
+ numElements,
+ location[i].timestamp,
+ location[i].latitude,
+ location[i].longitude,
+ location[i].altitudeMSL,
+ location[i].hSpeed,
+ location[i].heading,
+ location[i].hdop,
+ location[i].usedSatellites,
+ location[i].sigmaHPosition,
+ location[i].sigmaHSpeed,
+ location[i].sigmaHeading,
+ location[i].fixStatus,
+ location[i].fixTypeBits);
+ }
+}
+
static void cbSatelliteDetail(const TGNSSSatelliteDetail satelliteDetail[], uint16_t numElements)
{
int i;
@@ -161,6 +191,7 @@ int main()
gnssSimpleRegisterCourseCallback(&cbCourse);
gnssExtendedRegisterAccuracyCallback(&cbAccuracy);
gnssExtendedRegisterSatelliteDetailCallback(&cbSatelliteDetail);
+ gnssExtendedRegisterLocationCallback(&cbLocation);
// enter endless loop
while(1)
@@ -173,6 +204,7 @@ int main()
gnssSimpleDeregisterCourseCallback(&cbCourse);
gnssExtendedDeregisterAccuracyCallback(&cbAccuracy);
gnssExtendedDeregisterSatelliteDetailCallback(&cbSatelliteDetail);
+ gnssExtendedDeregisterLocationCallback(&cbLocation);
gnssSimpleDestroy();
gnssDestroy();