Hi,
I'm doing a project of taking photos and uploading to web server. I used Adafruit TTL Serial Camera (VC0706) and successfully connected to web server via HTTP.
The saving approach is to use multipart/form-data and transfer binary data to web server. The problem is: the photos saved are either of bad quality or completely broken, the photo I attached here is the best one I got.
Does anyone know any possible causes of this problems? How to solve the problem?
The code clip is the photo saving.
Code: Select all
uint16_t jpglen = cam.frameLength();
Adafruit_CC3000_Client client = cc3000.connectTCP(ip, port);
// Connect to the server, please change your IP address !
if (client.connected()) {
Serial.println(F("Connected !"));
client.println(F("POST /camera.php HTTP/1.1"));
client.println(F("Host: 192.121.3.100:80"));
client.println(F("Content-Type: multipart/form-data; boundary=AaB03x"));
client.print(F("Content-Length: "));
client.println(len);
client.print(start_request);//Some start request for multipart/form-data uploading scheme
// Read all the data up to # bytes!
byte wCount = 0; // For counting # of writes
while (jpglen > 0) {
uint8_t *buffer;
uint8_t bytesToRead = min(32, jpglen); // change 32 to 64 for a speedup but may not work with all setups!
buffer = cam.readPicture(bytesToRead);
client.write(buffer, bytesToRead);
if(++wCount >= 64) { // Every 2K, give a little feedback so it doesn't appear locked up
Serial.print('.');
wCount = 0;
}
jpglen -= bytesToRead;
}
client.print(end_request);
client.println();
Serial.println("Transmission over");
}
client.close();