Skip to content

Commit bb1b881

Browse files
committed
Fix compilation error in ESP32 Core v3.1.x
1 parent 5a9264e commit bb1b881

File tree

440 files changed

+37441
-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.

440 files changed

+37441
-753
lines changed

README.md

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

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

0 commit comments

Comments
 (0)