array(), 'selected' => array()); $nmealist['options'][0] = 'All'; $nmealist['options'][1] = 'RMC'; $nmealist['options'][2] = 'GGA'; $nmealist['options'][4] = 'GLL'; $nmealist['options'][8] = 'ZDA or ZDG'; if(!$pconfig['nmea']) array_push($nmealist['selected'], 0); foreach($nmealist['options'] as $val => $opt) { if($pconfig['nmea'] & $val) array_push($nmealist['selected'], $val); } return($nmealist); } $closehead = false; $pconfig = &$config['ntpd']['gps']; $pgtitle = array(gettext("Services"), gettext("NTP GPS")); $shortcut_section = "ntp"; include("head.inc"); $tab_array = array(); $tab_array[] = array(gettext("NTP"), false, "services_ntpd.php"); $tab_array[] = array(gettext("Serial GPS"), true, "services_ntpd_gps.php"); $tab_array[] = array(gettext("PPS"), false, "services_ntpd_pps.php"); display_top_tabs($tab_array); require('classes/Form.class.php'); $form = new Form; $section = new Form_Section('NTP Serial GPS Configuration'); $section->addInput(new Form_StaticText( 'Notes', '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.' . '
' . 'For the best results, NTP should have at least three sources of time. So it is best to configure at least 2 servers under ' . 'Services > NTP' . ' 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.' )); $gpstypes = array('Custom', 'Default', 'Generic', 'Garmin', 'MediaTek', 'SiRF', 'U-Blox', 'SureGPS'); $section->addInput(new Form_Select( 'gpstype', 'GPS', $pconfig['type'], array_combine($gpstypes, $gpstypes) ))->setHelp('This option allows you to select a predefined configuration.' . 'Default is the configuration of pfSense 2.1 and earlier (not recommended). Select Generic if your GPS is not listed.' . '

' . 'The perdefined configurations assume your GPS has already been set to NMEA mode.'); $serialports = glob("/dev/cua?[0-9]{,.[0-9]}", GLOB_BRACE); if (!empty($serialports)) { $splist = array(); foreach ($serialports as $port) { $shortport = substr($port,5); $splist[$shortport] = $shortport; } $section->addInput(new Form_Select( 'gpsport', 'Serial port', $pconfig['port'], $splist ))->setHelp('All serial ports are listed, be sure to pick the port with the GPS attached. '); $section->addInput(new Form_Select( 'gpsspeed', null, $pconfig['speed'], [0 => '4800', 15 => '9600', 32 => '19200', 48 => '38400', 64 => '57600', 80 => '115200'] ))->setHelp('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.'); } $nmealist = build_nmea_list(); $section->addInput(new Form_Select( 'gpsnmea', 'NMEA Sentences', $nmealist['selected'], $nmealist['options'], 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_Input( 'gpsfudge1', 'Fudge time 1', 'text', $pconfig['fudge1'] ))->setHelp('Fudge time 1 is used to specify the GPS PPS signal offset (default: 0.0).'); $section->addInput(new Form_Input( 'gpsfudge2', 'Fudge time 2', 'text', $pconfig['fudge2'] ))->setHelp('Fudge time 2 is used to specify the GPS time offset (default: 0.0).'); $section->addInput(new Form_Input( 'gpsstratum', 'Stratum (0-16)', 'text', $pconfig['stratum'] ))->setHelp('This may be used to change the GPS Clock stratum (default: 0). This may be useful if, for some reason, you want ntpd to prefer a different clock'); $section->addInput(new Form_Checkbox( 'gpsprefer', 'Flags', 'NTP should prefer this clock (default: enabled).', !$pconfig['prefer'] )); $section->addInput(new Form_Checkbox( 'gpsselect', null, 'NTP should not use this clock, it will be displayed for reference only(default: disabled).', $pconfig['noselect'] )); $section->addInput(new Form_Checkbox( 'gpsflag1', null, 'Enable PPS signal processing (default: enabled).', $pconfig['flag1'] )); $section->addInput(new Form_Checkbox( 'gpsflag2', null, 'Enable falling edge PPS signal processing (default: rising edge).', $pconfig['flag2'] )); $section->addInput(new Form_Checkbox( 'gpsflag3', null, 'Enable kernel PPS clock discipline (default: enabled).', $pconfig['flag3'] )); $section->addInput(new Form_Checkbox( 'gpsflag4', null, 'Obscure location in timestamp (default: unobscured).', $pconfig['flag4'] )); $section->addInput(new Form_Checkbox( 'gpssubsec', null, 'Log the sub-second fraction of the received time stamp (default: Not logged).', $pconfig['subsec'] ))->setHelp('Enabling this will rapidly fill the log, but is useful for tuning Fudge time 2.'); $section->addInput(new Form_Input( 'gpsrefid', 'Clock ID', 'text', $pconfig['refid'], ['placeholder' => '1 to 4 characters'] ))->setHelp('This may be used to change the GPS Clock ID (default: GPS).'); // Statistics logging section $btnadvgps = new Form_Button( 'btnadvgps', 'Advanced' ); $btnadvgps->removeClass('btn-primary')->addClass('btn-default btn-sm'); $section->addInput(new Form_StaticText( 'GPS Initialization', $btnadvgps . ' ' . 'Show GPS Initialization commands' )); $section->addInput(new Form_Textarea( 'gpsinitcmd', null, $pconfig['initcmd'] ))->setHelp('Commands entered here will be sent to the GPS during initialization. Please read and understand your GPS documentation before making any changes here'); $group = new Form_Group('NMEA Checksum Calculator'); $group->add(new Form_Input( 'nmeastring', null )); $btncalc = new Form_Button( 'btncalc', 'Calculate' ); $btncalc->removeClass('btn-primary')->addClass('btn-success btn-sm'); $group->add($btncalc); $group->add(new Form_Input( 'result', null, 'text', null, ['placeholder' => 'Result'] )); $group->setHelp('Enter the text between "$" and "*" of a NMEA command string:'); $group->addClass('calculator'); $section->add($group); $form->add($section); print($form); ?>