Skip to content

Commit f7794f3

Browse files
authored
Merge pull request #790 from sparkfun/nsUpdates
Make GNSS receiver configuration synchronous
2 parents 01f1bf3 + 5a81bbd commit f7794f3

39 files changed

+5066
-4862
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ on:
55

66
env:
77
FILENAME_PREFIX: RTK_Everywhere_Firmware
8-
FIRMWARE_VERSION_MAJOR: 2
9-
FIRMWARE_VERSION_MINOR: 3
8+
FIRMWARE_VERSION_MAJOR: 3
9+
FIRMWARE_VERSION_MINOR: 0
1010
CORE_VERSION: 3.0.7
1111

1212
jobs:

Firmware/RTK_Everywhere/AP-Config/index.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -297,17 +297,17 @@
297297
</div>
298298
</div>
299299

300-
<div class="form-group row" id="minCNOConfig">
300+
<div class="form-group row" id="minCN0Config">
301301
<div class="form-group row">
302-
<label for="minCNO" class="col-sm-4 col-6 col-form-label">Min C/N0:
302+
<label for="minCN0" class="col-sm-4 col-6 col-form-label">Min C/N0:
303303
<span class="tt" data-bs-placement="right"
304304
title="Minimum satellite signal level to be used in a fix. Default: 6dBHz for ZED-F9P and 10dBHz for UM980.">
305305
<span class="icon-info-circle text-primary ms-2"></span>
306306
</span>
307307
</label>
308308
<div class="col-sm-4 col-6">
309-
<input type="number" class="form-control" id="minCNO">
310-
<p id="minCNOError" class="inlineError"></p>
309+
<input type="number" class="form-control" id="minCN0">
310+
<p id="minCN0Error" class="inlineError"></p>
311311
</div>
312312
</div>
313313
</div>

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,8 @@ function parseIncoming(msg) {
278278
show("constellationNavic");
279279

280280
hide("dynamicModelDropdown"); //Not supported on LG290P
281-
show("minElevConfig");
282-
show("minCNOConfig");
281+
hide("minElevConfig"); //Not supported on LG290P
282+
hide("minCN0Config"); //Not supported on LG290P
283283

284284
ge("rtcmRateInfoText").setAttribute('data-bs-original-title', 'RTCM is transmitted by the base at a default of 1Hz for messages 1005, 1074, 1084, 1094, 1114, 1124, 1134. This can be lowered for radios with low bandwidth or tailored to transmit any/all RTCM messages. Limits: 0 to 20. Note: The measurement rate is overridden to 1Hz when in Base mode.');
285285

@@ -346,8 +346,8 @@ function parseIncoming(msg) {
346346
hide("enableNmeaOnRadio");
347347

348348
hide("dynamicModelDropdown"); //Not supported on LG290P
349-
show("minElevConfig");
350-
show("minCNOConfig");
349+
hide("minElevConfig"); //Not supported on LG290P
350+
hide("minCN0Config"); //Not supported on LG290P
351351

352352
ge("rtcmRateInfoText").setAttribute('data-bs-original-title', 'RTCM is transmitted by the base at a default of 1Hz for messages 1005, 1074, 1084, 1094, 1124, and 0.1Hz for 1033. This can be lowered for radios with low bandwidth or tailored to transmit any/all RTCM messages. Limits: 0 to 20. Note: The measurement rate is overridden to 1Hz when in Base mode.');
353353

@@ -930,7 +930,7 @@ function validateFields() {
930930
checkConstellations();
931931

932932
checkElementValue("minElev", 0, 90, "Must be between 0 and 90", "collapseGNSSConfig");
933-
checkElementValue("minCNO", 0, 90, "Must be between 0 and 90", "collapseGNSSConfig");
933+
checkElementValue("minCN0", 0, 90, "Must be between 0 and 90", "collapseGNSSConfig");
934934
if (isElementShown("lg290pGnssSettings") == true) {
935935
checkElementValue("rtcmMinElev", -90, 90, "Must be between -90 and 90", "collapseGNSSConfig");
936936
}

Firmware/RTK_Everywhere/Begin.ino

Lines changed: 46 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ void identifyBoard()
9494
// 0x08 - HUSB238 - USB C PD Sink Controller
9595
bool husb238Present = i2cIsDevicePresent(i2c_0, 0x08);
9696

97-
// 0x10 -MFI343S00177 Authentication Coprocessor
97+
// 0x10 - MFI343S00177 Authentication Coprocessor
9898
bool mfiPresent = i2cIsDevicePresent(i2c_0, 0x10);
9999

100100
i2c_0->end();
@@ -158,16 +158,6 @@ void identifyBoard()
158158
// Torch X2: 8.2/3.3 --> 836mV < 947mV < 1067mV (8.5% tolerance)
159159
else if (idWithAdc(idValue, 8.2, 3.3, 8.5))
160160
productVariant = RTK_TORCH_X2;
161-
162-
#ifdef FLEX_OVERRIDE
163-
systemPrintln("<<<<<<<<<< !!!!!!!!!! FLEX OVERRIDE !!!!!!!!!! >>>>>>>>>>");
164-
productVariant = RTK_FLEX; // TODO remove once v1.1 Flex has ID resistors
165-
#endif
166-
167-
#ifdef TORCH_X2_OVERRIDE
168-
systemPrintln("<<<<<<<<<< !!!!!!!!!! TORCH X2 OVERRIDE !!!!!!!!!! >>>>>>>>>>");
169-
productVariant = RTK_TORCH_X2; // TODO remove once v1.1 Torch X2 has ID resistors
170-
#endif
171161
}
172162

173163
if (ENABLE_DEVELOPER)
@@ -237,9 +227,10 @@ void beginBoard()
237227
present.needsExternalPpl = true; // Uses the PointPerfect Library
238228
present.galileoHasCapable = true;
239229
present.multipathMitigation = true; // UM980 has MPM, other platforms do not
240-
present.minCno = true;
230+
present.minCN0 = true;
241231
present.minElevation = true;
242232
present.dynamicModel = true;
233+
present.display_type = DISPLAY_MAX_NONE;
243234

244235
#ifdef COMPILE_IM19_IMU
245236
present.imu_im19 = true; // Allow tiltUpdate() to run
@@ -354,7 +345,7 @@ void beginBoard()
354345
present.display_i2c1 = true;
355346
present.display_type = DISPLAY_128x64;
356347
present.i2c1BusSpeed_400 = true; // Run display bus at higher speed
357-
present.minCno = true;
348+
present.minCN0 = true;
358349
present.minElevation = true;
359350
present.dynamicModel = true;
360351

@@ -451,7 +442,6 @@ void beginBoard()
451442
// Facet V2 is based on the ESP32-WROVER
452443
// ZED-F9P is interfaced via I2C and UART1
453444
// NEO-D9S is interfaced via I2C. UART2 TX is also connected to ESP32 pin 4
454-
// TODO: pass PMP over serial to save I2C traffic?
455445

456446
// Specify the GNSS radio
457447
#ifdef COMPILE_ZED
@@ -479,7 +469,7 @@ void beginBoard()
479469
present.fastPowerOff = true;
480470
present.invertedFastPowerOff = true;
481471
present.gnss_to_uart = true;
482-
present.minCno = true;
472+
present.minCN0 = true;
483473
present.minElevation = true;
484474
present.dynamicModel = true;
485475

@@ -561,7 +551,7 @@ void beginBoard()
561551
present.fastPowerOff = true;
562552
present.invertedFastPowerOff = true;
563553
present.gnss_to_uart = true;
564-
present.minCno = true;
554+
present.minCN0 = true;
565555
present.minElevation = true;
566556
present.dynamicModel = true;
567557

@@ -660,7 +650,7 @@ void beginBoard()
660650
present.mosaicMicroSd = true;
661651
present.microSdCardDetectLow = true; // Except microSD is connected to mosaic... present.microSd is false
662652

663-
present.minCno = true;
653+
present.minCN0 = true;
664654
present.minElevation = true;
665655
present.needsExternalPpl = true; // Uses the PointPerfect Library for L-Band
666656
present.dynamicModel = true;
@@ -734,7 +724,7 @@ void beginBoard()
734724

735725
// We can't enable here because we don't know if lg290pFirmwareVersion is >= v05
736726
// present.minElevation = true;
737-
// present.minCno = true;
727+
// present.minCN0 = true;
738728

739729
pin_I2C0_SDA = 7;
740730
pin_I2C0_SCL = 20;
@@ -782,15 +772,14 @@ void beginBoard()
782772
present.antennaPhaseCenter_mm = 62.0; // APC from drawings
783773
present.radio_lora = true;
784774
present.fuelgauge_bq40z50 = true;
785-
present.charger_mp2762a = true;
786775

787776
present.button_powerLow = true; // Button is pressed when high
788-
// present.button_mode = true; //TODO remove comment. This won't be available until v1.1 of hardware
777+
present.button_mode = true;
789778
present.beeper = true;
790779
present.gnss_to_uart = true;
791780

792781
present.gpioExpanderSwitches = true;
793-
// present.microSd = true; // TODO remove comment out - v1.0 hardware does not have pullup on #CD so card detection does not work
782+
present.microSd = true;
794783
present.microSdCardDetectLow = true;
795784

796785
present.display_i2c0 = true;
@@ -799,14 +788,18 @@ void beginBoard()
799788
present.displayInverted = true;
800789
present.tiltPossible = true;
801790

791+
present.fastPowerOff = true;
792+
present.invertedFastPowerOff = true; // Drive POWER_KILL high to cause powerdown
793+
802794
pin_I2C0_SDA = 15;
803795
pin_I2C0_SCL = 4;
804796

805797
pin_GnssUart_RX = 26;
806798
pin_GnssUart_TX = 27;
807799

808800
pin_powerSenseAndControl = 34;
809-
// pin_modeButton = 25; //TODO remove comment. This won't be available until v1.1 of hardware
801+
pin_powerFastOff = 23;
802+
pin_modeButton = 25;
810803

811804
pin_IMU_RX = 14; // ESP32 UART2
812805
pin_IMU_TX = 17;
@@ -824,8 +817,8 @@ void beginBoard()
824817
pin_microSD_CS = 22;
825818
pin_microSD_CardDetect = 39;
826819

827-
pin_gpioExpanderInterrupt =
828-
2; // TODO remove on v1.1 hardware. Not used since all GPIO expanded pins are outputs
820+
pinMode(pin_powerFastOff, OUTPUT);
821+
digitalWrite(pin_powerFastOff, LOW); // Low = Stay on. High = turn off.
829822

830823
DMW_if systemPrintf("pin_bluetoothStatusLED: %d\r\n", pin_bluetoothStatusLED);
831824
pinMode(pin_bluetoothStatusLED, OUTPUT);
@@ -870,15 +863,16 @@ void beginBoard()
870863
present.gnss_lg290p = true;
871864
present.antennaPhaseCenter_mm = 116.5; // Default to Torch helical APC, average of L1/L2
872865
present.fuelgauge_bq40z50 = true;
873-
present.charger_mp2762a = true;
874-
present.button_powerHigh = true; // Button is pressed when high
866+
present.button_powerLow = true; // Button is pressed when low
875867
present.beeper = true;
876868
present.gnss_to_uart = true;
877869
present.needsExternalPpl = true; // Uses the PointPerfect Library
870+
present.fastPowerOff = true;
871+
present.invertedFastPowerOff = true; // Drive PWRKILL high to cause powerdown
878872

879873
// We can't enable GNSS features here because we don't know if lg290pFirmwareVersion is >= v05
880874
// present.minElevation = true;
881-
// present.minCno = true;
875+
// present.minCN0 = true;
882876

883877
pin_I2C0_SDA = 15;
884878
pin_I2C0_SCL = 4;
@@ -887,7 +881,7 @@ void beginBoard()
887881
pin_GnssUart_TX = 17;
888882
pin_GNSS_DR_Reset = 22; // Push low to reset GNSS/DR.
889883

890-
pin_GNSS_TimePulse = 39; // PPS on UM980
884+
pin_GNSS_TimePulse = 39; // PPS on LG290P
891885

892886
pin_usbSelect = 12; // Controls U18 switch between ESP UART0 to USB or GNSS UART1
893887
pin_powerAdapterDetect = 36; // Goes low when USB cable is plugged in
@@ -899,12 +893,14 @@ void beginBoard()
899893
pin_beeper = 33;
900894

901895
pin_powerButton = 34;
902-
// pin_powerSenseAndControl = 18; // PWRKILL
896+
pin_powerFastOff = 18; // PWRKILL
903897

904898
pin_loraRadio_power = 19; // LoRa_EN
905899
// pin_loraRadio_boot = 23; // LoRa_BOOT0
906900
// pin_loraRadio_reset = 5; // LoRa_NRST
907901

902+
pinMode(pin_powerFastOff, INPUT); // Leave this as an input. powerDown() will drive high for fast power off
903+
908904
DMW_if systemPrintf("pin_bluetoothStatusLED: %d\r\n", pin_bluetoothStatusLED);
909905
pinMode(pin_bluetoothStatusLED, OUTPUT);
910906

@@ -1504,6 +1500,12 @@ void beginButtons()
15041500
buttonCount++;
15051501
if (present.gpioExpanderButtons == true)
15061502
buttonCount++;
1503+
if (productVariant == RTK_FLEX)
1504+
{
1505+
Serial.println("<<<<<<<<<<<<<<<<<<<< Deal with Flex buttons >>>>>>>>>>>>>>");
1506+
buttonCount = 1;
1507+
}
1508+
15071509
if (buttonCount > 1)
15081510
reportFatalError("Illegal button assignment.");
15091511

@@ -1523,9 +1525,15 @@ void beginButtons()
15231525
else
15241526
{
15251527
// Use the Button library
1526-
// Facet main/power button
1527-
if (present.button_powerLow == true && pin_powerSenseAndControl != PIN_UNDEFINED)
1528-
userBtn = new Button(pin_powerSenseAndControl);
1528+
if (present.button_powerLow == true)
1529+
{
1530+
// Torch X2 has both a powerButton and powerSenseAndControl (PWRKILL). Assign button task to powerButton.
1531+
if (pin_powerButton != PIN_UNDEFINED)
1532+
userBtn = new Button(pin_powerButton);
1533+
// Facet main/power button
1534+
else if (pin_powerSenseAndControl != PIN_UNDEFINED)
1535+
userBtn = new Button(pin_powerSenseAndControl);
1536+
}
15291537

15301538
// Torch main/power button
15311539
if (present.button_powerHigh == true && pin_powerButton != PIN_UNDEFINED)
@@ -1789,6 +1797,12 @@ bool i2cBusInitialization(TwoWire *i2cBus, int sda, int scl, int clockKHz)
17891797
// SDA/VCC shorted: 1000ms, response 5
17901798
// SDA/GND shorted: 14ms, response 5
17911799
timer = millis();
1800+
1801+
// If there is nothing else on the bus, the authentication coprocessor can be asleep
1802+
// Ping it twice to be sure
1803+
if (addr == 0x10)
1804+
i2cIsDevicePresent(i2cBus, addr); // Throw away result. Just wake it up.
1805+
17921806
if (i2cIsDevicePresent(i2cBus, addr))
17931807
{
17941808
if (deviceFound == false)

Firmware/RTK_Everywhere/Bluetooth.ino

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
2020
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2121

22+
BluetoothRadioType_e bluetoothRadioPreviousOnType = BLUETOOTH_RADIO_OFF;
23+
2224
#ifdef COMPILE_BT
2325

2426
//----------------------------------------
@@ -386,7 +388,10 @@ void BTConfirmRequestCallback(uint32_t numVal) {
386388

387389
// TODO: if the RTK device has an OLED, we should display the PIN so user can confirm
388390
systemPrintf("Device sent PIN: %06lu. Sending confirmation\r\n", numVal);
391+
#ifdef COMPILE_BT
389392
bluetoothSerialSpp->confirmReply(true); // AUTO_PAIR - equivalent to enableSSP(false, true);
393+
#endif // COMPILE_BT
394+
// TODO: if the RTK device has an OLED, we should display the PIN so user can confirm
390395
}
391396

392397
void deviceNameSpacesToUnderscores()
@@ -556,14 +561,14 @@ void bluetoothStart(bool skipOnlineCheck)
556561
bluetoothSerialSpp->enableSSP(false, false);
557562

558563
// Enable secure pairing with PIN :
559-
//bluetoothSerialSpp->enableSSP(false, true);
564+
// bluetoothSerialSpp->enableSSP(false, true);
560565

561566
// Accessory Protocol recommends using a PIN
562567
// Support Apple Accessory: Device to Accessory
563568
// 1. Search for an accessory from the device and initiate pairing.
564569
// 2. Verify pairing is successful after exchanging a pin code.
565-
//bluetoothSerialSpp->enableSSP(true, true); // Enable secure pairing with PIN
566-
//bluetoothSerialSpp->onConfirmRequest(&BTConfirmRequestCallback); // Callback to verify the PIN
570+
// bluetoothSerialSpp->enableSSP(true, true); // Enable secure pairing with PIN
571+
// bluetoothSerialSpp->onConfirmRequest(&BTConfirmRequestCallback); // Callback to verify the PIN
567572

568573
beginSuccess &= bluetoothSerialSpp->begin(
569574
deviceName, true, true, settings.sppRxQueueSize, settings.sppTxQueueSize, 0, 0,
@@ -595,9 +600,9 @@ void bluetoothStart(bool skipOnlineCheck)
595600
record.type = ESP_SDP_TYPE_RAW;
596601
record.uuid.len = sizeof(UUID_IAP2);
597602
memcpy(record.uuid.uuid.uuid128, UUID_IAP2, sizeof(UUID_IAP2));
598-
//record.service_name_length = strlen(sdp_service_name) + 1;
599-
//record.service_name = (char *)sdp_service_name;
600-
// Use the same EIR Local Name parameter as the Name in the IdentificationInformation
603+
// record.service_name_length = strlen(sdp_service_name) + 1;
604+
// record.service_name = (char *)sdp_service_name;
605+
// Use the same EIR Local Name parameter as the Name in the IdentificationInformation
601606
record.service_name_length = strlen(deviceName) + 1;
602607
record.service_name = (char *)deviceName;
603608
// record.rfcomm_channel_number = 1; // Doesn't seem to help the failed connects
@@ -672,7 +677,7 @@ void bluetoothStart(bool skipOnlineCheck)
672677

673678
if (pin_bluetoothStatusLED != PIN_UNDEFINED)
674679
{
675-
bluetoothLedTask.detach(); // Reset BT LED blinker task rate to 2Hz
680+
bluetoothLedTask.detach(); // Reset BT LED blinker task rate to 2Hz
676681
bluetoothLedTask.attach(bluetoothLedTaskPace2Hz, tickerBluetoothLedUpdate); // Rate in seconds, callback
677682
}
678683

@@ -682,11 +687,11 @@ void bluetoothStart(bool skipOnlineCheck)
682687
{
683688
if (bluetoothCommandTaskHandle == nullptr)
684689
xTaskCreatePinnedToCore(
685-
bluetoothCommandTask, // Function to run
686-
"BluetoothCommandTask", // Just for humans
687-
4000, // Stack Size - must be ~4000
688-
nullptr, // Task input parameter
689-
0, // Priority, with 3 (configMAX_PRIORITIES - 1) being the highest, and 0 being the lowest
690+
bluetoothCommandTask, // Function to run
691+
"BluetoothCommandTask", // Just for humans
692+
4000, // Stack Size - must be ~4000
693+
nullptr, // Task input parameter
694+
0, // Priority, with 3 (configMAX_PRIORITIES - 1) being the highest, and 0 being the lowest
690695
&bluetoothCommandTaskHandle, // Task handle
691696
settings.bluetoothInterruptsCore); // Core where task should run, 0 = core, 1 = Arduino
692697
}

Firmware/RTK_Everywhere/Developer.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ void wifiVerifyTables() {}
290290

291291
void menuTilt() {}
292292
void nmeaApplyCompensation(char *nmeaSentence, int arraySize) {}
293-
void tiltDetect() {}
293+
void tiltDetect() {systemPrintln("**Tilt Not Compiled**");}
294294
bool tiltIsCorrecting() {return(false);}
295295
void tiltRequestStop() {}
296296
void tiltSensorFactoryReset() {}

0 commit comments

Comments
 (0)