diff options
author | Cristian Maglie <c.maglie@bug.st> | 2013-08-08 16:43:19 +0200 |
---|---|---|
committer | Cristian Maglie <c.maglie@bug.st> | 2013-08-08 16:43:19 +0200 |
commit | a8193ed933d9c9954cefbfb541cde56770ab5b74 (patch) | |
tree | 80796833fecca5d7426f1d09f7ac9870bab5f062 /libraries/WiFi/WiFiServer.cpp | |
parent | a4c9fee673342304a5b12f7f2f7f9ecb9cb26d30 (diff) | |
parent | 5527c44aa443b20d63cf7a276180a36695233924 (diff) |
Merge branch 'ide-1.5.x-library-to-new-format' into ide-1.5.x
Diffstat (limited to 'libraries/WiFi/WiFiServer.cpp')
-rw-r--r-- | libraries/WiFi/WiFiServer.cpp | 89 |
1 files changed, 0 insertions, 89 deletions
diff --git a/libraries/WiFi/WiFiServer.cpp b/libraries/WiFi/WiFiServer.cpp deleted file mode 100644 index 2f03bc1..0000000 --- a/libraries/WiFi/WiFiServer.cpp +++ /dev/null @@ -1,89 +0,0 @@ -#include <string.h> -#include "server_drv.h" - -extern "C" { - #include "utility/debug.h" -} - -#include "WiFi.h" -#include "WiFiClient.h" -#include "WiFiServer.h" - -WiFiServer::WiFiServer(uint16_t port) -{ - _port = port; -} - -void WiFiServer::begin() -{ - uint8_t _sock = WiFiClass::getSocket(); - if (_sock != NO_SOCKET_AVAIL) - { - ServerDrv::startServer(_port, _sock); - WiFiClass::_server_port[_sock] = _port; - WiFiClass::_state[_sock] = _sock; - } -} - -WiFiClient WiFiServer::available(byte* status) -{ - static int cycle_server_down = 0; - const int TH_SERVER_DOWN = 50; - - for (int sock = 0; sock < MAX_SOCK_NUM; sock++) - { - if (WiFiClass::_server_port[sock] == _port) - { - WiFiClient client(sock); - uint8_t _status = client.status(); - uint8_t _ser_status = this->status(); - - if (status != NULL) - *status = _status; - - //server not in listen state, restart it - if ((_ser_status == 0)&&(cycle_server_down++ > TH_SERVER_DOWN)) - { - ServerDrv::startServer(_port, sock); - cycle_server_down = 0; - } - - if (_status == ESTABLISHED) - { - return client; //TODO - } - } - } - - return WiFiClient(255); -} - -uint8_t WiFiServer::status() { - return ServerDrv::getServerState(0); -} - - -size_t WiFiServer::write(uint8_t b) -{ - return write(&b, 1); -} - -size_t WiFiServer::write(const uint8_t *buffer, size_t size) -{ - size_t n = 0; - - for (int sock = 0; sock < MAX_SOCK_NUM; sock++) - { - if (WiFiClass::_server_port[sock] != 0) - { - WiFiClient client(sock); - - if (WiFiClass::_server_port[sock] == _port && - client.status() == ESTABLISHED) - { - n+=client.write(buffer, size); - } - } - } - return n; -} |