I need to update the code using the sim800l and esp32
but when tried to read file using TinyGSM lib i can’t print all data from them .
#include "GSM_OTA.hpp"
#include <Update.h>
#define FILE_URL "https://shehabhassan.github.io/FOTA_TEST/firmware.bin"
const char* firmware_url = FILE_URL;
static const char *url = FILE_URL;
#define TINY_GSM_MODEM_SIM800
#define SerialMon Serial
#define SerialAT Serial2
#if !defined(TINY_GSM_RX_BUFFER)
#define TINY_GSM_RX_BUFFER 2048
#endif
#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[] = "YourAPN"; // Replace with your correct APN
const char gprsUser[] = ""; // Replace with your username if required
const char gprsPass[] = ""; // Replace with your password if required
const char server[] = "https://shehabhassan.github.io";
const char resource[] = "/FOTA_TEST/firmware.bin";
const int port = 443;
uint32_t knownFileSize = 928416;//
#include <TinyGsmClient.h>
#ifdef DUMP_AT_COMMANDS
#include <StreamDebugger.h>
StreamDebugger debugger(SerialAT, SerialMon);
TinyGsm modem(debugger);
#else
TinyGsm modem(SerialAT);
#endif
TinyGsmClient client(modem);
void printDeviceInfo(){
Serial.println();
Serial.println("--------------------------");
Serial.println(String("Build: ") + __DATE__ " " __TIME__);
Serial.println(String("Flash: ") + ESP.getFlashChipSize() / 1024 + "K");
Serial.println(String("ESP sdk: ") + ESP.getSdkVersion());
Serial.println(String("Chip rev: ") + ESP.getChipRevision());
Serial.println(String("Free mem: ") + ESP.getFreeHeap());
Serial.println("--------------------------");
}
void setup() {
SerialMon.begin(115200);
delay(10);
SerialMon.println("Wait...");
if (!SPIFFS.begin(true)) {
SerialMon.println("An Error has occurred while mounting SPIFFS");
return;
}
TinyGsmAutoBaud(SerialAT, GSM_AUTOBAUD_MIN, GSM_AUTOBAUD_MAX);
delay(6000);
SerialMon.println("Initializing modem...");
modem.restart();
modem.init();
String modemInfo = modem.getModemInfo();
SerialMon.print("Modem Info: ");
SerialMon.println(modemInfo);
SerialMon.println(HEAP_AVAILABLE());
printDeviceInfo();
#if TINY_GSM_USE_GPRS
if (GSM_PIN && modem.getSimStatus() != 3) { modem.simUnlock(GSM_PIN); }
#endif
}
void loop() {
NetworkConnect();
Tiny_GPRS_CONNECT();
// if you get a connection, report back via serial:
if (!client.connect(server, port))
{
Serial.println(" fail");
delay(10000);
return;
}
Serial.println(" OK");
// Make a HTTP request:
client.print(String("GET ") + resource + " HTTP/1.0\r\n");
client.print(String("Host: ") + server + "\r\n");
client.print("Connection: close\r\n\r\n");
long timeout = millis();
while (client.available() == 0)
{
if (millis() - timeout > 5000L)
{
Serial.println(">>> Client Timeout !");
client.stop();
delay(10000L);
return;
}
}
Serial.println("Reading header");
uint32_t contentLength = knownFileSize;
File file = SPIFFS.open("/update.bin", FILE_APPEND);
long timeout1 = millis();
uint32_t response = 0;
while (client.available()) {
String line = client.readStringUntil('\n');
line.trim();
SerialMon.println(line); // Uncomment this to show response headers
}
#if TINY_GSM_USE_GPRS
modem.gprsDisconnect();
SerialMon.println(F("GPRS disconnected"));
#endif
while (true) { delay(1000); }
}
void NetworkConnect() {
SerialMon.print("Waiting for network...");
if (!modem.waitForNetwork()) {
SerialMon.println(" fail");
delay(10000);
return;
}
SerialMon.println(" success");
if (modem.isNetworkConnected()) { SerialMon.println("Network connected"); }
}
void Tiny_GPRS_CONNECT() {
#if TINY_GSM_USE_GPRS
SerialMon.print(F("Connecting to "));
SerialMon.print(apn);
if (!modem.gprsConnect(apn, gprsUser, gprsPass)) {
SerialMon.println(" fail");
delay(10000);
return;
}
SerialMon.println(" success");
if (modem.isGprsConnected()) { SerialMon.println("GPRS connected"); }
#endif
}