Skip to content

Commit 3e52bf9

Browse files
author
Nathan Seidle
committed
Change LED colors.
1 parent 6e7f8ef commit 3e52bf9

16 files changed

+3646362
-400
lines changed

Firmware/MACInName/MACInName.ino

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#include "BluetoothSerial.h"
2+
BluetoothSerial SerialBT;
3+
4+
const int baseSwitch = 5;
5+
6+
void setup() {
7+
Serial.begin(115200);
8+
Serial.println("MAC test");
9+
10+
pinMode(baseSwitch, INPUT_PULLUP); //HIGH = rover, LOW = base
11+
12+
startBluetooth();
13+
14+
}
15+
16+
void loop() {
17+
18+
19+
}
20+
21+
//Tack device's MAC address to end of friendly broadcast name
22+
//This allows multiple units to be on at same time
23+
void startBluetooth()
24+
{
25+
uint8_t mac[6];
26+
esp_read_mac(mac, ESP_MAC_WIFI_STA);
27+
mac[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
28+
29+
char deviceName[20];
30+
if (digitalRead(baseSwitch) == HIGH)
31+
{
32+
//Rover mode
33+
sprintf(deviceName, "Surveyor Rover-%02X%02X", mac[4], mac[5]);
34+
}
35+
else
36+
{
37+
//Base mode
38+
sprintf(deviceName, "Surveyor Base-%02X%02X", mac[4], mac[5]);
39+
}
40+
41+
Serial.print("Bluetooth broadcast as: ");
42+
Serial.println(deviceName);
43+
44+
SerialBT.begin(deviceName);
45+
}

Firmware/RTK_Enclosed/Base.ino

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
//Wait for survey in to complete
2+
bool updateSurveyInStatus()
3+
{
4+
//Update the LEDs only every second or so
5+
if (millis() - lastBaseUpdate > 1000)
6+
{
7+
lastBaseUpdate = millis();
8+
9+
bool response = myGPS.getSurveyStatus(2000); //Query module for SVIN status with 2000ms timeout (req can take a long time)
10+
if (response == true)
11+
{
12+
if (myGPS.svin.valid == true)
13+
{
14+
Serial.println(F("Base survey complete! RTCM now broadcasting."));
15+
baseState = BASE_TRANSMITTING;
16+
17+
digitalWrite(baseStatusLED, HIGH); //Turn on LED
18+
}
19+
else
20+
{
21+
byte SIV = myGPS.getSIV();
22+
23+
Serial.print(F("Time elapsed: "));
24+
Serial.print((String)myGPS.svin.observationTime);
25+
Serial.print(F(" Accuracy: "));
26+
Serial.print((String)myGPS.svin.meanAccuracy);
27+
Serial.print(F(" SIV: "));
28+
Serial.print(SIV);
29+
Serial.println();
30+
31+
SerialBT.print(F("Time elapsed: "));
32+
SerialBT.print((String)myGPS.svin.observationTime);
33+
SerialBT.print(F(" Accuracy: "));
34+
SerialBT.print((String)myGPS.svin.meanAccuracy);
35+
SerialBT.print(F(" SIV: "));
36+
SerialBT.print(SIV);
37+
SerialBT.println();
38+
39+
if (myGPS.svin.meanAccuracy > 6.0)
40+
baseState = BASE_SURVEYING_IN_SLOW;
41+
else
42+
baseState = BASE_SURVEYING_IN_FAST;
43+
44+
if (myGPS.svin.observationTime > maxSurveyInWait_s)
45+
{
46+
Serial.println(F("Survey-In took more than 5 minutes. Restarting survey in."));
47+
48+
resetSurvey();
49+
50+
surveyIn();
51+
}
52+
}
53+
}
54+
else
55+
{
56+
Serial.println(F("SVIN request failed"));
57+
}
58+
}
59+
60+
//Update the Base LED accordingly
61+
if (baseState == BASE_SURVEYING_IN_SLOW)
62+
{
63+
if (millis() - baseStateBlinkTime > 500)
64+
{
65+
baseStateBlinkTime += 500;
66+
Serial.println(F("Slow blink"));
67+
68+
if (digitalRead(baseStatusLED) == LOW)
69+
digitalWrite(baseStatusLED, HIGH);
70+
else
71+
digitalWrite(baseStatusLED, LOW);
72+
}
73+
}
74+
else if (baseState == BASE_SURVEYING_IN_FAST)
75+
{
76+
if (millis() - baseStateBlinkTime > 100)
77+
{
78+
baseStateBlinkTime += 100;
79+
Serial.println(F("Fast blink"));
80+
81+
if (digitalRead(baseStatusLED) == LOW)
82+
digitalWrite(baseStatusLED, HIGH);
83+
else
84+
digitalWrite(baseStatusLED, LOW);
85+
}
86+
}
87+
}
88+
89+
//Configure specific aspects of the receiver for base mode
90+
bool configureUbloxModuleBase()
91+
{
92+
bool response = true;
93+
94+
digitalWrite(positionAccuracyLED_20mm, LOW);
95+
digitalWrite(positionAccuracyLED_100mm, LOW);
96+
digitalWrite(positionAccuracyLED_1000mm, LOW);
97+
98+
// Set dynamic model
99+
if (myGPS.getDynamicModel() != DYN_MODEL_STATIONARY)
100+
{
101+
if (myGPS.setDynamicModel(DYN_MODEL_STATIONARY) == false)
102+
{
103+
Serial.println(F("setDynamicModel failed!"));
104+
return (false);
105+
}
106+
}
107+
108+
if (getRTCMSettings(UBX_RTCM_1005, COM_PORT_UART2) != 1)
109+
response &= myGPS.enableRTCMmessage(UBX_RTCM_1005, COM_PORT_UART2, 1); //Enable message 1005 to output through UART2, message every second
110+
if (getRTCMSettings(UBX_RTCM_1074, COM_PORT_UART2) != 1)
111+
response &= myGPS.enableRTCMmessage(UBX_RTCM_1074, COM_PORT_UART2, 1);
112+
if (getRTCMSettings(UBX_RTCM_1084, COM_PORT_UART2) != 1)
113+
response &= myGPS.enableRTCMmessage(UBX_RTCM_1084, COM_PORT_UART2, 1);
114+
if (getRTCMSettings(UBX_RTCM_1094, COM_PORT_UART2) != 1)
115+
response &= myGPS.enableRTCMmessage(UBX_RTCM_1094, COM_PORT_UART2, 1);
116+
if (getRTCMSettings(UBX_RTCM_1124, COM_PORT_UART2) != 1)
117+
response &= myGPS.enableRTCMmessage(UBX_RTCM_1124, COM_PORT_UART2, 1);
118+
if (getRTCMSettings(UBX_RTCM_1230, COM_PORT_UART2) != 10)
119+
response &= myGPS.enableRTCMmessage(UBX_RTCM_1230, COM_PORT_UART2, 10); //Enable message every 10 seconds
120+
121+
if (response == false)
122+
{
123+
Serial.println(F("RTCM failed to enable."));
124+
return (false);
125+
}
126+
127+
return (response);
128+
}
129+
130+
//Start survey
131+
//The ZED-F9P is slightly different than the NEO-M8P. See the Integration manual 3.5.8 for more info.
132+
void surveyIn()
133+
{
134+
resetSurvey();
135+
136+
bool response = myGPS.enableSurveyMode(60, 5.000); //Enable Survey in, 60 seconds, 5.0m
137+
if (response == false)
138+
{
139+
Serial.println(F("Survey start failed"));
140+
return;
141+
}
142+
Serial.println(F("Survey started. This will run until 60s has passed and less than 5m accuracy is achieved."));
143+
144+
baseState = BASE_SURVEYING_IN_SLOW;
145+
}
146+
147+
void resetSurvey()
148+
{
149+
//Slightly modified method for restarting survey-in from: https://portal.u-blox.com/s/question/0D52p00009IsVoMCAV/restarting-surveyin-on-an-f9p
150+
bool response = myGPS.disableSurveyMode(); //Disable survey
151+
delay(500);
152+
response &= myGPS.enableSurveyMode(1000, 400.000); //Enable Survey in with bogus values
153+
delay(500);
154+
response &= myGPS.disableSurveyMode(); //Disable survey
155+
delay(500);
156+
}

0 commit comments

Comments
 (0)