diff --git a/WiFi/Client.h b/WiFi/Client.h deleted file mode 100755 index c812089c1..000000000 --- a/WiFi/Client.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef client_h -#define client_h -#include "Arduino.h" -#include "Print.h" - -class Client : public Stream { - -public: - Client(); - Client(uint8_t sock); - - uint8_t status(); - int connect(IPAddress ip, uint16_t port); - int connect(const char *host, uint16_t port); - virtual void write(uint8_t); - virtual void write(const char *str); - virtual void write(const uint8_t *buf, size_t size); - virtual int available(); - virtual int read(); - virtual int read(uint8_t *buf, size_t size); - virtual int peek(); - virtual void flush(); - void stop(); - uint8_t connected(); - operator bool(); - - friend class Server; - -private: - static uint16_t _srcport; - uint8_t _sock; //not used - uint16_t _socket; - - uint8_t getFirstSocket(); -}; - -#endif diff --git a/WiFi/IPAddress.cpp b/WiFi/IPAddress.cpp deleted file mode 100644 index 610ff4c53..000000000 --- a/WiFi/IPAddress.cpp +++ /dev/null @@ -1,44 +0,0 @@ - -#include -#include - -IPAddress::IPAddress() -{ - memset(_address, 0, sizeof(_address)); -} - -IPAddress::IPAddress(uint8_t first_octet, uint8_t second_octet, uint8_t third_octet, uint8_t fourth_octet) -{ - _address[0] = first_octet; - _address[1] = second_octet; - _address[2] = third_octet; - _address[3] = fourth_octet; -} - -IPAddress::IPAddress(uint32_t address) -{ - memcpy(_address, &address, sizeof(_address)); -} - -IPAddress::IPAddress(const uint8_t *address) -{ - memcpy(_address, address, sizeof(_address)); -} - -IPAddress& IPAddress::operator=(const uint8_t *address) -{ - memcpy(_address, address, sizeof(_address)); - return *this; -} - -IPAddress& IPAddress::operator=(uint32_t address) -{ - memcpy(_address, (const uint8_t *)&address, sizeof(_address)); - return *this; -} - -bool IPAddress::operator==(const uint8_t* addr) -{ - return memcmp(addr, _address, sizeof(_address)) == 0; -} - diff --git a/WiFi/IPAddress.h b/WiFi/IPAddress.h deleted file mode 100644 index 487e420bd..000000000 --- a/WiFi/IPAddress.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * - * MIT License: - * Copyright (c) 2011 Adrian McEwen - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * adrianm@mcqn.com 1/1/2011 - */ - -#ifndef IPAddress_h -#define IPAddress_h - -// A class to make it easier to handle and pass around IP addresses - -class IPAddress { -private: - uint8_t _address[4]; // IPv4 address - // Access the raw byte array containing the address. Because this returns a pointer - // to the internal structure rather than a copy of the address this function should only - // be used when you know that the usage of the returned uint8_t* will be transient and not - // stored. - uint8_t* raw_address() { return _address; }; - -public: - // Constructors - IPAddress(); - IPAddress(uint8_t first_octet, uint8_t second_octet, uint8_t third_octet, uint8_t fourth_octet); - IPAddress(uint32_t address); - IPAddress(const uint8_t *address); - - // Overloaded cast operator to allow IPAddress objects to be used where a pointer - // to a four-byte uint8_t array is expected - operator uint32_t() { return *((uint32_t*)_address); }; - bool operator==(const IPAddress& addr) { return (*((uint32_t*)_address)) == (*((uint32_t*)addr._address)); }; - bool operator==(const uint8_t* addr); - - // Overloaded index operator to allow getting and setting individual octets of the address - uint8_t operator[](int index) const { return _address[index]; }; - uint8_t& operator[](int index) { return _address[index]; }; - - // Overloaded copy operators to allow initialisation of IPAddress objects from other types - IPAddress& operator=(const uint8_t *address); - IPAddress& operator=(uint32_t address); - - friend class EthernetClass; - friend class UDP; - friend class Client; - friend class Server; - friend class DhcpClass; - friend class DNSClient; -}; - -const IPAddress INADDR_NONE(0,0,0,0); - - -#endif diff --git a/WiFi/WiFi.h b/WiFi/WiFi.h index ac88bd02a..fbb1225d2 100755 --- a/WiFi/WiFi.h +++ b/WiFi/WiFi.h @@ -8,8 +8,8 @@ extern "C" { } #include "IPAddress.h" -#include "Client.h" -#include "Server.h" +#include "WiFiClient.h" +#include "WiFiServer.h" class WiFiClass { @@ -89,8 +89,8 @@ public: // function used for test uint8_t test(); - friend class Client; - friend class Server; + friend class WiFiClient; + friend class WiFiServer; }; extern WiFiClass WiFi; diff --git a/WiFi/Client.cpp b/WiFi/WiFiClient.cpp similarity index 74% rename from WiFi/Client.cpp rename to WiFi/WiFiClient.cpp index afdb31d7c..9aa0e64cd 100755 --- a/WiFi/Client.cpp +++ b/WiFi/WiFiClient.cpp @@ -7,19 +7,19 @@ extern "C" { } #include "WiFi.h" -#include "Client.h" -#include "Server.h" +#include "WiFiClient.h" +#include "WiFiServer.h" #include "server_drv.h" -uint16_t Client::_srcport = 1024; +uint16_t WiFiClient::_srcport = 1024; -Client::Client() : _sock(MAX_SOCK_NUM) { +WiFiClient::WiFiClient() : _sock(MAX_SOCK_NUM) { } -Client::Client(uint8_t sock) : _sock(sock) { +WiFiClient::WiFiClient(uint8_t sock) : _sock(sock) { } -int Client::connect(const char* host, uint16_t port) { +int WiFiClient::connect(const char* host, uint16_t port) { /* TODO Add DNS wifi spi function to resolve DNS */ #if 0 // Look up the host first @@ -37,7 +37,7 @@ int Client::connect(const char* host, uint16_t port) { #endif } -int Client::connect(IPAddress ip, uint16_t port) { +int WiFiClient::connect(IPAddress ip, uint16_t port) { _sock = getFirstSocket(); if (_sock != NO_SOCKET_AVAIL) { @@ -49,36 +49,40 @@ int Client::connect(IPAddress ip, uint16_t port) { return 1; } -void Client::write(uint8_t b) { +size_t WiFiClient::write(uint8_t b) { if (_sock != 255) { START(); ServerDrv::sendData(_sock, &b, 1); while (!ServerDrv::isDataSent(_sock)); END(); - + return 1; } + return 0; } -void Client::write(const char *str) { +size_t WiFiClient::write(const char *str) { if (_sock != 255) { unsigned int len = strlen(str); ServerDrv::sendData(_sock, (const uint8_t *)str, len); while (!ServerDrv::isDataSent(_sock)); + return len; } + return 0; } -void Client::write(const uint8_t *buf, size_t size) { +size_t WiFiClient::write(const uint8_t *buf, size_t size) { if (_sock != 255) { ServerDrv::sendData(_sock, buf, size); while (!ServerDrv::isDataSent(_sock)); + return size; } - + return 0; } -int Client::available() { +int WiFiClient::available() { if (_sock != 255) { return ServerDrv::availData(_sock); @@ -87,7 +91,7 @@ int Client::available() { return 0; } -int Client::read() { +int WiFiClient::read() { uint8_t b; if (!available()) return -1; @@ -96,23 +100,23 @@ int Client::read() { } -int Client::read(uint8_t* buf, size_t size) { +int WiFiClient::read(uint8_t* buf, size_t size) { if (!ServerDrv::getDataBuf(_sock, buf, &size)) return -1; return 0; } -int Client::peek() { +int WiFiClient::peek() { //TODO to be implemented return 0; } -void Client::flush() { +void WiFiClient::flush() { while (available()) read(); } -void Client::stop() { +void WiFiClient::stop() { if (_sock == 255) return; @@ -132,7 +136,7 @@ void Client::stop() { _sock = 255; } -uint8_t Client::connected() { +uint8_t WiFiClient::connected() { if (_sock == 255) { return 0; } else { @@ -142,7 +146,7 @@ uint8_t Client::connected() { } } -uint8_t Client::status() { +uint8_t WiFiClient::status() { if (_sock == 255) { return CLOSED; } else { @@ -150,12 +154,12 @@ uint8_t Client::status() { } } -Client::operator bool() { +WiFiClient::operator bool() { return _sock != 255; } // Private Methods -uint8_t Client::getFirstSocket() +uint8_t WiFiClient::getFirstSocket() { for (int i = 0; i < MAX_SOCK_NUM; i++) { if (WiFiClass::_state[i] == 0) diff --git a/WiFi/WiFiClient.h b/WiFi/WiFiClient.h new file mode 100755 index 000000000..597bcdb56 --- /dev/null +++ b/WiFi/WiFiClient.h @@ -0,0 +1,39 @@ +#ifndef wificlient_h +#define wificlient_h +#include "Arduino.h" +#include "Print.h" +#include "Client.h" +#include "IPAddress.h" + +class WiFiClient : public Client { + +public: + WiFiClient(); + WiFiClient(uint8_t sock); + + uint8_t status(); + virtual int connect(IPAddress ip, uint16_t port); + virtual int connect(const char *host, uint16_t port); + virtual size_t write(uint8_t); + virtual size_t write(const char *str); + virtual size_t write(const uint8_t *buf, size_t size); + virtual int available(); + virtual int read(); + virtual int read(uint8_t *buf, size_t size); + virtual int peek(); + virtual void flush(); + virtual void stop(); + virtual uint8_t connected(); + virtual operator bool(); + + friend class WiFiServer; + +private: + static uint16_t _srcport; + uint8_t _sock; //not used + uint16_t _socket; + + uint8_t getFirstSocket(); +}; + +#endif diff --git a/WiFi/Server.cpp b/WiFi/WiFiServer.cpp similarity index 74% rename from WiFi/Server.cpp rename to WiFi/WiFiServer.cpp index a8e236029..52277eac8 100755 --- a/WiFi/Server.cpp +++ b/WiFi/WiFiServer.cpp @@ -2,17 +2,17 @@ #include "server_drv.h" #include "WiFi.h" -#include "Client.h" -#include "Server.h" +#include "WiFiClient.h" +#include "WiFiServer.h" -Server::Server(uint16_t port) +WiFiServer::WiFiServer(uint16_t port) { _port = port; } -void Server::begin() +void WiFiServer::begin() { uint8_t _sock = WiFiClass::getSocket(); if (_sock != NO_SOCKET_AVAIL) @@ -22,7 +22,7 @@ void Server::begin() } } -Client Server::available(byte* status) +WiFiClient WiFiServer::available(byte* status) { //accept(); @@ -30,7 +30,7 @@ Client Server::available(byte* status) { if (WiFiClass::_server_port[sock] != 0) { - Client client(sock); + WiFiClient client(sock); int _status = client.status(); if (status != NULL) *status = _status; @@ -43,26 +43,26 @@ Client Server::available(byte* status) } } - return Client(255); + return WiFiClient(255); } -void Server::write(uint8_t b) +void WiFiServer::write(uint8_t b) { write(&b, 1); } -void Server::write(const char *str) +void WiFiServer::write(const char *str) { write((const uint8_t *)str, strlen(str)); } -void Server::write(const uint8_t *buffer, size_t size) +void WiFiServer::write(const uint8_t *buffer, size_t size) { for (int sock = 0; sock < MAX_SOCK_NUM; sock++) { if (WiFiClass::_server_port[sock] != 0) { - Client client(sock); + WiFiClient client(sock); if (WiFiClass::_server_port[sock] == _port && client.status() == ESTABLISHED) diff --git a/WiFi/Server.h b/WiFi/WiFiServer.h similarity index 58% rename from WiFi/Server.h rename to WiFi/WiFiServer.h index 34124af09..7eb3dd14e 100755 --- a/WiFi/Server.h +++ b/WiFi/WiFiServer.h @@ -1,21 +1,21 @@ -#ifndef server_h -#define server_h +#ifndef wifiserver_h +#define wifiserver_h extern "C" { #include "utility/wl_definitions.h" } -#include "Print.h" +#include "Server.h" -class Client; +class WiFiClient; -class Server : public Print { +class WiFiServer : public Server { private: uint16_t _port; void* pcb; public: - Server(uint16_t); - Client available(uint8_t* status = NULL); + WiFiServer(uint16_t); + WiFiClient available(uint8_t* status = NULL); void begin(); virtual void write(uint8_t); virtual void write(const char *str); diff --git a/WiFi/examples/PachubeClientString/PachubeClientString.ino b/WiFi/examples/PachubeClientString/PachubeClientString.ino index 9a38ec15a..1e007761b 100644 --- a/WiFi/examples/PachubeClientString/PachubeClientString.ino +++ b/WiFi/examples/PachubeClientString/PachubeClientString.ino @@ -22,16 +22,16 @@ */ #include -#include -char ssid[32] = { 0 }; +char ssid[] = "yourNetwork"; +char pass[] = "secretPassword"; int status = WL_IDLE_STATUS; // The address of the server you want to connect to (pachube.com): IPAddress server(173,203,98,29); // initialize the library instance: -Client client(server, 80); +WiFiClient client; long lastConnectionTime = 0; // last time you connected to the server, in milliseconds boolean lastConnected = false; // state of the connection last time through the main loop @@ -40,11 +40,10 @@ const int postingInterval = 10000; //delay between updates to Pachube.com int startWiFiWpa() { Serial.println("\nSetup WiFi Wpa..."); - //strcpy(ssid, "AndroidAP9647"); - strcpy(ssid, "Cariddi"); + strcpy(ssid, "tigoenet"); Serial.print("SSID: "); Serial.println(ssid); - const char *pass = "1234567890"; + const char *pass = "m30w-m30w"; status = WiFi.begin(ssid, pass); if ( status != WL_CONNECTED) { @@ -110,11 +109,11 @@ void loop() { // this method makes a HTTP connection to the server: void sendData(String thisData) { // if there's a successful connection: - if (client.connect()) { + if (client.connect(server, 80)) { Serial.println("connecting..."); // send the HTTP PUT request. // fill in your feed address here: - client.print("PUT /api/http://api.pachube.com/v2/feeds/24196.csv HTTP/1.1\n"); + client.print("PUT /api/24196.csv HTTP/1.1\n"); client.print("Host: www.pachube.com\n"); // fill in your Pachube API key here: client.print("X-PachubeApiKey: gw0L2A-J5ACRGQccX59tCYt0IEzyecr-SoiuC47U1-8\n"); diff --git a/WiFi/examples/Wifi_Open_ScanNetworks/Wifi_Open_ScanNetworks.ino b/WiFi/examples/Wifi_Open_ScanNetworks/Wifi_Open_ScanNetworks.ino index 87c5ffe02..64d27fbd0 100644 --- a/WiFi/examples/Wifi_Open_ScanNetworks/Wifi_Open_ScanNetworks.ino +++ b/WiFi/examples/Wifi_Open_ScanNetworks/Wifi_Open_ScanNetworks.ino @@ -7,7 +7,7 @@ * WiFi shield attached created 13 July 2010 - by Domenico La Fauci + by dlf (Metodo2 srl) modified 5 June 2011 by Tom Igoe */ diff --git a/WiFi/examples/Wifi_WEP_ScanNetworks/Wifi_WEP_ScanNetworks.ino b/WiFi/examples/Wifi_WEP_ScanNetworks/Wifi_WEP_ScanNetworks.ino index fd9f6fdaf..1198346bb 100644 --- a/WiFi/examples/Wifi_WEP_ScanNetworks/Wifi_WEP_ScanNetworks.ino +++ b/WiFi/examples/Wifi_WEP_ScanNetworks/Wifi_WEP_ScanNetworks.ino @@ -7,7 +7,7 @@ * WiFi shield attached created 13 July 2010 - by Domenico La Fauci + by dlf (Metodo2 srl) modified 5 June 2011 by Tom Igoe */ @@ -61,7 +61,7 @@ void loop() { void printIpData() { // print your WiFi shield's IP address: - ip = WiFi.localIp(); + ip = WiFi.localIP(); Serial.print("IP: "); Serial.print(ip[3]); Serial.print("."); diff --git a/WiFi/examples/Wifi_WPA_ChatServer/Wifi_WPA_ChatServer.ino b/WiFi/examples/Wifi_WPA_ChatServer/Wifi_WPA_ChatServer.ino index 75dab1936..6cbb4a736 100644 --- a/WiFi/examples/Wifi_WPA_ChatServer/Wifi_WPA_ChatServer.ino +++ b/WiFi/examples/Wifi_WPA_ChatServer/Wifi_WPA_ChatServer.ino @@ -25,7 +25,7 @@ char pass[] = "secretPassword"; // the WPA2 password for your network int status = WL_IDLE_STATUS; // the Wifi radio's status // telnet defaults to port 23 -Server server(23); +WiFiServer server(23); boolean gotAMessage = false; // whether or not you got a message from the client yet @@ -56,7 +56,7 @@ void setup() { void loop() { // wait for a new client: - Client client = server.available(); + WiFiClient client = server.available(); // when the client sends the first byte, say hello: if (client) { diff --git a/WiFi/examples/Wifi_WPA_PachubeClientString/Wifi_WPA_PachubeClientString.ino b/WiFi/examples/Wifi_WPA_PachubeClientString/Wifi_WPA_PachubeClientString.ino index 227f43b9b..88e44e849 100644 --- a/WiFi/examples/Wifi_WPA_PachubeClientString/Wifi_WPA_PachubeClientString.ino +++ b/WiFi/examples/Wifi_WPA_PachubeClientString/Wifi_WPA_PachubeClientString.ino @@ -31,7 +31,7 @@ int status = WL_IDLE_STATUS; IPAddress server(173,203,98,29); // initialize the library instance: -Client client; +WiFiClient client; long lastConnectionTime = 0; // last time you connected to the server, in milliseconds boolean lastConnected = false; // state of the connection last time through the main loop diff --git a/WiFi/examples/Wifi_WPA_ScanNetworks/Wifi_WPA_ScanNetworks.ino b/WiFi/examples/Wifi_WPA_ScanNetworks/Wifi_WPA_ScanNetworks.ino index 0c3bbf9fb..4a217f0cd 100644 --- a/WiFi/examples/Wifi_WPA_ScanNetworks/Wifi_WPA_ScanNetworks.ino +++ b/WiFi/examples/Wifi_WPA_ScanNetworks/Wifi_WPA_ScanNetworks.ino @@ -7,7 +7,7 @@ * WiFi shield attached created 13 July 2010 - by Domenico La Fauci + by dlf (Metodo2 srl) modified 5 June 2011 by Tom Igoe */ @@ -16,9 +16,8 @@ #include #include -char ssid[] = "yourNetwork"; // the name of your network -char pass[] = "secretPassword"; // the WPA2 password for your network - +char ssid[] = "yourNetwork"; +char pass[] = "secretpassword"; int status = WL_IDLE_STATUS; // the Wifi radio's status byte mac[6]; // the MAC address of your Wifi shield @@ -29,7 +28,11 @@ IPAddress subnet; // the subnet mask void setup() { // initialize serial: Serial.begin(9600); - + // scan for existing networks: + Serial.println("Scanning available networks..."); + //WiFi.begin(); + scanNetworks(); + // attempt to connect using WEP encryption: // Serial.println("Attempting to connect to WEP-128 network..."); // status = WiFi.begin(ssid, keyIndex, key); diff --git a/WiFi/examples/Wifi_WPA_TwitterClient/Wifi_WPA_TwitterClient.ino b/WiFi/examples/Wifi_WPA_TwitterClient/Wifi_WPA_TwitterClient.ino index f65d6a7b0..cc0cd9e38 100644 --- a/WiFi/examples/Wifi_WPA_TwitterClient/Wifi_WPA_TwitterClient.ino +++ b/WiFi/examples/Wifi_WPA_TwitterClient/Wifi_WPA_TwitterClient.ino @@ -24,7 +24,7 @@ char pass[] = "secretpassword"; int status = WL_IDLE_STATUS; // initialize the library instance: -Client client; +WiFiClient client; const int requestInterval = 30*1000; // delay between requests; 30 seconds diff --git a/WiFi/examples/Wifi_WPA_WebClient/Wifi_WPA_WebClient.ino b/WiFi/examples/Wifi_WPA_WebClient/Wifi_WPA_WebClient.ino index 5e1bd277b..57bc5d265 100644 --- a/WiFi/examples/Wifi_WPA_WebClient/Wifi_WPA_WebClient.ino +++ b/WiFi/examples/Wifi_WPA_WebClient/Wifi_WPA_WebClient.ino @@ -9,7 +9,7 @@ * WiFi shield attached created 13 July 2010 - by Domenico La Fauci + by dlf (Metodo2 srl) modified 21 May 2011 by Tom Igoe */ @@ -17,7 +17,6 @@ #include #include -#include char ssid[] = "yourNetwork"; char pass[] = "secretPassword"; @@ -27,7 +26,7 @@ IPAddress server(74,125,115,105); // Google // Initialize the Ethernet client library // with the IP address and port of the server // that you want to connect to (port 80 is default for HTTP): -Client client; +WiFiClient client; void setup() { Serial.begin(9600); diff --git a/WiFi/examples/Wifi_WPA_WebServer/Wifi_WPA_WebServer.ino b/WiFi/examples/Wifi_WPA_WebServer/Wifi_WPA_WebServer.ino index 9f121ad0b..eb0479a37 100644 --- a/WiFi/examples/Wifi_WPA_WebServer/Wifi_WPA_WebServer.ino +++ b/WiFi/examples/Wifi_WPA_WebServer/Wifi_WPA_WebServer.ino @@ -9,7 +9,7 @@ * Analog inputs attached to pins A0 through A5 (optional) created 13 July 2010 - by Domenico La Fauci + by dlf (Metodo2 srl) modified 5 June 2011 by Tom Igoe */ @@ -22,7 +22,7 @@ char ssid[] = "yourNetwork"; char pass[] = "secretpassword"; int status = WL_IDLE_STATUS; -Server server(80); +WiFiServer server(80); void setup() { // initialize serial: @@ -39,7 +39,7 @@ void setup() { else { server.begin(); Serial.print("Connected to wifi. My address:"); - IPAddress myAddress = WiFi.localIp(); + IPAddress myAddress = WiFi.localIP(); Serial.print(myAddress[0]); Serial.print("."); Serial.print(myAddress[1]); @@ -53,7 +53,7 @@ void setup() { void loop() { // listen for incoming clients - Client client = server.available(); + WiFiClient client = server.available(); if (client) { // an http request ends with a blank line boolean currentLineIsBlank = true; diff --git a/WiFi/examples/wifi_Server_example/wifi_Server_example.ino b/WiFi/examples/wifi_Server_example/wifi_Server_example.ino index 2a88a5617..7fc82afd8 100644 --- a/WiFi/examples/wifi_Server_example/wifi_Server_example.ino +++ b/WiFi/examples/wifi_Server_example/wifi_Server_example.ino @@ -6,10 +6,9 @@ A simple server is setup to exchange data. created 13 July 2010 - by Domenico La Fauci + by dlf (Metodo2 srl) */ #include -#include byte mac[6] = { 0 }; IPAddress ip; @@ -19,11 +18,11 @@ byte dataBuf[80] = { 0 }; char ssid[32] = { 0 }; int status = WL_IDLE_STATUS; -Server server(23); +WiFiServer server(23); void printIpData() { - ip = WiFi.localIp(); + ip = WiFi.localIP(); Serial.print("IP: "); Serial.print(ip[3],10);Serial.print("."); @@ -136,7 +135,7 @@ void loop() if (status == WL_CONNECTED) { byte status = 0; - Client client = server.available(&status); + WiFiClient client = server.available(&status); if (client) { //Serial.print("Status: "); //Serial.println(status, 16); diff --git a/WiFi/examples/wifi_Server_example_WEP/wifi_Server_example_WEP.ino b/WiFi/examples/wifi_Server_example_WEP/wifi_Server_example_WEP.ino index 9191d63e3..5c11b9580 100644 --- a/WiFi/examples/wifi_Server_example_WEP/wifi_Server_example_WEP.ino +++ b/WiFi/examples/wifi_Server_example_WEP/wifi_Server_example_WEP.ino @@ -6,10 +6,9 @@ A simple server is setup to exchange data. created 13 July 2010 - by Domenico La Fauci + by dlf (Metodo2 srl) */ #include -#include byte mac[6] = { 0 }; IPAddress ip; @@ -21,12 +20,11 @@ int status = WL_IDLE_STATUS; #define MAX_NUM_SSID 10 char ssidList[MAX_NUM_SSID][32] = { {0} }; - -Server server(23); +WiFiServer server(23); void printIpData() { - ip = WiFi.localIp(); + ip = WiFi.localIP(); Serial.print("IP: "); Serial.print(ip[3],10);Serial.print("."); @@ -147,7 +145,7 @@ void loop() if (status == WL_CONNECTED) { byte _status = 0; - Client client = server.available(&_status); + WiFiClient client = server.available(&_status); if (client) { Serial.print("Status: "); Serial.println(status, 16); diff --git a/WiFi/examples/wifi_Server_example_WPA/wifi_Server_example_WPA.ino b/WiFi/examples/wifi_Server_example_WPA/wifi_Server_example_WPA.ino index fa79002f1..bf0f731e7 100644 --- a/WiFi/examples/wifi_Server_example_WPA/wifi_Server_example_WPA.ino +++ b/WiFi/examples/wifi_Server_example_WPA/wifi_Server_example_WPA.ino @@ -6,10 +6,10 @@ A simple server is setup to exchange data. created 13 July 2010 - by Domenico La Fauci + by dlf (Metodo2 srl) */ #include -#include + #define _PRINT_ byte mac[6] = { 0 }; @@ -23,12 +23,12 @@ int status = WL_IDLE_STATUS; char ssidList[MAX_NUM_SSID][32] = { {0} }; -Server server(23); +WiFiServer server(23); boolean gotAMessage = false; // whether or not you got a message from the client yet void printIpData() { - ip = WiFi.localIp(); + ip = WiFi.localIP(); Serial.print("\nIP: "); Serial.print(ip[3],10);Serial.print("."); @@ -153,8 +153,7 @@ void execCmd(char* buf) Serial.print("\nExecuting command: "); Serial.println(buf); #endif - //server.write(buf); - server.print(buf); + server.write(buf); } @@ -163,7 +162,7 @@ void loop() if (status == WL_CONNECTED) { byte _status = 0; - Client client = server.available(&_status); + WiFiClient client = server.available(&_status); if (client) { if (!gotAMessage) { Serial.println("\nWe have a new client\n"); diff --git a/WiFi/examples/wifi_WEP_example/wifi_WEP_example.ino b/WiFi/examples/wifi_WEP_example/wifi_WEP_example.ino index 9208e2276..8849f7129 100644 --- a/WiFi/examples/wifi_WEP_example/wifi_WEP_example.ino +++ b/WiFi/examples/wifi_WEP_example/wifi_WEP_example.ino @@ -6,10 +6,9 @@ A simple server is setup to exchange data. created 13 July 2010 - by Domenico La Fauci + by dlf (Metodo2 srl) */ #include -#include byte mac[6] = { 0 }; IPAddress ip; @@ -22,11 +21,11 @@ int status = WL_IDLE_STATUS; char ssidList[MAX_NUM_SSID][32] = { {0} }; -Server server(23); +WiFiServer server(23); void printIpData() { - ip = WiFi.localIp(); + ip = WiFi.localIP(); Serial.print("IP: "); Serial.print(ip[3],10);Serial.print("."); diff --git a/WiFi/examples/wifi_example/wifi_example.pde b/WiFi/examples/wifi_example/wifi_example.pde index 4a05228b9..8db9d2412 100755 --- a/WiFi/examples/wifi_example/wifi_example.pde +++ b/WiFi/examples/wifi_example/wifi_example.pde @@ -6,10 +6,9 @@ A simple server is setup to exchange data. created 13 July 2010 - by Domenico La Fauci + by dlf (Metodo2 srl) */ #include -#include byte mac[6] = { 0 }; IPAddress ip; @@ -22,11 +21,11 @@ int status = WL_IDLE_STATUS; char ssidList[MAX_NUM_SSID][32] = { {0} }; -Server server(23); +WiFiServer server(23); void printIpData() { - ip = WiFi.localIp(); + ip = WiFi.localIP(); Serial.print("IP: "); Serial.print(ip[3],10);Serial.print("."); diff --git a/WiFi/utility/debug.h b/WiFi/utility/debug.h index ef3ba8c22..b9cd3c2aa 100644 --- a/WiFi/utility/debug.h +++ b/WiFi/utility/debug.h @@ -2,7 +2,7 @@ // // File: debug.h // -// Author: Domenico La Fauci +// Author: dlf (Metodo2 srl) // //********************************************/