Large POST request on ESP32 over SIM

Hey, bit of a pot shot putting it in here but anyways My Microcontroller is an esp32-cam, and I am trying to currently write a function to send a POST request containing form data to my server. I am using TinyGSM with a SIM7600 module. so currently the jpegs being captured take up 100kb in RAM this is 1/3 of the RAM, but thats fine. The issue is sending this to the SIM module. can only send 1kb over serial, so i have to chunk it into smaller sizes when sending it i.e
String head = "--PotWatcher\r\nContent-Disposition: form-data; name=\"image\"; filename=\"PotWatcherImage.jpg\"\r\nContent-Type: image/jpeg\r\n\r\n";
String tail = "\r\n--PotWatcher--\r\n";
// Make a HTTP GET request:
Serial.println("Performing HTTP POST request...");
client.print(String("POST ") + resource + " HTTP/1.1\r\n");
client.print(String("Host: ") + host + "\r\n");
client.print(String("Authorization: ") + uuid + "\r\n");
client.println("Connection: Keep-Alive");
client.println("Content-Length: " + String(length));
client.println("Content-Type: multipart/form-data;boundary=PotWatcher");
client.println();
client.print(head);

uint8_t *fbBuf = payload;
for (size_t n = 0; n < length; n = n + PACKET_SIZE)
{
if (n + PACKET_SIZE < length)
{
client.write(fbBuf, PACKET_SIZE);
fbBuf += PACKET_SIZE;
}
else if (length % PACKET_SIZE > 0)
{
size_t remainder = length % PACKET_SIZE;
client.write(fbBuf, remainder);
}
}

client.print(tail);
String head = "--PotWatcher\r\nContent-Disposition: form-data; name=\"image\"; filename=\"PotWatcherImage.jpg\"\r\nContent-Type: image/jpeg\r\n\r\n";
String tail = "\r\n--PotWatcher--\r\n";
// Make a HTTP GET request:
Serial.println("Performing HTTP POST request...");
client.print(String("POST ") + resource + " HTTP/1.1\r\n");
client.print(String("Host: ") + host + "\r\n");
client.print(String("Authorization: ") + uuid + "\r\n");
client.println("Connection: Keep-Alive");
client.println("Content-Length: " + String(length));
client.println("Content-Type: multipart/form-data;boundary=PotWatcher");
client.println();
client.print(head);

uint8_t *fbBuf = payload;
for (size_t n = 0; n < length; n = n + PACKET_SIZE)
{
if (n + PACKET_SIZE < length)
{
client.write(fbBuf, PACKET_SIZE);
fbBuf += PACKET_SIZE;
}
else if (length % PACKET_SIZE > 0)
{
size_t remainder = length % PACKET_SIZE;
client.write(fbBuf, remainder);
}
}

client.print(tail);
the issue with this is that if one of the .write()'s fails (which usually 1 does) i have no way of knowing until i get either a response from the server, or a timeout. An example of this would be https://cdn.discordapp.com/attachments/244238376167800832/1043504972156915792/image.png at this stage i am unsure on what to do. I can safely send post requests that contain little to no data (i.e for one of them i send the GPS lat and long and that works fine)
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server