Skip to content

Commit 160f634

Browse files
authored
Merge pull request #696 from LeeLeahy2/no-wifi-ethernet
Fix compiles with and without COMPILE_ETHERNET and COMPILE_WIFI
2 parents 7f955a4 + b7650ff commit 160f634

File tree

5 files changed

+73
-32
lines changed

5 files changed

+73
-32
lines changed

Firmware/RTK_Surveyor/Developer.ino

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,32 @@ void ntripServerStop(bool clientAllocated) {online.ntripServer = false;}
7373
void ntripServerUpdate() {}
7474
void ntripServerValidateTables() {}
7575

76+
//----------------------------------------
77+
// OTA client
78+
//----------------------------------------
79+
80+
void otaVerifyTables() {}
81+
82+
//----------------------------------------
83+
// PVT client
84+
//----------------------------------------
85+
86+
int32_t pvtClientSendData(uint16_t dataHead) {return 0;}
87+
void pvtClientUpdate() {}
88+
void pvtClientValidateTables() {}
89+
void pvtClientZeroTail() {}
90+
void discardPvtClientBytes(RING_BUFFER_OFFSET previousTail, RING_BUFFER_OFFSET newTail) {}
91+
92+
//----------------------------------------
93+
// PVT UDP server
94+
//----------------------------------------
95+
96+
int32_t pvtUdpServerSendData(uint16_t dataHead) {return 0;}
97+
void pvtUdpServerStop() {}
98+
void pvtUdpServerUpdate() {}
99+
void pvtUdpServerZeroTail() {}
100+
void discardPvtUdpServerBytes(RING_BUFFER_OFFSET previousTail, RING_BUFFER_OFFSET newTail) {}
101+
76102
#endif // COMPILE_NETWORK
77103

78104
//----------------------------------------
@@ -92,35 +118,16 @@ bool parseIncomingSettings() {return false;}
92118
#endif // COMPILE_AP
93119
#ifndef COMPILE_WIFI
94120

95-
//----------------------------------------
96-
// PVT client
97-
//----------------------------------------
98-
99-
uint16_t pvtClientSendData(uint16_t dataHead) {return 0;};
100-
void pvtClientUpdate() {}
101-
void pvtClientValidateTables() {}
102-
void pvtClientZeroTail() {}
103-
void discardPvtClientBytes(RING_BUFFER_OFFSET previousTail, RING_BUFFER_OFFSET newTail) {}
104-
105-
106121
//----------------------------------------
107122
// PVT server
108123
//----------------------------------------
109124

110-
int pvtServerSendData(uint16_t dataHead) {return 0;}
125+
int32_t pvtServerSendData(uint16_t dataHead) {return 0;}
126+
void pvtServerStop() {}
111127
void pvtServerUpdate() {}
112128
void pvtServerZeroTail() {}
113129
void pvtServerValidateTables() {}
114130
void discardPvtServerBytes(RING_BUFFER_OFFSET previousTail, RING_BUFFER_OFFSET newTail) {}
115-
void discardPvtUdpServerBytes(RING_BUFFER_OFFSET previousTail, RING_BUFFER_OFFSET newTail) {}
116-
117-
//----------------------------------------
118-
// PVT UDP server
119-
//----------------------------------------
120-
121-
int pvtUdpServerSendData(uint16_t dataHead) {return 0;}
122-
void pvtUdpServerUpdate() {}
123-
void pvtUdpServerZeroTail() {}
124131

125132
//----------------------------------------
126133
// WiFi

Firmware/RTK_Surveyor/Network.ino

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,38 @@ void menuNetwork()
378378
}
379379
}
380380

381+
//----------------------------------------
382+
// Allocate a network client
383+
//----------------------------------------
384+
NetworkClient * networkClient(uint8_t user, bool useSSL)
385+
{
386+
NetworkClient * client;
387+
int type;
388+
389+
type = networkGetType(user);
390+
#if defined(COMPILE_ETHERNET)
391+
if (type == NETWORK_TYPE_ETHERNET)
392+
{
393+
if (useSSL)
394+
client = new NetworkEthernetSslClient();
395+
else
396+
client = new NetworkEthernetClient;
397+
}
398+
else
399+
#endif // COMPILE_ETHERNET
400+
{
401+
#if defined(COMPILE_WIFI)
402+
if (useSSL)
403+
client = new NetworkWiFiSslClient();
404+
else
405+
client = new NetworkWiFiClient();
406+
#else // COMPILE_WIFI
407+
client = nullptr;
408+
#endif // COMPILE_WIFI
409+
}
410+
return client;
411+
}
412+
381413
//----------------------------------------
382414
// Display the IP address
383415
//----------------------------------------

