0

尝试每 5 秒从服务器获取数据,但 GPRS 需要很长时间才能执行每个命令。服务器以 Json 响应响应。

试图优化每个命令之间的延迟。GPRS 未按预期响应。

  SimHardware.println("AT+SAPBR=3,1,\"CONTYPE\",\"GPRS\"");  /* Connection type GPRS */
  SimHardware.flush();
  delay(5000);
  getSerial();

  SimHardware.println("AT+SAPBR=3,1,\"APN\",\"airtelgprs.com\""); /* APN of the provider */
  SimHardware.flush();
  delay(6000);
  getSerial();

  SimHardware.println("AT+SAPBR=0,1");
  SimHardware.flush();
  delay(1000);
  getSerial();

  SimHardware.println("AT+SAPBR=1,1");
  SimHardware.flush();
  delay(6000);
  getSerial();

  SimHardware.println("AT+HTTPINIT"); /* Initialize HTTP service */
  SimHardware.flush();
  delay(6000);
  getSerial();


  SimHardware.println("AT+HTTPPARA=\"CID\",1");  /* Set parameters for HTTP session */
  SimHardware.flush();
  delay(5000);
  getSerial();

  SimHardware.println("AT+HTTPPARA=\"URL\",\"MY URL"");  /* Set parameters for HTTP session */
  SimHardware.flush();
  delay(5000);
  getSerial();


void getSerial()
{
  delay(500);
  while (Serial.available())
  {
    SimHardware.write(Serial.read());//Forward what Serial received to Software Serial Port
  }
  while (SimHardware.available())
  {
    Serial.write(SimHardware.read());//Forward what Software Serial received to Serial Port
  }
}

如何使用 GPRS Sim800L 优化这个 HTTP GET ..?

4

0 回答 0