Hello Everyone,
I am using HTTP protocol to post data to my server. It seems to take around 3 seconds to open and close the connection and during that time I am losing around 200 packets of data since I cannot send and receive at the same time using a sim7000G. How can I decrease this time of opening and closing the connection? Here is the output of the sim7000g:
19:18:13.003 -> +CIPRXGET: 2,0,1023,332
19:18:13.003 -> HTTP/1.1 200 OK
19:18:13.003 -> Connection: close
19:18:13.003 -> x-powered-by: PHP/8.0.28
19:18:13.063 -> content-type: text/html; charset=UTF-8
19:18:13.063 -> content-length: 1152
19:18:13.063 -> date: Sat, 24 Jun 2023 23:18:12 GMT
19:18:13.063 -> server: LiteSpeed
19:18:13.063 -> platform: hostinger
19:18:13.063 ->
19:18:13.063 -> New record created successfully.<br>New record created successfully.<br>New record created successfully.<br>New record created successfully.<br>New record created successfully.<br>New record created successfully.<br>New record created successfully.<br>New record created successfully.<br>New record created successfully.<br>New record created successfully.<br>New record created successfully.<br>New record created successfully.<br>New record created successfully.<br>New record created successfully.<br>New record created successfully.<br>New record created successfully.<br>New record created successfully.<br>New record created successfully.<br>New record created successfully.<br>New record created successfully.<br>New record created successfully.<br>New record created successfully.<br>New record created successfu
19:18:13.098 -> OK
19:18:13.150 -> AT+CIPRXGET=2,0,332
19:18:13.150 ->
19:18:13.150 -> +CIPRXGET: 2,0,332,0
19:18:13.150 -> lly.<br>New record created successfully.<br>New record created successfully.<br>New record created successfully.<br>New record created successfully.<br>New record created successfully.<br>New record created successfully.<br>New record created successfully.<br>New record created successfully.<br>New record created successfully.<br>
19:18:13.188 -> OK
19:18:13.508 -> AT+CIPRXGET=4,0
19:18:13.508 ->
19:18:13.508 -> +CIPRXGET: 4,0,0
19:18:13.508 ->
19:18:13.508 -> OK
19:18:13.508 -> AT+CIPSTATUS=0
19:18:13.508 ->
19:18:13.508 -> +CIPSTATUS: 0,0,"TCP","154.49.142.244","80","REMOTE CLOSING"
19:18:13.508 ->
19:18:13.508 -> OK
19:18:14.001 -> AT+CIPRXGET=4,0
19:18:14.001 ->
19:18:14.001 -> +CIPRXGET: 4,0,0
19:18:14.001 ->
19:18:14.001 -> OK
19:18:14.001 -> AT+CIPSTATUS=0
19:18:14.001 ->
19:18:14.001 -> +CIPSTATUS: 0,0,"TCP","154.49.142.244","80","REMOTE CLOSING"
19:18:14.035 ->
19:18:14.035 -> OK
19:18:14.260 -> /update4.php?data=1&X=0.2092&Y=0.7584&Z=9.7151&T=26&X=0.2484&Y=0.7845&Z=9.7020&T=39&X=0.2027&Y=0.7257&Z=9.7543&T=66&X=0.2157&Y=0.7126&Z=9.6890&T=79&X=0.1896&Y=0.7388&Z=9.7282&T=451&X=0.2288&Y=0.7192&Z=9.6759&T=464&X=0.2157&Y=0.7322&Z=9.6890&T=477&X=0.2484&Y=0.7126&Z=9.6432&T=504&X=0.3007&Y=0.7518&Z=9.7413&T=517&X=0.2550&Y=0.7845&Z=9.6759&T=530&X=0.2419&Y=0.7976&Z=9.7740&T=544&X=0.2354&Y=0.6865&Z=9.7086&T=557&X=0.2157&Y=0.7518&Z=9.6367&T=583&X=0.2484&Y=0.6538&Z=9.7413&T=597&X=0.2615&Y=0.7257&Z=9.6890&T=610&X=0.2288&Y=0.7976&Z=9.7151&T=623&X=0.2419&Y=0.7649&Z=9.6824&T=650&X=0.2354&Y=0.7061&Z=9.6890&T=663&X=0.2484&Y=0.7322&Z=9.7151&T=676&X=0.2157&Y=0.7715&Z=9.6824&T=689&X=0.2354&Y=0.7257&Z=9.7151&T=702&X=0.2288&Y=0.6734&Z=9.6824&T=729&X=0.2223&Y=0.7192&Z=9.6694&T=742&X=0.2223&Y=0.7388&Z=9.6824&T=755&X=0.2027&Y=0.7322&Z=9.7151&T=769&X=0.2354&Y=0.6799&Z=9.6236&T=795&X=0.2680&Y=0.7518&Z=9.6890&T=808&X=0.2354&Y=0.7126&Z=9.7282&T=821&X=0.2550&Y=0.7518&Z=9.7282&T=835&X=0.2157&Y=0.7518&Z=9.6824&T=848&X=0.2354&Y=0.7845&Z=9.6432&T=874&X=0.2419&Y=0.7845&Z=9.7020&T=888
19:18:14.336 -> AT+CGATT?
19:18:14.336 ->
19:18:14.336 -> +CGATT: 1
19:18:14.336 ->
19:18:14.336 -> OK
19:18:14.336 -> AT+CIFSR;E0
19:18:14.336 ->
19:18:14.336 -> 10.32.159.200
19:18:14.336 ->
19:18:14.336 -> OK
19:18:14.374 -> /update4.php?data=1&X=0.2092&Y=0.7584&Z=9.7151&T=26&X=0.2484&Y=0.7845&Z=9.7020&T=39&X=0.2027&Y=0.7257&Z=9.7543&T=66&X=0.2157&Y=0.7126&Z=9.6890&T=79&X=0.1896&Y=0.7388&Z=9.7282&T=451&X=0.2288&Y=0.7192&Z=9.6759&T=464&X=0.2157&Y=0.7322&Z=9.6890&T=477&X=0.2484&Y=0.7126&Z=9.6432&T=504&X=0.3007&Y=0.7518&Z=9.7413&T=517&X=0.2550&Y=0.7845&Z=9.6759&T=530&X=0.2419&Y=0.7976&Z=9.7740&T=544&X=0.2354&Y=0.6865&Z=9.7086&T=557&X=0.2157&Y=0.7518&Z=9.6367&T=583&X=0.2484&Y=0.6538&Z=9.7413&T=597&X=0.2615&Y=0.7257&Z=9.6890&T=610&X=0.2288&Y=0.7976&Z=9.7151&T=623&X=0.2419&Y=0.7649&Z=9.6824&T=650&X=0.2354&Y=0.7061&Z=9.6890&T=663&X=0.2484&Y=0.7322&Z=9.7151&T=676&X=0.2157&Y=0.7715&Z=9.6824&T=689&X=0.2354&Y=0.7257&Z=9.7151&T=702&X=0.2288&Y=0.6734&Z=9.6824&T=729&X=0.2223&Y=0.7192&Z=9.6694&T=742&X=0.2223&Y=0.7388&Z=9.6824&T=755&X=0.2027&Y=0.7322&Z=9.7151&T=769&X=0.2354&Y=0.6799&Z=9.6236&T=795&X=0.2680&Y=0.7518&Z=9.6890&T=808&X=0.2354&Y=0.7126&Z=9.7282&T=821&X=0.2550&Y=0.7518&Z=9.7282&T=835&X=0.2157&Y=0.7518&Z=9.6824&T=848&X=0.2354&Y=0.7845&Z=9.6432&T=874&X=0.2419&Y=0.7845&Z=9.7020&T=888
19:18:14.450 -> ---------------END PACKET------
19:18:14.450 -> -----Sending Data starts----
19:18:14.450 -> AT+CIPCLOSE=0
19:18:14.450 ->
19:18:14.450 -> 0, CLOSE OK
19:18:14.450 -> AT+CIPSTART=0,"TCP","bridgesense.net",80
19:18:14.450 ->
19:18:14.450 -> OK
19:18:14.564 ->
19:18:14.564 -> 0, CONNECT OK
19:18:14.564 -> AT+CIPSEND=0,3
19:18:14.564 ->
19:18:14.564 -> >GET
19:18:14.600 -> DATA ACCEPT:0,3
19:18:14.600 -> AT+CIPSEND=0,1
19:18:14.600 ->
19:18:14.600 -> >
19:18:14.600 -> DATA ACCEPT:0,1
19:18:14.600 -> AT+CIPSEND=0,1071
19:18:14.600 ->
19:18:14.600 -> >/update4.php?data=1&X=0.2092&Y=0.7584&Z=9.7151&T=26&X=0.2484&Y=0.7845&Z=9.7020&T=39&X=0.2027&Y=0.7257&Z=9.7543&T=66&X=0.2157&Y=0.7126&Z=9.6890&T=79&X=0.1896&Y=0.7388&Z=9.7282&T=451&X=0.2288&Y=0.7192&Z=9.6759&T=464&X=0.2157&Y=0.7322&Z=9.6890&T=477&X=0.2484&Y=0.7126&Z=9.6432&T=504&X=0.3007&Y=0.7518&Z=9.7413&T=517&X=0.2550&Y=0.7845&Z=9.6759&T=530&X=0.2419&Y=0.7976&Z=9.7740&T=544&X=0.2354&Y=0.6865&Z=9.7086&T=557&X=0.2157&Y=0.7518&Z=9.6367&T=583&X=0.2484&Y=0.6538&Z=9.7413&T=597&X=0.2615&Y=0.7257&Z=9.6890&T=610&X=0.2288&Y=0.7976&Z=9.7151&T=623&X=0.2419&Y=0.7649&Z=9.6824&T=650&X=0.2354&Y=0.7061&Z=9.6890&T=663&X=0.2484&Y=0.7322&Z=9.7151&T=676&X=0.2157&Y=0.7715&Z=9.6824&T=689&X=0.2354&Y=0.7257&Z=9.7151&T=702&X=0.2288&Y=0.6734&Z=9.6824&T=729&X=0.2223&Y=0.7192&Z=9.6694&T=742&X=0.2223&Y=0.7388&Z=9.6824&T=755&X=0.2027&Y=0.7322&Z=9.7151&T=769&X=0.2354&Y=0.6799&Z=9.6236&T=795&X=0.2680&Y=0.7518&Z=9.6890&T=808&X=0.2354&Y=0.7126&Z=9.7282&T=821&X=0.2550&Y=0.7518&Z=9.7282&T=835&X=0.2157&Y=0.7518&Z=9.6824&T=848&X=0.2354&Y=0.7845&Z=9.6432&T=874&X=0.2419&Y=0.7845&Z=9.7020&T=888
19:18:14.714 -> DATA ACCEPT:0,1071
19:18:14.714 -> AT+CIPSEND=0,9
19:18:14.714 ->
19:18:14.714 -> > HTTP/1.1
19:18:14.714 -> DATA ACCEPT:0,9
19:18:14.714 -> AT+CIPSEND=0,2
19:18:14.714 ->
19:18:14.714 -> >
19:18:14.714 ->
19:18:14.714 -> DATA ACCEPT:0,2
19:18:14.714 -> AT+CIPSEND=0,6
19:18:14.714 ->
19:18:14.714 -> >Host:
19:18:14.714 -> DATA ACCEPT:0,6
19:18:14.714 -> AT+CIPSEND=0,15
19:18:14.714 ->
19:18:14.714 -> >bridgesense.net
19:18:14.752 -> DATA ACCEPT:0,15
19:18:14.752 -> AT+CIPSEND=0,2
19:18:14.752 ->
19:18:14.752 -> >
19:18:14.752 ->
19:18:14.752 -> DATA ACCEPT:0,2
19:18:14.752 -> AT+CIPSEND=0,10
19:18:14.752 ->
19:18:14.752 -> >User-Agent
19:18:14.752 -> DATA ACCEPT:0,10
19:18:14.752 -> AT+CIPSEND=0,2
19:18:14.752 ->
19:18:14.752 -> >:
19:18:14.752 -> DATA ACCEPT:0,2
19:18:14.752 -> AT+CIPSEND=0,13
19:18:14.752 ->
19:18:14.752 -> >Arduino/2.2.0
19:18:14.791 -> DATA ACCEPT:0,13
19:18:14.791 -> AT+CIPSEND=0,2
19:18:14.791 ->
19:18:14.791 -> >
19:18:14.791 ->
19:18:14.791 -> DATA ACCEPT:0,2
19:18:14.791 -> AT+CIPSEND=0,10
19:18:14.791 ->
19:18:14.791 -> >Connection
19:18:14.791 -> DATA ACCEPT:0,10
19:18:14.791 -> AT+CIPSEND=0,2
19:18:14.791 ->
19:18:14.791 -> >:
19:18:14.791 -> DATA ACCEPT:0,2
19:18:14.791 -> AT+CIPSEND=0,5
19:18:14.791 ->
19:18:14.791 -> >close
19:18:14.828 -> DATA ACCEPT:0,5
19:18:14.828 -> AT+CIPSEND=0,2
19:18:14.828 ->
19:18:14.828 -> >
19:18:14.828 ->
19:18:14.828 -> DATA ACCEPT:0,2
19:18:14.828 -> AT+CIPSEND=0,2
19:18:14.828 ->
19:18:14.828 -> >
19:18:14.828 ->
19:18:14.828 -> DATA ACCEPT:0,2
19:18:14.828 -> ----sending data ends----
19:18:14.828 -> AT+CIPRXGET=4,0
19:18:14.828 ->
19:18:14.828 -> +CIPRXGET: 4,0,0
19:18:14.828 ->
19:18:14.828 -> OK
19:18:14.828 -> AT+CIPSTATUS=0
19:18:14.866 ->
19:18:14.866 -> +CIPSTATUS: 0,0,"TCP","154.49.142.244","80","CONNECTED"
19:18:14.866 ->
19:18:14.866 -> OK
19:18:15.851 -> AT+CIPRXGET=4,0
19:18:15.851 ->
19:18:15.851 -> +CIPRXGET: 1,0
19:18:15.851 ->
19:18:15.851 -> +CIPRXGET: 4,0,1355
19:18:15.851 ->
19:18:15.851 -> OK
19:18:15.851 -> AT+CIPRXGET=2,0,1023
19:18:15.889 ->
19:18:15.889 -> +CIPRXGET: 2,0,1023,332
19:18:15.889 -> HTTP/1.1 200 OK
19:18:15.889 -> Connection: close
19:18:15.889 -> x-powered-by: PHP/8.0.28
19:18:15.889 -> content-type: text/html; charset=UTF-8
19:18:15.889 -> content-length: 1152
19:18:15.889 -> date: Sat, 24 Jun 2023 23:18:14 GMT
19:18:15.889 -> server: LiteSpeed
19:18:15.889 -> platform: hostinger
Here is the code I am using:
#include <esp_now.h>
#include <WiFiClientSecure.h>
#include <WiFi.h>
#define TINY_GSM_MODEM_SIM7000
#define SerialMon Serial
#define SerialAT Serial1
#define TINY_GSM_RX_BUFFER 1024
#define DUMP_AT_COMMANDS
#define TINY_GSM_DEBUG SerialMon
#define GSM_AUTOBAUD_MIN 9600
#define GSM_AUTOBAUD_MAX 115200
#define TINY_GSM_USE_GPRS true
#define TINY_GSM_USE_WIFI false
#define GSM_PIN ""
const char apn[] = "213x.m2m.com.attz";
const char gprsUser[] = "";
const char gprsPass[] = "";
const char server[] = "bridgesense.net";
const int port = 80;
#include <TinyGsmClient.h>
#include <ArduinoHttpClient.h>
#ifdef DUMP_AT_COMMANDS
#include <StreamDebugger.h>
StreamDebugger debugger(SerialAT, SerialMon);
TinyGsm modem(debugger);
#else
TinyGsm modem(SerialAT);
#endif
#define UART_BAUD 115200
#define PIN_DTR 25
#define PIN_TX 27
#define PIN_RX 26
#define PWR_PIN 4
TinyGsmClient client(modem);
HttpClient http(client, server, port);
int counter, lastIndex, numberOfPieces = 24;
String pieces[24], input;
float value_data[8] = {0.0};
int count = 0;
int url_Check = 0;
//Function Declaration
void updateData();
void initGSM();
void connectAPN();
//String data1 , data2 , data3 , data4, data5, data6, data7;
String data_Post = "";
char resource[16384];
typedef struct struct_message {
float depth1;
float depth2;
float depth3;
float depth4;
float accel_x;
float accel_y;
float accel_z;
char TTime[15];
float Temp;
} struct_message;
struct_message myData;
void OnDataRecv(const uint8_t * mac, const uint8_t *incomingData, int len) {
memcpy(&myData, incomingData, sizeof(myData));
/*
Serial.print("\n Bytes received: ");
Serial.println(len);
Serial.print("\n Depth_1: ");
Serial.println(myData.depth1);
Serial.print("\n Depth_2: ");
Serial.println(myData.depth2);
Serial.print("\n Depth_3: ");
Serial.println(myData.depth3);
Serial.print("\n Depth_4: ");
Serial.println(myData.depth4);
Serial.print("\n X-Accel: ");
Serial.println(myData.accel_x);
Serial.print("\n Y-Accel: ");
Serial.println(myData.accel_y);
Serial.print("\n Z-Accel: ");
Serial.println(myData.accel_z);
*/
//convert to Float
// value_data[0] = String(myData.depth1).toFloat();
// value_data[1] = String(myData.depth2).toFloat();
// value_data[2] = String(myData.depth3).toFloat();
// value_data[3] = String(myData.depth4).toFloat();
// value_data[4] = String(myData.accel_x).toFloat();
// value_data[5] = String(myData.accel_y).toFloat();
// value_data[6] = String(myData.accel_z).toFloat();
// value_data[7] = String(myData.Temp).toFloat();
/*
&D1= depth1 sensor
&D2= depthe2 sensor
&D3= deppth3 sensor
&D4= depthe4 sensor
&X= X-acceleration
&Y= Y-acceleration
&Z= Z-acceleration
&Te= Temperature
&T= Time
*/
if (myData.depth1 == 0 && myData.depth2 == 0 && myData.depth3 == 0 && myData.depth4 == 0 && myData.Temp == 0) // If depth1,2,3,4 & Temp is equal to zero. It means we are only sending Acceleration & time
{
if (url_Check == 0)
{
data_Post += "/update4.php?data=1";
}
data_Post += "&X=" + String(myData.accel_x, 4 ) + "&Y=" + String(myData.accel_y, 4) + "&Z=" + String(myData.accel_z, 4) + "&T=" + String(myData.TTime);
count++;
url_Check = 1;
if (count ==32) //change the packet size
{
Serial.println(data_Post);
updateData();
// delay(11115000);
count = 0;
data_Post = "";
url_Check = 0;
}
}
else // send complete packet
{
data_Post += "/update4.php?data=2";
data_Post += "&D1=" + String(myData.depth1, 2 ) + "&D2=" + String(myData.depth2, 2) + "&D3=" + String(myData.depth3, 2) + "&D4=" + String(myData.depth4, 2);
data_Post += "&X=" + String(myData.accel_x, 4 ) + "&Y=" + String(myData.accel_y, 4) + "&Z=" + String(myData.accel_z, 4) + "&Te=" + String(myData.Temp, 0);
data_Post += "&T=" + String(myData.TTime);
Serial.println(data_Post);
updateData();
data_Post = "";
}
}
//This Setup code is executed once then moves to void loop
void setup() {
SerialMon.begin(115200);
delay(10);
initGSM();
delay(2000);
connectAPN();
delay(2000);
WiFi.mode(WIFI_STA);
if (esp_now_init() != ESP_OK) {
Serial.println("Error initializing ESP-NOW");
return;
}
else {
Serial.println("ESP-NOW initialized Sucessfully");
}
esp_now_register_recv_cb(OnDataRecv);
}
void loop() {
}
//Intilization and Setup is everything above this comment Line
//The board is only intended to perform specific tasks once during the setup phase and
//then wait for external events or interrupts to trigger new actions or behaviors. In this case,
//the loop() function may be left blank because the board does not need to do anything continuously.
//You have to have a loop() function, but it doesn't have to have anything in it.
//So put everything in setup(), and have an empty loop().
void updateData() {
if (modem.isGprsConnected()) {
char resource[4096];
// SerialMon.print(F("Performing HTTP GET request... "));
data_Post.toCharArray(resource , data_Post.length() + 1);
Serial.println(resource);
Serial.println("---------------END PACKET------");
Serial.println("-----Sending Data starts----");
int err = http.get(resource);
if (err != 0) {
SerialMon.println(F("failed to connect"));
delay(10000);
return;
}
Serial.println("----sending data ends----");
// int status_code = http.responseStatusCode();
// SerialMon.print(F("Response status code: "));
// SerialMon.println(status_code);
// if (!status_code) {
// //delay(10000);
// // return;
// }
// SerialMon.println(F("Response Headers:"));
// while (http.headerAvailable()) {
// String headerName = http.readHeaderName();
// String headerValue = http.readHeaderValue();
// SerialMon.println(" " + headerName + " : " + headerValue);
// }
// int length = http.contentLength();
// if (length >= 0) {
// SerialMon.print(F("Content length is: "));
// SerialMon.println(length);
// }
// if (http.isResponseChunked()) {
// SerialMon.println(F("The response is chunked"));
// }
String body = http.responseBody();
// SerialMon.println(F("Response:"));
// SerialMon.println(body);
// http.stop();
// http.connectionKeepAlive();
// SerialMon.println(F("Server disconnected"));
}
else {
if (!modem.gprsConnect(apn, gprsUser, gprsPass))
{
Serial.println("---GPRS not connected!----");
Serial.println("---Re-initit GSM/GPRS---");
///
initGSM();
connectAPN();
}
else
{
Serial.println("---GPRS is connected!---");
}
}
}
void initGSM() {
Serial.println("-------InitGSM starts-----");
pinMode(PWR_PIN, OUTPUT);
digitalWrite(PWR_PIN, HIGH);
delay(300);
digitalWrite(PWR_PIN, LOW);
SerialAT.begin(UART_BAUD, SERIAL_8N1, PIN_RX, PIN_TX);
Serial.println("Initializing modem...");
// if (!modem.restart()) {
// Serial.println("Failed (modem.restart()) to restart modem, attempting to continue without restarting");
// }
Serial.println("Initializing modem...");
if (!modem.init()) {
Serial.println("Failed (modem.init()) to restart modem, attempting to continue without restarting");
}
String name = modem.getModemName();
//delay(500);
Serial.println("Modem Name: " + name);
String modemInfo = modem.getModemInfo();
//delay(500);
Serial.println("Modem Info: " + modemInfo);
if ( GSM_PIN && modem.getSimStatus() != 3 ) {
modem.simUnlock(GSM_PIN);
}
modem.sendAT("+CFUN=0 ");
if (modem.waitResponse(10000L) != 1) {
DBG(" +CFUN=0 false ");
}
//delay(200);
String res;
res = modem.setNetworkMode(2);
if (res != "1") {
DBG("setNetworkMode false ");
return ;
}
//delay(200);
res = modem.setPreferredMode(1);
if (res != "1") {
DBG("setPreferredMode false ");
return ;
}
//delay(400);
modem.sendAT("+CFUN=1 ");
if (modem.waitResponse(10000L) != 1) {
DBG(" +CFUN=1 false ");
}
//delay(200);
SerialAT.println("AT+CGDCONT?");
delay(50);
if (SerialAT.available()) {
input = SerialAT.readString();
for (int i = 0; i < input.length(); i++) {
if (input.substring(i, i + 1) == "\n") {
pieces[counter] = input.substring(lastIndex, i);
lastIndex = i + 1;
counter++;
}
if (i == input.length() - 1) {
pieces[counter] = input.substring(lastIndex, i);
}
}
input = "";
counter = 0;
lastIndex = 0;
for ( int y = 0; y < numberOfPieces; y++) {
for ( int x = 0; x < pieces[y].length(); x++) {
char c = pieces[y][x]; //gets one byte from buffer
if (c == ',') {
if (input.indexOf(": ") >= 0) {
String data = input.substring((input.indexOf(": ") + 1));
if ( data.toInt() > 0 && data.toInt() < 25) {
modem.sendAT("+CGDCONT=" + String(data.toInt()) + ",\"IP\",\"" + String(apn) + "\",\"0.0.0.0\",0,0,0,0");
}
input = "";
break;
}
// Reset for reuse
input = "";
} else {
input += c;
}
}
}
} else {
Serial.println("Failed to get PDP!");
}
Serial.println("\n\n\nWaiting for network...");
if (!modem.waitForNetwork()) {
//delay(10000);
return;
}
if (modem.isNetworkConnected()) {
Serial.println("Network connected");
}
Serial.println("\n---Starting GPRS TEST---\n");
Serial.println("Connecting to: " + String(apn));
if (!modem.gprsConnect(apn, gprsUser, gprsPass)) {
//delay(10000);
return;
}
Serial.print("GPRS status: ");
if (modem.isGprsConnected()) {
Serial.println("connected");
} else {
Serial.println("not connected");
}
Serial.println("--------Init GSM ends-------");
}
void connectAPN() {
Serial.print("Connecting to APN: ");
Serial.print(apn);
if (!modem.gprsConnect(apn, gprsUser, gprsPass)) {
Serial.println(" fail");
}
else {
Serial.println(" OK");
}
}