2
我試圖使用AT命令將蜂窩連接的arduino溫度傳感器的數據發送到xively.com。我可以打開TCP連接,但它會立即關閉。 爲什麼TCP連接繼續關閉?爲什麼TCP連接在使用AT命令從Adruino GPRS連接到xively時保持關閉狀態?
設置: 的Arduino UNO mackbook seeedstudio GPRS V2.0 ATT gophone SIM卡
這裏是我的終端讀出:
Call Ready
AT
OK
AT+CPIN?
+CPIN: READY
OK
AT+CGATT?
+CGATT: 1
OK
AT+CIPSHUT
SHUT OK
AT+CIPSTATUS
OK
STATE: IP INITIAL
AT+CIPMUX=0
OK
AT+CSTT="wap.cingular"
OK
AT+CIICR
OK
AT+CIFSR
10.52.49.206
AT+CIPSTART="TCP","api.xively.com","80"
OK
STATE: TCP CLOSED
我的設置: SEEEDStudio GPRS屏蔽 Arduino的烏諾 macbook
發送AT命令S到sheild,我已經設置了一個串行中繼使用以下代碼:
//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
}
我然後輸入命令和監視與CoolTerm串行通信。
你能夠保持TCP連接開放? – Goodword 2014-10-29 13:28:24
只要我記得,我能夠保持連接打開,但肯定不會永遠:)。 – 2014-10-30 13:34:48