Skip to content

Commit d01e0b0

Browse files
committed
Improving Casting performance and display.
1 parent 93ecea1 commit d01e0b0

File tree

5 files changed

+13
-135
lines changed

5 files changed

+13
-135
lines changed

Firmware/RTK_Surveyor/Base.ino

Lines changed: 1 addition & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -155,130 +155,6 @@ bool startFixedBase()
155155
return (response);
156156
}
157157

158-
//Call regularly to push latest u-blox data out over local WiFi
159-
//We make sure we are connected to WiFi, then
160-
bool updateNtripServer()
161-
{
162-
//Is WiFi setup?
163-
if (WiFi.isConnected() == false)
164-
{
165-
//Turn off Bluetooth and turn on WiFi
166-
endBluetooth();
167-
168-
Serial.printf("Connecting to local WiFi: %s", settings.wifiSSID);
169-
WiFi.begin(settings.wifiSSID, settings.wifiPW);
170-
171-
int maxTime = 10000;
172-
long startTime = millis();
173-
while (WiFi.status() != WL_CONNECTED) {
174-
delay(500);
175-
Serial.print(F("."));
176-
177-
if (millis() - startTime > maxTime)
178-
{
179-
Serial.println(F("\nFailed to connect to WiFi. Are you sure your WiFi credentials are correct?"));
180-
return (false);
181-
}
182-
183-
if (Serial.available()) return (false); //User has pressed a key
184-
}
185-
Serial.println();
186-
187-
radioState = WIFI_CONNECTED;
188-
} //End WiFi connect check
189-
190-
//Are we connected to caster?
191-
if (caster.connected() == false)
192-
{
193-
Serial.printf("Opening socket to %s\n", settings.casterHost);
194-
195-
if (caster.connect(settings.casterHost, settings.casterPort) == true) //Attempt connection
196-
{
197-
Serial.printf("Connected to %s:%d\n", settings.casterHost, settings.casterPort);
198-
199-
const int SERVER_BUFFER_SIZE = 512;
200-
char serverBuffer[SERVER_BUFFER_SIZE];
201-
202-
snprintf(serverBuffer, SERVER_BUFFER_SIZE, "SOURCE %s /%s\r\nSource-Agent: NTRIP %s/%s\r\n\r\n",
203-
settings.mountPointPW, settings.mountPoint, ntrip_server_name, "App Version 1.0");
204-
205-
Serial.printf("Sending credentials:\n%s\n", serverBuffer);
206-
caster.write(serverBuffer, strlen(serverBuffer));
207-
208-
//Wait for response
209-
unsigned long timeout = millis();
210-
while (caster.available() == 0)
211-
{
212-
if (millis() - timeout > 5000)
213-
{
214-
Serial.println(F("Caster failed to respond. Do you have your caster address and port correct?"));
215-
caster.stop();
216-
delay(10);
217-
return (false);
218-
}
219-
delay(10);
220-
}
221-
222-
delay(10); //Yield to RTOS
223-
224-
//Check reply
225-
bool connectionSuccess = false;
226-
char response[512];
227-
int responseSpot = 0;
228-
while (caster.available())
229-
{
230-
response[responseSpot++] = caster.read();
231-
if (strstr(response, "200") > 0) //Look for 'ICY 200 OK'
232-
connectionSuccess = true;
233-
if (responseSpot == 512 - 1) break;
234-
}
235-
response[responseSpot] = '\0';
236-
Serial.printf("Caster responded with: %s\n", response);
237-
238-
if (connectionSuccess == false)
239-
{
240-
Serial.printf("Caster responded with bad news: %s. Are you sure your caster credentials are correct?", response);
241-
}
242-
else
243-
{
244-
//We're connected!
245-
Serial.println(F("Connected to caster"));
246-
247-
//Reset flags
248-
lastServerReport_ms = millis();
249-
lastServerSent_ms = millis();
250-
casterBytesSent = 0;
251-
}
252-
} //End attempt to connect
253-
else
254-
{
255-
Serial.println(F("Failed to connect to caster. Are you sure your Caster address is correct?"));
256-
delay(10); //Give RTOS some time
257-
return (false);
258-
}
259-
} //End connected == false
260-
261-
262-
//Close socket if we don't have new data for 10s
263-
//RTK2Go will ban your IP address if you abuse it. See http://www.rtk2go.com/how-to-get-your-ip-banned/
264-
//So let's not leave the socket open/hanging without data
265-
if (millis() - lastServerSent_ms > maxTimeBeforeHangup_ms)
266-
{
267-
Serial.println(F("RTCM timeout. Disconnecting from caster."));
268-
caster.stop();
269-
return (false);
270-
}
271-
272-
//Report some statistics every 250
273-
if (millis() - lastServerReport_ms > 250)
274-
{
275-
lastServerReport_ms = millis();
276-
Serial.printf("Total bytes sent to caster: %d\n", casterBytesSent);
277-
}
278-
279-
return (true);
280-
}
281-
282158
//This function gets called from the SparkFun u-blox Arduino Library.
283159
//As each RTCM byte comes in you can specify what to do with it
284160
//Useful for passing the RTCM correction data to a radio, Ntrip broadcaster, etc.
@@ -295,7 +171,7 @@ void SFE_UBLOX_GNSS::processRTCM(uint8_t incoming)
295171
//Check for too many digits
296172
if (logIncreasing == true)
297173
{
298-
if (rtcmPacketsSent > 999) rtcmPacketsSent = 1; //Trim to three digits to avoid logging icon
174+
if (rtcmPacketsSent > 999) rtcmPacketsSent = 1; //Trim to three digits to avoid log icon
299175
}
300176
else
301177
{

Firmware/RTK_Surveyor/Display.ino

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ void paintBaseTempWiFiStarted()
572572
oled.setFontType(1);
573573
printTextwithKerning("Xmitting", textX, textY, textKerning);
574574

575-
oled.setCursor(0, 38); //x, y
575+
oled.setCursor(0, 39); //x, y
576576
oled.setFontType(0);
577577
oled.print("RTCM:");
578578

@@ -604,7 +604,7 @@ void paintBaseTempWiFiConnected()
604604
oled.setFontType(1);
605605
printTextwithKerning("Xmitting", textX, textY, textKerning);
606606

607-
oled.setCursor(0, 38); //x, y
607+
oled.setCursor(0, 39); //x, y
608608
oled.setFontType(0);
609609
oled.print("RTCM:");
610610

@@ -662,7 +662,7 @@ void paintBaseTempCasterConnected()
662662
oled.setFontType(1);
663663
printTextwithKerning("Casting", textX, textY, textKerning);
664664

665-
oled.setCursor(0, 38); //x, y
665+
oled.setCursor(0, 39); //x, y
666666
oled.setFontType(0);
667667
oled.print("RTCM:");
668668

Firmware/RTK_Surveyor/States.ino

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ void updateSystemState()
200200
snprintf(serverBuffer, SERVER_BUFFER_SIZE, "SOURCE %s /%s\r\nSource-Agent: NTRIP %s/%s\r\n\r\n",
201201
settings.mountPointPW, settings.mountPoint, ntrip_server_name, "App Version 1.0");
202202

203-
Serial.printf("Sending credentials:\n%s\n", serverBuffer);
203+
//Serial.printf("Sending credentials:\n%s\n", serverBuffer);
204204
caster.write(serverBuffer, strlen(serverBuffer));
205205

206206
casterResponseWaitStartTime = millis();
@@ -219,7 +219,6 @@ void updateSystemState()
219219
{
220220
Serial.println(F("Caster failed to respond. Do you have your caster address and port correct?"));
221221
caster.stop();
222-
delay(10); //Yield to RTOS
223222

224223
changeState(STATE_BASE_TEMP_WIFI_CONNECTED); //Return to previous state
225224
}
@@ -238,17 +237,17 @@ void updateSystemState()
238237
if (responseSpot == 512 - 1) break;
239238
}
240239
response[responseSpot] = '\0';
241-
Serial.printf("Caster responded with: %s\n", response);
240+
//Serial.printf("Caster responded with: %s\n", response);
242241

