Connectivity & Networking
GPS & GNSS Location Services
Global GPS API for NMEA parsing, coordinates, altitude, speed, and satellite telemetry.
21. Global Object: GPS (GNSS Subsystem & Location Services)
The GPS global object provides high-speed, battery-conscious access to the onboard GNSS satellite receiver (u-blox MIA-M10Q / Quectel L76K on LilyGO T-Deck Plus).
Architectural Guarantees:
- Asynchronous FreeRTOS Core 0 Processing: NMEA parsing runs in a dedicated background task (combining
TinyGPSPluswith a direct multi-constellation checksum-verified NMEA line parser supportingGP,GN,BD,GB,GL,GA,QZacrossRMC,GGA,GNS,GLL,GSA,GSV, andVTG), preventing UART buffer overruns and ensuring zero GUI/JavaScript thread freezing. - Privacy & Security Gating: All spatial readouts are protected by the KryonOS Permission Manager (
"location"permission) and backed by/local/system/app_permissions.json. - Continuous Warm Ephemeris & Power Lifecycle: When the system GPS Master Switch is enabled,
GPSEngine::init()starts the GNSS receiver at OS boot and keeps ephemeris acquisition warm in the background so satellite fixes are never lost when switching apps. CallingGPS.start()/GPS.enable()registers an app-level hold, and turning off the Master Switch in Settings cleanly shuts down the UART.
21.1 Hardware & Power Management
GPS.isAvailable()
- Returns:
Boolean - Description: Returns
trueif physical GNSS hardware is present on the board (e.g.trueon LilyGO T-Deck Plus,falseon standard T-Deck).
GPS.isEnabled()
- Returns:
Boolean - Description: Returns
trueonly if the Master Switch is ON and GNSS hardware is actively running.
GPS.start() / GPS.enable()
- Returns:
Boolean - Description: Registers an active GPS hold for the calling app. If Master Switch is OFF, prompts user to turn on GPS in Settings.
GPS.stop() / GPS.disable()
- Returns:
Boolean - Description: Releases the calling app's hold without interrupting background satellite tracking or other running apps.
GPS.requestPermission()
- Returns:
String("granted"|"denied") - Description: Programmatic consent query.
21.2 Spatial Coordinates & Telemetry
GPS.hasFix()
- Returns:
Boolean - Description: Instant check. Returns
trueif a valid 2D/3D coordinate fix has been decoded within the active freshness window (< 30000ms).
GPS.getLocation()
- Returns:
Object | null - Description: Returns the live spatial snapshot. Returns
nullif no valid fix or permission denied.
{
lat: 31.520370, // Latitude in decimal degrees (WGS84)
lng: 74.358747, // Longitude in decimal degrees (WGS84)
altitude: 214.5, // Altitude in meters above sea level
speed: 12.4, // Ground speed in km/h
speedKnots: 6.7, // Ground speed in knots
course: 184.2, // Heading in degrees (0.0 to 359.9)
accuracy: 2.3, // Estimated horizontal position error in meters
timestamp: 1731000000000 // UTC epoch milliseconds
}
GPS.getLastKnownLocation()
- Returns:
Object | null - Description: Returns the most recent cached coordinate snapshot immediately (loaded from RAM or
/local/system/gps_last_loc.jsonon boot) without waiting for a fresh satellite fix.
GPS.getStatus()
- Returns:
Object | null - Description: Returns satellite constellation health, tracked/visible counts, detected chipset model, live carrier signal strengths (SNR), precision metrics, and the latest checksum-verified raw NMEA sentences received from the hardware UART.
{
enabled: true,
hasFix: true,
fixType: "3D", // "none", "2D", "3D"
chipModel: "Quectel L76K", // "u-blox MIA-M10Q" or "Quectel L76K" (auto-detected)
satellitesTracked: 8, // Used in navigation solution (GGA/GNS/GSA)
satellitesVisible: 12, // Visible in RF sky across constellations (GPS/GLONASS/Galileo/BeiDou)
satellitesWithSignal: 7, // Satellites receiving valid RF carrier lock (SNR > 0)
avgSnr: 34.2, // Average signal-to-noise ratio in dB-Hz across tracked satellites
hdop: 1.15, // Horizontal Dilution of Precision (< 2.0 = excellent)
vdop: 1.42, // Vertical Dilution of Precision
ageMs: 140, // Milliseconds since last coordinate fix
searchTimeSec: 45, // Elapsed seconds since continuous satellite acquisition started
sentencesParsed: 182, // Valid NMEA sentences received
checksumErrors: 0, // Corrupt sentences rejected
charsProcessed: 14200, // Total serial bytes read from UART
currentBaud: 9600, // Active serial communication baud rate (38400 or 9600)
baudLocked: true, // True when auto-baud has verified framing & checksums
rawNmea: [ // Up to 4 latest checksum-verified raw NMEA sentences from UART
"$GNRMC,120000.00,A,3131.2222,N,07421.5248,E,0.0,0.0,081126,,,A*7C",
"$GNGGA,120000.00,3131.2222,N,07421.5248,E,1,08,1.1,214.5,M,,M,,*5A",
"$GNGSA,A,3,01,02,07,08,12,14,24,30,,,,,1.8,1.1,1.4*21",
"$GPGSV,3,1,09,01,40,083,38,02,17,308,32,07,22,154,35,08,66,039,41*7B"
]
}
21.3 Offline RTC & Clock Synchronization
GPS.getTime()
- Returns:
Object | null - Description: Returns current atomic time from GPS constellation.
{
year: 2026, month: 11, day: 7,
hour: 16, minute: 45, second: 12, centisecond: 30,
epochMs: 1731000000000
}
GPS.syncSystemTime()
- Returns:
Boolean - Description: Sets the hardware RTC (PCF8563) and ESP32 system clock using satellite atomic clock time.
21.4 Event-Driven Streaming
GPS.watchPosition(callback, [options])
- Parameters:
callback:Function(locationObject)options:Object({ minIntervalMs: 1000, minDistanceMeters: 2.0 })
- Returns:
Integer (watchId) - Description: Subscribes to live position updates. Automatically acquires an app hold.
GPS.clearWatch(watchId)
- Parameters:
watchId: Integer - Returns:
Boolean - Description: Cancels the position listener without shutting down the GNSS receiver.
21.5 Native C++ Geodesy & Math
GPS.distanceBetween(lat1, lon1, lat2, lon2)
- Returns:
Number - Description: Hardware-accelerated great-circle distance between two points in meters (Haversine formula).
GPS.courseTo(lat1, lon1, lat2, lon2)
- Returns:
Number - Description: Initial true bearing from point 1 to point 2 in degrees (0.0 to 359.9).
GPS.isInsideCircle(lat, lon, centerLat, centerLon, radiusMeters)
- Returns:
Boolean - Description: Ultra-fast radial geofence boundary test.
GPS.setRate(rateHz)
- Parameters:
rateHz: Integer(1,5, or10) - Returns:
Boolean - Description: Configures GNSS sentence reporting rate (
$PMTK220and$PCAS02).
GPS.getBaud()
- Returns:
Integer - Description: Returns the active UART communication speed in baud (e.g.
38400,9600, or115200) negotiated automatically by the kernel driver.
Take Apps and Games from KryonOS Official App Store Repository As Example: https://github.com/Haris16-code/KryonOS-AppStore
Document Version: 3.0.0