mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-16 09:34:39 +00:00
network time: fix several issues with gps settings
o Page did not work with translations. o Selected serial device wasn't shown. o Very old gpsport migration code zapped. o set_gps_default() must trigger on load.
This commit is contained in:
parent
f1c28948d1
commit
bb55f6c08a
@ -1405,9 +1405,9 @@ function system_ntp_setup_gps($serialport)
|
||||
symlink($serialport, $gps_device);
|
||||
|
||||
/* Send the following to the GPS port to initialize the GPS */
|
||||
if (is_array($config['ntpd']) && is_array($config['ntpd']['gps']) && !empty($config['ntpd']['gps']['type'])) {
|
||||
if (isset($config['ntpd']['gps'])) {
|
||||
$gps_init = base64_decode($config['ntpd']['gps']['initcmd']);
|
||||
}else{
|
||||
} else {
|
||||
$gps_init = base64_decode('JFBVQlgsNDAsR1NWLDAsMCwwLDAqNTkNCiRQVUJYLDQwLEdMTCwwLDAsMCwwKjVDDQokUFVCWCw0MCxaREEsMCwwLDAsMCo0NA0KJFBVQlgsNDAsVlRHLDAsMCwwLDAqNUUNCiRQVUJYLDQwLEdTViwwLDAsMCwwKjU5DQokUFVCWCw0MCxHU0EsMCwwLDAsMCo0RQ0KJFBVQlgsNDAsR0dBLDAsMCwwLDANCiRQVUJYLDQwLFRYVCwwLDAsMCwwDQokUFVCWCw0MCxSTUMsMCwwLDAsMCo0Ng0KJFBVQlgsNDEsMSwwMDA3LDAwMDMsNDgwMCwwDQokUFVCWCw0MCxaREEsMSwxLDEsMQ==');
|
||||
}
|
||||
|
||||
@ -1586,16 +1586,6 @@ function system_ntp_configure($start_ntpd = true)
|
||||
$ntpcfg .= $config['ntpd']['gps']['refid'];
|
||||
}
|
||||
$ntpcfg .= "\n";
|
||||
}elseif (!empty($config['ntpd']['gpsport'])
|
||||
&& file_exists('/dev/'.$config['ntpd']['gpsport'])
|
||||
&& system_ntp_setup_gps($config['ntpd']['gpsport'])) {
|
||||
/* This handles a 2.1 and earlier config */
|
||||
$ntpcfg .= "# GPS Setup\n";
|
||||
$ntpcfg .= "server 127.127.20.0 mode 0 minpoll 4 maxpoll 4 prefer\n";
|
||||
$ntpcfg .= "fudge 127.127.20.0 time1 0.155 time2 0.000 flag1 1 flag2 0 flag3 1\n";
|
||||
// Fall back to local clock if GPS is out of sync?
|
||||
$ntpcfg .= "server 127.127.1.0\n";
|
||||
$ntpcfg .= "fudge 127.127.1.0 stratum 12\n";
|
||||
}
|
||||
/* End GPS configuration */
|
||||
|
||||
|
||||
@ -52,11 +52,6 @@ if ($_POST) {
|
||||
elseif (isset($config['ntpd']['interface']))
|
||||
unset($config['ntpd']['interface']);
|
||||
|
||||
if (!empty($_POST['gpsport']) && file_exists('/dev/'.$_POST['gpsport']))
|
||||
$config['ntpd']['gpsport'] = $_POST['gpsport'];
|
||||
elseif (isset($config['ntpd']['gpsport']))
|
||||
unset($config['ntpd']['gpsport']);
|
||||
|
||||
unset($config['ntpd']['prefer']);
|
||||
unset($config['ntpd']['noselect']);
|
||||
$timeservers = '';
|
||||
|
||||
@ -2,8 +2,8 @@
|
||||
|
||||
/*
|
||||
Copyright (C) 2014-2015 Deciso B.V.
|
||||
Copyright (C) 2013 Dagorlad
|
||||
Copyright (C) 2012 Jim Pingle
|
||||
Copyright (C) 2013 Dagorlad
|
||||
Copyright (C) 2012 Jim Pingle
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
@ -33,38 +33,24 @@ require_once("services.inc");
|
||||
require_once("system.inc");
|
||||
require_once("interfaces.inc");
|
||||
|
||||
function set_default_gps() {
|
||||
global $config;
|
||||
|
||||
if (!isset($config['ntpd']) || !is_array($config['ntpd']))
|
||||
$config['ntpd'] = array();
|
||||
|
||||
if (!isset($config['ntpd']['gps'])) {
|
||||
$config['ntpd']['gps'] = array();
|
||||
$config['ntpd']['gps']['type'] = 'Generic';
|
||||
/* copy an existing configured GPS port if it exists, the unset may be uncommented post production */
|
||||
if (!empty($config['ntpd']['gpsport']) && empty($config['ntpd']['gps']['port'])) {
|
||||
$config['ntpd']['gps']['port'] = $config['ntpd']['gpsport'];
|
||||
unset($config['ntpd']['gpsport']); /* this removes the original port config from config.xml */
|
||||
$config['ntpd']['gps']['speed'] = 0;
|
||||
$config['ntpd']['gps']['nmea'] = 0;
|
||||
}
|
||||
|
||||
write_config("Setting default NTPd settings");
|
||||
}
|
||||
|
||||
if ($_POST) {
|
||||
|
||||
unset($input_errors);
|
||||
|
||||
if (!empty($_POST['gpsport']) && file_exists('/dev/'.$_POST['gpsport']))
|
||||
if (!empty($_POST['gpsport']) && file_exists('/dev/'.$_POST['gpsport'])) {
|
||||
$config['ntpd']['gps']['port'] = $_POST['gpsport'];
|
||||
/* if port is not set, remove all the gps config */
|
||||
else unset($config['ntpd']['gps']);
|
||||
} else if (isset($config['ntpd']['gps']['port'])) {
|
||||
unset($config['ntpd']['gps']['port']);
|
||||
}
|
||||
|
||||
if (!empty($_POST['gpstype']))
|
||||
if (!empty($_POST['gpstype'])) {
|
||||
$config['ntpd']['gps']['type'] = $_POST['gpstype'];
|
||||
elseif (isset($config['ntpd']['gps']['type']))
|
||||
} elseif (isset($config['ntpd']['gps']['type'])) {
|
||||
unset($config['ntpd']['gps']['type']);
|
||||
}
|
||||
|
||||
if (!empty($_POST['gpsspeed']))
|
||||
$config['ntpd']['gps']['speed'] = $_POST['gpsspeed'];
|
||||
@ -141,16 +127,13 @@ if ($_POST) {
|
||||
|
||||
$retval = system_ntp_configure();
|
||||
$savemsg = get_std_save_message();
|
||||
} else {
|
||||
/* set defaults if they do not already exist */
|
||||
if (empty($config['ntpd']['gps']['type'])) {
|
||||
set_default_gps();
|
||||
}
|
||||
}
|
||||
|
||||
$closehead = false;
|
||||
$pconfig = &$config['ntpd']['gps'];
|
||||
$pgtitle = array(gettext('Services'), gettext('Network Time'), gettext('GPS'));
|
||||
$shortcut_section = "ntp";
|
||||
|
||||
include("head.inc");
|
||||
?>
|
||||
|
||||
@ -250,7 +233,7 @@ SureGPS = #Sure Electronics SKG16B
|
||||
var gpsdef = new Object();
|
||||
//get the text description of the selected type
|
||||
var e = document.getElementById("gpstype");
|
||||
var type = e.options[e.selectedIndex].text;
|
||||
var type = e.options[e.selectedIndex].value;
|
||||
|
||||
//stuff the JS object as needed for each type
|
||||
switch(type) {
|
||||
@ -380,14 +363,14 @@ SureGPS = #Sure Electronics SKG16B
|
||||
<td width="78%" valign="top" class="vtable">
|
||||
<!-- Start with the original "Default", list a "Generic" and then specific configs alphabetically -->
|
||||
<select id="gpstype" name="gpstype" class="formselect" onchange="set_gps_default(this.form)">
|
||||
<option value="Custom"<?php if($pconfig['type'] == 'Custom') echo " selected=\"selected\""; ?>><?=gettext('Custom') ?></option>
|
||||
<option value="Generic" title="Generic"<?php if (empty($pconfig['type']) || $pconfig['type'] == 'Generic' ) echo " selected=\"selected\"";?>><?=gettext('Generic') ?></option>
|
||||
<option value="Default"<?php if($pconfig['type'] == 'Default') echo " selected=\"selected\""; ?>><?=gettext('Default') ?></option>
|
||||
<option value="Generic" title="Generic"<?php if($pconfig['type'] == 'Generic' ) echo " selected=\"selected\"";?>><?=gettext('Generic') ?></option>
|
||||
<option value="Garmin" title="$PGRM... Most Garmin"<?php if($pconfig['type'] == 'Garmin') echo " selected=\"selected\"";?>><?=gettext('Garmin') ?></option>
|
||||
<option value="MediaTek" title="$PMTK... Adafruit, Fastrax, some Garmin and others"<?php if($pconfig['type'] == 'MediaTek') echo " selected=\"selected\"";?>>MediaTek</option>
|
||||
<option value="SiRF" title="$PSRF... Used by many devices"<?php if($pconfig['type'] == 'sirf') echo " selected=\"selected\"";?>><?=gettext('SiRF') ?></option>
|
||||
<option value="U-Blox" title="$PUBX... U-Blox 5, 6 and probably 7"<?php if($pconfig['type'] == 'U-Blox') echo " selected=\"selected\"";?>><?=gettext('U-Blox') ?></option>
|
||||
<option value="SureGPS" title="$PMTK... Sure Electronics SKG16B"<?php if($pconfig['type'] == 'SureGPS') echo " selected=\"selected\"";?>><?=gettext('SureGPS') ?></option>
|
||||
<option value="Custom"<?php if($pconfig['type'] == 'Custom') echo " selected=\"selected\""; ?>><?=gettext('Custom') ?></option>
|
||||
</select> <?php echo gettext("This option allows you to select a predefined configuration.");?>
|
||||
<br />
|
||||
<br />
|
||||
@ -409,12 +392,13 @@ SureGPS = #Sure Electronics SKG16B
|
||||
<?php
|
||||
foreach ($serialports as $port):
|
||||
$shortport = substr($port,5);
|
||||
$selected = ($shortport == isset($pconfig['port'])?$pconfig['port']:null) ? " selected=\"selected\"" : "";
|
||||
$selected = '';
|
||||
if (isset($pconfig['port']) && $shortport === $pconfig['port']) {
|
||||
$selected = 'selected="selected"';
|
||||
}
|
||||
?>
|
||||
<option value="<?php echo $shortport;?>"<?php echo $selected;?>><?php echo $shortport;?></option>
|
||||
<?php
|
||||
endforeach;
|
||||
?>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<?php echo gettext("All serial ports are listed, be sure to pick the port with the GPS attached."); ?>
|
||||
<br /><br />
|
||||
@ -576,5 +560,10 @@ SureGPS = #Sure Electronics SKG16B
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
set_gps_default(document.getElementById('iform'));
|
||||
//]]>
|
||||
</script>
|
||||
|
||||
<?php include("foot.inc"); ?>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user