Here is the way I handle the connection:
(irrelevant parts stripped)
#define TINY_GSM_MODEM_SIM800
CustomConsole lcdConsole;
#define BLYNK_PRINT lcdConsole
#define SerialAT Serial1
#include <TinyGsmClient.h>
#include <BlynkSimpleSIM800.h>
TinyGsm modem(SerialAT);
BlynkTimer timer;
void GPRScheck() {
if (!modem.isGprsConnected()) {
modem.restart();
modem.simUnlock("1111");
Blynk.config(modem, auth, server);
if (Blynk.connectNetwork(apn, user, pass)) {
lcd.setCursor(1, 0);
lcd.print(F(" "));
lcd.setCursor(1, 0);
lcd.print(modem.getLocalIP());
String COP = modem.getOperator();
COP.remove(15);
lcd.setCursor(18, 0);
lcd.print(COP);
Blynk.connect();
}
}
int csq = modem.getSignalQuality();
char _buff[3];
if (csq != 99) {
csq = map(csq, 0, 31, 0, 99);
sprintf(_buff, "%2d", csq);
}
else {
strcpy(_buff, "--");
}
lcd.setCursor(37, 0);
lcd.print(_buff);
}
void setup()
{
//...
Serial.begin(9600);
//trigger GSM modem POWER pin
pinMode(20, OUTPUT);
digitalWrite(20, HIGH);
delay(1250);
digitalWrite(20, LOW);
pinMode (LED_BUILTIN, OUTPUT);
SerialAT.begin(115200);
delay(3000);
//...
GPRScheck(); //check and initialize GPRS/Blynk connection
//help();
timer.setInterval (60000L, GPRScheck);
}
void loop()
{
Blynk.run();
timer.run();
}
As it comes to library mod, I traced the BLYNK_FATAL definition located in BlynkDebug.h
.:
#define BLYNK_FATAL(msg) { BLYNK_LOG1(msg); BlynkFatal(); }
Where BlynkFatal() part causes the delayed (10sec) reboot
BLYNK_FATAL is called each time an unrecoverable (?) error occurs. In BlynkGsmClient.h
file you will find it (among others) in bool connectNetwork()
in line #43
SO, perhaps simple changing the BLYNK_FATAL to BLYNK_LOG1 in places, where you want to continue instead of reboot will help. BUT this solution is untested by me