I'm using WiFi CC3000 shield and Adafruit_CC3000.h library. I'm able to connect to my wifi network and all examples work. But my sketch doesn't :(
Here is my loop()
function:
void loop()
{
Serial.println("In-loop");
unsigned long ip;
cc3000.getHostByName("docs.google.com", &ip);
client = cc3000.connectTCP(ip, 80);
if (client.connected())
{
Serial.println("Connected!!!");
String data = "entry.1820200471=46";
data += "&submit=Submit";
client.println(F("POST docs.google.com/forms/d/1YABi7F1ViEqVknN74dQhNLLJqq0RJLRr1QjohRk0qhc/formResponse"));
// client.println(F("HTTP/1.1\r\n"));
client.println(F("Host: docs.google.com\r\n"));
client.println(F("Accept: */*\r\n"));
client.println(F("Accept-Encoding: gzip, deflate\r\n"));
client.println(F("User-Agent: runscope/0.1\r\n"));
client.println(F("Content-Type: application/x-www-form-urlencoded\r\n"));
client.println(F("Connection: close\r\n"));
client.print(F("Content-Length: \r\n"));
client.println(data.length());
client.println();
client.print(data);
client.println();
Serial.println("POST docs.google.com/forms/d/1YABi7F1ViEqVknN74dQhNLLJqq0RJLRr1QjohRk0qhc/formResponse");
// Serial.println("HTTP/1.1");
Serial.println("Host: docs.google.com");
Serial.println("Accept: */*");
Serial.println("Accept-Encoding: gzip, deflate");
Serial.println("User-Agent: runscope/0.1");
Serial.println("Content-Type: application/x-www-form-urlencoded");
Serial.println("Connection: close");
Serial.print("Content-Length: ");
Serial.println(data.length());
Serial.println();
Serial.print(data);
Serial.println();
Serial.println("----------");
unsigned long lastRead = millis();
while(client.connected() && (millis() - lastRead < 3000)) {
while (client.available()) {
char c = client.read();
Serial.print(c);
lastRead = millis();
}
}
Serial.println("----------");
} else {
Serial.println("Not connected");
}
delay(15000L);
}
And the output I get is follow:
In-loop
Connected!!!
POST docs.google.com/forms/d/1YABi7F1ViEqVknN74dQhNLLJqq0RJLRr1QjohRk0qhc/formResponse
Host: docs.google.com
Accept: */*
Accept-Encoding: gzip, deflate
User-Agent: runscope/0.1
Content-Type: application/x-www-form-urlencoded
Connection: close
Content-Length: 33
entry.1820200471=46&submit=Submit
----------
----------
I've tried my request here and it works (actually some headers I took from there).
Could anyone help me?