Project

General

Profile

Download (26 KB) Statistics
| Branch: | Tag: | Revision:
1 aa2aebfd nagyrobi
<?php
2
/* $Id$ */
3
/*
4 29aef6c4 Jim Thompson
        Copyright (C) 2013-2014 Electric Sheep Fencing, LP
5 aa2aebfd nagyrobi
	Copyright (C) 2013	Dagorlad
6
	Copyright (C) 2012	Jim Pingle
7
	All rights reserved.
8
9
	Redistribution and use in source and binary forms, with or without
10
	modification, are permitted provided that the following conditions are met:
11
12
	1. Redistributions of source code must retain the above copyright notice,
13
	   this list of conditions and the following disclaimer.
14
15
	2. Redistributions in binary form must reproduce the above copyright
16
	   notice, this list of conditions and the following disclaimer in the
17
	   documentation and/or other materials provided with the distribution.
18
19
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
20
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
21
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
23
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28
	POSSIBILITY OF SUCH DAMAGE.
29
*/
30
/*
31
	pfSense_MODULE:	ntpd_gps
32
*/
33
34
##|+PRIV
35
##|*IDENT=page-services-ntpd-gps
36
##|*NAME=Services: NTP Serial GPS page
37
##|*DESCR=Allow access to the 'Services: NTP Serial GPS' page..
38
##|*MATCH=services_ntpd_gps.php*
39
##|-PRIV
40
41 a3498099 Ermal
require_once("guiconfig.inc");
42 aa2aebfd nagyrobi
43
function set_default_gps() {
44 a3498099 Ermal
	global $config;
45
46
	if (!is_array($config['ntpd']))
47
		$config['ntpd'] = array();
48 42b5c637 Renato Botelho
	if (is_array($config['ntpd']['gps']))
49 a3498099 Ermal
		unset($config['ntpd']['gps']);
50
51
	$config['ntpd']['gps'] = array();
52 aa2aebfd nagyrobi
	$config['ntpd']['gps']['type'] = 'Default';
53
	/* copy an existing configured GPS port if it exists, the unset may be uncommented post production */
54 a3498099 Ermal
	if (!empty($config['ntpd']['gpsport']) && empty($config['ntpd']['gps']['port'])) {
55 aa2aebfd nagyrobi
		$config['ntpd']['gps']['port'] = $config['ntpd']['gpsport'];
56 a3498099 Ermal
		unset($config['ntpd']['gpsport']); /* this removes the original port config from config.xml */
57
		$config['ntpd']['gps']['speed'] = 0;
58
		$config['ntpd']['gps']['nmea'] = 0;
59 aa2aebfd nagyrobi
	}
60 a3498099 Ermal
61
	write_config("Setting default NTPd settings");
62 aa2aebfd nagyrobi
}
63
64
if ($_POST) {
65
66
	unset($input_errors);
67
68 46f5ced5 Renato Botelho
	if (!empty($_POST['gpsport']) && file_exists('/dev/'.$_POST['gpsport']))
69
		$config['ntpd']['gps']['port'] = $_POST['gpsport'];
70
	/* if port is not set, remove all the gps config */
71
	else unset($config['ntpd']['gps']);
72
73
	if (!empty($_POST['gpstype']))
74 3be4caf9 Jean Cyr
		$config['ntpd']['gps']['type'] = $_POST['gpstype'];
75 46f5ced5 Renato Botelho
	elseif (isset($config['ntpd']['gps']['type']))
76
		unset($config['ntpd']['gps']['type']);
77
78
	if (!empty($_POST['gpsspeed']))
79
		$config['ntpd']['gps']['speed'] = $_POST['gpsspeed'];
80
	elseif (isset($config['ntpd']['gps']['speed']))
81
		unset($config['ntpd']['gps']['speed']);
82
83
	if (!empty($_POST['gpsnmea']) && ($_POST['gpsnmea'][0] === "0"))
84
		$config['ntpd']['gps']['nmea'] = "0";
85
	else
86
		$config['ntpd']['gps']['nmea'] = strval(array_sum($_POST['gpsnmea']));
87
88
	if (!empty($_POST['gpsfudge1']))
89
		$config['ntpd']['gps']['fudge1'] = $_POST['gpsfudge1'];
90
	elseif (isset($config['ntpd']['gps']['fudge1']))
91
		unset($config['ntpd']['gps']['fudge1']);
92
93
	if (!empty($_POST['gpsfudge2']))
94
		$config['ntpd']['gps']['fudge2'] = $_POST['gpsfudge2'];
95
	elseif (isset($config['ntpd']['gps']['fudge2']))
96
		unset($config['ntpd']['gps']['fudge2']);
97
98
	if (!empty($_POST['gpsstratum']) && ($_POST['gpsstratum']) < 17 )
99
		$config['ntpd']['gps']['stratum'] = $_POST['gpsstratum'];
100
	elseif (isset($config['ntpd']['gps']['stratum']))
101
		unset($config['ntpd']['gps']['stratum']);
102
103
	if (empty($_POST['gpsprefer']))
104
		$config['ntpd']['gps']['prefer'] = 'on';
105
	elseif (isset($config['ntpd']['gps']['prefer']))
106
		unset($config['ntpd']['gps']['prefer']);
107
108
	if (!empty($_POST['gpsselect']))
109
		$config['ntpd']['gps']['noselect'] = $_POST['gpsselect'];
110
	elseif (isset($config['ntpd']['gps']['noselect']))
111
		unset($config['ntpd']['gps']['noselect']);
112
113
	if (!empty($_POST['gpsflag1']))
114
		$config['ntpd']['gps']['flag1'] = $_POST['gpsflag1'];
115
	elseif (isset($config['ntpd']['gps']['flag1']))
116
		unset($config['ntpd']['gps']['flag1']);
117
118
	if (!empty($_POST['gpsflag2']))
119
		$config['ntpd']['gps']['flag2'] = $_POST['gpsflag2'];
120
	elseif (isset($config['ntpd']['gps']['flag2']))
121
		unset($config['ntpd']['gps']['flag2']);
122
123
	if (!empty($_POST['gpsflag3']))
124
		$config['ntpd']['gps']['flag3'] = $_POST['gpsflag3'];
125
	elseif (isset($config['ntpd']['gps']['flag3']))
126
		unset($config['ntpd']['gps']['flag3']);
127
128
	if (!empty($_POST['gpsflag4']))
129
		$config['ntpd']['gps']['flag4'] = $_POST['gpsflag4'];
130
	elseif (isset($config['ntpd']['gps']['flag4']))
131
		unset($config['ntpd']['gps']['flag4']);
132
133
	if (!empty($_POST['gpssubsec']))
134
		$config['ntpd']['gps']['subsec'] = $_POST['gpssubsec'];
135
	elseif (isset($config['ntpd']['gps']['subsec']))
136
		unset($config['ntpd']['gps']['subsec']);
137
138
	if (!empty($_POST['gpsrefid']))
139
		$config['ntpd']['gps']['refid'] = $_POST['gpsrefid'];
140
	elseif (isset($config['ntpd']['gps']['refid']))
141
		unset($config['ntpd']['gps']['refid']);
142 42b5c637 Renato Botelho
143 46f5ced5 Renato Botelho
	if (!empty($_POST['gpsinitcmd']))
144
		$config['ntpd']['gps']['initcmd'] = base64_encode($_POST['gpsinitcmd']);
145
	elseif (isset($config['ntpd']['gps']['initcmd']))
146
		unset($config['ntpd']['gps']['initcmd']);
147
148
	write_config("Updated NTP GPS Settings");
149
150
	$retval = system_ntp_configure();
151
	$savemsg = get_std_save_message($retval);
152 a3498099 Ermal
} else {
153 aa2aebfd nagyrobi
	/* set defaults if they do not already exist */
154 a3498099 Ermal
	if (!is_array($config['ntpd']) || !is_array($config['ntpd']['gps']) || empty($config['ntpd']['gps']['type'])) {
155 aa2aebfd nagyrobi
		set_default_gps();
156
	}
157
}
158 9c37d703 Colin Fleming
$closehead = false;
159 aa2aebfd nagyrobi
$pconfig = &$config['ntpd']['gps'];
160
$pgtitle = array(gettext("Services"),gettext("NTP GPS"));
161
$shortcut_section = "ntp";
162
include("head.inc");
163
?>
164
165
<script type="text/javascript">
166 9c37d703 Colin Fleming
//<![CDATA[
167 aa2aebfd nagyrobi
	function show_advanced(showboxID, configvalueID) {
168
		document.getElementById(showboxID).innerHTML='';
169
		aodiv = document.getElementById(configvalueID);
170
		aodiv.style.display = "block";
171
	}
