From 948d16cb3ed0b3af495fbd182166ed7314219c10 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 1 Jan 2023 10:14:31 +0700 Subject: [PATCH] Update license. --- LICENSE | 2 +- README.md | 2 +- .../LegacyTokenAuthen/LegacyTokenAuthen.ino | 2 +- .../ReAuthenticate/ReAuthenticate.ino | 2 +- .../AccessTokenFile/AccessTokenFile.ino | 2 +- .../AnonymousSignin/AnonymousSignin.ino | 2 +- .../SignInAsUser/CustomToken/CustomToken.ino | 2 +- .../CustomTokenFile/CustomTokenFile.ino | 2 +- .../EmailPassword/EmailPassword.ino | 2 +- .../SignInWithAccessToken.ino | 216 +++--- .../SignInWithCustomToken.ino | 228 +++---- .../SignInWithIDToken/SignInWithIDToken.ino | 2 +- .../SignInWithRefreshAccessToken.ino | 200 +++--- .../SignInWithRefreshIDToken.ino | 230 +++---- .../Authentications/TestMode/TestMode.ino | 2 +- .../ResetPassword/ResetPassword.ino | 2 +- .../SendVerification/SendVerification.ino | 2 +- .../UserManagement/Signup/Signup.ino | 2 +- .../CallFunction/CallFunction.ino | 2 +- .../CreateFunctionFromSources.ino | 2 +- .../CreateFunctionWithCallback.ino | 2 +- .../CreateFunctionWithEventTrigger.ino | 2 +- .../CreateFunctionWithReturnStatus.ino | 2 +- .../DeployAutoZipFunction.ino | 2 +- .../DeleteFunction/DeleteFunction.ino | 2 +- .../DownloadFunction/DownloadFunction.ino | 2 +- .../IAMPolicy/CreatePolicy/CreatePolicy.ino | 2 +- .../IAMPolicy/GetPolicy/GetPolicy.ino | 2 +- .../IAMPolicy/SetPolicy/SetPolicy.ino | 2 +- .../ListFunctions/ListFunctions.ino | 2 +- .../PatchFunction/PatchFunction.ino | 2 +- .../RTDB/Ethernet/ESP32/Basic/Basic.ino | 442 ++++++------- .../ESP32/StreamCallback/StreamCallback.ino | 610 ++++++++--------- .../RTDB/Ethernet/ESP8266/Basic/Basic.ino | 444 ++++++------- .../ESP8266/StreamCallback/StreamCallback.ino | 616 +++++++++--------- .../RTDB/Ethernet/Others/Basic/Basic.ino | 450 ++++++------- .../ExternalClient/RTDB/WiFi/Basic/Basic.ino | 324 ++++----- .../WiFi/StreamCallback/StreamCallback.ino | 474 +++++++------- .../Create_Edit_Parse/Create_Edit_Parse.ino | 2 +- .../Client/ArduinoMQTT/ArduinoMQTT.ino | 2 +- .../FirebaseJson/Client/Firebase/Firebase.ino | 2 +- .../Client/WiFiClient/WiFiClient.ino | 2 +- .../WiFiClientSecure/WiFiClientSecure.ino | 2 +- examples/FirebaseJson/Stream/File/File.ino | 2 +- .../FirebaseJson/Stream/Serial/Serial.ino | 2 +- .../BatchGetDocuments/BatchGetDocuments.ino | 230 +++---- .../BatchWriteDocuments.ino | 362 +++++----- .../AppendArray/AppendArray.ino | 2 +- .../AppendMapValue/AppendMapValue.ino | 2 +- .../AppendMapValueArray.ino | 308 ++++----- .../AppendMapValueTimestamp.ino | 350 +++++----- .../IncrementFieldValue.ino | 2 +- .../SetUpdateDelete/SetUpdateDelete.ino | 2 +- .../CreateDocuments/CreateDocuments.ino | 2 +- examples/Firestore/DataQuery/DataQuery.ino | 2 +- .../DeleteDocument/DeleteDocument.ino | 2 +- .../ExportDocuments/ExportDocuments.ino | 2 +- .../Firestore/GetDocument/GetDocument.ino | 2 +- .../ImportDocuments/ImportDocuments.ino | 2 +- .../Indexes/CreateIndex/CreateIndex.ino | 276 ++++---- .../Indexes/DeleteIndex/DeleteIndex.ino | 236 +++---- .../ListCollectionIds/ListCollectionIds.ino | 2 +- .../Firestore/ListDocuments/ListDocuments.ino | 2 +- .../AppendMapValue/AppendMapValue.ino | 2 +- .../UpdateDocument/UpdateDocument.ino | 2 +- .../AppInstanceInfo/AppInstanceInfo.ino | 2 +- .../RegistAPNsTokens/RegistAPNsTokens.ino | 2 +- .../Send/HTTPv1/SendMessage/SendMessage.ino | 2 +- .../Send/HTTPv1/SendTopic/SendTopic.ino | 2 +- .../BroadcastMessage/BroadcastMessage.ino | 2 +- .../LegacyAPI/SendMessage/SendMessage.ino | 2 +- .../SendMessageEthernet/ESP32/ESP32.ino | 2 +- .../SendMessageEthernet/ESP8266/ESP8266.ino | 2 +- .../Send/LegacyAPI/SendTopic/SendTopic.ino | 2 +- .../SubscribeTopic/SubscribeTopic.ino | 2 +- .../UnsubscribeTopic/UnsubscribeTopic.ino | 2 +- examples/RTDB/BackupRestore/Flash/Flash.ino | 2 +- examples/RTDB/BackupRestore/SD/SD.ino | 2 +- examples/RTDB/Basic/Basic.ino | 2 +- examples/RTDB/BasicCert/BasicCert.ino | 2 +- examples/RTDB/BasicEthernet/ESP32/ESP32.ino | 2 +- .../RTDB/BasicEthernet/ESP8266/ESP8266.ino | 2 +- examples/RTDB/Blob/Blob.ino | 2 +- examples/RTDB/Blynk/Blynk.ino | 2 +- .../DataChangesListener/Callback/Callback.ino | 2 +- .../MultiPath/MultiPath.ino | 2 +- .../NoCallback/NoCallback.ino | 2 +- .../SingleDataObject/SingleDataObject.ino | 2 +- examples/RTDB/DataFilter/DataFilter.ino | 2 +- examples/RTDB/DataRetaining/DataRetaining.ino | 2 +- examples/RTDB/DatabaseRules/DatabaseRules.ino | 2 +- .../RTDB/DownloadFileOTA/DownloadFileOTA.ino | 2 +- examples/RTDB/ETag/ETag.ino | 2 +- examples/RTDB/FastSend/FastSend.ino | 2 +- examples/RTDB/File/Flash/Flash.ino | 2 +- examples/RTDB/File/SD/SD.ino | 2 +- .../RTDB/FireSense/AnalogRead/AnalogRead.ino | 2 +- examples/RTDB/FireSense/Blink/Blink.ino | 2 +- examples/RTDB/FireSense/Sensors/Sensors.ino | 2 +- examples/RTDB/Priority/Priority.ino | 2 +- examples/RTDB/Queue/Queue.ino | 2 +- examples/RTDB/ShallowedData/ShallowedData.ino | 2 +- examples/RTDB/Timestamp/Timestamp.ino | 2 +- .../FirebaseStorage/DeleteFile/DeleteFile.ino | 2 +- .../DownloadFile/DownloadFile.ino | 2 +- .../DownloadFileOTA/DownloadFileOTA.ino | 2 +- .../FirebaseStorage/ListFiles/ListFiles.ino | 2 +- .../FirebaseStorage/Metadata/Metadata.ino | 2 +- .../UploadByteArrayMemory.ino | 2 +- .../FirebaseStorage/UploadFile/UploadFile.ino | 2 +- .../DeleteFile/DeleteFile.ino | 2 +- .../DownloadFile/DownloadFile.ino | 2 +- .../DownloadFileOTA/DownloadFileOTA.ino | 2 +- .../ListFiles/ListFiles.ino | 2 +- .../GoogleCloudStorage/Metadata/Metadata.ino | 2 +- .../UploadFile/UploadFile.ino | 2 +- src/FB_Const.h | 4 +- src/FB_Utils.h | 4 +- src/Firebase.cpp | 2 +- src/Firebase.h | 2 +- src/Firebase_ESP_Client.h | 4 +- src/MB_NTP.h | 356 +++++----- src/README.md | 2 +- src/addons/FireSense/FireSense.h | 4 +- src/addons/FireSense/README.md | 2 +- src/firestore/FB_Firestore.cpp | 4 +- src/firestore/FB_Firestore.h | 4 +- src/functions/FB_Functions.cpp | 4 +- src/functions/FB_Functions.h | 4 +- src/functions/FunctionsConfig.cpp | 4 +- src/functions/FunctionsConfig.h | 4 +- src/functions/PocicyBuilder.cpp | 4 +- src/functions/PolicyBuilder.h | 4 +- src/gcs/GCS.cpp | 4 +- src/gcs/GCS.h | 4 +- src/json/FirebaseJson.cpp | 2 +- src/json/FirebaseJson.h | 2 +- src/json/MB_JSON/MB_JSON.c | 2 +- src/json/MB_JSON/MB_JSON.h | 2 +- src/json/MB_List.h | 2 +- src/json/MB_String.h | 4 +- src/mbfs/MB_FS.h | 2 +- src/message/FCM.cpp | 4 +- src/message/FCM.h | 4 +- src/rtdb/FB_RTDB.cpp | 4 +- src/rtdb/FB_RTDB.h | 4 +- src/rtdb/QueryFilter.cpp | 4 +- src/rtdb/QueryFilter.h | 4 +- src/rtdb/QueueInfo.cpp | 4 +- src/rtdb/QueueInfo.h | 4 +- src/rtdb/QueueManager.cpp | 4 +- src/rtdb/QueueManager.h | 4 +- src/rtdb/stream/FB_MP_Stream.cpp | 4 +- src/rtdb/stream/FB_MP_Stream.h | 4 +- src/rtdb/stream/FB_Stream.cpp | 4 +- src/rtdb/stream/FB_Stream.h | 4 +- src/session/FB_Session.cpp | 4 +- src/session/FB_Session.h | 4 +- src/signer/Signer.cpp | 4 +- src/signer/Signer.h | 4 +- src/storage/FCS.cpp | 4 +- src/storage/FCS.h | 4 +- src/wcs/base/FB_TCP_Client_Base.h | 2 +- src/wcs/custom/FB_Custom_TCP_Client.h | 2 +- src/wcs/esp32/FB_TCP_Client.cpp | 2 +- src/wcs/esp32/FB_TCP_Client.h | 2 +- src/wcs/esp8266/FB_TCP_Client.cpp | 2 +- src/wcs/esp8266/FB_TCP_Client.h | 2 +- 168 files changed, 3361 insertions(+), 3361 deletions(-) diff --git a/LICENSE b/LICENSE index 621c83e44..c22fc2301 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2022 mobizt +Copyright (c) 2023 mobizt Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 5e08206a3..d3e69cb55 100644 --- a/README.md +++ b/README.md @@ -1928,7 +1928,7 @@ Thanks for all contributions and Google Open Source. The MIT License (MIT) -Copyright (C) 2022 K. Suwatchai (Mobizt) +Copyright (c) 2023 K. Suwatchai (Mobizt) Permission is hereby granted, free of charge, to any person returning a copy of diff --git a/examples/Authentications/LegacyTokenAuthen/LegacyTokenAuthen.ino b/examples/Authentications/LegacyTokenAuthen/LegacyTokenAuthen.ino index 1f78f43cd..e2178dd59 100644 --- a/examples/Authentications/LegacyTokenAuthen/LegacyTokenAuthen.ino +++ b/examples/Authentications/LegacyTokenAuthen/LegacyTokenAuthen.ino @@ -6,7 +6,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/Authentications/ReAuthenticate/ReAuthenticate.ino b/examples/Authentications/ReAuthenticate/ReAuthenticate.ino index b91503119..543ca1ca7 100644 --- a/examples/Authentications/ReAuthenticate/ReAuthenticate.ino +++ b/examples/Authentications/ReAuthenticate/ReAuthenticate.ino @@ -6,7 +6,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/Authentications/SignInAsAdmin/AccessTokenFile/AccessTokenFile.ino b/examples/Authentications/SignInAsAdmin/AccessTokenFile/AccessTokenFile.ino index e99f9d4ce..7d4b9c62f 100644 --- a/examples/Authentications/SignInAsAdmin/AccessTokenFile/AccessTokenFile.ino +++ b/examples/Authentications/SignInAsAdmin/AccessTokenFile/AccessTokenFile.ino @@ -6,7 +6,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/Authentications/SignInAsGuest/AnonymousSignin/AnonymousSignin.ino b/examples/Authentications/SignInAsGuest/AnonymousSignin/AnonymousSignin.ino index 91b46f610..1fc9af8fe 100644 --- a/examples/Authentications/SignInAsGuest/AnonymousSignin/AnonymousSignin.ino +++ b/examples/Authentications/SignInAsGuest/AnonymousSignin/AnonymousSignin.ino @@ -6,7 +6,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/Authentications/SignInAsUser/CustomToken/CustomToken.ino b/examples/Authentications/SignInAsUser/CustomToken/CustomToken.ino index 35e64af02..3681941c5 100644 --- a/examples/Authentications/SignInAsUser/CustomToken/CustomToken.ino +++ b/examples/Authentications/SignInAsUser/CustomToken/CustomToken.ino @@ -6,7 +6,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/Authentications/SignInAsUser/CustomTokenFile/CustomTokenFile.ino b/examples/Authentications/SignInAsUser/CustomTokenFile/CustomTokenFile.ino index 7ad076dd6..33febcf85 100644 --- a/examples/Authentications/SignInAsUser/CustomTokenFile/CustomTokenFile.ino +++ b/examples/Authentications/SignInAsUser/CustomTokenFile/CustomTokenFile.ino @@ -6,7 +6,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/Authentications/SignInAsUser/EmailPassword/EmailPassword.ino b/examples/Authentications/SignInAsUser/EmailPassword/EmailPassword.ino index 5360fb3c5..bb1a70d07 100644 --- a/examples/Authentications/SignInAsUser/EmailPassword/EmailPassword.ino +++ b/examples/Authentications/SignInAsUser/EmailPassword/EmailPassword.ino @@ -6,7 +6,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/Authentications/SignInWithAccessToken/SignInWithAccessToken.ino b/examples/Authentications/SignInWithAccessToken/SignInWithAccessToken.ino index 0f274633d..e1fdc0361 100644 --- a/examples/Authentications/SignInWithAccessToken/SignInWithAccessToken.ino +++ b/examples/Authentications/SignInWithAccessToken/SignInWithAccessToken.ino @@ -1,108 +1,108 @@ - -/** - * Created by K. Suwatchai (Mobizt) - * - * Email: k_suwatchai@hotmail.com - * - * Github: https://github.com/mobizt/Firebase-ESP-Client - * - * Copyright (c) 2022 mobizt - * - */ - -/* This example shows how to authenticate using the OAuth2.0 access token generated from other app. */ - -#if defined(ESP32) -#include -#elif defined(ESP8266) -#include -#endif - -#include - -// Provide the token generation process info. -#include - -// Provide the RTDB payload printing info and other helper functions. -#include - -/* 1. Define the WiFi credentials */ -#define WIFI_SSID "WIFI_AP" -#define WIFI_PASSWORD "WIFI_PASSWORD" - -/* 2. If work with RTDB, define the RTDB URL */ -#define DATABASE_URL "URL" //.firebaseio.com or ..firebasedatabase.app - -/* 3. Define the Firebase Data object */ -FirebaseData fbdo; - -/* 4. Define the FirebaseAuth data for authentication data */ -FirebaseAuth auth; - -/* 5. Define the FirebaseConfig data for config data */ -FirebaseConfig config; - -unsigned long dataMillis = 0; -int count = 0; - -void setup() -{ - - Serial.begin(115200); - - WiFi.begin(WIFI_SSID, WIFI_PASSWORD); - Serial.print("Connecting to Wi-Fi"); - while (WiFi.status() != WL_CONNECTED) - { - Serial.print("."); - delay(300); - } - Serial.println(); - Serial.print("Connected with IP: "); - Serial.println(WiFi.localIP()); - Serial.println(); - - Serial.printf("Firebase Client v%s\n\n", FIREBASE_CLIENT_VERSION); - - /* Assign the RTDB URL */ - config.database_url = DATABASE_URL; - - Firebase.reconnectWiFi(true); - - /* Assign the callback function for the long running token generation task */ - config.token_status_callback = tokenStatusCallback; // see addons/TokenHelper.h - - // To refresh the token 5 minutes before expired - config.signer.preRefreshSeconds = 5 * 60; - - /* Set access token */ - // The access token obtained from other apps using OAuth2.0 authentication. - - // The APIs scopes that cover all library applications should include the following - // https://www.googleapis.com/auth/devstorage.full_control - // https://www.googleapis.com/auth/datastore - // https://www.googleapis.com/auth/userinfo.email - // https://www.googleapis.com/auth/firebase.database - // https://www.googleapis.com/auth/cloud-platform - // https://www.googleapis.com/auth/iam - - // Refresh token, Client ID and Client Secret are required for OAuth2.0 token refreshing. - // The Client ID and Client Secret can be taken from https://console.developers.google.com/apis/credentials - - // If Refresh token was not assigned or empty string, the id token will not refresh when it expired. - Firebase.setAccessToken(&config, "" /* access token */, 3600 /* expiry time */, "" /* refresh token */, "" /* client id */, "" /* client secret */); - - Firebase.begin(&config, &auth); -} - -void loop() -{ - - // Firebase.ready() should be called repeatedly to handle authentication tasks. - - if (millis() - dataMillis > 5000 && Firebase.ready()) - { - dataMillis = millis(); - Serial.printf("Set int... %s\n", Firebase.RTDB.setInt(&fbdo, "/test/int", count++) ? "ok" : fbdo.errorReason().c_str()); - } -} + +/** + * Created by K. Suwatchai (Mobizt) + * + * Email: k_suwatchai@hotmail.com + * + * Github: https://github.com/mobizt/Firebase-ESP-Client + * + * Copyright (c) 2023 mobizt + * + */ + +/* This example shows how to authenticate using the OAuth2.0 access token generated from other app. */ + +#if defined(ESP32) +#include +#elif defined(ESP8266) +#include +#endif + +#include + +// Provide the token generation process info. +#include + +// Provide the RTDB payload printing info and other helper functions. +#include + +/* 1. Define the WiFi credentials */ +#define WIFI_SSID "WIFI_AP" +#define WIFI_PASSWORD "WIFI_PASSWORD" + +/* 2. If work with RTDB, define the RTDB URL */ +#define DATABASE_URL "URL" //.firebaseio.com or ..firebasedatabase.app + +/* 3. Define the Firebase Data object */ +FirebaseData fbdo; + +/* 4. Define the FirebaseAuth data for authentication data */ +FirebaseAuth auth; + +/* 5. Define the FirebaseConfig data for config data */ +FirebaseConfig config; + +unsigned long dataMillis = 0; +int count = 0; + +void setup() +{ + + Serial.begin(115200); + + WiFi.begin(WIFI_SSID, WIFI_PASSWORD); + Serial.print("Connecting to Wi-Fi"); + while (WiFi.status() != WL_CONNECTED) + { + Serial.print("."); + delay(300); + } + Serial.println(); + Serial.print("Connected with IP: "); + Serial.println(WiFi.localIP()); + Serial.println(); + + Serial.printf("Firebase Client v%s\n\n", FIREBASE_CLIENT_VERSION); + + /* Assign the RTDB URL */ + config.database_url = DATABASE_URL; + + Firebase.reconnectWiFi(true); + + /* Assign the callback function for the long running token generation task */ + config.token_status_callback = tokenStatusCallback; // see addons/TokenHelper.h + + // To refresh the token 5 minutes before expired + config.signer.preRefreshSeconds = 5 * 60; + + /* Set access token */ + // The access token obtained from other apps using OAuth2.0 authentication. + + // The APIs scopes that cover all library applications should include the following + // https://www.googleapis.com/auth/devstorage.full_control + // https://www.googleapis.com/auth/datastore + // https://www.googleapis.com/auth/userinfo.email + // https://www.googleapis.com/auth/firebase.database + // https://www.googleapis.com/auth/cloud-platform + // https://www.googleapis.com/auth/iam + + // Refresh token, Client ID and Client Secret are required for OAuth2.0 token refreshing. + // The Client ID and Client Secret can be taken from https://console.developers.google.com/apis/credentials + + // If Refresh token was not assigned or empty string, the id token will not refresh when it expired. + Firebase.setAccessToken(&config, "" /* access token */, 3600 /* expiry time */, "" /* refresh token */, "" /* client id */, "" /* client secret */); + + Firebase.begin(&config, &auth); +} + +void loop() +{ + + // Firebase.ready() should be called repeatedly to handle authentication tasks. + + if (millis() - dataMillis > 5000 && Firebase.ready()) + { + dataMillis = millis(); + Serial.printf("Set int... %s\n", Firebase.RTDB.setInt(&fbdo, "/test/int", count++) ? "ok" : fbdo.errorReason().c_str()); + } +} diff --git a/examples/Authentications/SignInWithCustomToken/SignInWithCustomToken.ino b/examples/Authentications/SignInWithCustomToken/SignInWithCustomToken.ino index 84c8552be..e80d78ce2 100644 --- a/examples/Authentications/SignInWithCustomToken/SignInWithCustomToken.ino +++ b/examples/Authentications/SignInWithCustomToken/SignInWithCustomToken.ino @@ -1,114 +1,114 @@ - -/** - * Created by K. Suwatchai (Mobizt) - * - * Email: k_suwatchai@hotmail.com - * - * Github: https://github.com/mobizt/Firebase-ESP-Client - * - * Copyright (c) 2022 mobizt - * - */ - -/* This example shows how to authenticate using the Identity Platform custom token (custom claims signed JWT token) generated from other app. */ - -#if defined(ESP32) -#include -#elif defined(ESP8266) -#include -#endif - -#include - -// Provide the token generation process info. -#include - -// Provide the RTDB payload printing info and other helper functions. -#include - - -/** 1. Define the API key - * - * The API key can be obtained since you created the project and set up - * the Authentication in Firebase console. - * - * You may need to enable the Identity provider at https://console.cloud.google.com/customer-identity/providers - * Select your project, click at ENABLE IDENTITY PLATFORM button. - * The API key also available by click at the link APPLICATION SETUP DETAILS. - * - */ -#define API_KEY "API_KEY" - -/* 2. Define the WiFi credentials */ -#define WIFI_SSID "WIFI_AP" -#define WIFI_PASSWORD "WIFI_PASSWORD" - -/* 3. If work with RTDB, define the RTDB URL */ -#define DATABASE_URL "URL" //.firebaseio.com or ..firebasedatabase.app - -/* 4. Define the Firebase Data object */ -FirebaseData fbdo; - -/* 5. Define the FirebaseAuth data for authentication data */ -FirebaseAuth auth; - -/* 6. Define the FirebaseConfig data for config data */ -FirebaseConfig config; - -unsigned long dataMillis = 0; -int count = 0; - -void setup() -{ - - Serial.begin(115200); - - WiFi.begin(WIFI_SSID, WIFI_PASSWORD); - Serial.print("Connecting to Wi-Fi"); - while (WiFi.status() != WL_CONNECTED) - { - Serial.print("."); - delay(300); - } - Serial.println(); - Serial.print("Connected with IP: "); - Serial.println(WiFi.localIP()); - Serial.println(); - - Serial.printf("Firebase Client v%s\n\n", FIREBASE_CLIENT_VERSION); - - /* Assign the api key (required) */ - config.api_key = API_KEY; - - /* Assign the RTDB URL */ - config.database_url = DATABASE_URL; - - Firebase.reconnectWiFi(true); - - /* Assign the callback function for the long running token generation task */ - config.token_status_callback = tokenStatusCallback; // see addons/TokenHelper.h - - // To refresh the token 5 minutes before expired - config.signer.preRefreshSeconds = 5 * 60; - - /* Set custom token */ - // If the refresh token from Custom token verification or sign in, was assigned here instead of - // custom token (signed JWT token), the token refresh process will be performed immediately. - - // Any token that is not in the form header.payload.signature i.e., xxxxx.yyyyy.zzzzz will be treated as refresh token. - Firebase.setCustomToken(&config, "" /* custom token */); - - Firebase.begin(&config, &auth); -} - -void loop() -{ - - // Firebase.ready() should be called repeatedly to handle authentication tasks. - - if (millis() - dataMillis > 5000 && Firebase.ready()) - { - dataMillis = millis(); - Serial.printf("Set int... %s\n", Firebase.RTDB.setInt(&fbdo, "/test/int", count++) ? "ok" : fbdo.errorReason().c_str()); - } -} + +/** + * Created by K. Suwatchai (Mobizt) + * + * Email: k_suwatchai@hotmail.com + * + * Github: https://github.com/mobizt/Firebase-ESP-Client + * + * Copyright (c) 2023 mobizt + * + */ + +/* This example shows how to authenticate using the Identity Platform custom token (custom claims signed JWT token) generated from other app. */ + +#if defined(ESP32) +#include +#elif defined(ESP8266) +#include +#endif + +#include + +// Provide the token generation process info. +#include + +// Provide the RTDB payload printing info and other helper functions. +#include + + +/** 1. Define the API key + * + * The API key can be obtained since you created the project and set up + * the Authentication in Firebase console. + * + * You may need to enable the Identity provider at https://console.cloud.google.com/customer-identity/providers + * Select your project, click at ENABLE IDENTITY PLATFORM button. + * The API key also available by click at the link APPLICATION SETUP DETAILS. + * + */ +#define API_KEY "API_KEY" + +/* 2. Define the WiFi credentials */ +#define WIFI_SSID "WIFI_AP" +#define WIFI_PASSWORD "WIFI_PASSWORD" + +/* 3. If work with RTDB, define the RTDB URL */ +#define DATABASE_URL "URL" //.firebaseio.com or ..firebasedatabase.app + +/* 4. Define the Firebase Data object */ +FirebaseData fbdo; + +/* 5. Define the FirebaseAuth data for authentication data */ +FirebaseAuth auth; + +/* 6. Define the FirebaseConfig data for config data */ +FirebaseConfig config; + +unsigned long dataMillis = 0; +int count = 0; + +void setup() +{ + + Serial.begin(115200); + + WiFi.begin(WIFI_SSID, WIFI_PASSWORD); + Serial.print("Connecting to Wi-Fi"); + while (WiFi.status() != WL_CONNECTED) + { + Serial.print("."); + delay(300); + } + Serial.println(); + Serial.print("Connected with IP: "); + Serial.println(WiFi.localIP()); + Serial.println(); + + Serial.printf("Firebase Client v%s\n\n", FIREBASE_CLIENT_VERSION); + + /* Assign the api key (required) */ + config.api_key = API_KEY; + + /* Assign the RTDB URL */ + config.database_url = DATABASE_URL; + + Firebase.reconnectWiFi(true); + + /* Assign the callback function for the long running token generation task */ + config.token_status_callback = tokenStatusCallback; // see addons/TokenHelper.h + + // To refresh the token 5 minutes before expired + config.signer.preRefreshSeconds = 5 * 60; + + /* Set custom token */ + // If the refresh token from Custom token verification or sign in, was assigned here instead of + // custom token (signed JWT token), the token refresh process will be performed immediately. + + // Any token that is not in the form header.payload.signature i.e., xxxxx.yyyyy.zzzzz will be treated as refresh token. + Firebase.setCustomToken(&config, "" /* custom token */); + + Firebase.begin(&config, &auth); +} + +void loop() +{ + + // Firebase.ready() should be called repeatedly to handle authentication tasks. + + if (millis() - dataMillis > 5000 && Firebase.ready()) + { + dataMillis = millis(); + Serial.printf("Set int... %s\n", Firebase.RTDB.setInt(&fbdo, "/test/int", count++) ? "ok" : fbdo.errorReason().c_str()); + } +} diff --git a/examples/Authentications/SignInWithIDToken/SignInWithIDToken.ino b/examples/Authentications/SignInWithIDToken/SignInWithIDToken.ino index 79ef750a5..187703c02 100644 --- a/examples/Authentications/SignInWithIDToken/SignInWithIDToken.ino +++ b/examples/Authentications/SignInWithIDToken/SignInWithIDToken.ino @@ -6,7 +6,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/Authentications/SignInWithRefreshAccessToken/SignInWithRefreshAccessToken.ino b/examples/Authentications/SignInWithRefreshAccessToken/SignInWithRefreshAccessToken.ino index 138202c34..f9c312619 100644 --- a/examples/Authentications/SignInWithRefreshAccessToken/SignInWithRefreshAccessToken.ino +++ b/examples/Authentications/SignInWithRefreshAccessToken/SignInWithRefreshAccessToken.ino @@ -1,100 +1,100 @@ - -/** - * Created by K. Suwatchai (Mobizt) - * - * Email: k_suwatchai@hotmail.com - * - * Github: https://github.com/mobizt/Firebase-ESP-Client - * - * Copyright (c) 2022 mobizt - * - */ - -/* This example shows how to re-authenticate using the refresh token generated from other app via OAuth2.0 authentication. */ - -#if defined(ESP32) -#include -#elif defined(ESP8266) -#include -#endif - -#include - -// Provide the token generation process info. -#include - -// Provide the RTDB payload printing info and other helper functions. -#include - -/* 1. Define the WiFi credentials */ -#define WIFI_SSID "WIFI_AP" -#define WIFI_PASSWORD "WIFI_PASSWORD" - -/* 2. If work with RTDB, define the RTDB URL */ -#define DATABASE_URL "URL" //.firebaseio.com or ..firebasedatabase.app - -/* 3. Define the Firebase Data object */ -FirebaseData fbdo; - -/* 4. Define the FirebaseAuth data for authentication data */ -FirebaseAuth auth; - -/* 5. Define the FirebaseConfig data for config data */ -FirebaseConfig config; - -unsigned long dataMillis = 0; -int count = 0; - -void setup() -{ - - Serial.begin(115200); - - WiFi.begin(WIFI_SSID, WIFI_PASSWORD); - Serial.print("Connecting to Wi-Fi"); - while (WiFi.status() != WL_CONNECTED) - { - Serial.print("."); - delay(300); - } - Serial.println(); - Serial.print("Connected with IP: "); - Serial.println(WiFi.localIP()); - Serial.println(); - - Serial.printf("Firebase Client v%s\n\n", FIREBASE_CLIENT_VERSION); - - /* Assign the RTDB URL */ - config.database_url = DATABASE_URL; - - Firebase.reconnectWiFi(true); - - /* Assign the callback function for the long running token generation task */ - config.token_status_callback = tokenStatusCallback; // see addons/TokenHelper.h - - // To refresh the token 5 minutes before expired - config.signer.preRefreshSeconds = 5 * 60; - - // Use refresh token and force token to refresh immediately - // Refresh token, Client ID and Client Secret are required for OAuth2.0 token refreshing. - // The Client ID and Client Secret can be taken from https://console.developers.google.com/apis/credentials - - Firebase.setAccessToken(&config, "" /* set access token to empty to refresh token immediately */, 3600 /* expiry time */, "" /* refresh token */, "" /* client id */, "" /* client secret */); - - // Or refresh token manually - // Firebase.refreshToken(&config); - - Firebase.begin(&config, &auth); -} - -void loop() -{ - - // Firebase.ready() should be called repeatedly to handle authentication tasks. - - if (millis() - dataMillis > 5000 && Firebase.ready()) - { - dataMillis = millis(); - Serial.printf("Set int... %s\n", Firebase.RTDB.setInt(&fbdo, "/test/int", count++) ? "ok" : fbdo.errorReason().c_str()); - } -} + +/** + * Created by K. Suwatchai (Mobizt) + * + * Email: k_suwatchai@hotmail.com + * + * Github: https://github.com/mobizt/Firebase-ESP-Client + * + * Copyright (c) 2023 mobizt + * + */ + +/* This example shows how to re-authenticate using the refresh token generated from other app via OAuth2.0 authentication. */ + +#if defined(ESP32) +#include +#elif defined(ESP8266) +#include +#endif + +#include + +// Provide the token generation process info. +#include + +// Provide the RTDB payload printing info and other helper functions. +#include + +/* 1. Define the WiFi credentials */ +#define WIFI_SSID "WIFI_AP" +#define WIFI_PASSWORD "WIFI_PASSWORD" + +/* 2. If work with RTDB, define the RTDB URL */ +#define DATABASE_URL "URL" //.firebaseio.com or ..firebasedatabase.app + +/* 3. Define the Firebase Data object */ +FirebaseData fbdo; + +/* 4. Define the FirebaseAuth data for authentication data */ +FirebaseAuth auth; + +/* 5. Define the FirebaseConfig data for config data */ +FirebaseConfig config; + +unsigned long dataMillis = 0; +int count = 0; + +void setup() +{ + + Serial.begin(115200); + + WiFi.begin(WIFI_SSID, WIFI_PASSWORD); + Serial.print("Connecting to Wi-Fi"); + while (WiFi.status() != WL_CONNECTED) + { + Serial.print("."); + delay(300); + } + Serial.println(); + Serial.print("Connected with IP: "); + Serial.println(WiFi.localIP()); + Serial.println(); + + Serial.printf("Firebase Client v%s\n\n", FIREBASE_CLIENT_VERSION); + + /* Assign the RTDB URL */ + config.database_url = DATABASE_URL; + + Firebase.reconnectWiFi(true); + + /* Assign the callback function for the long running token generation task */ + config.token_status_callback = tokenStatusCallback; // see addons/TokenHelper.h + + // To refresh the token 5 minutes before expired + config.signer.preRefreshSeconds = 5 * 60; + + // Use refresh token and force token to refresh immediately + // Refresh token, Client ID and Client Secret are required for OAuth2.0 token refreshing. + // The Client ID and Client Secret can be taken from https://console.developers.google.com/apis/credentials + + Firebase.setAccessToken(&config, "" /* set access token to empty to refresh token immediately */, 3600 /* expiry time */, "" /* refresh token */, "" /* client id */, "" /* client secret */); + + // Or refresh token manually + // Firebase.refreshToken(&config); + + Firebase.begin(&config, &auth); +} + +void loop() +{ + + // Firebase.ready() should be called repeatedly to handle authentication tasks. + + if (millis() - dataMillis > 5000 && Firebase.ready()) + { + dataMillis = millis(); + Serial.printf("Set int... %s\n", Firebase.RTDB.setInt(&fbdo, "/test/int", count++) ? "ok" : fbdo.errorReason().c_str()); + } +} diff --git a/examples/Authentications/SignInWithRefreshIDToken/SignInWithRefreshIDToken.ino b/examples/Authentications/SignInWithRefreshIDToken/SignInWithRefreshIDToken.ino index 85e3c628d..440a13994 100644 --- a/examples/Authentications/SignInWithRefreshIDToken/SignInWithRefreshIDToken.ino +++ b/examples/Authentications/SignInWithRefreshIDToken/SignInWithRefreshIDToken.ino @@ -1,115 +1,115 @@ - -/** - * Created by K. Suwatchai (Mobizt) - * - * Email: k_suwatchai@hotmail.com - * - * Github: https://github.com/mobizt/Firebase-ESP-Client - * - * Copyright (c) 2022 mobizt - * - */ - -/* This example shows how to re-authenticate using the refresh token generated from other app. */ - -#if defined(ESP32) -#include -#elif defined(ESP8266) -#include -#endif - -#include - -// Provide the token generation process info. -#include - -// Provide the RTDB payload printing info and other helper functions. -#include - -/* 1. Define the WiFi credentials */ -#define WIFI_SSID "WIFI_AP" -#define WIFI_PASSWORD "WIFI_PASSWORD" - -/** 2. Define the API key - * - * The API key (required) can be obtained since you created the project and set up - * the Authentication in Firebase console. Then you will get the API key from - * Firebase project Web API key in Project settings, on General tab should show the - * Web API Key. - * - * You may need to enable the Identity provider at https://console.cloud.google.com/customer-identity/providers - * Select your project, click at ENABLE IDENTITY PLATFORM button. - * The API key also available by click at the link APPLICATION SETUP DETAILS. - * - */ -#define API_KEY "API_KEY" - -/* 3. If work with RTDB, define the RTDB URL */ -#define DATABASE_URL "URL" //.firebaseio.com or ..firebasedatabase.app - -/* 4. Define the Firebase Data object */ -FirebaseData fbdo; - -/* 5. Define the FirebaseAuth data for authentication data */ -FirebaseAuth auth; - -/* 6. Define the FirebaseConfig data for config data */ -FirebaseConfig config; - -unsigned long dataMillis = 0; -int count = 0; - -void setup() -{ - - Serial.begin(115200); - - WiFi.begin(WIFI_SSID, WIFI_PASSWORD); - Serial.print("Connecting to Wi-Fi"); - while (WiFi.status() != WL_CONNECTED) - { - Serial.print("."); - delay(300); - } - Serial.println(); - Serial.print("Connected with IP: "); - Serial.println(WiFi.localIP()); - Serial.println(); - - Serial.printf("Firebase Client v%s\n\n", FIREBASE_CLIENT_VERSION); - - /* Assign the API key (required) */ - config.api_key = API_KEY; - - /* Assign the RTDB URL */ - config.database_url = DATABASE_URL; - - Firebase.reconnectWiFi(true); - - /* Assign the callback function for the long running token generation task */ - config.token_status_callback = tokenStatusCallback; // see addons/TokenHelper.h - - // To refresh the token 5 minutes before expired - config.signer.preRefreshSeconds = 5 * 60; - - // Use refresh token and force token to refresh immediately - // Refresh token is required for id token refreshing. - Firebase.setIdToken(&config, "" /* set id token to empty to refresh token immediately */ , 3600 /* expiry time */, ""); - - // Or refresh token manually - // Firebase.refreshToken(&config); - - Firebase.begin(&config, &auth); -} - -void loop() -{ - - // Firebase.ready() should be called repeatedly to handle authentication tasks. - - if (millis() - dataMillis > 5000 && Firebase.ready()) - { - dataMillis = millis(); - Serial.printf("Set int... %s\n", Firebase.RTDB.setInt(&fbdo, "/test/int", count++) ? "ok" : fbdo.errorReason().c_str()); - } -} + +/** + * Created by K. Suwatchai (Mobizt) + * + * Email: k_suwatchai@hotmail.com + * + * Github: https://github.com/mobizt/Firebase-ESP-Client + * + * Copyright (c) 2023 mobizt + * + */ + +/* This example shows how to re-authenticate using the refresh token generated from other app. */ + +#if defined(ESP32) +#include +#elif defined(ESP8266) +#include +#endif + +#include + +// Provide the token generation process info. +#include + +// Provide the RTDB payload printing info and other helper functions. +#include + +/* 1. Define the WiFi credentials */ +#define WIFI_SSID "WIFI_AP" +#define WIFI_PASSWORD "WIFI_PASSWORD" + +/** 2. Define the API key + * + * The API key (required) can be obtained since you created the project and set up + * the Authentication in Firebase console. Then you will get the API key from + * Firebase project Web API key in Project settings, on General tab should show the + * Web API Key. + * + * You may need to enable the Identity provider at https://console.cloud.google.com/customer-identity/providers + * Select your project, click at ENABLE IDENTITY PLATFORM button. + * The API key also available by click at the link APPLICATION SETUP DETAILS. + * + */ +#define API_KEY "API_KEY" + +/* 3. If work with RTDB, define the RTDB URL */ +#define DATABASE_URL "URL" //.firebaseio.com or ..firebasedatabase.app + +/* 4. Define the Firebase Data object */ +FirebaseData fbdo; + +/* 5. Define the FirebaseAuth data for authentication data */ +FirebaseAuth auth; + +/* 6. Define the FirebaseConfig data for config data */ +FirebaseConfig config; + +unsigned long dataMillis = 0; +int count = 0; + +void setup() +{ + + Serial.begin(115200); + + WiFi.begin(WIFI_SSID, WIFI_PASSWORD); + Serial.print("Connecting to Wi-Fi"); + while (WiFi.status() != WL_CONNECTED) + { + Serial.print("."); + delay(300); + } + Serial.println(); + Serial.print("Connected with IP: "); + Serial.println(WiFi.localIP()); + Serial.println(); + + Serial.printf("Firebase Client v%s\n\n", FIREBASE_CLIENT_VERSION); + + /* Assign the API key (required) */ + config.api_key = API_KEY; + + /* Assign the RTDB URL */ + config.database_url = DATABASE_URL; + + Firebase.reconnectWiFi(true); + + /* Assign the callback function for the long running token generation task */ + config.token_status_callback = tokenStatusCallback; // see addons/TokenHelper.h + + // To refresh the token 5 minutes before expired + config.signer.preRefreshSeconds = 5 * 60; + + // Use refresh token and force token to refresh immediately + // Refresh token is required for id token refreshing. + Firebase.setIdToken(&config, "" /* set id token to empty to refresh token immediately */ , 3600 /* expiry time */, ""); + + // Or refresh token manually + // Firebase.refreshToken(&config); + + Firebase.begin(&config, &auth); +} + +void loop() +{ + + // Firebase.ready() should be called repeatedly to handle authentication tasks. + + if (millis() - dataMillis > 5000 && Firebase.ready()) + { + dataMillis = millis(); + Serial.printf("Set int... %s\n", Firebase.RTDB.setInt(&fbdo, "/test/int", count++) ? "ok" : fbdo.errorReason().c_str()); + } +} diff --git a/examples/Authentications/TestMode/TestMode.ino b/examples/Authentications/TestMode/TestMode.ino index 7dcc5cdc1..d95b0f699 100644 --- a/examples/Authentications/TestMode/TestMode.ino +++ b/examples/Authentications/TestMode/TestMode.ino @@ -6,7 +6,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/Authentications/UserManagement/ResetPassword/ResetPassword.ino b/examples/Authentications/UserManagement/ResetPassword/ResetPassword.ino index f8bc7513c..872603e0d 100644 --- a/examples/Authentications/UserManagement/ResetPassword/ResetPassword.ino +++ b/examples/Authentications/UserManagement/ResetPassword/ResetPassword.ino @@ -6,7 +6,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/Authentications/UserManagement/SendVerification/SendVerification.ino b/examples/Authentications/UserManagement/SendVerification/SendVerification.ino index 365ca0938..f029fadf0 100644 --- a/examples/Authentications/UserManagement/SendVerification/SendVerification.ino +++ b/examples/Authentications/UserManagement/SendVerification/SendVerification.ino @@ -6,7 +6,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/Authentications/UserManagement/Signup/Signup.ino b/examples/Authentications/UserManagement/Signup/Signup.ino index 69d73467c..f3a365f66 100644 --- a/examples/Authentications/UserManagement/Signup/Signup.ino +++ b/examples/Authentications/UserManagement/Signup/Signup.ino @@ -6,7 +6,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/CloudFunctions/CallFunction/CallFunction.ino b/examples/CloudFunctions/CallFunction/CallFunction.ino index eb4f75511..76ef449de 100644 --- a/examples/CloudFunctions/CallFunction/CallFunction.ino +++ b/examples/CloudFunctions/CallFunction/CallFunction.ino @@ -6,7 +6,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/CloudFunctions/CreateFunction/CreateFunctionFromSources/CreateFunctionFromSources.ino b/examples/CloudFunctions/CreateFunction/CreateFunctionFromSources/CreateFunctionFromSources.ino index cf7dd7ab0..a3cc14312 100644 --- a/examples/CloudFunctions/CreateFunction/CreateFunctionFromSources/CreateFunctionFromSources.ino +++ b/examples/CloudFunctions/CreateFunction/CreateFunctionFromSources/CreateFunctionFromSources.ino @@ -6,7 +6,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/CloudFunctions/CreateFunction/CreateFunctionWithCallback/CreateFunctionWithCallback.ino b/examples/CloudFunctions/CreateFunction/CreateFunctionWithCallback/CreateFunctionWithCallback.ino index 41098b25a..b31cb2b44 100644 --- a/examples/CloudFunctions/CreateFunction/CreateFunctionWithCallback/CreateFunctionWithCallback.ino +++ b/examples/CloudFunctions/CreateFunction/CreateFunctionWithCallback/CreateFunctionWithCallback.ino @@ -6,7 +6,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/CloudFunctions/CreateFunction/CreateFunctionWithEventTrigger/CreateFunctionWithEventTrigger.ino b/examples/CloudFunctions/CreateFunction/CreateFunctionWithEventTrigger/CreateFunctionWithEventTrigger.ino index 822c1f017..f88c44050 100644 --- a/examples/CloudFunctions/CreateFunction/CreateFunctionWithEventTrigger/CreateFunctionWithEventTrigger.ino +++ b/examples/CloudFunctions/CreateFunction/CreateFunctionWithEventTrigger/CreateFunctionWithEventTrigger.ino @@ -6,7 +6,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/CloudFunctions/CreateFunction/CreateFunctionWithReturnStatus/CreateFunctionWithReturnStatus.ino b/examples/CloudFunctions/CreateFunction/CreateFunctionWithReturnStatus/CreateFunctionWithReturnStatus.ino index 6dde4ece6..9c89585e0 100644 --- a/examples/CloudFunctions/CreateFunction/CreateFunctionWithReturnStatus/CreateFunctionWithReturnStatus.ino +++ b/examples/CloudFunctions/CreateFunction/CreateFunctionWithReturnStatus/CreateFunctionWithReturnStatus.ino @@ -6,7 +6,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/CloudFunctions/CreateFunction/DeployAutoZipFunction/DeployAutoZipFunction.ino b/examples/CloudFunctions/CreateFunction/DeployAutoZipFunction/DeployAutoZipFunction.ino index d73e5d1fc..0d6d57267 100644 --- a/examples/CloudFunctions/CreateFunction/DeployAutoZipFunction/DeployAutoZipFunction.ino +++ b/examples/CloudFunctions/CreateFunction/DeployAutoZipFunction/DeployAutoZipFunction.ino @@ -6,7 +6,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/CloudFunctions/DeleteFunction/DeleteFunction.ino b/examples/CloudFunctions/DeleteFunction/DeleteFunction.ino index f9e996d87..a30d4a2f7 100644 --- a/examples/CloudFunctions/DeleteFunction/DeleteFunction.ino +++ b/examples/CloudFunctions/DeleteFunction/DeleteFunction.ino @@ -6,7 +6,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/CloudFunctions/DownloadFunction/DownloadFunction.ino b/examples/CloudFunctions/DownloadFunction/DownloadFunction.ino index aef60e793..fe54e67f8 100644 --- a/examples/CloudFunctions/DownloadFunction/DownloadFunction.ino +++ b/examples/CloudFunctions/DownloadFunction/DownloadFunction.ino @@ -6,7 +6,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/CloudFunctions/IAMPolicy/CreatePolicy/CreatePolicy.ino b/examples/CloudFunctions/IAMPolicy/CreatePolicy/CreatePolicy.ino index 34486daad..06541c8f3 100644 --- a/examples/CloudFunctions/IAMPolicy/CreatePolicy/CreatePolicy.ino +++ b/examples/CloudFunctions/IAMPolicy/CreatePolicy/CreatePolicy.ino @@ -6,7 +6,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/CloudFunctions/IAMPolicy/GetPolicy/GetPolicy.ino b/examples/CloudFunctions/IAMPolicy/GetPolicy/GetPolicy.ino index 5bf7d6d5c..859498519 100644 --- a/examples/CloudFunctions/IAMPolicy/GetPolicy/GetPolicy.ino +++ b/examples/CloudFunctions/IAMPolicy/GetPolicy/GetPolicy.ino @@ -6,7 +6,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/CloudFunctions/IAMPolicy/SetPolicy/SetPolicy.ino b/examples/CloudFunctions/IAMPolicy/SetPolicy/SetPolicy.ino index 25b89abff..a1475e515 100644 --- a/examples/CloudFunctions/IAMPolicy/SetPolicy/SetPolicy.ino +++ b/examples/CloudFunctions/IAMPolicy/SetPolicy/SetPolicy.ino @@ -6,7 +6,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/CloudFunctions/ListFunctions/ListFunctions.ino b/examples/CloudFunctions/ListFunctions/ListFunctions.ino index 83a28a5d2..b593ce61b 100644 --- a/examples/CloudFunctions/ListFunctions/ListFunctions.ino +++ b/examples/CloudFunctions/ListFunctions/ListFunctions.ino @@ -6,7 +6,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/CloudFunctions/PatchFunction/PatchFunction.ino b/examples/CloudFunctions/PatchFunction/PatchFunction.ino index a75b5e5d0..4dd378a2e 100644 --- a/examples/CloudFunctions/PatchFunction/PatchFunction.ino +++ b/examples/CloudFunctions/PatchFunction/PatchFunction.ino @@ -6,7 +6,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/ExternalClient/RTDB/Ethernet/ESP32/Basic/Basic.ino b/examples/ExternalClient/RTDB/Ethernet/ESP32/Basic/Basic.ino index 9fed37b0a..b14f07bf6 100644 --- a/examples/ExternalClient/RTDB/Ethernet/ESP32/Basic/Basic.ino +++ b/examples/ExternalClient/RTDB/Ethernet/ESP32/Basic/Basic.ino @@ -1,221 +1,221 @@ - -/** - * Created by K. Suwatchai (Mobizt) - * - * Email: k_suwatchai@hotmail.com - * - * Github: https://github.com/mobizt/Firebase-ESP-Client - * - * Copyright (c) 2022 mobizt - * - */ - -/** This example shows the basic RTDB usage with external Client. - * This example used ESP32 and WIZnet W5500 (Etherner) devices which ESP_SSLClient will be used as the external Client. - * - * Don't gorget to define this in FirebaseFS.h - * #define FB_ENABLE_EXTERNAL_CLIENT - */ - -#include - -// Provide the token generation process info. -#include - -// Provide the RTDB payload printing info and other helper functions. -#include - -// https://github.com/arduino-libraries/Ethernet -#include - -// https://github.com/mobizt/ESP_SSLClient -#include - -// For NTP time client -#include "MB_NTP.h" - -// For the following credentials, see examples/Authentications/SignInAsUser/EmailPassword/EmailPassword.ino - -/* 1. Define the API Key */ -#define API_KEY "API_KEY" - -/* 2. Define the RTDB URL */ -#define DATABASE_URL "URL" //.firebaseio.com or ..firebasedatabase.app - -/* 3. Define the user Email and password that alreadey registerd or added in your project */ -#define USER_EMAIL "USER_EMAIL" -#define USER_PASSWORD "USER_PASSWORD" - -/* 4. Defined the Ethernet module connection */ -#define WIZNET_RESET_PIN 26 // Connect W5500 Reset pin to GPIO 26 of ESP32 -#define WIZNET_CS_PIN 5 // Connect W5500 CS pin to GPIO 5 of ESP32 -#define WIZNET_MISO_PIN 19 // Connect W5500 MISO pin to GPIO 19 of ESP32 -#define WIZNET_MOSI_PIN 23 // Connect W5500 MOSI pin to GPIO 23 of ESP32 -#define WIZNET_SCLK_PIN 18 // Connect W5500 SCLK pin to GPIO 18 of ESP32 - -/* 5. Define MAC */ -uint8_t Eth_MAC[] = {0x02, 0xF0, 0x0D, 0xBE, 0xEF, 0x01}; - -/* 6. Define IP (Optional) */ -IPAddress Eth_IP(192, 168, 1, 104); - -// Define Firebase Data object -FirebaseData fbdo; - -FirebaseAuth auth; -FirebaseConfig config; - -unsigned long sendDataPrevMillis = 0; - -int count = 0; - -volatile bool dataChanged = false; - -// Define the basic client -// The network interface devices that can be used to handle SSL data should -// have large memory buffer up to 1k - 2k or more, otherwise the SSL/TLS handshake -// will fail. -EthernetClient basic_client; - -// This is the wrapper client that utilized the basic client for io and -// provides the mean for the data encryption and decryption before sending to or after read from the io. -// The most probable failures are related to the basic client itself that may not provide the buffer -// that large enough for SSL data. -// The SSL client can do nothing for this case, you should increase the basic client buffer memory. -ESP_SSLClient ssl_client; - -// For NTP client -EthernetUDP udpClient; - -MB_NTP ntpClient(&udpClient, "pool.ntp.org" /* NTP host */, 123 /* NTP port */, 0 /* timezone offset in seconds */); - -uint32_t timestamp = 0; - -void ResetEthernet() -{ - Serial.println("Resetting WIZnet W5500 Ethernet Board... "); - pinMode(WIZNET_RESET_PIN, OUTPUT); - digitalWrite(WIZNET_RESET_PIN, HIGH); - delay(200); - digitalWrite(WIZNET_RESET_PIN, LOW); - delay(50); - digitalWrite(WIZNET_RESET_PIN, HIGH); - delay(200); -} - -void networkConnection() -{ - Ethernet.init(WIZNET_CS_PIN); - - ResetEthernet(); - - Serial.println("Starting Ethernet connection..."); - Ethernet.begin(Eth_MAC); - - unsigned long to = millis(); - - while (Ethernet.linkStatus() == LinkOFF || millis() - to < 2000) - { - delay(100); - } - - if (Ethernet.linkStatus() == LinkON) - { - Serial.print("Connected with IP "); - Serial.println(Ethernet.localIP()); - } - else - { - Serial.println("Can't connected"); - } -} - -// Define the callback function to handle server status acknowledgement -void networkStatusRequestCallback() -{ - // Set the network status - fbdo.setNetworkStatus(Ethernet.linkStatus() == LinkON); -} - -// Define the callback function to handle server connection -void tcpConnectionRequestCallback(const char *host, int port) -{ - - // You may need to set the system timestamp to use for - // auth token expiration checking. - - if (timestamp == 0) - { - timestamp = ntpClient.getTime(2000 /* wait 2000 ms */); - - if (timestamp > 0) - Firebase.setSystemTime(timestamp); - } - - Serial.print("Connecting to server via external Client... "); - if (!ssl_client.connect(host, port)) - { - Serial.println("failed."); - return; - } - Serial.println("success."); -} - -void setup() -{ - - Serial.begin(115200); - - networkConnection(); - - Serial_Printf("Firebase Client v%s\n\n", FIREBASE_CLIENT_VERSION); - - /* Assign the basic Client (Ethernet) pointer to the basic Client */ - ssl_client.setClient(&basic_client); - - /* Similar to WiFiClientSecure */ - ssl_client.setInsecure(); - - /* Assign the api key (required) */ - config.api_key = API_KEY; - - /* Assign the user sign in credentials */ - auth.user.email = USER_EMAIL; - auth.user.password = USER_PASSWORD; - - /* Assign the RTDB URL (required) */ - config.database_url = DATABASE_URL; - - /* Assign the callback function for the long running token generation task */ - config.token_status_callback = tokenStatusCallback; // see addons/TokenHelper.h - - /* fbdo.setExternalClient and fbdo.setExternalClientCallbacks must be called before Firebase.begin */ - - /* Assign the pointer to global defined external SSL Client object */ - fbdo.setExternalClient(&ssl_client); - - /* Assign the required callback functions */ - fbdo.setExternalClientCallbacks(tcpConnectionRequestCallback, networkConnection, networkStatusRequestCallback); - - // Comment or pass false value when WiFi reconnection will control by your code or third party library - Firebase.reconnectWiFi(true); - - Firebase.setDoubleDigits(5); - - Firebase.begin(&config, &auth); -} - -void loop() -{ - - // Firebase.ready() should be called repeatedly to handle authentication tasks. - - if (Firebase.ready() && (millis() - sendDataPrevMillis > 15000 || sendDataPrevMillis == 0)) - { - sendDataPrevMillis = millis(); - - Serial_Printf("Set bool... %s\n", Firebase.RTDB.setBool(&fbdo, F("/test/bool"), count % 2 == 0) ? "ok" : fbdo.errorReason().c_str()); - - count++; - } -} + +/** + * Created by K. Suwatchai (Mobizt) + * + * Email: k_suwatchai@hotmail.com + * + * Github: https://github.com/mobizt/Firebase-ESP-Client + * + * Copyright (c) 2023 mobizt + * + */ + +/** This example shows the basic RTDB usage with external Client. + * This example used ESP32 and WIZnet W5500 (Etherner) devices which ESP_SSLClient will be used as the external Client. + * + * Don't gorget to define this in FirebaseFS.h + * #define FB_ENABLE_EXTERNAL_CLIENT + */ + +#include + +// Provide the token generation process info. +#include + +// Provide the RTDB payload printing info and other helper functions. +#include + +// https://github.com/arduino-libraries/Ethernet +#include + +// https://github.com/mobizt/ESP_SSLClient +#include + +// For NTP time client +#include "MB_NTP.h" + +// For the following credentials, see examples/Authentications/SignInAsUser/EmailPassword/EmailPassword.ino + +/* 1. Define the API Key */ +#define API_KEY "API_KEY" + +/* 2. Define the RTDB URL */ +#define DATABASE_URL "URL" //.firebaseio.com or ..firebasedatabase.app + +/* 3. Define the user Email and password that alreadey registerd or added in your project */ +#define USER_EMAIL "USER_EMAIL" +#define USER_PASSWORD "USER_PASSWORD" + +/* 4. Defined the Ethernet module connection */ +#define WIZNET_RESET_PIN 26 // Connect W5500 Reset pin to GPIO 26 of ESP32 +#define WIZNET_CS_PIN 5 // Connect W5500 CS pin to GPIO 5 of ESP32 +#define WIZNET_MISO_PIN 19 // Connect W5500 MISO pin to GPIO 19 of ESP32 +#define WIZNET_MOSI_PIN 23 // Connect W5500 MOSI pin to GPIO 23 of ESP32 +#define WIZNET_SCLK_PIN 18 // Connect W5500 SCLK pin to GPIO 18 of ESP32 + +/* 5. Define MAC */ +uint8_t Eth_MAC[] = {0x02, 0xF0, 0x0D, 0xBE, 0xEF, 0x01}; + +/* 6. Define IP (Optional) */ +IPAddress Eth_IP(192, 168, 1, 104); + +// Define Firebase Data object +FirebaseData fbdo; + +FirebaseAuth auth; +FirebaseConfig config; + +unsigned long sendDataPrevMillis = 0; + +int count = 0; + +volatile bool dataChanged = false; + +// Define the basic client +// The network interface devices that can be used to handle SSL data should +// have large memory buffer up to 1k - 2k or more, otherwise the SSL/TLS handshake +// will fail. +EthernetClient basic_client; + +// This is the wrapper client that utilized the basic client for io and +// provides the mean for the data encryption and decryption before sending to or after read from the io. +// The most probable failures are related to the basic client itself that may not provide the buffer +// that large enough for SSL data. +// The SSL client can do nothing for this case, you should increase the basic client buffer memory. +ESP_SSLClient ssl_client; + +// For NTP client +EthernetUDP udpClient; + +MB_NTP ntpClient(&udpClient, "pool.ntp.org" /* NTP host */, 123 /* NTP port */, 0 /* timezone offset in seconds */); + +uint32_t timestamp = 0; + +void ResetEthernet() +{ + Serial.println("Resetting WIZnet W5500 Ethernet Board... "); + pinMode(WIZNET_RESET_PIN, OUTPUT); + digitalWrite(WIZNET_RESET_PIN, HIGH); + delay(200); + digitalWrite(WIZNET_RESET_PIN, LOW); + delay(50); + digitalWrite(WIZNET_RESET_PIN, HIGH); + delay(200); +} + +void networkConnection() +{ + Ethernet.init(WIZNET_CS_PIN); + + ResetEthernet(); + + Serial.println("Starting Ethernet connection..."); + Ethernet.begin(Eth_MAC); + + unsigned long to = millis(); + + while (Ethernet.linkStatus() == LinkOFF || millis() - to < 2000) + { + delay(100); + } + + if (Ethernet.linkStatus() == LinkON) + { + Serial.print("Connected with IP "); + Serial.println(Ethernet.localIP()); + } + else + { + Serial.println("Can't connected"); + } +} + +// Define the callback function to handle server status acknowledgement +void networkStatusRequestCallback() +{ + // Set the network status + fbdo.setNetworkStatus(Ethernet.linkStatus() == LinkON); +} + +// Define the callback function to handle server connection +void tcpConnectionRequestCallback(const char *host, int port) +{ + + // You may need to set the system timestamp to use for + // auth token expiration checking. + + if (timestamp == 0) + { + timestamp = ntpClient.getTime(2000 /* wait 2000 ms */); + + if (timestamp > 0) + Firebase.setSystemTime(timestamp); + } + + Serial.print("Connecting to server via external Client... "); + if (!ssl_client.connect(host, port)) + { + Serial.println("failed."); + return; + } + Serial.println("success."); +} + +void setup() +{ + + Serial.begin(115200); + + networkConnection(); + + Serial_Printf("Firebase Client v%s\n\n", FIREBASE_CLIENT_VERSION); + + /* Assign the basic Client (Ethernet) pointer to the basic Client */ + ssl_client.setClient(&basic_client); + + /* Similar to WiFiClientSecure */ + ssl_client.setInsecure(); + + /* Assign the api key (required) */ + config.api_key = API_KEY; + + /* Assign the user sign in credentials */ + auth.user.email = USER_EMAIL; + auth.user.password = USER_PASSWORD; + + /* Assign the RTDB URL (required) */ + config.database_url = DATABASE_URL; + + /* Assign the callback function for the long running token generation task */ + config.token_status_callback = tokenStatusCallback; // see addons/TokenHelper.h + + /* fbdo.setExternalClient and fbdo.setExternalClientCallbacks must be called before Firebase.begin */ + + /* Assign the pointer to global defined external SSL Client object */ + fbdo.setExternalClient(&ssl_client); + + /* Assign the required callback functions */ + fbdo.setExternalClientCallbacks(tcpConnectionRequestCallback, networkConnection, networkStatusRequestCallback); + + // Comment or pass false value when WiFi reconnection will control by your code or third party library + Firebase.reconnectWiFi(true); + + Firebase.setDoubleDigits(5); + + Firebase.begin(&config, &auth); +} + +void loop() +{ + + // Firebase.ready() should be called repeatedly to handle authentication tasks. + + if (Firebase.ready() && (millis() - sendDataPrevMillis > 15000 || sendDataPrevMillis == 0)) + { + sendDataPrevMillis = millis(); + + Serial_Printf("Set bool... %s\n", Firebase.RTDB.setBool(&fbdo, F("/test/bool"), count % 2 == 0) ? "ok" : fbdo.errorReason().c_str()); + + count++; + } +} diff --git a/examples/ExternalClient/RTDB/Ethernet/ESP32/StreamCallback/StreamCallback.ino b/examples/ExternalClient/RTDB/Ethernet/ESP32/StreamCallback/StreamCallback.ino index f101e1ed8..196681a76 100644 --- a/examples/ExternalClient/RTDB/Ethernet/ESP32/StreamCallback/StreamCallback.ino +++ b/examples/ExternalClient/RTDB/Ethernet/ESP32/StreamCallback/StreamCallback.ino @@ -1,305 +1,305 @@ -/** - * Created by K. Suwatchai (Mobizt) - * - * Email: k_suwatchai@hotmail.com - * - * Github: https://github.com/mobizt/Firebase-ESP-Client - * - * Copyright (c) 2022 mobizt - * - */ - -/** This example shows the RTDB data changed notification with external Client. - * This example used ESP32 and WIZnet W5500 (Etherner) devices which ESP_SSLClient will be used as the external Client. - * - * Don't gorget to define this in FirebaseFS.h - * #define FB_ENABLE_EXTERNAL_CLIENT - */ - -#include - -// Provide the token generation process info. -#include - -// Provide the RTDB payload printing info and other helper functions. -#include - -//https://github.com/arduino-libraries/Ethernet -#include - -// https://github.com/mobizt/ESP_SSLClient -#include - -// For NTP time client -#include "MB_NTP.h" - -// For the following credentials, see examples/Authentications/SignInAsUser/EmailPassword/EmailPassword.ino - -/* 1. Define the API Key */ -#define API_KEY "API_KEY" - -/* 2. Define the RTDB URL */ -#define DATABASE_URL "URL" //.firebaseio.com or ..firebasedatabase.app - -/* 3. Define the user Email and password that alreadey registerd or added in your project */ -#define USER_EMAIL "USER_EMAIL" -#define USER_PASSWORD "USER_PASSWORD" - -/* 4. Defined the Ethernet module connection */ -#define WIZNET_RESET_PIN 26 // Connect W5500 Reset pin to GPIO 26 of ESP32 -#define WIZNET_CS_PIN 5 // Connect W5500 CS pin to GPIO 5 of ESP32 -#define WIZNET_MISO_PIN 19 // Connect W5500 MISO pin to GPIO 19 of ESP32 -#define WIZNET_MOSI_PIN 23 // Connect W5500 MOSI pin to GPIO 23 of ESP32 -#define WIZNET_SCLK_PIN 18 // Connect W5500 SCLK pin to GPIO 18 of ESP32 - -/* 5. Define MAC */ -uint8_t Eth_MAC[] = {0x02, 0xF0, 0x0D, 0xBE, 0xEF, 0x01}; - -/* 6. Define IP (Optional) */ -IPAddress Eth_IP(192, 168, 1, 104); - -// Define Firebase Data object -FirebaseData stream; -FirebaseData fbdo; - -FirebaseAuth auth; -FirebaseConfig config; - -unsigned long sendDataPrevMillis = 0; - -int count = 0; - -volatile bool dataChanged = false; - -// Define the basic client -// The network interface devices that can be used to handle SSL data should -// have large memory buffer up to 1k - 2k or more, otherwise the SSL/TLS handshake -// will fail. -EthernetClient basic_client1; - -EthernetClient basic_client2; - -// This is the wrapper client that utilized the basic client for io and -// provides the mean for the data encryption and decryption before sending to or after read from the io. -// The most probable failures are related to the basic client itself that may not provide the buffer -// that large enough for SSL data. -// The SSL client can do nothing for this case, you should increase the basic client buffer memory. -ESP_SSLClient ssl_client1; - -ESP_SSLClient ssl_client2; - -// For NTP client -EthernetUDP udpClient; - -MB_NTP ntpClient(&udpClient, "pool.ntp.org" /* NTP host */, 123 /* NTP port */, 0 /* timezone offset in seconds */); - -uint32_t timestamp = 0; - -void ResetEthernet() -{ - Serial.println("Resetting WIZnet W5500 Ethernet Board... "); - pinMode(WIZNET_RESET_PIN, OUTPUT); - digitalWrite(WIZNET_RESET_PIN, HIGH); - delay(200); - digitalWrite(WIZNET_RESET_PIN, LOW); - delay(50); - digitalWrite(WIZNET_RESET_PIN, HIGH); - delay(200); -} - -void networkConnection() -{ - Ethernet.init(WIZNET_CS_PIN); - - ResetEthernet(); - - Serial.println("Starting Ethernet connection..."); - Ethernet.begin(Eth_MAC); - - unsigned long to = millis(); - - while (Ethernet.linkStatus() == LinkOFF || millis() - to < 2000) - { - delay(100); - } - - if (Ethernet.linkStatus() == LinkON) - { - Serial.print("Connected with IP "); - Serial.println(Ethernet.localIP()); - } - else - { - Serial.println("Can't connected"); - } -} - -// Define the callback function to handle server status acknowledgement -void networkStatusRequestCallback() -{ - // Set the network status - fbdo.setNetworkStatus(Ethernet.linkStatus() == LinkON); - stream.setNetworkStatus(Ethernet.linkStatus() == LinkON); -} - -// Define the callback function to handle server connection -void tcpConnectionRequestCallback1(const char *host, int port) -{ - - // You may need to set the system timestamp to use for - // auth token expiration checking. - - if (timestamp == 0) - { - timestamp = ntpClient.getTime(2000 /* wait 2000 ms */); - - if (timestamp > 0) - Firebase.setSystemTime(timestamp); - } - - Serial.print("Connecting to server via external Client... "); - if (!ssl_client1.connect(host, port)) - { - Serial.println("failed."); - return; - } - Serial.println("success."); -} - -// Define the callback function to handle server connection -void tcpConnectionRequestCallback2(const char *host, int port) -{ - - // You may need to set the system timestamp to use for - // auth token expiration checking. - - if (timestamp == 0) - { - timestamp = ntpClient.getTime(2000 /* wait 2000 ms */); - - if (timestamp > 0) - Firebase.setSystemTime(timestamp); - } - - Serial.print("Connecting to server via external Client2... "); - if (!ssl_client2.connect(host, port)) - { - Serial.println("failed."); - return; - } - Serial.println("success."); -} - -void streamCallback(FirebaseStream data) -{ - Serial_Printf("sream path, %s\nevent path, %s\ndata type, %s\nevent type, %s\n\n", - data.streamPath().c_str(), - data.dataPath().c_str(), - data.dataType().c_str(), - data.eventType().c_str()); - printResult(data); // see addons/RTDBHelper.h - Serial.println(); - - // This is the size of stream payload received (current and max value) - // Max payload size is the payload size under the stream path since the stream connected - // and read once and will not update until stream reconnection takes place. - // This max value will be zero as no payload received in case of ESP8266 which - // BearSSL reserved Rx buffer size is less than the actual stream payload. - Serial_Printf("Received stream payload size: %d (Max. %d)\n\n", data.payloadLength(), data.maxPayloadLength()); - - // Due to limited of stack memory, do not perform any task that used large memory here especially starting connect to server. - // Just set this flag and check it status later. - dataChanged = true; -} - -void streamTimeoutCallback(bool timeout) -{ - if (timeout) - Serial.println("stream timed out, resuming...\n"); - - if (!stream.httpConnected()) - Serial_Printf("error code: %d, reason: %s\n\n", stream.httpCode(), stream.errorReason().c_str()); -} - -void setup() -{ - - Serial.begin(115200); - - networkConnection(); - - Serial_Printf("Firebase Client v%s\n\n", FIREBASE_CLIENT_VERSION); - - /* Assign the basic Client (Ethernet) pointer to the basic Client */ - ssl_client1.setClient(&basic_client1); - - /* Similar to WiFiClientSecure */ - ssl_client1.setInsecure(); - - /* Assign the basic Client (Ethernet) pointer to the basic Client */ - ssl_client2.setClient(&basic_client2); - - /* Similar to WiFiClientSecure */ - ssl_client2.setInsecure(); - - /* Assign the api key (required) */ - config.api_key = API_KEY; - - /* Assign the user sign in credentials */ - auth.user.email = USER_EMAIL; - auth.user.password = USER_PASSWORD; - - /* Assign the RTDB URL (required) */ - config.database_url = DATABASE_URL; - - /* Assign the callback function for the long running token generation task */ - config.token_status_callback = tokenStatusCallback; // see addons/TokenHelper.h - - /* fbdo.setExternalClient and fbdo.setExternalClientCallbacks must be called before Firebase.begin */ - - /* Assign the pointer to global defined external SSL Client object */ - fbdo.setExternalClient(&ssl_client1); - - /* Assign the required callback functions */ - fbdo.setExternalClientCallbacks(tcpConnectionRequestCallback1, networkConnection, networkStatusRequestCallback); - - /* Assign the pointer to global defined external SSL Client object */ - stream.setExternalClient(&ssl_client2); - - /* Assign the required callback functions */ - stream.setExternalClientCallbacks(tcpConnectionRequestCallback2, networkConnection, networkStatusRequestCallback); - - // Comment or pass false value when WiFi reconnection will control by your code or third party library - Firebase.reconnectWiFi(true); - - Firebase.setDoubleDigits(5); - - Firebase.begin(&config, &auth); - - if (!Firebase.RTDB.beginStream(&stream, "/test/stream/data")) - Serial_Printf("sream begin error, %s\n\n", stream.errorReason().c_str()); - - Firebase.RTDB.setStreamCallback(&stream, streamCallback, streamTimeoutCallback); -} - -void loop() -{ - - // Firebase.ready() should be called repeatedly to handle authentication tasks. - - if (Firebase.ready() && (millis() - sendDataPrevMillis > 15000 || sendDataPrevMillis == 0)) - { - sendDataPrevMillis = millis(); - count++; - FirebaseJson json; - json.add("data", "hello"); - json.add("num", count); - Serial_Printf("Set json... %s\n\n", Firebase.RTDB.setJSON(&fbdo, "/test/stream/data/json", &json) ? "ok" : fbdo.errorReason().c_str()); - } - - if (dataChanged) - { - dataChanged = false; - // When stream data is available, do anything here... - } -} +/** + * Created by K. Suwatchai (Mobizt) + * + * Email: k_suwatchai@hotmail.com + * + * Github: https://github.com/mobizt/Firebase-ESP-Client + * + * Copyright (c) 2023 mobizt + * + */ + +/** This example shows the RTDB data changed notification with external Client. + * This example used ESP32 and WIZnet W5500 (Etherner) devices which ESP_SSLClient will be used as the external Client. + * + * Don't gorget to define this in FirebaseFS.h + * #define FB_ENABLE_EXTERNAL_CLIENT + */ + +#include + +// Provide the token generation process info. +#include + +// Provide the RTDB payload printing info and other helper functions. +#include + +//https://github.com/arduino-libraries/Ethernet +#include + +// https://github.com/mobizt/ESP_SSLClient +#include + +// For NTP time client +#include "MB_NTP.h" + +// For the following credentials, see examples/Authentications/SignInAsUser/EmailPassword/EmailPassword.ino + +/* 1. Define the API Key */ +#define API_KEY "API_KEY" + +/* 2. Define the RTDB URL */ +#define DATABASE_URL "URL" //.firebaseio.com or ..firebasedatabase.app + +/* 3. Define the user Email and password that alreadey registerd or added in your project */ +#define USER_EMAIL "USER_EMAIL" +#define USER_PASSWORD "USER_PASSWORD" + +/* 4. Defined the Ethernet module connection */ +#define WIZNET_RESET_PIN 26 // Connect W5500 Reset pin to GPIO 26 of ESP32 +#define WIZNET_CS_PIN 5 // Connect W5500 CS pin to GPIO 5 of ESP32 +#define WIZNET_MISO_PIN 19 // Connect W5500 MISO pin to GPIO 19 of ESP32 +#define WIZNET_MOSI_PIN 23 // Connect W5500 MOSI pin to GPIO 23 of ESP32 +#define WIZNET_SCLK_PIN 18 // Connect W5500 SCLK pin to GPIO 18 of ESP32 + +/* 5. Define MAC */ +uint8_t Eth_MAC[] = {0x02, 0xF0, 0x0D, 0xBE, 0xEF, 0x01}; + +/* 6. Define IP (Optional) */ +IPAddress Eth_IP(192, 168, 1, 104); + +// Define Firebase Data object +FirebaseData stream; +FirebaseData fbdo; + +FirebaseAuth auth; +FirebaseConfig config; + +unsigned long sendDataPrevMillis = 0; + +int count = 0; + +volatile bool dataChanged = false; + +// Define the basic client +// The network interface devices that can be used to handle SSL data should +// have large memory buffer up to 1k - 2k or more, otherwise the SSL/TLS handshake +// will fail. +EthernetClient basic_client1; + +EthernetClient basic_client2; + +// This is the wrapper client that utilized the basic client for io and +// provides the mean for the data encryption and decryption before sending to or after read from the io. +// The most probable failures are related to the basic client itself that may not provide the buffer +// that large enough for SSL data. +// The SSL client can do nothing for this case, you should increase the basic client buffer memory. +ESP_SSLClient ssl_client1; + +ESP_SSLClient ssl_client2; + +// For NTP client +EthernetUDP udpClient; + +MB_NTP ntpClient(&udpClient, "pool.ntp.org" /* NTP host */, 123 /* NTP port */, 0 /* timezone offset in seconds */); + +uint32_t timestamp = 0; + +void ResetEthernet() +{ + Serial.println("Resetting WIZnet W5500 Ethernet Board... "); + pinMode(WIZNET_RESET_PIN, OUTPUT); + digitalWrite(WIZNET_RESET_PIN, HIGH); + delay(200); + digitalWrite(WIZNET_RESET_PIN, LOW); + delay(50); + digitalWrite(WIZNET_RESET_PIN, HIGH); + delay(200); +} + +void networkConnection() +{ + Ethernet.init(WIZNET_CS_PIN); + + ResetEthernet(); + + Serial.println("Starting Ethernet connection..."); + Ethernet.begin(Eth_MAC); + + unsigned long to = millis(); + + while (Ethernet.linkStatus() == LinkOFF || millis() - to < 2000) + { + delay(100); + } + + if (Ethernet.linkStatus() == LinkON) + { + Serial.print("Connected with IP "); + Serial.println(Ethernet.localIP()); + } + else + { + Serial.println("Can't connected"); + } +} + +// Define the callback function to handle server status acknowledgement +void networkStatusRequestCallback() +{ + // Set the network status + fbdo.setNetworkStatus(Ethernet.linkStatus() == LinkON); + stream.setNetworkStatus(Ethernet.linkStatus() == LinkON); +} + +// Define the callback function to handle server connection +void tcpConnectionRequestCallback1(const char *host, int port) +{ + + // You may need to set the system timestamp to use for + // auth token expiration checking. + + if (timestamp == 0) + { + timestamp = ntpClient.getTime(2000 /* wait 2000 ms */); + + if (timestamp > 0) + Firebase.setSystemTime(timestamp); + } + + Serial.print("Connecting to server via external Client... "); + if (!ssl_client1.connect(host, port)) + { + Serial.println("failed."); + return; + } + Serial.println("success."); +} + +// Define the callback function to handle server connection +void tcpConnectionRequestCallback2(const char *host, int port) +{ + + // You may need to set the system timestamp to use for + // auth token expiration checking. + + if (timestamp == 0) + { + timestamp = ntpClient.getTime(2000 /* wait 2000 ms */); + + if (timestamp > 0) + Firebase.setSystemTime(timestamp); + } + + Serial.print("Connecting to server via external Client2... "); + if (!ssl_client2.connect(host, port)) + { + Serial.println("failed."); + return; + } + Serial.println("success."); +} + +void streamCallback(FirebaseStream data) +{ + Serial_Printf("sream path, %s\nevent path, %s\ndata type, %s\nevent type, %s\n\n", + data.streamPath().c_str(), + data.dataPath().c_str(), + data.dataType().c_str(), + data.eventType().c_str()); + printResult(data); // see addons/RTDBHelper.h + Serial.println(); + + // This is the size of stream payload received (current and max value) + // Max payload size is the payload size under the stream path since the stream connected + // and read once and will not update until stream reconnection takes place. + // This max value will be zero as no payload received in case of ESP8266 which + // BearSSL reserved Rx buffer size is less than the actual stream payload. + Serial_Printf("Received stream payload size: %d (Max. %d)\n\n", data.payloadLength(), data.maxPayloadLength()); + + // Due to limited of stack memory, do not perform any task that used large memory here especially starting connect to server. + // Just set this flag and check it status later. + dataChanged = true; +} + +void streamTimeoutCallback(bool timeout) +{ + if (timeout) + Serial.println("stream timed out, resuming...\n"); + + if (!stream.httpConnected()) + Serial_Printf("error code: %d, reason: %s\n\n", stream.httpCode(), stream.errorReason().c_str()); +} + +void setup() +{ + + Serial.begin(115200); + + networkConnection(); + + Serial_Printf("Firebase Client v%s\n\n", FIREBASE_CLIENT_VERSION); + + /* Assign the basic Client (Ethernet) pointer to the basic Client */ + ssl_client1.setClient(&basic_client1); + + /* Similar to WiFiClientSecure */ + ssl_client1.setInsecure(); + + /* Assign the basic Client (Ethernet) pointer to the basic Client */ + ssl_client2.setClient(&basic_client2); + + /* Similar to WiFiClientSecure */ + ssl_client2.setInsecure(); + + /* Assign the api key (required) */ + config.api_key = API_KEY; + + /* Assign the user sign in credentials */ + auth.user.email = USER_EMAIL; + auth.user.password = USER_PASSWORD; + + /* Assign the RTDB URL (required) */ + config.database_url = DATABASE_URL; + + /* Assign the callback function for the long running token generation task */ + config.token_status_callback = tokenStatusCallback; // see addons/TokenHelper.h + + /* fbdo.setExternalClient and fbdo.setExternalClientCallbacks must be called before Firebase.begin */ + + /* Assign the pointer to global defined external SSL Client object */ + fbdo.setExternalClient(&ssl_client1); + + /* Assign the required callback functions */ + fbdo.setExternalClientCallbacks(tcpConnectionRequestCallback1, networkConnection, networkStatusRequestCallback); + + /* Assign the pointer to global defined external SSL Client object */ + stream.setExternalClient(&ssl_client2); + + /* Assign the required callback functions */ + stream.setExternalClientCallbacks(tcpConnectionRequestCallback2, networkConnection, networkStatusRequestCallback); + + // Comment or pass false value when WiFi reconnection will control by your code or third party library + Firebase.reconnectWiFi(true); + + Firebase.setDoubleDigits(5); + + Firebase.begin(&config, &auth); + + if (!Firebase.RTDB.beginStream(&stream, "/test/stream/data")) + Serial_Printf("sream begin error, %s\n\n", stream.errorReason().c_str()); + + Firebase.RTDB.setStreamCallback(&stream, streamCallback, streamTimeoutCallback); +} + +void loop() +{ + + // Firebase.ready() should be called repeatedly to handle authentication tasks. + + if (Firebase.ready() && (millis() - sendDataPrevMillis > 15000 || sendDataPrevMillis == 0)) + { + sendDataPrevMillis = millis(); + count++; + FirebaseJson json; + json.add("data", "hello"); + json.add("num", count); + Serial_Printf("Set json... %s\n\n", Firebase.RTDB.setJSON(&fbdo, "/test/stream/data/json", &json) ? "ok" : fbdo.errorReason().c_str()); + } + + if (dataChanged) + { + dataChanged = false; + // When stream data is available, do anything here... + } +} diff --git a/examples/ExternalClient/RTDB/Ethernet/ESP8266/Basic/Basic.ino b/examples/ExternalClient/RTDB/Ethernet/ESP8266/Basic/Basic.ino index d256a54f5..545cfae4e 100644 --- a/examples/ExternalClient/RTDB/Ethernet/ESP8266/Basic/Basic.ino +++ b/examples/ExternalClient/RTDB/Ethernet/ESP8266/Basic/Basic.ino @@ -1,222 +1,222 @@ - -/** - * Created by K. Suwatchai (Mobizt) - * - * Email: k_suwatchai@hotmail.com - * - * Github: https://github.com/mobizt/Firebase-ESP8266 - * - * Copyright (c) 2022 mobizt - * - */ - -/** This example shows the basic RTDB usage with external Client. - * This example used ESP8266 and WIZnet W5500 (Ethernet) devices which ESP_SSLClient will be used as the external Client. - * - * Even the example for Ethernet that supports ENC28J60 and WIZnet W55xx is available at RTB/BasicEthernet/ESP8266/ESP8266.ino, - * this example will show how to use external SSL Client that supports other network interfaces e.g. GSMClient and especially - * EthernetClient in this example. - * - * Don't gorget to define this in FirebaseFS.h - * #define FB_ENABLE_EXTERNAL_CLIENT - */ - -#include - -// Provide the token generation process info. -#include - -// Provide the RTDB payload printing info and other helper functions. -#include - -// https://github.com/mobizt/ESP_SSLClient -#include - -#include - -// For NTP time client -#include "MB_NTP.h" - -// For the following credentials, see examples/Authentications/SignInAsUser/EmailPassword/EmailPassword.ino - -/* 1. Define the API Key */ -#define API_KEY "API_KEY" - -/* 2. Define the RTDB URL */ -#define DATABASE_URL "URL" //.firebaseio.com or ..firebasedatabase.app - -/* 3. Define the user Email and password that alreadey registerd or added in your project */ -#define USER_EMAIL "USER_EMAIL" -#define USER_PASSWORD "USER_PASSWORD" - -/* 4. Defined the Ethernet module connection */ -#define WIZNET_RESET_PIN 5 // Connect W5500 Reset pin to GPIO 5 (D1) of ESP8266 -#define WIZNET_CS_PIN 4 // Connect W5500 CS pin to GPIO 4 (D2) of ESP8266 -#define WIZNET_MISO_PIN 12 // Connect W5500 MISO pin to GPIO 12 (D6) of ESP8266 -#define WIZNET_MOSI_PIN 13 // Connect W5500 MOSI pin to GPIO 13 (D7) of ESP8266 -#define WIZNET_SCLK_PIN 14 // Connect W5500 SCLK pin to GPIO 14 (D5) of ESP8266 - -/* 5. Define MAC */ -uint8_t Eth_MAC[] = {0x02, 0xF0, 0x0D, 0xBE, 0xEF, 0x01}; - -/* 6. Define IP (Optional) */ -IPAddress Eth_IP(192, 168, 1, 104); - -// Define Firebase Data object -FirebaseData fbdo; - -FirebaseAuth auth; -FirebaseConfig config; - -unsigned long sendDataPrevMillis = 0; - -int count = 0; - -// Define the basic client -// The network interface devices that can be used to handle SSL data should -// have large memory buffer up to 1k - 2k or more, otherwise the SSL/TLS handshake -// will fail. -EthernetClient basic_client; - -// This is the wrapper client that utilized the basic client for io and -// provides the mean for the data encryption and decryption before sending to or after read from the io. -// The most probable failures are related to the basic client itself that may not provide the buffer -// that large enough for SSL data. -// The SSL client can do nothing for this case, you should increase the basic client buffer memory. -ESP_SSLClient ssl_client; - -// For NTP client -EthernetUDP udpClient; - -MB_NTP ntpClient(&udpClient, "pool.ntp.org" /* NTP host */, 123 /* NTP port */, 0 /* timezone offset in seconds */); - -uint32_t timestamp = 0; - -void ResetEthernet() -{ - Serial.println("Resetting WIZnet W5500 Ethernet Board... "); - pinMode(WIZNET_RESET_PIN, OUTPUT); - digitalWrite(WIZNET_RESET_PIN, HIGH); - delay(200); - digitalWrite(WIZNET_RESET_PIN, LOW); - delay(50); - digitalWrite(WIZNET_RESET_PIN, HIGH); - delay(200); -} - -void networkConnection() -{ - Ethernet.init(WIZNET_CS_PIN); - - ResetEthernet(); - - Serial.println("Starting Ethernet connection..."); - Ethernet.begin(Eth_MAC); - - unsigned long to = millis(); - - while (Ethernet.linkStatus() == LinkOFF || millis() - to < 2000) - { - delay(100); - } - - if (Ethernet.linkStatus() == LinkON) - { - Serial.print("Connected with IP "); - Serial.println(Ethernet.localIP()); - } - else - { - Serial.println("Can't connected"); - } -} - -// Define the callback function to handle server status acknowledgement -void networkStatusRequestCallback() -{ - // Set the network status - fbdo.setNetworkStatus(Ethernet.linkStatus() == LinkON); -} - -// Define the callback function to handle server connection -void tcpConnectionRequestCallback(const char *host, int port) -{ - - // You may need to set the system timestamp to use for - // auth token expiration checking. - - if (timestamp == 0) - { - timestamp = ntpClient.getTime(2000 /* wait 2000 ms */); - - if (timestamp > 0) - Firebase.setSystemTime(timestamp); - } - - Serial.print("Connecting to server via external Client... "); - if (!ssl_client.connect(host, port)) - { - Serial.println("failed."); - return; - } - Serial.println("success."); -} - -void setup() -{ - - Serial.begin(115200); - - networkConnection(); - - Serial_Printf("Firebase Client v%s\n\n", FIREBASE_CLIENT_VERSION); - - /* Assign the basic Client (Ethernet) pointer to the basic Client */ - ssl_client.setClient(&basic_client); - - /* Similar to WiFiClientSecure */ - ssl_client.setInsecure(); - - /* Assign the api key (required) */ - config.api_key = API_KEY; - - /* Assign the user sign in credentials */ - auth.user.email = USER_EMAIL; - auth.user.password = USER_PASSWORD; - - /* Assign the RTDB URL (required) */ - config.database_url = DATABASE_URL; - - /* Assign the callback function for the long running token generation task */ - config.token_status_callback = tokenStatusCallback; // see addons/TokenHelper.h - - /* fbdo.setExternalClient and fbdo.setExternalClientCallbacks must be called before Firebase.begin */ - - /* Assign the pointer to global defined external SSL Client object */ - fbdo.setExternalClient(&ssl_client); - - /* Assign the required callback functions */ - fbdo.setExternalClientCallbacks(tcpConnectionRequestCallback, networkConnection, networkStatusRequestCallback); - - // Comment or pass false value when WiFi reconnection will control by your code or third party library - Firebase.reconnectWiFi(true); - - Firebase.setDoubleDigits(5); - - Firebase.begin(&config, &auth); -} - -void loop() -{ - - // Firebase.ready() should be called repeatedly to handle authentication tasks. - - if (Firebase.ready() && (millis() - sendDataPrevMillis > 15000 || sendDataPrevMillis == 0)) - { - sendDataPrevMillis = millis(); - - Serial_Printf("Set bool... %s\n", Firebase.RTDB.setBool(&fbdo, F("/test/bool"), count % 2 == 0) ? "ok" : fbdo.errorReason().c_str()); - - count++; - } -} + +/** + * Created by K. Suwatchai (Mobizt) + * + * Email: k_suwatchai@hotmail.com + * + * Github: https://github.com/mobizt/Firebase-ESP8266 + * + * Copyright (c) 2023 mobizt + * + */ + +/** This example shows the basic RTDB usage with external Client. + * This example used ESP8266 and WIZnet W5500 (Ethernet) devices which ESP_SSLClient will be used as the external Client. + * + * Even the example for Ethernet that supports ENC28J60 and WIZnet W55xx is available at RTB/BasicEthernet/ESP8266/ESP8266.ino, + * this example will show how to use external SSL Client that supports other network interfaces e.g. GSMClient and especially + * EthernetClient in this example. + * + * Don't gorget to define this in FirebaseFS.h + * #define FB_ENABLE_EXTERNAL_CLIENT + */ + +#include + +// Provide the token generation process info. +#include + +// Provide the RTDB payload printing info and other helper functions. +#include + +// https://github.com/mobizt/ESP_SSLClient +#include + +#include + +// For NTP time client +#include "MB_NTP.h" + +// For the following credentials, see examples/Authentications/SignInAsUser/EmailPassword/EmailPassword.ino + +/* 1. Define the API Key */ +#define API_KEY "API_KEY" + +/* 2. Define the RTDB URL */ +#define DATABASE_URL "URL" //.firebaseio.com or ..firebasedatabase.app + +/* 3. Define the user Email and password that alreadey registerd or added in your project */ +#define USER_EMAIL "USER_EMAIL" +#define USER_PASSWORD "USER_PASSWORD" + +/* 4. Defined the Ethernet module connection */ +#define WIZNET_RESET_PIN 5 // Connect W5500 Reset pin to GPIO 5 (D1) of ESP8266 +#define WIZNET_CS_PIN 4 // Connect W5500 CS pin to GPIO 4 (D2) of ESP8266 +#define WIZNET_MISO_PIN 12 // Connect W5500 MISO pin to GPIO 12 (D6) of ESP8266 +#define WIZNET_MOSI_PIN 13 // Connect W5500 MOSI pin to GPIO 13 (D7) of ESP8266 +#define WIZNET_SCLK_PIN 14 // Connect W5500 SCLK pin to GPIO 14 (D5) of ESP8266 + +/* 5. Define MAC */ +uint8_t Eth_MAC[] = {0x02, 0xF0, 0x0D, 0xBE, 0xEF, 0x01}; + +/* 6. Define IP (Optional) */ +IPAddress Eth_IP(192, 168, 1, 104); + +// Define Firebase Data object +FirebaseData fbdo; + +FirebaseAuth auth; +FirebaseConfig config; + +unsigned long sendDataPrevMillis = 0; + +int count = 0; + +// Define the basic client +// The network interface devices that can be used to handle SSL data should +// have large memory buffer up to 1k - 2k or more, otherwise the SSL/TLS handshake +// will fail. +EthernetClient basic_client; + +// This is the wrapper client that utilized the basic client for io and +// provides the mean for the data encryption and decryption before sending to or after read from the io. +// The most probable failures are related to the basic client itself that may not provide the buffer +// that large enough for SSL data. +// The SSL client can do nothing for this case, you should increase the basic client buffer memory. +ESP_SSLClient ssl_client; + +// For NTP client +EthernetUDP udpClient; + +MB_NTP ntpClient(&udpClient, "pool.ntp.org" /* NTP host */, 123 /* NTP port */, 0 /* timezone offset in seconds */); + +uint32_t timestamp = 0; + +void ResetEthernet() +{ + Serial.println("Resetting WIZnet W5500 Ethernet Board... "); + pinMode(WIZNET_RESET_PIN, OUTPUT); + digitalWrite(WIZNET_RESET_PIN, HIGH); + delay(200); + digitalWrite(WIZNET_RESET_PIN, LOW); + delay(50); + digitalWrite(WIZNET_RESET_PIN, HIGH); + delay(200); +} + +void networkConnection() +{ + Ethernet.init(WIZNET_CS_PIN); + + ResetEthernet(); + + Serial.println("Starting Ethernet connection..."); + Ethernet.begin(Eth_MAC); + + unsigned long to = millis(); + + while (Ethernet.linkStatus() == LinkOFF || millis() - to < 2000) + { + delay(100); + } + + if (Ethernet.linkStatus() == LinkON) + { + Serial.print("Connected with IP "); + Serial.println(Ethernet.localIP()); + } + else + { + Serial.println("Can't connected"); + } +} + +// Define the callback function to handle server status acknowledgement +void networkStatusRequestCallback() +{ + // Set the network status + fbdo.setNetworkStatus(Ethernet.linkStatus() == LinkON); +} + +// Define the callback function to handle server connection +void tcpConnectionRequestCallback(const char *host, int port) +{ + + // You may need to set the system timestamp to use for + // auth token expiration checking. + + if (timestamp == 0) + { + timestamp = ntpClient.getTime(2000 /* wait 2000 ms */); + + if (timestamp > 0) + Firebase.setSystemTime(timestamp); + } + + Serial.print("Connecting to server via external Client... "); + if (!ssl_client.connect(host, port)) + { + Serial.println("failed."); + return; + } + Serial.println("success."); +} + +void setup() +{ + + Serial.begin(115200); + + networkConnection(); + + Serial_Printf("Firebase Client v%s\n\n", FIREBASE_CLIENT_VERSION); + + /* Assign the basic Client (Ethernet) pointer to the basic Client */ + ssl_client.setClient(&basic_client); + + /* Similar to WiFiClientSecure */ + ssl_client.setInsecure(); + + /* Assign the api key (required) */ + config.api_key = API_KEY; + + /* Assign the user sign in credentials */ + auth.user.email = USER_EMAIL; + auth.user.password = USER_PASSWORD; + + /* Assign the RTDB URL (required) */ + config.database_url = DATABASE_URL; + + /* Assign the callback function for the long running token generation task */ + config.token_status_callback = tokenStatusCallback; // see addons/TokenHelper.h + + /* fbdo.setExternalClient and fbdo.setExternalClientCallbacks must be called before Firebase.begin */ + + /* Assign the pointer to global defined external SSL Client object */ + fbdo.setExternalClient(&ssl_client); + + /* Assign the required callback functions */ + fbdo.setExternalClientCallbacks(tcpConnectionRequestCallback, networkConnection, networkStatusRequestCallback); + + // Comment or pass false value when WiFi reconnection will control by your code or third party library + Firebase.reconnectWiFi(true); + + Firebase.setDoubleDigits(5); + + Firebase.begin(&config, &auth); +} + +void loop() +{ + + // Firebase.ready() should be called repeatedly to handle authentication tasks. + + if (Firebase.ready() && (millis() - sendDataPrevMillis > 15000 || sendDataPrevMillis == 0)) + { + sendDataPrevMillis = millis(); + + Serial_Printf("Set bool... %s\n", Firebase.RTDB.setBool(&fbdo, F("/test/bool"), count % 2 == 0) ? "ok" : fbdo.errorReason().c_str()); + + count++; + } +} diff --git a/examples/ExternalClient/RTDB/Ethernet/ESP8266/StreamCallback/StreamCallback.ino b/examples/ExternalClient/RTDB/Ethernet/ESP8266/StreamCallback/StreamCallback.ino index 5e376861d..64e50dd11 100644 --- a/examples/ExternalClient/RTDB/Ethernet/ESP8266/StreamCallback/StreamCallback.ino +++ b/examples/ExternalClient/RTDB/Ethernet/ESP8266/StreamCallback/StreamCallback.ino @@ -1,308 +1,308 @@ -/** - * Created by K. Suwatchai (Mobizt) - * - * Email: k_suwatchai@hotmail.com - * - * Github: https://github.com/mobizt/Firebase-ESP8266 - * - * Copyright (c) 2022 mobizt - * - */ - -/** This example shows the RTDB data changed notification with external Client. - * This example used ESP8266 and WIZnet W5500 (Ethernet) devices which ESP_SSLClient will be used as the external Client. - * - * Even the example for Ethernet that supports ENC28J60 and WIZnet W55xx is available at RTDB/BasicEthernet/ESP8266/ESP8266.ino, - * this example will show how to use external SSL Client that supports other network interfaces e.g. GSMClient and especially - * EthernetClient in this example. - * - * Don't gorget to define this in FirebaseFS.h - * #define FB_ENABLE_EXTERNAL_CLIENT - */ - -#include - -// Provide the token generation process info. -#include - -// Provide the RTDB payload printing info and other helper functions. -#include - -// https://github.com/mobizt/ESP_SSLClient -#include - -#include - -// For NTP time client -#include "MB_NTP.h" - -// For the following credentials, see examples/Authentications/SignInAsUser/EmailPassword/EmailPassword.ino - -/* 1. Define the API Key */ -#define API_KEY "API_KEY" - -/* 2. Define the RTDB URL */ -#define DATABASE_URL "URL" //.firebaseio.com or ..firebasedatabase.app - -/* 3. Define the user Email and password that alreadey registerd or added in your project */ -#define USER_EMAIL "USER_EMAIL" -#define USER_PASSWORD "USER_PASSWORD" - -/* 4. Defined the Ethernet module connection */ -#define WIZNET_RESET_PIN 5 // Connect W5500 Reset pin to GPIO 5 (D1) of ESP8266 -#define WIZNET_CS_PIN 4 // Connect W5500 CS pin to GPIO 4 (D2) of ESP8266 -#define WIZNET_MISO_PIN 12 // Connect W5500 MISO pin to GPIO 12 (D6) of ESP8266 -#define WIZNET_MOSI_PIN 13 // Connect W5500 MOSI pin to GPIO 13 (D7) of ESP8266 -#define WIZNET_SCLK_PIN 14 // Connect W5500 SCLK pin to GPIO 14 (D5) of ESP8266 - -/* 5. Define MAC */ -uint8_t Eth_MAC[] = {0x02, 0xF0, 0x0D, 0xBE, 0xEF, 0x01}; - -/* 6. Define IP (Optional) */ -IPAddress Eth_IP(192, 168, 1, 104); - -// Define Firebase Data object -FirebaseData stream; -FirebaseData fbdo; - -FirebaseAuth auth; -FirebaseConfig config; - -unsigned long sendDataPrevMillis = 0; - -int count = 0; - -volatile bool dataChanged = false; - -// Define the basic client -// The network interface devices that can be used to handle SSL data should -// have large memory buffer up to 1k - 2k or more, otherwise the SSL/TLS handshake -// will fail. -EthernetClient basic_client1; - -EthernetClient basic_client2; - -// This is the wrapper client that utilized the basic client for io and -// provides the mean for the data encryption and decryption before sending to or after read from the io. -// The most probable failures are related to the basic client itself that may not provide the buffer -// that large enough for SSL data. -// The SSL client can do nothing for this case, you should increase the basic client buffer memory. -ESP_SSLClient ssl_client1; - -ESP_SSLClient ssl_client2; - -// For NTP client -EthernetUDP udpClient; - -MB_NTP ntpClient(&udpClient, "pool.ntp.org" /* NTP host */, 123 /* NTP port */, 0 /* timezone offset in seconds */); - -uint32_t timestamp = 0; - -void ResetEthernet() -{ - Serial.println("Resetting WIZnet W5500 Ethernet Board... "); - pinMode(WIZNET_RESET_PIN, OUTPUT); - digitalWrite(WIZNET_RESET_PIN, HIGH); - delay(200); - digitalWrite(WIZNET_RESET_PIN, LOW); - delay(50); - digitalWrite(WIZNET_RESET_PIN, HIGH); - delay(200); -} - -void networkConnection() -{ - Ethernet.init(WIZNET_CS_PIN); - - ResetEthernet(); - - Serial.println("Starting Ethernet connection..."); - Ethernet.begin(Eth_MAC); - - unsigned long to = millis(); - - while (Ethernet.linkStatus() == LinkOFF || millis() - to < 2000) - { - delay(100); - } - - if (Ethernet.linkStatus() == LinkON) - { - Serial.print("Connected with IP "); - Serial.println(Ethernet.localIP()); - } - else - { - Serial.println("Can't connected"); - } -} - -// Define the callback function to handle server status acknowledgement -void networkStatusRequestCallback() -{ - // Set the network status - fbdo.setNetworkStatus(Ethernet.linkStatus() == LinkON); - stream.setNetworkStatus(Ethernet.linkStatus() == LinkON); -} - -// Define the callback function to handle server connection -void tcpConnectionRequestCallback1(const char *host, int port) -{ - - // You may need to set the system timestamp to use for - // auth token expiration checking. - - if (timestamp == 0) - { - timestamp = ntpClient.getTime(2000 /* wait 2000 ms */); - - if (timestamp > 0) - Firebase.setSystemTime(timestamp); - } - - Serial.print("Connecting to server via external Client... "); - if (!ssl_client1.connect(host, port)) - { - Serial.println("failed."); - return; - } - Serial.println("success."); -} - -// Define the callback function to handle server connection -void tcpConnectionRequestCallback2(const char *host, int port) -{ - - // You may need to set the system timestamp to use for - // auth token expiration checking. - - if (timestamp == 0) - { - timestamp = ntpClient.getTime(2000 /* wait 2000 ms */); - - if (timestamp > 0) - Firebase.setSystemTime(timestamp); - } - - Serial.print("Connecting to server via external Client2... "); - if (!ssl_client2.connect(host, port)) - { - Serial.println("failed."); - return; - } - Serial.println("success."); -} - -void streamCallback(FirebaseStream data) -{ - Serial_Printf("sream path, %s\nevent path, %s\ndata type, %s\nevent type, %s\n\n", - data.streamPath().c_str(), - data.dataPath().c_str(), - data.dataType().c_str(), - data.eventType().c_str()); - printResult(data); // see addons/RTDBHelper.h - Serial.println(); - - // This is the size of stream payload received (current and max value) - // Max payload size is the payload size under the stream path since the stream connected - // and read once and will not update until stream reconnection takes place. - // This max value will be zero as no payload received in case of ESP8266 which - // BearSSL reserved Rx buffer size is less than the actual stream payload. - Serial_Printf("Received stream payload size: %d (Max. %d)\n\n", data.payloadLength(), data.maxPayloadLength()); - - // Due to limited of stack memory, do not perform any task that used large memory here especially starting connect to server. - // Just set this flag and check it status later. - dataChanged = true; -} - -void streamTimeoutCallback(bool timeout) -{ - if (timeout) - Serial.println("stream timed out, resuming...\n"); - - if (!stream.httpConnected()) - Serial_Printf("error code: %d, reason: %s\n\n", stream.httpCode(), stream.errorReason().c_str()); -} - -void setup() -{ - - Serial.begin(115200); - - networkConnection(); - - Serial_Printf("Firebase Client v%s\n\n", FIREBASE_CLIENT_VERSION); - - /* Assign the basic Client (Ethernet) pointer to the basic Client */ - ssl_client1.setClient(&basic_client1); - - /* Similar to WiFiClientSecure */ - ssl_client1.setInsecure(); - - /* Assign the basic Client (Ethernet) pointer to the SSL Client */ - ssl_client2.setClient(&basic_client2); - - /* Similar to WiFiClientSecure */ - ssl_client2.setInsecure(); - - /* Assign the api key (required) */ - config.api_key = API_KEY; - - /* Assign the user sign in credentials */ - auth.user.email = USER_EMAIL; - auth.user.password = USER_PASSWORD; - - /* Assign the RTDB URL (required) */ - config.database_url = DATABASE_URL; - - /* Assign the callback function for the long running token generation task */ - config.token_status_callback = tokenStatusCallback; // see addons/TokenHelper.h - - /* fbdo.setExternalClient and fbdo.setExternalClientCallbacks must be called before Firebase.begin */ - - /* Assign the pointer to global defined external SSL Client object */ - fbdo.setExternalClient(&ssl_client1); - - /* Assign the required callback functions */ - fbdo.setExternalClientCallbacks(tcpConnectionRequestCallback1, networkConnection, networkStatusRequestCallback); - - /* Assign the pointer to global defined external SSL Client object */ - stream.setExternalClient(&ssl_client2); - - /* Assign the required callback functions */ - stream.setExternalClientCallbacks(tcpConnectionRequestCallback2, networkConnection, networkStatusRequestCallback); - - // Comment or pass false value when WiFi reconnection will control by your code or third party library - Firebase.reconnectWiFi(true); - - Firebase.setDoubleDigits(5); - - Firebase.begin(&config, &auth); - - if (!Firebase.RTDB.beginStream(&stream, "/test/stream/data")) - Serial_Printf("sream begin error, %s\n\n", stream.errorReason().c_str()); - - Firebase.RTDB.setStreamCallback(&stream, streamCallback, streamTimeoutCallback); -} - -void loop() -{ - - // Firebase.ready() should be called repeatedly to handle authentication tasks. - - if (Firebase.ready() && (millis() - sendDataPrevMillis > 15000 || sendDataPrevMillis == 0)) - { - sendDataPrevMillis = millis(); - count++; - FirebaseJson json; - json.add("data", "hello"); - json.add("num", count); - Serial_Printf("Set json... %s\n\n", Firebase.RTDB.setJSON(&fbdo, "/test/stream/data/json", &json) ? "ok" : fbdo.errorReason().c_str()); - } - - if (dataChanged) - { - dataChanged = false; - // When stream data is available, do anything here... - } -} +/** + * Created by K. Suwatchai (Mobizt) + * + * Email: k_suwatchai@hotmail.com + * + * Github: https://github.com/mobizt/Firebase-ESP8266 + * + * Copyright (c) 2023 mobizt + * + */ + +/** This example shows the RTDB data changed notification with external Client. + * This example used ESP8266 and WIZnet W5500 (Ethernet) devices which ESP_SSLClient will be used as the external Client. + * + * Even the example for Ethernet that supports ENC28J60 and WIZnet W55xx is available at RTDB/BasicEthernet/ESP8266/ESP8266.ino, + * this example will show how to use external SSL Client that supports other network interfaces e.g. GSMClient and especially + * EthernetClient in this example. + * + * Don't gorget to define this in FirebaseFS.h + * #define FB_ENABLE_EXTERNAL_CLIENT + */ + +#include + +// Provide the token generation process info. +#include + +// Provide the RTDB payload printing info and other helper functions. +#include + +// https://github.com/mobizt/ESP_SSLClient +#include + +#include + +// For NTP time client +#include "MB_NTP.h" + +// For the following credentials, see examples/Authentications/SignInAsUser/EmailPassword/EmailPassword.ino + +/* 1. Define the API Key */ +#define API_KEY "API_KEY" + +/* 2. Define the RTDB URL */ +#define DATABASE_URL "URL" //.firebaseio.com or ..firebasedatabase.app + +/* 3. Define the user Email and password that alreadey registerd or added in your project */ +#define USER_EMAIL "USER_EMAIL" +#define USER_PASSWORD "USER_PASSWORD" + +/* 4. Defined the Ethernet module connection */ +#define WIZNET_RESET_PIN 5 // Connect W5500 Reset pin to GPIO 5 (D1) of ESP8266 +#define WIZNET_CS_PIN 4 // Connect W5500 CS pin to GPIO 4 (D2) of ESP8266 +#define WIZNET_MISO_PIN 12 // Connect W5500 MISO pin to GPIO 12 (D6) of ESP8266 +#define WIZNET_MOSI_PIN 13 // Connect W5500 MOSI pin to GPIO 13 (D7) of ESP8266 +#define WIZNET_SCLK_PIN 14 // Connect W5500 SCLK pin to GPIO 14 (D5) of ESP8266 + +/* 5. Define MAC */ +uint8_t Eth_MAC[] = {0x02, 0xF0, 0x0D, 0xBE, 0xEF, 0x01}; + +/* 6. Define IP (Optional) */ +IPAddress Eth_IP(192, 168, 1, 104); + +// Define Firebase Data object +FirebaseData stream; +FirebaseData fbdo; + +FirebaseAuth auth; +FirebaseConfig config; + +unsigned long sendDataPrevMillis = 0; + +int count = 0; + +volatile bool dataChanged = false; + +// Define the basic client +// The network interface devices that can be used to handle SSL data should +// have large memory buffer up to 1k - 2k or more, otherwise the SSL/TLS handshake +// will fail. +EthernetClient basic_client1; + +EthernetClient basic_client2; + +// This is the wrapper client that utilized the basic client for io and +// provides the mean for the data encryption and decryption before sending to or after read from the io. +// The most probable failures are related to the basic client itself that may not provide the buffer +// that large enough for SSL data. +// The SSL client can do nothing for this case, you should increase the basic client buffer memory. +ESP_SSLClient ssl_client1; + +ESP_SSLClient ssl_client2; + +// For NTP client +EthernetUDP udpClient; + +MB_NTP ntpClient(&udpClient, "pool.ntp.org" /* NTP host */, 123 /* NTP port */, 0 /* timezone offset in seconds */); + +uint32_t timestamp = 0; + +void ResetEthernet() +{ + Serial.println("Resetting WIZnet W5500 Ethernet Board... "); + pinMode(WIZNET_RESET_PIN, OUTPUT); + digitalWrite(WIZNET_RESET_PIN, HIGH); + delay(200); + digitalWrite(WIZNET_RESET_PIN, LOW); + delay(50); + digitalWrite(WIZNET_RESET_PIN, HIGH); + delay(200); +} + +void networkConnection() +{ + Ethernet.init(WIZNET_CS_PIN); + + ResetEthernet(); + + Serial.println("Starting Ethernet connection..."); + Ethernet.begin(Eth_MAC); + + unsigned long to = millis(); + + while (Ethernet.linkStatus() == LinkOFF || millis() - to < 2000) + { + delay(100); + } + + if (Ethernet.linkStatus() == LinkON) + { + Serial.print("Connected with IP "); + Serial.println(Ethernet.localIP()); + } + else + { + Serial.println("Can't connected"); + } +} + +// Define the callback function to handle server status acknowledgement +void networkStatusRequestCallback() +{ + // Set the network status + fbdo.setNetworkStatus(Ethernet.linkStatus() == LinkON); + stream.setNetworkStatus(Ethernet.linkStatus() == LinkON); +} + +// Define the callback function to handle server connection +void tcpConnectionRequestCallback1(const char *host, int port) +{ + + // You may need to set the system timestamp to use for + // auth token expiration checking. + + if (timestamp == 0) + { + timestamp = ntpClient.getTime(2000 /* wait 2000 ms */); + + if (timestamp > 0) + Firebase.setSystemTime(timestamp); + } + + Serial.print("Connecting to server via external Client... "); + if (!ssl_client1.connect(host, port)) + { + Serial.println("failed."); + return; + } + Serial.println("success."); +} + +// Define the callback function to handle server connection +void tcpConnectionRequestCallback2(const char *host, int port) +{ + + // You may need to set the system timestamp to use for + // auth token expiration checking. + + if (timestamp == 0) + { + timestamp = ntpClient.getTime(2000 /* wait 2000 ms */); + + if (timestamp > 0) + Firebase.setSystemTime(timestamp); + } + + Serial.print("Connecting to server via external Client2... "); + if (!ssl_client2.connect(host, port)) + { + Serial.println("failed."); + return; + } + Serial.println("success."); +} + +void streamCallback(FirebaseStream data) +{ + Serial_Printf("sream path, %s\nevent path, %s\ndata type, %s\nevent type, %s\n\n", + data.streamPath().c_str(), + data.dataPath().c_str(), + data.dataType().c_str(), + data.eventType().c_str()); + printResult(data); // see addons/RTDBHelper.h + Serial.println(); + + // This is the size of stream payload received (current and max value) + // Max payload size is the payload size under the stream path since the stream connected + // and read once and will not update until stream reconnection takes place. + // This max value will be zero as no payload received in case of ESP8266 which + // BearSSL reserved Rx buffer size is less than the actual stream payload. + Serial_Printf("Received stream payload size: %d (Max. %d)\n\n", data.payloadLength(), data.maxPayloadLength()); + + // Due to limited of stack memory, do not perform any task that used large memory here especially starting connect to server. + // Just set this flag and check it status later. + dataChanged = true; +} + +void streamTimeoutCallback(bool timeout) +{ + if (timeout) + Serial.println("stream timed out, resuming...\n"); + + if (!stream.httpConnected()) + Serial_Printf("error code: %d, reason: %s\n\n", stream.httpCode(), stream.errorReason().c_str()); +} + +void setup() +{ + + Serial.begin(115200); + + networkConnection(); + + Serial_Printf("Firebase Client v%s\n\n", FIREBASE_CLIENT_VERSION); + + /* Assign the basic Client (Ethernet) pointer to the basic Client */ + ssl_client1.setClient(&basic_client1); + + /* Similar to WiFiClientSecure */ + ssl_client1.setInsecure(); + + /* Assign the basic Client (Ethernet) pointer to the SSL Client */ + ssl_client2.setClient(&basic_client2); + + /* Similar to WiFiClientSecure */ + ssl_client2.setInsecure(); + + /* Assign the api key (required) */ + config.api_key = API_KEY; + + /* Assign the user sign in credentials */ + auth.user.email = USER_EMAIL; + auth.user.password = USER_PASSWORD; + + /* Assign the RTDB URL (required) */ + config.database_url = DATABASE_URL; + + /* Assign the callback function for the long running token generation task */ + config.token_status_callback = tokenStatusCallback; // see addons/TokenHelper.h + + /* fbdo.setExternalClient and fbdo.setExternalClientCallbacks must be called before Firebase.begin */ + + /* Assign the pointer to global defined external SSL Client object */ + fbdo.setExternalClient(&ssl_client1); + + /* Assign the required callback functions */ + fbdo.setExternalClientCallbacks(tcpConnectionRequestCallback1, networkConnection, networkStatusRequestCallback); + + /* Assign the pointer to global defined external SSL Client object */ + stream.setExternalClient(&ssl_client2); + + /* Assign the required callback functions */ + stream.setExternalClientCallbacks(tcpConnectionRequestCallback2, networkConnection, networkStatusRequestCallback); + + // Comment or pass false value when WiFi reconnection will control by your code or third party library + Firebase.reconnectWiFi(true); + + Firebase.setDoubleDigits(5); + + Firebase.begin(&config, &auth); + + if (!Firebase.RTDB.beginStream(&stream, "/test/stream/data")) + Serial_Printf("sream begin error, %s\n\n", stream.errorReason().c_str()); + + Firebase.RTDB.setStreamCallback(&stream, streamCallback, streamTimeoutCallback); +} + +void loop() +{ + + // Firebase.ready() should be called repeatedly to handle authentication tasks. + + if (Firebase.ready() && (millis() - sendDataPrevMillis > 15000 || sendDataPrevMillis == 0)) + { + sendDataPrevMillis = millis(); + count++; + FirebaseJson json; + json.add("data", "hello"); + json.add("num", count); + Serial_Printf("Set json... %s\n\n", Firebase.RTDB.setJSON(&fbdo, "/test/stream/data/json", &json) ? "ok" : fbdo.errorReason().c_str()); + } + + if (dataChanged) + { + dataChanged = false; + // When stream data is available, do anything here... + } +} diff --git a/examples/ExternalClient/RTDB/Ethernet/Others/Basic/Basic.ino b/examples/ExternalClient/RTDB/Ethernet/Others/Basic/Basic.ino index 1201bb1ca..86b001c48 100644 --- a/examples/ExternalClient/RTDB/Ethernet/Others/Basic/Basic.ino +++ b/examples/ExternalClient/RTDB/Ethernet/Others/Basic/Basic.ino @@ -1,226 +1,226 @@ - -/** - * Created by K. Suwatchai (Mobizt) - * - * Email: k_suwatchai@hotmail.com - * - * Github: https://github.com/mobizt/Firebase-ESP-Client - * - * Copyright (c) 2022 mobizt - * - */ - -/** This example shows the basic RTDB usage with external Client. - * This example used your Arduino device and WIZnet W5500 (Ethernet) device which SSLClient https://github.com/OPEnSLab-OSU/SSLClient - * will be used as the external Client. - * - * This SSLClient, https://github.com/OPEnSLab-OSU/SSLClient can't use in ESP8266 device due to wdt reset error. - * - * Don't gorget to define this in FirebaseFS.h - * #define FB_ENABLE_EXTERNAL_CLIENT - */ - -#include - -// Provide the token generation process info. -#include - -// Provide the RTDB payload printing info and other helper functions. -#include - -#include - -/* 1. Install SSLClient library */ -// https://github.com/OPEnSLab-OSU/SSLClient -#include - -/* 2. Create Trus anchors for the server i.e. www.google.com */ -// https://github.com/OPEnSLab-OSU/SSLClient/blob/master/TrustAnchors.md -// or generate using this site https://openslab-osu.github.io/bearssl-certificate-utility/ -#include "trust_anchors.h" - -// For NTP time client -#include "MB_NTP.h" - -// For the following credentials, see examples/Authentications/SignInAsUser/EmailPassword/EmailPassword.ino - -/* 3. Define the API Key */ -#define API_KEY "API_KEY" - -/* 4. Define the RTDB URL */ -#define DATABASE_URL "URL" //.firebaseio.com or ..firebasedatabase.app - -/* 5. Define the user Email and password that alreadey registerd or added in your project */ -#define USER_EMAIL "USER_EMAIL" -#define USER_PASSWORD "USER_PASSWORD" - -/* 6. Defined the Ethernet module connection */ -#define WIZNET_RESET_PIN 26 // Connect W5500 Reset pin to GPIO 26 of ESP32 -#define WIZNET_CS_PIN 5 // Connect W5500 CS pin to GPIO 5 of ESP32 -#define WIZNET_MISO_PIN 19 // Connect W5500 MISO pin to GPIO 19 of ESP32 -#define WIZNET_MOSI_PIN 23 // Connect W5500 MOSI pin to GPIO 23 of ESP32 -#define WIZNET_SCLK_PIN 18 // Connect W5500 SCLK pin to GPIO 18 of ESP32 - -/* 7. Define the analog GPIO pin to pull random bytes from, used in seeding the RNG for SSLClient */ -const int analog_pin = 34; // ESP32 GPIO 34 (Analog pin) - -/* 8. Define MAC */ -uint8_t Eth_MAC[] = {0x02, 0xF0, 0x0D, 0xBE, 0xEF, 0x01}; - -/* 9. Define IP (Optional) */ -IPAddress Eth_IP(192, 168, 1, 104); - -// Define Firebase Data object -FirebaseData fbdo; - -FirebaseAuth auth; -FirebaseConfig config; - -unsigned long sendDataPrevMillis = 0; - -int count = 0; - -volatile bool dataChanged = false; - -// Define the basic client -// The network interface devices that can be used to handle SSL data should -// have large memory buffer up to 1k - 2k or more, otherwise the SSL/TLS handshake -// will fail. -EthernetClient basic_client; - -// This is the wrapper client that utilized the basic client for io and -// provides the mean for the data encryption and decryption before sending to or after read from the io. -// The most probable failures are related to the basic client itself that may not provide the buffer -// that large enough for SSL data. -// The SSL client can do nothing for this case, you should increase the basic client buffer memory. -SSLClient ssl_client(basic_client, TAs, (size_t)TAs_NUM, analog_pin); - -// For NTP client -EthernetUDP udpClient; - -MB_NTP ntpClient(&udpClient, "pool.ntp.org" /* NTP host */, 123 /* NTP port */, 0 /* timezone offset in seconds */); - -uint32_t timestamp = 0; - -void ResetEthernet() -{ - Serial.println("Resetting WIZnet W5500 Ethernet Board... "); - pinMode(WIZNET_RESET_PIN, OUTPUT); - digitalWrite(WIZNET_RESET_PIN, HIGH); - delay(200); - digitalWrite(WIZNET_RESET_PIN, LOW); - delay(50); - digitalWrite(WIZNET_RESET_PIN, HIGH); - delay(200); -} - -void networkConnection() -{ - Ethernet.init(WIZNET_CS_PIN); - - ResetEthernet(); - - Serial.println("Starting Ethernet connection..."); - Ethernet.begin(Eth_MAC); - - unsigned long to = millis(); - - while (Ethernet.linkStatus() == LinkOFF || millis() - to < 2000) - { - delay(100); - } - - if (Ethernet.linkStatus() == LinkON) - { - Serial.print("Connected with IP "); - Serial.println(Ethernet.localIP()); - } - else - { - Serial.println("Can't connected"); - } -} - -// Define the callback function to handle server status acknowledgement -void networkStatusRequestCallback() -{ - // Set the network status - fbdo.setNetworkStatus(Ethernet.linkStatus() == LinkON); -} - -// Define the callback function to handle server connection -void tcpConnectionRequestCallback(const char *host, int port) -{ - - // You may need to set the system timestamp to use for - // auth token expiration checking. - - if (timestamp == 0) - { - timestamp = ntpClient.getTime(2000 /* wait 2000 ms */); - - if (timestamp > 0) - Firebase.setSystemTime(timestamp); - } - - Serial.print("Connecting to server via external Client... "); - if (!ssl_client.connect(host, port)) - { - Serial.println("failed."); - return; - } - Serial.println("success."); -} - -void setup() -{ - - Serial.begin(115200); - - networkConnection(); - - Serial_Printf("Firebase Client v%s\n\n", FIREBASE_CLIENT_VERSION); - - /* Assign the api key (required) */ - config.api_key = API_KEY; - - /* Assign the user sign in credentials */ - auth.user.email = USER_EMAIL; - auth.user.password = USER_PASSWORD; - - /* Assign the RTDB URL (required) */ - config.database_url = DATABASE_URL; - - /* Assign the callback function for the long running token generation task */ - config.token_status_callback = tokenStatusCallback; // see addons/TokenHelper.h - - /* fbdo.setExternalClient and fbdo.setExternalClientCallbacks must be called before Firebase.begin */ - - /* Assign the pointer to global defined external SSL Client object */ - fbdo.setExternalClient(&ssl_client); - - /* Assign the required callback functions */ - fbdo.setExternalClientCallbacks(tcpConnectionRequestCallback, networkConnection, networkStatusRequestCallback); - - // Comment or pass false value when WiFi reconnection will control by your code or third party library - Firebase.reconnectWiFi(true); - - Firebase.setDoubleDigits(5); - - Firebase.begin(&config, &auth); -} - -void loop() -{ - - // Firebase.ready() should be called repeatedly to handle authentication tasks. - - if (Firebase.ready() && (millis() - sendDataPrevMillis > 15000 || sendDataPrevMillis == 0)) - { - sendDataPrevMillis = millis(); - - Serial_Printf("Set bool... %s\n", Firebase.RTDB.setBool(&fbdo, F("/test/bool"), count % 2 == 0) ? "ok" : fbdo.errorReason().c_str()); - - count++; - } + +/** + * Created by K. Suwatchai (Mobizt) + * + * Email: k_suwatchai@hotmail.com + * + * Github: https://github.com/mobizt/Firebase-ESP-Client + * + * Copyright (c) 2023 mobizt + * + */ + +/** This example shows the basic RTDB usage with external Client. + * This example used your Arduino device and WIZnet W5500 (Ethernet) device which SSLClient https://github.com/OPEnSLab-OSU/SSLClient + * will be used as the external Client. + * + * This SSLClient, https://github.com/OPEnSLab-OSU/SSLClient can't use in ESP8266 device due to wdt reset error. + * + * Don't gorget to define this in FirebaseFS.h + * #define FB_ENABLE_EXTERNAL_CLIENT + */ + +#include + +// Provide the token generation process info. +#include + +// Provide the RTDB payload printing info and other helper functions. +#include + +#include + +/* 1. Install SSLClient library */ +// https://github.com/OPEnSLab-OSU/SSLClient +#include + +/* 2. Create Trus anchors for the server i.e. www.google.com */ +// https://github.com/OPEnSLab-OSU/SSLClient/blob/master/TrustAnchors.md +// or generate using this site https://openslab-osu.github.io/bearssl-certificate-utility/ +#include "trust_anchors.h" + +// For NTP time client +#include "MB_NTP.h" + +// For the following credentials, see examples/Authentications/SignInAsUser/EmailPassword/EmailPassword.ino + +/* 3. Define the API Key */ +#define API_KEY "API_KEY" + +/* 4. Define the RTDB URL */ +#define DATABASE_URL "URL" //.firebaseio.com or ..firebasedatabase.app + +/* 5. Define the user Email and password that alreadey registerd or added in your project */ +#define USER_EMAIL "USER_EMAIL" +#define USER_PASSWORD "USER_PASSWORD" + +/* 6. Defined the Ethernet module connection */ +#define WIZNET_RESET_PIN 26 // Connect W5500 Reset pin to GPIO 26 of ESP32 +#define WIZNET_CS_PIN 5 // Connect W5500 CS pin to GPIO 5 of ESP32 +#define WIZNET_MISO_PIN 19 // Connect W5500 MISO pin to GPIO 19 of ESP32 +#define WIZNET_MOSI_PIN 23 // Connect W5500 MOSI pin to GPIO 23 of ESP32 +#define WIZNET_SCLK_PIN 18 // Connect W5500 SCLK pin to GPIO 18 of ESP32 + +/* 7. Define the analog GPIO pin to pull random bytes from, used in seeding the RNG for SSLClient */ +const int analog_pin = 34; // ESP32 GPIO 34 (Analog pin) + +/* 8. Define MAC */ +uint8_t Eth_MAC[] = {0x02, 0xF0, 0x0D, 0xBE, 0xEF, 0x01}; + +/* 9. Define IP (Optional) */ +IPAddress Eth_IP(192, 168, 1, 104); + +// Define Firebase Data object +FirebaseData fbdo; + +FirebaseAuth auth; +FirebaseConfig config; + +unsigned long sendDataPrevMillis = 0; + +int count = 0; + +volatile bool dataChanged = false; + +// Define the basic client +// The network interface devices that can be used to handle SSL data should +// have large memory buffer up to 1k - 2k or more, otherwise the SSL/TLS handshake +// will fail. +EthernetClient basic_client; + +// This is the wrapper client that utilized the basic client for io and +// provides the mean for the data encryption and decryption before sending to or after read from the io. +// The most probable failures are related to the basic client itself that may not provide the buffer +// that large enough for SSL data. +// The SSL client can do nothing for this case, you should increase the basic client buffer memory. +SSLClient ssl_client(basic_client, TAs, (size_t)TAs_NUM, analog_pin); + +// For NTP client +EthernetUDP udpClient; + +MB_NTP ntpClient(&udpClient, "pool.ntp.org" /* NTP host */, 123 /* NTP port */, 0 /* timezone offset in seconds */); + +uint32_t timestamp = 0; + +void ResetEthernet() +{ + Serial.println("Resetting WIZnet W5500 Ethernet Board... "); + pinMode(WIZNET_RESET_PIN, OUTPUT); + digitalWrite(WIZNET_RESET_PIN, HIGH); + delay(200); + digitalWrite(WIZNET_RESET_PIN, LOW); + delay(50); + digitalWrite(WIZNET_RESET_PIN, HIGH); + delay(200); +} + +void networkConnection() +{ + Ethernet.init(WIZNET_CS_PIN); + + ResetEthernet(); + + Serial.println("Starting Ethernet connection..."); + Ethernet.begin(Eth_MAC); + + unsigned long to = millis(); + + while (Ethernet.linkStatus() == LinkOFF || millis() - to < 2000) + { + delay(100); + } + + if (Ethernet.linkStatus() == LinkON) + { + Serial.print("Connected with IP "); + Serial.println(Ethernet.localIP()); + } + else + { + Serial.println("Can't connected"); + } +} + +// Define the callback function to handle server status acknowledgement +void networkStatusRequestCallback() +{ + // Set the network status + fbdo.setNetworkStatus(Ethernet.linkStatus() == LinkON); +} + +// Define the callback function to handle server connection +void tcpConnectionRequestCallback(const char *host, int port) +{ + + // You may need to set the system timestamp to use for + // auth token expiration checking. + + if (timestamp == 0) + { + timestamp = ntpClient.getTime(2000 /* wait 2000 ms */); + + if (timestamp > 0) + Firebase.setSystemTime(timestamp); + } + + Serial.print("Connecting to server via external Client... "); + if (!ssl_client.connect(host, port)) + { + Serial.println("failed."); + return; + } + Serial.println("success."); +} + +void setup() +{ + + Serial.begin(115200); + + networkConnection(); + + Serial_Printf("Firebase Client v%s\n\n", FIREBASE_CLIENT_VERSION); + + /* Assign the api key (required) */ + config.api_key = API_KEY; + + /* Assign the user sign in credentials */ + auth.user.email = USER_EMAIL; + auth.user.password = USER_PASSWORD; + + /* Assign the RTDB URL (required) */ + config.database_url = DATABASE_URL; + + /* Assign the callback function for the long running token generation task */ + config.token_status_callback = tokenStatusCallback; // see addons/TokenHelper.h + + /* fbdo.setExternalClient and fbdo.setExternalClientCallbacks must be called before Firebase.begin */ + + /* Assign the pointer to global defined external SSL Client object */ + fbdo.setExternalClient(&ssl_client); + + /* Assign the required callback functions */ + fbdo.setExternalClientCallbacks(tcpConnectionRequestCallback, networkConnection, networkStatusRequestCallback); + + // Comment or pass false value when WiFi reconnection will control by your code or third party library + Firebase.reconnectWiFi(true); + + Firebase.setDoubleDigits(5); + + Firebase.begin(&config, &auth); +} + +void loop() +{ + + // Firebase.ready() should be called repeatedly to handle authentication tasks. + + if (Firebase.ready() && (millis() - sendDataPrevMillis > 15000 || sendDataPrevMillis == 0)) + { + sendDataPrevMillis = millis(); + + Serial_Printf("Set bool... %s\n", Firebase.RTDB.setBool(&fbdo, F("/test/bool"), count % 2 == 0) ? "ok" : fbdo.errorReason().c_str()); + + count++; + } } \ No newline at end of file diff --git a/examples/ExternalClient/RTDB/WiFi/Basic/Basic.ino b/examples/ExternalClient/RTDB/WiFi/Basic/Basic.ino index d4ab2ffcd..efff0c0ec 100644 --- a/examples/ExternalClient/RTDB/WiFi/Basic/Basic.ino +++ b/examples/ExternalClient/RTDB/WiFi/Basic/Basic.ino @@ -1,162 +1,162 @@ - -/** - * Created by K. Suwatchai (Mobizt) - * - * Email: k_suwatchai@hotmail.com - * - * Github: https://github.com/mobizt/Firebase-ESP-Client - * - * Copyright (c) 2022 mobizt - * - */ - -/** This example shows the basic RTDB usage with external Client. - * This example used SAMD21 device and WiFiNINA as the external Client. - */ - -#if defined(ARDUINO_ARCH_SAMD) -#include -#endif - -#include - -// Provide the token generation process info. -#include - -// Provide the RTDB payload printing info and other helper functions. -#include - -/* 1. Define the WiFi credentials */ -#define WIFI_SSID "WIFI_AP" -#define WIFI_PASSWORD "WIFI_PASSWORD" - -// For the following credentials, see examples/Authentications/SignInAsUser/EmailPassword/EmailPassword.ino - -/* 2. Define the API Key */ -#define API_KEY "API_KEY" - -/* 3. Define the RTDB URL */ -#define DATABASE_URL "URL" //.firebaseio.com or ..firebasedatabase.app - -/* 4. Define the user Email and password that alreadey registerd or added in your project */ -#define USER_EMAIL "USER_EMAIL" -#define USER_PASSWORD "USER_PASSWORD" - -// Define Firebase Data object -FirebaseData fbdo; - -FirebaseAuth auth; -FirebaseConfig config; - -unsigned long sendDataPrevMillis = 0; - -unsigned long count = 0; - -WiFiSSLClient ssl_client; - -void networkConnection() -{ - // Reset the network connection - WiFi.disconnect(); - - WiFi.begin(WIFI_SSID, WIFI_PASSWORD); - Serial.print("Connecting to Wi-Fi"); - unsigned long ms = millis(); - while (WiFi.status() != WL_CONNECTED) - { - Serial.print("."); - delay(300); - if (millis() - ms >= 5000) - { - Serial.println(" failed!"); - return; - } - } - Serial.println(); - Serial_Printf("Connected with IP: "); - Serial.println(WiFi.localIP()); - Serial.println(); -} - -// Define the callback function to handle server status acknowledgement -void networkStatusRequestCallback() -{ - // Set the network status - fbdo.setNetworkStatus(WiFi.status() == WL_CONNECTED); -} - -// Define the callback function to handle server connection -void tcpConnectionRequestCallback(const char *host, int port) -{ - - // You may need to set the system timestamp to use for - // auth token expiration checking. - - Firebase.setSystemTime(WiFi.getTime()); - - Serial.print("Connecting to server via external Client... "); - if (!ssl_client.connect(host, port)) - { - Serial.println("failed."); - return; - } - Serial.println("success."); -} - -void setup() -{ - - Serial.begin(115200); - -#if defined(ARDUINO_ARCH_SAMD) - while (!Serial) - ; -#endif - - networkConnection(); - - Serial_Printf("Firebase Client v%s\n\n", FIREBASE_CLIENT_VERSION); - - /* Assign the api key (required) */ - config.api_key = API_KEY; - - /* Assign the user sign in credentials */ - auth.user.email = USER_EMAIL; - auth.user.password = USER_PASSWORD; - - /* Assign the RTDB URL (required) */ - config.database_url = DATABASE_URL; - - /* Assign the callback function for the long running token generation task */ - config.token_status_callback = tokenStatusCallback; // see addons/TokenHelper.h - - /* fbdo.setExternalClient and fbdo.setExternalClientCallbacks must be called before Firebase.begin */ - - /* Assign the pointer to global defined external SSL Client object */ - fbdo.setExternalClient(&ssl_client); - - /* Assign the required callback functions */ - fbdo.setExternalClientCallbacks(tcpConnectionRequestCallback, networkConnection, networkStatusRequestCallback); - - // Comment or pass false value when WiFi reconnection will control by your code or third party library - Firebase.reconnectWiFi(true); - - Firebase.setDoubleDigits(5); - - Firebase.begin(&config, &auth); -} - -void loop() -{ - - // Firebase.ready() should be called repeatedly to handle authentication tasks. - - if (Firebase.ready() && (millis() - sendDataPrevMillis > 15000 || sendDataPrevMillis == 0)) - { - sendDataPrevMillis = millis(); - - Serial_Printf("Set bool... %s\n", Firebase.RTDB.setBool(&fbdo, F("/test/bool"), count % 2 == 0) ? "ok" : fbdo.errorReason().c_str()); - - count++; - } -} + +/** + * Created by K. Suwatchai (Mobizt) + * + * Email: k_suwatchai@hotmail.com + * + * Github: https://github.com/mobizt/Firebase-ESP-Client + * + * Copyright (c) 2023 mobizt + * + */ + +/** This example shows the basic RTDB usage with external Client. + * This example used SAMD21 device and WiFiNINA as the external Client. + */ + +#if defined(ARDUINO_ARCH_SAMD) +#include +#endif + +#include + +// Provide the token generation process info. +#include + +// Provide the RTDB payload printing info and other helper functions. +#include + +/* 1. Define the WiFi credentials */ +#define WIFI_SSID "WIFI_AP" +#define WIFI_PASSWORD "WIFI_PASSWORD" + +// For the following credentials, see examples/Authentications/SignInAsUser/EmailPassword/EmailPassword.ino + +/* 2. Define the API Key */ +#define API_KEY "API_KEY" + +/* 3. Define the RTDB URL */ +#define DATABASE_URL "URL" //.firebaseio.com or ..firebasedatabase.app + +/* 4. Define the user Email and password that alreadey registerd or added in your project */ +#define USER_EMAIL "USER_EMAIL" +#define USER_PASSWORD "USER_PASSWORD" + +// Define Firebase Data object +FirebaseData fbdo; + +FirebaseAuth auth; +FirebaseConfig config; + +unsigned long sendDataPrevMillis = 0; + +unsigned long count = 0; + +WiFiSSLClient ssl_client; + +void networkConnection() +{ + // Reset the network connection + WiFi.disconnect(); + + WiFi.begin(WIFI_SSID, WIFI_PASSWORD); + Serial.print("Connecting to Wi-Fi"); + unsigned long ms = millis(); + while (WiFi.status() != WL_CONNECTED) + { + Serial.print("."); + delay(300); + if (millis() - ms >= 5000) + { + Serial.println(" failed!"); + return; + } + } + Serial.println(); + Serial_Printf("Connected with IP: "); + Serial.println(WiFi.localIP()); + Serial.println(); +} + +// Define the callback function to handle server status acknowledgement +void networkStatusRequestCallback() +{ + // Set the network status + fbdo.setNetworkStatus(WiFi.status() == WL_CONNECTED); +} + +// Define the callback function to handle server connection +void tcpConnectionRequestCallback(const char *host, int port) +{ + + // You may need to set the system timestamp to use for + // auth token expiration checking. + + Firebase.setSystemTime(WiFi.getTime()); + + Serial.print("Connecting to server via external Client... "); + if (!ssl_client.connect(host, port)) + { + Serial.println("failed."); + return; + } + Serial.println("success."); +} + +void setup() +{ + + Serial.begin(115200); + +#if defined(ARDUINO_ARCH_SAMD) + while (!Serial) + ; +#endif + + networkConnection(); + + Serial_Printf("Firebase Client v%s\n\n", FIREBASE_CLIENT_VERSION); + + /* Assign the api key (required) */ + config.api_key = API_KEY; + + /* Assign the user sign in credentials */ + auth.user.email = USER_EMAIL; + auth.user.password = USER_PASSWORD; + + /* Assign the RTDB URL (required) */ + config.database_url = DATABASE_URL; + + /* Assign the callback function for the long running token generation task */ + config.token_status_callback = tokenStatusCallback; // see addons/TokenHelper.h + + /* fbdo.setExternalClient and fbdo.setExternalClientCallbacks must be called before Firebase.begin */ + + /* Assign the pointer to global defined external SSL Client object */ + fbdo.setExternalClient(&ssl_client); + + /* Assign the required callback functions */ + fbdo.setExternalClientCallbacks(tcpConnectionRequestCallback, networkConnection, networkStatusRequestCallback); + + // Comment or pass false value when WiFi reconnection will control by your code or third party library + Firebase.reconnectWiFi(true); + + Firebase.setDoubleDigits(5); + + Firebase.begin(&config, &auth); +} + +void loop() +{ + + // Firebase.ready() should be called repeatedly to handle authentication tasks. + + if (Firebase.ready() && (millis() - sendDataPrevMillis > 15000 || sendDataPrevMillis == 0)) + { + sendDataPrevMillis = millis(); + + Serial_Printf("Set bool... %s\n", Firebase.RTDB.setBool(&fbdo, F("/test/bool"), count % 2 == 0) ? "ok" : fbdo.errorReason().c_str()); + + count++; + } +} diff --git a/examples/ExternalClient/RTDB/WiFi/StreamCallback/StreamCallback.ino b/examples/ExternalClient/RTDB/WiFi/StreamCallback/StreamCallback.ino index ec8daa130..12439a4ee 100644 --- a/examples/ExternalClient/RTDB/WiFi/StreamCallback/StreamCallback.ino +++ b/examples/ExternalClient/RTDB/WiFi/StreamCallback/StreamCallback.ino @@ -1,237 +1,237 @@ -/** - * Created by K. Suwatchai (Mobizt) - * - * Email: k_suwatchai@hotmail.com - * - * Github: https://github.com/mobizt/Firebase-ESP-Client - * - * Copyright (c) 2022 mobizt - * - */ - -/** This example shows the RTDB data changed notification with external Client. - * This example used SAMD21 device and WiFiNINA as the external Client. - */ - -#if defined(ARDUINO_ARCH_SAMD) -#include -#endif - -#include - -// Provide the token generation process info. -#include - -// Provide the RTDB payload printing info and other helper functions. -#include - -/* 1. Define the WiFi credentials */ -#define WIFI_SSID "WIFI_AP" -#define WIFI_PASSWORD "WIFI_PASSWORD" - -// For the following credentials, see examples/Authentications/SignInAsUser/EmailPassword/EmailPassword.ino - -/* 2. Define the API Key */ -#define API_KEY "API_KEY" - -/* 3. Define the RTDB URL */ -#define DATABASE_URL "URL" //.firebaseio.com or ..firebasedatabase.app - -/* 4. Define the user Email and password that alreadey registerd or added in your project */ -#define USER_EMAIL "USER_EMAIL" -#define USER_PASSWORD "USER_PASSWORD" - -// Define Firebase Data object -FirebaseData stream; -FirebaseData fbdo; - -FirebaseAuth auth; -FirebaseConfig config; - -unsigned long sendDataPrevMillis = 0; - -int count = 0; - -volatile bool dataChanged = false; - -WiFiSSLClient ssl_client1; - -WiFiSSLClient ssl_client2; - -void networkConnection() -{ - // Reset the network connection - WiFi.disconnect(); - - WiFi.begin(WIFI_SSID, WIFI_PASSWORD); - Serial.print("Connecting to Wi-Fi"); - unsigned long ms = millis(); - while (WiFi.status() != WL_CONNECTED) - { - Serial.print("."); - delay(300); - if (millis() - ms >= 5000) - { - Serial.println(" failed!"); - return; - } - } - Serial.println(); - Serial_Printf("Connected with IP: "); - Serial.println(WiFi.localIP()); - Serial.println(); -} - -// Define the callback function to handle server status acknowledgement -void networkStatusRequestCallback() -{ - // Set the network status - fbdo.setNetworkStatus(WiFi.status() == WL_CONNECTED); - stream.setNetworkStatus(WiFi.status() == WL_CONNECTED); -} - -// Define the callback function to handle server connection -void tcpConnectionRequestCallback1(const char *host, int port) -{ - - // You may need to set the system timestamp to use for - // auth token expiration checking. - - Firebase.setSystemTime(WiFi.getTime()); - - Serial.print("Connecting to server via external Client... "); - if (!ssl_client1.connect(host, port)) - { - Serial.println("failed."); - return; - } - Serial.println("success."); -} - -// Define the callback function to handle server connection -void tcpConnectionRequestCallback2(const char *host, int port) -{ - - // You may need to set the system timestamp to use for - // auth token expiration checking. - - Firebase.setSystemTime(WiFi.getTime()); - - Serial.print("Connecting to server via external Client... "); - if (!ssl_client2.connect(host, port)) - { - Serial.println("failed."); - return; - } - Serial.println("success."); -} - -void streamCallback(FirebaseStream data) -{ - Serial_Printf("sream path, %s\nevent path, %s\ndata type, %s\nevent type, %s\n\n", - data.streamPath().c_str(), - data.dataPath().c_str(), - data.dataType().c_str(), - data.eventType().c_str()); - printResult(data); // see addons/RTDBHelper.h - Serial.println(); - - // This is the size of stream payload received (current and max value) - // Max payload size is the payload size under the stream path since the stream connected - // and read once and will not update until stream reconnection takes place. - // This max value will be zero as no payload received in case of ESP8266 which - // BearSSL reserved Rx buffer size is less than the actual stream payload. - Serial_Printf("Received stream payload size: %d (Max. %d)\n\n", data.payloadLength(), data.maxPayloadLength()); - - // Due to limited of stack memory, do not perform any task that used large memory here especially starting connect to server. - // Just set this flag and check it status later. - dataChanged = true; -} - -void streamTimeoutCallback(bool timeout) -{ - if (timeout) - Serial.println("stream timed out, resuming...\n"); - - if (!stream.httpConnected()) - Serial_Printf("error code: %d, reason: %s\n\n", stream.httpCode(), stream.errorReason().c_str()); -} - -void setup() -{ - - Serial.begin(115200); - -#if defined(ARDUINO_ARCH_SAMD) - while (!Serial) - ; -#endif - - networkConnection(); - - Serial_Printf("Firebase Client v%s\n\n", FIREBASE_CLIENT_VERSION); - - /* Assign the api key (required) */ - config.api_key = API_KEY; - - /* Assign the user sign in credentials */ - auth.user.email = USER_EMAIL; - auth.user.password = USER_PASSWORD; - - /* Assign the RTDB URL (required) */ - config.database_url = DATABASE_URL; - - /* Assign the callback function for the long running token generation task */ - config.token_status_callback = tokenStatusCallback; // see addons/TokenHelper.h - - // Or use legacy authenticate method - // config.database_url = DATABASE_URL; - // config.signer.tokens.legacy_token = ""; - - // To connect without auth in Test Mode, see Authentications/TestMode/TestMode.ino - - /* fbdo.setExternalClient and fbdo.setExternalClientCallbacks must be called before Firebase.begin */ - - /* Assign the pointer to global defined external SSL Client object */ - fbdo.setExternalClient(&ssl_client1); - - /* Assign the required callback functions */ - fbdo.setExternalClientCallbacks(tcpConnectionRequestCallback1, networkConnection, networkStatusRequestCallback); - - /* Assign the pointer to global defined external SSL Client object */ - stream.setExternalClient(&ssl_client2); - - /* Assign the required callback functions */ - stream.setExternalClientCallbacks(tcpConnectionRequestCallback2, networkConnection, networkStatusRequestCallback); - - Firebase.reconnectWiFi(true); - - Firebase.begin(&config, &auth); - - if (!Firebase.RTDB.beginStream(&stream, "/test/stream/data")) - Serial_Printf("sream begin error, %s\n\n", stream.errorReason().c_str()); - - Firebase.RTDB.setStreamCallback(&stream, streamCallback, streamTimeoutCallback); -} - -void loop() -{ - - // Firebase.ready() should be called repeatedly to handle authentication tasks. - - if (Firebase.ready() && (millis() - sendDataPrevMillis > 15000 || sendDataPrevMillis == 0)) - { - sendDataPrevMillis = millis(); - count++; - FirebaseJson json; - json.add("data", "hello"); - json.add("num", count); - Serial_Printf("Set json... %s\n\n", Firebase.RTDB.setJSON(&fbdo, "/test/stream/data/json", &json) ? "ok" : fbdo.errorReason().c_str()); - } - - if (dataChanged) - { - dataChanged = false; - // When stream data is available, do anything here... - } -} +/** + * Created by K. Suwatchai (Mobizt) + * + * Email: k_suwatchai@hotmail.com + * + * Github: https://github.com/mobizt/Firebase-ESP-Client + * + * Copyright (c) 2023 mobizt + * + */ + +/** This example shows the RTDB data changed notification with external Client. + * This example used SAMD21 device and WiFiNINA as the external Client. + */ + +#if defined(ARDUINO_ARCH_SAMD) +#include +#endif + +#include + +// Provide the token generation process info. +#include + +// Provide the RTDB payload printing info and other helper functions. +#include + +/* 1. Define the WiFi credentials */ +#define WIFI_SSID "WIFI_AP" +#define WIFI_PASSWORD "WIFI_PASSWORD" + +// For the following credentials, see examples/Authentications/SignInAsUser/EmailPassword/EmailPassword.ino + +/* 2. Define the API Key */ +#define API_KEY "API_KEY" + +/* 3. Define the RTDB URL */ +#define DATABASE_URL "URL" //.firebaseio.com or ..firebasedatabase.app + +/* 4. Define the user Email and password that alreadey registerd or added in your project */ +#define USER_EMAIL "USER_EMAIL" +#define USER_PASSWORD "USER_PASSWORD" + +// Define Firebase Data object +FirebaseData stream; +FirebaseData fbdo; + +FirebaseAuth auth; +FirebaseConfig config; + +unsigned long sendDataPrevMillis = 0; + +int count = 0; + +volatile bool dataChanged = false; + +WiFiSSLClient ssl_client1; + +WiFiSSLClient ssl_client2; + +void networkConnection() +{ + // Reset the network connection + WiFi.disconnect(); + + WiFi.begin(WIFI_SSID, WIFI_PASSWORD); + Serial.print("Connecting to Wi-Fi"); + unsigned long ms = millis(); + while (WiFi.status() != WL_CONNECTED) + { + Serial.print("."); + delay(300); + if (millis() - ms >= 5000) + { + Serial.println(" failed!"); + return; + } + } + Serial.println(); + Serial_Printf("Connected with IP: "); + Serial.println(WiFi.localIP()); + Serial.println(); +} + +// Define the callback function to handle server status acknowledgement +void networkStatusRequestCallback() +{ + // Set the network status + fbdo.setNetworkStatus(WiFi.status() == WL_CONNECTED); + stream.setNetworkStatus(WiFi.status() == WL_CONNECTED); +} + +// Define the callback function to handle server connection +void tcpConnectionRequestCallback1(const char *host, int port) +{ + + // You may need to set the system timestamp to use for + // auth token expiration checking. + + Firebase.setSystemTime(WiFi.getTime()); + + Serial.print("Connecting to server via external Client... "); + if (!ssl_client1.connect(host, port)) + { + Serial.println("failed."); + return; + } + Serial.println("success."); +} + +// Define the callback function to handle server connection +void tcpConnectionRequestCallback2(const char *host, int port) +{ + + // You may need to set the system timestamp to use for + // auth token expiration checking. + + Firebase.setSystemTime(WiFi.getTime()); + + Serial.print("Connecting to server via external Client... "); + if (!ssl_client2.connect(host, port)) + { + Serial.println("failed."); + return; + } + Serial.println("success."); +} + +void streamCallback(FirebaseStream data) +{ + Serial_Printf("sream path, %s\nevent path, %s\ndata type, %s\nevent type, %s\n\n", + data.streamPath().c_str(), + data.dataPath().c_str(), + data.dataType().c_str(), + data.eventType().c_str()); + printResult(data); // see addons/RTDBHelper.h + Serial.println(); + + // This is the size of stream payload received (current and max value) + // Max payload size is the payload size under the stream path since the stream connected + // and read once and will not update until stream reconnection takes place. + // This max value will be zero as no payload received in case of ESP8266 which + // BearSSL reserved Rx buffer size is less than the actual stream payload. + Serial_Printf("Received stream payload size: %d (Max. %d)\n\n", data.payloadLength(), data.maxPayloadLength()); + + // Due to limited of stack memory, do not perform any task that used large memory here especially starting connect to server. + // Just set this flag and check it status later. + dataChanged = true; +} + +void streamTimeoutCallback(bool timeout) +{ + if (timeout) + Serial.println("stream timed out, resuming...\n"); + + if (!stream.httpConnected()) + Serial_Printf("error code: %d, reason: %s\n\n", stream.httpCode(), stream.errorReason().c_str()); +} + +void setup() +{ + + Serial.begin(115200); + +#if defined(ARDUINO_ARCH_SAMD) + while (!Serial) + ; +#endif + + networkConnection(); + + Serial_Printf("Firebase Client v%s\n\n", FIREBASE_CLIENT_VERSION); + + /* Assign the api key (required) */ + config.api_key = API_KEY; + + /* Assign the user sign in credentials */ + auth.user.email = USER_EMAIL; + auth.user.password = USER_PASSWORD; + + /* Assign the RTDB URL (required) */ + config.database_url = DATABASE_URL; + + /* Assign the callback function for the long running token generation task */ + config.token_status_callback = tokenStatusCallback; // see addons/TokenHelper.h + + // Or use legacy authenticate method + // config.database_url = DATABASE_URL; + // config.signer.tokens.legacy_token = ""; + + // To connect without auth in Test Mode, see Authentications/TestMode/TestMode.ino + + /* fbdo.setExternalClient and fbdo.setExternalClientCallbacks must be called before Firebase.begin */ + + /* Assign the pointer to global defined external SSL Client object */ + fbdo.setExternalClient(&ssl_client1); + + /* Assign the required callback functions */ + fbdo.setExternalClientCallbacks(tcpConnectionRequestCallback1, networkConnection, networkStatusRequestCallback); + + /* Assign the pointer to global defined external SSL Client object */ + stream.setExternalClient(&ssl_client2); + + /* Assign the required callback functions */ + stream.setExternalClientCallbacks(tcpConnectionRequestCallback2, networkConnection, networkStatusRequestCallback); + + Firebase.reconnectWiFi(true); + + Firebase.begin(&config, &auth); + + if (!Firebase.RTDB.beginStream(&stream, "/test/stream/data")) + Serial_Printf("sream begin error, %s\n\n", stream.errorReason().c_str()); + + Firebase.RTDB.setStreamCallback(&stream, streamCallback, streamTimeoutCallback); +} + +void loop() +{ + + // Firebase.ready() should be called repeatedly to handle authentication tasks. + + if (Firebase.ready() && (millis() - sendDataPrevMillis > 15000 || sendDataPrevMillis == 0)) + { + sendDataPrevMillis = millis(); + count++; + FirebaseJson json; + json.add("data", "hello"); + json.add("num", count); + Serial_Printf("Set json... %s\n\n", Firebase.RTDB.setJSON(&fbdo, "/test/stream/data/json", &json) ? "ok" : fbdo.errorReason().c_str()); + } + + if (dataChanged) + { + dataChanged = false; + // When stream data is available, do anything here... + } +} diff --git a/examples/FirebaseJson/BasicUsage/Create_Edit_Parse/Create_Edit_Parse.ino b/examples/FirebaseJson/BasicUsage/Create_Edit_Parse/Create_Edit_Parse.ino index c9162e953..992cbb390 100644 --- a/examples/FirebaseJson/BasicUsage/Create_Edit_Parse/Create_Edit_Parse.ino +++ b/examples/FirebaseJson/BasicUsage/Create_Edit_Parse/Create_Edit_Parse.ino @@ -5,7 +5,7 @@ * * Github: https://github.com/mobizt/FirebaseJson * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/FirebaseJson/Client/ArduinoMQTT/ArduinoMQTT.ino b/examples/FirebaseJson/Client/ArduinoMQTT/ArduinoMQTT.ino index 5877c9a06..656d77fd2 100644 --- a/examples/FirebaseJson/Client/ArduinoMQTT/ArduinoMQTT.ino +++ b/examples/FirebaseJson/Client/ArduinoMQTT/ArduinoMQTT.ino @@ -5,7 +5,7 @@ * * Github: https://github.com/mobizt * - * Copyright (c) 2021 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/FirebaseJson/Client/Firebase/Firebase.ino b/examples/FirebaseJson/Client/Firebase/Firebase.ino index 44bcf2a9c..5838b147c 100644 --- a/examples/FirebaseJson/Client/Firebase/Firebase.ino +++ b/examples/FirebaseJson/Client/Firebase/Firebase.ino @@ -6,7 +6,7 @@ * * Github: https://github.com/mobizt/FirebaseJson * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/FirebaseJson/Client/WiFiClient/WiFiClient.ino b/examples/FirebaseJson/Client/WiFiClient/WiFiClient.ino index 124b47149..77f35f347 100644 --- a/examples/FirebaseJson/Client/WiFiClient/WiFiClient.ino +++ b/examples/FirebaseJson/Client/WiFiClient/WiFiClient.ino @@ -5,7 +5,7 @@ * * Github: https://github.com/mobizt * - * Copyright (c) 2021 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/FirebaseJson/Client/WiFiClientSecure/WiFiClientSecure.ino b/examples/FirebaseJson/Client/WiFiClientSecure/WiFiClientSecure.ino index b4621c278..8bab88c2d 100644 --- a/examples/FirebaseJson/Client/WiFiClientSecure/WiFiClientSecure.ino +++ b/examples/FirebaseJson/Client/WiFiClientSecure/WiFiClientSecure.ino @@ -5,7 +5,7 @@ * * Github: https://github.com/mobizt * - * Copyright (c) 2021 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/FirebaseJson/Stream/File/File.ino b/examples/FirebaseJson/Stream/File/File.ino index 4596d29a9..c99485b3f 100644 --- a/examples/FirebaseJson/Stream/File/File.ino +++ b/examples/FirebaseJson/Stream/File/File.ino @@ -5,7 +5,7 @@ * * Github: https://github.com/mobizt/FirebaseJson * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/FirebaseJson/Stream/Serial/Serial.ino b/examples/FirebaseJson/Stream/Serial/Serial.ino index ba572cd65..c1c5cc2e8 100644 --- a/examples/FirebaseJson/Stream/Serial/Serial.ino +++ b/examples/FirebaseJson/Stream/Serial/Serial.ino @@ -5,7 +5,7 @@ * * Github: https://github.com/mobizt/FirebaseJson * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/Firestore/BatchGetDocuments/BatchGetDocuments.ino b/examples/Firestore/BatchGetDocuments/BatchGetDocuments.ino index 75a2e2353..bd6d0991b 100644 --- a/examples/Firestore/BatchGetDocuments/BatchGetDocuments.ino +++ b/examples/Firestore/BatchGetDocuments/BatchGetDocuments.ino @@ -1,115 +1,115 @@ - -/** - * Created by K. Suwatchai (Mobizt) - * - * Email: k_suwatchai@hotmail.com - * - * Github: https://github.com/mobizt/Firebase-ESP-Client - * - * Copyright (c) 2022 mobizt - * - */ - -// This example shows how to get multiple documents from a document collection. This operation required Email/password, custom or OAUth2.0 authentication. - -#if defined(ESP32) -#include -#elif defined(ESP8266) -#include -#endif - -#include - -// Provide the token generation process info. -#include - -/* 1. Define the WiFi credentials */ -#define WIFI_SSID "WIFI_AP" -#define WIFI_PASSWORD "WIFI_PASSWORD" - -/* 2. Define the API Key */ -#define API_KEY "API_KEY" - -/* 3. Define the project ID */ -#define FIREBASE_PROJECT_ID "PROJECT_ID" - -/* 4. Define the user Email and password that alreadey registerd or added in your project */ -#define USER_EMAIL "USER_EMAIL" -#define USER_PASSWORD "USER_PASSWORD" - -// Define Firebase Data object -FirebaseData fbdo; - -FirebaseAuth auth; -FirebaseConfig config; - -bool taskCompleted = false; - -void batchCallback(const char *data) -{ - Serial.print(data); -} - -void setup() -{ - - Serial.begin(115200); - - WiFi.begin(WIFI_SSID, WIFI_PASSWORD); - Serial.print("Connecting to Wi-Fi"); - while (WiFi.status() != WL_CONNECTED) - { - Serial.print("."); - delay(300); - } - Serial.println(); - Serial.print("Connected with IP: "); - Serial.println(WiFi.localIP()); - Serial.println(); - - Serial.printf("Firebase Client v%s\n\n", FIREBASE_CLIENT_VERSION); - - /* Assign the api key (required) */ - config.api_key = API_KEY; - - /* Assign the user sign in credentials */ - auth.user.email = USER_EMAIL; - auth.user.password = USER_PASSWORD; - - /* Assign the callback function for the long running token generation task */ - config.token_status_callback = tokenStatusCallback; // see addons/TokenHelper.h - -#if defined(ESP8266) - // In ESP8266 required for BearSSL rx/tx buffer for large data handle, increase Rx size as needed. - fbdo.setBSSLBufferSize(2048 /* Rx buffer size in bytes from 512 - 16384 */, 2048 /* Tx buffer size in bytes from 512 - 16384 */); -#endif - - // Limit the size of response payload to be collected in FirebaseData - fbdo.setResponseSize(2048); - - Firebase.begin(&config, &auth); - - Firebase.reconnectWiFi(true); -} - -void loop() -{ - - // Firebase.ready() should be called repeatedly to handle authentication tasks. - - if (Firebase.ready() && !taskCompleted) - { - taskCompleted = true; - - FirebaseJson newTransaction; - newTransaction.set("readWrite/retryTransaction", ""); - - Serial.println("\nGet multiple documents...\n"); - - if (!Firebase.Firestore.batchGetDocuments(&fbdo, FIREBASE_PROJECT_ID, "" /* databaseId can be (default) or empty */, - "info/countries,a0/b0/c0/d1,a0/b0/c0/d2,test_collection/test_document" /* documentPaths */, - "Singapore.population,key1" /* masks */, batchCallback /* callback */, "" /* transaction */, - &newTransaction /* newTransaction */, "" /* readTime */)) - Serial.println(fbdo.errorReason()); - } -} + +/** + * Created by K. Suwatchai (Mobizt) + * + * Email: k_suwatchai@hotmail.com + * + * Github: https://github.com/mobizt/Firebase-ESP-Client + * + * Copyright (c) 2023 mobizt + * + */ + +// This example shows how to get multiple documents from a document collection. This operation required Email/password, custom or OAUth2.0 authentication. + +#if defined(ESP32) +#include +#elif defined(ESP8266) +#include +#endif + +#include + +// Provide the token generation process info. +#include + +/* 1. Define the WiFi credentials */ +#define WIFI_SSID "WIFI_AP" +#define WIFI_PASSWORD "WIFI_PASSWORD" + +/* 2. Define the API Key */ +#define API_KEY "API_KEY" + +/* 3. Define the project ID */ +#define FIREBASE_PROJECT_ID "PROJECT_ID" + +/* 4. Define the user Email and password that alreadey registerd or added in your project */ +#define USER_EMAIL "USER_EMAIL" +#define USER_PASSWORD "USER_PASSWORD" + +// Define Firebase Data object +FirebaseData fbdo; + +FirebaseAuth auth; +FirebaseConfig config; + +bool taskCompleted = false; + +void batchCallback(const char *data) +{ + Serial.print(data); +} + +void setup() +{ + + Serial.begin(115200); + + WiFi.begin(WIFI_SSID, WIFI_PASSWORD); + Serial.print("Connecting to Wi-Fi"); + while (WiFi.status() != WL_CONNECTED) + { + Serial.print("."); + delay(300); + } + Serial.println(); + Serial.print("Connected with IP: "); + Serial.println(WiFi.localIP()); + Serial.println(); + + Serial.printf("Firebase Client v%s\n\n", FIREBASE_CLIENT_VERSION); + + /* Assign the api key (required) */ + config.api_key = API_KEY; + + /* Assign the user sign in credentials */ + auth.user.email = USER_EMAIL; + auth.user.password = USER_PASSWORD; + + /* Assign the callback function for the long running token generation task */ + config.token_status_callback = tokenStatusCallback; // see addons/TokenHelper.h + +#if defined(ESP8266) + // In ESP8266 required for BearSSL rx/tx buffer for large data handle, increase Rx size as needed. + fbdo.setBSSLBufferSize(2048 /* Rx buffer size in bytes from 512 - 16384 */, 2048 /* Tx buffer size in bytes from 512 - 16384 */); +#endif + + // Limit the size of response payload to be collected in FirebaseData + fbdo.setResponseSize(2048); + + Firebase.begin(&config, &auth); + + Firebase.reconnectWiFi(true); +} + +void loop() +{ + + // Firebase.ready() should be called repeatedly to handle authentication tasks. + + if (Firebase.ready() && !taskCompleted) + { + taskCompleted = true; + + FirebaseJson newTransaction; + newTransaction.set("readWrite/retryTransaction", ""); + + Serial.println("\nGet multiple documents...\n"); + + if (!Firebase.Firestore.batchGetDocuments(&fbdo, FIREBASE_PROJECT_ID, "" /* databaseId can be (default) or empty */, + "info/countries,a0/b0/c0/d1,a0/b0/c0/d2,test_collection/test_document" /* documentPaths */, + "Singapore.population,key1" /* masks */, batchCallback /* callback */, "" /* transaction */, + &newTransaction /* newTransaction */, "" /* readTime */)) + Serial.println(fbdo.errorReason()); + } +} diff --git a/examples/Firestore/BatchWriteDocuments/BatchWriteDocuments.ino b/examples/Firestore/BatchWriteDocuments/BatchWriteDocuments.ino index 11439d884..1bdf7d1d6 100644 --- a/examples/Firestore/BatchWriteDocuments/BatchWriteDocuments.ino +++ b/examples/Firestore/BatchWriteDocuments/BatchWriteDocuments.ino @@ -1,181 +1,181 @@ - -/** - * Created by K. Suwatchai (Mobizt) - * - * Email: k_suwatchai@hotmail.com - * - * Github: https://github.com/mobizt/Firebase-ESP-Client - * - * Copyright (c) 2022 mobizt - * - */ - -// This example shows how to apply a batch of writes operation. This operation required Email/password, custom or OAUth2.0 authentication. - -#if defined(ESP32) -#include -#elif defined(ESP8266) -#include -#endif - -#include - -// Provide the token generation process info. -#include - -/* 1. Define the WiFi credentials */ -#define WIFI_SSID "WIFI_AP" -#define WIFI_PASSWORD "WIFI_PASSWORD" - -/* 2. Define the API Key */ -#define API_KEY "API_KEY" - -/* 3. Define the project ID */ -#define FIREBASE_PROJECT_ID "PROJECT_ID" - -/* 4. Define the user Email and password that alreadey registerd or added in your project */ -#define USER_EMAIL "USER_EMAIL" -#define USER_PASSWORD "USER_PASSWORD" - -// Define Firebase Data object -FirebaseData fbdo; - -FirebaseAuth auth; -FirebaseConfig config; - -unsigned long dataMillis = 0; -int count = 0; - -void batchCallback(const char *data) -{ - Serial.print(data); -} - -void setup() -{ - - Serial.begin(115200); - - WiFi.begin(WIFI_SSID, WIFI_PASSWORD); - Serial.print("Connecting to Wi-Fi"); - while (WiFi.status() != WL_CONNECTED) - { - Serial.print("."); - delay(300); - } - Serial.println(); - Serial.print("Connected with IP: "); - Serial.println(WiFi.localIP()); - Serial.println(); - - Serial.printf("Firebase Client v%s\n\n", FIREBASE_CLIENT_VERSION); - - /* Assign the api key (required) */ - config.api_key = API_KEY; - - /* Assign the user sign in credentials */ - auth.user.email = USER_EMAIL; - auth.user.password = USER_PASSWORD; - - /* Assign the callback function for the long running token generation task */ - config.token_status_callback = tokenStatusCallback; // see addons/TokenHelper.h - -#if defined(ESP8266) - // In ESP8266 required for BearSSL rx/tx buffer for large data handle, increase Rx size as needed. - fbdo.setBSSLBufferSize(2048 /* Rx buffer size in bytes from 512 - 16384 */, 2048 /* Tx buffer size in bytes from 512 - 16384 */); -#endif - - // Limit the size of response payload to be collected in FirebaseData - fbdo.setResponseSize(2048); - - Firebase.begin(&config, &auth); - - Firebase.reconnectWiFi(true); -} - -void loop() -{ - - // Firebase.ready() should be called repeatedly to handle authentication tasks. - - if (Firebase.ready() && (millis() - dataMillis > 60000 || dataMillis == 0)) - { - dataMillis = millis(); - count++; - - Serial.print("Batch write documents... "); - - // The dyamic array of write object fb_esp_firestore_document_write_t. - std::vector writes; - - // A write object that will be written to the document. - struct fb_esp_firestore_document_write_t update_write; - - // Set the write object write operation type. - // fb_esp_firestore_document_write_type_update, - // fb_esp_firestore_document_write_type_delete, - // fb_esp_firestore_document_write_type_transform - update_write.type = fb_esp_firestore_document_write_type_update; - - // Set the document content to write (transform) - - FirebaseJson content; - String documentPath = "test_collection/test_document_map_value"; - String documentPath2 = "test_collection/test_document_timestamp"; - - content.set("fields/myMap/mapValue/fields/key" + String(count) + "/mapValue/fields/name/stringValue", "value" + String(count)); - content.set("fields/myMap/mapValue/fields/key" + String(count) + "/mapValue/fields/count/stringValue", String(count)); - // Set the update document content - update_write.update_document_content = content.raw(); - - update_write.update_masks = "myMap.key" + String(count); - - // Set the update document path - update_write.update_document_path = documentPath.c_str(); - - // Add a write object to a write array. - writes.push_back(update_write); - - // A write object that will be written to the document. - struct fb_esp_firestore_document_write_t transform_write; - - // Set the write object write operation type. - // fb_esp_firestore_document_write_type_update, - // fb_esp_firestore_document_write_type_delete, - // fb_esp_firestore_document_write_type_transform - transform_write.type = fb_esp_firestore_document_write_type_transform; - - // Set the document path of document to write (transform) - transform_write.document_transform.transform_document_path = documentPath2; - - // Set a transformation of a field of the document. - struct fb_esp_firestore_document_write_field_transforms_t field_transforms; - - // Set field path to write. - field_transforms.fieldPath = "myTime"; - - // Set the transformation type. - // fb_esp_firestore_transform_type_set_to_server_value, - // fb_esp_firestore_transform_type_increment, - // fb_esp_firestore_transform_type_maaximum, - // fb_esp_firestore_transform_type_minimum, - // fb_esp_firestore_transform_type_append_missing_elements, - // fb_esp_firestore_transform_type_remove_all_from_array - field_transforms.transform_type = fb_esp_firestore_transform_type_set_to_server_value; - - // Set the transformation content, server value for this case. - // See https://firebase.google.com/docs/firestore/reference/rest/v1/Write#servervalue - field_transforms.transform_content = "REQUEST_TIME"; // set timestamp to timestamp field - - // Add a field transformation object to a write object. - transform_write.document_transform.field_transforms.push_back(field_transforms); - - // Add a write object to a write array. - writes.push_back(transform_write); - - if (Firebase.Firestore.batchWriteDocuments(&fbdo, FIREBASE_PROJECT_ID, "" /* databaseId can be (default) or empty */, writes /* dynamic array of fb_esp_firestore_document_write_t */, nullptr /* labels */)) - Serial.printf("ok\n%s\n\n", fbdo.payload().c_str()); - else - Serial.println(fbdo.errorReason()); - } -} + +/** + * Created by K. Suwatchai (Mobizt) + * + * Email: k_suwatchai@hotmail.com + * + * Github: https://github.com/mobizt/Firebase-ESP-Client + * + * Copyright (c) 2023 mobizt + * + */ + +// This example shows how to apply a batch of writes operation. This operation required Email/password, custom or OAUth2.0 authentication. + +#if defined(ESP32) +#include +#elif defined(ESP8266) +#include +#endif + +#include + +// Provide the token generation process info. +#include + +/* 1. Define the WiFi credentials */ +#define WIFI_SSID "WIFI_AP" +#define WIFI_PASSWORD "WIFI_PASSWORD" + +/* 2. Define the API Key */ +#define API_KEY "API_KEY" + +/* 3. Define the project ID */ +#define FIREBASE_PROJECT_ID "PROJECT_ID" + +/* 4. Define the user Email and password that alreadey registerd or added in your project */ +#define USER_EMAIL "USER_EMAIL" +#define USER_PASSWORD "USER_PASSWORD" + +// Define Firebase Data object +FirebaseData fbdo; + +FirebaseAuth auth; +FirebaseConfig config; + +unsigned long dataMillis = 0; +int count = 0; + +void batchCallback(const char *data) +{ + Serial.print(data); +} + +void setup() +{ + + Serial.begin(115200); + + WiFi.begin(WIFI_SSID, WIFI_PASSWORD); + Serial.print("Connecting to Wi-Fi"); + while (WiFi.status() != WL_CONNECTED) + { + Serial.print("."); + delay(300); + } + Serial.println(); + Serial.print("Connected with IP: "); + Serial.println(WiFi.localIP()); + Serial.println(); + + Serial.printf("Firebase Client v%s\n\n", FIREBASE_CLIENT_VERSION); + + /* Assign the api key (required) */ + config.api_key = API_KEY; + + /* Assign the user sign in credentials */ + auth.user.email = USER_EMAIL; + auth.user.password = USER_PASSWORD; + + /* Assign the callback function for the long running token generation task */ + config.token_status_callback = tokenStatusCallback; // see addons/TokenHelper.h + +#if defined(ESP8266) + // In ESP8266 required for BearSSL rx/tx buffer for large data handle, increase Rx size as needed. + fbdo.setBSSLBufferSize(2048 /* Rx buffer size in bytes from 512 - 16384 */, 2048 /* Tx buffer size in bytes from 512 - 16384 */); +#endif + + // Limit the size of response payload to be collected in FirebaseData + fbdo.setResponseSize(2048); + + Firebase.begin(&config, &auth); + + Firebase.reconnectWiFi(true); +} + +void loop() +{ + + // Firebase.ready() should be called repeatedly to handle authentication tasks. + + if (Firebase.ready() && (millis() - dataMillis > 60000 || dataMillis == 0)) + { + dataMillis = millis(); + count++; + + Serial.print("Batch write documents... "); + + // The dyamic array of write object fb_esp_firestore_document_write_t. + std::vector writes; + + // A write object that will be written to the document. + struct fb_esp_firestore_document_write_t update_write; + + // Set the write object write operation type. + // fb_esp_firestore_document_write_type_update, + // fb_esp_firestore_document_write_type_delete, + // fb_esp_firestore_document_write_type_transform + update_write.type = fb_esp_firestore_document_write_type_update; + + // Set the document content to write (transform) + + FirebaseJson content; + String documentPath = "test_collection/test_document_map_value"; + String documentPath2 = "test_collection/test_document_timestamp"; + + content.set("fields/myMap/mapValue/fields/key" + String(count) + "/mapValue/fields/name/stringValue", "value" + String(count)); + content.set("fields/myMap/mapValue/fields/key" + String(count) + "/mapValue/fields/count/stringValue", String(count)); + // Set the update document content + update_write.update_document_content = content.raw(); + + update_write.update_masks = "myMap.key" + String(count); + + // Set the update document path + update_write.update_document_path = documentPath.c_str(); + + // Add a write object to a write array. + writes.push_back(update_write); + + // A write object that will be written to the document. + struct fb_esp_firestore_document_write_t transform_write; + + // Set the write object write operation type. + // fb_esp_firestore_document_write_type_update, + // fb_esp_firestore_document_write_type_delete, + // fb_esp_firestore_document_write_type_transform + transform_write.type = fb_esp_firestore_document_write_type_transform; + + // Set the document path of document to write (transform) + transform_write.document_transform.transform_document_path = documentPath2; + + // Set a transformation of a field of the document. + struct fb_esp_firestore_document_write_field_transforms_t field_transforms; + + // Set field path to write. + field_transforms.fieldPath = "myTime"; + + // Set the transformation type. + // fb_esp_firestore_transform_type_set_to_server_value, + // fb_esp_firestore_transform_type_increment, + // fb_esp_firestore_transform_type_maaximum, + // fb_esp_firestore_transform_type_minimum, + // fb_esp_firestore_transform_type_append_missing_elements, + // fb_esp_firestore_transform_type_remove_all_from_array + field_transforms.transform_type = fb_esp_firestore_transform_type_set_to_server_value; + + // Set the transformation content, server value for this case. + // See https://firebase.google.com/docs/firestore/reference/rest/v1/Write#servervalue + field_transforms.transform_content = "REQUEST_TIME"; // set timestamp to timestamp field + + // Add a field transformation object to a write object. + transform_write.document_transform.field_transforms.push_back(field_transforms); + + // Add a write object to a write array. + writes.push_back(transform_write); + + if (Firebase.Firestore.batchWriteDocuments(&fbdo, FIREBASE_PROJECT_ID, "" /* databaseId can be (default) or empty */, writes /* dynamic array of fb_esp_firestore_document_write_t */, nullptr /* labels */)) + Serial.printf("ok\n%s\n\n", fbdo.payload().c_str()); + else + Serial.println(fbdo.errorReason()); + } +} diff --git a/examples/Firestore/CommitDocument/AppendArray/AppendArray.ino b/examples/Firestore/CommitDocument/AppendArray/AppendArray.ino index 62e719b70..6b41371f1 100644 --- a/examples/Firestore/CommitDocument/AppendArray/AppendArray.ino +++ b/examples/Firestore/CommitDocument/AppendArray/AppendArray.ino @@ -6,7 +6,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/Firestore/CommitDocument/AppendMapValue/AppendMapValue.ino b/examples/Firestore/CommitDocument/AppendMapValue/AppendMapValue.ino index 5c08deb4a..f4274dd5b 100644 --- a/examples/Firestore/CommitDocument/AppendMapValue/AppendMapValue.ino +++ b/examples/Firestore/CommitDocument/AppendMapValue/AppendMapValue.ino @@ -6,7 +6,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/Firestore/CommitDocument/AppendMapValueArray/AppendMapValueArray.ino b/examples/Firestore/CommitDocument/AppendMapValueArray/AppendMapValueArray.ino index c2317ef05..6c6dbeb19 100644 --- a/examples/Firestore/CommitDocument/AppendMapValueArray/AppendMapValueArray.ino +++ b/examples/Firestore/CommitDocument/AppendMapValueArray/AppendMapValueArray.ino @@ -1,154 +1,154 @@ - -/** - * Created by K. Suwatchai (Mobizt) - * - * Email: k_suwatchai@hotmail.com - * - * Github: https://github.com/mobizt/Firebase-ESP-Client - * - * Copyright (c) 2022 mobizt - * - */ - -// This example shows how to append map value to array field. This operation required Email/password, custom or OAUth2.0 authentication. - -#if defined(ESP32) -#include -#elif defined(ESP8266) -#include -#endif - -#include - -// Provide the token generation process info. -#include - -/* 1. Define the WiFi credentials */ -#define WIFI_SSID "WIFI_AP" -#define WIFI_PASSWORD "WIFI_PASSWORD" - -/* 2. Define the API Key */ -#define API_KEY "API_KEY" - -/* 3. Define the project ID */ -#define FIREBASE_PROJECT_ID "PROJECT_ID" - -/* 4. Define the user Email and password that alreadey registerd or added in your project */ -#define USER_EMAIL "USER_EMAIL" -#define USER_PASSWORD "USER_PASSWORD" - -// Define Firebase Data object -FirebaseData fbdo; - -FirebaseAuth auth; -FirebaseConfig config; - -unsigned long dataMillis = 0; -int count = 0; - -void setup() -{ - - Serial.begin(115200); - - WiFi.begin(WIFI_SSID, WIFI_PASSWORD); - Serial.print("Connecting to Wi-Fi"); - while (WiFi.status() != WL_CONNECTED) - { - Serial.print("."); - delay(300); - } - Serial.println(); - Serial.print("Connected with IP: "); - Serial.println(WiFi.localIP()); - Serial.println(); - - Serial.printf("Firebase Client v%s\n\n", FIREBASE_CLIENT_VERSION); - - /* Assign the api key (required) */ - config.api_key = API_KEY; - - /* Assign the user sign in credentials */ - auth.user.email = USER_EMAIL; - auth.user.password = USER_PASSWORD; - - /* Assign the callback function for the long running token generation task */ - config.token_status_callback = tokenStatusCallback; // see addons/TokenHelper.h - -#if defined(ESP8266) - // In ESP8266 required for BearSSL rx/tx buffer for large data handle, increase Rx size as needed. - fbdo.setBSSLBufferSize(2048 /* Rx buffer size in bytes from 512 - 16384 */, 2048 /* Tx buffer size in bytes from 512 - 16384 */); -#endif - - // Limit the size of response payload to be collected in FirebaseData - fbdo.setResponseSize(2048); - - Firebase.begin(&config, &auth); - - Firebase.reconnectWiFi(true); -} - -void loop() -{ - - // Firebase.ready() should be called repeatedly to handle authentication tasks. - - if (Firebase.ready() && (millis() - dataMillis > 60000 || dataMillis == 0)) - { - dataMillis = millis(); - count++; - - Serial.print("Commit a document (append array)... "); - - // The dyamic array of write object fb_esp_firestore_document_write_t. - std::vector writes; - - // A write object that will be written to the document. - struct fb_esp_firestore_document_write_t transform_write; - - // Set the write object write operation type. - // fb_esp_firestore_document_write_type_update, - // fb_esp_firestore_document_write_type_delete, - // fb_esp_firestore_document_write_type_transform - transform_write.type = fb_esp_firestore_document_write_type_transform; - - // Set the document path of document to write (transform) - transform_write.document_transform.transform_document_path = "test_collection/test_document"; - - // Set a transformation of a field of the document. - struct fb_esp_firestore_document_write_field_transforms_t field_transforms; - - // Set field path to write. - field_transforms.fieldPath = "appended_map_array"; - - // Set the transformation type. - // fb_esp_firestore_transform_type_set_to_server_value, - // fb_esp_firestore_transform_type_increment, - // fb_esp_firestore_transform_type_maaximum, - // fb_esp_firestore_transform_type_minimum, - // fb_esp_firestore_transform_type_append_missing_elements, - // fb_esp_firestore_transform_type_remove_all_from_array - field_transforms.transform_type = fb_esp_firestore_transform_type_append_missing_elements; - - // For the usage of FirebaseJson, see examples/FirebaseJson/BasicUsage/Create.ino - FirebaseJson content; - - content.set("values/[0]/mapValue/fields/id/stringValue", "item" + String(count)); - content.set("values/[0]/mapValue/fields/status/booleanValue", count % 2 == 0); - - - // Set the transformation content. - field_transforms.transform_content = content.raw(); - - // Add a field transformation object to a write object. - transform_write.document_transform.field_transforms.push_back(field_transforms); - - // Add a write object to a write array. - writes.push_back(transform_write); - - if (Firebase.Firestore.commitDocument(&fbdo, FIREBASE_PROJECT_ID, "" /* databaseId can be (default) or empty */, writes /* dynamic array of fb_esp_firestore_document_write_t */, "" /* transaction */)) - Serial.printf("ok\n%s\n\n", fbdo.payload().c_str()); - else - Serial.println(fbdo.errorReason()); - } -} + +/** + * Created by K. Suwatchai (Mobizt) + * + * Email: k_suwatchai@hotmail.com + * + * Github: https://github.com/mobizt/Firebase-ESP-Client + * + * Copyright (c) 2023 mobizt + * + */ + +// This example shows how to append map value to array field. This operation required Email/password, custom or OAUth2.0 authentication. + +#if defined(ESP32) +#include +#elif defined(ESP8266) +#include +#endif + +#include + +// Provide the token generation process info. +#include + +/* 1. Define the WiFi credentials */ +#define WIFI_SSID "WIFI_AP" +#define WIFI_PASSWORD "WIFI_PASSWORD" + +/* 2. Define the API Key */ +#define API_KEY "API_KEY" + +/* 3. Define the project ID */ +#define FIREBASE_PROJECT_ID "PROJECT_ID" + +/* 4. Define the user Email and password that alreadey registerd or added in your project */ +#define USER_EMAIL "USER_EMAIL" +#define USER_PASSWORD "USER_PASSWORD" + +// Define Firebase Data object +FirebaseData fbdo; + +FirebaseAuth auth; +FirebaseConfig config; + +unsigned long dataMillis = 0; +int count = 0; + +void setup() +{ + + Serial.begin(115200); + + WiFi.begin(WIFI_SSID, WIFI_PASSWORD); + Serial.print("Connecting to Wi-Fi"); + while (WiFi.status() != WL_CONNECTED) + { + Serial.print("."); + delay(300); + } + Serial.println(); + Serial.print("Connected with IP: "); + Serial.println(WiFi.localIP()); + Serial.println(); + + Serial.printf("Firebase Client v%s\n\n", FIREBASE_CLIENT_VERSION); + + /* Assign the api key (required) */ + config.api_key = API_KEY; + + /* Assign the user sign in credentials */ + auth.user.email = USER_EMAIL; + auth.user.password = USER_PASSWORD; + + /* Assign the callback function for the long running token generation task */ + config.token_status_callback = tokenStatusCallback; // see addons/TokenHelper.h + +#if defined(ESP8266) + // In ESP8266 required for BearSSL rx/tx buffer for large data handle, increase Rx size as needed. + fbdo.setBSSLBufferSize(2048 /* Rx buffer size in bytes from 512 - 16384 */, 2048 /* Tx buffer size in bytes from 512 - 16384 */); +#endif + + // Limit the size of response payload to be collected in FirebaseData + fbdo.setResponseSize(2048); + + Firebase.begin(&config, &auth); + + Firebase.reconnectWiFi(true); +} + +void loop() +{ + + // Firebase.ready() should be called repeatedly to handle authentication tasks. + + if (Firebase.ready() && (millis() - dataMillis > 60000 || dataMillis == 0)) + { + dataMillis = millis(); + count++; + + Serial.print("Commit a document (append array)... "); + + // The dyamic array of write object fb_esp_firestore_document_write_t. + std::vector writes; + + // A write object that will be written to the document. + struct fb_esp_firestore_document_write_t transform_write; + + // Set the write object write operation type. + // fb_esp_firestore_document_write_type_update, + // fb_esp_firestore_document_write_type_delete, + // fb_esp_firestore_document_write_type_transform + transform_write.type = fb_esp_firestore_document_write_type_transform; + + // Set the document path of document to write (transform) + transform_write.document_transform.transform_document_path = "test_collection/test_document"; + + // Set a transformation of a field of the document. + struct fb_esp_firestore_document_write_field_transforms_t field_transforms; + + // Set field path to write. + field_transforms.fieldPath = "appended_map_array"; + + // Set the transformation type. + // fb_esp_firestore_transform_type_set_to_server_value, + // fb_esp_firestore_transform_type_increment, + // fb_esp_firestore_transform_type_maaximum, + // fb_esp_firestore_transform_type_minimum, + // fb_esp_firestore_transform_type_append_missing_elements, + // fb_esp_firestore_transform_type_remove_all_from_array + field_transforms.transform_type = fb_esp_firestore_transform_type_append_missing_elements; + + // For the usage of FirebaseJson, see examples/FirebaseJson/BasicUsage/Create.ino + FirebaseJson content; + + content.set("values/[0]/mapValue/fields/id/stringValue", "item" + String(count)); + content.set("values/[0]/mapValue/fields/status/booleanValue", count % 2 == 0); + + + // Set the transformation content. + field_transforms.transform_content = content.raw(); + + // Add a field transformation object to a write object. + transform_write.document_transform.field_transforms.push_back(field_transforms); + + // Add a write object to a write array. + writes.push_back(transform_write); + + if (Firebase.Firestore.commitDocument(&fbdo, FIREBASE_PROJECT_ID, "" /* databaseId can be (default) or empty */, writes /* dynamic array of fb_esp_firestore_document_write_t */, "" /* transaction */)) + Serial.printf("ok\n%s\n\n", fbdo.payload().c_str()); + else + Serial.println(fbdo.errorReason()); + } +} diff --git a/examples/Firestore/CommitDocument/AppendMapValueTimestamp/AppendMapValueTimestamp.ino b/examples/Firestore/CommitDocument/AppendMapValueTimestamp/AppendMapValueTimestamp.ino index 77c862994..dabb24a7e 100644 --- a/examples/Firestore/CommitDocument/AppendMapValueTimestamp/AppendMapValueTimestamp.ino +++ b/examples/Firestore/CommitDocument/AppendMapValueTimestamp/AppendMapValueTimestamp.ino @@ -1,175 +1,175 @@ - -/** - * Created by K. Suwatchai (Mobizt) - * - * Email: k_suwatchai@hotmail.com - * - * Github: https://github.com/mobizt/Firebase-ESP-Client - * - * Copyright (c) 2022 mobizt - * - */ - -// This example shows how to append new value with server timestamp to a map field usng commit. This operation required Email/password, custom or OAUth2.0 authentication. - -#if defined(ESP32) -#include -#elif defined(ESP8266) -#include -#endif - -#include - -// Provide the token generation process info. -#include - -/* 1. Define the WiFi credentials */ -#define WIFI_SSID "WIFI_AP" -#define WIFI_PASSWORD "WIFI_PASSWORD" - -/* 2. Define the API Key */ -#define API_KEY "API_KEY" - -/* 3. Define the project ID */ -#define FIREBASE_PROJECT_ID "PROJECT_ID" - -/* 4. Define the user Email and password that alreadey registerd or added in your project */ -#define USER_EMAIL "USER_EMAIL" -#define USER_PASSWORD "USER_PASSWORD" - -// Define Firebase Data object -FirebaseData fbdo; - -FirebaseAuth auth; -FirebaseConfig config; - -unsigned long dataMillis = 0; -int count = 0; - -void setup() -{ - - Serial.begin(115200); - - WiFi.begin(WIFI_SSID, WIFI_PASSWORD); - Serial.print("Connecting to Wi-Fi"); - while (WiFi.status() != WL_CONNECTED) - { - Serial.print("."); - delay(300); - } - Serial.println(); - Serial.print("Connected with IP: "); - Serial.println(WiFi.localIP()); - Serial.println(); - - Serial.printf("Firebase Client v%s\n\n", FIREBASE_CLIENT_VERSION); - - /* Assign the api key (required) */ - config.api_key = API_KEY; - - /* Assign the user sign in credentials */ - auth.user.email = USER_EMAIL; - auth.user.password = USER_PASSWORD; - - /* Assign the callback function for the long running token generation task */ - config.token_status_callback = tokenStatusCallback; // see addons/TokenHelper.h - -#if defined(ESP8266) - // In ESP8266 required for BearSSL rx/tx buffer for large data handle, increase Rx size as needed. - fbdo.setBSSLBufferSize(2048 /* Rx buffer size in bytes from 512 - 16384 */, 2048 /* Tx buffer size in bytes from 512 - 16384 */); -#endif - - // Limit the size of response payload to be collected in FirebaseData - fbdo.setResponseSize(2048); - - Firebase.begin(&config, &auth); - - Firebase.reconnectWiFi(true); -} - -void loop() -{ - - // Firebase.ready() should be called repeatedly to handle authentication tasks. - - if (Firebase.ready() && (millis() - dataMillis > 60000 || dataMillis == 0)) - { - dataMillis = millis(); - count++; - - Serial.print("Commit a document (append map value in document)... "); - - // The dyamic array of write object fb_esp_firestore_document_write_t. - std::vector writes; - - // A write object that will be written to the document. - struct fb_esp_firestore_document_write_t update_write; - - // Set the write object write operation type. - // fb_esp_firestore_document_write_type_update, - // fb_esp_firestore_document_write_type_delete, - // fb_esp_firestore_document_write_type_transform - update_write.type = fb_esp_firestore_document_write_type_update; - - // Set the document content to write (transform) - - FirebaseJson content; - String documentPath = "test_collection/test_document_map_value_timestamp"; - - content.set("fields/myMap/mapValue/fields/key" + String(count) + "/mapValue/fields/name/stringValue", "value" + String(count)); - content.set("fields/myMap/mapValue/fields/key" + String(count) + "/mapValue/fields/count/stringValue", String(count)); - // Set the update document content - update_write.update_document_content = content.raw(); - - update_write.update_masks = "myMap.key" + String(count); - - // Set the update document path - update_write.update_document_path = documentPath.c_str(); - - // Add a write object to a write array. - writes.push_back(update_write); - - // A write object that will be written to the document. - struct fb_esp_firestore_document_write_t transform_write; - - // Set the write object write operation type. - // fb_esp_firestore_document_write_type_update, - // fb_esp_firestore_document_write_type_delete, - // fb_esp_firestore_document_write_type_transform - transform_write.type = fb_esp_firestore_document_write_type_transform; - - // Set the document path of document to write (transform) - transform_write.document_transform.transform_document_path = documentPath; - - // Set a transformation of a field of the document. - struct fb_esp_firestore_document_write_field_transforms_t field_transforms; - - // Set field path to write. - field_transforms.fieldPath = "myMap.key" + String(count) + ".timestamp"; - - // Set the transformation type. - // fb_esp_firestore_transform_type_set_to_server_value, - // fb_esp_firestore_transform_type_increment, - // fb_esp_firestore_transform_type_maaximum, - // fb_esp_firestore_transform_type_minimum, - // fb_esp_firestore_transform_type_append_missing_elements, - // fb_esp_firestore_transform_type_remove_all_from_array - field_transforms.transform_type = fb_esp_firestore_transform_type_set_to_server_value; - - // Set the transformation content, server value for this case. - // See https://firebase.google.com/docs/firestore/reference/rest/v1/Write#servervalue - field_transforms.transform_content = "REQUEST_TIME"; // set timestamp to timestamp field - - // Add a field transformation object to a write object. - transform_write.document_transform.field_transforms.push_back(field_transforms); - - // Add a write object to a write array. - writes.push_back(transform_write); - - if (Firebase.Firestore.commitDocument(&fbdo, FIREBASE_PROJECT_ID, "" /* databaseId can be (default) or empty */, writes /* dynamic array of fb_esp_firestore_document_write_t */, "" /* transaction */)) - Serial.printf("ok\n%s\n\n", fbdo.payload().c_str()); - else - Serial.println(fbdo.errorReason()); - } -} + +/** + * Created by K. Suwatchai (Mobizt) + * + * Email: k_suwatchai@hotmail.com + * + * Github: https://github.com/mobizt/Firebase-ESP-Client + * + * Copyright (c) 2023 mobizt + * + */ + +// This example shows how to append new value with server timestamp to a map field usng commit. This operation required Email/password, custom or OAUth2.0 authentication. + +#if defined(ESP32) +#include +#elif defined(ESP8266) +#include +#endif + +#include + +// Provide the token generation process info. +#include + +/* 1. Define the WiFi credentials */ +#define WIFI_SSID "WIFI_AP" +#define WIFI_PASSWORD "WIFI_PASSWORD" + +/* 2. Define the API Key */ +#define API_KEY "API_KEY" + +/* 3. Define the project ID */ +#define FIREBASE_PROJECT_ID "PROJECT_ID" + +/* 4. Define the user Email and password that alreadey registerd or added in your project */ +#define USER_EMAIL "USER_EMAIL" +#define USER_PASSWORD "USER_PASSWORD" + +// Define Firebase Data object +FirebaseData fbdo; + +FirebaseAuth auth; +FirebaseConfig config; + +unsigned long dataMillis = 0; +int count = 0; + +void setup() +{ + + Serial.begin(115200); + + WiFi.begin(WIFI_SSID, WIFI_PASSWORD); + Serial.print("Connecting to Wi-Fi"); + while (WiFi.status() != WL_CONNECTED) + { + Serial.print("."); + delay(300); + } + Serial.println(); + Serial.print("Connected with IP: "); + Serial.println(WiFi.localIP()); + Serial.println(); + + Serial.printf("Firebase Client v%s\n\n", FIREBASE_CLIENT_VERSION); + + /* Assign the api key (required) */ + config.api_key = API_KEY; + + /* Assign the user sign in credentials */ + auth.user.email = USER_EMAIL; + auth.user.password = USER_PASSWORD; + + /* Assign the callback function for the long running token generation task */ + config.token_status_callback = tokenStatusCallback; // see addons/TokenHelper.h + +#if defined(ESP8266) + // In ESP8266 required for BearSSL rx/tx buffer for large data handle, increase Rx size as needed. + fbdo.setBSSLBufferSize(2048 /* Rx buffer size in bytes from 512 - 16384 */, 2048 /* Tx buffer size in bytes from 512 - 16384 */); +#endif + + // Limit the size of response payload to be collected in FirebaseData + fbdo.setResponseSize(2048); + + Firebase.begin(&config, &auth); + + Firebase.reconnectWiFi(true); +} + +void loop() +{ + + // Firebase.ready() should be called repeatedly to handle authentication tasks. + + if (Firebase.ready() && (millis() - dataMillis > 60000 || dataMillis == 0)) + { + dataMillis = millis(); + count++; + + Serial.print("Commit a document (append map value in document)... "); + + // The dyamic array of write object fb_esp_firestore_document_write_t. + std::vector writes; + + // A write object that will be written to the document. + struct fb_esp_firestore_document_write_t update_write; + + // Set the write object write operation type. + // fb_esp_firestore_document_write_type_update, + // fb_esp_firestore_document_write_type_delete, + // fb_esp_firestore_document_write_type_transform + update_write.type = fb_esp_firestore_document_write_type_update; + + // Set the document content to write (transform) + + FirebaseJson content; + String documentPath = "test_collection/test_document_map_value_timestamp"; + + content.set("fields/myMap/mapValue/fields/key" + String(count) + "/mapValue/fields/name/stringValue", "value" + String(count)); + content.set("fields/myMap/mapValue/fields/key" + String(count) + "/mapValue/fields/count/stringValue", String(count)); + // Set the update document content + update_write.update_document_content = content.raw(); + + update_write.update_masks = "myMap.key" + String(count); + + // Set the update document path + update_write.update_document_path = documentPath.c_str(); + + // Add a write object to a write array. + writes.push_back(update_write); + + // A write object that will be written to the document. + struct fb_esp_firestore_document_write_t transform_write; + + // Set the write object write operation type. + // fb_esp_firestore_document_write_type_update, + // fb_esp_firestore_document_write_type_delete, + // fb_esp_firestore_document_write_type_transform + transform_write.type = fb_esp_firestore_document_write_type_transform; + + // Set the document path of document to write (transform) + transform_write.document_transform.transform_document_path = documentPath; + + // Set a transformation of a field of the document. + struct fb_esp_firestore_document_write_field_transforms_t field_transforms; + + // Set field path to write. + field_transforms.fieldPath = "myMap.key" + String(count) + ".timestamp"; + + // Set the transformation type. + // fb_esp_firestore_transform_type_set_to_server_value, + // fb_esp_firestore_transform_type_increment, + // fb_esp_firestore_transform_type_maaximum, + // fb_esp_firestore_transform_type_minimum, + // fb_esp_firestore_transform_type_append_missing_elements, + // fb_esp_firestore_transform_type_remove_all_from_array + field_transforms.transform_type = fb_esp_firestore_transform_type_set_to_server_value; + + // Set the transformation content, server value for this case. + // See https://firebase.google.com/docs/firestore/reference/rest/v1/Write#servervalue + field_transforms.transform_content = "REQUEST_TIME"; // set timestamp to timestamp field + + // Add a field transformation object to a write object. + transform_write.document_transform.field_transforms.push_back(field_transforms); + + // Add a write object to a write array. + writes.push_back(transform_write); + + if (Firebase.Firestore.commitDocument(&fbdo, FIREBASE_PROJECT_ID, "" /* databaseId can be (default) or empty */, writes /* dynamic array of fb_esp_firestore_document_write_t */, "" /* transaction */)) + Serial.printf("ok\n%s\n\n", fbdo.payload().c_str()); + else + Serial.println(fbdo.errorReason()); + } +} diff --git a/examples/Firestore/CommitDocument/IncrementFieldValue/IncrementFieldValue.ino b/examples/Firestore/CommitDocument/IncrementFieldValue/IncrementFieldValue.ino index 49ba0f302..6458bcb7a 100644 --- a/examples/Firestore/CommitDocument/IncrementFieldValue/IncrementFieldValue.ino +++ b/examples/Firestore/CommitDocument/IncrementFieldValue/IncrementFieldValue.ino @@ -6,7 +6,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/Firestore/CommitDocument/SetUpdateDelete/SetUpdateDelete.ino b/examples/Firestore/CommitDocument/SetUpdateDelete/SetUpdateDelete.ino index 5e3ba1641..5230476d2 100644 --- a/examples/Firestore/CommitDocument/SetUpdateDelete/SetUpdateDelete.ino +++ b/examples/Firestore/CommitDocument/SetUpdateDelete/SetUpdateDelete.ino @@ -6,7 +6,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/Firestore/CreateDocuments/CreateDocuments.ino b/examples/Firestore/CreateDocuments/CreateDocuments.ino index a2b3d20fb..e0b8144d9 100644 --- a/examples/Firestore/CreateDocuments/CreateDocuments.ino +++ b/examples/Firestore/CreateDocuments/CreateDocuments.ino @@ -6,7 +6,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/Firestore/DataQuery/DataQuery.ino b/examples/Firestore/DataQuery/DataQuery.ino index 735cd6d22..a8afbb9b1 100644 --- a/examples/Firestore/DataQuery/DataQuery.ino +++ b/examples/Firestore/DataQuery/DataQuery.ino @@ -6,7 +6,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/Firestore/DeleteDocument/DeleteDocument.ino b/examples/Firestore/DeleteDocument/DeleteDocument.ino index 4326b3c12..938e34046 100644 --- a/examples/Firestore/DeleteDocument/DeleteDocument.ino +++ b/examples/Firestore/DeleteDocument/DeleteDocument.ino @@ -6,7 +6,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/Firestore/ExportDocuments/ExportDocuments.ino b/examples/Firestore/ExportDocuments/ExportDocuments.ino index ce13ff1d9..5bb338f27 100644 --- a/examples/Firestore/ExportDocuments/ExportDocuments.ino +++ b/examples/Firestore/ExportDocuments/ExportDocuments.ino @@ -6,7 +6,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/Firestore/GetDocument/GetDocument.ino b/examples/Firestore/GetDocument/GetDocument.ino index d8ef878b3..fdf06d3fb 100644 --- a/examples/Firestore/GetDocument/GetDocument.ino +++ b/examples/Firestore/GetDocument/GetDocument.ino @@ -6,7 +6,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/Firestore/ImportDocuments/ImportDocuments.ino b/examples/Firestore/ImportDocuments/ImportDocuments.ino index c18f82028..cbcebf06c 100644 --- a/examples/Firestore/ImportDocuments/ImportDocuments.ino +++ b/examples/Firestore/ImportDocuments/ImportDocuments.ino @@ -6,7 +6,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/Firestore/Indexes/CreateIndex/CreateIndex.ino b/examples/Firestore/Indexes/CreateIndex/CreateIndex.ino index 0214b38bc..3660fbc69 100644 --- a/examples/Firestore/Indexes/CreateIndex/CreateIndex.ino +++ b/examples/Firestore/Indexes/CreateIndex/CreateIndex.ino @@ -1,139 +1,139 @@ - -/** - * Created by K. Suwatchai (Mobizt) - * - * Email: k_suwatchai@hotmail.com - * - * Github: https://github.com/mobizt/Firebase-ESP-Client - * - * Copyright (c) 2022 mobizt - * - */ - -// This example will show how to create the specified index to the fields in a collection. -// This operation required OAUth2.0 authentication. - -#if defined(ESP32) -#include -#elif defined(ESP8266) -#include -#endif - -#include - -// Provide the token generation process info. -#include - -// Provide the RTDB payload printing info and other helper functions. -#include - -/* 1. Define the WiFi credentials */ -#define WIFI_SSID "WIFI_AP" -#define WIFI_PASSWORD "WIFI_PASSWORD" - -/** 2. Define the API key - * - * The API key can be obtained since you created the project and set up - * the Authentication in Firebase console. - * - * You may need to enable the Identity provider at https://console.cloud.google.com/customer-identity/providers - * Select your project, click at ENABLE IDENTITY PLATFORM button. - * The API key also available by click at the link APPLICATION SETUP DETAILS. - * - */ -#define API_KEY "API_KEY" - -/** 3. Define the Service Account credentials (required for token generation) - * - * This information can be taken from the service account JSON file. - * - * To download service account file, from the Firebase console, goto project settings, - * select "Service accounts" tab and click at "Generate new private key" button - */ -#define FIREBASE_PROJECT_ID "PROJECT_ID" -#define FIREBASE_CLIENT_EMAIL "CLIENT_EMAIL" -const char PRIVATE_KEY[] PROGMEM = "-----BEGIN PRIVATE KEY-----XXXXXXXXXXXX-----END PRIVATE KEY-----\n"; - -/* 4. Define the Firebase Data object */ -FirebaseData fbdo; - -/* 5. Define the FirebaseAuth data for authentication data */ -FirebaseAuth auth; - -/* 6. Define the FirebaseConfig data for config data */ -FirebaseConfig config; - -bool taskCompleted = false; - -void setup() -{ - - Serial.begin(115200); - - WiFi.begin(WIFI_SSID, WIFI_PASSWORD); - Serial.print("Connecting to Wi-Fi"); - while (WiFi.status() != WL_CONNECTED) - { - Serial.print("."); - delay(300); - } - Serial.println(); - Serial.print("Connected with IP: "); - Serial.println(WiFi.localIP()); - Serial.println(); - - Serial.printf("Firebase Client v%s\n\n", FIREBASE_CLIENT_VERSION); - - /* Assign the api key (required) */ - config.api_key = API_KEY; - - /* Assign the sevice account credentials and private key (required) */ - config.service_account.data.client_email = FIREBASE_CLIENT_EMAIL; - config.service_account.data.project_id = FIREBASE_PROJECT_ID; - config.service_account.data.private_key = PRIVATE_KEY; - - Firebase.reconnectWiFi(true); - - fbdo.setResponseSize(4096); - - /* Assign the callback function for the long running token generation task */ - config.token_status_callback = tokenStatusCallback; // see addons/TokenHelper.h - - Firebase.begin(&config, &auth); -} - -void loop() -{ - - // Firebase.ready() should be called repeatedly to handle authentication tasks. - if (Firebase.ready() && !taskCompleted) - { - taskCompleted = true; - - FirebaseJsonArray fields; - fields.set("/[0]/fieldPath", "myArray"); - fields.set("/[0]/arrayConfig", "CONTAINS"); - - fields.set("/[1]/fieldPath", "myField"); - fields.set("/[1]/order", "ASCENDING"); - - Serial.print("Create index... "); - if (Firebase.Firestore.createIndex(&fbdo, FIREBASE_PROJECT_ID, "" /* databaseId can be (default) or empty */, "myCol" /* collectionId */, - "ANY_API" /* API mode e.g., ANY_API and DATASTORE_MODE_API */, "COLLECTION" /* queryScope */, &fields /* fields array to set index */)) - Serial.printf("ok\n%s\n\n", fbdo.payload().c_str()); - else - Serial.println(fbdo.errorReason()); - - Serial.print("List indexes... "); - if (Firebase.Firestore.listIndex(&fbdo, FIREBASE_PROJECT_ID, "" /* databaseId can be (default) or empty */, "myCol" /* collectionId */)) - Serial.printf("ok\n%s\n\n", fbdo.payload().c_str()); - else - Serial.println(fbdo.errorReason()); - - Serial.print("Get indexes... "); - if (Firebase.Firestore.getIndex(&fbdo, FIREBASE_PROJECT_ID, "" /* databaseId can be (default) or empty */, "myCol" /* collectionId */, "" /* index id to get */)) - Serial.printf("ok\n%s\n\n", fbdo.payload().c_str()); - else - Serial.println(fbdo.errorReason()); - } + +/** + * Created by K. Suwatchai (Mobizt) + * + * Email: k_suwatchai@hotmail.com + * + * Github: https://github.com/mobizt/Firebase-ESP-Client + * + * Copyright (c) 2023 mobizt + * + */ + +// This example will show how to create the specified index to the fields in a collection. +// This operation required OAUth2.0 authentication. + +#if defined(ESP32) +#include +#elif defined(ESP8266) +#include +#endif + +#include + +// Provide the token generation process info. +#include + +// Provide the RTDB payload printing info and other helper functions. +#include + +/* 1. Define the WiFi credentials */ +#define WIFI_SSID "WIFI_AP" +#define WIFI_PASSWORD "WIFI_PASSWORD" + +/** 2. Define the API key + * + * The API key can be obtained since you created the project and set up + * the Authentication in Firebase console. + * + * You may need to enable the Identity provider at https://console.cloud.google.com/customer-identity/providers + * Select your project, click at ENABLE IDENTITY PLATFORM button. + * The API key also available by click at the link APPLICATION SETUP DETAILS. + * + */ +#define API_KEY "API_KEY" + +/** 3. Define the Service Account credentials (required for token generation) + * + * This information can be taken from the service account JSON file. + * + * To download service account file, from the Firebase console, goto project settings, + * select "Service accounts" tab and click at "Generate new private key" button + */ +#define FIREBASE_PROJECT_ID "PROJECT_ID" +#define FIREBASE_CLIENT_EMAIL "CLIENT_EMAIL" +const char PRIVATE_KEY[] PROGMEM = "-----BEGIN PRIVATE KEY-----XXXXXXXXXXXX-----END PRIVATE KEY-----\n"; + +/* 4. Define the Firebase Data object */ +FirebaseData fbdo; + +/* 5. Define the FirebaseAuth data for authentication data */ +FirebaseAuth auth; + +/* 6. Define the FirebaseConfig data for config data */ +FirebaseConfig config; + +bool taskCompleted = false; + +void setup() +{ + + Serial.begin(115200); + + WiFi.begin(WIFI_SSID, WIFI_PASSWORD); + Serial.print("Connecting to Wi-Fi"); + while (WiFi.status() != WL_CONNECTED) + { + Serial.print("."); + delay(300); + } + Serial.println(); + Serial.print("Connected with IP: "); + Serial.println(WiFi.localIP()); + Serial.println(); + + Serial.printf("Firebase Client v%s\n\n", FIREBASE_CLIENT_VERSION); + + /* Assign the api key (required) */ + config.api_key = API_KEY; + + /* Assign the sevice account credentials and private key (required) */ + config.service_account.data.client_email = FIREBASE_CLIENT_EMAIL; + config.service_account.data.project_id = FIREBASE_PROJECT_ID; + config.service_account.data.private_key = PRIVATE_KEY; + + Firebase.reconnectWiFi(true); + + fbdo.setResponseSize(4096); + + /* Assign the callback function for the long running token generation task */ + config.token_status_callback = tokenStatusCallback; // see addons/TokenHelper.h + + Firebase.begin(&config, &auth); +} + +void loop() +{ + + // Firebase.ready() should be called repeatedly to handle authentication tasks. + if (Firebase.ready() && !taskCompleted) + { + taskCompleted = true; + + FirebaseJsonArray fields; + fields.set("/[0]/fieldPath", "myArray"); + fields.set("/[0]/arrayConfig", "CONTAINS"); + + fields.set("/[1]/fieldPath", "myField"); + fields.set("/[1]/order", "ASCENDING"); + + Serial.print("Create index... "); + if (Firebase.Firestore.createIndex(&fbdo, FIREBASE_PROJECT_ID, "" /* databaseId can be (default) or empty */, "myCol" /* collectionId */, + "ANY_API" /* API mode e.g., ANY_API and DATASTORE_MODE_API */, "COLLECTION" /* queryScope */, &fields /* fields array to set index */)) + Serial.printf("ok\n%s\n\n", fbdo.payload().c_str()); + else + Serial.println(fbdo.errorReason()); + + Serial.print("List indexes... "); + if (Firebase.Firestore.listIndex(&fbdo, FIREBASE_PROJECT_ID, "" /* databaseId can be (default) or empty */, "myCol" /* collectionId */)) + Serial.printf("ok\n%s\n\n", fbdo.payload().c_str()); + else + Serial.println(fbdo.errorReason()); + + Serial.print("Get indexes... "); + if (Firebase.Firestore.getIndex(&fbdo, FIREBASE_PROJECT_ID, "" /* databaseId can be (default) or empty */, "myCol" /* collectionId */, "" /* index id to get */)) + Serial.printf("ok\n%s\n\n", fbdo.payload().c_str()); + else + Serial.println(fbdo.errorReason()); + } } \ No newline at end of file diff --git a/examples/Firestore/Indexes/DeleteIndex/DeleteIndex.ino b/examples/Firestore/Indexes/DeleteIndex/DeleteIndex.ino index a1eb9d75e..c4af00481 100644 --- a/examples/Firestore/Indexes/DeleteIndex/DeleteIndex.ino +++ b/examples/Firestore/Indexes/DeleteIndex/DeleteIndex.ino @@ -1,119 +1,119 @@ - -/** - * Created by K. Suwatchai (Mobizt) - * - * Email: k_suwatchai@hotmail.com - * - * Github: https://github.com/mobizt/Firebase-ESP-Client - * - * Copyright (c) 2022 mobizt - * - */ - -// This example will show how to delete an index. -// This operation required OAUth2.0 authentication. - -#if defined(ESP32) -#include -#elif defined(ESP8266) -#include -#endif - -#include - -// Provide the token generation process info. -#include - -// Provide the RTDB payload printing info and other helper functions. -#include - -/* 1. Define the WiFi credentials */ -#define WIFI_SSID "WIFI_AP" -#define WIFI_PASSWORD "WIFI_PASSWORD" - -/** 2. Define the API key - * - * The API key can be obtained since you created the project and set up - * the Authentication in Firebase console. - * - * You may need to enable the Identity provider at https://console.cloud.google.com/customer-identity/providers - * Select your project, click at ENABLE IDENTITY PLATFORM button. - * The API key also available by click at the link APPLICATION SETUP DETAILS. - * - */ -#define API_KEY "API_KEY" - -/** 3. Define the Service Account credentials (required for token generation) - * - * This information can be taken from the service account JSON file. - * - * To download service account file, from the Firebase console, goto project settings, - * select "Service accounts" tab and click at "Generate new private key" button - */ -#define FIREBASE_PROJECT_ID "PROJECT_ID" -#define FIREBASE_CLIENT_EMAIL "CLIENT_EMAIL" -const char PRIVATE_KEY[] PROGMEM = "-----BEGIN PRIVATE KEY-----XXXXXXXXXXXX-----END PRIVATE KEY-----\n"; - -/* 4. Define the Firebase Data object */ -FirebaseData fbdo; - -/* 5. Define the FirebaseAuth data for authentication data */ -FirebaseAuth auth; - -/* 6. Define the FirebaseConfig data for config data */ -FirebaseConfig config; - -bool taskCompleted = false; - -void setup() -{ - - Serial.begin(115200); - - WiFi.begin(WIFI_SSID, WIFI_PASSWORD); - Serial.print("Connecting to Wi-Fi"); - while (WiFi.status() != WL_CONNECTED) - { - Serial.print("."); - delay(300); - } - Serial.println(); - Serial.print("Connected with IP: "); - Serial.println(WiFi.localIP()); - Serial.println(); - - Serial.printf("Firebase Client v%s\n\n", FIREBASE_CLIENT_VERSION); - - /* Assign the api key (required) */ - config.api_key = API_KEY; - - /* Assign the sevice account credentials and private key (required) */ - config.service_account.data.client_email = FIREBASE_CLIENT_EMAIL; - config.service_account.data.project_id = FIREBASE_PROJECT_ID; - config.service_account.data.private_key = PRIVATE_KEY; - - Firebase.reconnectWiFi(true); - - fbdo.setResponseSize(4096); - - /* Assign the callback function for the long running token generation task */ - config.token_status_callback = tokenStatusCallback; // see addons/TokenHelper.h - - Firebase.begin(&config, &auth); -} - -void loop() -{ - - // Firebase.ready() should be called repeatedly to handle authentication tasks. - if (Firebase.ready() && !taskCompleted) - { - taskCompleted = true; - - Serial.print("Delete index... "); - if (Firebase.Firestore.deleteIndex(&fbdo, FIREBASE_PROJECT_ID, "" /* databaseId can be (default) or empty */, "" /* index id to delete */)) - Serial.printf("ok\n%s\n\n", fbdo.payload().c_str()); - else - Serial.println(fbdo.errorReason()); - } + +/** + * Created by K. Suwatchai (Mobizt) + * + * Email: k_suwatchai@hotmail.com + * + * Github: https://github.com/mobizt/Firebase-ESP-Client + * + * Copyright (c) 2023 mobizt + * + */ + +// This example will show how to delete an index. +// This operation required OAUth2.0 authentication. + +#if defined(ESP32) +#include +#elif defined(ESP8266) +#include +#endif + +#include + +// Provide the token generation process info. +#include + +// Provide the RTDB payload printing info and other helper functions. +#include + +/* 1. Define the WiFi credentials */ +#define WIFI_SSID "WIFI_AP" +#define WIFI_PASSWORD "WIFI_PASSWORD" + +/** 2. Define the API key + * + * The API key can be obtained since you created the project and set up + * the Authentication in Firebase console. + * + * You may need to enable the Identity provider at https://console.cloud.google.com/customer-identity/providers + * Select your project, click at ENABLE IDENTITY PLATFORM button. + * The API key also available by click at the link APPLICATION SETUP DETAILS. + * + */ +#define API_KEY "API_KEY" + +/** 3. Define the Service Account credentials (required for token generation) + * + * This information can be taken from the service account JSON file. + * + * To download service account file, from the Firebase console, goto project settings, + * select "Service accounts" tab and click at "Generate new private key" button + */ +#define FIREBASE_PROJECT_ID "PROJECT_ID" +#define FIREBASE_CLIENT_EMAIL "CLIENT_EMAIL" +const char PRIVATE_KEY[] PROGMEM = "-----BEGIN PRIVATE KEY-----XXXXXXXXXXXX-----END PRIVATE KEY-----\n"; + +/* 4. Define the Firebase Data object */ +FirebaseData fbdo; + +/* 5. Define the FirebaseAuth data for authentication data */ +FirebaseAuth auth; + +/* 6. Define the FirebaseConfig data for config data */ +FirebaseConfig config; + +bool taskCompleted = false; + +void setup() +{ + + Serial.begin(115200); + + WiFi.begin(WIFI_SSID, WIFI_PASSWORD); + Serial.print("Connecting to Wi-Fi"); + while (WiFi.status() != WL_CONNECTED) + { + Serial.print("."); + delay(300); + } + Serial.println(); + Serial.print("Connected with IP: "); + Serial.println(WiFi.localIP()); + Serial.println(); + + Serial.printf("Firebase Client v%s\n\n", FIREBASE_CLIENT_VERSION); + + /* Assign the api key (required) */ + config.api_key = API_KEY; + + /* Assign the sevice account credentials and private key (required) */ + config.service_account.data.client_email = FIREBASE_CLIENT_EMAIL; + config.service_account.data.project_id = FIREBASE_PROJECT_ID; + config.service_account.data.private_key = PRIVATE_KEY; + + Firebase.reconnectWiFi(true); + + fbdo.setResponseSize(4096); + + /* Assign the callback function for the long running token generation task */ + config.token_status_callback = tokenStatusCallback; // see addons/TokenHelper.h + + Firebase.begin(&config, &auth); +} + +void loop() +{ + + // Firebase.ready() should be called repeatedly to handle authentication tasks. + if (Firebase.ready() && !taskCompleted) + { + taskCompleted = true; + + Serial.print("Delete index... "); + if (Firebase.Firestore.deleteIndex(&fbdo, FIREBASE_PROJECT_ID, "" /* databaseId can be (default) or empty */, "" /* index id to delete */)) + Serial.printf("ok\n%s\n\n", fbdo.payload().c_str()); + else + Serial.println(fbdo.errorReason()); + } } \ No newline at end of file diff --git a/examples/Firestore/ListCollectionIds/ListCollectionIds.ino b/examples/Firestore/ListCollectionIds/ListCollectionIds.ino index c58769c69..c8c99fb03 100644 --- a/examples/Firestore/ListCollectionIds/ListCollectionIds.ino +++ b/examples/Firestore/ListCollectionIds/ListCollectionIds.ino @@ -6,7 +6,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/Firestore/ListDocuments/ListDocuments.ino b/examples/Firestore/ListDocuments/ListDocuments.ino index cf368d8d5..4cdc9bbb2 100644 --- a/examples/Firestore/ListDocuments/ListDocuments.ino +++ b/examples/Firestore/ListDocuments/ListDocuments.ino @@ -6,7 +6,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/Firestore/PatchDocument/AppendMapValue/AppendMapValue.ino b/examples/Firestore/PatchDocument/AppendMapValue/AppendMapValue.ino index b8c9acaa3..2f62bc853 100644 --- a/examples/Firestore/PatchDocument/AppendMapValue/AppendMapValue.ino +++ b/examples/Firestore/PatchDocument/AppendMapValue/AppendMapValue.ino @@ -6,7 +6,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/Firestore/PatchDocument/UpdateDocument/UpdateDocument.ino b/examples/Firestore/PatchDocument/UpdateDocument/UpdateDocument.ino index aed75882f..f233c17cc 100644 --- a/examples/Firestore/PatchDocument/UpdateDocument/UpdateDocument.ino +++ b/examples/Firestore/PatchDocument/UpdateDocument/UpdateDocument.ino @@ -6,7 +6,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/Messaging/AppInstanceInfo/AppInstanceInfo.ino b/examples/Messaging/AppInstanceInfo/AppInstanceInfo.ino index fe30004a4..07aabe21d 100644 --- a/examples/Messaging/AppInstanceInfo/AppInstanceInfo.ino +++ b/examples/Messaging/AppInstanceInfo/AppInstanceInfo.ino @@ -5,7 +5,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/Messaging/RegistAPNsTokens/RegistAPNsTokens.ino b/examples/Messaging/RegistAPNsTokens/RegistAPNsTokens.ino index d9367674a..89140fd6a 100644 --- a/examples/Messaging/RegistAPNsTokens/RegistAPNsTokens.ino +++ b/examples/Messaging/RegistAPNsTokens/RegistAPNsTokens.ino @@ -5,7 +5,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/Messaging/Send/HTTPv1/SendMessage/SendMessage.ino b/examples/Messaging/Send/HTTPv1/SendMessage/SendMessage.ino index b7d3771c2..e0c01aca4 100644 --- a/examples/Messaging/Send/HTTPv1/SendMessage/SendMessage.ino +++ b/examples/Messaging/Send/HTTPv1/SendMessage/SendMessage.ino @@ -5,7 +5,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/Messaging/Send/HTTPv1/SendTopic/SendTopic.ino b/examples/Messaging/Send/HTTPv1/SendTopic/SendTopic.ino index c0db08cb4..12d510fb6 100644 --- a/examples/Messaging/Send/HTTPv1/SendTopic/SendTopic.ino +++ b/examples/Messaging/Send/HTTPv1/SendTopic/SendTopic.ino @@ -5,7 +5,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/Messaging/Send/LegacyAPI/BroadcastMessage/BroadcastMessage.ino b/examples/Messaging/Send/LegacyAPI/BroadcastMessage/BroadcastMessage.ino index 8f86d308d..cddc7b58e 100644 --- a/examples/Messaging/Send/LegacyAPI/BroadcastMessage/BroadcastMessage.ino +++ b/examples/Messaging/Send/LegacyAPI/BroadcastMessage/BroadcastMessage.ino @@ -5,7 +5,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/Messaging/Send/LegacyAPI/SendMessage/SendMessage.ino b/examples/Messaging/Send/LegacyAPI/SendMessage/SendMessage.ino index 97a5af5a9..9632c8cc2 100644 --- a/examples/Messaging/Send/LegacyAPI/SendMessage/SendMessage.ino +++ b/examples/Messaging/Send/LegacyAPI/SendMessage/SendMessage.ino @@ -5,7 +5,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/Messaging/Send/LegacyAPI/SendMessageEthernet/ESP32/ESP32.ino b/examples/Messaging/Send/LegacyAPI/SendMessageEthernet/ESP32/ESP32.ino index 260903e58..97f2024d1 100644 --- a/examples/Messaging/Send/LegacyAPI/SendMessageEthernet/ESP32/ESP32.ino +++ b/examples/Messaging/Send/LegacyAPI/SendMessageEthernet/ESP32/ESP32.ino @@ -6,7 +6,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/Messaging/Send/LegacyAPI/SendMessageEthernet/ESP8266/ESP8266.ino b/examples/Messaging/Send/LegacyAPI/SendMessageEthernet/ESP8266/ESP8266.ino index c1d2fd298..4c15b8bef 100644 --- a/examples/Messaging/Send/LegacyAPI/SendMessageEthernet/ESP8266/ESP8266.ino +++ b/examples/Messaging/Send/LegacyAPI/SendMessageEthernet/ESP8266/ESP8266.ino @@ -5,7 +5,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/Messaging/Send/LegacyAPI/SendTopic/SendTopic.ino b/examples/Messaging/Send/LegacyAPI/SendTopic/SendTopic.ino index 0257f5174..ffa05c1a4 100644 --- a/examples/Messaging/Send/LegacyAPI/SendTopic/SendTopic.ino +++ b/examples/Messaging/Send/LegacyAPI/SendTopic/SendTopic.ino @@ -5,7 +5,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/Messaging/SubscribeTopic/SubscribeTopic.ino b/examples/Messaging/SubscribeTopic/SubscribeTopic.ino index bd4f6440f..cb3e65ef5 100644 --- a/examples/Messaging/SubscribeTopic/SubscribeTopic.ino +++ b/examples/Messaging/SubscribeTopic/SubscribeTopic.ino @@ -5,7 +5,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/Messaging/UnsubscribeTopic/UnsubscribeTopic.ino b/examples/Messaging/UnsubscribeTopic/UnsubscribeTopic.ino index dc6777334..b7e5d89da 100644 --- a/examples/Messaging/UnsubscribeTopic/UnsubscribeTopic.ino +++ b/examples/Messaging/UnsubscribeTopic/UnsubscribeTopic.ino @@ -5,7 +5,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/RTDB/BackupRestore/Flash/Flash.ino b/examples/RTDB/BackupRestore/Flash/Flash.ino index 663db1c43..54d6dbcf4 100644 --- a/examples/RTDB/BackupRestore/Flash/Flash.ino +++ b/examples/RTDB/BackupRestore/Flash/Flash.ino @@ -5,7 +5,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/RTDB/BackupRestore/SD/SD.ino b/examples/RTDB/BackupRestore/SD/SD.ino index 9b06605ce..1e34213d5 100644 --- a/examples/RTDB/BackupRestore/SD/SD.ino +++ b/examples/RTDB/BackupRestore/SD/SD.ino @@ -5,7 +5,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/RTDB/Basic/Basic.ino b/examples/RTDB/Basic/Basic.ino index 7f1c4a1dd..b2ca68630 100644 --- a/examples/RTDB/Basic/Basic.ino +++ b/examples/RTDB/Basic/Basic.ino @@ -6,7 +6,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/RTDB/BasicCert/BasicCert.ino b/examples/RTDB/BasicCert/BasicCert.ino index 93b0cbb6c..d83afb005 100644 --- a/examples/RTDB/BasicCert/BasicCert.ino +++ b/examples/RTDB/BasicCert/BasicCert.ino @@ -6,7 +6,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/RTDB/BasicEthernet/ESP32/ESP32.ino b/examples/RTDB/BasicEthernet/ESP32/ESP32.ino index 3ad2b91f2..de7776816 100644 --- a/examples/RTDB/BasicEthernet/ESP32/ESP32.ino +++ b/examples/RTDB/BasicEthernet/ESP32/ESP32.ino @@ -6,7 +6,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/RTDB/BasicEthernet/ESP8266/ESP8266.ino b/examples/RTDB/BasicEthernet/ESP8266/ESP8266.ino index eac354855..288e364c8 100644 --- a/examples/RTDB/BasicEthernet/ESP8266/ESP8266.ino +++ b/examples/RTDB/BasicEthernet/ESP8266/ESP8266.ino @@ -6,7 +6,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/RTDB/Blob/Blob.ino b/examples/RTDB/Blob/Blob.ino index ec06665be..43460e322 100644 --- a/examples/RTDB/Blob/Blob.ino +++ b/examples/RTDB/Blob/Blob.ino @@ -5,7 +5,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/RTDB/Blynk/Blynk.ino b/examples/RTDB/Blynk/Blynk.ino index fc9eefe94..7ddeaff28 100644 --- a/examples/RTDB/Blynk/Blynk.ino +++ b/examples/RTDB/Blynk/Blynk.ino @@ -5,7 +5,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/RTDB/DataChangesListener/Callback/Callback.ino b/examples/RTDB/DataChangesListener/Callback/Callback.ino index 2ae6c9b68..88285411e 100644 --- a/examples/RTDB/DataChangesListener/Callback/Callback.ino +++ b/examples/RTDB/DataChangesListener/Callback/Callback.ino @@ -5,7 +5,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/RTDB/DataChangesListener/MultiPath/MultiPath.ino b/examples/RTDB/DataChangesListener/MultiPath/MultiPath.ino index 96eca9834..c9ba7db70 100644 --- a/examples/RTDB/DataChangesListener/MultiPath/MultiPath.ino +++ b/examples/RTDB/DataChangesListener/MultiPath/MultiPath.ino @@ -5,7 +5,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/RTDB/DataChangesListener/NoCallback/NoCallback.ino b/examples/RTDB/DataChangesListener/NoCallback/NoCallback.ino index 534484b50..cfdaef797 100644 --- a/examples/RTDB/DataChangesListener/NoCallback/NoCallback.ino +++ b/examples/RTDB/DataChangesListener/NoCallback/NoCallback.ino @@ -5,7 +5,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/RTDB/DataChangesListener/SingleDataObject/SingleDataObject.ino b/examples/RTDB/DataChangesListener/SingleDataObject/SingleDataObject.ino index 21183996a..8b94dfca1 100644 --- a/examples/RTDB/DataChangesListener/SingleDataObject/SingleDataObject.ino +++ b/examples/RTDB/DataChangesListener/SingleDataObject/SingleDataObject.ino @@ -5,7 +5,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/RTDB/DataFilter/DataFilter.ino b/examples/RTDB/DataFilter/DataFilter.ino index 57ca8d635..8cf207a8f 100644 --- a/examples/RTDB/DataFilter/DataFilter.ino +++ b/examples/RTDB/DataFilter/DataFilter.ino @@ -5,7 +5,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/RTDB/DataRetaining/DataRetaining.ino b/examples/RTDB/DataRetaining/DataRetaining.ino index 06bc1b340..0b2828188 100644 --- a/examples/RTDB/DataRetaining/DataRetaining.ino +++ b/examples/RTDB/DataRetaining/DataRetaining.ino @@ -5,7 +5,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/RTDB/DatabaseRules/DatabaseRules.ino b/examples/RTDB/DatabaseRules/DatabaseRules.ino index 2b10d131e..5e98470d6 100644 --- a/examples/RTDB/DatabaseRules/DatabaseRules.ino +++ b/examples/RTDB/DatabaseRules/DatabaseRules.ino @@ -5,7 +5,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/RTDB/DownloadFileOTA/DownloadFileOTA.ino b/examples/RTDB/DownloadFileOTA/DownloadFileOTA.ino index c00366c58..b6883da51 100644 --- a/examples/RTDB/DownloadFileOTA/DownloadFileOTA.ino +++ b/examples/RTDB/DownloadFileOTA/DownloadFileOTA.ino @@ -5,7 +5,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/RTDB/ETag/ETag.ino b/examples/RTDB/ETag/ETag.ino index 15ed2e6e3..ba2d95c23 100644 --- a/examples/RTDB/ETag/ETag.ino +++ b/examples/RTDB/ETag/ETag.ino @@ -5,7 +5,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/RTDB/FastSend/FastSend.ino b/examples/RTDB/FastSend/FastSend.ino index f3273e61c..63746a752 100644 --- a/examples/RTDB/FastSend/FastSend.ino +++ b/examples/RTDB/FastSend/FastSend.ino @@ -5,7 +5,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/RTDB/File/Flash/Flash.ino b/examples/RTDB/File/Flash/Flash.ino index 47c2335c5..dd9794d46 100644 --- a/examples/RTDB/File/Flash/Flash.ino +++ b/examples/RTDB/File/Flash/Flash.ino @@ -5,7 +5,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/RTDB/File/SD/SD.ino b/examples/RTDB/File/SD/SD.ino index 69841c9d8..72249c7b1 100644 --- a/examples/RTDB/File/SD/SD.ino +++ b/examples/RTDB/File/SD/SD.ino @@ -5,7 +5,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/RTDB/FireSense/AnalogRead/AnalogRead.ino b/examples/RTDB/FireSense/AnalogRead/AnalogRead.ino index 44daf8e4c..6cd828781 100644 --- a/examples/RTDB/FireSense/AnalogRead/AnalogRead.ino +++ b/examples/RTDB/FireSense/AnalogRead/AnalogRead.ino @@ -6,7 +6,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/RTDB/FireSense/Blink/Blink.ino b/examples/RTDB/FireSense/Blink/Blink.ino index 4d1c57a44..fc950757f 100644 --- a/examples/RTDB/FireSense/Blink/Blink.ino +++ b/examples/RTDB/FireSense/Blink/Blink.ino @@ -6,7 +6,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/RTDB/FireSense/Sensors/Sensors.ino b/examples/RTDB/FireSense/Sensors/Sensors.ino index 41ff24a0e..7a3f20bfb 100644 --- a/examples/RTDB/FireSense/Sensors/Sensors.ino +++ b/examples/RTDB/FireSense/Sensors/Sensors.ino @@ -6,7 +6,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/RTDB/Priority/Priority.ino b/examples/RTDB/Priority/Priority.ino index 88c2e4d4f..0c313fbc9 100644 --- a/examples/RTDB/Priority/Priority.ino +++ b/examples/RTDB/Priority/Priority.ino @@ -5,7 +5,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/RTDB/Queue/Queue.ino b/examples/RTDB/Queue/Queue.ino index aa79edc76..889ad7d9c 100644 --- a/examples/RTDB/Queue/Queue.ino +++ b/examples/RTDB/Queue/Queue.ino @@ -5,7 +5,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/RTDB/ShallowedData/ShallowedData.ino b/examples/RTDB/ShallowedData/ShallowedData.ino index 8fc0b8b9a..939a5c979 100644 --- a/examples/RTDB/ShallowedData/ShallowedData.ino +++ b/examples/RTDB/ShallowedData/ShallowedData.ino @@ -5,7 +5,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/RTDB/Timestamp/Timestamp.ino b/examples/RTDB/Timestamp/Timestamp.ino index 68f58f4ff..3fb3e14c6 100644 --- a/examples/RTDB/Timestamp/Timestamp.ino +++ b/examples/RTDB/Timestamp/Timestamp.ino @@ -6,7 +6,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/Storage/FirebaseStorage/DeleteFile/DeleteFile.ino b/examples/Storage/FirebaseStorage/DeleteFile/DeleteFile.ino index 20834e70a..f3265b20e 100644 --- a/examples/Storage/FirebaseStorage/DeleteFile/DeleteFile.ino +++ b/examples/Storage/FirebaseStorage/DeleteFile/DeleteFile.ino @@ -5,7 +5,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/Storage/FirebaseStorage/DownloadFile/DownloadFile.ino b/examples/Storage/FirebaseStorage/DownloadFile/DownloadFile.ino index f7c7d931a..932b089c6 100644 --- a/examples/Storage/FirebaseStorage/DownloadFile/DownloadFile.ino +++ b/examples/Storage/FirebaseStorage/DownloadFile/DownloadFile.ino @@ -5,7 +5,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/Storage/FirebaseStorage/DownloadFileOTA/DownloadFileOTA.ino b/examples/Storage/FirebaseStorage/DownloadFileOTA/DownloadFileOTA.ino index 8094f88bb..88781c5a8 100644 --- a/examples/Storage/FirebaseStorage/DownloadFileOTA/DownloadFileOTA.ino +++ b/examples/Storage/FirebaseStorage/DownloadFileOTA/DownloadFileOTA.ino @@ -5,7 +5,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/Storage/FirebaseStorage/ListFiles/ListFiles.ino b/examples/Storage/FirebaseStorage/ListFiles/ListFiles.ino index b6b71221c..34b4e2960 100644 --- a/examples/Storage/FirebaseStorage/ListFiles/ListFiles.ino +++ b/examples/Storage/FirebaseStorage/ListFiles/ListFiles.ino @@ -5,7 +5,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/Storage/FirebaseStorage/Metadata/Metadata.ino b/examples/Storage/FirebaseStorage/Metadata/Metadata.ino index 114a11abe..d8c165714 100644 --- a/examples/Storage/FirebaseStorage/Metadata/Metadata.ino +++ b/examples/Storage/FirebaseStorage/Metadata/Metadata.ino @@ -5,7 +5,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/Storage/FirebaseStorage/UploadByteArrayMemory/UploadByteArrayMemory.ino b/examples/Storage/FirebaseStorage/UploadByteArrayMemory/UploadByteArrayMemory.ino index 7dacc85f4..ab51c1af3 100644 --- a/examples/Storage/FirebaseStorage/UploadByteArrayMemory/UploadByteArrayMemory.ino +++ b/examples/Storage/FirebaseStorage/UploadByteArrayMemory/UploadByteArrayMemory.ino @@ -5,7 +5,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/Storage/FirebaseStorage/UploadFile/UploadFile.ino b/examples/Storage/FirebaseStorage/UploadFile/UploadFile.ino index 9cfffb77e..428ae5cb2 100644 --- a/examples/Storage/FirebaseStorage/UploadFile/UploadFile.ino +++ b/examples/Storage/FirebaseStorage/UploadFile/UploadFile.ino @@ -5,7 +5,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/Storage/GoogleCloudStorage/DeleteFile/DeleteFile.ino b/examples/Storage/GoogleCloudStorage/DeleteFile/DeleteFile.ino index 9617409f7..f2e5b26e0 100644 --- a/examples/Storage/GoogleCloudStorage/DeleteFile/DeleteFile.ino +++ b/examples/Storage/GoogleCloudStorage/DeleteFile/DeleteFile.ino @@ -5,7 +5,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/Storage/GoogleCloudStorage/DownloadFile/DownloadFile.ino b/examples/Storage/GoogleCloudStorage/DownloadFile/DownloadFile.ino index c2cd7a983..7abb1d4a1 100644 --- a/examples/Storage/GoogleCloudStorage/DownloadFile/DownloadFile.ino +++ b/examples/Storage/GoogleCloudStorage/DownloadFile/DownloadFile.ino @@ -5,7 +5,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/Storage/GoogleCloudStorage/DownloadFileOTA/DownloadFileOTA.ino b/examples/Storage/GoogleCloudStorage/DownloadFileOTA/DownloadFileOTA.ino index 5d8b6c587..d198004d3 100644 --- a/examples/Storage/GoogleCloudStorage/DownloadFileOTA/DownloadFileOTA.ino +++ b/examples/Storage/GoogleCloudStorage/DownloadFileOTA/DownloadFileOTA.ino @@ -5,7 +5,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/Storage/GoogleCloudStorage/ListFiles/ListFiles.ino b/examples/Storage/GoogleCloudStorage/ListFiles/ListFiles.ino index 9f51d71a0..53979698f 100644 --- a/examples/Storage/GoogleCloudStorage/ListFiles/ListFiles.ino +++ b/examples/Storage/GoogleCloudStorage/ListFiles/ListFiles.ino @@ -5,7 +5,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/Storage/GoogleCloudStorage/Metadata/Metadata.ino b/examples/Storage/GoogleCloudStorage/Metadata/Metadata.ino index 2336027c3..37fcf1a4f 100644 --- a/examples/Storage/GoogleCloudStorage/Metadata/Metadata.ino +++ b/examples/Storage/GoogleCloudStorage/Metadata/Metadata.ino @@ -5,7 +5,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/examples/Storage/GoogleCloudStorage/UploadFile/UploadFile.ino b/examples/Storage/GoogleCloudStorage/UploadFile/UploadFile.ino index 5e51caee8..5732d98b1 100644 --- a/examples/Storage/GoogleCloudStorage/UploadFile/UploadFile.ino +++ b/examples/Storage/GoogleCloudStorage/UploadFile/UploadFile.ino @@ -5,7 +5,7 @@ * * Github: https://github.com/mobizt/Firebase-ESP-Client * - * Copyright (c) 2022 mobizt + * Copyright (c) 2023 mobizt * */ diff --git a/src/FB_Const.h b/src/FB_Const.h index 548c3bbf4..0e79df43d 100644 --- a/src/FB_Const.h +++ b/src/FB_Const.h @@ -3,10 +3,10 @@ * Created December 12, 2022 * * This work is a part of Firebase ESP Client library - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * The MIT License (MIT) - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * * Permission is hereby granted, free of charge, to any person returning a copy of diff --git a/src/FB_Utils.h b/src/FB_Utils.h index ba8a19a5e..b8b31c1d8 100644 --- a/src/FB_Utils.h +++ b/src/FB_Utils.h @@ -5,10 +5,10 @@ * Created December 20, 2022 * * This work is a part of Firebase ESP Client library - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * The MIT License (MIT) - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * * Permission is hereby granted, free of charge, to any person returning a copy of diff --git a/src/Firebase.cpp b/src/Firebase.cpp index 13ecb5b55..a7db3524e 100644 --- a/src/Firebase.cpp +++ b/src/Firebase.cpp @@ -4,7 +4,7 @@ * Created December 19, 2022 * * The MIT License (MIT) - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * * Permission is hereby granted, free of charge, to any person returning a copy of diff --git a/src/Firebase.h b/src/Firebase.h index 188d74c7c..0b92cf151 100644 --- a/src/Firebase.h +++ b/src/Firebase.h @@ -5,7 +5,7 @@ * Created December 19, 2022 * * The MIT License (MIT) - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * * Permission is hereby granted, free of charge, to any person returning a copy of diff --git a/src/Firebase_ESP_Client.h b/src/Firebase_ESP_Client.h index 22c3cb807..965a31411 100644 --- a/src/Firebase_ESP_Client.h +++ b/src/Firebase_ESP_Client.h @@ -16,10 +16,10 @@ * * * This work is a part of Firebase ESP Client library - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * The MIT License (MIT) - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * * Permission is hereby granted, free of charge, to any person returning a copy of diff --git a/src/MB_NTP.h b/src/MB_NTP.h index c2ff0aacf..0b352e94c 100644 --- a/src/MB_NTP.h +++ b/src/MB_NTP.h @@ -1,179 +1,179 @@ -/** - * Mobizt's UDP NTP Time Client, version 1.0.1 - * - * The MIT License (MIT) - * Copyright (c) 2022 K. Suwatchai (Mobizt) - * - * - * Permission is hereby granted, free of charge, to any person returning a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * 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. - */ - -#ifndef MB_NTP_H -#define MB_NTP_H - -#include -#include "Udp.h" - -class MB_NTP -{ - -public: - MB_NTP(); - - MB_NTP(UDP *client, const char *host, uint16_t port, int timeZoneOffset = 0); - - ~MB_NTP(); - - bool begin(); - - bool begin(UDP *client, const char *host, uint16_t port, int timeZoneOffset = 0); - - uint32_t getTime(uint16_t waitMillisec = 0); - -private: - UDP *udp = NULL; - String host; - uint16_t port = 0; - int timeZoneOffset = 0; - bool udpStarted = false; - uint16_t intPort = 55432; - unsigned long timeout = 2000; - unsigned long lastRequestMs = 0; - uint32_t ts = 0; - const uint8_t ntpPacketSize = 48; - uint8_t packet[48]; - bool sendRequest(); - bool getResponse(); -}; - -MB_NTP::MB_NTP() -{ -} - -MB_NTP::~MB_NTP() -{ -} - -MB_NTP::MB_NTP(UDP *client, const char *host, uint16_t port, int timeZoneOffset) -{ - begin(client, host, port, timeZoneOffset); -} - -bool MB_NTP::begin(UDP *client, const char *host, uint16_t port, int timeZoneOffset) -{ - this->udp = client; - this->host = host; - this->port = port; - this->timeZoneOffset = timeZoneOffset; - - return this->begin(); -} - -bool MB_NTP::begin() -{ - if (!this->udp || this->host.length() == 0 || this->port == 0) - return false; - - udpStarted = udp->begin(intPort) > 0; - - return udpStarted; -} - -bool MB_NTP::sendRequest() -{ - if (!udpStarted) - return false; - - if (lastRequestMs == 0 || millis() - lastRequestMs > timeout) - { - lastRequestMs = millis(); - - if (!udp->beginPacket(host.c_str(), port)) - return false; - - memset(packet, 0, ntpPacketSize); - - // https://datatracker.ietf.org/doc/html/rfc5905 - packet[0] = 0b11100011; // leap indicator[0-1], version number[2-4], mode[5-7] - packet[1] = 0; // stratum 0 is unspecified or invalid - packet[2] = 6; // polling interval in log2 seconds - packet[3] = 236; // precision in log2 seconds - - // 4 bytes for Root Delay - // 4 bytes for Root Dispersion - // 4 bytes for Reference ID (kiss code) - // 8 bytes for Reference Timestamp - // 8 bytes for Origin Timestamp - // 8 bytes for Receive Timestamp - // 8 bytes for Transmit Timestamp - - if (udp->write(packet, ntpPacketSize) != ntpPacketSize) - return false; - - if (!udp->endPacket()) - return false; - } - - return true; -} - -bool MB_NTP::getResponse() -{ - - if (!udpStarted) - return false; - - if (!udp->parsePacket()) - return false; - - memset(packet, 0, ntpPacketSize); - - if (udp->read(packet, ntpPacketSize) > 0) - { - unsigned long highWord = word(packet[40], packet[41]); - unsigned long lowWord = word(packet[42], packet[43]); - - unsigned long s1900 = highWord << 16 | lowWord; - - ts = s1900 - 2208988800UL + timeZoneOffset; - - return true; - } - - return false; -} - -uint32_t MB_NTP::getTime(uint16_t waitMillisec) -{ - - if (getResponse()) - return ts; - - if (!sendRequest()) - return 0; - - if (waitMillisec > 0) - delay(waitMillisec); - - if (!getResponse()) - return 0; - - return ts; -} - +/** + * Mobizt's UDP NTP Time Client, version 1.0.1 + * + * The MIT License (MIT) + * Copyright (c) 2023 K. Suwatchai (Mobizt) + * + * + * Permission is hereby granted, free of charge, to any person returning a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * 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. + */ + +#ifndef MB_NTP_H +#define MB_NTP_H + +#include +#include "Udp.h" + +class MB_NTP +{ + +public: + MB_NTP(); + + MB_NTP(UDP *client, const char *host, uint16_t port, int timeZoneOffset = 0); + + ~MB_NTP(); + + bool begin(); + + bool begin(UDP *client, const char *host, uint16_t port, int timeZoneOffset = 0); + + uint32_t getTime(uint16_t waitMillisec = 0); + +private: + UDP *udp = NULL; + String host; + uint16_t port = 0; + int timeZoneOffset = 0; + bool udpStarted = false; + uint16_t intPort = 55432; + unsigned long timeout = 2000; + unsigned long lastRequestMs = 0; + uint32_t ts = 0; + const uint8_t ntpPacketSize = 48; + uint8_t packet[48]; + bool sendRequest(); + bool getResponse(); +}; + +MB_NTP::MB_NTP() +{ +} + +MB_NTP::~MB_NTP() +{ +} + +MB_NTP::MB_NTP(UDP *client, const char *host, uint16_t port, int timeZoneOffset) +{ + begin(client, host, port, timeZoneOffset); +} + +bool MB_NTP::begin(UDP *client, const char *host, uint16_t port, int timeZoneOffset) +{ + this->udp = client; + this->host = host; + this->port = port; + this->timeZoneOffset = timeZoneOffset; + + return this->begin(); +} + +bool MB_NTP::begin() +{ + if (!this->udp || this->host.length() == 0 || this->port == 0) + return false; + + udpStarted = udp->begin(intPort) > 0; + + return udpStarted; +} + +bool MB_NTP::sendRequest() +{ + if (!udpStarted) + return false; + + if (lastRequestMs == 0 || millis() - lastRequestMs > timeout) + { + lastRequestMs = millis(); + + if (!udp->beginPacket(host.c_str(), port)) + return false; + + memset(packet, 0, ntpPacketSize); + + // https://datatracker.ietf.org/doc/html/rfc5905 + packet[0] = 0b11100011; // leap indicator[0-1], version number[2-4], mode[5-7] + packet[1] = 0; // stratum 0 is unspecified or invalid + packet[2] = 6; // polling interval in log2 seconds + packet[3] = 236; // precision in log2 seconds + + // 4 bytes for Root Delay + // 4 bytes for Root Dispersion + // 4 bytes for Reference ID (kiss code) + // 8 bytes for Reference Timestamp + // 8 bytes for Origin Timestamp + // 8 bytes for Receive Timestamp + // 8 bytes for Transmit Timestamp + + if (udp->write(packet, ntpPacketSize) != ntpPacketSize) + return false; + + if (!udp->endPacket()) + return false; + } + + return true; +} + +bool MB_NTP::getResponse() +{ + + if (!udpStarted) + return false; + + if (!udp->parsePacket()) + return false; + + memset(packet, 0, ntpPacketSize); + + if (udp->read(packet, ntpPacketSize) > 0) + { + unsigned long highWord = word(packet[40], packet[41]); + unsigned long lowWord = word(packet[42], packet[43]); + + unsigned long s1900 = highWord << 16 | lowWord; + + ts = s1900 - 2208988800UL + timeZoneOffset; + + return true; + } + + return false; +} + +uint32_t MB_NTP::getTime(uint16_t waitMillisec) +{ + + if (getResponse()) + return ts; + + if (!sendRequest()) + return 0; + + if (waitMillisec > 0) + delay(waitMillisec); + + if (!getResponse()) + return 0; + + return ts; +} + #endif \ No newline at end of file diff --git a/src/README.md b/src/README.md index 6ca912309..574a28168 100644 --- a/src/README.md +++ b/src/README.md @@ -5854,7 +5854,7 @@ e.g. to(), to(), to() The MIT License (MIT) -Copyright (c) 2022 K. Suwatchai (Mobizt) +Copyright (c) 2023 K. Suwatchai (Mobizt) Permission is hereby granted, free of charge, to any person returning a copy of diff --git a/src/addons/FireSense/FireSense.h b/src/addons/FireSense/FireSense.h index f85ccee6a..d22b702a3 100644 --- a/src/addons/FireSense/FireSense.h +++ b/src/addons/FireSense/FireSense.h @@ -10,10 +10,10 @@ * Created July 10, 2022 * * This work is a part of Firebase ESP Client library - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * The MIT License (MIT) - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * * Permission is hereby granted, free of charge, to any person returning a copy diff --git a/src/addons/FireSense/README.md b/src/addons/FireSense/README.md index 4bb95349c..a78157a76 100644 --- a/src/addons/FireSense/README.md +++ b/src/addons/FireSense/README.md @@ -252,7 +252,7 @@ return **`String`** The unique id String of device. The MIT License (MIT) -Copyright (c) 2021 K. Suwatchai (Mobizt) +Copyright (c) 2023 K. Suwatchai (Mobizt) Permission is hereby granted, free of charge, to any person returning a copy of diff --git a/src/firestore/FB_Firestore.cpp b/src/firestore/FB_Firestore.cpp index ff1fded85..1d31f2dfd 100644 --- a/src/firestore/FB_Firestore.cpp +++ b/src/firestore/FB_Firestore.cpp @@ -6,10 +6,10 @@ * Created December 25, 2022 * * This work is a part of Firebase ESP Client library - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * The MIT License (MIT) - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * * Permission is hereby granted, free of charge, to any person returning a copy of diff --git a/src/firestore/FB_Firestore.h b/src/firestore/FB_Firestore.h index ee11bf89a..a0af600e7 100644 --- a/src/firestore/FB_Firestore.h +++ b/src/firestore/FB_Firestore.h @@ -6,10 +6,10 @@ * Created December 25, 2022 * * This work is a part of Firebase ESP Client library - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * The MIT License (MIT) - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * * Permission is hereby granted, free of charge, to any person returning a copy of diff --git a/src/functions/FB_Functions.cpp b/src/functions/FB_Functions.cpp index 1f152a824..8b09d808f 100644 --- a/src/functions/FB_Functions.cpp +++ b/src/functions/FB_Functions.cpp @@ -6,10 +6,10 @@ * Created December 25, 2022 * * This work is a part of Firebase ESP Client library - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * The MIT License (MIT) - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * * Permission is hereby granted, free of charge, to any person returning a copy of diff --git a/src/functions/FB_Functions.h b/src/functions/FB_Functions.h index 0202d7cbf..8ba120f3d 100644 --- a/src/functions/FB_Functions.h +++ b/src/functions/FB_Functions.h @@ -6,10 +6,10 @@ * Created December 25, 2022 * * This work is a part of Firebase ESP Client library - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * The MIT License (MIT) - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * * Permission is hereby granted, free of charge, to any person returning a copy of diff --git a/src/functions/FunctionsConfig.cpp b/src/functions/FunctionsConfig.cpp index b3066f41f..a68698249 100644 --- a/src/functions/FunctionsConfig.cpp +++ b/src/functions/FunctionsConfig.cpp @@ -6,10 +6,10 @@ * Created December 22, 2022 * * This work is a part of Firebase ESP Client library - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * The MIT License (MIT) - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * * Permission is hereby granted, free of charge, to any person returning a copy of diff --git a/src/functions/FunctionsConfig.h b/src/functions/FunctionsConfig.h index 8b887c703..c28e6dd89 100644 --- a/src/functions/FunctionsConfig.h +++ b/src/functions/FunctionsConfig.h @@ -6,10 +6,10 @@ * Created December 22, 2022 * * This work is a part of Firebase ESP Client library - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * The MIT License (MIT) - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * * Permission is hereby granted, free of charge, to any person returning a copy of diff --git a/src/functions/PocicyBuilder.cpp b/src/functions/PocicyBuilder.cpp index ca2b71d79..62185791e 100644 --- a/src/functions/PocicyBuilder.cpp +++ b/src/functions/PocicyBuilder.cpp @@ -6,10 +6,10 @@ * Created December 12, 2022 * * This work is a part of Firebase ESP Client library - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * The MIT License (MIT) - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * * Permission is hereby granted, free of charge, to any person returning a copy of diff --git a/src/functions/PolicyBuilder.h b/src/functions/PolicyBuilder.h index 588d50f87..a8b3f1868 100644 --- a/src/functions/PolicyBuilder.h +++ b/src/functions/PolicyBuilder.h @@ -6,10 +6,10 @@ * Created December 12, 2022 * * This work is a part of Firebase ESP Client library - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * The MIT License (MIT) - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * * Permission is hereby granted, free of charge, to any person returning a copy of diff --git a/src/gcs/GCS.cpp b/src/gcs/GCS.cpp index 0608f676f..a37f256f1 100644 --- a/src/gcs/GCS.cpp +++ b/src/gcs/GCS.cpp @@ -6,10 +6,10 @@ * Created December 25, 2022 * * This work is a part of Firebase ESP Client library - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * The MIT License (MIT) - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * * Permission is hereby granted, free of charge, to any person returning a copy of diff --git a/src/gcs/GCS.h b/src/gcs/GCS.h index 8037de998..6a6cddaef 100644 --- a/src/gcs/GCS.h +++ b/src/gcs/GCS.h @@ -6,10 +6,10 @@ * Created December 25, 2022 * * This work is a part of Firebase ESP Client library - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * The MIT License (MIT) - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * * Permission is hereby granted, free of charge, to any person returning a copy of diff --git a/src/json/FirebaseJson.cpp b/src/json/FirebaseJson.cpp index 1d06ad21a..d2508105e 100644 --- a/src/json/FirebaseJson.cpp +++ b/src/json/FirebaseJson.cpp @@ -14,7 +14,7 @@ * * * The MIT License (MIT) - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * Copyright (c) 2009-2017 Dave Gamble and cJSON contributors * * diff --git a/src/json/FirebaseJson.h b/src/json/FirebaseJson.h index 1e7cfc06d..48887d449 100644 --- a/src/json/FirebaseJson.h +++ b/src/json/FirebaseJson.h @@ -14,7 +14,7 @@ * * * The MIT License (MIT) - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * Copyright (c) 2009-2017 Dave Gamble and cJSON contributors * * diff --git a/src/json/MB_JSON/MB_JSON.c b/src/json/MB_JSON/MB_JSON.c index 69dd0f88f..bfaa44069 100644 --- a/src/json/MB_JSON/MB_JSON.c +++ b/src/json/MB_JSON/MB_JSON.c @@ -5,7 +5,7 @@ Created December 20, 2021 - Copyright (c) 2022 Mobizt (K. Suwatchai) + Copyright (c) 2023 Mobizt (K. Suwatchai) Copyright (c) 2009-2017 Dave Gamble and cJSON contributors diff --git a/src/json/MB_JSON/MB_JSON.h b/src/json/MB_JSON/MB_JSON.h index 2027ce3b4..0c8e6f18d 100644 --- a/src/json/MB_JSON/MB_JSON.h +++ b/src/json/MB_JSON/MB_JSON.h @@ -5,7 +5,7 @@ Created December 20, 2021 - Copyright (c) 2022 Mobizt (K. Suwatchai) + Copyright (c) 2023 Mobizt (K. Suwatchai) Copyright (c) 2009-2017 Dave Gamble and cJSON contributors diff --git a/src/json/MB_List.h b/src/json/MB_List.h index f929187e7..bdb215cf2 100644 --- a/src/json/MB_List.h +++ b/src/json/MB_List.h @@ -4,7 +4,7 @@ * Created November 1, 2022 * * The MIT License (MIT) - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * * Permission is hereby granted, free of charge, to any person obtaining a copy of diff --git a/src/json/MB_String.h b/src/json/MB_String.h index 5e0337fdf..775ade48d 100644 --- a/src/json/MB_String.h +++ b/src/json/MB_String.h @@ -1,6 +1,6 @@ /** - * Mobizt's SRAM/PSRAM supported String, version 1.2.8 + * Mobizt's SRAM/PSRAM supported String, version 1.2.9 * * Created December 3, 2022 * @@ -53,7 +53,7 @@ * - Initial release * * The MIT License (MIT) - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * * Permission is hereby granted, free of charge, to any person returning a copy of diff --git a/src/mbfs/MB_FS.h b/src/mbfs/MB_FS.h index 2973b63d2..3b3ccbc7b 100644 --- a/src/mbfs/MB_FS.h +++ b/src/mbfs/MB_FS.h @@ -6,7 +6,7 @@ * Created November 10, 2022 * * The MIT License (MIT) - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * * Permission is hereby granted, free of charge, to any person returning a copy of diff --git a/src/message/FCM.cpp b/src/message/FCM.cpp index fa626f94f..6e935ef31 100644 --- a/src/message/FCM.cpp +++ b/src/message/FCM.cpp @@ -6,10 +6,10 @@ * Created December 25, 2022 * * This work is a part of Firebase ESP Client library - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * The MIT License (MIT) - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * * Permission is hereby granted, free of charge, to any person returning a copy of diff --git a/src/message/FCM.h b/src/message/FCM.h index e88779ca7..db8739883 100644 --- a/src/message/FCM.h +++ b/src/message/FCM.h @@ -6,10 +6,10 @@ * Created December 25, 2022 * * This work is a part of Firebase ESP Client library - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * The MIT License (MIT) - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * * Permission is hereby granted, free of charge, to any person returning a copy of diff --git a/src/rtdb/FB_RTDB.cpp b/src/rtdb/FB_RTDB.cpp index 56b26e47d..a4d97ed06 100644 --- a/src/rtdb/FB_RTDB.cpp +++ b/src/rtdb/FB_RTDB.cpp @@ -6,10 +6,10 @@ * Created December 25, 2022 * * This work is a part of Firebase ESP Client library - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * The MIT License (MIT) - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * * Permission is hereby granted, free of charge, to any person returning a copy of diff --git a/src/rtdb/FB_RTDB.h b/src/rtdb/FB_RTDB.h index c4351c42c..c0f0d4c01 100644 --- a/src/rtdb/FB_RTDB.h +++ b/src/rtdb/FB_RTDB.h @@ -6,10 +6,10 @@ * Created December 25, 2022 * * This work is a part of Firebase ESP Client library - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * The MIT License (MIT) - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * * Permission is hereby granted, free of charge, to any person returning a copy of diff --git a/src/rtdb/QueryFilter.cpp b/src/rtdb/QueryFilter.cpp index b94f270d2..04ca88454 100644 --- a/src/rtdb/QueryFilter.cpp +++ b/src/rtdb/QueryFilter.cpp @@ -6,10 +6,10 @@ * Created December 19, 2022 * * This work is a part of Firebase ESP Client library - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * The MIT License (MIT) - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * * Permission is hereby granted, free of charge, to any person returning a copy of diff --git a/src/rtdb/QueryFilter.h b/src/rtdb/QueryFilter.h index c02c0d007..c0d8a98a6 100644 --- a/src/rtdb/QueryFilter.h +++ b/src/rtdb/QueryFilter.h @@ -6,10 +6,10 @@ * Created December 19, 2022 * * This work is a part of Firebase ESP Client library - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * The MIT License (MIT) - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * * Permission is hereby granted, free of charge, to any person returning a copy of diff --git a/src/rtdb/QueueInfo.cpp b/src/rtdb/QueueInfo.cpp index 0220d12d6..4d3285d32 100644 --- a/src/rtdb/QueueInfo.cpp +++ b/src/rtdb/QueueInfo.cpp @@ -6,10 +6,10 @@ * Created December 25, 2022 * * This work is a part of Firebase ESP Client library - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * The MIT License (MIT) - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * * Permission is hereby granted, free of charge, to any person returning a copy of diff --git a/src/rtdb/QueueInfo.h b/src/rtdb/QueueInfo.h index 00dafb1cf..5936fc4a0 100644 --- a/src/rtdb/QueueInfo.h +++ b/src/rtdb/QueueInfo.h @@ -6,10 +6,10 @@ * Created December 25, 2022 * * This work is a part of Firebase ESP Client library - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * The MIT License (MIT) - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * * Permission is hereby granted, free of charge, to any person returning a copy of diff --git a/src/rtdb/QueueManager.cpp b/src/rtdb/QueueManager.cpp index c1f94e605..5d4bd2e5a 100644 --- a/src/rtdb/QueueManager.cpp +++ b/src/rtdb/QueueManager.cpp @@ -6,10 +6,10 @@ * Created November 1, 2022 * * This work is a part of Firebase ESP Client library - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * The MIT License (MIT) - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * * Permission is hereby granted, free of charge, to any person returning a copy of diff --git a/src/rtdb/QueueManager.h b/src/rtdb/QueueManager.h index 5fbba48f2..1ca7da182 100644 --- a/src/rtdb/QueueManager.h +++ b/src/rtdb/QueueManager.h @@ -6,10 +6,10 @@ * Created November 1, 2022 * * This work is a part of Firebase ESP Client library - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * The MIT License (MIT) - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * * Permission is hereby granted, free of charge, to any person returning a copy of diff --git a/src/rtdb/stream/FB_MP_Stream.cpp b/src/rtdb/stream/FB_MP_Stream.cpp index 5bd73819e..99244d3b0 100644 --- a/src/rtdb/stream/FB_MP_Stream.cpp +++ b/src/rtdb/stream/FB_MP_Stream.cpp @@ -6,10 +6,10 @@ * Created December 19, 2022 * * This work is a part of Firebase ESP Client library - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * The MIT License (MIT) - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * * Permission is hereby granted, free of charge, to any person returning a copy of diff --git a/src/rtdb/stream/FB_MP_Stream.h b/src/rtdb/stream/FB_MP_Stream.h index 133f9c2a1..684afad0d 100644 --- a/src/rtdb/stream/FB_MP_Stream.h +++ b/src/rtdb/stream/FB_MP_Stream.h @@ -6,10 +6,10 @@ * Created December 19, 2022 * * This work is a part of Firebase ESP Client library - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * The MIT License (MIT) - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * * Permission is hereby granted, free of charge, to any person returning a copy of diff --git a/src/rtdb/stream/FB_Stream.cpp b/src/rtdb/stream/FB_Stream.cpp index 0e9cadc43..3b73fcee4 100644 --- a/src/rtdb/stream/FB_Stream.cpp +++ b/src/rtdb/stream/FB_Stream.cpp @@ -6,10 +6,10 @@ * Created December 19, 2022 * * This work is a part of Firebase ESP Client library - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * The MIT License (MIT) - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * * Permission is hereby granted, free of charge, to any person returning a copy of diff --git a/src/rtdb/stream/FB_Stream.h b/src/rtdb/stream/FB_Stream.h index 463b16628..54bf6c7bb 100644 --- a/src/rtdb/stream/FB_Stream.h +++ b/src/rtdb/stream/FB_Stream.h @@ -6,10 +6,10 @@ * Created December 19, 2022 * * This work is a part of Firebase ESP Client library - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * The MIT License (MIT) - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * * Permission is hereby granted, free of charge, to any person returning a copy of diff --git a/src/session/FB_Session.cpp b/src/session/FB_Session.cpp index 622e162e5..25ef07e78 100644 --- a/src/session/FB_Session.cpp +++ b/src/session/FB_Session.cpp @@ -6,10 +6,10 @@ * Created December 25, 2022 * * This work is a part of Firebase ESP Client library - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * The MIT License (MIT) - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * * Permission is hereby granted, free of charge, to any person returning a copy of diff --git a/src/session/FB_Session.h b/src/session/FB_Session.h index abb498e75..9b3f2ae52 100644 --- a/src/session/FB_Session.h +++ b/src/session/FB_Session.h @@ -6,10 +6,10 @@ * Created December 25, 2022 * * This work is a part of Firebase ESP Client library - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * The MIT License (MIT) - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * * Permission is hereby granted, free of charge, to any person returning a copy of diff --git a/src/signer/Signer.cpp b/src/signer/Signer.cpp index 17b0449d6..c3c8d0c3b 100644 --- a/src/signer/Signer.cpp +++ b/src/signer/Signer.cpp @@ -6,10 +6,10 @@ * Created December 25, 2022 * * This work is a part of Firebase ESP Client library - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * The MIT License (MIT) - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * * Permission is hereby granted, free of charge, to any person returning a copy of diff --git a/src/signer/Signer.h b/src/signer/Signer.h index de1570656..76f9f5f5a 100644 --- a/src/signer/Signer.h +++ b/src/signer/Signer.h @@ -6,10 +6,10 @@ * Created December 25, 2022 * * This work is a part of Firebase ESP Client library - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * The MIT License (MIT) - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * * Permission is hereby granted, free of charge, to any person returning a copy of diff --git a/src/storage/FCS.cpp b/src/storage/FCS.cpp index 0774b2222..a4b5d4e51 100644 --- a/src/storage/FCS.cpp +++ b/src/storage/FCS.cpp @@ -6,10 +6,10 @@ * Created December 25, 2022 * * This work is a part of Firebase ESP Client library - * Copyright (c) 2021 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * The MIT License (MIT) - * Copyright (c) 2021 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * * Permission is hereby granted, free of charge, to any person returning a copy of diff --git a/src/storage/FCS.h b/src/storage/FCS.h index 2cda871bb..92ad8068c 100644 --- a/src/storage/FCS.h +++ b/src/storage/FCS.h @@ -6,10 +6,10 @@ * Created December 25, 2022 * * This work is a part of Firebase ESP Client library - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * The MIT License (MIT) - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * * Permission is hereby granted, free of charge, to any person returning a copy of diff --git a/src/wcs/base/FB_TCP_Client_Base.h b/src/wcs/base/FB_TCP_Client_Base.h index 8aa1c5fd9..39fcf5fa3 100644 --- a/src/wcs/base/FB_TCP_Client_Base.h +++ b/src/wcs/base/FB_TCP_Client_Base.h @@ -4,7 +4,7 @@ * Created November 10, 2022 * * The MIT License (MIT) - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * * Permission is hereby granted, free of charge, to any person returning a copy of diff --git a/src/wcs/custom/FB_Custom_TCP_Client.h b/src/wcs/custom/FB_Custom_TCP_Client.h index c1f1a6cfe..d98f185a7 100644 --- a/src/wcs/custom/FB_Custom_TCP_Client.h +++ b/src/wcs/custom/FB_Custom_TCP_Client.h @@ -4,7 +4,7 @@ * Created December 19, 2022 * * The MIT License (MIT) - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * TCPClient Arduino library for ESP32 * diff --git a/src/wcs/esp32/FB_TCP_Client.cpp b/src/wcs/esp32/FB_TCP_Client.cpp index 58c25b5bb..297e83249 100644 --- a/src/wcs/esp32/FB_TCP_Client.cpp +++ b/src/wcs/esp32/FB_TCP_Client.cpp @@ -4,7 +4,7 @@ * Created December 19, 2022 * * The MIT License (MIT) - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * * Copyright (c) 2015 Markus Sattler. All rights reserved. diff --git a/src/wcs/esp32/FB_TCP_Client.h b/src/wcs/esp32/FB_TCP_Client.h index f03dffd43..9dfe9ebc6 100644 --- a/src/wcs/esp32/FB_TCP_Client.h +++ b/src/wcs/esp32/FB_TCP_Client.h @@ -4,7 +4,7 @@ * Created December 19, 2022 * * The MIT License (MIT) - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * * Copyright (c) 2015 Markus Sattler. All rights reserved. diff --git a/src/wcs/esp8266/FB_TCP_Client.cpp b/src/wcs/esp8266/FB_TCP_Client.cpp index ba059f3d9..9ee8f47dd 100644 --- a/src/wcs/esp8266/FB_TCP_Client.cpp +++ b/src/wcs/esp8266/FB_TCP_Client.cpp @@ -4,7 +4,7 @@ * Created December 19, 2022 * * The MIT License (MIT) - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * * Permission is hereby granted, free of charge, to any person returning a copy of diff --git a/src/wcs/esp8266/FB_TCP_Client.h b/src/wcs/esp8266/FB_TCP_Client.h index 9a78719a2..80b085630 100644 --- a/src/wcs/esp8266/FB_TCP_Client.h +++ b/src/wcs/esp8266/FB_TCP_Client.h @@ -4,7 +4,7 @@ * Created December 19, 2022 * * The MIT License (MIT) - * Copyright (c) 2022 K. Suwatchai (Mobizt) + * Copyright (c) 2023 K. Suwatchai (Mobizt) * * * Permission is hereby granted, free of charge, to any person returning a copy of