From 628efed740cd43c4cb1fcf9ae12c2f95e9ccd207 Mon Sep 17 00:00:00 2001 From: Suwatchai K Date: Sat, 21 Dec 2024 14:11:17 +0700 Subject: [PATCH] Add support PPP network in ESP32 Core v3.x.x --- README.md | 36 ++- .../DefaultPPPNetwork/ESP32/ESP32.ino | 256 +++++++++++++++++ .../Async/Callback/GSMNetwork/GSMNetwork.ino | 3 + .../DefaultPPPNetwork/ESP32/ESP32.ino | 250 ++++++++++++++++ .../NoCallback/GSMNetwork/GSMNetwork.ino | 3 + .../DefaultPPPNetwork/ESP32/ESP32.ino | 266 ++++++++++++++++++ .../Sync/GSMNetwork/GSMNetwork.ino | 3 + examples/App/README.md | 6 + examples/README.md | 3 + library.json | 2 +- library.properties | 2 +- resources/docs/net_config.md | 49 ++++ src/Config.h | 3 + src/core/AsyncClient/AsyncClient.h | 6 +- src/core/Core.h | 2 +- src/core/NetConfig.h | 19 +- src/core/Network.h | 30 +- 17 files changed, 925 insertions(+), 14 deletions(-) create mode 100644 examples/App/NetworkInterfaces/Async/Callback/DefaultNetworks/DefaultPPPNetwork/ESP32/ESP32.ino create mode 100644 examples/App/NetworkInterfaces/Async/NoCallback/DefaultNetworks/DefaultPPPNetwork/ESP32/ESP32.ino create mode 100644 examples/App/NetworkInterfaces/Sync/DefaultNetworks/DefaultPPPNetwork/ESP32/ESP32.ino diff --git a/README.md b/README.md index 5e686632..73541ab9 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,11 @@ ![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/mobizt/FirebaseClient/.github%2Fworkflows%2Fcompile_library.yml?logo=github&label=compile) [![Github Stars](https://img.shields.io/github/stars/mobizt/FirebaseClient?logo=github)](https://github.com/mobizt/FirebaseClient/stargazers) ![Github Issues](https://img.shields.io/github/issues/mobizt/FirebaseClient?logo=github) -![GitHub Release](https://img.shields.io/github/v/release/mobizt/FirebaseClient) ![Arduino](https://img.shields.io/badge/Arduino-v1.4.10-57C207?logo=arduino) ![PlatformIO](https://badges.registry.platformio.org/packages/mobizt/library/FirebaseClient.svg) ![GitHub Release Date](https://img.shields.io/github/release-date/mobizt/FirebaseClient) +![GitHub Release](https://img.shields.io/github/v/release/mobizt/FirebaseClient) ![Arduino](https://img.shields.io/badge/Arduino-v1.4.11-57C207?logo=arduino) ![PlatformIO](https://badges.registry.platformio.org/packages/mobizt/library/FirebaseClient.svg) ![GitHub Release Date](https://img.shields.io/github/release-date/mobizt/FirebaseClient) [![GitHub Sponsors](https://img.shields.io/github/sponsors/mobizt?logo=github)](https://github.com/sponsors/mobizt) -Revision `2024-12-11T12:02:01Z` +Revision `2024-12-21T04:55:10Z` ## Table of Contents @@ -133,6 +133,7 @@ For the FAQ (Frequently Asked Questions), please visit [here](/FAQ.md). * Arduino® GIGA R1 WiFi * Arduino® OPTA * Raspberry Pi Pico (RP2040) + * Raspberry Pi Pico 2 (RP2350) * STM32 MCU based boards (minimum 256k Flash memory) * Teensy 3.1, 3.2, 3.5, 3.6, 4.0 and 4.1 * LAN8720 Ethernet PHY @@ -142,7 +143,7 @@ For the FAQ (Frequently Asked Questions), please visit [here](/FAQ.md). * W5100 SPI Ethernet module * W5500 SPI Ethernet module * SIMCom Modules with [TinyGSM](https://github.com/vshymanskyy/TinyGSM) - + * PPP Modules with ESP32 Core v3.x.x # Unsuppored Devices @@ -327,7 +328,7 @@ Rename folder from **FirebaseClient-main** to **FirebaseClient**. Go to menu **Files** -> **Examples** -> **FirebaseClient** and choose one from examples. -- ### RP2040 Arduino SDK installation +- ### RP2040/RP2350 Arduino SDK installation For Arduino IDE, the Arduino-Pico SDK can be installed from Boards Manager by searching pico and choose Raspberry Pi Pico/RP2040 to install. @@ -508,7 +509,7 @@ The async task handler will kepp the async tasks running as long as it places in #### Running Many Tasks Concurrency Using Different Async Clients (In Different SSL Clients) -In Raspberry Pi Pico W, its `WiFiClientSecure` memory used for the transmit and receive buffers are adjustable (512 to 16384) and you have enough memory to run many tasks concurrency using different async clients. +In Raspberry Pi Pico W/2W, its `WiFiClientSecure` memory used for the transmit and receive buffers are adjustable (512 to 16384) and you have enough memory to run many tasks concurrency using different async clients. In ESP32 device, its `WiFiClientSecure` memory usage cannot be adjusted, it requires at least 50 k per connection (37 k used for `mbedTLS` memory allocation) and only three `WiFiClientSecure`(s) can be defined. @@ -1377,6 +1378,8 @@ The `AsyncClientClass` object requires the network config data (`network_config_ - [DefaultNetwork](/examples/App/NetworkInterfaces/Async/Callback/DefaultNetworks/DefaultNetwork/) is used with the core WiFi enabled networking. +- [DefaultPPPNetwork](/examples/App/NetworkInterfaces/Async/Callback/DefaultNetworks/DefaultPPPNetwork/) is used with the ESP32 core v3.x.x with PPP networking supports. + - [DefaultWiFiNetwork](/examples/App/NetworkInterfaces/Async/Callback/DefaultNetworks/DefaultWiFiNetwork/) is used with the core WiFi Multi enabled networking or non-core WiFi networking. - [DefaultEthernetNetwork](/examples/App/NetworkInterfaces/Async/Callback/DefaultNetworks/DefaultEthernetNetwork/) is used with the core Ethernet enabled networking. @@ -1397,7 +1400,7 @@ To set or change the network for the `AsyncClientClass`, please see [Change Netw > > In ESP8266/ESP32, you can't use WiFi while using ESP-Now. -The default network class can be used with WiFi capable MCUs e.g. ESP8266, ESP32 and Raspberry Pi Pico W. +The default network class can be used with WiFi capable MCUs e.g. ESP8266, ESP32 and Raspberry Pi Pico W/2W. The boolean parameter passed to the default network class constructor is the option for how the network (WiFi) reconnection can be done automatically or manually. @@ -1435,6 +1438,19 @@ When you define `DefaultNetwork` with no parameter, the WiFi reconnection will b > If you are using ESP32 device, and `` was enabled. The bugs in the outdated ESP32 Core WiFi will cause unknown network connection issue when library is trying to reconnect your WiFi using `WiFi.reconnect()`. > You have to update the ESP32 Arduino Core SDK to the latest version or at least v2.x.x. +- `DefaultPPPNetwork` + +The `DefaultPPPNetwork` class constructor. + +```cpp +DefaultPPPNetwork::DefaultPPNetwork() +``` + +This DefaultPPPNetwork class is for ESP32 v3.x.x with PPP network supports. + +See [ESP32 DefaultPPPNetwork example](/examples/App/NetworkInterfaces/Async/Callback/DefaultNetworks/DefaultPPPNetwork/ESP32/) for using ESP32 with its PPP library. + + - `DefaultWiFiNetwork` This `DefaultWiFiNetwork` class required some parameter for reconnection using WiFi credentials. @@ -1468,6 +1484,7 @@ void setup() } ``` + - `DefaultEthernetNetwork` The DefaultEthernetNetwork class parameters are included the following. @@ -1693,6 +1710,8 @@ The following section will provide the basic (bare minimum) code example and the * [ESP32](/examples/App/NetworkInterfaces/Async/Callback/DefaultNetworks/DefaultEthernetNetwork/ESP32/) * [ESP8266](/examples/App/NetworkInterfaces/Async/Callback/DefaultNetworks/DefaultEthernetNetwork/ESP8266/) * [DefaultNetwork](/examples/App/NetworkInterfaces/Async/Callback/DefaultNetworks/DefaultNetwork/) + * [DefaultPPPNetwork](/examples/App/NetworkInterfaces/Async/Callback/DefaultNetworks/DefaultPPPNetwork/) + * [ESP32](/examples/App/NetworkInterfaces/Async/Callback/DefaultNetworks/DefaultPPPNetwork/ESP32/) * [DefaultWiFiNetwork](/examples/App/NetworkInterfaces/Async/Callback/DefaultNetworks/DefaultWiFiNetwork/) * [EthernetNetwork](/examples/App/NetworkInterfaces/Async/Callback/EthernetNetwork/) * [GenericNetwork](/examples/App/NetworkInterfaces/Async/Callback/GenericNetwork/) @@ -1704,6 +1723,8 @@ The following section will provide the basic (bare minimum) code example and the * [ESP32](/examples/App/NetworkInterfaces/Async/NoCallback/DefaultNetworks/DefaultEthernetNetwork/ESP32/) * [ESP8266](/examples/App/NetworkInterfaces/Async/NoCallback/DefaultNetworks/DefaultEthernetNetwork/ESP8266/) * [DefaultNetwork](/examples/App/NetworkInterfaces/Async/NoCallback/DefaultNetworks/DefaultNetwork/) + * [DefaultPPPNetwork](/examples/App/NetworkInterfaces/Async/NoCallback/DefaultNetworks/DefaultPPPNetwork/) + * [ESP32](/examples/App/NetworkInterfaces/Async/NoCallback/DefaultNetworks/DefaultPPPNetwork/ESP32/) * [DefaultWiFiNetwork](/examples/App/NetworkInterfaces/Async/NoCallback/DefaultNetworks/DefaultWiFiNetwork/) * [EthernetNetwork](/examples/App/NetworkInterfaces/Async/NoCallback/EthernetNetwork/) * [GenericNetwork](/examples/App/NetworkInterfaces/Async/NoCallback/GenericNetwork/) @@ -1715,6 +1736,8 @@ The following section will provide the basic (bare minimum) code example and the * [ESP32](/examples/App/NetworkInterfaces/Sync/DefaultNetworks/DefaultEthernetNetwork/ESP32/) * [ESP8266](/examples/App/NetworkInterfaces/Sync/DefaultNetworks/DefaultEthernetNetwork/ESP8266/) * [DefaultNetwork](/examples/App/NetworkInterfaces/Sync/DefaultNetworks/DefaultNetwork/) + * [DefaultPPPNetwork](/examples/App/NetworkInterfaces/Sync/DefaultNetworks/DefaultPPPNetwork/) + * [ESP32](/examples/App/NetworkInterfaces/Sync/DefaultNetworks/DefaultPPPNetwork/ESP32/) * [DefaultWiFiNetwork](/examples/App/NetworkInterfaces/Sync//DefaultNetworks/DefaultWiFiNetwork/) * [EthernetNetwork](/examples/App/NetworkInterfaces/Sync/EthernetNetwork/) * [GenericNetwork](/examples/App/NetworkInterfaces/Sync/GenericNetwork/) @@ -3093,6 +3116,7 @@ ENABLE_ESP8266_W5500_ETH // For native core library W5500 Ethernet module suppor ENABLE_ESP8266_W5100_ETH // For native core library W5100 Ethernet module support in ESP8266. FIREBASE_DISABLE_ONBOARD_WIFI // For disabling on-board WiFI functionality in case external Client usage. FIREBASE_DISABLE_NATIVE_ETHERNET // For disabling native (sdk) Ethernet functionality in case external Client usage. +FIREBASE_DISABLE_NATIVE_PPP // For disabling native ESP32 (sdk) PPP functionality. ENABLE_ASYNC_TCP_CLIENT // For Async TCP Client usage. FIREBASE_ASYNC_QUEUE_LIMIT // For maximum async queue limit setting for an async client. FIREBASE_PRINTF_PORT // For Firebase.printf debug port. diff --git a/examples/App/NetworkInterfaces/Async/Callback/DefaultNetworks/DefaultPPPNetwork/ESP32/ESP32.ino b/examples/App/NetworkInterfaces/Async/Callback/DefaultNetworks/DefaultPPPNetwork/ESP32/ESP32.ino new file mode 100644 index 00000000..4acedbfa --- /dev/null +++ b/examples/App/NetworkInterfaces/Async/Callback/DefaultNetworks/DefaultPPPNetwork/ESP32/ESP32.ino @@ -0,0 +1,256 @@ + + +/** + * This example is for ESP32 Core v3.x.x and the SIM modules. + * + * WaveShare SIM7600 with hardware Flow Control + * + * ESP32 WaveShare SIM7600 + * + * GPIO25 RST + * GPIO21 TX + * GPIO22 RX + * GPIO26 RTS + * GPIO27 CTS + * GND GND + * + * SIM800 basic module with just TX,RX and RST + * + * GPIO0 RST + * GPIO2 TX + * GPIO19 RX + * GND GND + * + * The PPP ESP32 example was taken from + * https://github.com/espressif/arduino-esp32/blob/master/libraries/PPP/examples/PPP_Basic/PPP_Basic.ino + * + * The complete usage guidelines, please visit https://github.com/mobizt/FirebaseClient + * + */ + +#include + +#include + +#include + +// The API key can be obtained from Firebase console > Project Overview > Project settings. +#define API_KEY "Web_API_KEY" + +// User Email and password that already registerd or added in your project. +#define USER_EMAIL "USER_EMAIL" +#define USER_PASSWORD "USER_PASSWORD" + +void asyncCB(AsyncResult &aResult); + +void printResult(AsyncResult &aResult); + +DefaultPPPNetwork default_network; + +UserAuth user_auth(API_KEY, USER_EMAIL, USER_PASSWORD, 3000 /* expire period in seconds (<= 3600) */); + +FirebaseApp app; + +NetworkClientSecure ssl_client; + +using AsyncClient = AsyncClientClass; + +AsyncClient aClient(ssl_client, getNetwork(default_network)); + +#define PPP_MODEM_APN "YourAPN" +#define PPP_MODEM_PIN "0000" // or NULL + +// WaveShare SIM7600 HW Flow Control +#define PPP_MODEM_RST 25 +#define PPP_MODEM_RST_LOW false // active HIGH +#define PPP_MODEM_RST_DELAY 200 +#define PPP_MODEM_TX 21 +#define PPP_MODEM_RX 22 +#define PPP_MODEM_RTS 26 +#define PPP_MODEM_CTS 27 +#define PPP_MODEM_FC ESP_MODEM_FLOW_CONTROL_HW +#define PPP_MODEM_MODEL PPP_MODEM_SIM7600 + +// SIM800 basic module with just TX,RX and RST +// #define PPP_MODEM_RST 0 +// #define PPP_MODEM_RST_LOW true //active LOW +// #define PPP_MODEM_TX 2 +// #define PPP_MODEM_RX 19 +// #define PPP_MODEM_RTS -1 +// #define PPP_MODEM_CTS -1 +// #define PPP_MODEM_FC ESP_MODEM_FLOW_CONTROL_NONE +// #define PPP_MODEM_MODEL PPP_MODEM_SIM800 + +bool firebaseConfigReady = false; + +void onEvent(arduino_event_id_t event, arduino_event_info_t info) +{ + switch (event) + { + case ARDUINO_EVENT_PPP_START: + Serial.println("PPP Started"); + break; + case ARDUINO_EVENT_PPP_CONNECTED: + Serial.println("PPP Connected"); + break; + case ARDUINO_EVENT_PPP_GOT_IP: + Serial.println("PPP Got IP"); + break; + case ARDUINO_EVENT_PPP_LOST_IP: + Serial.println("PPP Lost IP"); + break; + case ARDUINO_EVENT_PPP_DISCONNECTED: + Serial.println("PPP Disconnected"); + break; + case ARDUINO_EVENT_PPP_STOP: + Serial.println("PPP Stopped"); + break; + default: + break; + } +} + +void setup() +{ + Serial.begin(115200); + + // This delay is needed in case ETH_CLK_MODE was set to ETH_CLOCK_GPIO0_IN, + // to allow the external clock source to be ready before initialize the Ethernet. + delay(500); + + Serial.printf("Firebase Client v%s\n", FIREBASE_CLIENT_VERSION); + + // Listen for modem events + Network.onEvent(onEvent); + + // Configure the modem + PPP.setApn(PPP_MODEM_APN); + PPP.setPin(PPP_MODEM_PIN); + PPP.setResetPin(PPP_MODEM_RST, PPP_MODEM_RST_LOW, PPP_MODEM_RST_DELAY); + PPP.setPins(PPP_MODEM_TX, PPP_MODEM_RX, PPP_MODEM_RTS, PPP_MODEM_CTS, PPP_MODEM_FC); + + Serial.println("Starting the modem. It might take a while!"); + PPP.begin(PPP_MODEM_MODEL); + + Serial.print("Manufacturer: "); + Serial.println(PPP.cmd("AT+CGMI", 10000)); + Serial.print("Model: "); + Serial.println(PPP.moduleName()); + Serial.print("IMEI: "); + Serial.println(PPP.IMEI()); + + bool attached = PPP.attached(); + if (!attached) + { + int i = 0; + unsigned int s = millis(); + Serial.print("Waiting to connect to network"); + while (!attached && ((++i) < 600)) + { + Serial.print("."); + delay(100); + attached = PPP.attached(); + } + Serial.print((millis() - s) / 1000.0, 1); + Serial.println("s"); + attached = PPP.attached(); + } + + Serial.print("Attached: "); + Serial.println(attached); + Serial.print("State: "); + Serial.println(PPP.radioState()); + if (attached) + { + Serial.print("Operator: "); + Serial.println(PPP.operatorName()); + Serial.print("IMSI: "); + Serial.println(PPP.IMSI()); + Serial.print("RSSI: "); + Serial.println(PPP.RSSI()); + int ber = PPP.BER(); + if (ber > 0) + { + Serial.print("BER: "); + Serial.println(ber); + Serial.print("NetMode: "); + Serial.println(PPP.networkMode()); + } + + Serial.println("Switching to data mode..."); + PPP.mode(ESP_MODEM_MODE_CMUX); // Data and Command mixed mode + if (!PPP.waitStatusBits(ESP_NETIF_CONNECTED_BIT, 1000)) + { + Serial.println("Failed to connect to internet!"); + } + else + { + Serial.println("Connected to internet!"); + } + } + else + { + Serial.println("Failed to connect to network!"); + } +} + +void setConfig() +{ + if (firebaseConfigReady) + return; + + firebaseConfigReady = true; + + Serial.println("Initializing app..."); + + ssl_client.setInsecure(); + + initializeApp(aClient, app, getAuth(user_auth), asyncCB, "authTask"); +} + +void loop() +{ + if (PPP.connected()) + { + setConfig(); + } + + // The async task handler should run inside the main loop + // without blocking delay or bypassing with millis code blocks. + + app.loop(); + + // To get the authentication time to live in seconds before expired. + // app.ttl(); +} + +void asyncCB(AsyncResult &aResult) +{ + // WARNING! + // Do not put your codes inside the callback and printResult. + + printResult(aResult); +} + +void printResult(AsyncResult &aResult) +{ + if (aResult.isEvent()) + { + Firebase.printf("Event task: %s, msg: %s, code: %d\n", aResult.uid().c_str(), aResult.appEvent().message().c_str(), aResult.appEvent().code()); + } + + if (aResult.isDebug()) + { + Firebase.printf("Debug task: %s, msg: %s\n", aResult.uid().c_str(), aResult.debug().c_str()); + } + + if (aResult.isError()) + { + Firebase.printf("Error task: %s, msg: %s, code: %d\n", aResult.uid().c_str(), aResult.error().message().c_str(), aResult.error().code()); + } + + if (aResult.available()) + { + Firebase.printf("task: %s, payload: %s\n", aResult.uid().c_str(), aResult.c_str()); + } +} \ No newline at end of file diff --git a/examples/App/NetworkInterfaces/Async/Callback/GSMNetwork/GSMNetwork.ino b/examples/App/NetworkInterfaces/Async/Callback/GSMNetwork/GSMNetwork.ino index a7b25895..571a0290 100644 --- a/examples/App/NetworkInterfaces/Async/Callback/GSMNetwork/GSMNetwork.ino +++ b/examples/App/NetworkInterfaces/Async/Callback/GSMNetwork/GSMNetwork.ino @@ -8,6 +8,9 @@ * - The GPRS APN (Access Point Name). * - The GPRS user. * - The GPRS password. + * + * In ESP32 Core v3.x.x, PPP devices are natively supported. + * See examples/App/NetworkInterfaces/Async/Callback/DefaultNetworks/DefaultPPPNetwork/ESP32 * * The complete usage guidelines, please visit https://github.com/mobizt/FirebaseClient * diff --git a/examples/App/NetworkInterfaces/Async/NoCallback/DefaultNetworks/DefaultPPPNetwork/ESP32/ESP32.ino b/examples/App/NetworkInterfaces/Async/NoCallback/DefaultNetworks/DefaultPPPNetwork/ESP32/ESP32.ino new file mode 100644 index 00000000..70631ea0 --- /dev/null +++ b/examples/App/NetworkInterfaces/Async/NoCallback/DefaultNetworks/DefaultPPPNetwork/ESP32/ESP32.ino @@ -0,0 +1,250 @@ + + +/** + * This example is for ESP32 Core v3.x.x and the SIM modules. + * + * WaveShare SIM7600 with hardware Flow Control + * + * ESP32 WaveShare SIM7600 + * + * GPIO25 RST + * GPIO21 TX + * GPIO22 RX + * GPIO26 RTS + * GPIO27 CTS + * GND GND + * + * SIM800 basic module with just TX,RX and RST + * + * GPIO0 RST + * GPIO2 TX + * GPIO19 RX + * GND GND + * + * The PPP ESP32 example was taken from + * https://github.com/espressif/arduino-esp32/blob/master/libraries/PPP/examples/PPP_Basic/PPP_Basic.ino + * + * The complete usage guidelines, please visit https://github.com/mobizt/FirebaseClient + * + */ + +#include + +#include + +#include + +// The API key can be obtained from Firebase console > Project Overview > Project settings. +#define API_KEY "Web_API_KEY" + +// User Email and password that already registerd or added in your project. +#define USER_EMAIL "USER_EMAIL" +#define USER_PASSWORD "USER_PASSWORD" + +void printResult(AsyncResult &aResult); + +DefaultPPPNetwork default_network; + +UserAuth user_auth(API_KEY, USER_EMAIL, USER_PASSWORD, 3000 /* expire period in seconds (<= 3600) */); + +FirebaseApp app; + +NetworkClientSecure ssl_client; + +using AsyncClient = AsyncClientClass; + +AsyncClient aClient(ssl_client, getNetwork(default_network)); + +AsyncResult aResult_no_callback; + +#define PPP_MODEM_APN "YourAPN" +#define PPP_MODEM_PIN "0000" // or NULL + +// WaveShare SIM7600 HW Flow Control +#define PPP_MODEM_RST 25 +#define PPP_MODEM_RST_LOW false // active HIGH +#define PPP_MODEM_RST_DELAY 200 +#define PPP_MODEM_TX 21 +#define PPP_MODEM_RX 22 +#define PPP_MODEM_RTS 26 +#define PPP_MODEM_CTS 27 +#define PPP_MODEM_FC ESP_MODEM_FLOW_CONTROL_HW +#define PPP_MODEM_MODEL PPP_MODEM_SIM7600 + +// SIM800 basic module with just TX,RX and RST +// #define PPP_MODEM_RST 0 +// #define PPP_MODEM_RST_LOW true //active LOW +// #define PPP_MODEM_TX 2 +// #define PPP_MODEM_RX 19 +// #define PPP_MODEM_RTS -1 +// #define PPP_MODEM_CTS -1 +// #define PPP_MODEM_FC ESP_MODEM_FLOW_CONTROL_NONE +// #define PPP_MODEM_MODEL PPP_MODEM_SIM800 + +bool firebaseConfigReady = false; + +void onEvent(arduino_event_id_t event, arduino_event_info_t info) +{ + switch (event) + { + case ARDUINO_EVENT_PPP_START: + Serial.println("PPP Started"); + break; + case ARDUINO_EVENT_PPP_CONNECTED: + Serial.println("PPP Connected"); + break; + case ARDUINO_EVENT_PPP_GOT_IP: + Serial.println("PPP Got IP"); + break; + case ARDUINO_EVENT_PPP_LOST_IP: + Serial.println("PPP Lost IP"); + break; + case ARDUINO_EVENT_PPP_DISCONNECTED: + Serial.println("PPP Disconnected"); + break; + case ARDUINO_EVENT_PPP_STOP: + Serial.println("PPP Stopped"); + break; + default: + break; + } +} + +void setup() +{ + Serial.begin(115200); + + // This delay is needed in case ETH_CLK_MODE was set to ETH_CLOCK_GPIO0_IN, + // to allow the external clock source to be ready before initialize the Ethernet. + delay(500); + + Serial.printf("Firebase Client v%s\n", FIREBASE_CLIENT_VERSION); + + // Listen for modem events + Network.onEvent(onEvent); + + // Configure the modem + PPP.setApn(PPP_MODEM_APN); + PPP.setPin(PPP_MODEM_PIN); + PPP.setResetPin(PPP_MODEM_RST, PPP_MODEM_RST_LOW, PPP_MODEM_RST_DELAY); + PPP.setPins(PPP_MODEM_TX, PPP_MODEM_RX, PPP_MODEM_RTS, PPP_MODEM_CTS, PPP_MODEM_FC); + + Serial.println("Starting the modem. It might take a while!"); + PPP.begin(PPP_MODEM_MODEL); + + Serial.print("Manufacturer: "); + Serial.println(PPP.cmd("AT+CGMI", 10000)); + Serial.print("Model: "); + Serial.println(PPP.moduleName()); + Serial.print("IMEI: "); + Serial.println(PPP.IMEI()); + + bool attached = PPP.attached(); + if (!attached) + { + int i = 0; + unsigned int s = millis(); + Serial.print("Waiting to connect to network"); + while (!attached && ((++i) < 600)) + { + Serial.print("."); + delay(100); + attached = PPP.attached(); + } + Serial.print((millis() - s) / 1000.0, 1); + Serial.println("s"); + attached = PPP.attached(); + } + + Serial.print("Attached: "); + Serial.println(attached); + Serial.print("State: "); + Serial.println(PPP.radioState()); + if (attached) + { + Serial.print("Operator: "); + Serial.println(PPP.operatorName()); + Serial.print("IMSI: "); + Serial.println(PPP.IMSI()); + Serial.print("RSSI: "); + Serial.println(PPP.RSSI()); + int ber = PPP.BER(); + if (ber > 0) + { + Serial.print("BER: "); + Serial.println(ber); + Serial.print("NetMode: "); + Serial.println(PPP.networkMode()); + } + + Serial.println("Switching to data mode..."); + PPP.mode(ESP_MODEM_MODE_CMUX); // Data and Command mixed mode + if (!PPP.waitStatusBits(ESP_NETIF_CONNECTED_BIT, 1000)) + { + Serial.println("Failed to connect to internet!"); + } + else + { + Serial.println("Connected to internet!"); + } + } + else + { + Serial.println("Failed to connect to network!"); + } +} + +void setConfig() +{ + if (firebaseConfigReady) + return; + + firebaseConfigReady = true; + + Serial.println("Initializing app..."); + + ssl_client.setInsecure(); + + initializeApp(aClient, app, getAuth(user_auth), aResult_no_callback); +} + +void loop() +{ + if (PPP.connected()) + { + setConfig(); + } + + // The async task handler should run inside the main loop + // without blocking delay or bypassing with millis code blocks. + + app.loop(); + + // To get the authentication time to live in seconds before expired. + // app.ttl(); + + printResult(aResult_no_callback); +} + +void printResult(AsyncResult &aResult) +{ + if (aResult.isEvent()) + { + Firebase.printf("Event task: %s, msg: %s, code: %d\n", aResult.uid().c_str(), aResult.appEvent().message().c_str(), aResult.appEvent().code()); + } + + if (aResult.isDebug()) + { + Firebase.printf("Debug task: %s, msg: %s\n", aResult.uid().c_str(), aResult.debug().c_str()); + } + + if (aResult.isError()) + { + Firebase.printf("Error task: %s, msg: %s, code: %d\n", aResult.uid().c_str(), aResult.error().message().c_str(), aResult.error().code()); + } + + if (aResult.available()) + { + Firebase.printf("task: %s, payload: %s\n", aResult.uid().c_str(), aResult.c_str()); + } +} \ No newline at end of file diff --git a/examples/App/NetworkInterfaces/Async/NoCallback/GSMNetwork/GSMNetwork.ino b/examples/App/NetworkInterfaces/Async/NoCallback/GSMNetwork/GSMNetwork.ino index 66f16300..66a3983e 100644 --- a/examples/App/NetworkInterfaces/Async/NoCallback/GSMNetwork/GSMNetwork.ino +++ b/examples/App/NetworkInterfaces/Async/NoCallback/GSMNetwork/GSMNetwork.ino @@ -8,6 +8,9 @@ * - The GPRS APN (Access Point Name). * - The GPRS user. * - The GPRS password. + * + * In ESP32 Core v3.x.x, PPP devices are natively supported. + * See examples/App/NetworkInterfaces/Async/NoCallback/DefaultNetworks/DefaultPPPNetwork/ESP32 * * The complete usage guidelines, please visit https://github.com/mobizt/FirebaseClient * diff --git a/examples/App/NetworkInterfaces/Sync/DefaultNetworks/DefaultPPPNetwork/ESP32/ESP32.ino b/examples/App/NetworkInterfaces/Sync/DefaultNetworks/DefaultPPPNetwork/ESP32/ESP32.ino new file mode 100644 index 00000000..d21ad19c --- /dev/null +++ b/examples/App/NetworkInterfaces/Sync/DefaultNetworks/DefaultPPPNetwork/ESP32/ESP32.ino @@ -0,0 +1,266 @@ + + +/** + * This example is for ESP32 Core v3.x.x and the SIM modules. + * + * WaveShare SIM7600 with hardware Flow Control + * + * ESP32 WaveShare SIM7600 + * + * GPIO25 RST + * GPIO21 TX + * GPIO22 RX + * GPIO26 RTS + * GPIO27 CTS + * GND GND + * + * SIM800 basic module with just TX,RX and RST + * + * GPIO0 RST + * GPIO2 TX + * GPIO19 RX + * GND GND + * + * The PPP ESP32 example was taken from + * https://github.com/espressif/arduino-esp32/blob/master/libraries/PPP/examples/PPP_Basic/PPP_Basic.ino + * + * The complete usage guidelines, please visit https://github.com/mobizt/FirebaseClient + * + */ + +#include + +#include + +#include + +// The API key can be obtained from Firebase console > Project Overview > Project settings. +#define API_KEY "Web_API_KEY" + +// User Email and password that already registerd or added in your project. +#define USER_EMAIL "USER_EMAIL" +#define USER_PASSWORD "USER_PASSWORD" + +void authHandler(); + +void printResult(AsyncResult &aResult); + +DefaultPPPNetwork default_network; + +UserAuth user_auth(API_KEY, USER_EMAIL, USER_PASSWORD, 3000 /* expire period in seconds (<= 3600) */); + +FirebaseApp app; + +NetworkClientSecure ssl_client; + +using AsyncClient = AsyncClientClass; + +AsyncClient aClient(ssl_client, getNetwork(default_network)); + +AsyncResult aResult_no_callback; + +#define PPP_MODEM_APN "YourAPN" +#define PPP_MODEM_PIN "0000" // or NULL + +// WaveShare SIM7600 HW Flow Control +#define PPP_MODEM_RST 25 +#define PPP_MODEM_RST_LOW false // active HIGH +#define PPP_MODEM_RST_DELAY 200 +#define PPP_MODEM_TX 21 +#define PPP_MODEM_RX 22 +#define PPP_MODEM_RTS 26 +#define PPP_MODEM_CTS 27 +#define PPP_MODEM_FC ESP_MODEM_FLOW_CONTROL_HW +#define PPP_MODEM_MODEL PPP_MODEM_SIM7600 + +// SIM800 basic module with just TX,RX and RST +// #define PPP_MODEM_RST 0 +// #define PPP_MODEM_RST_LOW true //active LOW +// #define PPP_MODEM_TX 2 +// #define PPP_MODEM_RX 19 +// #define PPP_MODEM_RTS -1 +// #define PPP_MODEM_CTS -1 +// #define PPP_MODEM_FC ESP_MODEM_FLOW_CONTROL_NONE +// #define PPP_MODEM_MODEL PPP_MODEM_SIM800 + +bool firebaseConfigReady = false; + +void onEvent(arduino_event_id_t event, arduino_event_info_t info) +{ + switch (event) + { + case ARDUINO_EVENT_PPP_START: + Serial.println("PPP Started"); + break; + case ARDUINO_EVENT_PPP_CONNECTED: + Serial.println("PPP Connected"); + break; + case ARDUINO_EVENT_PPP_GOT_IP: + Serial.println("PPP Got IP"); + break; + case ARDUINO_EVENT_PPP_LOST_IP: + Serial.println("PPP Lost IP"); + break; + case ARDUINO_EVENT_PPP_DISCONNECTED: + Serial.println("PPP Disconnected"); + break; + case ARDUINO_EVENT_PPP_STOP: + Serial.println("PPP Stopped"); + break; + default: + break; + } +} + +void setup() +{ + Serial.begin(115200); + + // This delay is needed in case ETH_CLK_MODE was set to ETH_CLOCK_GPIO0_IN, + // to allow the external clock source to be ready before initialize the Ethernet. + delay(500); + + Serial.printf("Firebase Client v%s\n", FIREBASE_CLIENT_VERSION); + + // Listen for modem events + Network.onEvent(onEvent); + + // Configure the modem + PPP.setApn(PPP_MODEM_APN); + PPP.setPin(PPP_MODEM_PIN); + PPP.setResetPin(PPP_MODEM_RST, PPP_MODEM_RST_LOW, PPP_MODEM_RST_DELAY); + PPP.setPins(PPP_MODEM_TX, PPP_MODEM_RX, PPP_MODEM_RTS, PPP_MODEM_CTS, PPP_MODEM_FC); + + Serial.println("Starting the modem. It might take a while!"); + PPP.begin(PPP_MODEM_MODEL); + + Serial.print("Manufacturer: "); + Serial.println(PPP.cmd("AT+CGMI", 10000)); + Serial.print("Model: "); + Serial.println(PPP.moduleName()); + Serial.print("IMEI: "); + Serial.println(PPP.IMEI()); + + bool attached = PPP.attached(); + if (!attached) + { + int i = 0; + unsigned int s = millis(); + Serial.print("Waiting to connect to network"); + while (!attached && ((++i) < 600)) + { + Serial.print("."); + delay(100); + attached = PPP.attached(); + } + Serial.print((millis() - s) / 1000.0, 1); + Serial.println("s"); + attached = PPP.attached(); + } + + Serial.print("Attached: "); + Serial.println(attached); + Serial.print("State: "); + Serial.println(PPP.radioState()); + if (attached) + { + Serial.print("Operator: "); + Serial.println(PPP.operatorName()); + Serial.print("IMSI: "); + Serial.println(PPP.IMSI()); + Serial.print("RSSI: "); + Serial.println(PPP.RSSI()); + int ber = PPP.BER(); + if (ber > 0) + { + Serial.print("BER: "); + Serial.println(ber); + Serial.print("NetMode: "); + Serial.println(PPP.networkMode()); + } + + Serial.println("Switching to data mode..."); + PPP.mode(ESP_MODEM_MODE_CMUX); // Data and Command mixed mode + if (!PPP.waitStatusBits(ESP_NETIF_CONNECTED_BIT, 1000)) + { + Serial.println("Failed to connect to internet!"); + } + else + { + Serial.println("Connected to internet!"); + } + } + else + { + Serial.println("Failed to connect to network!"); + } +} + +void setConfig() +{ + if (firebaseConfigReady) + return; + + firebaseConfigReady = true; + + Serial.println("Initializing app..."); + + ssl_client.setInsecure(); + + initializeApp(aClient, app, getAuth(user_auth), aResult_no_callback); +} + +void loop() +{ + if (PPP.connected()) + { + setConfig(); + } + + authHandler(); + + app.loop(); + + // To get the authentication time to live in seconds before expired. + // app.ttl(); + + printResult(aResult_no_callback); +} + +void authHandler() +{ + // Blocking authentication handler with timeout + unsigned long ms = millis(); + while (app.isInitialized() && !app.ready() && millis() - ms < 120 * 1000) + { + // The JWT token processor required for ServiceAuth and CustomAuth authentications. + // JWT is a static object of JWTClass and it's not thread safe. + // In multi-threaded operations (multi-FirebaseApp), you have to define JWTClass for each FirebaseApp, + // and set it to the FirebaseApp via FirebaseApp::setJWTProcessor(), before calling initializeApp. + JWT.loop(app.getAuth()); + printResult(aResult_no_callback); + } +} + +void printResult(AsyncResult &aResult) +{ + if (aResult.isEvent()) + { + Firebase.printf("Event task: %s, msg: %s, code: %d\n", aResult.uid().c_str(), aResult.appEvent().message().c_str(), aResult.appEvent().code()); + } + + if (aResult.isDebug()) + { + Firebase.printf("Debug task: %s, msg: %s\n", aResult.uid().c_str(), aResult.debug().c_str()); + } + + if (aResult.isError()) + { + Firebase.printf("Error task: %s, msg: %s, code: %d\n", aResult.uid().c_str(), aResult.error().message().c_str(), aResult.error().code()); + } + + if (aResult.available()) + { + Firebase.printf("task: %s, payload: %s\n", aResult.uid().c_str(), aResult.c_str()); + } +} \ No newline at end of file diff --git a/examples/App/NetworkInterfaces/Sync/GSMNetwork/GSMNetwork.ino b/examples/App/NetworkInterfaces/Sync/GSMNetwork/GSMNetwork.ino index 64410ce9..9a2518e9 100644 --- a/examples/App/NetworkInterfaces/Sync/GSMNetwork/GSMNetwork.ino +++ b/examples/App/NetworkInterfaces/Sync/GSMNetwork/GSMNetwork.ino @@ -8,6 +8,9 @@ * - The GPRS APN (Access Point Name). * - The GPRS user. * - The GPRS password. + * + * In ESP32 Core v3.x.x, PPP devices are natively supported. + * See examples/App/NetworkInterfaces/Sync/DefaultNetworks/DefaultPPPNetwork/ESP32 * * The complete usage guidelines, please visit https://github.com/mobizt/FirebaseClient * diff --git a/examples/App/README.md b/examples/App/README.md index 5dfc81d5..52ceb2d4 100644 --- a/examples/App/README.md +++ b/examples/App/README.md @@ -51,6 +51,8 @@ * [ESP32](/examples/App/NetworkInterfaces/Async/Callback/DefaultNetworks/DefaultEthernetNetwork/ESP32/) * [ESP8266](/examples/App/NetworkInterfaces/Async/Callback/DefaultNetworks/DefaultEthernetNetwork/ESP8266/) * [DefaultNetwork](/examples/App/NetworkInterfaces/Async/Callback/DefaultNetworks/DefaultNetwork/) + * [DefaultPPPNetwork](/examples/App/NetworkInterfaces/Async/Callback/DefaultNetworks/DefaultPPPNetwork/) + * [ESP32](/examples/App/NetworkInterfaces/Async/Callback/DefaultNetworks/DefaultPPPNetwork/ESP32/) * [DefaultWiFiNetwork](/examples/App/NetworkInterfaces/Async/Callback/DefaultNetworks/DefaultWiFiNetwork/) * [EthernetNetwork](/examples/App/NetworkInterfaces/Async/Callback/EthernetNetwork/) * [GenericNetwork](/examples/App/NetworkInterfaces/Async/Callback/GenericNetwork/) @@ -61,6 +63,8 @@ * [ESP32](/examples/App/NetworkInterfaces/Async/NoCallback/DefaultNetworks/DefaultEthernetNetwork/ESP32/) * [ESP8266](/examples/App/NetworkInterfaces/Async/NoCallback/DefaultNetworks/DefaultEthernetNetwork/ESP8266/) * [DefaultNetwork](/examples/App/NetworkInterfaces/Async/NoCallback/DefaultNetworks/DefaultNetwork/) + * [DefaultPPPNetwork](/examples/App/NetworkInterfaces/Async/NoCallback/DefaultNetworks/DefaultPPPNetwork/) + * [ESP32](/examples/App/NetworkInterfaces/Async/NoCallback/DefaultNetworks/DefaultPPPNetwork/ESP32/) * [DefaultWiFiNetwork](/examples/App/NetworkInterfaces/Async/NoCallback/DefaultNetworks/DefaultWiFiNetwork/) * [EthernetNetwork](/examples/App/NetworkInterfaces/Async/NoCallback/EthernetNetwork/) * [GenericNetwork](/examples/App/NetworkInterfaces/Async/NoCallback/GenericNetwork/) @@ -71,6 +75,8 @@ * [ESP32](/examples/App/NetworkInterfaces/Sync/DefaultNetworks/DefaultEthernetNetwork/ESP32/) * [ESP8266](/examples/App/NetworkInterfaces/Sync/DefaultNetworks/DefaultEthernetNetwork/ESP8266/) * [DefaultNetwork](/examples/App/NetworkInterfaces/Sync/DefaultNetworks/DefaultNetwork/) + * [DefaultPPPNetwork](/examples/App/NetworkInterfaces/Sync/DefaultNetworks/DefaultPPPNetwork/) + * [ESP32](/examples/App/NetworkInterfaces/Sync/DefaultNetworks/DefaultPPPNetwork/ESP32/) * [DefaultWiFiNetwork](/examples/App/NetworkInterfaces/Sync//DefaultNetworks/DefaultWiFiNetwork/) * [EthernetNetwork](/examples/App/NetworkInterfaces/Sync/EthernetNetwork/) * [GenericNetwork](/examples/App/NetworkInterfaces/Sync/GenericNetwork/) diff --git a/examples/README.md b/examples/README.md index e223e9ae..731801f6 100644 --- a/examples/README.md +++ b/examples/README.md @@ -52,6 +52,7 @@ │ │ │ │ │ │ ├───ESP32 │ │ │ │ │ │ └───ESP8266 │ │ │ │ │ ├───DefaultNetwork +│ │ │ │ │ ├───DefaultPPPNetwork │ │ │ │ │ └───DefaultWiFiNetwork │ │ │ │ ├───EthernetNetwork │ │ │ │ ├───GenericNetwork @@ -62,6 +63,7 @@ │ │ │ │ │ ├───ESP32 │ │ │ │ │ └───ESP8266 │ │ │ │ ├───DefaultNetwork +│ │ │ │ ├───DefaultPPPNetwork │ │ │ │ └───DefaultWiFiNetwork │ │ │ ├───EthernetNetwork │ │ │ ├───GenericNetwork @@ -72,6 +74,7 @@ │ │ │ │ ├───ESP32 │ │ │ │ └───ESP8266 │ │ │ ├───DefaultNetwork +│ │ │ ├───DefaultPPPNetwork │ │ │ └───DefaultWiFiNetwork │ │ ├───EthernetNetwork │ │ ├───GenericNetwork diff --git a/library.json b/library.json index 4d0308a8..d77477df 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "FirebaseClient", - "version": "1.4.10", + "version": "1.4.11", "keywords": "communication, REST, esp32, esp8266, arduino", "description": "Async Firebase Client library for Arduino.", "repository": { diff --git a/library.properties b/library.properties index 0a90ef2c..bf0caaf9 100644 --- a/library.properties +++ b/library.properties @@ -1,6 +1,6 @@ name=FirebaseClient -version=1.4.10 +version=1.4.11 author=Mobizt diff --git a/resources/docs/net_config.md b/resources/docs/net_config.md index efd5d595..03e8faf9 100644 --- a/resources/docs/net_config.md +++ b/resources/docs/net_config.md @@ -313,6 +313,55 @@ class DefaultEthernetNetwork
+# DefaultPPPtNetwork + +## Description + +The default Ethernet class for ESP32 with PPP supports. + + +```cpp +class DefaultPPPtNetwork +``` + + +## Constructors + + 1. ### 🔹 DefaultPPPtNetwork() + + The default PPP network class for ESP32 with native PPP ptotocols supports. + + See [ESP32 DefaultPPPNetwork example](/examples/App/NetworkInterfaces/Async/Callback/DefaultNetworks/DefaultPPPNetwork/ESP32/) for using ESP32 with its native PPP library. + + ```cpp + DefaultPPPtNetwork() + ``` + +## Functions + +1. ### 🔹 void clear() + + Clear the internal network data. + + ```cpp + void clear() + ``` + +2. ### 🔹 network_config_data &get() + + Get the reference to the internal `network_config_data`. + + ```cpp + network_config_data &get() + ``` + + **Returns:** + + - `network_config_data &` - The reference to internal `network_config_data`. + +
+ + # DefaultWiFiNetwork ## Description diff --git a/src/Config.h b/src/Config.h index 2edae550..0fee291c 100644 --- a/src/Config.h +++ b/src/Config.h @@ -114,6 +114,9 @@ * * 🏷️ For disabling native (sdk) Ethernet functionality in case external Client usage. * #define FIREBASE_DISABLE_NATIVE_ETHERNET + * + * 🏷️ For disabling native ESP32 (sdk) PPP functionality. + * #define FIREBASE_DISABLE_NATIVE_PPP * * 🏷️ For Async TCP Client usage. * #define ENABLE_ASYNC_TCP_CLIENT diff --git a/src/core/AsyncClient/AsyncClient.h b/src/core/AsyncClient/AsyncClient.h index f6f379f3..7c5773d6 100644 --- a/src/core/AsyncClient/AsyncClient.h +++ b/src/core/AsyncClient/AsyncClient.h @@ -1,5 +1,5 @@ /** - * Created November 28, 2024 + * Created December 21, 2024 * * For MCU build target (CORE_ARDUINO_XXXX), see Options.h. * @@ -1837,8 +1837,8 @@ class AsyncClientClass : public ResultBase, RTDBResultBase net.network_status = ethernetConnected(); } // also check the native network before calling external cb - else if (net.network_data_type == firebase_network_data_default_network || WIFI_CONNECTED || ethLinkUp()) - net.network_status = WIFI_CONNECTED || ethLinkUp(); + else if (net.network_data_type == firebase_network_data_default_network || WIFI_CONNECTED || ethLinkUp() || PPP_CONNECTED) + net.network_status = WIFI_CONNECTED || ethLinkUp() || PPP_CONNECTED; else if (net.network_data_type == firebase_network_data_generic_network) { if (!net.generic.net_status_cb) diff --git a/src/core/Core.h b/src/core/Core.h index ad8049d0..8689ff47 100644 --- a/src/core/Core.h +++ b/src/core/Core.h @@ -7,7 +7,7 @@ #undef FIREBASE_CLIENT_VERSION #endif -#define FIREBASE_CLIENT_VERSION "1.4.10" +#define FIREBASE_CLIENT_VERSION "1.4.11" static void sys_idle() { diff --git a/src/core/NetConfig.h b/src/core/NetConfig.h index 8b79d7a6..33e8c0fe 100644 --- a/src/core/NetConfig.h +++ b/src/core/NetConfig.h @@ -1,5 +1,5 @@ /** - * Created July 6, 2024 + * Created December 21, 2024 * * The MIT License (MIT) * Copyright (c) 2024 K. Suwatchai (Mobizt) @@ -43,6 +43,7 @@ struct network_config_data friend class GenericNetwork; friend class EthernetNetwork; friend class GSMNetwork; + friend class DefaultPPPNetwork; friend class DefaultEthernetNetwork; friend class DefaultWiFiNetwork; friend class AsyncClientClass; @@ -446,6 +447,22 @@ class DefaultEthernetNetwork : public DefaultNetwork ~DefaultEthernetNetwork() { clear(); } }; +class DefaultPPPNetwork : public DefaultNetwork +{ + +public: + /** + * The default PPP network class for ESP32 with native PPP ptotocols supports. + * See /examples/App/NetworkInterfaces/Async/Callback/DefaultNetworks/DefaultPPPNetwork/ESP32/ for using ESP32 with its native PPP library. + */ + DefaultPPPNetwork() + { + init(); + network_data.network_data_type = firebase_network_data_default_network; + } + ~DefaultPPPNetwork() { clear(); } +}; + class DefaultWiFiNetwork : public DefaultNetwork { diff --git a/src/core/Network.h b/src/core/Network.h index c01b6078..8c419521 100644 --- a/src/core/Network.h +++ b/src/core/Network.h @@ -1,5 +1,5 @@ /** - * Created Sepyember 17, 2024 + * Created December 21, 2024 * * For MCU build target (CORE_ARDUINO_XXXX), see Options.h. * @@ -264,12 +264,40 @@ typedef void (*NetworkStatusCallback)(bool &); #define FIREBASE_GSM_MODEM_IS_AVAILABLE #endif +#if !defined(FIREBASE_DISABLE_NATIVE_PPP) && defined(ESP_ARDUINO_VERSION) /* ESP32 core >= v2.0.x */ +#if ESP_ARDUINO_VERSION >= ESP_ARDUINO_VERSION_VAL(3, 0, 0) + +#if __has_include() +#include +#endif + +#define FIREBASE_NATIVE_PPP_IS_AVAILABLE +// ESP32 Core Enum +// PPP_MODEM_GENERIC +// PPP_MODEM_SIM7600 +// PPP_MODEM_SIM7070 +// PPP_MODEM_SIM7000 +// PPP_MODEM_BG96 +// PPP_MODEM_SIM800 +#if defined(CONFIG_ESP_MODEM_ADD_CUSTOM_MODULE) +// PPP_MODEM_CUSTOM +#endif + +#endif +#endif + #if defined(FIREBASE_WIFI_IS_AVAILABLE) #define WIFI_CONNECTED (WiFi.status() == WL_CONNECTED) #else #define WIFI_CONNECTED false #endif +#if defined(FIREBASE_NATIVE_PPP_IS_AVAILABLE) +#define PPP_CONNECTED PPP.connected() +#else +#define PPP_CONNECTED false +#endif + typedef struct firebase_spi_ethernet_module_t { #if defined(ESP8266) && defined(ESP8266_CORE_SDK_V3_X_X)