172 42b5c637 Renato Botelho
173 aa2aebfd nagyrobi
	function ToggleOther(clicked, checkOff) {
174
		if (document.getElementById(clicked).checked) {
175
			document.getElementById(checkOff).checked=false;
176
		}
177
	}
178
179 f9f3e44c Renato Botelho
/*
180 aa2aebfd nagyrobi
init commands are Base64 encoded
181
Default =	#Sponsored, probably a Ublox
182
		$PUBX,40,GSV,0,0,0,0*59
183
		$PUBX,40,GLL,0,0,0,0*5C
184
		$PUBX,40,ZDA,0,0,0,0*44
185
		$PUBX,40,VTG,0,0,0,0*5E
186
		$PUBX,40,GSV,0,0,0,0*59
187
		$PUBX,40,GSA,0,0,0,0*4E
188
		$PUBX,40,GGA,0,0,0,0
189
		$PUBX,40,TXT,0,0,0,0
190
		$PUBX,40,RMC,0,0,0,0*46
191
		$PUBX,41,1,0007,0003,4800,0
192
		$PUBX,40,ZDA,1,1,1,1
193
194
Generic =					#do nothing
195 42b5c637 Renato Botelho
196 aa2aebfd nagyrobi
Garmin =	#most Garmin
197
		$PGRMC,,,,,,,,,,3,,2,4*52	#enable PPS @ 100ms
198
		$PGRMC1,,1,,,,,,W,,,,,,,*30	#enable WAAS
199
		$PGRMO,,3*74			#turn off all sentences
200
		$PGRMO,GPRMC,1*3D		#enable RMC
201
		$PGRMO,GPGGA,1*20		#enable GGA
202
		$PGRMO,GPGLL,1*26		#enable GLL
203
204
MediaTek =	#Adafruit, Fastrax, some Garmin and others
205
		$PMTK225,0*2B			#normal power mode
206
		$PMTK314,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0*28	#enable GLL, RMC, GGA and ZDA
207
		$PMTK301,2*2E			#enable WAAS
208
		$PMTK320,0*2F			#power save off
209
		$PMTK330,0*2E			#set WGS84 datum
210
		$PMTK386,0*23			#disable static navigation (MT333X)
211
		$PMTK397,0*23			#disable static navigation (MT332X)
212
		$PMTK251,4800*14		#4800 baud rate
213
214
SiRF =		#used by many devices
215 42b5c637 Renato Botelho
		$PSRF103,00,00,01,01*25		#turn on GGA
216 aa2aebfd nagyrobi
		$PSRF103,01,00,01,01*24		#turn on GLL
217
		$PSRF103,02,00,00,01*24		#turn off GSA
218
		$PSRF103,03,00,00,01*24		#turn off GSV
219
		$PSRF103,04,00,01,01*24		#turn on RMC
220
		$PSRF103,05,00,00,01*24		#turn off VTG
221
		$PSRF100,1,4800,8,1,0*0E	#set port to 4800,N,8,1
222
223
U-Blox =	#U-Blox 5, 6 and probably 7
224
		$PUBX,40,GGA,1,1,1,1,0,0*5A	#turn on GGA all ports
225
		$PUBX,40,GLL,1,1,1,1,0,0*5C	#turn on GLL all ports
226
		$PUBX,40,GSA,0,0,0,0,0,0*4E	#turn off GSA all ports
227
		$PUBX,40,GSV,0,0,0,0,0,0*59	#turn off GSV all ports
228
		$PUBX,40,RMC,1,1,1,1,0,0*47	#turn on RMC all ports
229
		$PUBX,40,VTG,0,0,0,0,0,0*5E	#turn off VTG all ports
230
		$PUBX,40,GRS,0,0,0,0,0,0*5D	#turn off GRS all ports
231
		$PUBX,40,GST,0,0,0,0,0,0*5B	#turn off GST all ports
232
		$PUBX,40,ZDA,1,1,1,1,0,0*44	#turn on ZDA all ports
233
		$PUBX,40,GBS,0,0,0,0,0,0*4D	#turn off GBS all ports
234
		$PUBX,40,DTM,0,0,0,0,0,0*46	#turn off DTM all ports
235
		$PUBX,40,GPQ,0,0,0,0,0,0*5D	#turn off GPQ all ports
236
		$PUBX,40,TXT,0,0,0,0,0,0*43	#turn off TXT all ports
237
		$PUBX,40,THS,0,0,0,0,0,0*54	#turn off THS all ports (U-Blox 6)
238
		$PUBX,41,1,0007,0003,4800,0*13	# set port 1 to 4800 baud
239 42b5c637 Renato Botelho
240 aa2aebfd nagyrobi
SureGPS = 		#Sure Electronics SKG16B
241
		$PMTK225,0*2B
242
		$PMTK314,1,1,0,1,0,5,0,0,0,0,0,0,0,0,0,0,0,1,0*2D
243
		$PMTK301,2*2E
244
		$PMTK397,0*23
245
		$PMTK102*31
246
		$PMTK313,1*2E
247
		$PMTK513,1*28
248
		$PMTK319,0*25
249
		$PMTK527,0.00*00
250
		$PMTK251,9600*17	#really needs to work at 9600 baud
251 42b5c637 Renato Botelho
252 f9f3e44c Renato Botelho
*/
253 aa2aebfd nagyrobi
254
	function set_gps_default(form) {
255
		//This handles a new config and also a reset to a defined default config
256
		var gpsdef = new Object();
257
		//get the text description of the selected type
258
		var e = document.getElementById("gpstype");
259
		var type = e.options[e.selectedIndex].text;
260
261
		//stuff the JS object as needed for each type
262
		switch(type) {
263
			case "Default":
264
				gpsdef['nmea'] = 0;
265
				gpsdef['speed'] = 0;
266
				gpsdef['fudge1'] = "0.155";
267
				gpsdef['fudge2'] = "";
268
				gpsdef['inittxt'] = "JFBVQlgsNDAsR1NWLDAsMCwwLDAqNTkNCiRQVUJYLDQwLEdMTCwwLDAsMCwwKjVDDQokUFVCWCw0MCxaREEsMCwwLDAsMCo0NA0KJFBVQlgsNDAsVlRHLDAsMCwwLDAqNUUNCiRQVUJYLDQwLEdTViwwLDAsMCwwKjU5DQokUFVCWCw0MCxHU0EsMCwwLDAsMCo0RQ0KJFBVQlgsNDAsR0dBLDAsMCwwLDANCiRQVUJYLDQwLFRYVCwwLDAsMCwwDQokUFVCWCw0MCxSTUMsMCwwLDAsMCo0Ng0KJFBVQlgsNDEsMSwwMDA3LDAwMDMsNDgwMCwwDQokUFVCWCw0MCxaREEsMSwxLDEsMQ0K";
269
				break;
270
271
			case "Garmin":
272
				gpsdef['nmea'] = 0;
273
				gpsdef['speed'] = 0;
274
				gpsdef['fudge1'] = "";
275
				gpsdef['fudge2'] = "0.600";
276
				gpsdef['inittxt'] = "JFBHUk1DLCwsLCwsLCwsLDMsLDIsOCo1RQ0KJFBHUk1DMSwsMSwsLCwsLFcsLCwsLCwsKjMwDQokUEdSTU8sLDMqNzQNCiRQR1JNTyxHUFJNQywxKjNEDQokUEdSTU8sR1BHR0EsMSoyMA0KJFBHUk1PLEdQR0xMLDEqMjYNCg==";
277
				break;
278 42b5c637 Renato Botelho
279 aa2aebfd nagyrobi
			case "Generic":
280
				gpsdef['nmea'] = 0;
281
				gpsdef['speed'] = 0;
282
				gpsdef['fudge1'] = "";
283
				gpsdef['fudge2'] = "0.400";
284
				gpsdef['inittxt'] = "";
285
				break;
286
287
			case "MediaTek":
288
				gpsdef['nmea'] = 0;
289
				gpsdef['speed'] = 0;
290
				gpsdef['fudge1'] = "";
291
				gpsdef['fudge2'] = "0.400";
292
				gpsdef['inittxt'] = "JFBNVEsyMjUsMCoyQg0KJFBNVEszMTQsMSwxLDAsMSwwLDAsMCwwLDAsMCwwLDAsMCwwLDAsMCwwLDEsMCoyOA0KJFBNVEszMDEsMioyRQ0KJFBNVEszMjAsMCoyRg0KJFBNVEszMzAsMCoyRQ0KJFBNVEszODYsMCoyMw0KJFBNVEszOTcsMCoyMw0KJFBNVEsyNTEsNDgwMCoxNA0K";
293
				break;
294
295
			case "SiRF":
296
				gpsdef['nmea'] = 0;
297
				gpsdef['speed'] = 0;
298
				gpsdef['fudge1'] = "";
299
				gpsdef['fudge2'] = "0.704"; //valid for 4800, 0.688 @ 9600, 0.640 @ USB
300
				gpsdef['inittxt'] = "JFBTUkYxMDMsMDAsMDAsMDEsMDEqMjUNCiRQU1JGMTAzLDAxLDAwLDAxLDAxKjI0DQokUFNSRjEwMywwMiwwMCwwMCwwMSoyNA0KJFBTUkYxMDMsMDMsMDAsMDAsMDEqMjQNCiRQU1JGMTAzLDA0LDAwLDAxLDAxKjI0DQokUFNSRjEwMywwNSwwMCwwMCwwMSoyNA0KJFBTUkYxMDAsMSw0ODAwLDgsMSwwKjBFDQo=";
301
				break;
302
303
			case "U-Blox":
304
				gpsdef['nmea'] = 0;
305
				gpsdef['speed'] = 0;
306
				gpsdef['fudge1'] = "";
307
				gpsdef['fudge2'] = "0.400";
308
				gpsdef['inittxt'] = "JFBVQlgsNDAsR0dBLDEsMSwxLDEsMCwwKjVBDQokUFVCWCw0MCxHTEwsMSwxLDEsMSwwLDAqNUMNCiRQVUJYLDQwLEdTQSwwLDAsMCwwLDAsMCo0RQ0KJFBVQlgsNDAsR1NWLDAsMCwwLDAsMCwwKjU5DQokUFVCWCw0MCxSTUMsMSwxLDEsMSwwLDAqNDcNCiRQVUJYLDQwLFZURywwLDAsMCwwLDAsMCo1RQ0KJFBVQlgsNDAsR1JTLDAsMCwwLDAsMCwwKjVEDQokUFVCWCw0MCxHU1QsMCwwLDAsMCwwLDAqNUINCiRQVUJYLDQwLFpEQSwxLDEsMSwxLDAsMCo0NA0KJFBVQlgsNDAsR0JTLDAsMCwwLDAsMCwwKjREDQokUFVCWCw0MCxEVE0sMCwwLDAsMCwwLDAqNDYNCiRQVUJYLDQwLEdQUSwwLDAsMCwwLDAsMCo1RA0KJFBVQlgsNDAsVFhULDAsMCwwLDAsMCwwKjQzDQokUFVCWCw0MCxUSFMsMCwwLDAsMCwwLDAqNTQNCiRQVUJYLDQxLDEsMDAwNywwMDAzLDQ4MDAsMCoxMw0K";
309
				break;
310
311
			case "SureGPS":
312 151693da nagyrobi
				gpsdef['nmea'] = 1;
313 aa2aebfd nagyrobi
				gpsdef['speed'] = 16;
314
				gpsdef['fudge1'] = "";
315 151693da nagyrobi
				gpsdef['fudge2'] = "0.407";
316 aa2aebfd nagyrobi
				gpsdef['inittxt'] = "JFBNVEsyMjUsMCoyQg0KJFBNVEszMTQsMSwxLDAsMSwwLDUsMCwwLDAsMCwwLDAsMCwwLDAsMCwwLDEsMCoyRA0KJFBNVEszMDEsMioyRQ0KJFBNVEszOTcsMCoyMw0KJFBNVEsxMDIqMzENCiRQTVRLMzEzLDEqMkUNCiRQTVRLNTEzLDEqMjgNCiRQTVRLMzE5LDAqMjUNCiRQTVRLNTI3LDAuMDAqMDANCiRQTVRLMjUxLDk2MDAqMTcNCg==";
317
				break;
318 8e2a4091 Renato Botelho
			default:
319
				return;
320
		}
321 aa2aebfd nagyrobi
322
		//then update the html and set the common stuff
323
		document.getElementById("gpsnmea").selectedIndex = gpsdef['nmea'];
324
		document.getElementById("gpsspeed").selectedIndex = gpsdef['speed'];
325
		form.gpsfudge1.value = gpsdef['fudge1'];
326
		form.gpsfudge2.value = gpsdef['fudge2'];
327
		form.gpsstratum.value = "";
328
		form.gpsrefid.value = "";
329
		form.gpsspeed.value = gpsdef['speed'];
330
		document.getElementById("gpsflag1").checked=true
331
		document.getElementById("gpsflag2").checked=false
332
		document.getElementById("gpsflag3").checked=true
333
		document.getElementById("gpsflag4").checked=false
334
		document.getElementById("gpssubsec").checked=false
335
		form.gpsinitcmd.value = atob(gpsdef['inittxt']);
336
	}
