Skip to content

Commit 1370e9b

Browse files
committed
Add NTRIP_SERVER_DATA structure
1 parent aa87640 commit 1370e9b

File tree

2 files changed

+55
-23
lines changed

2 files changed

+55
-23
lines changed

Firmware/RTK_Surveyor/RTK_Surveyor.ino

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,28 @@
6060
// the minor firmware version
6161
#define RTK_IDENTIFIER (FIRMWARE_VERSION_MAJOR * 0x10 + FIRMWARE_VERSION_MINOR)
6262

63+
#ifdef COMPILE_ETHERNET
64+
#include <Ethernet.h> // http://librarymanager/All#Arduino_Ethernet
65+
#include "SparkFun_WebServer_ESP32_W5500.h" //http://librarymanager/All#SparkFun_WebServer_ESP32_W5500 v1.5.5
66+
#endif // COMPILE_ETHERNET
67+
68+
#ifdef COMPILE_WIFI
69+
#include "ESP32OTAPull.h" //http://librarymanager/All#ESP-OTA-Pull Used for getting
70+
#include "esp_wifi.h" //Needed for esp_wifi_set_protocol()
71+
#include <DNSServer.h> //Built-in.
72+
#include <ESPmDNS.h> //Built-in.
73+
#include <HTTPClient.h> //Built-in. Needed for ThingStream API for ZTP
74+
#include <PubSubClient.h> //http://librarymanager/All#PubSubClient_MQTT_Lightweight by Nick O'Leary v2.8.0 Used for MQTT obtaining of keys
75+
#include <WiFi.h> //Built-in.
76+
#include <WiFiClientSecure.h> //Built-in.
77+
#include <WiFiMulti.h> //Built-in.
78+
#endif // COMPILE_WIFI
79+
80+
#if COMPILE_NETWORK
81+
#include <SSLClientESP32.h> // http://librarymanager/All#SSLClientESP32
82+
#include "X509_Certificate_Bundle.h" // Root certificates
83+
#endif // COMPILE_NETWORK
84+
6385
#include "settings.h"
6486

