Skip to content

Commit 0257df3

Browse files
committed
Add support user config in the sketch and remove FirebaseConfig.h
1 parent 0a0ed24 commit 0257df3

173 files changed

Lines changed: 1026 additions & 638 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 12 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
![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)
44

5-
![GitHub Release](https://img.shields.io/github/v/release/mobizt/FirebaseClient) ![Arduino](https://img.shields.io/badge/Arduino-v2.0.3-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)
5+
![GitHub Release](https://img.shields.io/github/v/release/mobizt/FirebaseClient) ![Arduino](https://img.shields.io/badge/Arduino-v2.0.4-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)
66

7-
Revision `2025-04-07`
7+
Revision `2025-05-20`
88

99
## Introduction
1010

@@ -179,7 +179,7 @@ In version 2.x.x and later, when assign the timeout (> 0) to the `initializeApp`
179179

180180
The callback function assigned with `initializeApp` function will provide the auth process event, debug and error information while authenticating in async and sync modes.
181181

182-
In version 2.x.x, the `FirebaseApp` class can also maintain the async tasks that shored in other `AsyncClientClass`s.
182+
In version 2.x.x, the `FirebaseApp` class can also maintain the async tasks that stored in other `AsyncClientClass`s.
183183

184184
The details for all classes used in this library are available. Click the following links for details.
185185

@@ -693,7 +693,7 @@ Some options can be disabled.
693693

694694
- ### Predefined Options
695695

696-
The predefined options that are already set in [**FirebaseConfig.h**](src/FirebaseConfig.h) are following.
696+
The predefined options are defined as the following.
697697

698698
```cpp
699699
ENABLE_DATABASE // For RTDB compilation
@@ -722,9 +722,16 @@ ENABLE_ETHERNET_NETWORK
722722
ENABLE_GSM_NETWORK
723723
```
724724

725+
In version 2.0.4 and newer, the config file `FirebaseCongig.h` and `UserConfig.h` are obsoleted and will not be used in this library.
726+
727+
Then in the version 2.0.4 and newer, to save program space by compiling only the options you used, define the following macro and followed by the options that you want to use before including the library header file `FirebaseClient.h`.
728+
729+
```cpp
730+
ENABLE_USER_CONFIG
731+
```
725732
- ### Optional Options
726733

727-
The following options are not yet defined in [**FirebaseConfig.h**](src/FirebaseConfig.h) and can be defined by user.
734+
The following options are not yet pre-defined and can be defined by user (in your sketch with `ENABLE_USER_CONFIG`).
728735

729736
```cpp
730737
FIREBASE_ETHERNET_MODULE_LIB `"EthernetLibrary.h"` // For the Ethernet library to work with external Ethernet module.
@@ -742,61 +749,6 @@ FIREBASE_PRINTF_PORT // For Firebase.printf debug port class object.
742749
FIREBASE_PRINTF_BUFFER // Firebase.printf buffer size. The default printf buffer size is 1024 for ESP8266 and SAMD otherwise 4096. Some debug message may be truncated for larger text.
743750
```
744751

745-
You can assign the optional build options using one of the following methods.
746-
747-
- By creating user config file `UserConfig.h` in library installed folder and define these optional options.
748-
749-
- By adding compiler build flags with `-D name`.
750-
751-
- By defined the macros before including the library main header file `FirebaseClient.h`.
752-
753-
In PlatformIO IDE, using `build_flags` in PlatformIO IDE's platformio.ini is more convenient
754-
755-
```ini
756-
build_flags = -D DISABLE_STORAGE
757-
-D FIREBASE_DISABLE_ONBOARD_WIFI
758-
```
759-
760-
For external Ethernet module integation used with function `setEthernetClient`, both `FIREBASE_ETHERNET_MODULE_LIB` and `FIREBASE_ETHERNET_MODULE_CLASS` should be defined.
761-
762-
`FIREBASE_ETHERNET_MODULE_LIB` is the Ethernet library name with extension (.h) and should be inside `""` or `<>` e.g. `"Ethernet.h"`.
763-
764-
`FIREBASE_ETHERNET_MODULE_CLASS` is the name of static object defined from class e.g. `Ethernet`.
765-
766-
`FIREBASE_ETHERNET_MODULE_TIMEOUT` is the timeout in milliseconds to wait for network connection.
767-
768-
For disabling predefined options instead of editing the [**FirebaseConfig.h**](src/FirebaseConfig.h) or using `#undef` in `UserConfig.h`, you can define these build flags with these names or macros in `UserConfig.h`.
769-
770-
```cpp
771-
DISABLE_DATABASE // For disabling RTDB support
772-
DISABLE_FIRESTORE // For disabling Firestore support
773-
DISABLE_FIRESTORE_QUERY // For Firestore Query feature compilation
774-
DISABLE_MESSAGING // For disabling Firebase Cloud Messaging support
775-
DISABLE_STORAGE // For disabling Firebase Storage support
776-
DISABLE_CLOUD_STORAGE // For disabling Google Cloud Storage support
777-
DISABLE_FUNCTIONS // For disabling Google Cloud Functions support
778-
DISABLE_RULESETS // For disabling RuleSets support
779-
DISABLE_PSRAM // For disabling PSRAM support
780-
DISABLE_OTA // For disabling OTA updates support
781-
DISABLE_FS // For disabling filesystem support
782-
783-
// For disabling authentication and token
784-
DISABLE_SERVICE_AUTH
785-
DISABLE_CUSTOM_AUTH
786-
DISABLE_USER_AUTH
787-
DISABLE_ACCESS_TOKEN
788-
DISABLE_CUSTOM_TOKEN
789-
DISABLE_ID_TOKEN
790-
DISABLE_LEGACY_TOKEN
791-
792-
FIREBASE_DISABLE_ALL_OPTIONS // For disabling all predefined build options above
793-
```
794-
795-
> [!NOTE]
796-
> `UserConfig.h` for user config should be placed in the library installed folder inside the `src` folder.
797-
798-
This `UserConfig.h` will not change or overwrite when update the library.
799-
800752
The library code size is varied from 80k - 110k (WiFi and WiFiClientSecure excluded) depends on the build options.
801753

802754
The code size is 170k lesser than ancestor Firebase libraries when perform the same task.

examples/App/AppInitialization/CustomAuth/CustomAuth.ino

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,12 @@
7777
* function immediately.
7878
*/
7979

80-
#include <Arduino.h>
80+
81+
// To define build options in your sketch,
82+
// adding the following macros before FirebaseClient.h
83+
#define ENABLE_USER_CONFIG
84+
#define ENABLE_CUSTOM_AUTH
85+
8186
#include <FirebaseClient.h>
8287
#include "ExampleFunctions.h" // Provides the functions used in the examples.
8388

examples/App/AppInitialization/CustomAuthFile/CustomAuthFile.ino

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,12 @@
7878
* function immediately.
7979
*/
8080

81-
#include <Arduino.h>
81+
// To define build options in your sketch,
82+
// adding the following macros before FirebaseClient.h
83+
#define ENABLE_USER_CONFIG
84+
#define ENABLE_CUSTOM_AUTH
85+
#define ENABLE_FS
86+
8287
#include <FirebaseClient.h>
8388
#include "ExampleFunctions.h" // Provides the functions used in the examples.
8489

examples/App/AppInitialization/NoAuth/NoAuth.ino

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@
5050
*
5151
*/
5252

53-
#include <Arduino.h>
53+
// To define build options in your sketch,
54+
// adding the following macros before FirebaseClient.h
55+
#define ENABLE_USER_CONFIG
56+
5457
#include <FirebaseClient.h>
5558
#include "ExampleFunctions.h" // Provides the functions used in the examples.
5659

examples/App/AppInitialization/ReAuthenticate/ReAuthenticate.ino

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@
2020
* The complete usage guidelines, please visit https://github.com/mobizt/FirebaseClient
2121
*/
2222

23-
#include <Arduino.h>
23+
// To define build options in your sketch,
24+
// adding the following macros before FirebaseClient.h
25+
#define ENABLE_USER_CONFIG
26+
#define ENABLE_USER_AUTH
27+
2428
#include <FirebaseClient.h>
2529
#include "ExampleFunctions.h" // Provides the functions used in the examples.
2630

examples/App/AppInitialization/SaveAndLoad/SaveAndLoad.ino

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@
66
* The complete usage guidelines, please read README.md or visit https://github.com/mobizt/FirebaseClient
77
*/
88

9-
#include <Arduino.h>
9+
// To define build options in your sketch,
10+
// adding the following macros before FirebaseClient.h
11+
#define ENABLE_USER_CONFIG
12+
#define ENABLE_USER_AUTH
13+
#define ENABLE_FS
14+
1015
#include <FirebaseClient.h>
1116
#include "ExampleFunctions.h" // Provides the functions used in the examples.
1217

examples/App/AppInitialization/ServiceAuth/ServiceAuth.ino

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,10 @@
6969
* function immediately.
7070
*/
7171

72-
#include <Arduino.h>
72+
// To define build options in your sketch
73+
#define ENABLE_USER_CONFIG
74+
#define ENABLE_SERVICE_AUTH
75+
7376
#include <FirebaseClient.h>
7477
#include "ExampleFunctions.h" // Provides the functions used in the examples.
7578

examples/App/AppInitialization/ServiceAuthFile/ServiceAuthFile.ino

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,12 @@
6767
* function immediately.
6868
*/
6969

70-
#include <Arduino.h>
70+
// To define build options in your sketch,
71+
// adding the following macros before FirebaseClient.h
72+
#define ENABLE_USER_CONFIG
73+
#define ENABLE_SERVICE_AUTH
74+
#define ENABLE_FS
75+
7176
#include <FirebaseClient.h>
7277
#include "ExampleFunctions.h" // Provides the functions used in the examples.
7378

examples/App/AppInitialization/TokenAuth/AccessToken/AccessToken.ino

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,12 @@
5757
* By providing AsyncResultCallback in the initializeApp function, the debug information will be collected and send to AsyncResultCallback
5858
* function immediately.
5959
*/
60-
#include <Arduino.h>
60+
61+
// To define build options in your sketch,
62+
// adding the following macros before FirebaseClient.h
63+
#define ENABLE_USER_CONFIG
64+
#define ENABLE_ACCESS_TOKEN
65+
6166
#include <FirebaseClient.h>
6267
#include "ExampleFunctions.h" // Provides the functions used in the examples.
6368

examples/App/AppInitialization/TokenAuth/CustomToken/CustomToken.ino

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,11 @@
5656
* function immediately.
5757
*/
5858

59-
#include <Arduino.h>
59+
// To define build options in your sketch,
60+
// adding the following macros before FirebaseClient.h
61+
#define ENABLE_USER_CONFIG
62+
#define ENABLE_CUSTOM_TOKEN
63+
6064
#include <FirebaseClient.h>
6165
#include "ExampleFunctions.h" // Provides the functions used in the examples.
6266

0 commit comments

Comments
 (0)