@@ -6,10 +6,17 @@ void beginBoard()
6
6
{
7
7
// Use ADC to check 50% resistor divider
8
8
int pin_adc_rtk_facet = 35 ;
9
- if (analogReadMilliVolts (pin_adc_rtk_facet) > (3300 / 2 * 0.9 ) && analogReadMilliVolts (pin_adc_rtk_facet) < (3300 / 2 * 1.1 ))
9
+ uint16_t idValue = analogReadMilliVolts (pin_adc_rtk_facet);
10
+ log_d (" Board ADC ID: %d" , idValue);
11
+
12
+ if (idValue > (3300 / 2 * 0.9 ) && idValue < (3300 / 2 * 1.1 ))
10
13
{
11
14
productVariant = RTK_FACET;
12
15
}
16
+ else if (idValue > (3300 * 2 / 3 * 0.9 ) && idValue < (3300 * 2 / 3 * 1.1 ))
17
+ {
18
+ productVariant = RTK_FACET_LBAND;
19
+ }
13
20
else if (isConnected (0x19 ) == true ) // Check for accelerometer
14
21
{
15
22
if (zedModuleType == PLATFORM_F9P) productVariant = RTK_EXPRESS;
@@ -77,7 +84,7 @@ void beginBoard()
77
84
strcpy (platformPrefix, " Express Plus" );
78
85
}
79
86
}
80
- else if (productVariant == RTK_FACET)
87
+ else if (productVariant == RTK_FACET || productVariant == RTK_FACET_LBAND )
81
88
{
82
89
// v11
83
90
pin_muxA = 2 ;
@@ -113,12 +120,24 @@ void beginBoard()
113
120
pinMode (pin_radio_cts, OUTPUT);
114
121
digitalWrite (pin_radio_cts, LOW);
115
122
116
- strcpy (platformFilePrefix, " SFE_Facet" );
117
- strcpy (platformPrefix, " Facet" );
123
+ if (productVariant == RTK_FACET)
124
+ {
125
+ strcpy (platformFilePrefix, " SFE_Facet" );
126
+ strcpy (platformPrefix, " Facet" );
127
+ }
128
+ else if (productVariant == RTK_FACET_LBAND)
129
+ {
130
+ strcpy (platformFilePrefix, " SFE_Facet_LBand" );
131
+ strcpy (platformPrefix, " Facet L-Band" );
132
+ }
118
133
}
119
134
120
135
Serial.printf (" SparkFun RTK %s v%d.%d-%s\r\n " , platformPrefix, FIRMWARE_VERSION_MAJOR, FIRMWARE_VERSION_MINOR, __DATE__);
121
136
137
+ // Get unit MAC address
138
+ esp_read_mac (unitMACAddress, ESP_MAC_WIFI_STA);
139
+ unitMACAddress[5 ] += 2 ; // Convert MAC address to Bluetooth MAC (add 2): https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/system.html#mac-address
140
+
122
141
// For all boards, check reset reason. If reset was due to wdt or panic, append last log
123
142
if (esp_reset_reason () == ESP_RST_POWERON)
124
143
{
@@ -139,8 +158,8 @@ void beginBoard()
139
158
if (settings.enableResetDisplay == true )
140
159
{
141
160
settings.resetCount ++;
142
- recordSystemSettings (); // Record to NVM
143
161
Serial.printf (" resetCount: %d\n\r " , settings.resetCount );
162
+ recordSystemSettings (); // Record to NVM
144
163
}
145
164
146
165
Serial.print (" Reset reason: " );
@@ -222,11 +241,11 @@ void beginSD()
222
241
}
223
242
224
243
// Setup FAT file access semaphore
225
- if (xFATSemaphore == NULL )
244
+ if (sdCardSemaphore == NULL )
226
245
{
227
- xFATSemaphore = xSemaphoreCreateMutex ();
228
- if (xFATSemaphore != NULL )
229
- xSemaphoreGive (xFATSemaphore ); // Make the file system available for use
246
+ sdCardSemaphore = xSemaphoreCreateMutex ();
247
+ if (sdCardSemaphore != NULL )
248
+ xSemaphoreGive (sdCardSemaphore ); // Make the file system available for use
230
249
}
231
250
232
251
if (createTestFile () == false )
@@ -320,16 +339,14 @@ void stopUART2Tasks()
320
339
321
340
void beginFS ()
322
341
{
323
- #define FORMAT_LITTLEFS_IF_FAILED true
324
-
325
342
if (online.fs == false )
326
343
{
327
- Serial.println (" Starting FS" );
328
-
329
- if (!LittleFS.begin (FORMAT_LITTLEFS_IF_FAILED)) {
344
+ if (!LittleFS.begin (true )) // Format LittleFS if begin fails
345
+ {
330
346
log_d (" Error: LittleFS not online" );
331
347
return ;
332
348
}
349
+ Serial.println (" LittleFS Started" );
333
350
online.fs = true ;
334
351
}
335
352
}
@@ -350,7 +367,7 @@ void beginDisplay()
350
367
{
351
368
Serial.println (F (" Display not detected" ));
352
369
}
353
- else if (productVariant == RTK_EXPRESS || productVariant == RTK_EXPRESS_PLUS || productVariant == RTK_FACET)
370
+ else if (productVariant == RTK_EXPRESS || productVariant == RTK_EXPRESS_PLUS || productVariant == RTK_FACET || productVariant == RTK_FACET_LBAND )
354
371
{
355
372
Serial.println (F (" Display Error: Not detected." ));
356
373
}
@@ -401,19 +418,25 @@ void beginGNSS()
401
418
zedFirmwareVersionInt = 121 ;
402
419
else if (strstr (zedFirmwareVersion, " 1.30" ) != NULL ) // ZED-F9P released Dec, 2021
403
420
zedFirmwareVersionInt = 130 ;
421
+ else if (strstr (zedFirmwareVersion, " 1.32" ) != NULL ) // ZED-F9P released May, 2022
422
+ zedFirmwareVersionInt = 132 ;
404
423
else
424
+ {
405
425
Serial.printf (" Unknown firmware version: %s\n\r " , zedFirmwareVersion);
426
+ zedFirmwareVersionInt = 99 ; // 0.99 invalid firmware version
427
+ }
406
428
407
429
// Determine if we have a ZED-F9P (Express/Facet) or an ZED-F9R (Express Plus/Facet Plus)
408
430
if (strstr (i2cGNSS.minfo .extension [3 ], " ZED-F9P" ) != NULL )
409
- {
410
431
zedModuleType = PLATFORM_F9P;
411
- }
412
432
else if (strstr (i2cGNSS.minfo .extension [3 ], " ZED-F9R" ) != NULL )
413
- {
414
433
zedModuleType = PLATFORM_F9R;
434
+ else
435
+ {
436
+ Serial.printf (" Unknown ZED module: %s\n\r " , i2cGNSS.minfo .extension [3 ]);
437
+ zedModuleType = PLATFORM_F9P;
415
438
}
416
-
439
+
417
440
printModuleInfo (); // Print module type and firmware version
418
441
}
419
442
@@ -429,7 +452,7 @@ void configureGNSS()
429
452
// Configuring the ZED can take more than 2000ms. We save configuration to
430
453
// ZED so there is no need to update settings unless user has modified
431
454
// the settings file or internal settings.
432
- if (updateZEDSettings == false )
455
+ if (settings. updateZEDSettings == false )
433
456
{
434
457
log_d (" Skipping ZED configuration" );
435
458
return ;
@@ -549,16 +572,22 @@ void beginSystemState()
549
572
{
550
573
// If the rocker switch was moved while off, force module settings
551
574
// When switch is set to '1' = BASE, pin will be shorted to ground
552
- if (settings.lastState == STATE_ROVER_NOT_STARTED && digitalRead (pin_setupButton) == LOW) updateZEDSettings = true ;
553
- else if (settings.lastState == STATE_BASE_NOT_STARTED && digitalRead (pin_setupButton) == HIGH) updateZEDSettings = true ;
575
+ if (settings.lastState == STATE_ROVER_NOT_STARTED && digitalRead (pin_setupButton) == LOW) settings. updateZEDSettings = true ;
576
+ else if (settings.lastState == STATE_BASE_NOT_STARTED && digitalRead (pin_setupButton) == HIGH) settings. updateZEDSettings = true ;
554
577
555
- systemState = STATE_ROVER_NOT_STARTED; // Assume Rover. ButtonCheckTask() will correct as needed.
578
+ if (online.lband == false )
579
+ systemState = STATE_ROVER_NOT_STARTED; // Assume Rover. ButtonCheckTask() will correct as needed.
580
+ else
581
+ systemState = STATE_KEYS_STARTED; // Begin process for getting new keys
556
582
557
583
setupBtn = new Button (pin_setupButton); // Create the button in memory
558
584
}
559
585
else if (productVariant == RTK_EXPRESS || productVariant == RTK_EXPRESS_PLUS)
560
586
{
561
- systemState = settings.lastState ; // Return to system state previous to power down.
587
+ if (online.lband == false )
588
+ systemState = settings.lastState ; // Return to either Rover or Base Not Started. The last state previous to power down.
589
+ else
590
+ systemState = STATE_KEYS_STARTED; // Begin process for getting new keys
562
591
563
592
if (systemState > STATE_SHUTDOWN)
564
593
{
@@ -569,18 +598,20 @@ void beginSystemState()
569
598
setupBtn = new Button (pin_setupButton); // Create the button in memory
570
599
powerBtn = new Button (pin_powerSenseAndControl); // Create the button in memory
571
600
}
572
- else if (productVariant == RTK_FACET)
601
+ else if (productVariant == RTK_FACET || productVariant == RTK_FACET_LBAND )
573
602
{
574
- systemState = settings.lastState ; // Return to system state previous to power down.
603
+ if (online.lband == false )
604
+ systemState = settings.lastState ; // Return to either Rover or Base Not Started. The last state previous to power down.
605
+ else
606
+ systemState = STATE_KEYS_STARTED; // Begin process for getting new keys
575
607
576
608
if (systemState > STATE_SHUTDOWN)
577
609
{
578
610
Serial.println (" Unknown state - factory reset" );
579
611
factoryReset ();
580
612
}
581
613
582
- if (systemState == STATE_ROVER_NOT_STARTED)
583
- firstRoverStart = true ; // Allow user to enter test screen during first rover start
614
+ firstRoverStart = true ; // Allow user to enter test screen during first rover start
584
615
585
616
powerBtn = new Button (pin_powerSenseAndControl); // Create the button in memory
586
617
}
@@ -603,7 +634,7 @@ bool beginExternalTriggers()
603
634
if (online.gnss == false ) return (false );
604
635
605
636
// If our settings haven't changed, trust ZED's settings
606
- if (updateZEDSettings == false )
637
+ if (settings. updateZEDSettings == false )
607
638
{
608
639
log_d (" Skipping ZED Trigger configuration" );
609
640
return (true );
@@ -644,3 +675,72 @@ bool beginExternalTriggers()
644
675
645
676
return (response);
646
677
}
678
+
679
+ // Check if NEO-D9S is connected. Configure if available.
680
+ void beginLBand ()
681
+ {
682
+ if (i2cLBand.begin (Wire, 0x43 ) == false ) // Connect to the u-blox NEO-D9S using Wire port. The D9S default I2C address is 0x43 (not 0x42)
683
+ {
684
+ log_d (" L-Band not detected" );
685
+ return ;
686
+ }
687
+
688
+ if (online.gnss == true )
689
+ {
690
+ i2cGNSS.checkUblox (); // Regularly poll to get latest data and any RTCM
691
+ i2cGNSS.checkCallbacks (); // Process any callbacks: ie, eventTriggerReceived
692
+ }
693
+
694
+ // If we have a fix, check which frequency to use
695
+ if (fixType == 2 || fixType == 3 || fixType == 4 || fixType == 5 ) // 2D, 3D, 3D+DR, or Time
696
+ {
697
+ if ( (longitude > -125 && longitude < -67 ) && (latitude > -90 && latitude < 90 ))
698
+ {
699
+ log_d (" Setting L-Band to US" );
700
+ settings.LBandFreq = 1556290000 ; // We are in US band
701
+ }
702
+ else if ( (longitude > -25 && longitude < 70 ) && (latitude > -90 && latitude < 90 ))
703
+ {
704
+ log_d (" Setting L-Band to EU" );
705
+ settings.LBandFreq = 1545260000 ; // We are in EU band
706
+ }
707
+ else
708
+ {
709
+ Serial.println (" Unknown band area" );
710
+ settings.LBandFreq = 1556290000 ; // Default to US
711
+ }
712
+ recordSystemSettings ();
713
+ }
714
+ else
715
+ log_d (" No fix available for L-Band frequency determination" );
716
+
717
+ bool response = true ;
718
+ response &= i2cLBand.setVal32 (UBLOX_CFG_PMP_CENTER_FREQUENCY, settings.LBandFreq ); // Default 1539812500 Hz
719
+ response &= i2cLBand.setVal16 (UBLOX_CFG_PMP_SEARCH_WINDOW, 2200 ); // Default 2200 Hz
720
+ response &= i2cLBand.setVal8 (UBLOX_CFG_PMP_USE_SERVICE_ID, 0 ); // Default 1
721
+ response &= i2cLBand.setVal16 (UBLOX_CFG_PMP_SERVICE_ID, 21845 ); // Default 50821
722
+ response &= i2cLBand.setVal16 (UBLOX_CFG_PMP_DATA_RATE, 2400 ); // Default 2400 bps
723
+ response &= i2cLBand.setVal8 (UBLOX_CFG_PMP_USE_DESCRAMBLER, 1 ); // Default 1
724
+ response &= i2cLBand.setVal16 (UBLOX_CFG_PMP_DESCRAMBLER_INIT, 26969 ); // Default 23560
725
+ response &= i2cLBand.setVal8 (UBLOX_CFG_PMP_USE_PRESCRAMBLING, 0 ); // Default 0
726
+ response &= i2cLBand.setVal64 (UBLOX_CFG_PMP_UNIQUE_WORD, 16238547128276412563ull );
727
+ response &= i2cLBand.setVal (UBLOX_CFG_MSGOUT_UBX_RXM_PMP_I2C, 1 ); // Ensure UBX-RXM-PMP is enabled on the I2C port
728
+ response &= i2cLBand.setVal (UBLOX_CFG_MSGOUT_UBX_RXM_PMP_UART1, 1 ); // Output UBX-RXM-PMP on UART1
729
+ response &= i2cLBand.setVal (UBLOX_CFG_UART2OUTPROT_UBX, 1 ); // Enable UBX output on UART2
730
+ response &= i2cLBand.setVal (UBLOX_CFG_MSGOUT_UBX_RXM_PMP_UART2, 1 ); // Output UBX-RXM-PMP on UART2
731
+ response &= i2cLBand.setVal32 (UBLOX_CFG_UART1_BAUDRATE, 38400 ); // match baudrate with ZED default
732
+ response &= i2cLBand.setVal32 (UBLOX_CFG_UART2_BAUDRATE, 38400 ); // match baudrate with ZED default
733
+
734
+ if (response == false )
735
+ Serial.println (" L-Band failed to configure" );
736
+
737
+ i2cLBand.softwareResetGNSSOnly (); // Do a restart
738
+
739
+ i2cLBand.setRXMPMPmessageCallbackPtr (&pushRXMPMP); // Call pushRXMPMP when new PMP data arrives. Push it to the GNSS
740
+
741
+ i2cGNSS.setRXMCORcallbackPtr (&checkRXMCOR); // Check if the PMP data is being decrypted successfully
742
+
743
+ log_d (" L-Band online" );
744
+
745
+ online.lband = true ;
746
+ }
0 commit comments