I'm having a problem with my etheet shield server coection. I coected my etheet shield to a router ( client mode ) and then coect this router to my phone hotspot. This is my code:
#include <SPI.h>
#include <Etheet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
char server[] = "www.xxx";
IPAddress ip(192, 168, 1, 177);
EtheetClient client;
void setup() {
Serial.begin(9600);
while (!Serial) {
;
}
// start the Etheet coection:
if (Etheet.begin(mac) == 0) {
Serial.println("Failed to configure Etheet using DHCP");
Etheet.begin(mac, ip);
}
// give the Etheet shield a second to initialize:
delay(1000);
Serial.println("coecting...");
Serial.println(Etheet.localIP());
// if you get a coection, report back via serial:
if (client.coect(server, 80)) {
Serial.println("coected");
// Make a HTTP request:
client.println("GET http://xxx/ccc.php HTTP/1.1");
client.println("Coection: close");
client.println();
} else {
// if you didn't get a coection to the server:
Serial.println("coection failed");
}
}
void loop() {
if (client.available()) {
char c = client.read();
Serial.print(c);
}
// if the server's discoected, stop the client:
if (!client.coected()) {
Serial.println();
Serial.println("discoecting.");
client.stop();
// do nothing forevermore:
while (true);
}
}
here is what showing on the serial monitor :
coecting...
192.168.43.107 //
coected
HTTP/1.1 400 Bad Request
Date: Mon, 23 May 2016 17:45:44 GMT
Server: Apache
Content-Length: 226
Coection: close
Content-Type: text/html; charset=iso-8859-1
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
</p>
</body></html>
discoecting.
it worked when i directly coect it with my wifi router, but when trying to coect it to my hotspot using a client mode router it gives a Bad request. any help please ?
