Additions to WiFiClient and WiFiServer (#404)

Required for WebServer and/or DNSServer libraries
This commit is contained in:
bbx10 2017-06-14 01:22:16 -07:00 committed by Me No Dev
parent 6af648e8f5
commit b05c7dfa59
4 changed files with 22 additions and 1 deletions

View File

@ -224,6 +224,11 @@ size_t WiFiClient::write(const uint8_t *buf, size_t size)
return res;
}
size_t WiFiClient::write_P(PGM_P buf, size_t size)
{
return write(buf, size);
}
int WiFiClient::read(uint8_t *buf, size_t size)
{
if(!available()) {

View File

@ -44,6 +44,7 @@ public:
int connect(const char *host, uint16_t port);
size_t write(uint8_t data);
size_t write(const uint8_t *buf, size_t size);
size_t write_P(PGM_P buf, size_t size);
int available();
int read();
int read(uint8_t *buf, size_t size);
@ -84,6 +85,10 @@ public:
IPAddress remoteIP(int fd) const;
uint16_t remotePort() const;
uint16_t remotePort(int fd) const;
IPAddress localIP() const;
IPAddress localIP(int fd) const;
uint16_t localPort() const;
uint16_t localPort(int fd) const;
IPAddress localIP() const;
IPAddress localIP(int fd) const;

View File

@ -21,6 +21,7 @@
#include <lwip/netdb.h>
#undef write
#undef close
int WiFiServer::setTimeout(uint32_t seconds){
struct timeval tv;
@ -103,8 +104,16 @@ bool WiFiServer::hasClient() {
}
void WiFiServer::end(){
close(sockfd);
lwip_close_r(sockfd);
sockfd = -1;
_listening = false;
}
void WiFiServer::close(){
end();
}
void WiFiServer::stop(){
end();
}

View File

@ -50,6 +50,8 @@ class WiFiServer : public Server {
using Print::write;
void end();
void close();
void stop();
operator bool(){return _listening;}
int setTimeout(uint32_t seconds);
void stopAll();