Skip to content

Commit 3ebfe6b

Browse files
authored
Merge pull request #657 from sparkfun/release_candidate
Release candidate
2 parents fc75984 + 0f636fc commit 3ebfe6b

40 files changed

+9665
-4891
lines changed

.github/workflows/compile-rtk-firmware.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
env:
77
FILENAME_PREFIX: RTK_Surveyor_Firmware
88
FIRMWARE_VERSION_MAJOR: 3
9-
FIRMWARE_VERSION_MINOR: 7
9+
FIRMWARE_VERSION_MINOR: 8
1010
POINTPERFECT_TOKEN: ${{ secrets.POINTPERFECT_TOKEN }}
1111

1212
jobs:

.gitignore

+10
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,13 @@ Icon
4646
# Files that might appear on external disk
4747
.Spotlight-V100
4848
.Trashes
49+
50+
# =========================
51+
# Linux Files
52+
# =========================
53+
54+
Compare
55+
NMEA_Client
56+
Read_Map_File
57+
RTK_Reset
58+
Split_Messages

Firmware/RTK_Surveyor/AP-Config/index.html

-30
Original file line numberDiff line numberDiff line change
@@ -466,21 +466,6 @@
466466

467467

468468
<div id="messageList">
469-
<div class="form-group row" id="msgUBX_NMEA_DTM">
470-
<label for="UBX_NMEA_DTM" class="col-sm-3 col-5 col-form-label">NMEA_DTM:</label>
471-
<div class="col-sm-8 col-7"><input type="number" class="form-control"
472-
id="UBX_NMEA_DTM" value="0">
473-
<p id="UBX_NMEA_DTMError" class="inlineError"></p>
474-
</div>
475-
</div>
476-
<hr>
477-
<div class="form-group row" id="msgUBX_NAV_ATT">
478-
<label for="UBX_NAV_ATT" class="col-sm-3 col-5 col-form-label">NAV_ATT:</label>
479-
<div class="col-sm-8 col-7"><input type="number" class="form-control"
480-
id="UBX_NAV_ATT" value="0">
481-
<p id="UBX_NAV_ATTError" class="inlineError"></p>
482-
</div>
483-
</div>
484469
</div>
485470
</div>
486471
</div>
@@ -926,21 +911,6 @@
926911
</div>
927912

928913
<div id="messageListBase">
929-
<div class="form-group row" id="msgUBX_NMEA_DTM">
930-
<label for="UBX_NMEA_DTM" class="col-sm-3 col-5 col-form-label">RTCM_1005:</label>
931-
<div class="col-sm-8 col-7"><input type="number" class="form-control"
932-
id="UBX_NMEA_DTM" value="0">
933-
<p id="UBX_NMEA_DTMError" class="inlineError"></p>
934-
</div>
935-
</div>
936-
<hr>
937-
<div class="form-group row" id="msgUBX_NAV_ATT">
938-
<label for="UBX_NAV_ATT" class="col-sm-3 col-5 col-form-label">RTCM_1074:</label>
939-
<div class="col-sm-8 col-7"><input type="number" class="form-control"
940-
id="UBX_NAV_ATT" value="0">
941-
<p id="UBX_NAV_ATTError" class="inlineError"></p>
942-
</div>
943-
</div>
944914
</div>
945915

946916
</div>

