SpecsLocation
SPECS NDK reference for the SpecsLocation fused location provider, which returns the last known device position, heading and speed.
SpecsLocation is the fused location provider for SPECS. It returns the last known device position, combining GPS, heading, and speed data.
Include and link SpecsLocation
#include <SpecsLocationProvider.h>
// Transitively includes:
// SpecsLocationDefinitions.h — types and constants
target_link_libraries(myapp specs_location)
Required permission: GPS_RAW—SpecsLocation_getCachedLocation is annotated with SPECS_REQUIRES_PERMISSION(GPS_RAW). The permission is recorded in your library's .snap.permissions manifest at build time; see Permission Annotations and Manifest Embedding.
SpecsLocation types
SpecsLocation_FusedLocation_t
Since: v1.3.0
#define SPECS_LOCATION_PROVIDER_MAX_LEN 16
typedef struct {
double latitudeDecimalDegrees; // WGS84 latitude
double longitudeDecimalDegrees; // WGS84 longitude
double altitudeMeters; // altitude above sea level
float horizontalAccuracyMeters; // 68% confidence radius
float verticalAccuracyMeters; // 68% confidence
float headingDegrees; // compass heading (0 = north, clockwise)
float headingAccuracyDegrees; // heading uncertainty
float speedMetersPerSecond; // ground speed
float speedAccuracyMetersPerSecond; // speed uncertainty
int64_t timestampMilliseconds; // fix timestamp (ms since epoch)
char provider[SPECS_LOCATION_PROVIDER_MAX_LEN]; // e.g. "fused"
} SpecsLocation_FusedLocation_t;
SpecsLocation function reference
// Retrieve the last cached fused location.
// Returns 0 on success, non-zero on error (e.g. -1 if outLocation is NULL).
// Since: v1.3.0
int SpecsLocation_getCachedLocation(SpecsLocation_FusedLocation_t *outLocation);
Read the cached location
#include <SpecsLocationProvider.h>
#include <stdio.h>
void printCachedLocation(void) {
SpecsLocation_FusedLocation_t loc;
if (SpecsLocation_getCachedLocation(&loc) == 0) {
printf("Lat: %f, Lon: %f, Alt: %f m\n",
loc.latitudeDecimalDegrees,
loc.longitudeDecimalDegrees,
loc.altitudeMeters);
printf("Speed: %.1f m/s, Heading: %.1f°\n",
loc.speedMetersPerSecond,
loc.headingDegrees);
}
}