Skip to content

Commit 6a4f8bf

Browse files
at least it compiles on Arduino 1.0
1 parent bb69a62 commit 6a4f8bf

3 files changed

Lines changed: 10 additions & 12 deletions

File tree

‎HTTPClient.cpp‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ typedef struct
4242
#define URI_RESERVED(byte) (byte == '!' || byte == '*' || byte == '\'' || byte == '(' || byte == ')' || byte == ';' || byte == ':' || byte == '&' || byte == '=' || byte == '+' || byte == '$' || byte == ',' || byte == '/' || byte == '?' || byte == '#' || byte == '[' || byte == ']')
4343

4444
HTTPClient::HTTPClient(char* host, uint8_t* ip) :
45-
Client(ip, 80), hostName(host), debugCommunication(0)
45+
EthernetClient(), hostName(host), debugCommunication(0), ip(ip), port(80)
4646
{
4747
//nothing else to do
4848
}
4949

5050
HTTPClient::HTTPClient(char*host, uint8_t* ip, uint16_t port) :
51-
Client(ip, port), hostName(host), debugCommunication(0)
51+
EthernetClient(), hostName(host), debugCommunication(0), ip(ip), port(port)
5252
{
5353
//nothing else to do
5454
}
@@ -188,7 +188,7 @@ HTTPClient::openClientFile()
188188
{
189189
stop();
190190
}
191-
if (connect())
191+
if (connect(ip,port))
192192
{
193193
return result;
194194
}

‎HTTPClient.h‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#define HTTPCLIENT_H_
2727

2828
#include <inttypes.h>
29-
#include "Client.h"
29+
#include "EthernetClient.h"
3030

3131
/* This struct is used to pass parameters as URI paramters and additional HTTP headers.
3232
* normally you pass this as a array. The last entry must have the NULL-Pointer as name.
@@ -43,7 +43,7 @@ typedef struct
4343
* To construct a HTTP client you have to provide the IP AND the name of the server Ð else
4444
* the virtual host management of most internet servers will fail. Sorry for the inconvenience.
4545
*/
46-
class HTTPClient : private Client
46+
class HTTPClient : private EthernetClient
4747
{
4848
public:
4949
/*
@@ -162,6 +162,10 @@ class HTTPClient : private Client
162162
private:
163163
//the name of the host we are talking to
164164
char* hostName;
165+
//the ip of the host
166+
uint8_t* ip;
167+
//the port we are talking to
168+
uint16_t port;
165169
//the HTTP return code of the last request
166170
int lastReturnCode;
167171
//print to serial?
Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ byte server[] = {
4848
173,203,98,29 };
4949

5050
// initialize the library instance:
51-
Client client(server, 80);
51+
EthernetClient client;
5252

5353
long lastConnectionTime = 0; // last time you connected to the server, in milliseconds
5454
boolean lastConnected = false; // state of the connection last time through the main loop
@@ -105,9 +105,3 @@ void loop() {
105105
// the loop:
106106
lastConnected = client.connected();
107107
}
108-
109-
110-
111-
112-
113-

0 commit comments

Comments
 (0)