Firmware/RTK_Surveyor/AP-Config/src/main.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ function validateFields() {
479479
checkElementValue("minCNO", 0, 90, "Must be between 0 and 90", "collapseGNSSConfig");
480480

481481
if (ge("enableNtripClient").checked) {
482-
checkElementString("ntripClient_CasterHost", 1, 30, "Must be 1 to 30 characters", "collapseGNSSConfig");
482+
checkElementString("ntripClient_CasterHost", 1, 45, "Must be 1 to 45 characters", "collapseGNSSConfig");
483483
checkElementValue("ntripClient_CasterPort", 1, 99999, "Must be 1 to 99999", "collapseGNSSConfig");
484484
checkElementString("ntripClient_MountPoint", 1, 30, "Must be 1 to 30 characters", "collapseGNSSConfig");
485485
checkElementCasterUser("ntripClient_CasterUser", "rtk2go.com", "User must use their email address", "collapseGNSSConfig");

Firmware/RTK_Surveyor/Begin.ino

+105-32
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,56 @@
33
void identifyBoard()
44
{
55
// Use ADC to check resistor divider
6-
int pin_adc_rtk_facet = 35;
7-
uint16_t idValue = analogReadMilliVolts(pin_adc_rtk_facet);
8-
log_d("Board ADC ID: %d", idValue);
9-
10-
if (idValue > (3300 / 2 * 0.9) && idValue < (3300 / 2 * 1.1))
6+
// Express: 10/3.3
7+
// Express+: 3.3/10
8+
// Facet: 10/10
9+
// Facet L-Band: 10/20
10+
// Reference Station: 20/10
11+
// Facet L-Band Direct: 10/100
12+
// Surveyor: ID resistors do not exist
13+
14+
const float rtkExpressID = 3.3 / (10 + 3.3) * 3300; // 819mV
15+
const float rtkExressPlusID = 10.0 / (10 + 3.3) * 3300; // 2418mV
16+
const float rtkFacetID = 10.0 / (10 + 10) * 3300; // 1650mV
17+
const float rtkFacetLbandID = 20.0 / (20 + 10) * 3300; // 2200mV
18+
const float rtkReferenceStationID = 10.0 / (10 + 20) * 3300; // 1100mV
19+
const float rtkFacetLbandDirectID = 1.0 / (4.7 + 1) * 3300; // 579mV
20+
21+
const float tolerance = 0.0475; // 4.75% Testing shows the combined ADC+resistors is under a 1% window
22+
const float upperThreshold = 1 + tolerance; // 104.75%
23+
const float lowerThreshold = 1 - tolerance; // 95.25%
24+
25+
int pin_deviceID = 35;
26+
uint16_t idValue = analogReadMilliVolts(pin_deviceID);
27+
log_d("Board ADC ID (mV): %d", idValue);
28+
29+
if (idValue > (rtkFacetID * lowerThreshold) && idValue < (rtkFacetID * upperThreshold))
1130
{
1231
productVariant = RTK_FACET;
1332
}
14-
else if (idValue > (3300 * 2 / 3 * 0.9) && idValue < (3300 * 2 / 3 * 1.1))
33+
else if (idValue > (rtkFacetLbandID * lowerThreshold) && idValue < (rtkFacetLbandID * upperThreshold))
1534
{
1635
productVariant = RTK_FACET_LBAND;
1736
}
18-
else if (idValue > (3300 * 3.3 / 13.3 * 0.9) && idValue < (3300 * 3.3 / 13.3 * 1.1))
37+
else if (idValue > (rtkExpressID * lowerThreshold) && idValue < (rtkExpressID * upperThreshold))
1938
{
2039
productVariant = RTK_EXPRESS;
2140
}
22-
else if (idValue > (3300 * 10 / 13.3 * 0.9) && idValue < (3300 * 10 / 13.3 * 1.1))
41+
else if (idValue > (rtkExressPlusID * lowerThreshold) && idValue < (rtkExressPlusID * upperThreshold))
2342
{
2443
productVariant = RTK_EXPRESS_PLUS;
2544
}
26-
else if (idValue > (3300 * 1 / 3 * 0.9) && idValue < (3300 * 1 / 3 * 1.1))
45+
else if (idValue > (rtkReferenceStationID * lowerThreshold) && idValue < (rtkReferenceStationID * upperThreshold))
2746
{
2847
productVariant = REFERENCE_STATION;
2948
// We can't auto-detect the ZED version if the firmware is in configViaEthernet mode,
3049
// so fake it here - otherwise messageSupported always returns false
3150
zedFirmwareVersionInt = 112;
3251
}
52+
else if (idValue > (rtkFacetLbandDirectID * lowerThreshold) && idValue < (rtkFacetLbandDirectID * upperThreshold))
53+
{
54+
productVariant = RTK_FACET_LBAND_DIRECT;
55+
}
3356
else
3457
{
3558
productVariant = RTK_UNKNOWN; // Need to wait until the GNSS and Accel have been initialized
@@ -112,10 +135,28 @@ void beginBoard()
112135
}
113136
else
114137
{
115-
productVariant = RTK_SURVEYOR;
138+
// Detect RTK Expresses (v1.3 and below) that do not have an accel or device ID resistors
139+
140+
// On a Surveyor, pin 34 is not connected. On Express, 34 is connected to ZED_TX_READY
141+
const int pin_ZedTxReady = 34;
142+
uint16_t pinValue = analogReadMilliVolts(pin_ZedTxReady);
143+
log_d("Alternate ID pinValue (mV): %d\r\n", pinValue); // Surveyor = 142 to 152, //Express = 3129
144+
if (pinValue > 3000)
145+
{
146+
if (zedModuleType == PLATFORM_F9P)
147+
productVariant = RTK_EXPRESS;
148+
else if (zedModuleType == PLATFORM_F9R)
149+
productVariant = RTK_EXPRESS_PLUS;
150+
}
151+
else
152+
productVariant = RTK_SURVEYOR;
116153
}
117154
}
118155

156+
// We need some settings before we are completely powered on
157+
// ie, disablePowerFiltering, enableResetDisplay, resetCount, etc
158+
loadSettingsPartial(); // Loads settings from LFS
159+
119160
// Setup hardware pins
120161
if (productVariant == RTK_SURVEYOR)
121162
{
@@ -173,7 +214,8 @@ void beginBoard()
173214
strncpy(platformPrefix, "Express Plus", sizeof(platformPrefix) - 1);
174215
}
175216
}
176-
else if (productVariant == RTK_FACET || productVariant == RTK_FACET_LBAND)
217+
else if (productVariant == RTK_FACET || productVariant == RTK_FACET_LBAND ||
218+
productVariant == RTK_FACET_LBAND_DIRECT)
177219
{
178220
// v11
179221
pin_muxA = 2;
@@ -219,6 +261,15 @@ void beginBoard()
219261
strncpy(platformFilePrefix, "SFE_Facet_LBand", sizeof(platformFilePrefix) - 1);
220262
strncpy(platformPrefix, "Facet L-Band", sizeof(platformPrefix) - 1);
221263
}
264+
else if (productVariant == RTK_FACET_LBAND_DIRECT)
265+
{
266+
strncpy(platformFilePrefix, "SFE_Facet_LBand_Direct", sizeof(platformFilePrefix) - 1);
267+
strncpy(platformPrefix, "Facet L-Band Direct", sizeof(platformPrefix) - 1);
268+
269+
// Override the default setting if a user has not explicitly configured the setting
270+
if (settings.useI2cForLbandCorrectionsConfigured == false)
271+
settings.useI2cForLbandCorrections = false;
272+
}
222273
}
223274
else if (productVariant == REFERENCE_STATION)
224275
{
@@ -244,7 +295,6 @@ void beginBoard()
244295
ethernetMACAddress[5] += 3; // Convert MAC address to Ethernet MAC (add 3)
245296

246297
// For all boards, check reset reason. If reset was due to wdt or panic, append last log
247-
loadSettingsPartial(); // Loads settings from LFS
248298
if ((esp_reset_reason() == ESP_RST_POWERON) || (esp_reset_reason() == ESP_RST_SW))
249299
{
250300
reuseLastLog = false; // Start new log
@@ -446,13 +496,13 @@ void beginSD()
446496
}
447497
}
448498
}
449-
#else // COMPILE_SD_MMC
499+
#else // COMPILE_SD_MMC
450500
else
451501
{
452502
log_d("SD_MMC not compiled");
453503
break; // No SD available.
454504
}
455-
#endif // COMPILE_SD_MMC
505+
#endif // COMPILE_SD_MMC
456506