337
338
	//function to compute a NMEA checksum derived from the public domain function at http://www.hhhh.org/wiml/proj/nmeaxor.html
339
	function NMEAChecksum(cmd) {
340
		// Compute the checksum by XORing all the character values in the string.
341
		var checksum = 0;
342
		for(var i = 0; i < cmd.length; i++) {
343
			checksum = checksum ^ cmd.charCodeAt(i);
344
		}
345
		// Convert it to hexadecimal (base-16, upper case, most significant byte first).
346
		var hexsum = Number(checksum).toString(16).toUpperCase();
347
		if (hexsum.length < 2) {
348
			hexsum = ("00" + hexsum).slice(-2);
349
		}
350
		// Display the result
351
		document.getElementById("nmeachecksum").innerHTML = hexsum;
352
	}
353 9c37d703 Colin Fleming
//]]>
354 aa2aebfd nagyrobi
</script>
355 9c37d703 Colin Fleming
</head>
356 aa2aebfd nagyrobi
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
357
<?php include("fbegin.inc"); ?>
358
<form action="services_ntpd_gps.php" method="post" name="iform" id="iform" accept-charset="utf-8">
359
<?php if ($input_errors) print_input_errors($input_errors); ?>
360
<?php if ($savemsg) print_info_box($savemsg); ?>
361
362 9c37d703 Colin Fleming
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="ntpd gps">
363 42b5c637 Renato Botelho
	<tr><td>
