Skip to content

Commit aeb47d8

Browse files
authored
Merge pull request #55 from sparkfun/release_candidate
Add WiFi config. Fix SPP congestion. Add ZED-F9R support.
2 parents 698c6cd + 7eb6ebe commit aeb47d8

39 files changed

+15998
-1121
lines changed
Binary file not shown.
Binary file not shown.
15 KB
Binary file not shown.

Firmware/RTK_Surveyor/AP-Config/index.html

Lines changed: 1065 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
@font-face {
2+
font-family: "bootstrap-icons";
3+
src:
4+
url('fonts/bootstrap-icons.woff2') format("woff2");
5+
/* url('fonts/bootstrap-icons.woff') format("woff"); */
6+
}
7+
8+
[class^="bi-"]::before,
9+
[class*=" bi-"]::before {
10+
display: inline-block;
11+
font-family: bootstrap-icons !important;
12+
font-style: normal;
13+
font-weight: normal !important;
14+
font-variant: normal;
15+
text-transform: none;
16+
line-height: 1;
17+
vertical-align: -.125em;
18+
-webkit-font-smoothing: antialiased;
19+
-moz-osx-font-smoothing: grayscale;
20+
}
21+
22+
.bi-caret-down-fill::before { content: "\f229"; }
23+
.bi-caret-up-fill::before { content: "\f235"; }
24+
.bi-save2::before { content: "\f527"; }
25+
.bi-x-circle::before { content: "\f623"; }
26+
.bi-info-circle-fill::before { content: "\f430"; }

Firmware/RTK_Surveyor/AP-Config/src/bootstrap.min.css

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Firmware/RTK_Surveyor/AP-Config/src/bootstrap.min.js

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.
Binary file not shown.
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 4 additions & 0 deletions
Loading

Firmware/RTK_Surveyor/AP-Config/src/jquery-3.6.0.min.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 547 additions & 0 deletions
Large diffs are not rendered by default.
Loading

Firmware/RTK_Surveyor/Base.ino

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,6 @@ bool configureUbloxModuleBase()
55
bool response = true;
66
int maxWait = 2000;
77

8-
if (productVariant == RTK_SURVEYOR)
9-
{
10-
digitalWrite(pin_positionAccuracyLED_1cm, LOW);
11-
digitalWrite(pin_positionAccuracyLED_10cm, LOW);
12-
digitalWrite(pin_positionAccuracyLED_100cm, LOW);
13-
}
14-
158
i2cGNSS.checkUblox(); //Regularly poll to get latest data and any RTCM
169

1710
if (i2cGNSS.getSurveyInActive() == true)

Firmware/RTK_Surveyor/Begin.ino