457507
if (createTestFile() == false)
458508
{
@@ -491,7 +541,7 @@ void endSD(bool alreadyHaveSemaphore, bool releaseSemaphore)
491541
#ifdef COMPILE_SD_MMC
492542
else
493543
SD_MMC.end();
494-
#endif // COMPILE_SD_MMC
544+
#endif // COMPILE_SD_MMC
495545

496546
online.microSD = false;
497547
systemPrintln("microSD: Offline");
@@ -549,20 +599,38 @@ void resetSPI()
549599
// See issue: https://github.com/espressif/arduino-esp32/issues/3386
550600
void beginUART2()
551601
{
552-
ringBuffer = (uint8_t *)malloc(settings.gnssHandlerBufferSize);
553-
554-
if (pinUART2TaskHandle == nullptr)
555-
xTaskCreatePinnedToCore(
556-
pinUART2Task,
557-
"UARTStart", // Just for humans
558-
2000, // Stack Size
559-
nullptr, // Task input parameter
560-
0, // Priority, with 3 (configMAX_PRIORITIES - 1) being the highest, and 0 being the lowest
561-
&pinUART2TaskHandle, // Task handle
562-
settings.gnssUartInterruptsCore); // Core where task should run, 0=core, 1=Arduino
563-
564-
while (uart2pinned == false) // Wait for task to run once
565-
delay(1);
602+
size_t length;
603+
604+
// Determine the length of data to be retained in the ring buffer
605+
// after discarding the oldest data
606+
length = settings.gnssHandlerBufferSize;
607+
rbOffsetEntries = (length >> 1) / AVERAGE_SENTENCE_LENGTH_IN_BYTES;
608+
length = settings.gnssHandlerBufferSize
609+
+ (rbOffsetEntries * sizeof(RING_BUFFER_OFFSET));
610+
ringBuffer = nullptr;
611+
rbOffsetArray = (RING_BUFFER_OFFSET *)malloc(length);
612+
if (!rbOffsetArray)
613+
{
614+
rbOffsetEntries = 0;
615+
systemPrintln("ERROR: Failed to allocate the ring buffer!");
616+
}
617+
else
618+
{
619+
ringBuffer = (uint8_t *)&rbOffsetArray[rbOffsetEntries];
620+
rbOffsetArray[0] = 0;
621+
if (pinUART2TaskHandle == nullptr)
622+
xTaskCreatePinnedToCore(
623+
pinUART2Task,
624+
"UARTStart", // Just for humans
625+
2000, // Stack Size
626+
nullptr, // Task input parameter
627+
0, // Priority, with 3 (configMAX_PRIORITIES - 1) being the highest, and 0 being the lowest
628+
&pinUART2TaskHandle, // Task handle
629+
settings.gnssUartInterruptsCore); // Core where task should run, 0=core, 1=Arduino
630+
631+
while (uart2pinned == false) // Wait for task to run once
632+
delay(1);
633+
}
566634
}
567635

568636
// Assign UART2 interrupts to the core that started the task. See:
@@ -877,7 +945,7 @@ void beginInterrupts()
877945
pinMode(pin_Ethernet_Interrupt, INPUT_PULLUP); // Prepare the interrupt pin
878946
attachInterrupt(pin_Ethernet_Interrupt, ethernetISR, FALLING); // Attach the interrupt
879947
}
880-
#endif // COMPILE_ETHERNET
948+
#endif // COMPILE_ETHERNET
881949
}
882950

