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条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
    • ¥15 如何在scanpy上做差异基因和通路富集?
    • ¥20 关于#硬件工程#的问题,请各位专家解答!
    • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
    • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
    • ¥30 截图中的mathematics程序转换成matlab
    • ¥15 动力学代码报错,维度不匹配
    • ¥15 Power query添加列问题
    • ¥50 Kubernetes&Fission&Eleasticsearch
    • ¥15 報錯:Person is not mapped,如何解決?