243242
if (connectionSuccess == false)
244243
{
245-
Serial.printf("Caster responded with bad news: %s. Are you sure your caster credentials are correct?", response);
244+
Serial.printf("Caster responded with bad news: %s. Are you sure your caster credentials are correct?\n", response);
246245
changeState(STATE_BASE_TEMP_WIFI_CONNECTED); //Return to previous state
247246
}
248247
else
249248
{
250249
//We're connected!
251-
Serial.println(F("Connected to caster"));
250+
//Serial.println(F("Connected to caster"));
252251

253252
//Reset flags
254253
lastServerReport_ms = millis();
@@ -266,6 +265,7 @@ void updateSystemState()
266265
{
267266
if (caster.connected() == false)
268267
{
268+
Serial.println(F("Caster no longer connected. Reconnecting..."));
269269
changeState(STATE_BASE_TEMP_WIFI_CONNECTED); //Return to 2 earlier states to try to reconnect
270270
}
271271
}

Firmware/RTK_Surveyor/System.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ bool configureUbloxModule()
6666
}
6767

6868
getPortSettings(COM_PORT_I2C); //Load the settingPayload with this port's settings
69-
if (settingPayload[OUTPUT_SETTING] != (COM_TYPE_UBX | COM_TYPE_NMEA) || settingPayload[INPUT_SETTING] != COM_TYPE_UBX)
69+
if (settingPayload[OUTPUT_SETTING] != (COM_TYPE_UBX | COM_TYPE_NMEA | COM_TYPE_RTCM3) || settingPayload[INPUT_SETTING] != COM_TYPE_UBX)
7070
{
71-
response &= i2cGNSS.setPortOutput(COM_PORT_I2C, COM_TYPE_UBX | COM_TYPE_NMEA); //Set the I2C port to output UBX and NMEA
71+
response &= i2cGNSS.setPortOutput(COM_PORT_I2C, COM_TYPE_UBX | COM_TYPE_NMEA | COM_TYPE_RTCM3); //Set the I2C port to output UBX (config), NMEA (logging), and RTCM3 (casting)
7272
response &= i2cGNSS.setPortInput(COM_PORT_I2C, COM_TYPE_UBX); //Set the I2C port to input UBX only
7373
}
7474

Firmware/RTK_Surveyor/menuMain.ino

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
//If user doesn't respond within a few seconds, return to main loop
33
void menuMain()
44
{
5+
displaySerialConfig(); //Display 'Serial Config' while user is configuring
6+
57
while (1)
68
{
79
Serial.println();

0 commit comments

Comments
 (0)