linkit

GPRS re-connectivity issue

Hello,

I have a scenario where the LinkIt ONE device is sending GPS data using built-in GPRS functionality to a server while moving from one place to another (geographical locations).

Issue

When the device enters a zone where GPRS signals are not available, it tries to reconnect with the server (which is normal). But after some time (5-6 re-connection attempts) it gets stuck in the following function call.

client.Connect()

Which can be acceptable, but when the device gets back in zone where GPRS signals are available, it is not proceeding further i.e. it is still stuck in the client.Connect() function call.

Required behavior

Normally, the LinkIt ONE should keep trying to reconnect with the server when the GPRS signals are not available and as soon as it receives the GPRS signals it should successfully reconnect.


So, is there a way to resolve this like checking GPRS status or signals?

Any discussion on this will be helpful.


Here is my sketch

#include <LGPRS.h>
#include <LGPRSClient.h>
#include <LGPRSServer.h>
char server[] ="arduino.cc";
char path[] ="/asciilogo.txt";
int port = 80; // HTTP
LGPRSClient client;
uint8_t buff;
void setup()
{
  Serial.begin(115200);
  while (!Serial); // wait for serial port to connect.
  
  Serial.println("-- Starting GPRS only --");
  
  initGprs();
}
void loop()
{  
  // if you get a connection, report back via serial:
  Serial.print("Connect to");
  Serial.println(server);
  if (client.connect(server, port))
  {
    Serial.println("connected");
    // Make a HTTP request:
    client.print("GET");
    client.print(path);
    client.println("HTTP/1.1");
    client.print("Host:");
    client.println(server);
    client.println("Connection: close");
    client.println();
  }
  else
  {
    // if you didn't get a connection to the server:
    Serial.println("connection failed");
  }  
  Serial.println("Waiting for client.available() ...");
  while(client.connected() && !client.available()); // wait to read values from client
  while(client.available())
  {    
    char ch = client.read();
    Serial.print(ch);
  }  
  if (!client.available() && !client.connected())
  {
    Serial.println("disconnected");
  }
  delay(5000);
}

void initGprs()
{
  Serial.println("Connecting to AP ...");
  while (!LGPRS.attachGPRS())
  {
    delay(500);
  }
  Serial.println("Connected to AP");
}

sachinJan 29,2018 17:18 PMAdd Comment

Comment

Popular Topics