Skip to content

Commit 15fe85c

Browse files
committed
Merge branch 'release_candidate' of https://github.com/sparkfun/SparkFun_RTK_Firmware into release_candidate
2 parents 257b0f1 + ef623b6 commit 15fe85c

File tree

8 files changed

+1021
-3
lines changed

8 files changed

+1021
-3
lines changed

Firmware/RTK_Surveyor/States.ino

Lines changed: 219 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,89 @@ void updateSystemState()
2323
//Move between states as needed
2424
switch (systemState)
2525
{
26+
/*
27+
.-----------------------------------.
28+
NTRIP Client | STATE_ROVER_NOT_STARTED |
29+
.------------| Text: 'Rover' and 'Rover Started' |
30+
| Enabled '-----------------------------------'
31+
| = False |
32+
| Stop WiFi, | NTRIP Client Enabled = True
33+
| Start | Stop Bluetooth
34+
| Bluetooth | Start WiFi
35+
| V
36+
| .-----------------------------------. 8 Sec
37+
| | STATE_ROVER_CLIENT_WIFI_STARTED | Connection
38+
| | Blinking WiFi Icon | Timeout
39+
| | "HPA: >30m" |--------------.
40+
| | "SIV: 0" | |
41+
| '-----------------------------------' |
42+
| | |
43+
| | radioState = WIFI_CONNECTED |
44+
| | WiFi connected = True |
45+
| V |
46+
| .-----------------------------------. |
47+
| | STATE_ROVER_CLIENT_WIFI_CONNECTED | Connection |
48+
| | Solid WiFi Icon | failed V
49+
| | "HPA: >30m" |------------->+
50+
| | "SIV: 0" | Stop WiFi, |
51+
| '-----------------------------------' Start |
52+
| | Bluetooth |
53+
| | |
54+
| | Client Started |
55+
| V |
56+
| .-----------------------------------. |
57+
| | STATE_ROVER_CLIENT_STARTED | No response, |
58+
| | Blinking WiFi Icon | unauthorized V
59+
| | "HPA: >30m" |------------->+
60+
| | "SIV: 0" | Stop WiFi, |
61+
| '-----------------------------------' Start |
62+
| | Bluetooth |
63+
| | |
64+
| | Client Connected |
65+
| V |
66+
'----------------------------->+<-------------------------------'
67+
|
68+
V
69+
.-----------------------------------.
70+
| STATE_ROVER_NO_FIX |
71+
| SIV Icon Blink |
72+
| "HPA: >30m" |
73+
| "SIV: 0" |
74+
'-----------------------------------'
75+
|
76+
| GPS Lock
77+
| 3D, 3D+DR
78+
V
79+
.-----------------------------------.
80+
| STATE_ROVER_FIX | Carrier
81+
| SIV Icon Solid | Solution = 2
82+
.-------->| "HPA: .513" |---------.
83+
| | "SIV: 30" | |
84+
| '-----------------------------------' |
85+
| | |
86+
| | Carrier Solution = 1 |
87+
| V |
88+
| .-----------------------------------. |
89+
| | STATE_ROVER_RTK_FLOAT | |
90+
| No RTK | Double Crosshair Blinking | |
91+
+<--------| "*HPA: .080" | |
92+
^ | "SIV: 30" | |
93+
| '-----------------------------------' |
94+
| ^ | |
95+
| | | Carrier |
96+
| | | Solution = 2 |
97+
| | V |
98+
| Carrier | +<-------------------'
99+
| Solution = 1 | |
100+
| | V
101+
| .-----------------------------------.
102+
| | STATE_ROVER_RTK_FIX |
103+
| No RTK | Double Crosshair Solid |
104+
'---------| "*HPA: .014" |
105+
| "SIV: 30" |
106+
'-----------------------------------'
107+
108+
*/
26109
case (STATE_ROVER_NOT_STARTED):
27110
{
28111
if (online.gnss == false)
@@ -305,6 +388,85 @@ void updateSystemState()
305388
}
306389
break;
307390

391+
/*
392+
.-----------------------------------.
393+
startBase() | STATE_BASE_NOT_STARTED |
394+
.------------| Text: 'Base' |
395+
| = false '-----------------------------------'
396+
| |
397+
| Stop WiFi, | startBase() = true
398+
| Stop | Stop WiFi
399+
| Bluetooth | Start Bluetooth
400+
| V
401+
| .-----------------------------------.
402+
| | STATE_BASE_TEMP_SETTLE |
403+
| | Temp Base Icon. Blinking HPA. |
404+
| | "HPA: 7.15" |
405+
| | "SIV: 5" |
406+
| '-----------------------------------'
407+
V |
408+
STATE_BASE_FIXED_NOT_STARTED | horizontalAccuracy > 0.0
409+
(next diagram) | && horizontalAccuracy
410+
| < settings.surveyInStartingAccuracy
411+
| && beginSurveyIn() == true
412+
V
413+
.-----------------------------------.
414+
| STATE_BASE_TEMP_SURVEY_STARTED | svinObservationTime >
415+
| Temp Base Icon blinking | maxSurveyInWait_s
416+
| "Mean: 0.089" |--------------.
417+
| "Time: 36" | |
418+
'-----------------------------------' |
419+
| |
420+
| getSurveyInValid() |
421+
| = true V
422+
| STATE_ROVER_NOT_STARTED
423+
V (Previous diagram)
424+
.-----------------------------------.
425+
| STATE_BASE_TEMP_TRANSMITTING |
426+
| Temp Base Icon solid |
427+
| "Xmitting" |
428+
| "RTCM: 2145" |
429+
'-----------------------------------'
430+
|
431+
| NTRIP enabled = true
432+
V
433+
.-----------------------------------.
434+
| STATE_BASE_TEMP_WIFI_STARTED |
435+
| Blinking WiFi Icon |
436+
| "Xmitting" |
437+
| "RTCM: 0" |
438+
'-----------------------------------'
439+
|
440+
| WiFi connected = true
441+
| radioState = WIFI_CONNECTED
442+
V
443+
.-----------------------------------.
444+
| STATE_BASE_TEMP_WIFI_CONNECTED |
445+
.--------------->| Solid WiFi Icon |
446+
| | "Xmitting" |
447+
| | "RTCM: 2145" |
448+
| '-----------------------------------'
449+
| |
450+
| | Caster enabled
451+
| V
452+
| .-----------------------------------.
453+
| | STATE_BASE_TEMP_CASTER_STARTED |
454+
| Caster failed | Solid WiFi Icon |
455+
+<---------------| "Connecting" |
456+
^ Authorization | "RTCM: 2145" |
457+
| failed '-----------------------------------'
458+
| |
459+
| | Caster connected
460+
| V
461+
| .-----------------------------------.
462+
| Caster failed | STATE_BASE_TEMP_CASTER_CONNECTED |
463+
'----------------| Solid WiFi Icon |
464+
| "Casting" |
465+
| "RTCM: 2145" |
466+
'-----------------------------------'
467+
468+
*/
469+
308470
case (STATE_BASE_NOT_STARTED):
309471
{
310472
if (online.gnss == false)
@@ -585,6 +747,63 @@ void updateSystemState()
585747
}
586748
break;
587749

750+
/*
751+
.-----------------------------------.
752+
startBase() | STATE_BASE_FIXED_NOT_STARTED |
753+
= false | Text: "Base Started" |
754+
.-------------| |
755+
| '-----------------------------------'
756+
V |
757+
STATE_ROVER_NOT_STARTED | startBase() = true
758+
(Rover diagram) V
759+
.-----------------------------------.
760+
| STATE_BASE_FIXED_TRANSMITTING |
761+
| Castle Base Icon solid |
762+
| "Xmitting" |
763+
| "RTCM: 0" |
764+
'-----------------------------------'
765+
|
766+
| NTRIP enabled = true
767+
| Stop Bluetooth
768+
| Start WiFi
769+
V
770+
.-----------------------------------.
771+
| STATE_BASE_FIXED_WIFI_STARTED |
772+
| Blinking WiFi Icon |
773+
| "Xmitting" |
774+
| "RTCM: 0" |
775+
'-----------------------------------'
776+
|
777+
| WiFi connected
778+
| radioState = WIFI_CONNECTED
779+
V
780+
.-----------------------------------.
781+
| STATE_BASE_FIXED_WIFI_CONNECTED |
782+
.----------->| Solid WiFi Icon |
783+
| | "Xmitting" |
784+
| | "RTCM: 2145" |
785+
| '-----------------------------------'
786+
| |
787+
| | Caster enabled
788+
| V
789+
| .-----------------------------------.
790+
| Caster | STATE_BASE_FIXED_CASTER_STARTED |
791+
| Connection | Solid WiFi Icon |
792+
| Failed | "Xmitting" |
793+
+------------| "RTCM: 2145" |
794+
^ Failed '-----------------------------------'
795+
| Authroization |
796+
| | Caster connected
797+
| V
798+
| .-----------------------------------.
799+
| Caster | STATE_BASE_FIXED_WIFI_CONNECTED |
800+
| Connection | Solid WiFi Icon |
801+
| Failed | "Casting" |
802+
'------------| "RTCM: 2145" |
803+
'-----------------------------------'
804+
805+
*/
806+
588807
//User has set switch to base with fixed option enabled. Let's configure and try to get there.
589808
//If fixed base fails, we'll handle it here
590809
case (STATE_BASE_FIXED_NOT_STARTED):

Firmware/RTK_Surveyor/Tasks.ino

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,39 @@ void ButtonCheckTask(void *e)
132132

133133
while (true)
134134
{
135+
/* RTK Surveyor
136+
137+
.----------------------------.
138+
| |
139+
V |
140+
.------------------. |
141+
| Power On | |
142+
'------------------' |
143+
| |
144+
| Setup button = 0 |
145+
V |
146+
.------------------. |
147+
.------>| Rover Mode | |
148+
| '------------------' |
149+
| | |
150+
| | Setup button = 1 |
151+
| V |
152+
| .------------------. |
153+
'-------| Base Mode | |
154+
Setup button = 0 '------------------' |
155+
after long time | | |
156+
| | Setup button = 0 |
157+
Setup button = 0 | | after short time |
158+
after short time | | (< 500 mSec) |
159+
(< 500 mSec) | | |
160+
STATE_ROVER_NOT_STARTED | | |
161+
V V |
162+
.------------------. .------------------. |
163+
| Test Mode | | WiFi Config Mode |----------'
164+
'------------------' '------------------'
165+
166+
*/
167+
135168
if (productVariant == RTK_SURVEYOR)
136169
{
137170
setupBtn->read();

Firmware/Test Sketches/SD_FileListing/SD_FileListing.ino

Lines changed: 73 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
#include "settings.h"
88

9+
#define ASCII_LF 0x0a
10+
#define ASCII_CR 0x0d
11+
912
int pin_microSD_CS = 25;
1013

1114
//microSD Interface
@@ -34,6 +37,10 @@ const TickType_t fatSemaphore_longWait_ms = 200 / portTICK_PERIOD_MS;
3437
uint32_t sdCardSizeMB = 0;
3538
uint32_t sdFreeSpaceMB = 0;
3639
uint32_t sdUsedSpaceMB = 0;
40+
41+
char filename[1024];
42+
uint8_t buffer[5701];
43+
3744
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
3845

3946
void setup()
@@ -52,9 +59,72 @@ void setup()
5259

5360
void loop()
5461
{
62+
int bytesRead;
63+
int bytesToRead;
64+
char data;
65+
int length;
66+
SdFile sdFile;
67+
SdFile sdRootDir;
68+
69+
// Read the filename
70+
Serial.println("\nPlease enter the filename:");
71+
length = 0;
72+
do {
73+
while (!Serial.available());
74+
data = Serial.read();
75+
if ((data == ASCII_LF) || (data == ASCII_CR))
76+
break;
77+
filename[length++] = data;
78+
} while (1);
79+
filename[length] = 0;
80+
81+
// Skip reading the SD card if no filename is specified
82+
if (length) {
83+
Serial.printf("filename: %s\n", filename);
84+
do {
85+
86+
// Attempt to open the root directory
87+
Serial.println("Attempting to open the root directory");
88+
sdRootDir = SdFile();
89+
if (!sdRootDir.openRoot(sd.vol())) {
90+
Serial.println("ERROR - Failed to open root directory!");
91+
break;
92+
}
93+
94+
// Attempt to open the file
95+
Serial.printf("Attempting to open file %s\n", filename);
96+
if (!sdFile.open(&sdRootDir, filename, O_RDONLY)) {
97+
// File not found
98+
Serial.println("ERROR - File not found!");
99+
sdRootDir.close();
100+
break;
101+
}
102+
Serial.printf("File %s opened successfully!\n", filename);
103+
104+
// Close the root directory
105+
Serial.println("Closing the root directory");
106+
sdRootDir.close();
107+
108+
// Read the file
109+
do {
110+
111+
// Read data from the file
112+
bytesToRead = sizeof(buffer);
113+
Serial.printf("Attempting to read %d bytes from %s\n", bytesToRead, filename);
114+
bytesRead = sdFile.read(buffer, bytesToRead);
115+
Serial.printf("bytesRead: %d\n", bytesRead);
116+
} while (bytesRead > 0);
117+
118+
// Close the file
119+
Serial.printf("Closing %s\n", filename);
120+
sdFile.close();
121+
Serial.println();
122+
} while (0);
123+
}
124+
125+
// Wait for user to confirm reset
55126
Serial.println("Press a key to reset");
56127

57-
if (Serial.available()) ESP.restart();
58-
59-
delay(1000);
128+
while (!Serial.available());
129+
ESP.restart();
60130
}

0 commit comments

Comments
 (0)