Firmware/RTK_Surveyor/PvtClient.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ PvtClient.ino
116116
* private SNIP NTRIP caster
117117
*/
118118

119-
#ifdef COMPILE_WIFI
119+
#if COMPILE_NETWORK
120120

121121
//----------------------------------------
122122
// Constants
@@ -520,4 +520,4 @@ void pvtClientZeroTail()
520520
pvtClientTail = 0;
521521
}
522522

523-
#endif // COMPILE_WIFI
523+
#endif // COMPILE_NETWORK

Firmware/RTK_Surveyor/PvtUdpServer.ino

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ pvtUdpServer.ino
3333
3434
RTK Express(+) with WiFi enabled, PvtUdpServer enabled, PvtUdpPort setup,
3535
Smartphone with QField:
36-
36+
3737
Network Setup:
38-
Connect the Smartphone and the RTK Express to the same Network (e.g. the Smartphones HotSpot).
38+
Connect the Smartphone and the RTK Express to the same Network (e.g. the Smartphones HotSpot).
3939
4040
QField Setup:
4141
* Open a project
@@ -53,13 +53,13 @@ pvtUdpServer.ino
5353
* Exit the menus
5454
5555
1. Long press on the location icon in the lower right corner
56-
56+
5757
2. Enable Show Position Information
5858
59-
3. Verify that the displayed coordinates, fix tpe etc. are valid
59+
3. Verify that the displayed coordinates, fix tpe etc. are valid
6060
*/
6161

62-
#ifdef COMPILE_WIFI
62+
#if COMPILE_NETWORK
6363

6464
//----------------------------------------
6565
// Constants
@@ -121,7 +121,7 @@ int32_t pvtUdpServerSendDataBroadcast(uint8_t *data, uint16_t length)
121121
PERIODIC_CLEAR(PD_PVT_UDP_SERVER_BROADCAST_DATA);
122122
systemPrintf("PVT UDP Server failed to write %d bytes as broadcast\r\n", length);
123123
length = 0;
124-
}
124+
}
125125
}
126126
return length;
127127
}
@@ -148,7 +148,7 @@ int32_t pvtUdpServerSendData(uint16_t dataHead)
148148
if ((tail + bytesToSend) > settings.gnssHandlerBufferSize)
149149
bytesToSend = settings.gnssHandlerBufferSize - tail;
150150

151-
// Send the data
151+
// Send the data
152152
bytesToSend = pvtUdpServerSendDataBroadcast(&ringBuffer[tail], bytesToSend);
153153

154154
// Assume all data was sent, wrap the buffer pointer
@@ -369,4 +369,4 @@ void pvtUdpServerZeroTail()
369369
pvtUdpServerTail = 0;
370370
}
371371

372-
#endif // COMPILE_WIFI
372+
#endif // COMPILE_NETWORK

Firmware/RTK_Surveyor/RTK_Surveyor.ino

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,11 @@ char logFileName[sizeof("SFE_Reference_Station_230101_120101.ubx_plusExtraSpace"
201201
// Over-the-Air (OTA) update support
202202
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
203203

204+
#if COMPILE_NETWORK
204205
#include <SSLClientESP32.h> // http://librarymanager/All#SSLClientESP32
205206
#include "X509_Certificate_Bundle.h" // Root certificates
207+
#endif // COMPILE_NETWORK
208+
#include <ArduinoJson.h> //http://librarymanager/All#Arduino_JSON_messagepack v6.19.4
206209

207210
#include "esp_ota_ops.h" //Needed for partition counting and updateFromSD
208211

@@ -229,7 +232,6 @@ unsigned int binBytesSent = 0; // Tracks firmware bytes sent over WiFi O
229232
// Connection settings to NTRIP Caster
230233
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
231234
#ifdef COMPILE_WIFI
232-
#include <ArduinoJson.h> //http://librarymanager/All#Arduino_JSON_messagepack v6.19.4
233235
#include <ESPmDNS.h> //Built-in.
234236
#include <HTTPClient.h> //Built-in. Needed for ThingStream API for ZTP
235237
#include <PubSubClient.h> //http://librarymanager/All#PubSubClient_MQTT_Lightweight by Nick O'Leary v2.8.0 Used for MQTT obtaining of keys

0 commit comments

Comments
 (0)