diff options
author | jskyboo <jack@ron.hog.mooo.info> | 2017-02-02 00:41:31 -0800 |
---|---|---|
committer | jskyboo <jack@ron.hog.mooo.info> | 2017-02-02 00:41:31 -0800 |
commit | 6924a2bf34a70cd33284a28ca3575f33f9834375 (patch) | |
tree | b16cca31c0974da3be92093fa514fc0d8ac0549f | |
parent | 121dd971194df28221a679d5ceda12d1fea614f1 (diff) | |
download | pfsense-6924a2bf34a70cd33284a28ca3575f33f9834375.zip pfsense-6924a2bf34a70cd33284a28ca3575f33f9834375.tar.gz |
Add to NTP GPS processing of PGRMF sentence
-rw-r--r-- | src/etc/inc/system.inc | 3 | ||||
-rw-r--r-- | src/usr/local/www/services_ntpd_gps.php | 16 | ||||
-rw-r--r-- | src/usr/local/www/status_ntpd.php | 13 | ||||
-rw-r--r-- | src/usr/local/www/widgets/widgets/ntp_status.widget.php | 13 |
4 files changed, 45 insertions, 0 deletions
diff --git a/src/etc/inc/system.inc b/src/etc/inc/system.inc index 296f610..1c3e102 100644 --- a/src/etc/inc/system.inc +++ b/src/etc/inc/system.inc @@ -1775,6 +1775,9 @@ function system_ntp_configure() { if (!empty($config['ntpd']['gps']['subsec'])) { $ntpmode += 128; } + if (!empty($config['ntpd']['gps']['processpgrmf'])) { + $ntpmode += 256; + } $ntpcfg .= (string) $ntpmode; } else { $ntpcfg .= '0'; diff --git a/src/usr/local/www/services_ntpd_gps.php b/src/usr/local/www/services_ntpd_gps.php index 4c5bc8c..1b4970d 100644 --- a/src/usr/local/www/services_ntpd_gps.php +++ b/src/usr/local/www/services_ntpd_gps.php @@ -173,6 +173,12 @@ if ($_POST) { } else { $config['ntpd']['gps']['nmea'] = strval(array_sum($_POST['gpsnmea'])); } + + if (!empty($_POST['processpgrmf'])) { + $config['ntpd']['gps']['processpgrmf'] = $_POST['processpgrmf']; + } elseif (isset($config['ntpd']['gps']['processpgrmf']) || $config['ntpd']['gps']['type'] !== 'Garmin') { + unset($config['ntpd']['gps']['processpgrmf']); + } if (!empty($_POST['gpsfudge1'])) { $config['ntpd']['gps']['fudge1'] = $_POST['gpsfudge1']; @@ -377,6 +383,13 @@ $section->addInput(new Form_Select( true ))->setHelp('By default NTP will listen for all supported NMEA sentences. One or more sentences to listen for may be specified.'); +$section->addInput(new Form_Checkbox( + 'processpgrmf', + null, + 'Process PGRMF. Ignores ALL other NMEA sentences. (default: unchecked).', + $pconfig['processpgrmf'] +)); + $section->addInput(new Form_Input( 'gpsfudge1', 'Fudge Time 1', @@ -588,6 +601,7 @@ events.push(function() { function set_gps_default(type) { $('#gpsnmea').val(0); + $('#processpgrmf').prop('checked', false); $('#gpsspeed').val(0); $('#gpsfudge1').val(0); $('#gpsinitcmd').val(get_gps_string(type)); @@ -686,7 +700,9 @@ events.push(function() { // When the 'GPS' selector is changed, we set the gps defaults $('#gpstype').on('change', function() { set_gps_default($(this).val()); + hideInput('processpgrmf', $(this).val() !== "Garmin"); }); + hideInput('processpgrmf', '<?=$pconfig['type']?>' !== "Garmin"); if ('<?=$pconfig['initcmd']?>' == '') { set_gps_default('<?=$pconfig['type']?>'); diff --git a/src/usr/local/www/status_ntpd.php b/src/usr/local/www/status_ntpd.php index 8436f6e..7ee0325 100644 --- a/src/usr/local/www/status_ntpd.php +++ b/src/usr/local/www/status_ntpd.php @@ -141,6 +141,19 @@ if (!isset($config['ntpd']['noquery'])) { $gps_lon = $gps_lon * (($gps_vars[4] == "E") ? 1 : -1); $gps_lat_dir = $gps_vars[2]; $gps_lon_dir = $gps_vars[4]; + } elseif (substr($tmp, 0, 6) == '$PGRMF') { + $gps_vars = preg_split('/[,\*]+/', $tmp); + $gps_ok = $gps_vars[11]; + $gps_lat_deg = substr($gps_vars[6], 0, 2); + $gps_lat_min = substr($gps_vars[6], 2); + $gps_lon_deg = substr($gps_vars[8], 0, 3); + $gps_lon_min = substr($gps_vars[8], 3); + $gps_lat = $gps_lat_deg + $gps_lat_min / 60.0; + $gps_lat = $gps_lat * (($gps_vars[7] == "N") ? 1 : -1); + $gps_lon = $gps_lon_deg + $gps_lon_min / 60.0; + $gps_lon = $gps_lon * (($gps_vars[9] == "E") ? 1 : -1); + $gps_lat_dir = $gps_vars[7]; + $gps_lon_dir = $gps_vars[9]; } } } diff --git a/src/usr/local/www/widgets/widgets/ntp_status.widget.php b/src/usr/local/www/widgets/widgets/ntp_status.widget.php index 04ef6c4..2bf2185 100644 --- a/src/usr/local/www/widgets/widgets/ntp_status.widget.php +++ b/src/usr/local/www/widgets/widgets/ntp_status.widget.php @@ -121,6 +121,19 @@ if ($_REQUEST['updateme']) { $gps_lon = $gps_lon * (($gps_vars[4] == "E") ? 1 : -1); $gps_lat_dir = $gps_vars[2]; $gps_lon_dir = $gps_vars[4]; + } elseif (substr($tmp, 0, 6) == '$PGRMF') { + $gps_vars = preg_split('/[,\*]+/', $tmp); + $gps_ok = $gps_vars[11]; + $gps_lat_deg = substr($gps_vars[6], 0, 2); + $gps_lat_min = substr($gps_vars[6], 2); + $gps_lon_deg = substr($gps_vars[8], 0, 3); + $gps_lon_min = substr($gps_vars[8], 3); + $gps_lat = $gps_lat_deg + $gps_lat_min / 60.0; + $gps_lat = $gps_lat * (($gps_vars[7] == "N") ? 1 : -1); + $gps_lon = $gps_lon_deg + $gps_lon_min / 60.0; + $gps_lon = $gps_lon * (($gps_vars[9] == "E") ? 1 : -1); + $gps_lat_dir = $gps_vars[7]; + $gps_lon_dir = $gps_vars[9]; } } } |