ESP32:如何使用GPRS将图像发送到HTTP或FTP服务器?

时间:2020-04-28 00:55:35

标签: esp32

我正在尝试使用TinyGSM库,目的是将小图像(5K)文件发送到http服务器(ftp也会这样做)。

If I send the image via WiFi it works ok with the following code:
WiFiClient webClient;
if (!webClient.connect(serverURL.c_str(),tcpPort)){
  return("connection failed"); 
}
webClient.print(headerTxt+bodyTxt+bodyPic);
webClient.write((uint8_t*)tempImageBuffer,ImgMetaData.imSize);
webClient.print("\r\n"+bodyEnd);
pDBGln("Done.");

但是,如果我使用下面运行的GPRS代码,则该图像未存储在服务器上,并且返回以下代码后显示的错误。 请注意,GPRS工作正常,我也在同一项目中向MySQL发送了一些数据,并且一切正常。

include TinyGsmClient.h  //(hash sign and brackets removed)
// TinyGSM Client for Internet connection (before setup())
TinyGsmClient client(modem);

if (!modem.gprsConnect(apn, gprsUser, gprsPass)) {
  pDBGln("Modem connect fail");
  }else{
  if (!client.connect(serverURL.c_str(), tcpPort)) {
    pDBGln("Client connect fail");
  }else {
    client.print(headerTxt+bodyTxt+bodyPic);
    client.write((uint8_t*)tempImageBuffer,ImgMetaData.imSize);
    client.print("\r\n"+bodyEnd);
    pDBGln("Done.");

使用此GPRS代码时HTTP服务器返回的错误:

返回值:HTTP / 1.1 500内部服务器错误

Date: Mon, 27 Apr 2020 21:07:05 GMT
Server: Apache
Upgrade: h2,h2c
Connection: Upgrade, close
Last-Modified: Tue, 05 Feb 2019 11:47:32 GMT
Accept-Ranges: bytes
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 8352
Content-Type: text/html

⸮⸮r⸮nG⸮⸮5⸮w⸮.u⸮⸮⸮:⸮i⸮T⸮...... 
it goes on and on and seems to be the entire image sent back from the server.

预先感谢 问候 保罗·博尔赫斯(Paulo Borges)

0 个答案:

没有答案