Skip to content

Commit cb9aaa2

Browse files
committed
Fix compilation error in ESP32 Core v3.1.x
1 parent fa44ed2 commit cb9aaa2

File tree

380 files changed

+10589
-753
lines changed

Some content is hidden

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

380 files changed

+10589
-753
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
## We have moved to the new library
88

99
> [!WARNING]
10-
> This library is now deprecated but no further supports for feature request.
10+
> This library is now deprecated and end of life. No further supports for help and feature request.
1111
> We recommended the [FirebaseClient](https://github.com/mobizt/FirebaseClient) library for ongoing supports.
1212
> You have to read the library documentation thoroughly before use.
1313
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
2+
/**
3+
* Created by K. Suwatchai (Mobizt)
4+
*
5+
6+
*
7+
* Github: https://github.com/mobizt/Firebase-ESP8266
8+
*
9+
* Copyright (c) 2023 mobizt
10+
*
11+
*/
12+
13+
/** This example will show how to authenticate using
14+
* the legacy token or database secret with the new APIs (using config and auth data).
15+
*/
16+
17+
#include <Arduino.h>
18+
#include <WiFi.h>
19+
#include <FirebaseESP32.h>
20+
21+
// Provide the RTDB payload printing info and other helper functions.
22+
#include <addons/RTDBHelper.h>
23+
24+
/* 1. Define the WiFi credentials */
25+
#define WIFI_SSID "WIFI_AP"
26+
#define WIFI_PASSWORD "WIFI_PASSWORD"
27+
28+
/* 2. If work with RTDB, define the RTDB URL and database secret */
29+
#define DATABASE_URL "URL" //<databaseName>.firebaseio.com or <databaseName>.<region>.firebasedatabase.app
30+
#define DATABASE_SECRET "DATABASE_SECRET"
31+
32+
/* 3. Define the Firebase Data object */
33+
FirebaseData fbdo;
34+
35+
/* 4, Define the FirebaseAuth data for authentication data */
36+
FirebaseAuth auth;
37+
38+
/* Define the FirebaseConfig data for config data */
39+
FirebaseConfig config;
40+
41+
unsigned long dataMillis = 0;
42+
int count = 0;
43+
44+
void setup()
45+
{
46+
47+
Serial.begin(115200);
48+
49+
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
50+
Serial.print("Connecting to Wi-Fi");
51+
while (WiFi.status() != WL_CONNECTED)
52+
{
53+
Serial.print(".");
54+
delay(300);
55+
}
56+
Serial.println();
57+
Serial.print("Connected with IP: ");
58+
Serial.println(WiFi.localIP());
59+
Serial.println();
60+
61+
Serial.printf("Firebase Client v%s\n\n", FIREBASE_CLIENT_VERSION);
62+
63+
/* Assign the certificate file (optional) */
64+
// config.cert.file = "/cert.cer";
65+
// config.cert.file_storage = StorageType::FLASH;
66+
67+
/* Assign the database URL and database secret(required) */
68+
config.database_url = DATABASE_URL;
69+
config.signer.tokens.legacy_token = DATABASE_SECRET;
70+
71+
// Comment or pass false value when WiFi reconnection will control by your code or third party library e.g. WiFiManager
72+
Firebase.reconnectNetwork(true);
73+
74+
// Since v4.4.x, BearSSL engine was used, the SSL buffer need to be set.
75+
// Large data transmission may require larger RX buffer, otherwise connection issue or data read time out can be occurred.
76+
fbdo.setBSSLBufferSize(4096 /* Rx buffer size in bytes from 512 - 16384 */, 1024 /* Tx buffer size in bytes from 512 - 16384 */);
77+
78+
/* Initialize the library with the Firebase authen and config */
79+
Firebase.begin(&config, &auth);
80+
81+
// Or use legacy authenticate method
82+
// Firebase.begin(DATABASE_URL, DATABASE_SECRET);
83+
}
84+
85+
void loop()
86+
{
87+
if (millis() - dataMillis > 5000)
88+
{
89+
dataMillis = millis();
90+
Serial.printf("Set int... %s\n", Firebase.setInt(fbdo, "/test/int", count++) ? "ok" : fbdo.errorReason().c_str());
91+
}
92+
}
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
/**
2+
* Created by K. Suwatchai (Mobizt)
3+
*
4+
5+
*
6+
* Github: https://github.com/mobizt/Firebase-ESP8266
7+
*
8+
* Copyright (c) 2023 mobizt
9+
*
10+
*/
11+
12+
/** This example will show how to re-authenticate after signed in with Email and password.
13+
*/
14+
15+
#include <Arduino.h>
16+
#include <WiFi.h>
17+
#include <FirebaseESP32.h>
18+
19+
#include <FirebaseESP32.h>
20+
21+
// Provide the token generation process info.
22+
#include <addons/TokenHelper.h>
23+
24+
// Provide the RTDB payload printing info and other helper functions.
25+
#include <addons/RTDBHelper.h>
26+
27+
/* 1. Define the WiFi credentials */
28+
#define WIFI_SSID "WIFI_AP"
29+
#define WIFI_PASSWORD "WIFI_PASSWORD"
30+
31+
/** 2. Define the API key
32+
*
33+
* The API key (required) can be obtained since you created the project and set up
34+
* the Authentication in Firebase console. Then you will get the API key from
35+
* Firebase project Web API key in Project settings, on General tab should show the
36+
* Web API Key.
37+
*
38+
* You may need to enable the Identity provider at https://console.cloud.google.com/customer-identity/providers
39+
* Select your project, click at ENABLE IDENTITY PLATFORM button.
40+
* The API key also available by click at the link APPLICATION SETUP DETAILS.
41+
*
42+
*/
43+
#define API_KEY "API_KEY"
44+
45+
/* 3. Define the user Email and password that already registerd or added in your project */
46+
#define USER_EMAIL1 "USER_EMAIL1"
47+
#define USER_PASSWORD1 "USER_PASSWORD1"
48+
49+
#define USER_EMAIL2 "USER_EMAIL2"
50+
#define USER_PASSWORD2 "USER_PASSWORD2"
51+
52+
/* 4. If work with RTDB, define the RTDB URL */
53+
#define DATABASE_URL "URL" //<databaseName>.firebaseio.com or <databaseName>.<region>.firebasedatabase.app
54+
55+
/* 5. Define the Firebase Data object */
56+
FirebaseData fbdo;
57+
58+
/* 6. Define the FirebaseAuth data for authentication data */
59+
FirebaseAuth auth;
60+
61+
/* 7. Define the FirebaseConfig data for config data */
62+
FirebaseConfig config;
63+
64+
unsigned long dataMillis = 0;
65+
int count = 0;
66+
bool toggleUser = false;
67+
68+
void signIn(const char *email, const char *password)
69+
{
70+
/* Assign the user sign in credentials */
71+
auth.user.email = email;
72+
auth.user.password = password;
73+
74+
/* Reset stored authen and config */
75+
Firebase.reset(&config);
76+
77+
/* Initialize the library with the Firebase authen and config */
78+
Firebase.begin(&config, &auth);
79+
}
80+
81+
void setup()
82+
{
83+
84+
Serial.begin(115200);
85+
86+
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
87+
Serial.print("Connecting to Wi-Fi");
88+
while (WiFi.status() != WL_CONNECTED)
89+
{
90+
Serial.print(".");
91+
delay(300);
92+
}
93+
Serial.println();
94+
Serial.print("Connected with IP: ");
95+
Serial.println(WiFi.localIP());
96+
Serial.println();
97+
98+
Serial.printf("Firebase Client v%s\n\n", FIREBASE_CLIENT_VERSION);
99+
100+
/* Assign the api key (required) */
101+
config.api_key = API_KEY;
102+
103+
/* Assign the RTDB URL */
104+
config.database_url = DATABASE_URL;
105+
106+
// Comment or pass false value when WiFi reconnection will control by your code or third party library e.g. WiFiManager
107+
Firebase.reconnectNetwork(true);
108+
109+
// Since v4.4.x, BearSSL engine was used, the SSL buffer need to be set.
110+
// Large data transmission may require larger RX buffer, otherwise connection issue or data read time out can be occurred.
111+
fbdo.setBSSLBufferSize(4096 /* Rx buffer size in bytes from 512 - 16384 */, 1024 /* Tx buffer size in bytes from 512 - 16384 */);
112+
113+
fbdo.setResponseSize(4096);
114+
115+
/* Assign the callback function for the long running token generation task */
116+
config.token_status_callback = tokenStatusCallback; // see addons/TokenHelper.h
117+
118+
/** Sign in as user 1 */
119+
signIn(USER_EMAIL1, USER_PASSWORD1);
120+
}
121+
122+
void loop()
123+
{
124+
// Firebase.ready() should be called repeatedly to handle authentication tasks.
125+
126+
if (millis() - dataMillis > 5000)
127+
{
128+
dataMillis = millis();
129+
130+
if (Firebase.ready())
131+
{
132+
String path = "/UsersData/";
133+
path += auth.token.uid.c_str(); //<- user uid of current user that sign in with Emal/Password
134+
path += "/test/int";
135+
Serial.printf("Current UID: %s\n", auth.token.uid.c_str());
136+
Serial.printf("Set int... %s\n", Firebase.setInt(fbdo, path, count++) ? "ok" : fbdo.errorReason().c_str());
137+
138+
// Swap users every 5 times
139+
if (count % 5 == 0)
140+
{
141+
Serial.println();
142+
143+
if (toggleUser)
144+
signIn(USER_EMAIL1, USER_PASSWORD1); /** Sign in as user 1 */
145+
else
146+
signIn(USER_EMAIL2, USER_PASSWORD2); /** Sign in as user 2 */
147+
toggleUser = !toggleUser;
148+
}
149+
}
150+
}
151+
}

0 commit comments

Comments
 (0)