mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-16 11:21:18 +03:00
Changed names of the Ethernet classes: Client -> EthernetClient, NetClient -> Client, and basic testing performed
This commit is contained in:
@ -1,10 +1,10 @@
|
|||||||
#ifndef netclient_h
|
#ifndef client_h
|
||||||
#define netclient_h
|
#define client_h
|
||||||
#include "Print.h"
|
#include "Print.h"
|
||||||
#include "NetClient.h"
|
#include "Stream.h"
|
||||||
#include "IPAddress.h"
|
#include "IPAddress.h"
|
||||||
|
|
||||||
class NetClient : public Stream {
|
class Client : public Stream {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual int connect(IPAddress ip, uint16_t port) =0;
|
virtual int connect(IPAddress ip, uint16_t port) =0;
|
||||||
@ -20,6 +20,8 @@ public:
|
|||||||
virtual void stop() = 0;
|
virtual void stop() = 0;
|
||||||
virtual uint8_t connected() = 0;
|
virtual uint8_t connected() = 0;
|
||||||
virtual operator bool() = 0;
|
virtual operator bool() = 0;
|
||||||
|
protected:
|
||||||
|
uint8_t* rawIPAddress(IPAddress& addr) { return addr.raw_address(); };
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -1,11 +0,0 @@
|
|||||||
#ifndef netserver_h
|
|
||||||
#define netserver_h
|
|
||||||
|
|
||||||
class NetClient;
|
|
||||||
|
|
||||||
class NetServer {
|
|
||||||
public:
|
|
||||||
virtual void begin() =0;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
9
hardware/arduino/cores/arduino/Server.h
Normal file
9
hardware/arduino/cores/arduino/Server.h
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#ifndef server_h
|
||||||
|
#define server_h
|
||||||
|
|
||||||
|
class Server {
|
||||||
|
public:
|
||||||
|
virtual void begin() =0;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -4,8 +4,8 @@
|
|||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
//#include "w5100.h"
|
//#include "w5100.h"
|
||||||
#include "IPAddress.h"
|
#include "IPAddress.h"
|
||||||
#include "Client.h"
|
#include "EthernetClient.h"
|
||||||
#include "Server.h"
|
#include "EthernetServer.h"
|
||||||
|
|
||||||
#define MAX_SOCK_NUM 4
|
#define MAX_SOCK_NUM 4
|
||||||
|
|
||||||
@ -29,8 +29,8 @@ public:
|
|||||||
IPAddress gatewayIP();
|
IPAddress gatewayIP();
|
||||||
IPAddress dnsServerIP();
|
IPAddress dnsServerIP();
|
||||||
|
|
||||||
friend class Client;
|
friend class EthernetClient;
|
||||||
friend class Server;
|
friend class EthernetServer;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern EthernetClass Ethernet;
|
extern EthernetClass Ethernet;
|
||||||
|
@ -8,19 +8,19 @@ extern "C" {
|
|||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
|
|
||||||
#include "Ethernet.h"
|
#include "Ethernet.h"
|
||||||
#include "Client.h"
|
#include "EthernetClient.h"
|
||||||
#include "Server.h"
|
#include "EthernetServer.h"
|
||||||
#include "Dns.h"
|
#include "Dns.h"
|
||||||
|
|
||||||
uint16_t Client::_srcport = 1024;
|
uint16_t EthernetClient::_srcport = 1024;
|
||||||
|
|
||||||
Client::Client() : _sock(MAX_SOCK_NUM) {
|
EthernetClient::EthernetClient() : _sock(MAX_SOCK_NUM) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Client::Client(uint8_t sock) : _sock(sock) {
|
EthernetClient::EthernetClient(uint8_t sock) : _sock(sock) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int Client::connect(const char* host, uint16_t port) {
|
int EthernetClient::connect(const char* host, uint16_t port) {
|
||||||
// Look up the host first
|
// Look up the host first
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
DNSClient dns;
|
DNSClient dns;
|
||||||
@ -35,7 +35,7 @@ int Client::connect(const char* host, uint16_t port) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int Client::connect(IPAddress ip, uint16_t port) {
|
int EthernetClient::connect(IPAddress ip, uint16_t port) {
|
||||||
if (_sock != MAX_SOCK_NUM)
|
if (_sock != MAX_SOCK_NUM)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ int Client::connect(IPAddress ip, uint16_t port) {
|
|||||||
if (_srcport == 0) _srcport = 1024;
|
if (_srcport == 0) _srcport = 1024;
|
||||||
socket(_sock, SnMR::TCP, _srcport, 0);
|
socket(_sock, SnMR::TCP, _srcport, 0);
|
||||||
|
|
||||||
if (!::connect(_sock, ip.raw_address(), port)) {
|
if (!::connect(_sock, rawIPAddress(ip), port)) {
|
||||||
_sock = MAX_SOCK_NUM;
|
_sock = MAX_SOCK_NUM;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -70,15 +70,15 @@ int Client::connect(IPAddress ip, uint16_t port) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t Client::write(uint8_t b) {
|
size_t EthernetClient::write(uint8_t b) {
|
||||||
return write(&b, 1);
|
return write(&b, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t Client::write(const char *str) {
|
size_t EthernetClient::write(const char *str) {
|
||||||
return write((const uint8_t *) str, strlen(str));
|
return write((const uint8_t *) str, strlen(str));
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t Client::write(const uint8_t *buf, size_t size) {
|
size_t EthernetClient::write(const uint8_t *buf, size_t size) {
|
||||||
if (_sock == MAX_SOCK_NUM) {
|
if (_sock == MAX_SOCK_NUM) {
|
||||||
setWriteError();
|
setWriteError();
|
||||||
return 0;
|
return 0;
|
||||||
@ -90,13 +90,13 @@ size_t Client::write(const uint8_t *buf, size_t size) {
|
|||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Client::available() {
|
int EthernetClient::available() {
|
||||||
if (_sock != MAX_SOCK_NUM)
|
if (_sock != MAX_SOCK_NUM)
|
||||||
return W5100.getRXReceivedSize(_sock);
|
return W5100.getRXReceivedSize(_sock);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Client::read() {
|
int EthernetClient::read() {
|
||||||
uint8_t b;
|
uint8_t b;
|
||||||
if ( recv(_sock, &b, 1) > 0 )
|
if ( recv(_sock, &b, 1) > 0 )
|
||||||
{
|
{
|
||||||
@ -110,11 +110,11 @@ int Client::read() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int Client::read(uint8_t *buf, size_t size) {
|
int EthernetClient::read(uint8_t *buf, size_t size) {
|
||||||
return recv(_sock, buf, size);
|
return recv(_sock, buf, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Client::peek() {
|
int EthernetClient::peek() {
|
||||||
uint8_t b;
|
uint8_t b;
|
||||||
// Unlike recv, peek doesn't check to see if there's any data available, so we must
|
// Unlike recv, peek doesn't check to see if there's any data available, so we must
|
||||||
if (!available())
|
if (!available())
|
||||||
@ -123,12 +123,12 @@ int Client::peek() {
|
|||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::flush() {
|
void EthernetClient::flush() {
|
||||||
while (available())
|
while (available())
|
||||||
read();
|
read();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::stop() {
|
void EthernetClient::stop() {
|
||||||
if (_sock == MAX_SOCK_NUM)
|
if (_sock == MAX_SOCK_NUM)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -148,7 +148,7 @@ void Client::stop() {
|
|||||||
_sock = MAX_SOCK_NUM;
|
_sock = MAX_SOCK_NUM;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t Client::connected() {
|
uint8_t EthernetClient::connected() {
|
||||||
if (_sock == MAX_SOCK_NUM) return 0;
|
if (_sock == MAX_SOCK_NUM) return 0;
|
||||||
|
|
||||||
uint8_t s = status();
|
uint8_t s = status();
|
||||||
@ -156,14 +156,14 @@ uint8_t Client::connected() {
|
|||||||
(s == SnSR::CLOSE_WAIT && !available()));
|
(s == SnSR::CLOSE_WAIT && !available()));
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t Client::status() {
|
uint8_t EthernetClient::status() {
|
||||||
if (_sock == MAX_SOCK_NUM) return SnSR::CLOSED;
|
if (_sock == MAX_SOCK_NUM) return SnSR::CLOSED;
|
||||||
return W5100.readSnSR(_sock);
|
return W5100.readSnSR(_sock);
|
||||||
}
|
}
|
||||||
|
|
||||||
// the next function allows us to use the client returned by
|
// the next function allows us to use the client returned by
|
||||||
// Server::available() as the condition in an if-statement.
|
// EthernetServer::available() as the condition in an if-statement.
|
||||||
|
|
||||||
Client::operator bool() {
|
EthernetClient::operator bool() {
|
||||||
return _sock != MAX_SOCK_NUM;
|
return _sock != MAX_SOCK_NUM;
|
||||||
}
|
}
|
@ -1,15 +1,15 @@
|
|||||||
#ifndef client_h
|
#ifndef ethernetclient_h
|
||||||
#define client_h
|
#define ethernetclient_h
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
#include "Print.h"
|
#include "Print.h"
|
||||||
#include "NetClient.h"
|
#include "Client.h"
|
||||||
#include "IPAddress.h"
|
#include "IPAddress.h"
|
||||||
|
|
||||||
class Client : public NetClient {
|
class EthernetClient : public Client {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Client();
|
EthernetClient();
|
||||||
Client(uint8_t sock);
|
EthernetClient(uint8_t sock);
|
||||||
|
|
||||||
uint8_t status();
|
uint8_t status();
|
||||||
virtual int connect(IPAddress ip, uint16_t port);
|
virtual int connect(IPAddress ip, uint16_t port);
|
||||||
@ -26,7 +26,7 @@ public:
|
|||||||
virtual uint8_t connected();
|
virtual uint8_t connected();
|
||||||
virtual operator bool();
|
virtual operator bool();
|
||||||
|
|
||||||
friend class Server;
|
friend class EthernetServer;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static uint16_t _srcport;
|
static uint16_t _srcport;
|
@ -5,18 +5,18 @@ extern "C" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#include "Ethernet.h"
|
#include "Ethernet.h"
|
||||||
#include "Client.h"
|
#include "EthernetClient.h"
|
||||||
#include "Server.h"
|
#include "EthernetServer.h"
|
||||||
|
|
||||||
Server::Server(uint16_t port)
|
EthernetServer::EthernetServer(uint16_t port)
|
||||||
{
|
{
|
||||||
_port = port;
|
_port = port;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server::begin()
|
void EthernetServer::begin()
|
||||||
{
|
{
|
||||||
for (int sock = 0; sock < MAX_SOCK_NUM; sock++) {
|
for (int sock = 0; sock < MAX_SOCK_NUM; sock++) {
|
||||||
Client client(sock);
|
EthernetClient client(sock);
|
||||||
if (client.status() == SnSR::CLOSED) {
|
if (client.status() == SnSR::CLOSED) {
|
||||||
socket(sock, SnMR::TCP, _port, 0);
|
socket(sock, SnMR::TCP, _port, 0);
|
||||||
listen(sock);
|
listen(sock);
|
||||||
@ -26,12 +26,12 @@ void Server::begin()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server::accept()
|
void EthernetServer::accept()
|
||||||
{
|
{
|
||||||
int listening = 0;
|
int listening = 0;
|
||||||
|
|
||||||
for (int sock = 0; sock < MAX_SOCK_NUM; sock++) {
|
for (int sock = 0; sock < MAX_SOCK_NUM; sock++) {
|
||||||
Client client(sock);
|
EthernetClient client(sock);
|
||||||
|
|
||||||
if (EthernetClass::_server_port[sock] == _port) {
|
if (EthernetClass::_server_port[sock] == _port) {
|
||||||
if (client.status() == SnSR::LISTEN) {
|
if (client.status() == SnSR::LISTEN) {
|
||||||
@ -48,12 +48,12 @@ void Server::accept()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Client Server::available()
|
EthernetClient EthernetServer::available()
|
||||||
{
|
{
|
||||||
accept();
|
accept();
|
||||||
|
|
||||||
for (int sock = 0; sock < MAX_SOCK_NUM; sock++) {
|
for (int sock = 0; sock < MAX_SOCK_NUM; sock++) {
|
||||||
Client client(sock);
|
EthernetClient client(sock);
|
||||||
if (EthernetClass::_server_port[sock] == _port &&
|
if (EthernetClass::_server_port[sock] == _port &&
|
||||||
(client.status() == SnSR::ESTABLISHED ||
|
(client.status() == SnSR::ESTABLISHED ||
|
||||||
client.status() == SnSR::CLOSE_WAIT)) {
|
client.status() == SnSR::CLOSE_WAIT)) {
|
||||||
@ -64,27 +64,27 @@ Client Server::available()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Client(MAX_SOCK_NUM);
|
return EthernetClient(MAX_SOCK_NUM);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t Server::write(uint8_t b)
|
size_t EthernetServer::write(uint8_t b)
|
||||||
{
|
{
|
||||||
write(&b, 1);
|
write(&b, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t Server::write(const char *str)
|
size_t EthernetServer::write(const char *str)
|
||||||
{
|
{
|
||||||
write((const uint8_t *)str, strlen(str));
|
write((const uint8_t *)str, strlen(str));
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t Server::write(const uint8_t *buffer, size_t size)
|
size_t EthernetServer::write(const uint8_t *buffer, size_t size)
|
||||||
{
|
{
|
||||||
size_t n = 0;
|
size_t n = 0;
|
||||||
|
|
||||||
accept();
|
accept();
|
||||||
|
|
||||||
for (int sock = 0; sock < MAX_SOCK_NUM; sock++) {
|
for (int sock = 0; sock < MAX_SOCK_NUM; sock++) {
|
||||||
Client client(sock);
|
EthernetClient client(sock);
|
||||||
|
|
||||||
if (EthernetClass::_server_port[sock] == _port &&
|
if (EthernetClass::_server_port[sock] == _port &&
|
||||||
client.status() == SnSR::ESTABLISHED) {
|
client.status() == SnSR::ESTABLISHED) {
|
@ -1,18 +1,18 @@
|
|||||||
#ifndef server_h
|
#ifndef ethernetserver_h
|
||||||
#define server_h
|
#define ethernetserver_h
|
||||||
|
|
||||||
#include "NetServer.h"
|
#include "Server.h"
|
||||||
|
|
||||||
class Client;
|
class EthernetClient;
|
||||||
|
|
||||||
class Server :
|
class EthernetServer :
|
||||||
public NetServer {
|
public Server {
|
||||||
private:
|
private:
|
||||||
uint16_t _port;
|
uint16_t _port;
|
||||||
void accept();
|
void accept();
|
||||||
public:
|
public:
|
||||||
Server(uint16_t);
|
EthernetServer(uint16_t);
|
||||||
Client available();
|
EthernetClient available();
|
||||||
virtual void begin();
|
virtual void begin();
|
||||||
virtual size_t write(uint8_t);
|
virtual size_t write(uint8_t);
|
||||||
virtual size_t write(const char *str);
|
virtual size_t write(const char *str);
|
@ -39,7 +39,7 @@ IPAddress subnet(255, 255, 255, 0);
|
|||||||
// Initialize the Ethernet server library
|
// Initialize the Ethernet server library
|
||||||
// with the IP address and port you want to use
|
// with the IP address and port you want to use
|
||||||
// (port 80 is default for HTTP):
|
// (port 80 is default for HTTP):
|
||||||
Server server(80);
|
EthernetServer server(80);
|
||||||
|
|
||||||
|
|
||||||
//Sensor's memory register addresses:
|
//Sensor's memory register addresses:
|
||||||
@ -96,7 +96,7 @@ void loop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// listen for incoming Ethernet connections:
|
// listen for incoming Ethernet connections:
|
||||||
listenForClients();
|
listenForEthernetClients();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -124,9 +124,9 @@ void getData() {
|
|||||||
Serial.println(" Pa");
|
Serial.println(" Pa");
|
||||||
}
|
}
|
||||||
|
|
||||||
void listenForClients() {
|
void listenForEthernetClients() {
|
||||||
// listen for incoming clients
|
// listen for incoming clients
|
||||||
Client client = server.available();
|
EthernetClient client = server.available();
|
||||||
if (client) {
|
if (client) {
|
||||||
Serial.println("Got a client");
|
Serial.println("Got a client");
|
||||||
// an http request ends with a blank line
|
// an http request ends with a blank line
|
||||||
|
@ -29,7 +29,7 @@ IPAddress gateway(192,168,1, 1);
|
|||||||
IPAddress subnet(255, 255, 0, 0);
|
IPAddress subnet(255, 255, 0, 0);
|
||||||
|
|
||||||
// telnet defaults to port 23
|
// telnet defaults to port 23
|
||||||
Server server(23);
|
EthernetServer server(23);
|
||||||
boolean gotAMessage = false; // whether or not you got a message from the client yet
|
boolean gotAMessage = false; // whether or not you got a message from the client yet
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
@ -43,7 +43,7 @@ void setup() {
|
|||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
// wait for a new client:
|
// wait for a new client:
|
||||||
Client client = server.available();
|
EthernetClient client = server.available();
|
||||||
|
|
||||||
// when the client sends the first byte, say hello:
|
// when the client sends the first byte, say hello:
|
||||||
if (client) {
|
if (client) {
|
||||||
|
@ -24,7 +24,7 @@ byte mac[] = {
|
|||||||
// Initialize the Ethernet client library
|
// Initialize the Ethernet client library
|
||||||
// with the IP address and port of the server
|
// with the IP address and port of the server
|
||||||
// that you want to connect to (port 80 is default for HTTP):
|
// that you want to connect to (port 80 is default for HTTP):
|
||||||
Client client;
|
EthernetClient client;
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
// start the serial library:
|
// start the serial library:
|
||||||
|
@ -30,7 +30,7 @@ IPAddress gateway(192,168,1, 1);
|
|||||||
IPAddress subnet(255, 255, 0, 0);
|
IPAddress subnet(255, 255, 0, 0);
|
||||||
|
|
||||||
// telnet defaults to port 23
|
// telnet defaults to port 23
|
||||||
Server server(23);
|
EthernetServer server(23);
|
||||||
boolean gotAMessage = false; // whether or not you got a message from the client yet
|
boolean gotAMessage = false; // whether or not you got a message from the client yet
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
@ -59,7 +59,7 @@ void setup() {
|
|||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
// wait for a new client:
|
// wait for a new client:
|
||||||
Client client = server.available();
|
EthernetClient client = server.available();
|
||||||
|
|
||||||
// when the client sends the first byte, say hello:
|
// when the client sends the first byte, say hello:
|
||||||
if (client) {
|
if (client) {
|
||||||
|
@ -25,7 +25,7 @@ char serverName[] = "www.google.com";
|
|||||||
// Initialize the Ethernet client library
|
// Initialize the Ethernet client library
|
||||||
// with the IP address and port of the server
|
// with the IP address and port of the server
|
||||||
// that you want to connect to (port 80 is default for HTTP):
|
// that you want to connect to (port 80 is default for HTTP):
|
||||||
Client client;
|
EthernetClient client;
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
// start the serial library:
|
// start the serial library:
|
||||||
|
@ -29,7 +29,7 @@ byte mac[] = {
|
|||||||
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
|
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
|
||||||
|
|
||||||
// initialize the library instance:
|
// initialize the library instance:
|
||||||
Client client;
|
EthernetClient client;
|
||||||
|
|
||||||
long lastConnectionTime = 0; // last time you connected to the server, in milliseconds
|
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
|
boolean lastConnected = false; // state of the connection last time through the main loop
|
||||||
|
@ -30,7 +30,7 @@ byte mac[] = {
|
|||||||
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
|
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
|
||||||
|
|
||||||
// initialize the library instance:
|
// initialize the library instance:
|
||||||
Client client;
|
EthernetClient client;
|
||||||
|
|
||||||
long lastConnectionTime = 0; // last time you connected to the server, in milliseconds
|
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
|
boolean lastConnected = false; // state of the connection last time through the main loop
|
||||||
|
@ -33,7 +33,7 @@ IPAddress server(1,1,1,1);
|
|||||||
// with the IP address and port of the server
|
// with the IP address and port of the server
|
||||||
// that you want to connect to (port 23 is default for telnet;
|
// that you want to connect to (port 23 is default for telnet;
|
||||||
// if you're using Processing's ChatServer, use port 10002):
|
// if you're using Processing's ChatServer, use port 10002):
|
||||||
Client client;
|
EthernetClient client;
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
// start the Ethernet connection:
|
// start the Ethernet connection:
|
||||||
|
@ -33,7 +33,7 @@ byte mac[] = {
|
|||||||
IPAddress ip(192,168,1,20);
|
IPAddress ip(192,168,1,20);
|
||||||
|
|
||||||
// initialize the library instance:
|
// initialize the library instance:
|
||||||
Client client;
|
EthernetClient client;
|
||||||
|
|
||||||
const int requestInterval = 60000; // delay between requests
|
const int requestInterval = 60000; // delay between requests
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ IPAddress server(173,194,33,104); // Google
|
|||||||
// Initialize the Ethernet client library
|
// Initialize the Ethernet client library
|
||||||
// with the IP address and port of the server
|
// with the IP address and port of the server
|
||||||
// that you want to connect to (port 80 is default for HTTP):
|
// that you want to connect to (port 80 is default for HTTP):
|
||||||
Client client;
|
EthernetClient client;
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
// start the serial library:
|
// start the serial library:
|
||||||
|
@ -26,7 +26,7 @@ IPAddress ip(192,168,1, 177);
|
|||||||
// Initialize the Ethernet server library
|
// Initialize the Ethernet server library
|
||||||
// with the IP address and port you want to use
|
// with the IP address and port you want to use
|
||||||
// (port 80 is default for HTTP):
|
// (port 80 is default for HTTP):
|
||||||
Server server(80);
|
EthernetServer server(80);
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
@ -38,7 +38,7 @@ void setup()
|
|||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
// listen for incoming clients
|
// listen for incoming clients
|
||||||
Client client = server.available();
|
EthernetClient client = server.available();
|
||||||
if (client) {
|
if (client) {
|
||||||
// an http request ends with a blank line
|
// an http request ends with a blank line
|
||||||
boolean currentLineIsBlank = true;
|
boolean currentLineIsBlank = true;
|
||||||
|
@ -7,8 +7,8 @@
|
|||||||
#######################################
|
#######################################
|
||||||
|
|
||||||
Ethernet KEYWORD1
|
Ethernet KEYWORD1
|
||||||
Client KEYWORD1
|
EthernetClient KEYWORD1
|
||||||
Server KEYWORD1
|
EthernetServer KEYWORD1
|
||||||
IPAddress KEYWORD1
|
IPAddress KEYWORD1
|
||||||
|
|
||||||
#######################################
|
#######################################
|
||||||
|
Reference in New Issue
Block a user