Lines changed: 129 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ void beginBoard()
1212
}
1313
else if (isConnected(0x19) == true) //Check for accelerometer
1414
{
15-
productVariant = RTK_EXPRESS;
15+
if (zedModuleType == PLATFORM_F9P) productVariant = RTK_EXPRESS;
16+
else if (zedModuleType == PLATFORM_F9R) productVariant = RTK_EXPRESS_PLUS;
1617
}
1718
else
1819
{
@@ -29,16 +30,20 @@ void beginBoard()
2930
pin_positionAccuracyLED_100cm = 13;
3031
pin_baseStatusLED = 4;
3132
pin_bluetoothStatusLED = 12;
32-
pin_baseSwitch = 5;
33+
pin_setupButton = 5;
3334
pin_microSD_CS = 25;
3435
pin_zed_tx_ready = 26;
3536
pin_zed_reset = 27;
3637
pin_batteryLevel_alert = 36;
3738

39+
//Bug in ZED-F9P v1.13 firmware causes RTK LED to not light when RTK Floating with SBAS on.
40+
//The following changes the POR default but will be overwritten by settings in NVM or settings file
41+
ubxConstellations[1].enabled = false;
42+
3843
strcpy(platformFilePrefix, "SFE_Surveyor");
3944
strcpy(platformPrefix, "Surveyor");
4045
}
41-
else if (productVariant == RTK_EXPRESS)
46+
else if (productVariant == RTK_EXPRESS || productVariant == RTK_EXPRESS_PLUS)
4247
{
4348
pin_muxA = 2;
4449
pin_muxB = 4;
@@ -61,8 +66,16 @@ void beginBoard()
6166

6267
setMuxport(settings.dataPortChannel); //Set mux to user's choice: NMEA, I2C, PPS, or DAC
6368

64-
strcpy(platformFilePrefix, "SFE_Express");
65-
strcpy(platformPrefix, "Express");
69+
if (productVariant == RTK_EXPRESS)
70+
{
71+
strcpy(platformFilePrefix, "SFE_Express");
72+
strcpy(platformPrefix, "Express");
73+
}
74+
else if (productVariant == RTK_EXPRESS_PLUS)
75+
{
76+
strcpy(platformFilePrefix, "SFE_Express_Plus");
77+
strcpy(platformPrefix, "Express Plus");
78+
}
6679
}
6780
else if (productVariant == RTK_FACET)
6881
{
@@ -89,8 +102,6 @@ void beginBoard()
89102

90103
setMuxport(settings.dataPortChannel); //Set mux to user's choice: NMEA, I2C, PPS, or DAC
91104

92-
delay(1000);
93-
94105
strcpy(platformFilePrefix, "SFE_Facet");
95106
strcpy(platformPrefix, "Facet");
96107
}
@@ -101,10 +112,14 @@ void beginBoard()
101112
if (esp_reset_reason() == ESP_RST_POWERON)
102113
{
103114
reuseLastLog = false; //Start new log
115+
settings.resetCount = 0;
116+
recordSystemSettings(); //Record to NVM
104117
}
105118
else
106119
{
107120
reuseLastLog = true; //Attempt to reuse previous log
121+
settings.resetCount++;
122+
recordSystemSettings(); //Record to NVM
108123

109124
Serial.print("Reset reason: ");
110125
switch (esp_reset_reason())
@@ -188,25 +203,76 @@ void beginSD()
188203
}
189204
}
190205

206+
//We want the UART2 interrupts to be pinned to core 0 to avoid competing with I2C interrupts
191207
//We do not start the UART2 for GNSS->BT reception here because the interrupts would be pinned to core 1
192-
//competing with I2C interrupts
193-
//See issue: https://github.com/espressif/arduino-esp32/issues/3386
194208
//We instead start a task that runs on core 0, that then begins serial
209+
//See issue: https://github.com/espressif/arduino-esp32/issues/3386
195210
void beginUART2()
196211
{
197-
if (startUART2TaskHandle == NULL) xTaskCreatePinnedToCore(
198-
startUART2Task,
212+
if (pinUART2TaskHandle == NULL) xTaskCreatePinnedToCore(
213+
pinUART2Task,
199214
"UARTStart", //Just for humans
200215
2000, //Stack Size
201216
NULL, //Task input parameter
202217
0, // Priority, with 3 (configMAX_PRIORITIES - 1) being the highest, and 0 being the lowest.
203-
&startUART2TaskHandle, //Task handle
218+
&pinUART2TaskHandle, //Task handle
204219
0); //Core where task should run, 0=core, 1=Arduino
205220

206-
while (uart2Started == false) //Wait for task to run once
221+
while (uart2pinned == false) //Wait for task to run once
207222
delay(1);
208223
}
209224

225+
//Assign UART2 interrupts to the core 0. See: https://github.com/espressif/arduino-esp32/issues/3386
226+
void pinUART2Task( void *pvParameters )
227+
{
228+
serialGNSS.begin(settings.dataPortBaud); //UART2 on pins 16/17 for SPP. The ZED-F9P will be configured to output NMEA over its UART1 at the same rate.
229+
serialGNSS.setRxBufferSize(SERIAL_SIZE_RX);
230+
serialGNSS.setTimeout(50);
231+
232+
uart2pinned = true;
233+
234+
vTaskDelete( NULL ); //Delete task once it has run once
235+
}
236+
237+
//Serial Read/Write tasks for the F9P must be started after BT is up and running otherwise SerialBT.available will cause reboot
238+
void startUART2Tasks()
239+
{
240+
//Start the tasks for handling incoming and outgoing BT bytes to/from ZED-F9P
241+
if (F9PSerialReadTaskHandle == NULL)
242+
xTaskCreate(
243+
F9PSerialReadTask,
244+
"F9Read", //Just for humans
245+
readTaskStackSize, //Stack Size
246+
NULL, //Task input parameter
247+
F9PSerialReadTaskPriority, //Priority
248+
&F9PSerialReadTaskHandle); //Task handle
249+
250+
if (F9PSerialWriteTaskHandle == NULL)
251+
xTaskCreate(
252+
F9PSerialWriteTask,
253+
"F9Write", //Just for humans
254+
writeTaskStackSize, //Stack Size
255+
NULL, //Task input parameter
256+
F9PSerialWriteTaskPriority, //Priority
257+
&F9PSerialWriteTaskHandle); //Task handle
258+
}
259+
260+
//Stop tasks - useful when running firmware update or WiFi AP is running
261+
void stopUART2Tasks()
262+
{
263+
//Delete tasks if running
264+
if (F9PSerialReadTaskHandle != NULL)
265+
{
266+
vTaskDelete(F9PSerialReadTaskHandle);
267+
F9PSerialReadTaskHandle = NULL;
268+
}
269+
if (F9PSerialWriteTaskHandle != NULL)
270+
{
271+
vTaskDelete(F9PSerialWriteTaskHandle);
272+
F9PSerialWriteTaskHandle = NULL;
273+
}
274+
}
275+
210276
//ESP32 requires the creation of an EEPROM space
211277
void beginEEPROM()
212278
{
@@ -229,7 +295,7 @@ void beginDisplay()
229295
}
230296
}
231297

