dongraa1986 2019-03-10 12:58
浏览 193

PHP:逐步接收POST数据(arduino esp8266 car gps tracker project)

I found this nice example on building a gps-sd-wifi project.

MartijnBraam/car-tracker

The problem is in github the php file is not included.

How should I read the data coming from an ESP8266 (or equivalent) using this code as the sender...

I would like to get all the data and be able to save it to a file, or redirect it to mysql.

Thank you

void uploadTrack(char* name){
  File log = SD.open(name);
  WiFiClient client;
  int tracker = ESP.getChipId();
  String trackerId = String(tracker);
  Serial.printf("Uploading %s
", name);
  if(client.connect("tracker.brixit.nl", 80)){
    Serial.println("Sending headers");
    String length = String(log.size());
    String headers = String("POST /upload.php HTTP/1.0
")+
      "Host: tracker.brixit.nl
" +
      "Connection: close
" + 
      "Content-Type: text/csv
" + 
      "Content-Length: " + length + "
" +
      "X-Tracker: " + trackerId + "
" +
      "X-Secret: " + secret + "
" + 
      "X-Track: " + name + "
" +
      "
";
    client.print(headers);
    Serial.println("Sending data");

    char buffer[1470];
    while(true){
      int bytes = log.read(buffer,1470);
      if(bytes < 1){
        break;
      }
      client.write_P(buffer, bytes);
      delay(0);
    }
    Serial.println("Upload done");
    client.stop();
  }


}
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 对于相关问题的求解与代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
    • ¥15 保护模式-系统加载-段寄存器
    • ¥15 电脑桌面设定一个区域禁止鼠标操作
    • ¥15 求NPF226060磁芯的详细资料