QUECTEL EC21 http get 响应在每个查询上都不同

问题描述 投票:0回答:0

我正在尝试在 arduino 上运行 get 查询。

这是我的代码。

    #include <RBD_Timer.h> // https://github.com/alextaujenis/RBD_Timer
    
    RBD::Timer timer(500);
    
    int cnt = -1;
    
    const String webURL = "https://webhook.site/457acaa4-ea36-459a-a8c8-b275a21a5df2";
    
    
    void setup(){
      delay(2000);
      Serial.begin(9600);
      Serial.setTimeout(100);
      delay(10);
    
      Serial1.begin(115200);
      delay(10);
    
      issueCommand("ATI");
    }
    
    void loop(){
      String command = "";
      readSerial();
      while(Serial.available())
      {
        command = Serial.readStringUntil('\n');
        issueCommand(command);
      }
      if(timer.onRestart()){cnt++;operation();}
    }
    
    void issueCommand(String msg){
      Serial1.println(msg);
      delay(10);
    }
    
    void readSerial(){
      while (Serial1.available()){
        Serial.write(Serial1.read());
        timer.restart();
      }
    }
    
    void operation()
    {  
      if      (cnt == 0){issueCommand("AT+QIDEACT=1");}
      else if (cnt == 1){issueCommand("AT+QIACT?");}
      else if (cnt == 2){issueCommand("AT+QICSGP=1,1,\"internet\",\"\",\"\" ,3");}
      else if (cnt == 3){issueCommand("AT+QIACT?");}
      else if (cnt == 4){issueCommand("AT+QIACT=1");}
      else if (cnt == 5){issueCommand("AT+QIACT?");}
      else if (cnt == 6){issueCommand("AT+QHTTPURL="+String(webURL.length())+",80");}
      else if (cnt == 7){issueCommand(webURL);} //https://webhook.site/457acaa4-ea36-459a-a8c8-b275a21a5df2
      else if (cnt == 8){issueCommand("AT+QHTTPGET=80");timer.setTimeout(3000);}
      else if (cnt == 9){issueCommand("AT+QHTTPREAD=80");}
    }

我正在按顺序运行这些代码。每行以 115200 波特率从 Serial1 向 QUEECTEL 发送 AT 代码。大多数 AT 代码都有 500 毫秒的等待时间,但在获取后我将其增加到 3000 毫秒。

这是我在串行监视器上的回复

OK
AT+QIDEACT=1

OK
AT+QIACT?

OK
AT+QICSGP=1,1,"internet","","" ,3

OK
AT+QIACT?

OK
AT+QIACT=1

OK
AT+QIACT?

+QIACT: 1,1,1,"172.30.138.99"

OK
AT+QHTTPURL=57,80

CONNECT

OK
AT+QHTTPGET=80

OK

+QHTTPGET: 0,200
AT+QHTTPREAD=80

CONNECT
A1234567890,B1234567890,C1234567890,567890
OK

+QHTTPREAD: 0

正如你在我收到的回复中看到的;

A1234567890,B1234567890,C1234567890,567890

但必须如此;

A1234567890,B1234567890,C1234567890,D1234567890,E1234567890

每次我执行查询时,响应都会发生变化。 在这里...

AT+QHTTPGET=80

OK

+QHTTPGET: 0,200
AT+QHTTPREAD=80

CONNECT
A1234567890,B1234567890,C1234567890,4567890,E1234567890
OK

+QHTTPREAD: 0

又来了...

+QHTTPGET: 0,200
AT+QHTTPREAD=80

CONNECT
A1234567890,B1234567890,C1234567890,90,E1234567890
OK

+QHTTPREAD: 0

如果我通过 PowerShell 进行查询,则没有问题......

关键是什么?

arduino gsm at-command quectel gsmcomm
© www.soinside.com 2019 - 2024. All rights reserved.