#$ TITLE: Custom NMEA commands
#$ FIRMWARE_VERSION: 4.5
#$ CATEGORY: OTHER
#$ STATUS: COMMUNITY
#$ KEYWORDS: gps, custom commands, nmea
#$ AUTHOR: KMfpv
#$ DESCRIPTION: GPS with NMEA protocol only (most non-UBLOX Modules) based on MediaTek or GoTop Chipsets
#$ DESCRIPTION: (like the MediaTek MT33xx Series or GoTop GK95xx Series) mostly don't have a 
#$ DESCRIPTION: dedicated flash chip for storing settings. Those GPS Modules tend to default to 
#$ DESCRIPTION: 9600 and 1 Hz, which is neither accurate nor near accurate.
#$ DESCRIPTION: So this is for all the cheapos and recylers (like me) out there,
#$ DESCRIPTION: using older GPS Modules from arduino times or safe some money by buying
#$ DESCRIPTION: E108-GN02D/GN01D, B&G0x, Beitian BN-180 and V.KEL
#$ DESCRIPTION: 
#$ DESCRIPTION: If your GPS Module is already wired up, use "gpspassthrough" in CLI, so
#$ DESCRIPTION: you should see the messages from the GPS Module. And if you can read the
#$ DESCRIPTION: scrolling messages (like $PMGSA.......) already, your baudrate is set
#$ DESCRIPTION: correctly. As a miniKwad pilot, you have a feeling for time, you should
#$ DESCRIPTION: be able to tell the refresh rate (4 Lines = 1 packet). 
#$ DESCRIPTION: 
#$ DESCRIPTION:  1 Hz =  4 lines (easy to read)
#$ DESCRIPTION:  5 Hz = 20 lines (easy to identify the messages)
#$ DESCRIPTION: 10 Hz = 40 lines (getting dizzy watching for minutes or hours)
#$ DESCRIPTION: 
#$ DESCRIPTION: Verify correct GPS settings with provided tool from <a href="https://github.com/betaflight/betaflight/issues/12239#issuecomment-1486572616" target="_blank">here</a>.
#$ DESCRIPTION: You can use this tool to test settings as needed, but remember, that betaflight only
#$ DESCRIPTION: uses GGA/RMC/GSV/GSA so don't enable more, as it doesn't help with performance.
#$ DESCRIPTION: 
#$ WARNING: hint by sugaarK: if you wana use the new rescue mode you can't use less than 57600 or 10 hz and have good results
#$ DISCUSSION: https://github.com/betaflight/betaflight/issues/12239; https://github.com/betaflight/betaflight/pull/12591

#$ INCLUDE_DISCLAIMER: misc/disclaimer/en/gps.txt

#$ INCLUDE: presets/4.5/other/reset_gps.txt

#disable gps auto config
set gps_auto_config = OFF

#$ OPTION_GROUP BEGIN: OUTPUT messages (needed once)
	#$ OPTION BEGIN (UNCHECKED): Mediatek 
		set gps_nmea_custom_command = $PMTK314,0,1,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0*28
	#$ OPTION END

	#$ OPTION BEGIN (UNCHECKED): GoTop
		set gps_nmea_custom_command = $PGKC242,0,1,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*37
	#$ OPTION END
#$ OPTION_GROUP END

#$ OPTION_GROUP BEGIN: BAUDRATE/UPDATE (38400/5Hz)
	#$ OPTION BEGIN (UNCHECKED): Mediatek MTK 
		set gps_nmea_custom_command = $PMTK251,38400*27 $PMTK220,200*2C
	#$ OPTION END

	#$ OPTION BEGIN (UNCHECKED): GoTop
		set gps_nmea_custom_command = $PMTK251,38400*27 $PGKC101,200*31

	#$ OPTION END
#$ OPTION_GROUP END

#$ OPTION_GROUP BEGIN: BAUDRATE/UPDATE (57600/5Hz)
	#$ OPTION BEGIN (UNCHECKED): Mediatek MTK 
		set gps_nmea_custom_command = $PMTK251,57600*2C $PMTK220,200*2C
	#$ OPTION END

	#$ OPTION BEGIN (UNCHECKED): GoTop
		set gps_nmea_custom_command = $PGKC147,57600*35 $PGKC101,200*31

	#$ OPTION END
#$ OPTION_GROUP END

#$ OPTION_GROUP BEGIN: BAUDRATE/UPDATE (57600/10Hz)
	#$ OPTION BEGIN (UNCHECKED): Mediatek MTK 
		set gps_nmea_custom_command = $PMTK251,57600*2C $PMTK220,100*2F
	#$ OPTION END

	#$ OPTION BEGIN (UNCHECKED): GoTop
		set gps_nmea_custom_command = $PGKC147,57600*35 $PGKC101,100*32
	#$ OPTION END
#$ OPTION_GROUP END

#$ OPTION_GROUP BEGIN: BAUDRATE/UPDATE (115200/5Hz)
	#$ OPTION BEGIN (UNCHECKED): Mediatek MTK 
		set gps_nmea_custom_command = $PMTK251,115200*1F $PMTK220,200*2C
	#$ OPTION END

	#$ OPTION BEGIN (UNCHECKED): GoTop
		set gps_nmea_custom_command = $PGKC147,115200*06 $PGKC101,200*31

	#$ OPTION END
#$ OPTION_GROUP END

#$ OPTION_GROUP BEGIN: BAUDRATE/UPDATE (115200/10Hz)
	#$ OPTION BEGIN (UNCHECKED): Mediatek MTK 
		set gps_nmea_custom_command = $PMTK251,115200*1F $PMTK220,100*2F
	#$ OPTION END

	#$ OPTION BEGIN (UNCHECKED): GoTop
		set gps_nmea_custom_command = $PGKC147,115200*06 $PGKC101,100*32
	#$ OPTION END
#$ OPTION_GROUP END
