UNPKG

@jbroll/nmea-simple

Version:

NMEA 0183 sentence parser and encoder

59 lines (58 loc) 2.35 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); // Map talker IDs to system IDs according to uBlox NMEA 4.1 spec function getTalkerSystemId(talkerId) { switch (talkerId) { case "GP": return 1; // GPS case "GL": return 2; // GLONASS (primary) case "GA": return 3; // Galileo case "GB": return 4; // BeiDou case "GQ": return 5; // QZSS // case "GL": return 6; // GLONASS (secondary) case "GI": return 7; // IRNSS/NavIC default: return 0; // Unknown/Combined } } exports.getTalkerSystemId = getTalkerSystemId; // Apply system-specific PRN offset based on uBlox NMEA 4.1 spec function adjustPRN(prn, systemId) { switch (systemId) { case 1: return prn; // GPS: no adjustment needed (1-32) case 2: // GLONASS (primary): no adjustment needed (65-96) case 6: return prn; // GLONASS (secondary): no adjustment needed (65-96) case 3: return prn + 100; // Galileo: add 100 (101-136) case 4: return prn + 200; // BeiDou: add 200 (201-235) case 5: return prn; // QZSS: no adjustment needed (193-197) case 7: return prn + 400; // IRNSS/NavIC: add 400 (401-414) default: return prn; // Unknown: no adjustment } } exports.adjustPRN = adjustPRN; // Validate PRN is in correct range for system according to uBlox NMEA 4.1 function validatePRN(prn, systemId) { switch (systemId) { case 1: return prn >= 1 && prn <= 32; // GPS case 2: // GLONASS (primary) case 6: return prn >= 65 && prn <= 96; // GLONASS (secondary) case 3: return prn >= 101 && prn <= 136; // Galileo case 4: return prn >= 201 && prn <= 235; // BeiDou case 5: return prn >= 193 && prn <= 197; // QZSS case 7: return prn >= 401 && prn <= 414; // IRNSS/NavIC default: return true; // Unknown: accept any } } exports.validatePRN = validatePRN; // Get the name of the GNSS system for a given system ID function getSystemName(systemId) { switch (systemId) { case 1: return "GPS"; case 2: case 6: return "GLONASS"; case 3: return "Galileo"; case 4: return "BeiDou"; case 5: return "QZSS"; case 7: return "IRNSS/NavIC"; default: return "Unknown"; } } exports.getSystemName = getSystemName;