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