364 aa2aebfd nagyrobi
<?php
365 f9f3e44c Renato Botelho
		$tab_array = array();
366
		$tab_array[] = array(gettext("NTP"), false, "services_ntpd.php");
367
		$tab_array[] = array(gettext("Serial GPS"), true, "services_ntpd_gps.php");
368
		$tab_array[] = array(gettext("PPS"), false, "services_ntpd_pps.php");
369
		display_top_tabs($tab_array);
370 aa2aebfd nagyrobi
?>
371 42b5c637 Renato Botelho
	</td></tr>
372
	<tr><td>
373 aa2aebfd nagyrobi
	<div id="mainarea">
374 9c37d703 Colin Fleming
	<table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area">
375 aa2aebfd nagyrobi
		<tr>
376
			<td colspan="2" valign="top" class="listtopic"><?=gettext("NTP Serial GPS Configuration"); ?></td>
377
		</tr>
378
		<tr>
379
			<td width="22%" valign="top" class="vncellreq">
380
			</td>
381
			<td width="78%" class="vtable">A GPS connected via a serial port may be used as a reference clock for NTP. If the GPS also supports PPS and is properly configured, and connected, that GPS may also be used as a Pulse Per Second clock reference. NOTE: a USB GPS may work, but is not recommended due to USB bus timing issues.
