Skip to content

Commit 26f48d8

Browse files
author
dberschauer
committed
Merge remote-tracking branch 'origin/release_candidate' into captive-portal
2 parents ce21dab + d1c1e8d commit 26f48d8

File tree

12 files changed

+1291
-831
lines changed

12 files changed

+1291
-831
lines changed

Firmware/RTK_Surveyor/Begin.ino

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,8 @@ void beginUART2()
554554
{
555555
ringBuffer = (uint8_t *)malloc(settings.gnssHandlerBufferSize);
556556
if (!ringBuffer)
557+
systemPrintln("ERROR: Failed to allocate the ring buffer!");
558+
else
557559
{
558560
if (pinUART2TaskHandle == nullptr)
559561
xTaskCreatePinnedToCore(

Firmware/RTK_Surveyor/Developer.ino

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ void pvtClientZeroTail() {}
100100
// PVT server
101101
//----------------------------------------
102102

103-
bool pvtServerActive() {return false;}
104103
int pvtServerSendData(uint16_t dataHead) {return 0;}
105104
void pvtServerUpdate() {}
106105
void pvtServerZeroTail() {}

Firmware/RTK_Surveyor/Network.ino

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,11 @@ const int networkStateEntries = sizeof(networkState) / sizeof(networkState[0]);
181181
// List of network users
182182
const char * const networkUser[] =
183183
{
184+
"NTP Server",
184185
"NTRIP Client",
185186
"NTRIP Server",
186187
"PVT Client",
187-
"NTP Server",
188+
"PVT Server",
188189
};
189190
const int networkUserEntries = sizeof(networkUser) / sizeof(networkUser[0]);
190191

@@ -302,20 +303,9 @@ void menuNetwork()
302303
//------------------------------
303304

304305
else if (incoming == 4)
305-
{
306306
// Toggle WiFi NEMA server
307307
settings.enablePvtServer ^= 1;
308-
if ((!settings.enablePvtServer) && online.pvtServer)
309-
{
310-
// Tell the UART2 tasks that the TCP server is shutting down
311-
online.pvtServer = false;
312308

313-
// Wait for the UART2 tasks to close the TCP client connections
314-
while (pvtServerActive())
315-
delay(5);
316-
systemPrintln("TCP Server offline");
317-
}
318-
}
319309
else if (incoming == 5)
320310
{
321311
systemPrint("Enter the TCP port to use (0 to 65535): ");
@@ -849,6 +839,12 @@ void networkStop(uint8_t networkType)
849839
systemPrintln("Network layer stopping PVT client");
850840
pvtClientStop();
851841
break;
842+
843+
case NETWORK_USER_PVT_SERVER:
844+
if (settings.debugNetworkLayer)
845+
systemPrintln("Network layer stopping PVT server");
846+
pvtServerStop();
847+
break;
852848
}
853849
}
854850
}

Firmware/RTK_Surveyor/NetworkClient.h

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,24 @@ class NetworkClient : public Client
88
protected:
99

1010
Client * _client; // Ethernet or WiFi client
11+
bool _friendClass;
1112
uint8_t _networkType;
1213

1314
public:
1415

1516
//------------------------------
1617
// Create the network client
1718
//------------------------------
19+
NetworkClient(Client * client, uint8_t networkType)
20+
{
21+
_friendClass = true;
22+
_networkType = networkType;
23+
_client = client;
24+
}
25+
1826
NetworkClient(uint8_t user)
1927
{
28+
_friendClass = false;
2029
_networkType = networkGetType(user);
2130
#if defined(COMPILE_ETHERNET)
2231
if (_networkType == NETWORK_TYPE_ETHERNET)
@@ -38,7 +47,8 @@ class NetworkClient : public Client
3847
if (_client)
3948
{
4049
_client->stop();
41-
delete _client;
50+
if (!_friendClass)
51+
delete _client;
4252
_client = nullptr;
4353
}
4454
};
@@ -221,6 +231,57 @@ class NetworkClient : public Client
221231
{
222232
return Client::rawIPAddress(addr);
223233
}
234+
235+
//------------------------------
236+
// Declare the friend classes
237+
//------------------------------
238+
239+
friend class NetworkEthernetClient;
240+
friend class NetworkWiFiClient;
241+
};
242+
243+
#ifdef COMPILE_ETHERNET
244+
class NetworkEthernetClient : public NetworkClient
245+
{
246+
private:
247+
248+
EthernetClient _client;
249+
250+
public:
251+
252+
NetworkEthernetClient(EthernetClient& client) :
253+
_client{client},
254+
NetworkClient(&_client, NETWORK_TYPE_ETHERNET)
255+
{
256+
}
257+
258+
~NetworkEthernetClient()
259+
{
260+
this->~NetworkClient();
261+
}
262+
};
263+
#endif // COMPILE_ETHERNET
264+
265+
#ifdef COMPILE_WIFI
266+
class NetworkWiFiClient : public NetworkClient
267+
{
268+
private:
269+
270+
WiFiClient _client;
271+
272+
public:
273+
274+
NetworkWiFiClient(WiFiClient& client) :
275+
_client{client},
276+
NetworkClient(&_client, NETWORK_TYPE_WIFI)
277+
{
278+
}
279+
280+
~NetworkWiFiClient()
281+
{
282+
this->~NetworkClient();
283+
}
224284
};
285+
#endif // COMPILE_WIFI
225286

226287
#endif // __NETWORK_CLIENT_H__

Firmware/RTK_Surveyor/PvtClient.ino

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,11 @@ const int pvtClientStateNameEntries = sizeof(pvtClientStateName) / sizeof(pvtCli
153153
static NetworkClient * pvtClient;
154154
static IPAddress pvtClientIpAddress;
155155
static uint8_t pvtClientState;
156-
static volatile uint16_t pvtClientTail;
156+
static volatile RING_BUFFER_OFFSET pvtClientTail;
157157
static volatile bool pvtClientWriteError;
158158

159159
//----------------------------------------
160-
// PVT Client Routines
160+
// PVT Client handleGnssDataTask Support Routines
161161
//----------------------------------------
162162

163163
// Send PVT data to the NMEA server
@@ -250,6 +250,10 @@ void pvtClientSetState(uint8_t newState)
250250
}
251251
}
252252

253+
//----------------------------------------
254+
// PVT Client Routines
255+
//----------------------------------------
256+
253257
// Start the PVT client
254258
bool pvtClientStart()
255259
{

0 commit comments

Comments
 (0)