Skip to content

Commit abefe60

Browse files
authored
WiFiS3: add comparison operator to subclasses
1 parent 9e3084b commit abefe60

File tree

8 files changed

+42
-4
lines changed

8 files changed

+42
-4
lines changed

libraries/WiFiS3/src/WiFiClient.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,13 @@ uint8_t WiFiClient::connected() {
231231
return rv;
232232
}
233233

234+
/* -------------------------------------------------------------------------- */
235+
bool WiFiClient::operator==(const WiFiClient& whs)
236+
{
237+
/* -------------------------------------------------------------------------- */
238+
return _sock == whs._sock;
239+
}
240+
234241
/* -------------------------------------------------------------------------- */
235242
IPAddress WiFiClient::remoteIP() {
236243
/* -------------------------------------------------------------------------- */

libraries/WiFiS3/src/WiFiClient.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@ class WiFiClient : public Client {
5454
virtual operator bool() {
5555
return _sock != -1;
5656
}
57-
57+
virtual bool operator==(const WiFiClient&);
58+
virtual bool operator!=(const WiFiClient& whs)
59+
{
60+
return !this->operator==(whs);
61+
};
5862
virtual IPAddress remoteIP();
5963
virtual uint16_t remotePort();
6064

libraries/WiFiS3/src/WiFiSSLClient.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,10 @@ uint8_t WiFiSSLClient::connected() {
224224
}
225225
return rv;
226226
}
227+
bool WiFiSSLClient::operator==(const WiFiSSLClient& whs)
228+
{
229+
return _sock == whs._sock;
230+
}
227231

228232
/* -------------------------------------------------------------------------- */
229233
IPAddress WiFiSSLClient::remoteIP() {

libraries/WiFiS3/src/WiFiSSLClient.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ class WiFiSSLClient : public WiFiClient {
4646
virtual operator bool() {
4747
return _sock != -1;
4848
}
49-
49+
virtual bool operator==(const WiFiSSLClient&);
50+
virtual bool operator!=(const WiFiSSLClient& whs)
51+
{
52+
return !this->operator==(whs);
53+
};
5054
virtual IPAddress remoteIP();
5155
virtual uint16_t remotePort();
5256

libraries/WiFiS3/src/WiFiServer.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,9 @@ void WiFiServer::end() {
8282
modem.write(string(PROMPT(_SERVEREND)),res, "%s%d\r\n" , CMD_WRITE(_SERVEREND), _sock);
8383
_sock = -1;
8484
}
85+
}
86+
87+
bool WiFiServer::operator==(const WiFiServer& whs)
88+
{
89+
return _sock == whs._sock;
8590
}

libraries/WiFiS3/src/WiFiServer.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ class WiFiServer : public Server {
4242
virtual size_t write(uint8_t);
4343
virtual size_t write(const uint8_t *buf, size_t size);
4444
void end();
45-
45+
virtual bool operator==(const WiFiServer&);
46+
virtual bool operator!=(const WiFiServer& whs)
47+
{
48+
return !this->operator==(whs);
49+
};
4650

4751
using Print::write;
4852

libraries/WiFiS3/src/WiFiUdp.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,12 @@ void WiFiUDP::flush() {
254254
modem.write(string(PROMPT(_UDPFLUSH)),res, "%s%d\r\n" , CMD_WRITE(_UDPFLUSH), _sock);
255255
}
256256
}
257-
257+
258+
bool WiFiUDP::operator==(const WiFiUDP& whs)
259+
{
260+
return _sock == whs._sock;
261+
}
262+
258263
/* -------------------------------------------------------------------------- */
259264
IPAddress WiFiUDP::remoteIP() {
260265
/* -------------------------------------------------------------------------- */

libraries/WiFiS3/src/WiFiUdp.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ class WiFiUDP : public UDP {
8282
// Return the next byte from the current packet without moving on to the next byte
8383
virtual int peek();
8484
virtual void flush(); // Finish reading the current packet
85+
virtual bool operator==(const WiFiUDP&);
86+
virtual bool operator!=(const WiFiUDP& whs)
87+
{
88+
return !this->operator==(whs);
89+
};
8590

8691
// Return the IP address of the host who sent the current incoming packet
8792
virtual IPAddress remoteIP();

0 commit comments

Comments
 (0)