382 8cd558b6 ayvis
			<br />
383
			<br /><?php echo gettext("For the best results, NTP should have at least three sources of time. So it is best to configure at least 2 servers under"); ?> <a href="services_ntpd.php"><?php echo gettext("Services > NTP"); ?></a> <?php echo gettext("to minimize clock drift if the GPS data is not valid over time. Otherwise ntpd may only use values from the unsynchronized local clock when providing time to clients."); ?>
384 aa2aebfd nagyrobi
			</td>
385
		</tr>
386
		<tr>
387
			<td width="22%" valign="top" class="vncellreq"><?=gettext("GPS"); ?></td>
388
			<td width="78%" valign="top" class="vtable">
389 f9f3e44c Renato Botelho
				<!-- Start with the original "Default", list a "Generic" and then specific configs alphabetically -->
390 aa2aebfd nagyrobi
				<select id="gpstype" name="gpstype" class="formselect" onchange="set_gps_default(this.form)">
391 8e2a4091 Renato Botelho
					<option value="Custom"<?php if($pconfig['type'] == 'Custom') echo " selected=\"selected\""; ?>>Custom</option>
392 9c37d703 Colin Fleming
					<option value="Default"<?php if($pconfig['type'] == 'Default') echo " selected=\"selected\""; ?>>Default</option>