6587
#define MAX_CPU_CORES 2
@@ -200,10 +222,6 @@ char logFileName[sizeof("SFE_Reference_Station_230101_120101.ubx_plusExtraSpace"
200222
// Over-the-Air (OTA) update support
201223
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
202224

203-
#if COMPILE_NETWORK
204-
#include <SSLClientESP32.h> // http://librarymanager/All#SSLClientESP32
205-
#include "X509_Certificate_Bundle.h" // Root certificates
206-
#endif // COMPILE_NETWORK
207225
#include <ArduinoJson.h> //http://librarymanager/All#Arduino_JSON_messagepack v6.19.4
208226

209227
#include "esp_ota_ops.h" //Needed for partition counting and updateFromSD
@@ -216,7 +234,6 @@ char logFileName[sizeof("SFE_Reference_Station_230101_120101.ubx_plusExtraSpace"
216234
}
217235

218236
#ifdef COMPILE_WIFI
219-
#include "ESP32OTAPull.h" //http://librarymanager/All#ESP-OTA-Pull Used for getting
220237

221238
#define WIFI_STOP() \
222239
{ \
@@ -237,19 +254,6 @@ unsigned int binBytesSent = 0; // Tracks firmware bytes sent over WiFi O
237254
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
238255
// Connection settings to NTRIP Caster
239256
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
240-
#ifdef COMPILE_WIFI
241-
#include <ESPmDNS.h> //Built-in.
242-
#include <HTTPClient.h> //Built-in. Needed for ThingStream API for ZTP
243-
#include <PubSubClient.h> //http://librarymanager/All#PubSubClient_MQTT_Lightweight by Nick O'Leary v2.8.0 Used for MQTT obtaining of keys
244-
#include <WiFi.h> //Built-in.
245-
#include <WiFiClientSecure.h> //Built-in.
246-
#include <WiFiMulti.h> //Built-in.
247-
#include <DNSServer.h> //Built-in.
248-
249-
#include "esp_wifi.h" //Needed for esp_wifi_set_protocol()
250-
251-
#endif // COMPILE_WIFI
252-
253257
#include "base64.h" //Built-in. Needed for NTRIP Client credential encoding.
254258

255259
bool enableRCFirmware = false; // Goes true from AP config page
@@ -574,7 +578,6 @@ const uint8_t ESPNOW_MAX_PEERS = 5; // Maximum of 5 rovers
574578
// Ethernet
575579
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
576580
#ifdef COMPILE_ETHERNET
577-
#include <Ethernet.h> // http://librarymanager/All#Arduino_Ethernet
578581
IPAddress ethernetIPAddress;
579582
IPAddress ethernetDNS;
580583
IPAddress ethernetGateway;
@@ -591,15 +594,11 @@ class derivedEthernetUDP : public EthernetUDP
591594
volatile struct timeval ethernetNtpTv; // This will hold the time the Ethernet NTP packet arrived
592595
bool ntpLogIncreasing;
593596

594-
#include "SparkFun_WebServer_ESP32_W5500.h" //http://librarymanager/All#SparkFun_WebServer_ESP32_W5500 v1.5.5
595597
#endif // COMPILE_ETHERNET
596598

597599
unsigned long lastEthernetCheck = 0; // Prevents cable checking from continually happening
598600
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
599601

600-
#include "NetworkClient.h" //Supports both WiFiClient and EthernetClient
601-
#include "NetworkUDP.h" //Supports both WiFiUdp and EthernetUdp
602-
603602
// Global variables
604603
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
605604
#define lbandMACAddress btMACAddress

Firmware/RTK_Surveyor/settings.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#ifndef __SETTINGS_H__
2+
#define __SETTINGS_H__
3+
14
// System can enter a variety of states
25
// See statemachine diagram at:
36
// https://lucid.app/lucidchart/53519501-9fa5-4352-aa40-673f88ca0c9b/edit?invitationId=inv_ebd4b988-513d-4169-93fd-c291851108f8
@@ -274,6 +277,35 @@ enum WiFiState
274277
};
275278
volatile byte wifiState = WIFI_STATE_OFF;
276279

280+
#include "NetworkClient.h" // Built-in - Supports both WiFiClient and EthernetClient
281+
#include "NetworkUDP.h" //Built-in - Supports both WiFiUdp and EthernetUdp
282+
283+
// NTRIP Server data
284+
typedef struct _NTRIP_SERVER_DATA
285+
{
286+
// Network connection used to push RTCM to NTRIP caster
287+
NetworkClient *networkClient;
288+
volatile uint8_t state;
289+
290+
// Count of bytes sent by the NTRIP server to the NTRIP caster
291+
uint32_t bytesSent;
292+
293+
// Throttle the time between connection attempts
294+
// ms - Max of 4,294,967,295 or 4.3M seconds or 71,000 minutes or 1193 hours or 49 days between attempts
295+
uint32_t connectionAttemptTimeout;
296+
uint32_t lastConnectionAttempt;
297+
int connectionAttempts; // Count the number of connection attempts between restarts
298+
299+
// NTRIP server timer usage:
300+
// * Reconnection delay
301+
// * Measure the connection response time
302+
// * Receive RTCM correction data timeout
303+
// * Monitor last RTCM byte received for frame counting
304+
uint32_t timer;
305+
uint32_t startTime;
306+
int connectionAttemptsTotal; // Count the number of connection attempts absolutely
307+
} NTRIP_SERVER_DATA;
308+
277309
typedef enum
278310
{
279311
ESPNOW_OFF,
@@ -1177,3 +1209,4 @@ rqXRfboQnoZsG4q5WTP468SQvvG5
11771209
)=====";
11781210
#endif // COMPILE_L_BAND
11791211
#endif // COMPILE_WIFI
1212+
#endif // __SETTINGS_H__

0 commit comments

Comments
 (0)