232-
//Connect to and configure ZED-F9P
298+
//Connect to ZED module and identify particulars
233299
void beginGNSS()
234300
{
235301
if (i2cGNSS.begin() == false)
@@ -250,32 +316,32 @@ void beginGNSS()
250316
//Check the firmware version of the ZED-F9P. Based on Example21_ModuleInfo.
251317
if (i2cGNSS.getModuleInfo(1100) == true) // Try to get the module info
252318
{
319+
//i2cGNSS.minfo.extension[1] looks like 'FWVER=HPG 1.12'
253320
strcpy(zedFirmwareVersion, i2cGNSS.minfo.extension[1]);
254321

255-
//i2cGNSS.minfo.extension[1] looks like 'FWVER=HPG 1.12'
256-
//Replace = with - to avoid NVM parsing issues
257-
char *ptr = strchr(zedFirmwareVersion, '=');
322+
//Remove 'FWVER='. It's extraneous and = causes settings file parsing issues
323+
char *ptr = strstr(zedFirmwareVersion, "FWVER=");
258324
if (ptr != NULL)
259-
zedFirmwareVersion[ptr - zedFirmwareVersion] = ':';
260-
261-
Serial.print(F("ZED-F9P firmware: "));
262-
Serial.println(zedFirmwareVersion);
263-
264-
// if (strcmp(i2cGNSS.minfo.extension[1], latestZEDFirmware) != 0)
265-
// {
266-
// Serial.print(F("The ZED-F9P appears to have outdated firmware. Found: "));
267-
// Serial.println(i2cGNSS.minfo.extension[1]);
268-
// Serial.print(F("The Surveyor works best with "));
269-
// Serial.println(latestZEDFirmware);
270-
// Serial.print(F("Please upgrade using u-center."));
271-
// Serial.println();
272-
// }
273-
// else
274-
// {
275-
// Serial.println(F("ZED-F9P firmware is current"));
276-
// }
325+
strcpy(zedFirmwareVersion, ptr + strlen("FWVER="));
326+
327+
//Determine if we have a ZED-F9P (Express/Facet) or an ZED-F9R (Express Plus/Facet Plus)
328+
if (strstr(i2cGNSS.minfo.extension[3], "ZED-F9P") != NULL)
329+
{
330+
zedModuleType = PLATFORM_F9P;
331+
}
332+
else if (strstr(i2cGNSS.minfo.extension[3], "ZED-F9R") != NULL)
333+
{
334+
zedModuleType = PLATFORM_F9R;
335+
}
336+
337+
printModuleInfo(); //Print module type and firmware version
277338
}
339+
online.gnss = true;
340+
}
278341