393
					<option value="Generic" title="Generic"<?php if($pconfig['type'] == 'Generic') echo " selected=\"selected\"";?>>Generic</option>
394
					<option value="Garmin" title="$PGRM... Most Garmin"<?php if($pconfig['type'] == 'Garmin') echo " selected=\"selected\"";?>>Garmin</option>
395
					<option value="MediaTek" title="$PMTK... Adafruit, Fastrax, some Garmin and others"<?php if($pconfig['type'] == 'MediaTek') echo " selected=\"selected\"";?>>MediaTek</option>
396
					<option value="SiRF" title="$PSRF... Used by many devices"<?php if($pconfig['type'] == 'sirf') echo " selected=\"selected\"";?>>SiRF</option>
397
					<option value="U-Blox" title="$PUBX... U-Blox 5, 6 and probably 7"<?php if($pconfig['type'] == 'U-Blox') echo " selected=\"selected\"";?>>U-Blox</option>
398
					<option value="SureGPS" title="$PMTK... Sure Electronics SKG16B"<?php if($pconfig['type'] == 'SureGPS') echo " selected=\"selected\"";?>>SureGPS</option>
399 aa2aebfd nagyrobi
				</select> <?php echo gettext("This option allows you to select a predefined configuration.");?>
400 8cd558b6 ayvis
				<br />
401
				<br />
402 f9f3e44c Renato Botelho
				<strong><?php echo gettext("Note: ");?></strong><?php echo gettext("Default is the configuration of pfSense 2.1 and earlier"); ?>
403
				<?php echo gettext(" (not recommended). Select Generic if your GPS is not listed.)"); ?><br />
404
				<strong><?php echo gettext("Note: ");?></strong><?php echo gettext("The perdefined configurations assume your GPS has already been set to NMEA mode."); ?>
405 aa2aebfd nagyrobi
			</td>
406
		</tr>
407
408 f9f3e44c Renato Botelho
<?php
409
	/* Probing would be nice, but much more complex. Would need to listen to each port for 1s+ and watch for strings. */
410
	$serialports = glob("/dev/cua?[0-9]{,.[0-9]}", GLOB_BRACE);
411
	if (!empty($serialports)):
412
?>
413 aa2aebfd nagyrobi
		<tr>
414
			<td width="22%" valign="top" class="vncellreq">Serial port</td>
415
			<td width="78%" class="vtable">
416
				<select name="gpsport" class="formselect">
417
					<option value="">none</option>
418 f9f3e44c Renato Botelho
<?php
419
				foreach ($serialports as $port):
420
					$shortport = substr($port,5);
421
					$selected = ($shortport == $pconfig['port']) ? " selected=\"selected\"" : "";
422
?>
423
					<option value="<?php echo $shortport;?>"<?php echo $selected;?>><?php echo $shortport;?></option>
424
<?php
425
				endforeach;
426
?>
427 aa2aebfd nagyrobi
				</select>&nbsp;
428
				<?php echo gettext("All serial ports are listed, be sure to pick the port with the GPS attached."); ?>
429 8cd558b6 ayvis
				<br /><br />
430 aa2aebfd nagyrobi
				<select id="gpsspeed" name="gpsspeed" class="formselect">
431 9c37d703 Colin Fleming
					<option value="0"<?php if(!$pconfig['speed']) echo " selected=\"selected\""; ?>>4800</option>
432
					<option value="16"<?php if($pconfig['speed'] === '16') echo " selected=\"selected\"";?>>9600</option>
433
					<option value="32"<?php if($pconfig['speed'] === '32') echo " selected=\"selected\"";?>>19200</option>
434
					<option value="48"<?php if($pconfig['speed'] === '48') echo " selected=\"selected\"";?>>38400</option>
435
					<option value="64"<?php if($pconfig['speed'] === '64') echo " selected=\"selected\"";?>>57600</option>
436
					<option value="80"<?php if($pconfig['speed'] === '80') echo " selected=\"selected\"";?>>115200</option>
437 aa2aebfd nagyrobi
				</select>&nbsp;<?php echo gettext("Serial port baud rate."); ?>
438 8cd558b6 ayvis
				<br />
439
				<br />
440 aa2aebfd nagyrobi
				<?php echo gettext("Note: A higher baud rate is generally only helpful if the GPS is sending too many sentences. It is recommended to configure the GPS to send only one sentence at a baud rate of 4800 or 9600."); ?>
441
			</td>
442
		</tr>
443 f9f3e44c Renato Botelho
<?php
444
	endif;
445
?>
446 aa2aebfd nagyrobi
		<tr>
447 f9f3e44c Renato Botelho
			<!-- 1 = RMC, 2 = GGA, 4 = GLL, 8 = ZDA or ZDG -->
448 aa2aebfd nagyrobi
			<td width="22%" valign="top" class="vncellreq">NMEA sentences</td>
