Skip to content

Commit 0d25566

Browse files
authored
Merge pull request #345 from LeeLeahy2/no-network-type-client
Change NetworkEthernetClient & NetworkWiFiClient to RTKNetworkClientType
2 parents 5721bee + ec9c721 commit 0d25566

File tree

3 files changed

+9
-43
lines changed

3 files changed

+9
-43
lines changed

Firmware/RTK_Everywhere/Network.ino

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -358,18 +358,7 @@ RTKNetworkClient *networkClient(uint8_t user, bool useSSL)
358358
int type;
359359

360360
type = networkGetType(user);
361-
#if defined(COMPILE_ETHERNET)
362-
if (type == NETWORK_TYPE_ETHERNET)
363-
client = new NetworkEthernetClient;
364-
else
365-
#endif // COMPILE_ETHERNET
366-
{
367-
#if defined(COMPILE_WIFI)
368-
client = new NetworkWiFiClient();
369-
#else // COMPILE_WIFI
370-
client = nullptr;
371-
#endif // COMPILE_WIFI
372-
}
361+
client = new RTKNetworkClientType(type);
373362
return client;
374363
}
375364

Firmware/RTK_Everywhere/RTKNetworkClient.h

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -233,56 +233,33 @@ class RTKNetworkClient : public NetworkClient
233233
// Declare the friend classes
234234
//------------------------------
235235

236-
friend class NetworkEthernetClient;
237236
friend class NetworkEthernetSslClient;
238237
friend class NetworkWiFiClient;
239238
friend class NetworkWiFiSslClient;
240239
};
241240

242-
#ifdef COMPILE_ETHERNET
243-
class NetworkEthernetClient : public RTKNetworkClient
241+
class RTKNetworkClientType : public RTKNetworkClient
244242
{
245243
private:
246-
NetworkClient _ethernetClient;
247-
248-
public:
249-
NetworkEthernetClient() : RTKNetworkClient(&_ethernetClient, NETWORK_TYPE_ETHERNET)
250-
{
251-
}
252-
253-
NetworkEthernetClient(NetworkClient &client)
254-
: _ethernetClient{client}, RTKNetworkClient(&_ethernetClient, NETWORK_TYPE_ETHERNET)
255-
{
256-
}
257-
258-
~NetworkEthernetClient()
259-
{
260-
this->~RTKNetworkClient();
261-
}
262-
};
263-
#endif // COMPILE_ETHERNET
264-
265-
#ifdef COMPILE_WIFI
266-
class NetworkWiFiClient : public RTKNetworkClient
267-
{
268-
protected:
269244
NetworkClient _client;
270245

271246
public:
272-
NetworkWiFiClient() : RTKNetworkClient(&_client, NETWORK_TYPE_WIFI)
247+
RTKNetworkClientType(uint8_t type) : RTKNetworkClient(&_client, type)
273248
{
274249
}
275250

276-
NetworkWiFiClient(WiFiClient &client) : _client{client}, RTKNetworkClient(&_client, NETWORK_TYPE_WIFI)
251+
RTKNetworkClientType(NetworkClient &client, uint8_t type)
252+
: _client{client}, RTKNetworkClient(&_client, type)
277253
{
278254
}
279255

280-
~NetworkWiFiClient()
256+
~RTKNetworkClientType()
281257
{
282258
this->~RTKNetworkClient();
283259
}
284260
};
285261

262+
#ifdef COMPILE_WIFI
286263
class NetworkSecureWiFiClient : public RTKNetworkClient
287264
{
288265
protected:

Firmware/RTK_Everywhere/TcpServer.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ void tcpServerUpdate()
449449
// Determine if the client data structure is in use
450450
if (!(tcpServerClientConnected & (1 << index)))
451451
{
452-
WiFiClient client;
452+
NetworkClient client;
453453

454454
// Data structure not in use
455455
// Check for another TCP server client
@@ -460,7 +460,7 @@ void tcpServerUpdate()
460460
break;
461461

462462
// Start processing the new TCP server client connection
463-
tcpServerClient[index] = new NetworkWiFiClient(client);
463+
tcpServerClient[index] = new RTKNetworkClientType(client, NETWORK_TYPE_WIFI);
464464
tcpServerClientIpAddress[index] = tcpServerClient[index]->remoteIP();
465465
tcpServerClientConnected = tcpServerClientConnected | (1 << index);
466466
tcpServerClientDataSent = tcpServerClientDataSent | (1 << index);

0 commit comments

Comments
 (0)