Почему TCP-соединение закрывается при подключении к xively из Adruino GPRS с помощью AT-команд?

Я пытаюсь отправить данные с датчика температуры Arduino, подключенного к сотовой сети, на xively.com с помощью AT-команд. Я могу открыть TCP-соединение, но оно сразу закрывается. Почему TCP-соединение закрывается?

настройка: arduino uno mackbook seeedstudio gprs v2.0 att сим-карта gophone

Вот мои показания Терминала:

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 Shield Arduino Uno macbook

Чтобы посылать AT-команды на экран, я настроил последовательное реле, используя следующий код:

//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.


person Goodword    schedule 03.09.2014    source источник


Ответы (1)


Это работает для меня:

send AT+CGREG? until you get +CGREG: 0,1
send AT+CGATT? response +CGATT: 1
send AT+CSTT="internet","","" response OK
send AT+CIICR response OK
send AT+CIFSR response IP address
send AT+CIPSTART="TCP","api.xively.com","80" response CONNECT OK
person Oldrich Svec    schedule 09.09.2014
comment
Можете ли вы оставить TCP-соединение открытым? - person Goodword; 29.10.2014
comment
Сколько себя помню, мне удавалось поддерживать соединение открытым, но уж точно не навсегда :). - person Oldrich Svec; 30.10.2014