449
			<td width="78%" class="vtable">
450 151693da nagyrobi
				<select id="gpsnmea" name="gpsnmea[]" multiple="multiple" class="formselect" size="5">
451 9c37d703 Colin Fleming
					<option value="0"<?php if(!$pconfig['nmea']) echo " selected=\"selected\""; ?>>All</option>
452 151693da nagyrobi
					<option value="1"<?php if($pconfig['nmea'] & 1) echo " selected=\"selected\"";?>>RMC</option>
453 9c37d703 Colin Fleming
					<option value="2"<?php if($pconfig['nmea'] & 2) echo " selected=\"selected\"";?>>GGA</option>
454
					<option value="4"<?php if($pconfig['nmea'] & 4) echo " selected=\"selected\"";?>>GLL</option>
455
					<option value="8"<?php if($pconfig['nmea'] & 8) echo " selected=\"selected\"";?>>ZDA or ZDG</option>
456 8cd558b6 ayvis
				</select><br />
457 aa2aebfd nagyrobi
				<?php echo gettext("By default NTP will listen for all supported NMEA sentences. Here one or more sentences to listen for may be specified."); ?>
458
			</td>
459
		</tr>
460
		<tr>
461
			<td width="22%" valign="top" class="vncellreq">Fudge time 1</td>
462
			<td width="78%" class="vtable">
463 9c37d703 Colin Fleming
				<input name="gpsfudge1" type="text" class="formfld unknown" id="gpsfudge1" min="-1" max="1" size="20" value="<?=htmlspecialchars($pconfig['fudge1']);?>" />(<?php echo gettext("seconds");?>)<br />
464 aa2aebfd nagyrobi
				<?php echo gettext("Fudge time 1 is used to specify the GPS PPS signal offset");?> (<?php echo gettext("default");?>: 0.0).</td>
465
		</tr>
466
		<tr>
467
			<td width="22%" valign="top" class="vncellreq">Fudge time 2</td>
468
			<td width="78%" class="vtable">
469 9c37d703 Colin Fleming
				<input name="gpsfudge2" type="text" class="formfld unknown" id="gpsfudge2" min="-1" max="1" size="20" value="<?=htmlspecialchars($pconfig['fudge2']);?>" />(<?php echo gettext("seconds");?>)<br />
470 aa2aebfd nagyrobi
				<?php echo gettext("Fudge time 2 is used to specify the GPS time offset");?> (<?php echo gettext("default");?>: 0.0).</td>
471
		</tr>
472
		<tr>
473
			<td width="22%" valign="top" class="vncellreq">Stratum</td>
474
			<td width="78%" class="vtable">
475 9c37d703 Colin Fleming
				<input name="gpsstratum" type="text" class="formfld unknown" id="gpsstratum" max="16" size="20" value="<?=htmlspecialchars($pconfig['stratum']);?>" /><?php echo gettext("(0-16)");?><br />
476 aa2aebfd nagyrobi
				<?php echo gettext("This may be used to change the GPS Clock stratum");?> (<?php echo gettext("default");?>: 0). <?php echo gettext("This may be useful if, for some reason, you want ntpd to prefer a different clock"); ?></td>
477
		</tr>
478
		<tr>
479
			<td width="22%" valign="top" class="vncellreq">Flags</td>
480
			<td width="78%" class="vtable">
481
				<table>
482
					<tr>
483
						<td>
484 8cd558b6 ayvis
				<?php echo gettext("Normally there should be no need to change these options from the defaults."); ?><br />
485 aa2aebfd nagyrobi
						</td>
486
					</tr>
487
				</table>
488
				<table>
489
					<tr>
490
						<td>
491 9c37d703 Colin Fleming
							<input name="gpsprefer" type="checkbox" class="formcheckbox" id="gpsprefer" onclick="ToggleOther('gpsprefer', 'gpsselect')"<?php if(!$pconfig['prefer']) echo " checked=\"checked\""; ?> />
492 aa2aebfd nagyrobi
						</td>
493
						<td>
494
							<span class="vexpl"><?php echo gettext("NTP should prefer this clock (default: enabled)."); ?></span>
495
						</td>
496
					</tr>
497
					<tr>
498
						<td>
499 9c37d703 Colin Fleming
							<input name="gpsselect" type="checkbox" class="formcheckbox" id="gpsselect" onclick="ToggleOther('gpsselect', 'gpsprefer')"<?php if($pconfig['noselect']) echo " checked=\"checked\""; ?> />
500 aa2aebfd nagyrobi
						</td>
501
						<td>
502
							<span class="vexpl"><?php echo gettext("NTP should not use this clock, it will be displayed for reference only(default: disabled)."); ?></span>
503
						</td>
504
					</tr>
505
					<tr>
506
						<td>
507 9c37d703 Colin Fleming
							<input name="gpsflag1" type="checkbox" class="formcheckbox" id="gpsflag1"<?php if($pconfig['flag1']) echo " checked=\"checked\""; ?> />
508 aa2aebfd nagyrobi
						</td>
509
						<td>
510
							<span class="vexpl"><?php echo gettext("Enable PPS signal processing (default: enabled)."); ?></span>