342+
//Configuration can take >1s so configure during splash
343+
void configureGNSS()
344+
{
279345
bool response = configureUbloxModule();
280346
if (response == false)
281347
{
@@ -293,8 +359,6 @@ void beginGNSS()
293359
}
294360

295361
Serial.println(F("GNSS configuration complete"));
296-
297-
online.gnss = true;
298362
}
299363

300364
//Set LEDs for output and configure PWM
@@ -307,22 +371,25 @@ void beginLEDs()
307371
pinMode(pin_positionAccuracyLED_100cm, OUTPUT);
308372
pinMode(pin_baseStatusLED, OUTPUT);
309373
pinMode(pin_bluetoothStatusLED, OUTPUT);
310-
pinMode(pin_baseSwitch, INPUT_PULLUP); //HIGH = rover, LOW = base
374+
pinMode(pin_setupButton, INPUT_PULLUP); //HIGH = rover, LOW = base
311375

312376
digitalWrite(pin_positionAccuracyLED_1cm, LOW);
313377
digitalWrite(pin_positionAccuracyLED_10cm, LOW);
314378
digitalWrite(pin_positionAccuracyLED_100cm, LOW);
315379
digitalWrite(pin_baseStatusLED, LOW);
316380
digitalWrite(pin_bluetoothStatusLED, LOW);
317381

318-
ledcSetup(ledRedChannel, freq, resolution);
319-
ledcSetup(ledGreenChannel, freq, resolution);
382+
ledcSetup(ledRedChannel, pwmFreq, pwmResolution);
383+
ledcSetup(ledGreenChannel, pwmFreq, pwmResolution);
384+
ledcSetup(ledBTChannel, pwmFreq, pwmResolution);
320385

321386
ledcAttachPin(pin_batteryLevelLED_Red, ledRedChannel);
322387
ledcAttachPin(pin_batteryLevelLED_Green, ledGreenChannel);
388+
ledcAttachPin(pin_bluetoothStatusLED, ledBTChannel);
323389

324390
ledcWrite(ledRedChannel, 0);
325391
ledcWrite(ledGreenChannel, 0);
392+
ledcWrite(ledBTChannel, 0);
326393
}
327394
}
328395

@@ -368,19 +435,31 @@ void beginSystemState()
368435
{
369436
if (productVariant == RTK_SURVEYOR)
370437
{
371-
//Assume Rover. checkButtons() will correct as needed.
372-
systemState = STATE_ROVER_NOT_STARTED;
373-
buttonPreviousState = BUTTON_BASE;
438+
systemState = STATE_ROVER_NOT_STARTED; //Assume Rover. ButtonCheckTask_Switch() will correct as needed.
439+
440+
setupBtn = new Button(pin_setupButton); //Create the button in memory
374441
}
375-
if (productVariant == RTK_EXPRESS || productVariant == RTK_EXPRESS)
442+
else if (productVariant == RTK_EXPRESS || productVariant == RTK_EXPRESS_PLUS)
376443
{
377444
systemState = settings.lastState; //Return to system state previous to power down.
378445

379-
if (systemState == STATE_ROVER_NOT_STARTED)
380-
buttonPreviousState = BUTTON_ROVER;
381-
else if (systemState == STATE_BASE_NOT_STARTED)
382-
buttonPreviousState = BUTTON_BASE;
383-
else
384-
buttonPreviousState = BUTTON_ROVER;
446+
setupBtn = new Button(pin_setupButton); //Create the button in memory
447+
powerBtn = new Button(pin_powerSenseAndControl); //Create the button in memory
385448
}
449+
else if (productVariant == RTK_FACET)
450+
{
451+
systemState = settings.lastState; //Return to system state previous to power down.
452+
453+
powerBtn = new Button(pin_powerSenseAndControl); //Create the button in memory
454+
}
455+
456+
//Starts task for monitoring button presses
457+
if (ButtonCheckTaskHandle == NULL)
458+
xTaskCreate(
459+
ButtonCheckTask,
460+
"BtnCheck", //Just for humans
461+
buttonTaskStackSize, //Stack Size
462+
NULL, //Task input parameter
463+
ButtonCheckTaskPriority, //Priority, with 3 (configMAX_PRIORITIES - 1) being the highest, and 0 being the lowest.
464+
&ButtonCheckTaskHandle); //Task handle
386465
}

0 commit comments

Comments
 (0)