From b5ef680d78ab4844111a752c8954aee8efd8f43c Mon Sep 17 00:00:00 2001 From: Benjamin Faershtein <119711889+RCGV1@users.noreply.github.com> Date: Mon, 21 Apr 2025 22:24:53 -0700 Subject: [PATCH] Added flight mode build flag --- src/gps/GPS.cpp | 11 +++++++++++ src/gps/cas.h | 23 +++++++++++++++++++++++ src/gps/ubx.h | 20 ++++++++++++++++++++ userPrefs.jsonc | 1 + 4 files changed, 55 insertions(+) diff --git a/src/gps/GPS.cpp b/src/gps/GPS.cpp index 41a2ff980..f33c2d334 100644 --- a/src/gps/GPS.cpp +++ b/src/gps/GPS.cpp @@ -545,6 +545,12 @@ bool GPS::setup() } else if (gnssModel == GNSS_MODEL_ATGM336H) { // Set the intial configuration of the device - these _should_ work for most AT6558 devices msglen = makeCASPacket(0x06, 0x07, sizeof(_message_CAS_CFG_NAVX_CONF), _message_CAS_CFG_NAVX_CONF); + +#ifdef USERPREFS_GPS_FLIGHT_MODE + if (USERPREFS_GPS_FLIGHT_MODE) { + msglen = makeCASPacket(0x06, 0x07, sizeof(_message_CAS_CFG_NAVX_CONF_FLIGHT), _message_CAS_CFG_NAVX_CONF_FLIGHT); + } +#endif _serial_gps->write(UBXscratch, msglen); if (getACKCas(0x06, 0x07, 250) != GNSS_RESPONSE_OK) { LOG_WARN("ATGM336H: Could not set Config"); @@ -670,6 +676,11 @@ bool GPS::setup() } // Turn off unwanted NMEA messages, set update rate SEND_UBX_PACKET(0x06, 0x08, _message_1HZ, "set GPS update rate", 500); +#ifdef USERPREFS_GPS_FLIGHT_MODE + if (USERPREFS_GPS_FLIGHT_MODE) { + SEND_UBX_PACKET(0x06, 0x24, _message_NAV5_FLIGHT, "enable flight mode", 500); + } +#endif SEND_UBX_PACKET(0x06, 0x01, _message_GLL, "disable NMEA GLL", 500); SEND_UBX_PACKET(0x06, 0x01, _message_GSA, "enable NMEA GSA", 500); SEND_UBX_PACKET(0x06, 0x01, _message_GSV, "disable NMEA GSV", 500); diff --git a/src/gps/cas.h b/src/gps/cas.h index 725fd07b3..68bf998f3 100644 --- a/src/gps/cas.h +++ b/src/gps/cas.h @@ -61,3 +61,26 @@ static const uint8_t _message_CAS_CFG_NAVX_CONF[] = { 0x00, 0x00, 0x00, 0x00, // Time Accuracy Max 0x00, 0x00, 0x00, 0x00 // Static Hold Threshold }; + +static const uint8_t _message_CAS_CFG_NAVX_CONF_FLIGHT[] = { + 0x03, 0x01, 0x00, 0x00, // Update Mask: Dynamic Mode, Fix Mode, Nav Settings + 0x06, // Dynamic Mode: flight <2g + 0x03, // Fix Mode: Auto 2D/3D + 0x00, // Min SV + 0x00, // Max SVs + 0x00, // Min CNO + 0x00, // Reserved1 + 0x00, // Init 3D fix + 0x00, // Min Elevation + 0x00, // Dr Limit + 0x07, // Nav System: 2^0 = GPS, 2^1 = BDS 2^2 = GLONASS: 2^3 + // 3=GPS+BDS, 7=GPS+BDS+GLONASS + 0x00, 0x00, // Rollover Week + 0x00, 0x00, 0x00, 0x00, // Fix Altitude + 0x00, 0x00, 0x00, 0x00, // Fix Height Error + 0x00, 0x00, 0x00, 0x00, // PDOP Maximum + 0x00, 0x00, 0x00, 0x00, // TDOP Maximum + 0x00, 0x00, 0x00, 0x00, // Position Accuracy Max + 0x00, 0x00, 0x00, 0x00, // Time Accuracy Max + 0x00, 0x00, 0x00, 0x00 // Static Hold Threshold +}; diff --git a/src/gps/ubx.h b/src/gps/ubx.h index d674bed51..8201574dd 100644 --- a/src/gps/ubx.h +++ b/src/gps/ubx.h @@ -194,6 +194,26 @@ static const uint8_t _message_NAVX5_8[] = { 0x00 // useAdr }; +// Flight mode +static const uint8_t _message_NAV5_FLIGHT[] PROGMEM = { + 0xFF, 0xFF, // mask + 0x06, // dynModel + 0x02, // fixMode + 0x00, 0x00, 0x00, 0x00, // fixedAlt + 0x00, 0x00, 0x00, 0x00, // fixedAltVar + 0x05, // minElev + 0x00, // drLimit + 0xFA, 0x00, // pDop + 0xFA, 0x00, // tDop + 0x64, 0x00, // pAcc + 0x2C, 0x01, // tAcc + 0x00, // staticHoldThresh + 0x00, // dgpsTimeOut + 0x00, 0x00, 0x00, 0x00, // reserved2 + 0x00, 0x00, 0x00, 0x00, // reserved3 + 0x00, 0x00, 0x00, 0x00 // reserved4 +}; + // Set GPS update rate to 1Hz // Lowering the update rate helps to save power. // Additionally, for some new modules like the M9/M10, an update rate lower than 5Hz diff --git a/userPrefs.jsonc b/userPrefs.jsonc index d522ad272..aadd99685 100644 --- a/userPrefs.jsonc +++ b/userPrefs.jsonc @@ -29,6 +29,7 @@ // "USERPREFS_FIXED_GPS_LON": "2.294508368", // "USERPREFS_CONFIG_SMART_POSITION_ENABLED": "false", // "USERPREFS_CONFIG_GPS_UPDATE_INTERVAL": "600", + // "USERPREFS_GPS_FLIGHT_MODE": "true", // "USERPREFS_CONFIG_POSITION_BROADCAST_INTERVAL": "1800", // "USERPREFS_LORACONFIG_CHANNEL_NUM": "31", // "USERPREFS_LORACONFIG_MODEM_PRESET": "meshtastic_Config_LoRaConfig_ModemPreset_SHORT_FAST",