511
						</td>
512
					</tr>
513
					<tr>
514
						<td>
515 9c37d703 Colin Fleming
							<input name="gpsflag2" type="checkbox" class="formcheckbox" id="gpsflag2"<?php if($pconfig['flag2']) echo " checked=\"checked\""; ?> />
516 aa2aebfd nagyrobi
						</td>
517
						<td>
518
							<span class="vexpl"><?php echo gettext("Enable falling edge PPS signal processing (default: rising edge)."); ?></span>
519
						</td>
520
					</tr>
521
					<tr>
522
						<td>
523 9c37d703 Colin Fleming
							<input name="gpsflag3" type="checkbox" class="formcheckbox" id="gpsflag3"<?php if($pconfig['flag3']) echo " checked=\"checked\""; ?> />
524 aa2aebfd nagyrobi
						</td>
525
						<td>
526
							<span class="vexpl"><?php echo gettext("Enable kernel PPS clock discipline (default: enabled)."); ?></span>
527
						</td>
528
					</tr>
529
					<tr>
530
						<td>
531 9c37d703 Colin Fleming
							<input name="gpsflag4" type="checkbox" class="formcheckbox" id="gpsflag4"<?php if($pconfig['flag4']) echo " checked=\"checked\""; ?> />
532 aa2aebfd nagyrobi
						</td>
533
						<td>
534
							<span class="vexpl"><?php echo gettext("Obscure location in timestamp (default: unobscured)."); ?></span>
535
						</td>
536
					</tr>
537
					<tr>
538
						<td>
539 9c37d703 Colin Fleming
							<input name="gpssubsec" type="checkbox" class="formcheckbox" id="gpssubsec"<?php if($pconfig['subsec']) echo " checked=\"checked\""; ?> />
540 aa2aebfd nagyrobi
						</td>
541
						<td>
542 8cd558b6 ayvis
							<span class="vexpl"><?php echo gettext("Log the sub-second fraction of the received time stamp (default: Not logged).<br />Note: enabling this will rapidly fill the log, but is useful for tuning Fudge time 2."); ?></span>
543 aa2aebfd nagyrobi
						</td>
544
					</tr>
545
				</table>
546
			</td>
547
		</tr>
548
		<tr>
549
			<td width="22%" valign="top" class="vncellreq">Clock ID</td>
550
			<td width="78%" class="vtable">
551 9c37d703 Colin Fleming
				<input name="gpsrefid" type="text" class="formfld unknown" id="gpsrefid" maxlength= "4" size="20" value="<?=htmlspecialchars($pconfig['refid']);?>" /><?php echo gettext("(1 to 4 charactors)");?><br />
552 aa2aebfd nagyrobi
				<?php echo gettext("This may be used to change the GPS Clock ID");?> (<?php echo gettext("default");?>: GPS).</td>
553
		</tr>
554
		<tr>
555
			<td width="22%" valign="top" class="vncellreq">GPS Initialization</td>
556
			<td width="78%" class="vtable">
557
				<div id="showgpsinitbox">
558 9c37d703 Colin Fleming
					<input type="button" onclick="show_advanced('showgpsinitbox', 'showgpsinit')" value="<?=gettext("Advanced");?>" /> - <?=gettext("Show GPS Initialization commands");?>
559 aa2aebfd nagyrobi
				</div>
560
				<div id="showgpsinit" style="display:none">
561
					<p>
562
					<textarea name="gpsinitcmd" class="formpre" id="gpsinitcmd" cols="65" rows="7"><?=htmlspecialchars(base64_decode($pconfig['initcmd'])); /*resultmatch*/?></textarea><br />
563
					<?php echo gettext("Note: Commands entered here will be sent to the GPS during initialization. Please read and understand your GPS documentation before making any changes here.");?><br /><br />
564
					<strong><?php echo gettext("NMEA checksum calculator");?>:</strong>
565
					<br />
566 38505a80 Colin Fleming
					<?php echo gettext("Enter the text between &quot;$&quot; and &quot;*&quot; of a NMEA command string:");?><br /> $<input name="nmeastring" type="text" class="formfld unknown" id="nmeastring" size="30" value="" />*<span id="nmeachecksum"><?php echo gettext("checksum");?></span>&nbsp;&nbsp;
567 9c37d703 Colin Fleming
					<input type="button" onclick="NMEAChecksum(nmeastring.value)" value="<?=gettext("Calculate NMEA checksum");?>" /><br /></p>
568 aa2aebfd nagyrobi
				</div>
569
			</td>
570
		</tr>
571
		<tr>
572
			<td width="22%" valign="top">&nbsp;</td>
573
			<td width="78%">
574 9c37d703 Colin Fleming
			<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" />
575 aa2aebfd nagyrobi
			</td>
576
		</tr>
577
	</table>
578
	</div>
579 42b5c637 Renato Botelho
	</td></tr>
580 aa2aebfd nagyrobi
</table>
581 9c37d703 Colin Fleming
<script type="text/javascript">
582
//<![CDATA[
583
set_gps_default(this.form);
584
//]]>
585
</script>
586 aa2aebfd nagyrobi
</form>
587
<?php include("fend.inc"); ?>
588
</body>
589
</html>