below is tweaked example code for sending image to my server. (I just changed client.connect method)
anyway, when I took pic, then goes to connection failed.
and I logged my server , didn't come any.
as you may can typed http://myforever.herokuapp.com:80/getPic , then comes to my server well.
why I can't connect to my server to send image...?
void camCapture(ArduCAM myCAM){
//WiFiClient client = server.client();
WiFiClient client;
const int httpPort = 80;
if (!client.connect(http://myforever.herokuapp.com/getPic, httpPort)) {
Serial.println("connection failed");
return;
}
size_t len = myCAM.read_fifo_length();
if (len >= 0x07ffff){
Serial.println("Over size.");
return;
}else if (len == 0 ){
Serial.println("Size is 0.");
return;
}
myCAM.CS_LOW();
myCAM.set_fifo_burst();
#if !(defined (ARDUCAM_SHIELD_V2) && defined (OV2640_CAM))
SPI.transfer(0xFF);
#endif
//if (!client.connected()) return;
String response = "POST /api/device/image HTTP/1.1\r\n";
response += "Content-Type: image/jpeg\r\n";
response += "Content-Length: " + String(len) + "\r\n\r\n";
//server.sendContent(response);
Serial.println("conected to the server");
client.println(response);
static const size_t bufferSize = 4096;
static uint8_t buffer[bufferSize] = {0xFF};
while (len) {
size_t will_copy = (len < bufferSize) ? len : bufferSize;
SPI.transferBytes(&buffer[0], &buffer[0], will_copy);
if (!client.connected()) break;
client.write(&buffer[0], will_copy);
len -= will_copy;
}
myCAM.CS_HIGH();
}[/s]