883951
// Set LEDs for output and configure PWM
@@ -981,7 +1049,7 @@ void beginSystemState()
9811049
if (systemState > STATE_NOT_SET)
9821050
{
9831051
systemPrintln("Unknown state - factory reset");
984-
factoryReset(false); //We do not have the SD semaphore
1052+
factoryReset(false); // We do not have the SD semaphore
9851053
}
9861054

9871055
if (productVariant == RTK_SURVEYOR)
@@ -1002,6 +1070,7 @@ void beginSystemState()
10021070
systemState = STATE_ROVER_NOT_STARTED; // Assume Rover. ButtonCheckTask() will correct as needed.
10031071

10041072
setupBtn = new Button(pin_setupButton); // Create the button in memory
1073+
// Allocation failure handled in ButtonCheckTask
10051074
}
10061075
else if (productVariant == RTK_EXPRESS || productVariant == RTK_EXPRESS_PLUS)
10071076
{
@@ -1020,8 +1089,10 @@ void beginSystemState()
10201089

10211090
setupBtn = new Button(pin_setupButton); // Create the button in memory
10221091
powerBtn = new Button(pin_powerSenseAndControl); // Create the button in memory
1092+
// Allocation failures handled in ButtonCheckTask
10231093
}
1024-
else if (productVariant == RTK_FACET || productVariant == RTK_FACET_LBAND)
1094+
else if (productVariant == RTK_FACET || productVariant == RTK_FACET_LBAND ||
1095+
productVariant == RTK_FACET_LBAND_DIRECT)
10251096
{
10261097
if (settings.lastState == STATE_NOT_SET) // Default
10271098
{
@@ -1041,6 +1112,7 @@ void beginSystemState()
10411112
firstRoverStart = false;
10421113

10431114
powerBtn = new Button(pin_powerSenseAndControl); // Create the button in memory
1115+
// Allocation failure handled in ButtonCheckTask
10441116
}
10451117
else if (productVariant == REFERENCE_STATION)
10461118
{
@@ -1055,6 +1127,7 @@ void beginSystemState()
10551127
.lastState; // Return to either NTP, Base or Rover Not Started. The last state previous to power down.
10561128

10571129
setupBtn = new Button(pin_setupButton); // Create the button in memory
1130+
// Allocation failure handled in ButtonCheckTask
10581131
}
10591132

10601133
// Starts task for monitoring button presses

Firmware/RTK_Surveyor/Bluetooth.ino

+7-3
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,11 @@ void bluetoothStart()
214214
bluetoothSerial->register_callback(bluetoothCallback); // Controls BT Status LED on Surveyor
215215
bluetoothSerial->setTimeout(250);
216216

217-
systemPrint("Bluetooth broadcasting as: ");
217+
if (settings.bluetoothRadioType == BLUETOOTH_RADIO_SPP)
218+
systemPrint("Bluetooth SPP broadcasting as: ");
219+
else if (settings.bluetoothRadioType == BLUETOOTH_RADIO_BLE)
220+
systemPrint("Bluetooth Low-Energy broadcasting as: ");
221+
218222
systemPrintln(deviceName);
219223

220224
// Start task for controlling Bluetooth pair LED
@@ -226,7 +230,7 @@ void bluetoothStart()
226230
}
227231

228232
bluetoothState = BT_NOTCONNECTED;
229-
reportHeapNow();
233+
reportHeapNow(false);
230234
}
231235
#endif // COMPILE_BT
232236
}
@@ -267,7 +271,7 @@ void bluetoothStop()
267271
log_d("Bluetooth turned off");
268272

269273
bluetoothState = BT_OFF;
270-
reportHeapNow();
274+
reportHeapNow(false);
271275
}
272276
#endif // COMPILE_BT
273277
bluetoothIncomingRTCM = false;

0 commit comments

Comments
 (0)