Skip to content

Commit b05c7df

Browse files
bbx10me-no-dev
authored andcommitted
Additions to WiFiClient and WiFiServer (espressif#404)
Required for WebServer and/or DNSServer libraries
1 parent 6af648e commit b05c7df

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

libraries/WiFi/src/WiFiClient.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,11 @@ size_t WiFiClient::write(const uint8_t *buf, size_t size)
224224
return res;
225225
}
226226

227+
size_t WiFiClient::write_P(PGM_P buf, size_t size)
228+
{
229+
return write(buf, size);
230+
}
231+
227232
int WiFiClient::read(uint8_t *buf, size_t size)
228233
{
229234
if(!available()) {

libraries/WiFi/src/WiFiClient.h

+5
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class WiFiClient : public Client
4444
int connect(const char *host, uint16_t port);
4545
size_t write(uint8_t data);
4646
size_t write(const uint8_t *buf, size_t size);
47+
size_t write_P(PGM_P buf, size_t size);
4748
int available();
4849
int read();
4950
int read(uint8_t *buf, size_t size);
@@ -84,6 +85,10 @@ class WiFiClient : public Client
8485
IPAddress remoteIP(int fd) const;
8586
uint16_t remotePort() const;
8687
uint16_t remotePort(int fd) const;
88+
IPAddress localIP() const;
89+
IPAddress localIP(int fd) const;
90+
uint16_t localPort() const;
91+
uint16_t localPort(int fd) const;
8792

8893
IPAddress localIP() const;
8994
IPAddress localIP(int fd) const;

libraries/WiFi/src/WiFiServer.cpp

+10-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <lwip/netdb.h>
2222

2323
#undef write
24+
#undef close
2425

2526
int WiFiServer::setTimeout(uint32_t seconds){
2627
struct timeval tv;
@@ -103,8 +104,16 @@ bool WiFiServer::hasClient() {
103104
}
104105

105106
void WiFiServer::end(){
106-
close(sockfd);
107+
lwip_close_r(sockfd);
107108
sockfd = -1;
108109
_listening = false;
109110
}
110111

112+
void WiFiServer::close(){
113+
end();
114+
}
115+
116+
void WiFiServer::stop(){
117+
end();
118+
}
119+

libraries/WiFi/src/WiFiServer.h

+2
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ class WiFiServer : public Server {
5050
using Print::write;
5151

5252
void end();
53+
void close();
54+
void stop();
5355
operator bool(){return _listening;}
5456
int setTimeout(uint32_t seconds);
5557
void stopAll();

0 commit comments

Comments
 (0)