Skip to content

Commit

Permalink
Fix native Ethernet and Ethernet integration issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
mobizt committed Sep 15, 2023
1 parent 7954275 commit 28241b1
Show file tree
Hide file tree
Showing 43 changed files with 82 additions and 86 deletions.
33 changes: 12 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
![arduino-library-badge](https://www.ardu-badge.com/badge/Firebase%20Arduino%20Client%20Library%20for%20ESP8266%20and%20ESP32.svg) ![PlatformIO](https://badges.registry.platformio.org/packages/mobizt/library/Firebase%20Arduino%20Client%20Library%20for%20ESP8266%20and%20ESP32.svg)


The managed, complete, fast and secure Firebase Client Library that supports most Arduino devices except for AVR. The following are platforms in which the libraries are also available (RTDB only).
This library provides Firebase Realtime database, Firebase Cloud Messaging, Cloud Firestore database, Firebase Storage, Google Cloud Storage and Cloud Functions for Firebase functions and supports most Arduino devices except for AVR devices that have resources and compiler limit.

This library can work with on-chip/on-board network (WiFi/Ethernet) and External network module via Client library.

* [Arduino MKR WiFi 1010, Arduino MKR VIDOR 4000 and Arduino UNO WiFi Rev.2](https://github.com/mobizt/Firebase-Arduino-WiFiNINA)

* [Arduino WiFi Shield 101 and Arduino MKR1000 WIFI](https://github.com/mobizt/Firebase-Arduino-WiFi101)
The features can be configurable to add and exclude some unused features, see [Library Build Options](#library-build-options).

The [ESP8266 and Raspberry Pi Pico](https://github.com/mobizt/Firebase-ESP8266) and [ESP32](https://github.com/mobizt/Firebase-ESP32) versions are available which provide only Firebase Realtime database and Firebase Cloud Messaging functions.


## Contents
Expand Down Expand Up @@ -115,31 +115,20 @@ The managed, complete, fast and secure Firebase Client Library that supports mos

## Features

* Supports most Arduino devices (except for AVR)
* Supports most Arduino devices (except for AVR) with or without external neywork module.

* Supports most Firebase Services included Google Cloud Storage.

* Supports external Heap via SRAM/PSRAM in ESP8266 and ESP32.
* Supports external Heap using SRAM/PSRAM in ESP8266 and ESP32.

* TinyGSMClient and Ethernet Client integration.

* Faster server reconnection with SSL Session Resumption.

* Supports external network module.

* Supports Firebase Realtime database.

* Supports Cloud Firestore database.

* Supports Firebase Storage.

* Supports Google Cloud Storage.

* Supports Firebase Cloud Messaging.

* Supports Test Mode (No Auth).
* Supports Authentications and Test Mode (No Auth for some services).

* Supports Firmware OTA updates via RTDB, Firebase Storage and Google Cloud Storage.
* Supports Firmware OTA updates.

* Supports Cloud Functions for Firebase.

## Supported Devices.

Expand Down Expand Up @@ -632,6 +621,7 @@ The following options are not yet defined in [**FirebaseFS.h**](src/FirebaseFS.h
```cpp
FIREBASE_ETHERNET_MODULE_LIB `"EthernetLibrary.h"` // For the Ethernet library to work with external Ethernet module
FIREBASE_ETHERNET_MODULE_CLASS EthernetClass // For the Ethernet class object of Ethernet library to work with external Ethernet module
FIREBASE_ETHERNET_MODULE_TIMEOUT 2000 // For the time out in milliseconds to wait external Ethernet module to connect to network
ENABLE_ESP8266_ENC28J60_ETH // For native core library ENC28J60 Ethernet module support in ESP8266
ENABLE_ESP8266_W5500_ETH // For native core library W5500 Ethernet module support in ESP8266
ENABLE_ESP8266_W5100_ETH // For native core library W5100 Ethernet module support in ESP8266
Expand Down Expand Up @@ -659,6 +649,7 @@ For external Ethernet module integation used with function `setEthernetClient`,

`FIREBASE_ETHERNET_MODULE_CLASS` is the name of static object defined from class e.g. `Ethernet`.

`FIREBASE_ETHERNET_MODULE_TIMEOUT` is the time out in milliseconds to wait network connection.

For disabling predefined options instead of editing the [**FirebaseFS.h**](src/FirebaseFS.h) or using `#undef` in `CustomFirebaseFS.h`, you can define these build flags with these names or macros in `CustomFirebaseFS.h`.

Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Firebase Arduino Client Library for ESP8266 and ESP32",
"version": "4.4.7",
"version": "4.4.8",
"keywords": "communication, REST, esp32, esp8266, arduino",
"description": "The library supports Firebase products e.g. Realtime database, Cloud Firestore database, Firebase Storage and Google Cloud Storage, Cloud Functions for Firebase and Cloud Messaging. The library also supported other Arduino devices using Clients interfaces e.g. WiFiClient, EthernetClient, and GSMClient.",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name=Firebase Arduino Client Library for ESP8266 and ESP32

version=4.4.7
version=4.4.8

author=Mobizt

Expand Down
2 changes: 1 addition & 1 deletion src/FB_Const.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40407)
#if !FIREBASE_CLIENT_VERSION_CHECK(40408)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/FB_Error.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40407)
#if !FIREBASE_CLIENT_VERSION_CHECK(40408)
#error "Mixed versions compilation."
#endif

Expand Down
38 changes: 18 additions & 20 deletions src/FB_Network.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40407)
#if !FIREBASE_CLIENT_VERSION_CHECK(40408)
#error "Mixed versions compilation."
#endif

/**
* Created September 5, 2023
* Created September 14, 2023
*/
#ifndef FIREBASE_NETWORK_H
#define FIREBASE_NETWORK_H
Expand Down Expand Up @@ -71,20 +71,23 @@

#endif

#if defined(INC_ENC28J60_LWIP) && defined(INC_W5100_LWIP) && defined(INC_W5500_LWIP)
#if defined(INC_ENC28J60_LWIP) || defined(INC_W5100_LWIP) || defined(INC_W5500_LWIP)
#define FIREBASE_ETH_IS_AVAILABLE
#endif

#endif

#endif


#if __has_include(<Ethernet.h>) || (defined(FIREBASE_ETHERNET_MODULE_LIB) && defined(FIREBASE_ETHERNET_MODULE_CLASS))

#if defined(ESP8266)
#undef MAX_SOCK_NUM
#endif

#if (defined(ESP8266) && defined(FIREBASE_DISABLE_NATIVE_ETHERNET)) || (!defined(ESP8266) && !defined(ARDUINO_NANO_RP2040_CONNECT))

#if defined(FIREBASE_DISABLE_NATIVE_ETHERNET)

#if defined(FIREBASE_ETHERNET_MODULE_LIB) && defined(FIREBASE_ETHERNET_MODULE_CLASS)
#if __has_include(FIREBASE_ETHERNET_MODULE_LIB)
Expand All @@ -100,33 +103,28 @@
#endif

#if defined(ETH_MODULE_CLASS)

#define FIREBASE_ETHERNET_MODULE_IS_AVAILABLE
#endif

#if !defined(FIREBASE_ETHERNET_MODULE_TIMEOUT)
#define FIREBASE_ETHERNET_MODULE_TIMEOUT 2000
#elif FIREBASE_ETHERNET_MODULE_TIMEOUT <= 0 || FIREBASE_ETHERNET_MODULE_TIMEOUT > 120 * 1000
#undef FIREBASE_ETHERNET_MODULE_TIMEOUT
#define FIREBASE_ETHERNET_MODULE_TIMEOUT 2000
#endif

#undef MAX_SOCK_NUM
#elif !defined(ARDUINO_NANO_RP2040_CONNECT)

#if defined(FIREBASE_ETHERNET_MODULE_LIB) && defined(FIREBASE_ETHERNET_MODULE_CLASS)
#if __has_include(FIREBASE_ETHERNET_MODULE_LIB)
#include FIREBASE_ETHERNET_MODULE_LIB
#define ETH_MODULE_CLASS FIREBASE_ETHERNET_MODULE_CLASS
#elif __has_include(<Ethernet.h>)
#include <Ethernet.h>
#define ETH_MODULE_CLASS Ethernet
#endif
#else
#include <Ethernet.h>
#define ETH_MODULE_CLASS Ethernet
#endif

#if defined(ETH_MODULE_CLASS)
#define FIREBASE_ETHERNET_MODULE_IS_AVAILABLE

#endif


#if defined(ESP8266)
#undef MAX_SOCK_NUM
#endif


#endif

#if defined(ESP32) || defined(ESP8266) || defined(ARDUINO_RASPBERRY_PI_PICO_W) || \
Expand Down
2 changes: 1 addition & 1 deletion src/FB_Utils.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40407)
#if !FIREBASE_CLIENT_VERSION_CHECK(40408)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/Firebase.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40407)
#if !FIREBASE_CLIENT_VERSION_CHECK(40408)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/Firebase.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40407)
#if !FIREBASE_CLIENT_VERSION_CHECK(40408)
#error "Mixed versions compilation."
#endif

Expand Down
4 changes: 3 additions & 1 deletion src/FirebaseFS.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40407)
#if !FIREBASE_CLIENT_VERSION_CHECK(40408)
#error "Mixed versions compilation."
#endif

Expand Down Expand Up @@ -180,9 +180,11 @@
* - FIREBASE_ETHERNET_MODULE_LIB is the Ethernet library name with extension (.h) and
* should be inside "" or <> e.g. "Ethernet.h".
* - FIREBASE_ETHERNET_MODULE_CLASS is the name of static object defined from class e.g. Ethernet.
* - FIREBASE_ETHERNET_MODULE_TIMEOUT is the time out in milliseconds to wait network connection.
*
* #define FIREBASE_ETHERNET_MODULE_LIB "EthernetLib.h"
* #define FIREBASE_ETHERNET_MODULE_CLASS EthernetClass
* #define FIREBASE_ETHERNET_MODULE_TIMEOUT 2000
*
* 🏷️ For native core library ENC28J60 Ethernet module support in ESP8266
* #define ENABLE_ESP8266_ENC28J60_ETH
Expand Down
13 changes: 9 additions & 4 deletions src/client/FB_TCP_Client.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Firebase TCP Client v1.0.1
* Firebase TCP Client v1.0.2
*
* Created September 11, 2023
* Created September 14, 2023
*
* The MIT License (MIT)
* Copyright (c) 2022 K. Suwatchai (Mobizt)
Expand Down Expand Up @@ -1055,7 +1055,7 @@ class Firebase_TCP_Client : public Client

unsigned long to = millis();

while (ETH_MODULE_CLASS.linkStatus() == LinkOFF && millis() - to < 2000)
while (ETH_MODULE_CLASS.linkStatus() == LinkOFF && millis() - to < FIREBASE_ETHERNET_MODULE_TIMEOUT)
{
delay(100);
}
Expand All @@ -1082,7 +1082,12 @@ class Firebase_TCP_Client : public Client
bool ethernetConnected()
{
#if defined(FIREBASE_ETHERNET_MODULE_IS_AVAILABLE)
_network_status = ETH_MODULE_CLASS.linkStatus() == LinkON;
_network_status = ETH_MODULE_CLASS.linkStatus() == LinkON && validIP(ETH_MODULE_CLASS.localIP());
if (!_network_status)
{
delay(FIREBASE_ETHERNET_MODULE_TIMEOUT);
_network_status = ETH_MODULE_CLASS.linkStatus() == LinkON && validIP(ETH_MODULE_CLASS.localIP());
}
#endif
return _network_status;
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/FirebaseCore.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40407)
#if !FIREBASE_CLIENT_VERSION_CHECK(40408)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/core/FirebaseCore.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40407)
#if !FIREBASE_CLIENT_VERSION_CHECK(40408)
#error "Mixed versions compilation."
#endif

Expand Down
4 changes: 2 additions & 2 deletions src/core/Firebase_Client_Version.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef FIREBASE_CLIENT_VERSION
#define FIREBASE_CLIENT_VERSION "4.4.7"
#define FIREBASE_CLIENT_VERSION_NUM 40407
#define FIREBASE_CLIENT_VERSION "4.4.8"
#define FIREBASE_CLIENT_VERSION_NUM 40408

/* The inconsistent file version checking to prevent mixed versions compilation. */
#define FIREBASE_CLIENT_VERSION_CHECK(ver) (ver == FIREBASE_CLIENT_VERSION_NUM)
Expand Down
2 changes: 1 addition & 1 deletion src/firestore/FB_Firestore.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40407)
#if !FIREBASE_CLIENT_VERSION_CHECK(40408)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/firestore/FB_Firestore.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40407)
#if !FIREBASE_CLIENT_VERSION_CHECK(40408)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/functions/FB_Functions.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40407)
#if !FIREBASE_CLIENT_VERSION_CHECK(40408)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/functions/FB_Functions.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40407)
#if !FIREBASE_CLIENT_VERSION_CHECK(40408)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/functions/FunctionsConfig.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40407)
#if !FIREBASE_CLIENT_VERSION_CHECK(40408)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/functions/FunctionsConfig.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40407)
#if !FIREBASE_CLIENT_VERSION_CHECK(40408)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/functions/PocicyBuilder.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40407)
#if !FIREBASE_CLIENT_VERSION_CHECK(40408)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/functions/PolicyBuilder.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40407)
#if !FIREBASE_CLIENT_VERSION_CHECK(40408)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/gcs/GCS.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40407)
#if !FIREBASE_CLIENT_VERSION_CHECK(40408)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/gcs/GCS.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40407)
#if !FIREBASE_CLIENT_VERSION_CHECK(40408)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/message/FCM.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40407)
#if !FIREBASE_CLIENT_VERSION_CHECK(40408)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/message/FCM.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40407)
#if !FIREBASE_CLIENT_VERSION_CHECK(40408)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/message/LFCM.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40407)
#if !FIREBASE_CLIENT_VERSION_CHECK(40408)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/rtdb/FB_RTDB.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40407)
#if !FIREBASE_CLIENT_VERSION_CHECK(40408)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/rtdb/FB_RTDB.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40407)
#if !FIREBASE_CLIENT_VERSION_CHECK(40408)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/rtdb/QueryFilter.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40407)
#if !FIREBASE_CLIENT_VERSION_CHECK(40408)
#error "Mixed versions compilation."
#endif

Expand Down
Loading

0 comments on commit 28241b1

Please sign in to comment.