Skip to content

Commit 434688b

Browse files
authored
Merge branch 'mobizt:main' into fix-typos
2 parents 62ed3cf + 48793db commit 434688b

File tree

12 files changed

+137
-114
lines changed

12 files changed

+137
-114
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ In Library Manager Window, search **"firebase"** in the search form then select
6868

6969
Click **"Install"** button.
7070

71-
For `PlatformIO` IDE, using the following command.
71+
For `PlatformIO` IDE, use the following command.
7272

7373
**pio lib install "FirebaseClient""**
7474

@@ -115,15 +115,15 @@ See this Arduino-Pico SDK [documentation](https://arduino-pico.readthedocs.io/en
115115

116116
For new `Firebase` users, please read the [Project Preparation and Setup](#project-preparation-and-setup) section for preparing the Firebase project.
117117

118-
For new library user that the project was setup and prepared, see the [bare minimun examples](/examples/BareMinimum/) to start using this library with minimum code that requires by this library.
118+
For new library user that the project was setup and prepared, see the [bare minimun examples](/examples/BareMinimum/) to start using this library with minimum code that is required by this library.
119119

120120
For more examples, please click [here](/examples/).
121121

122122
### Working Principle
123123

124-
This library can be used in two modes i.e. async mode and await or sinc mode.
124+
This library can be used in two modes i.e. async mode and await or sync mode.
125125

126-
With async mode, the task will store in the FIFO queue. The result of the running task can be obtained via the callback function or the proxy object that assign when calling the functions.
126+
With async mode, the task will be stored in the FIFO queue. The result of the running task can be obtained via the callback function or the proxy object that assign when calling the functions.
127127

128128
The `AsyncClientClass` is the proxy class that provides the queue for async tasks and also the information of task process when working in await or sync mode.
129129

@@ -712,4 +712,4 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
712712

713713
`THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.`
714714

715-
*Last updated 2025-05-29 UTC.*
715+
*Last updated 2025-08-01 UTC.*

examples/BareMinimum/AllServices/AllServices.ino

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* The beare minimum code example for using all Firebase services.
2+
* The bare minimum code example for using all Firebase services.
33
*
44
* The steps which are generally required are explained below.
55
*
@@ -37,7 +37,7 @@
3737
* ==============================
3838
* It handles server connection and data transfer works.
3939
*
40-
* In this beare minimum example we use only one SSL client for all processes.
40+
* In this bare minimum example we use only one SSL client for all processes.
4141
* In some use cases e.g. Realtime Database Stream connection, you may have to define the SSL client for it separately.
4242
*
4343
* Step 6. Define the Async Client.
@@ -56,14 +56,14 @@
5656
*
5757
* Step 8. Start the authenticate process.
5858
* ========================================
59-
* At this step, the authentication credential will be used to generate the auth tokens for authentication by
59+
* At this step, the authentication credentials will be used to generate the auth tokens for authentication by
6060
* calling initializeApp.
6161
*
6262
* This allows us to use different authentications for each Firebase/Google Cloud services with different
6363
* FirebaseApps (authentication handler)s.
6464
*
6565
* When calling initializeApp with timeout, the authenication process will begin immediately and wait at this process
66-
* until it finished or timed out. It works in sync mode.
66+
* until it is finished or timed out. It works in sync mode.
6767
*
6868
* If no timeout was assigned, it will work in async mode. The authentication task will be added to async client queue
6969
* to process later e.g. in the loop by calling FirebaseApp::loop.
@@ -80,7 +80,7 @@
8080
* ========================================================================================================
8181
* This allows us to use different authentications for each Firebase/Google Cloud services.
8282
*
83-
* It is easy to bind/unbind/change the authentication method for different Firebase/Google Cloud services APIs.
83+
* It is easy to bind, unbind or change the authentication method for different Firebase/Google Cloud services APIs.
8484
*
8585
* Step 10. Set the Realtime Database URL (for Realtime Database only)
8686
* ===================================================================
@@ -94,7 +94,7 @@
9494
* Before calling the Firebase/Google Cloud services functions, the FirebaseApp::ready() of authentication handler that bined to it
9595
* should return true.
9696
*
97-
* Step 13. Process the results of async tasks the end of the loop.
97+
* Step 13. Process the results of async tasks at the end of the loop.
9898
* ============================================================================
9999
* This requires only when async result was assigned to the Firebase/Google Cloud services functions.
100100
*/
@@ -110,6 +110,7 @@
110110
#define ENABLE_CLOUD_STORAGE
111111
#define ENABLE_FUNCTIONS
112112

113+
// For ESP32
113114
#include <WiFi.h>
114115
#include <WiFiClientSecure.h>
115116
#include <FirebaseClient.h>
@@ -191,17 +192,18 @@ void setup()
191192

192193
// The SSL client options depend on the SSL client used.
193194

194-
// Skip certificate verification
195+
// Skip certificate verification (Optional)
195196
ssl_client1.setInsecure();
196197
ssl_client2.setInsecure();
197198

198199
// Set timeout
200+
// Set timeout for ESP32 core sdk v3.x (Optional)
199201
ssl_client1.setConnectionTimeout(1000);
200202
ssl_client1.setHandshakeTimeout(5);
201203
ssl_client2.setConnectionTimeout(1000);
202204
ssl_client2.setHandshakeTimeout(5);
203205

204-
// ESP8266 Set buffer size
206+
// ESP8266 Set buffer size (Optional)
205207
// ssl_client1.setBufferSizes(4096, 1024);
206208
// ssl_client2.setBufferSizes(4096, 1024);
207209

@@ -233,6 +235,19 @@ void loop()
233235
{
234236
onetimeTest = true;
235237

238+
// The following code shows how to call the Firebase functions in both async and await or sync mode
239+
240+
// for demonstation only. You can choose async or await/sync mode or use both modes in the same application.
241+
// For await/sync mode, no callback and AsyncResult object are assigned to the function, the function will
242+
// return the value or payload immediately.
243+
244+
// For async mode, the value or payload will be returned later to the AsyncResult object
245+
// or when the callback was called.
246+
// If AsyncResult was assigned to the function, please don't forget to check it before
247+
// exiting the loop as in step 13.
248+
249+
// For elaborate usage, plese see other examples.
250+
236251
// Realtime Database set value.
237252
// ============================
238253

examples/BareMinimum/README.md

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

33
The minimum code examples when using this library.
44

5-
* [BeareMinimum](/examples/BareMinimum/)
5+
* [BareMinimum](/examples/BareMinimum/)
66
* [RealtimeDatabase](/examples/BareMinimum/RealtimeDatabase/)
7-
* [AllServices](/examples/BareMinimum/AllServices/)
7+
* [AllServices](/examples/BareMinimum/AllServices/)

examples/BareMinimum/RealtimeDatabase/RealtimeDatabase.ino

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/**
2-
* The beare minimum code example for using Realtime Database service.
2+
* The bare minimum code example for using Realtime Database service.
33
*
44
* The steps which are generally required are explained below.
55
*
66
* Step 1. Include the network, SSL client and Firebase libraries.
77
* ===============================================================
88
*
9-
* Step 2. Define the user functions that requred for the library usage.
9+
* Step 2. Define the user functions that are required for library usage.
1010
* =====================================================================
1111
*
1212
* Step 3. Define the authentication config (identifier) class.
@@ -94,7 +94,7 @@
9494
* Before calling the Firebase/Google Cloud services functions, the FirebaseApp::ready() of authentication handler that bined to it
9595
* should return true.
9696
*
97-
* Step 13. Process the results of async tasks the end of the loop.
97+
* Step 13. Process the results of async tasks at the end of the loop.
9898
* ============================================================================
9999
* This requires only when async result was assigned to the Firebase/Google Cloud services functions.
100100
*/
@@ -104,6 +104,7 @@
104104
#define ENABLE_USER_AUTH
105105
#define ENABLE_DATABASE
106106

107+
// For ESP32
107108
#include <WiFi.h>
108109
#include <WiFiClientSecure.h>
109110
#include <FirebaseClient.h>
@@ -155,17 +156,17 @@ void setup()
155156

156157
// The SSL client options depend on the SSL client used.
157158

158-
// Skip certificate verification
159+
// Skip certificate verification (Optional)
159160
ssl_client1.setInsecure();
160161
ssl_client2.setInsecure();
161162

162-
// Set timeout
163+
// Set timeout for ESP32 core sdk v3.x. (Optional)
163164
ssl_client1.setConnectionTimeout(1000);
164165
ssl_client1.setHandshakeTimeout(5);
165166
ssl_client2.setConnectionTimeout(1000);
166167
ssl_client2.setHandshakeTimeout(5);
167168

168-
// ESP8266 Set buffer size
169+
// ESP8266 Set buffer size (Optional)
169170
// ssl_client1.setBufferSizes(4096, 1024);
170171
// ssl_client2.setBufferSizes(4096, 1024);
171172

@@ -189,6 +190,19 @@ void loop()
189190
{
190191
onetimeTest = true;
191192

193+
// The following codes showed how to call the Firebase functions in both async and await modes
194+
195+
// for demonstation only. You can choose async or await mode or use both modes in the same application.
196+
// For await mode, no callback and AsyncResult object are assigned to the function, the function will
197+
// return the value or payload immediately.
198+
199+
// For async mode, the value or payload will be returned later to the AsyncResult object
200+
// or when the callback was called.
201+
// If AsyncResult was assigned to the function, please don't forget to check it before
202+
// exiting the loop as in step 13.
203+
204+
// For elaborate usage, plese see other examples.
205+
192206
// Realtime Database set value.
193207
// ============================
194208

@@ -198,13 +212,6 @@ void loop()
198212
// Async call with AsyncResult for returning result.
199213
Database.set<bool>(async_client1, "/examples/BareMinimum/data/set2", true, dbResult);
200214

201-
// Sync call which waits until the result was received.
202-
bool status = Database.set<double>(async_client2, "/examples/BareMinimum/data/set3", 199.538639);
203-
if (status)
204-
Serial.println("Value set complete.");
205-
else
206-
Firebase.printf("Error, msg: %s, code: %d\n", async_client2.lastError().message().c_str(), async_client2.lastError().code());
207-
208215
// Realtime Database get value.
209216
// ============================
210217

@@ -214,6 +221,7 @@ void loop()
214221
// Async call with AsyncResult for returning result.
215222
Database.get(async_client1, "/examples/BareMinimum/data/set2", dbResult, false);
216223

224+
// Await call which waits until the result was received.
217225
String value = Database.get<String>(async_client2, "/examples/BareMinimum/data/set3");
218226
if (async_client2.lastError().code() == 0)
219227
{
@@ -245,4 +253,4 @@ void processData(AsyncResult &aResult)
245253

246254
if (aResult.available())
247255
Firebase.printf("task: %s, payload: %s\n", aResult.uid().c_str(), aResult.c_str());
248-
}
256+
}

examples/RealtimeDatabase/Stream/Stream.ino

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -135,22 +135,22 @@ void processData(AsyncResult &aResult)
135135

136136
if (aResult.available())
137137
{
138-
RealtimeDatabaseResult &RTDB = aResult.to<RealtimeDatabaseResult>();
139-
if (RTDB.isStream())
138+
RealtimeDatabaseResult &stream = aResult.to<RealtimeDatabaseResult>();
139+
if (stream.isStream())
140140
{
141141
Serial.println("----------------------------");
142142
Firebase.printf("task: %s\n", aResult.uid().c_str());
143-
Firebase.printf("event: %s\n", RTDB.event().c_str());
144-
Firebase.printf("path: %s\n", RTDB.dataPath().c_str());
145-
Firebase.printf("data: %s\n", RTDB.to<const char *>());
146-
Firebase.printf("type: %d\n", RTDB.type());
143+
Firebase.printf("event: %s\n", stream.event().c_str());
144+
Firebase.printf("path: %s\n", stream.dataPath().c_str());
145+
Firebase.printf("data: %s\n", stream.to<const char *>());
146+
Firebase.printf("type: %d\n", stream.type());
147147

148148
// The stream event from RealtimeDatabaseResult can be converted to the values as following.
149-
bool v1 = RTDB.to<bool>();
150-
int v2 = RTDB.to<int>();
151-
float v3 = RTDB.to<float>();
152-
double v4 = RTDB.to<double>();
153-
String v5 = RTDB.to<String>();
149+
bool v1 = stream.to<bool>();
150+
int v2 = stream.to<int>();
151+
float v3 = stream.to<float>();
152+
double v4 = stream.to<double>();
153+
String v5 = stream.to<String>();
154154
}
155155
else
156156
{

examples/RealtimeDatabase/StreamConcurentcy/StreamConcurentcy.ino

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -177,22 +177,22 @@ void processData(AsyncResult &aResult)
177177

178178
if (aResult.available())
179179
{
180-
RealtimeDatabaseResult &RTDB = aResult.to<RealtimeDatabaseResult>();
181-
if (RTDB.isStream())
180+
RealtimeDatabaseResult &stream = aResult.to<RealtimeDatabaseResult>();
181+
if (stream.isStream())
182182
{
183183
Serial.println("----------------------------");
184184
Firebase.printf("task: %s\n", aResult.uid().c_str());
185-
Firebase.printf("event: %s\n", RTDB.event().c_str());
186-
Firebase.printf("path: %s\n", RTDB.dataPath().c_str());
187-
Firebase.printf("data: %s\n", RTDB.to<const char *>());
188-
Firebase.printf("type: %d\n", RTDB.type());
185+
Firebase.printf("event: %s\n", stream.event().c_str());
186+
Firebase.printf("path: %s\n", stream.dataPath().c_str());
187+
Firebase.printf("data: %s\n", stream.to<const char *>());
188+
Firebase.printf("type: %d\n", stream.type());
189189

190190
// The stream event from RealtimeDatabaseResult can be converted to the values as following.
191-
bool v1 = RTDB.to<bool>();
192-
int v2 = RTDB.to<int>();
193-
float v3 = RTDB.to<float>();
194-
double v4 = RTDB.to<double>();
195-
String v5 = RTDB.to<String>();
191+
bool v1 = stream.to<bool>();
192+
int v2 = stream.to<int>();
193+
float v3 = stream.to<float>();
194+
double v4 = stream.to<double>();
195+
String v5 = stream.to<String>();
196196
}
197197
else
198198
{

examples/RealtimeDatabase/StreamEthernet/ESP32ETH/ESP32ETH.ino

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -285,22 +285,22 @@ void processData(AsyncResult &aResult)
285285

286286
if (aResult.available())
287287
{
288-
RealtimeDatabaseResult &RTDB = aResult.to<RealtimeDatabaseResult>();
289-
if (RTDB.isStream())
288+
RealtimeDatabaseResult &stream = aResult.to<RealtimeDatabaseResult>();
289+
if (stream.isStream())
290290
{
291291
Serial.println("----------------------------");
292292
Firebase.printf("task: %s\n", aResult.uid().c_str());
293-
Firebase.printf("event: %s\n", RTDB.event().c_str());
294-
Firebase.printf("path: %s\n", RTDB.dataPath().c_str());
295-
Firebase.printf("data: %s\n", RTDB.to<const char *>());
296-
Firebase.printf("type: %d\n", RTDB.type());
293+
Firebase.printf("event: %s\n", stream.event().c_str());
294+
Firebase.printf("path: %s\n", stream.dataPath().c_str());
295+
Firebase.printf("data: %s\n", stream.to<const char *>());
296+
Firebase.printf("type: %d\n", stream.type());
297297

298298
// The stream event from RealtimeDatabaseResult can be converted to the values as following.
299-
bool v1 = RTDB.to<bool>();
300-
int v2 = RTDB.to<int>();
301-
float v3 = RTDB.to<float>();
302-
double v4 = RTDB.to<double>();
303-
String v5 = RTDB.to<String>();
299+
bool v1 = stream.to<bool>();
300+
int v2 = stream.to<int>();
301+
float v3 = stream.to<float>();
302+
double v4 = stream.to<double>();
303+
String v5 = stream.to<String>();
304304
}
305305
else
306306
{

examples/RealtimeDatabase/StreamEthernet/ESP32Ethernet/ESP32Ethernet.ino

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -176,22 +176,22 @@ void processData(AsyncResult &aResult)
176176

177177
if (aResult.available())
178178
{
179-
RealtimeDatabaseResult &RTDB = aResult.to<RealtimeDatabaseResult>();
180-
if (RTDB.isStream())
179+
RealtimeDatabaseResult &stream = aResult.to<RealtimeDatabaseResult>();
180+
if (stream.isStream())
181181
{
182182
Serial.println("----------------------------");
183183
Firebase.printf("task: %s\n", aResult.uid().c_str());
184-
Firebase.printf("event: %s\n", RTDB.event().c_str());
185-
Firebase.printf("path: %s\n", RTDB.dataPath().c_str());
186-
Firebase.printf("data: %s\n", RTDB.to<const char *>());
187-
Firebase.printf("type: %d\n", RTDB.type());
184+
Firebase.printf("event: %s\n", stream.event().c_str());
185+
Firebase.printf("path: %s\n", stream.dataPath().c_str());
186+
Firebase.printf("data: %s\n", stream.to<const char *>());
187+
Firebase.printf("type: %d\n", stream.type());
188188

189189
// The stream event from RealtimeDatabaseResult can be converted to the values as following.
190-
bool v1 = RTDB.to<bool>();
191-
int v2 = RTDB.to<int>();
192-
float v3 = RTDB.to<float>();
193-
double v4 = RTDB.to<double>();
194-
String v5 = RTDB.to<String>();
190+
bool v1 = stream.to<bool>();
191+
int v2 = stream.to<int>();
192+
float v3 = stream.to<float>();
193+
double v4 = stream.to<double>();
194+
String v5 = stream.to<String>();
195195
}
196196
else
197197
{

0 commit comments

Comments
 (0)