我有 Arduino Leonardo 和Seeedstudio GPRS Shield v2.0。他们俩都无缝地工作。按照此处有关主要 gprs 屏蔽链接的教程,我已成功将以下代码编译为 arduino:
//Serial Relay - Arduino will patch a
//serial link between the computer and the GPRS Shield
//at 19200 bps 8-N-1
//Computer is connected to Hardware UART
//GPRS Shield is connected to the Software UART
#include <SoftwareSerial.h>
SoftwareSerial GPRS(7, 8);
unsigned char buffer[64]; // buffer array for data recieve over serial port
int count=0; // counter for buffer array
void setup()
{
GPRS.begin(19200); // the GPRS baud rate
Serial.begin(19200); // the Serial port of Arduino baud rate.
}
void loop()
{
if (GPRS.available()) // if date is comming from softwareserial port ==> data is comming from gprs shield
{
while(GPRS.available()) // reading data into char array
{
buffer[count++]=GPRS.read(); // writing data into array
if(count == 64)break;
}
Serial.write(buffer,count); // if no data transmission ends, write buffer to hardware serial port
clearBufferArray(); // call clearBufferArray function to clear the storaged data from the array
count = 0; // set counter of while loop to zero
}
if (Serial.available()) // if data is available on hardwareserial port ==> data is comming from PC or notebook
GPRS.write(Serial.read()); // write it to the GPRS shield
}
void clearBufferArray() // function to clear buffer array
{
for (int i=0; i<count;i++)
{ buffer[i]=NULL;} // clear all index of array with command NULL
}
上面的代码将来自串行的 AT 命令作为输入并将其传递给 gprs 模块。所以,我可以输入类似:“ATD + +1XXXXXXXX”的代码来呼叫号码,并且它起作用了。问题是我无法从 gprs 模块序列中得到响应,之后它只是空白。我读到对串行终端的响应应该是:“OK”。我的问题是:
一个。有什么我错过的吗?我想将响应写入终端。
湾。我想发出http请求,有人有经验怎么做吗?我的意思是这个 gprs 开放网站 blablablabla.com/cs/blabla.php?name=blabla
谢谢之前