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 js调用html页面需要隐藏某个按钮
    • ¥15 ads仿真结果在圆图上是怎么读数的
    • ¥20 Cotex M3的调试和程序执行方式是什么样的?
    • ¥15 一道python难题3
    • ¥15 牛顿斯科特系数表表示
    • ¥15 arduino 步进电机
    • ¥20 程序进入HardFault_Handler
    • ¥15 oracle集群安装出bug
    • ¥15 关于#python#的问题:自动化测试
    • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题