Skip to content

Commit 573c0ea

Browse files
committed
Update examples and documentation
1 parent b5ae3fc commit 573c0ea

File tree

12 files changed

+470
-10
lines changed

12 files changed

+470
-10
lines changed

README.md

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

77
[![GitHub Sponsors](https://img.shields.io/github/sponsors/mobizt?logo=github)](https://github.com/sponsors/mobizt)
88

9-
Revision `2025-01-23T06:30:53Z`
9+
Revision `2025-01-24T09:51:37Z`
1010

1111
## Table of Contents
1212

@@ -984,13 +984,22 @@ The [CustomAuth](/examples/App/AppInitialization/Async/Callback/CustomAuth/) cla
984984
CustomAuth::CustomAuth(<TimeStatusCallback>, <api_key>, <client_email>, <project_id>, <private_key>, <user_id>, <scope>, <claims>, <expire>)
985985
```
986986

987-
988987
```cpp
989988
CustomAuth::CustomAuth(<TimeStatusCallback>, <file_config_data>, <api_key>, <user_id>, <scope>, <claims>, <expire>)
990989
```
991990
991+
```cpp
992+
CustomAuth::CustomAuth(<timestamp>, <api_key>, <client_email>, <project_id>, <private_key>, <user_id>, <scope>, <claims>, <expire>)
993+
```
994+
995+
```cpp
996+
CustomAuth::CustomAuth(<timestamp>, <file_config_data>, <api_key>, <user_id>, <scope>, <claims>, <expire>)
997+
```
998+
992999
`<TimeStatusCallback>` The time status callback that provides the UNIX timestamp used to set the issue time and expiration time in the JWT token payload.
9931000
1001+
`<timestamp>` The current UNiX timestamp (seonds since Jan 1, 1970 midnight).
1002+
9941003
`<file_config_data>` The filesystem data (`file_config_data`) obtained from `FileConfig` class object of service account key file.
9951004
9961005
`<api_key>` The web API key of the project.
@@ -1029,8 +1038,18 @@ ServiceAuth::ServiceAuth(<TimeStatusCallback>, <client_email>, <project_id>, <pr
10291038
ServiceAuth::ServiceAuth(<TimeStatusCallback>, <file_config_data>, <expire>)
10301039
```
10311040
1041+
```cpp
1042+
ServiceAuth::ServiceAuth(<timestamp>, <client_email>, <project_id>, <private_key>, <expire>)
1043+
```
1044+
1045+
```cpp
1046+
ServiceAuth::ServiceAuth(<timestamp>, <file_config_data>, <expire>)
1047+
```
1048+
10321049
`<TimeStatusCallback>` The time status callback that provides the UNIX timestamp used to set the issue time and expiration time in the JWT token payload.
10331050
1051+
`<timestamp>` The current UNiX timestamp (seonds since Jan 1, 1970 midnight).
1052+
10341053
`<file_config_data>` The filesystem data (`file_config_data`) obtained from `FileConfig` class object of service account key file.
10351054
10361055
`<client_email>` The service account client Email.

examples/App/AppInitialization/Async/Callback/CustomAuth/CustomAuth.ino

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,20 @@
3636
* <scope> - The OAuth scopes.
3737
* <claims> - The OAuth claims.
3838
* <expire> - The expiry period in seconds (less than 3600), 3300 is the default value.
39+
*
40+
* 3.------------------------
41+
*
42+
* CustomAuth::CustomAuth(<timestamp>, <api_key>, <client_email>, <project_id>, <private_key>, <user_id>, <scope>, <claims>, <expire>);
43+
*
44+
* <timestamp> - The current UNiX timestamp (seonds since Jan 1, 1970 midnight).
45+
* <api_key> - The web API key of project.
46+
* <client_email> - The service account client Email.
47+
* <project_id> - The service account project ID.
48+
* <private_key> - The service account private key.
49+
* <user_id> - The user ID.
50+
* <scope> - The OAuth scopes.
51+
* <claims> - The OAuth claims.
52+
* <expire> - The expiry period in seconds (less than 3600), 3300 is the default value.
3953
*
4054
* NOTE:
4155
*

examples/App/AppInitialization/Async/Callback/CustomAuthFile/CustomAuthFile.ino

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,21 @@
3737
* <scope> - The OAuth scopes.
3838
* <claims> - The OAuth claims.
3939
* <expire> - The expiry period in seconds (less than 3600), 3300 is the default value.
40+
*
41+
* 3.------------------------
42+
*
43+
* CustomAuth::CustomAuth(<timestamp>, <file_config_data>, <api_key>, <user_id>, <scope>, <claims>, <expire>);
44+
*
45+
* <timestamp> - The current UNiX timestamp (seonds since Jan 1, 1970 midnight).
46+
* <file_config_data> - The filesystem data (file_config_data) obtained from FileConfig class object of service account key file.
47+
* <api_key> - The web API key of project.
48+
* <client_email> - The service account client Email.
49+
* <project_id> - The service account project ID.
50+
* <private_key> - The service account private key.
51+
* <user_id> - The user ID.
52+
* <scope> - The OAuth scopes.
53+
* <claims> - The OAuth claims.
54+
* <expire> - The expiry period in seconds (less than 3600), 3300 is the default value.
4055
*
4156
* NOTE:
4257
*

examples/App/AppInitialization/Async/Callback/ServiceAuth/ServiceAuth.ino

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,16 @@
3232
* <project_id> - The service account project ID.
3333
* <private_key> - The service account private key.
3434
* <expire> - The expiry period in seconds (less than 3600), 3300 is the default value.
35+
*
36+
* 3.------------------------
37+
*
38+
* ServiceAuth::ServiceAuth(<timestamp>, <client_email>, <project_id>, <private_key>, <expire>);
39+
*
40+
* <timestamp> - The current UNiX timestamp (seonds since Jan 1, 1970 midnight).
41+
* <client_email> - The service account client Email.
42+
* <project_id> - The service account project ID.
43+
* <private_key> - The service account private key.
44+
* <expire> - The expiry period in seconds (less than 3600), 3300 is the default value.
3545
*
3646
* NOTE:
3747
*

examples/App/AppInitialization/Async/Callback/ServiceAuthFile/ServiceAuthFile.ino

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@
3030
* <TimeStatusCallback> - The time status callback that provide the UNIX timestamp value used for JWT token signing.
3131
* <file_config_data> - The filesystem data (file_config_data) obtained from FileConfig class object of service account key file.
3232
* <expire> - The expiry period in seconds (less than 3600), 3300 is the default value.
33+
*
34+
* 3.------------------------
35+
*
36+
* ServiceAuth::ServiceAuth(<timestamp>, <file_config_data>, <expire>);
37+
*
38+
* <timestamp> - The current UNiX timestamp (seonds since Jan 1, 1970 midnight).
39+
* <file_config_data> - The filesystem data (file_config_data) obtained from FileConfig class object of service account key file.
40+
* <expire> - The expiry period in seconds (less than 3600), 3300 is the default value.
3341
*
3442
* NOTE:
3543
*
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#include "MyFirebase.h"
2+
#include <WiFi.h>
3+
#include <WiFiClientSecure.h>
4+
5+
#define WIFI_SSID "WIFI_AP"
6+
#define WIFI_PASSWORD "WIFI_PASSWORD"
7+
8+
#define API_KEY "Web_API_KEY"
9+
10+
#define USER_EMAIL "USER_EMAIL"
11+
#define USER_PASSWORD "USER_PASSWORD"
12+
#define DATABASE_URL "URL"
13+
14+
WiFiClientSecure ssl_client1, ssl_client2;
15+
16+
MyFirebase fb;
17+
int count = 0;
18+
unsigned long ms = 0;
19+
20+
void setup()
21+
{
22+
Serial.begin(115200);
23+
24+
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
25+
26+
Serial.print("Connecting to Wi-Fi");
27+
while (WiFi.status() != WL_CONNECTED)
28+
{
29+
Serial.print(".");
30+
delay(300);
31+
}
32+
Serial.println();
33+
Serial.print("Connected with IP: ");
34+
Serial.println(WiFi.localIP());
35+
Serial.println();
36+
37+
Firebase.printf("Firebase Client v%s\n", FIREBASE_CLIENT_VERSION);
38+
39+
ssl_client1.setInsecure();
40+
ssl_client2.setInsecure();
41+
42+
fb.userBegin(ssl_client1, DATABASE_URL, API_KEY, USER_EMAIL, USER_PASSWORD);
43+
44+
fb.beginStream(ssl_client2, "/test/string");
45+
}
46+
47+
void loop()
48+
{
49+
if (fb.ready() && (ms == 0 || millis() - ms > 20000))
50+
{
51+
ms = millis();
52+
53+
count++;
54+
55+
Serial.println("Setting the string value...");
56+
fb.setString("/test/string", "Hello " + String(count));
57+
58+
Serial.println("Getting the string value...");
59+
Serial.println(fb.getString("/test/string"));
60+
}
61+
62+
if (fb.available())
63+
{
64+
if (fb.isEvent())
65+
Serial.printf("Event task: %s, msg: %s, code: %d\n", fb.taskId().c_str(), fb.eventString().c_str(), fb.eventCode());
66+
67+
if (fb.isDebug())
68+
Serial.printf("Debug task: %s, msg: %s\n", fb.taskId().c_str(), fb.debugString().c_str());
69+
70+
if (fb.isError())
71+
Serial.printf("Error task: %s, msg: %s, code: %d\n", fb.taskId().c_str(), fb.errorString().c_str(), fb.errorCode());
72+
73+
if (fb.isPayload())
74+
{
75+
if (fb.isStream())
76+
{
77+
Serial.println("---------------------------");
78+
Serial.println("Stream data...");
79+
Serial.printf("task: %s\n", fb.taskId().c_str());
80+
Serial.printf("event: %s\n", fb.StreamEvent().c_str());
81+
Serial.printf("path: %s\n", fb.StreamDataPath().c_str());
82+
Serial.printf("data: %s\n", fb.StreamData().c_str());
83+
Serial.printf("type: %d\n", fb.StreamDataType());
84+
}
85+
else
86+
Serial.printf("task: %s, payload: %s\n", fb.taskId().c_str(), fb.payload().c_str());
87+
}
88+
}
89+
}

0 commit comments

Comments
 (0)