diff --git a/examples/Authentications/LegacyTokenAuthen/LegacyTokenAuthen.ino b/examples/Authentications/LegacyTokenAuthen/LegacyTokenAuthen.ino index 01514b31..dd75bb95 100644 --- a/examples/Authentications/LegacyTokenAuthen/LegacyTokenAuthen.ino +++ b/examples/Authentications/LegacyTokenAuthen/LegacyTokenAuthen.ino @@ -21,7 +21,7 @@ #elif defined(ESP8266) #include #include -#elif defined(PICO_RP2040) +#elif defined(ARDUINO_RASPBERRY_PI_PICO_W) #include #include #endif diff --git a/examples/Authentications/ReAuthenticate/ReAuthenticate.ino b/examples/Authentications/ReAuthenticate/ReAuthenticate.ino index 033840ad..6e2fb0c6 100644 --- a/examples/Authentications/ReAuthenticate/ReAuthenticate.ino +++ b/examples/Authentications/ReAuthenticate/ReAuthenticate.ino @@ -19,7 +19,7 @@ #elif defined(ESP8266) #include #include -#elif defined(PICO_RP2040) +#elif defined(ARDUINO_RASPBERRY_PI_PICO_W) #include #include #endif diff --git a/examples/Authentications/SignInAsAdmin/AccessTokenFile/AccessTokenFile.ino b/examples/Authentications/SignInAsAdmin/AccessTokenFile/AccessTokenFile.ino index 5e3e219c..293108e9 100644 --- a/examples/Authentications/SignInAsAdmin/AccessTokenFile/AccessTokenFile.ino +++ b/examples/Authentications/SignInAsAdmin/AccessTokenFile/AccessTokenFile.ino @@ -33,7 +33,7 @@ #elif defined(ESP8266) #include #include -#elif defined(PICO_RP2040) +#elif defined(ARDUINO_RASPBERRY_PI_PICO_W) #include #include #endif diff --git a/examples/Authentications/SignInAsGuest/AnonymousSignin/AnonymousSignin.ino b/examples/Authentications/SignInAsGuest/AnonymousSignin/AnonymousSignin.ino index 4769751e..f299f28b 100644 --- a/examples/Authentications/SignInAsGuest/AnonymousSignin/AnonymousSignin.ino +++ b/examples/Authentications/SignInAsGuest/AnonymousSignin/AnonymousSignin.ino @@ -27,7 +27,7 @@ #elif defined(ESP8266) #include #include -#elif defined(PICO_RP2040) +#elif defined(ARDUINO_RASPBERRY_PI_PICO_W) #include #include #endif diff --git a/examples/Authentications/SignInAsUser/CustomToken/CustomToken.ino b/examples/Authentications/SignInAsUser/CustomToken/CustomToken.ino index a0aa9598..a1089597 100644 --- a/examples/Authentications/SignInAsUser/CustomToken/CustomToken.ino +++ b/examples/Authentications/SignInAsUser/CustomToken/CustomToken.ino @@ -29,7 +29,7 @@ #elif defined(ESP8266) #include #include -#elif defined(PICO_RP2040) +#elif defined(ARDUINO_RASPBERRY_PI_PICO_W) #include #include #endif diff --git a/examples/Authentications/SignInAsUser/CustomTokenFile/CustomTokenFile.ino b/examples/Authentications/SignInAsUser/CustomTokenFile/CustomTokenFile.ino index 81dbb75a..6d22552a 100644 --- a/examples/Authentications/SignInAsUser/CustomTokenFile/CustomTokenFile.ino +++ b/examples/Authentications/SignInAsUser/CustomTokenFile/CustomTokenFile.ino @@ -29,7 +29,7 @@ #elif defined(ESP8266) #include #include -#elif defined(PICO_RP2040) +#elif defined(ARDUINO_RASPBERRY_PI_PICO_W) #include #include #endif diff --git a/examples/Authentications/SignInAsUser/EmailPassword/EmailPassword.ino b/examples/Authentications/SignInAsUser/EmailPassword/EmailPassword.ino index ab1edce8..fa0de440 100644 --- a/examples/Authentications/SignInAsUser/EmailPassword/EmailPassword.ino +++ b/examples/Authentications/SignInAsUser/EmailPassword/EmailPassword.ino @@ -30,7 +30,7 @@ #elif defined(ESP8266) #include #include -#elif defined(PICO_RP2040) +#elif defined(ARDUINO_RASPBERRY_PI_PICO_W) #include #include #endif diff --git a/examples/Authentications/SignInWithAccessToken/SignInWithAccessToken.ino b/examples/Authentications/SignInWithAccessToken/SignInWithAccessToken.ino index 84abece6..83170447 100644 --- a/examples/Authentications/SignInWithAccessToken/SignInWithAccessToken.ino +++ b/examples/Authentications/SignInWithAccessToken/SignInWithAccessToken.ino @@ -19,7 +19,7 @@ #elif defined(ESP8266) #include #include -#elif defined(PICO_RP2040) +#elif defined(ARDUINO_RASPBERRY_PI_PICO_W) #include #include #endif diff --git a/examples/Authentications/SignInWithCustomToken/SignInWithCustomToken.ino b/examples/Authentications/SignInWithCustomToken/SignInWithCustomToken.ino index edbd2983..0edef025 100644 --- a/examples/Authentications/SignInWithCustomToken/SignInWithCustomToken.ino +++ b/examples/Authentications/SignInWithCustomToken/SignInWithCustomToken.ino @@ -19,7 +19,7 @@ #elif defined(ESP8266) #include #include -#elif defined(PICO_RP2040) +#elif defined(ARDUINO_RASPBERRY_PI_PICO_W) #include #include #endif diff --git a/examples/Authentications/SignInWithIDToken/SignInWithIDToken.ino b/examples/Authentications/SignInWithIDToken/SignInWithIDToken.ino index 6a1c20dd..7e322858 100644 --- a/examples/Authentications/SignInWithIDToken/SignInWithIDToken.ino +++ b/examples/Authentications/SignInWithIDToken/SignInWithIDToken.ino @@ -18,7 +18,7 @@ #elif defined(ESP8266) #include #include -#elif defined(PICO_RP2040) +#elif defined(ARDUINO_RASPBERRY_PI_PICO_W) #include #include #endif diff --git a/examples/Authentications/SignInWithRefreshAccessToken/SignInWithRefreshAccessToken.ino b/examples/Authentications/SignInWithRefreshAccessToken/SignInWithRefreshAccessToken.ino index 3760f414..1980ad01 100644 --- a/examples/Authentications/SignInWithRefreshAccessToken/SignInWithRefreshAccessToken.ino +++ b/examples/Authentications/SignInWithRefreshAccessToken/SignInWithRefreshAccessToken.ino @@ -19,7 +19,7 @@ #elif defined(ESP8266) #include #include -#elif defined(PICO_RP2040) +#elif defined(ARDUINO_RASPBERRY_PI_PICO_W) #include #include #endif diff --git a/examples/Authentications/SignInWithRefreshIDToken/SignInWithRefreshIDToken.ino b/examples/Authentications/SignInWithRefreshIDToken/SignInWithRefreshIDToken.ino index 7b896123..0adfd19b 100644 --- a/examples/Authentications/SignInWithRefreshIDToken/SignInWithRefreshIDToken.ino +++ b/examples/Authentications/SignInWithRefreshIDToken/SignInWithRefreshIDToken.ino @@ -19,7 +19,7 @@ #elif defined(ESP8266) #include #include -#elif defined(PICO_RP2040) +#elif defined(ARDUINO_RASPBERRY_PI_PICO_W) #include #include #endif diff --git a/examples/Authentications/TestMode/TestMode.ino b/examples/Authentications/TestMode/TestMode.ino index a01fb90b..144e857c 100644 --- a/examples/Authentications/TestMode/TestMode.ino +++ b/examples/Authentications/TestMode/TestMode.ino @@ -19,7 +19,7 @@ #elif defined(ESP8266) #include #include -#elif defined(PICO_RP2040) +#elif defined(ARDUINO_RASPBERRY_PI_PICO_W) #include #include #endif diff --git a/examples/Authentications/UserManagement/ResetPassword/ResetPassword.ino b/examples/Authentications/UserManagement/ResetPassword/ResetPassword.ino index 3de8a1ff..d2201c2a 100644 --- a/examples/Authentications/UserManagement/ResetPassword/ResetPassword.ino +++ b/examples/Authentications/UserManagement/ResetPassword/ResetPassword.ino @@ -21,7 +21,7 @@ #elif defined(ESP8266) #include #include -#elif defined(PICO_RP2040) +#elif defined(ARDUINO_RASPBERRY_PI_PICO_W) #include #include #endif diff --git a/examples/Authentications/UserManagement/SendVerification/SendVerification.ino b/examples/Authentications/UserManagement/SendVerification/SendVerification.ino index dde6a742..f5776100 100644 --- a/examples/Authentications/UserManagement/SendVerification/SendVerification.ino +++ b/examples/Authentications/UserManagement/SendVerification/SendVerification.ino @@ -25,7 +25,7 @@ #elif defined(ESP8266) #include #include -#elif defined(PICO_RP2040) +#elif defined(ARDUINO_RASPBERRY_PI_PICO_W) #include #include #endif diff --git a/examples/Authentications/UserManagement/Signup/Signup.ino b/examples/Authentications/UserManagement/Signup/Signup.ino index e26366c0..c9212c94 100644 --- a/examples/Authentications/UserManagement/Signup/Signup.ino +++ b/examples/Authentications/UserManagement/Signup/Signup.ino @@ -24,7 +24,7 @@ #elif defined(ESP8266) #include #include -#elif defined(PICO_RP2040) +#elif defined(ARDUINO_RASPBERRY_PI_PICO_W) #include #include #endif diff --git a/examples/BackupRestore/Flash/Flash.ino b/examples/BackupRestore/Flash/Flash.ino index 30254536..1ba0f5ec 100644 --- a/examples/BackupRestore/Flash/Flash.ino +++ b/examples/BackupRestore/Flash/Flash.ino @@ -18,7 +18,7 @@ #elif defined(ESP8266) #include #include -#elif defined(PICO_RP2040) +#elif defined(ARDUINO_RASPBERRY_PI_PICO_W) #include #include #endif diff --git a/examples/BackupRestore/SD/SD.ino b/examples/BackupRestore/SD/SD.ino index 574bd0ef..9dcd1a16 100644 --- a/examples/BackupRestore/SD/SD.ino +++ b/examples/BackupRestore/SD/SD.ino @@ -21,7 +21,7 @@ #elif defined(ESP8266) #include #include -#elif defined(PICO_RP2040) +#elif defined(ARDUINO_RASPBERRY_PI_PICO_W) #include #include #endif diff --git a/examples/Basic/Basic.ino b/examples/Basic/Basic.ino index 5a7c285c..7ceeac9b 100644 --- a/examples/Basic/Basic.ino +++ b/examples/Basic/Basic.ino @@ -17,7 +17,7 @@ #elif defined(ESP8266) #include #include -#elif defined(PICO_RP2040) +#elif defined(ARDUINO_RASPBERRY_PI_PICO_W) #include #include #endif diff --git a/examples/BasicCert/BasicCert.ino b/examples/BasicCert/BasicCert.ino index da9c4c6b..c3c504e6 100644 --- a/examples/BasicCert/BasicCert.ino +++ b/examples/BasicCert/BasicCert.ino @@ -17,7 +17,7 @@ #elif defined(ESP8266) #include #include -#elif defined(PICO_RP2040) +#elif defined(ARDUINO_RASPBERRY_PI_PICO_W) #include #include #endif diff --git a/examples/BasicEthernet/BasicEthernet.ino b/examples/BasicEthernet/BasicEthernet.ino index 72a5b355..7fe8db75 100644 --- a/examples/BasicEthernet/BasicEthernet.ino +++ b/examples/BasicEthernet/BasicEthernet.ino @@ -102,9 +102,15 @@ void setupFirebase() config.token_status_callback = tokenStatusCallback; // see addons/TokenHelper.h /* Assign the pointer to Ethernet module lwip interface */ +#if defined(ENABLE_ESP8266_ENC28J60_ETH) config.spi_ethernet_module.enc28j60 = ð - // config.spi_ethernet_module.w5100 = ð - // config.spi_ethernet_module.w5500 = ð +#endif +#if defined(ENABLE_ESP8266_W5100_ETH) + config.spi_ethernet_module.w5100 = ð +#endif +#if defined(ENABLE_ESP8266_W5500_ETH) + config.spi_ethernet_module.w5500 = ð +#endif // Or use legacy authenticate method // config.database_url = DATABASE_URL; diff --git a/examples/Blob/Blob.ino b/examples/Blob/Blob.ino index 509bc772..75364c05 100644 --- a/examples/Blob/Blob.ino +++ b/examples/Blob/Blob.ino @@ -18,7 +18,7 @@ #elif defined(ESP8266) #include #include -#elif defined(PICO_RP2040) +#elif defined(ARDUINO_RASPBERRY_PI_PICO_W) #include #include #endif diff --git a/examples/Blynk/Blynk.ino b/examples/Blynk/Blynk.ino index c8b3ac51..493956f9 100644 --- a/examples/Blynk/Blynk.ino +++ b/examples/Blynk/Blynk.ino @@ -18,7 +18,7 @@ #elif defined(ESP8266) #include #include -#elif defined(PICO_RP2040) +#elif defined(ARDUINO_RASPBERRY_PI_PICO_W) #include #include #endif diff --git a/examples/DataChangesListener/Callback/Callback.ino b/examples/DataChangesListener/Callback/Callback.ino index e706cff5..ae3fd3b6 100644 --- a/examples/DataChangesListener/Callback/Callback.ino +++ b/examples/DataChangesListener/Callback/Callback.ino @@ -15,7 +15,7 @@ #elif defined(ESP8266) #include #include -#elif defined(PICO_RP2040) +#elif defined(ARDUINO_RASPBERRY_PI_PICO_W) #include #include #endif @@ -192,7 +192,7 @@ void loop() // Firebase.ready() should be called repeatedly to handle authentication tasks. -#if defined(PICO_RP2040) +#if defined(ARDUINO_RASPBERRY_PI_PICO_W) Firebase.runStream(); #endif diff --git a/examples/DataChangesListener/MultiPath/MultiPath.ino b/examples/DataChangesListener/MultiPath/MultiPath.ino index daeabd9a..5b0d8bcc 100644 --- a/examples/DataChangesListener/MultiPath/MultiPath.ino +++ b/examples/DataChangesListener/MultiPath/MultiPath.ino @@ -16,7 +16,7 @@ #elif defined(ESP8266) #include #include -#elif defined(PICO_RP2040) +#elif defined(ARDUINO_RASPBERRY_PI_PICO_W) #include #include #endif @@ -205,7 +205,7 @@ void loop() // Firebase.ready() should be called repeatedly to handle authentication tasks. -#if defined(PICO_RP2040) +#if defined(ARDUINO_RASPBERRY_PI_PICO_W) Firebase.runStream(); #endif diff --git a/examples/DataChangesListener/NoCallback/NoCallback.ino b/examples/DataChangesListener/NoCallback/NoCallback.ino index 9a6201f4..5ab3adf4 100644 --- a/examples/DataChangesListener/NoCallback/NoCallback.ino +++ b/examples/DataChangesListener/NoCallback/NoCallback.ino @@ -16,7 +16,7 @@ #elif defined(ESP8266) #include #include -#elif defined(PICO_RP2040) +#elif defined(ARDUINO_RASPBERRY_PI_PICO_W) #include #include #endif diff --git a/examples/DataChangesListener/SingleDataObject/SingleDataObject.ino b/examples/DataChangesListener/SingleDataObject/SingleDataObject.ino index 0d8259d1..9cc372da 100644 --- a/examples/DataChangesListener/SingleDataObject/SingleDataObject.ino +++ b/examples/DataChangesListener/SingleDataObject/SingleDataObject.ino @@ -16,7 +16,7 @@ #elif defined(ESP8266) #include #include -#elif defined(PICO_RP2040) +#elif defined(ARDUINO_RASPBERRY_PI_PICO_W) #include #include #endif diff --git a/examples/DataFilter/DataFilter.ino b/examples/DataFilter/DataFilter.ino index 2ee5a07c..ab2013cf 100644 --- a/examples/DataFilter/DataFilter.ino +++ b/examples/DataFilter/DataFilter.ino @@ -18,7 +18,7 @@ #elif defined(ESP8266) #include #include -#elif defined(PICO_RP2040) +#elif defined(ARDUINO_RASPBERRY_PI_PICO_W) #include #include #endif diff --git a/examples/DataRetaining/DataRetaining.ino b/examples/DataRetaining/DataRetaining.ino index cb6fa835..c23b1265 100644 --- a/examples/DataRetaining/DataRetaining.ino +++ b/examples/DataRetaining/DataRetaining.ino @@ -18,7 +18,7 @@ #elif defined(ESP8266) #include #include -#elif defined(PICO_RP2040) +#elif defined(ARDUINO_RASPBERRY_PI_PICO_W) #include #include #endif diff --git a/examples/DatabaseRules/DatabaseRules.ino b/examples/DatabaseRules/DatabaseRules.ino index 5871fd89..4e026942 100644 --- a/examples/DatabaseRules/DatabaseRules.ino +++ b/examples/DatabaseRules/DatabaseRules.ino @@ -18,7 +18,7 @@ #elif defined(ESP8266) #include #include -#elif defined(PICO_RP2040) +#elif defined(ARDUINO_RASPBERRY_PI_PICO_W) #include #include #endif diff --git a/examples/DownloadFileOTA/DownloadFileOTA.ino b/examples/DownloadFileOTA/DownloadFileOTA.ino index d9696d3d..e87c931f 100644 --- a/examples/DownloadFileOTA/DownloadFileOTA.ino +++ b/examples/DownloadFileOTA/DownloadFileOTA.ino @@ -18,7 +18,7 @@ #elif defined(ESP8266) #include #include -#elif defined(PICO_RP2040) +#elif defined(ARDUINO_RASPBERRY_PI_PICO_W) #include #include #endif diff --git a/examples/ETag/ETag.ino b/examples/ETag/ETag.ino index e92d4aa1..5469c9d7 100644 --- a/examples/ETag/ETag.ino +++ b/examples/ETag/ETag.ino @@ -19,7 +19,7 @@ #elif defined(ESP8266) #include #include -#elif defined(PICO_RP2040) +#elif defined(ARDUINO_RASPBERRY_PI_PICO_W) #include #include #endif diff --git a/examples/FastSend/FastSend.ino b/examples/FastSend/FastSend.ino index da924bef..a1b6591a 100644 --- a/examples/FastSend/FastSend.ino +++ b/examples/FastSend/FastSend.ino @@ -18,7 +18,7 @@ #elif defined(ESP8266) #include #include -#elif defined(PICO_RP2040) +#elif defined(ARDUINO_RASPBERRY_PI_PICO_W) #include #include #endif diff --git a/examples/File/Flash/Flash.ino b/examples/File/Flash/Flash.ino index f17a3d0d..46c758a2 100644 --- a/examples/File/Flash/Flash.ino +++ b/examples/File/Flash/Flash.ino @@ -18,7 +18,7 @@ #elif defined(ESP8266) #include #include -#elif defined(PICO_RP2040) +#elif defined(ARDUINO_RASPBERRY_PI_PICO_W) #include #include #endif diff --git a/examples/File/SD/SD.ino b/examples/File/SD/SD.ino index 2c5843d0..0e431fe1 100644 --- a/examples/File/SD/SD.ino +++ b/examples/File/SD/SD.ino @@ -21,7 +21,7 @@ #elif defined(ESP8266) #include #include -#elif defined(PICO_RP2040) +#elif defined(ARDUINO_RASPBERRY_PI_PICO_W) #include #include #endif diff --git a/examples/FireSense/AnalogRead/AnalogRead.ino b/examples/FireSense/AnalogRead/AnalogRead.ino index 974f0222..651fc169 100644 --- a/examples/FireSense/AnalogRead/AnalogRead.ino +++ b/examples/FireSense/AnalogRead/AnalogRead.ino @@ -70,7 +70,7 @@ #elif defined(ESP8266) #include #include -#elif defined(PICO_RP2040) +#elif defined(ARDUINO_RASPBERRY_PI_PICO_W) #include #include #endif diff --git a/examples/FireSense/AutomaticPlantWatering/AutomaticPlantWatering.ino b/examples/FireSense/AutomaticPlantWatering/AutomaticPlantWatering.ino index 00636c15..522d2def 100644 --- a/examples/FireSense/AutomaticPlantWatering/AutomaticPlantWatering.ino +++ b/examples/FireSense/AutomaticPlantWatering/AutomaticPlantWatering.ino @@ -75,7 +75,7 @@ #elif defined(ESP8266) #include #include -#elif defined(PICO_RP2040) +#elif defined(ARDUINO_RASPBERRY_PI_PICO_W) #include #include #endif diff --git a/examples/FireSense/Blink/Blink.ino b/examples/FireSense/Blink/Blink.ino index e7b58eed..efbd1d49 100644 --- a/examples/FireSense/Blink/Blink.ino +++ b/examples/FireSense/Blink/Blink.ino @@ -68,7 +68,7 @@ #elif defined(ESP8266) #include #include -#elif defined(PICO_RP2040) +#elif defined(ARDUINO_RASPBERRY_PI_PICO_W) #include #include #endif diff --git a/examples/FireSense/Sensors/Sensors.ino b/examples/FireSense/Sensors/Sensors.ino index d2837225..f73d171e 100644 --- a/examples/FireSense/Sensors/Sensors.ino +++ b/examples/FireSense/Sensors/Sensors.ino @@ -64,7 +64,7 @@ #elif defined(ESP8266) #include #include -#elif defined(PICO_RP2040) +#elif defined(ARDUINO_RASPBERRY_PI_PICO_W) #include #include #endif diff --git a/examples/FirebaseJson/Client/ArduinoMQTT/ArduinoMQTT.ino b/examples/FirebaseJson/Client/ArduinoMQTT/ArduinoMQTT.ino index ca0a5fa2..b809c5aa 100644 --- a/examples/FirebaseJson/Client/ArduinoMQTT/ArduinoMQTT.ino +++ b/examples/FirebaseJson/Client/ArduinoMQTT/ArduinoMQTT.ino @@ -19,7 +19,7 @@ #include #elif defined(ESP8266) #include -#elif defined(ESP32) || defined(PICO_RP2040) +#elif defined(ESP32) || defined(ARDUINO_RASPBERRY_PI_PICO_W) #include #endif diff --git a/examples/FirebaseJson/Client/Firebase/Firebase.ino b/examples/FirebaseJson/Client/Firebase/Firebase.ino index bcc15e05..41e592a2 100644 --- a/examples/FirebaseJson/Client/Firebase/Firebase.ino +++ b/examples/FirebaseJson/Client/Firebase/Firebase.ino @@ -11,7 +11,7 @@ */ #include -#if defined(ESP32) || defined(PICO_RP2040) +#if defined(ESP32) || defined(ARDUINO_RASPBERRY_PI_PICO_W) #include #elif defined(ESP8266) #include diff --git a/examples/FirebaseJson/Client/WiFiClient/WiFiClient.ino b/examples/FirebaseJson/Client/WiFiClient/WiFiClient.ino index 27b34e55..291b8168 100644 --- a/examples/FirebaseJson/Client/WiFiClient/WiFiClient.ino +++ b/examples/FirebaseJson/Client/WiFiClient/WiFiClient.ino @@ -10,7 +10,7 @@ */ #include -#if defined(ESP32) || defined(PICO_RP2040) +#if defined(ESP32) || defined(ARDUINO_RASPBERRY_PI_PICO_W) #include #elif defined(ESP8266) #include diff --git a/examples/FirebaseJson/Client/WiFiClientSecure/WiFiClientSecure.ino b/examples/FirebaseJson/Client/WiFiClientSecure/WiFiClientSecure.ino index 2859a4a7..c1d87d46 100644 --- a/examples/FirebaseJson/Client/WiFiClientSecure/WiFiClientSecure.ino +++ b/examples/FirebaseJson/Client/WiFiClientSecure/WiFiClientSecure.ino @@ -10,7 +10,7 @@ */ #include -#if defined(ESP32) || defined(PICO_RP2040) +#if defined(ESP32) || defined(ARDUINO_RASPBERRY_PI_PICO_W) #include #elif defined(ESP8266) #include diff --git a/examples/Messaging/Messaging.ino b/examples/Messaging/Messaging.ino index 98f061a5..8d279dd9 100644 --- a/examples/Messaging/Messaging.ino +++ b/examples/Messaging/Messaging.ino @@ -34,7 +34,7 @@ #elif defined(ESP8266) #include #include -#elif defined(PICO_RP2040) +#elif defined(ARDUINO_RASPBERRY_PI_PICO_W) #include #include #endif diff --git a/examples/MessagingEthernet/MessagingEthernet.ino b/examples/MessagingEthernet/MessagingEthernet.ino index 48ff5d66..0e988c56 100644 --- a/examples/MessagingEthernet/MessagingEthernet.ino +++ b/examples/MessagingEthernet/MessagingEthernet.ino @@ -30,8 +30,12 @@ #include #include -//#include -//#include +// #include +// #include + +/** Don't gorget to define this in FirebaseFS.h + #define ENABLE_ESP8266_ENC28J60_ETH +*/ #define FIREBASE_FCM_SERVER_KEY "FIREBASE_PROJECT_CLOUD_MESSAGING_SERVER_KEY" #define FIREBASE_FCM_DEVICE_TOKEN_1 "RECIPIENT_DEVICE_TOKEN" @@ -89,9 +93,15 @@ void setup() Firebase.reconnectWiFi(true); +#if defined(ENABLE_ESP8266_ENC28J60_ETH) spi_ethernet_module.enc28j60 = ð - // spi_ethernet_module.w5100 = ð - // spi_ethernet_module.w5500 = ð +#endif +#if defined(ENABLE_ESP8266_W5100_ETH) + spi_ethernet_module.w5100 = ð +#endif +#if defined(ENABLE_ESP8266_W5500_ETH) + spi_ethernet_module.w5500 = ð +#endif fbdo.fcm.begin(FIREBASE_FCM_SERVER_KEY, &spi_ethernet_module); diff --git a/examples/Priority/Priority.ino b/examples/Priority/Priority.ino index 9bac7e9f..f0a8523d 100644 --- a/examples/Priority/Priority.ino +++ b/examples/Priority/Priority.ino @@ -21,7 +21,7 @@ #elif defined(ESP8266) #include #include -#elif defined(PICO_RP2040) +#elif defined(ARDUINO_RASPBERRY_PI_PICO_W) #include #include #endif diff --git a/examples/Queue/Queue.ino b/examples/Queue/Queue.ino index e3603a91..61caefc1 100644 --- a/examples/Queue/Queue.ino +++ b/examples/Queue/Queue.ino @@ -18,7 +18,7 @@ #elif defined(ESP8266) #include #include -#elif defined(PICO_RP2040) +#elif defined(ARDUINO_RASPBERRY_PI_PICO_W) #include #include #endif diff --git a/examples/RTDB/Ethernet/Basic/Basic.ino b/examples/RTDB/Ethernet/Basic/Basic.ino deleted file mode 100644 index aa2ccffd..00000000 --- a/examples/RTDB/Ethernet/Basic/Basic.ino +++ /dev/null @@ -1,188 +0,0 @@ - -/** - * 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 devices which SSLClient and EthernetLarge 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 - -/* 1. install EthernetLarge library */ -// https://github.com/OPEnSLab-OSU/EthernetLarge -// Include EthernetLarge.h -#include - -/* 2. Install SSLClient library */ -// https://github.com/OPEnSLab-OSU/SSLClient -#include - -/* 3. 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 - -/* 4. Define the API Key */ -#define API_KEY "API_KEY" - -/* 5. Define the RTDB URL */ -#define DATABASE_URL "URL" //.firebaseio.com or ..firebasedatabase.app - -/* 6. Define the user Email and password that alreadey registerd or added in your project */ -#define USER_EMAIL "USER_EMAIL" -#define USER_PASSWORD "USER_PASSWORD" - -/* 7. 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 - -/* 8. 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) - -/* 9. Define MAC */ -uint8_t Eth_MAC[] = {0x02, 0xF0, 0x0D, 0xBE, 0xEF, 0x01}; - -/* 10. 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; - -EthernetClient client; - -const int analog_pin = 34; // ESP32 GPIO 34 (Analog pin) - -SSLClient ssl_client(client, TAs, (size_t)TAs_NUM, analog_pin); - -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); -} - -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(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/RTDB/Ethernet/Basic/trust_anchors.h b/examples/RTDB/Ethernet/Basic/trust_anchors.h deleted file mode 100644 index 4b7ae20a..00000000 --- a/examples/RTDB/Ethernet/Basic/trust_anchors.h +++ /dev/null @@ -1,78 +0,0 @@ -#ifndef _CERTIFICATES_H_ -#define _CERTIFICATES_H_ - -#ifdef __cplusplus -extern "C" -{ -#endif - -/* This file is auto-generated by the pycert_bearssl tool. Do not change it manually. - * Certificates are BearSSL br_x509_trust_anchor format. Included certs: - * - * Index: 0 - * Label: GlobalSign Root CA - * Subject: CN=GlobalSign Root CA,OU=Root CA,O=GlobalSign nv-sa,C=BE - * Domain(s): www.google.com - */ - -#define TAs_NUM 1 - -static const unsigned char TA_DN0[] = { - 0x30, 0x57, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, - 0x02, 0x42, 0x45, 0x31, 0x19, 0x30, 0x17, 0x06, 0x03, 0x55, 0x04, 0x0a, - 0x13, 0x10, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x53, 0x69, 0x67, 0x6e, - 0x20, 0x6e, 0x76, 0x2d, 0x73, 0x61, 0x31, 0x10, 0x30, 0x0e, 0x06, 0x03, - 0x55, 0x04, 0x0b, 0x13, 0x07, 0x52, 0x6f, 0x6f, 0x74, 0x20, 0x43, 0x41, - 0x31, 0x1b, 0x30, 0x19, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x12, 0x47, - 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x53, 0x69, 0x67, 0x6e, 0x20, 0x52, 0x6f, - 0x6f, 0x74, 0x20, 0x43, 0x41, -}; - -static const unsigned char TA_RSA_N0[] = { - 0xda, 0x0e, 0xe6, 0x99, 0x8d, 0xce, 0xa3, 0xe3, 0x4f, 0x8a, 0x7e, 0xfb, - 0xf1, 0x8b, 0x83, 0x25, 0x6b, 0xea, 0x48, 0x1f, 0xf1, 0x2a, 0xb0, 0xb9, - 0x95, 0x11, 0x04, 0xbd, 0xf0, 0x63, 0xd1, 0xe2, 0x67, 0x66, 0xcf, 0x1c, - 0xdd, 0xcf, 0x1b, 0x48, 0x2b, 0xee, 0x8d, 0x89, 0x8e, 0x9a, 0xaf, 0x29, - 0x80, 0x65, 0xab, 0xe9, 0xc7, 0x2d, 0x12, 0xcb, 0xab, 0x1c, 0x4c, 0x70, - 0x07, 0xa1, 0x3d, 0x0a, 0x30, 0xcd, 0x15, 0x8d, 0x4f, 0xf8, 0xdd, 0xd4, - 0x8c, 0x50, 0x15, 0x1c, 0xef, 0x50, 0xee, 0xc4, 0x2e, 0xf7, 0xfc, 0xe9, - 0x52, 0xf2, 0x91, 0x7d, 0xe0, 0x6d, 0xd5, 0x35, 0x30, 0x8e, 0x5e, 0x43, - 0x73, 0xf2, 0x41, 0xe9, 0xd5, 0x6a, 0xe3, 0xb2, 0x89, 0x3a, 0x56, 0x39, - 0x38, 0x6f, 0x06, 0x3c, 0x88, 0x69, 0x5b, 0x2a, 0x4d, 0xc5, 0xa7, 0x54, - 0xb8, 0x6c, 0x89, 0xcc, 0x9b, 0xf9, 0x3c, 0xca, 0xe5, 0xfd, 0x89, 0xf5, - 0x12, 0x3c, 0x92, 0x78, 0x96, 0xd6, 0xdc, 0x74, 0x6e, 0x93, 0x44, 0x61, - 0xd1, 0x8d, 0xc7, 0x46, 0xb2, 0x75, 0x0e, 0x86, 0xe8, 0x19, 0x8a, 0xd5, - 0x6d, 0x6c, 0xd5, 0x78, 0x16, 0x95, 0xa2, 0xe9, 0xc8, 0x0a, 0x38, 0xeb, - 0xf2, 0x24, 0x13, 0x4f, 0x73, 0x54, 0x93, 0x13, 0x85, 0x3a, 0x1b, 0xbc, - 0x1e, 0x34, 0xb5, 0x8b, 0x05, 0x8c, 0xb9, 0x77, 0x8b, 0xb1, 0xdb, 0x1f, - 0x20, 0x91, 0xab, 0x09, 0x53, 0x6e, 0x90, 0xce, 0x7b, 0x37, 0x74, 0xb9, - 0x70, 0x47, 0x91, 0x22, 0x51, 0x63, 0x16, 0x79, 0xae, 0xb1, 0xae, 0x41, - 0x26, 0x08, 0xc8, 0x19, 0x2b, 0xd1, 0x46, 0xaa, 0x48, 0xd6, 0x64, 0x2a, - 0xd7, 0x83, 0x34, 0xff, 0x2c, 0x2a, 0xc1, 0x6c, 0x19, 0x43, 0x4a, 0x07, - 0x85, 0xe7, 0xd3, 0x7c, 0xf6, 0x21, 0x68, 0xef, 0xea, 0xf2, 0x52, 0x9f, - 0x7f, 0x93, 0x90, 0xcf, -}; - -static const unsigned char TA_RSA_E0[] = { - 0x01, 0x00, 0x01, -}; - -static const br_x509_trust_anchor TAs[] = { - { - { (unsigned char *)TA_DN0, sizeof TA_DN0 }, - BR_X509_TA_CA, - { - BR_KEYTYPE_RSA, - { .rsa = { - (unsigned char *)TA_RSA_N0, sizeof TA_RSA_N0, - (unsigned char *)TA_RSA_E0, sizeof TA_RSA_E0, - } } - } - }, -}; - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* ifndef _CERTIFICATES_H_ */ diff --git a/examples/RTDB/Ethernet/StreamCallback/StreamCallback.ino b/examples/RTDB/Ethernet/StreamCallback/StreamCallback.ino deleted file mode 100644 index 8aa2080f..00000000 --- a/examples/RTDB/Ethernet/StreamCallback/StreamCallback.ino +++ /dev/null @@ -1,242 +0,0 @@ -/** - * 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 devices which SSLClient and EthernetLarge 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 - -/* 1. install EthernetLarge library */ -// https://github.com/OPEnSLab-OSU/EthernetLarge -// Include EthernetLarge.h -#include - -/* 2. Install SSLClient library */ -// https://github.com/OPEnSLab-OSU/SSLClient -#include - -/* 3. 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 - -/* 4. Define the API Key */ -#define API_KEY "API_KEY" - -/* 5. Define the RTDB URL */ -#define DATABASE_URL "URL" //.firebaseio.com or ..firebasedatabase.app - -/* 6. Define the user Email and password that alreadey registerd or added in your project */ -#define USER_EMAIL "USER_EMAIL" -#define USER_PASSWORD "USER_PASSWORD" - -/* 7. 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 - -/* 8. 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) - -/* 9. Define MAC */ -uint8_t Eth_MAC[] = {0x02, 0xF0, 0x0D, 0xBE, 0xEF, 0x01}; - -/* 10. 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; - -EthernetClient client; - -EthernetClient client2; - -const int analog_pin = 34; // ESP32 GPIO 34 (Analog pin) - -SSLClient ssl_client(client, TAs, (size_t)TAs_NUM, analog_pin); - -SSLClient ssl_client2(client2, TAs, (size_t)TAs_NUM, analog_pin); - -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); -} - -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 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(networkConnection, networkStatusRequestCallback); - - /* Assign the pointer to global defined external SSL Client object */ - stream.setExternalClient(&ssl_client2); - - /* Assign the required callback functions */ - stream.setExternalClientCallbacks(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/RTDB/Ethernet/StreamCallback/trust_anchors.h b/examples/RTDB/Ethernet/StreamCallback/trust_anchors.h deleted file mode 100644 index 4b7ae20a..00000000 --- a/examples/RTDB/Ethernet/StreamCallback/trust_anchors.h +++ /dev/null @@ -1,78 +0,0 @@ -#ifndef _CERTIFICATES_H_ -#define _CERTIFICATES_H_ - -#ifdef __cplusplus -extern "C" -{ -#endif - -/* This file is auto-generated by the pycert_bearssl tool. Do not change it manually. - * Certificates are BearSSL br_x509_trust_anchor format. Included certs: - * - * Index: 0 - * Label: GlobalSign Root CA - * Subject: CN=GlobalSign Root CA,OU=Root CA,O=GlobalSign nv-sa,C=BE - * Domain(s): www.google.com - */ - -#define TAs_NUM 1 - -static const unsigned char TA_DN0[] = { - 0x30, 0x57, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, - 0x02, 0x42, 0x45, 0x31, 0x19, 0x30, 0x17, 0x06, 0x03, 0x55, 0x04, 0x0a, - 0x13, 0x10, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x53, 0x69, 0x67, 0x6e, - 0x20, 0x6e, 0x76, 0x2d, 0x73, 0x61, 0x31, 0x10, 0x30, 0x0e, 0x06, 0x03, - 0x55, 0x04, 0x0b, 0x13, 0x07, 0x52, 0x6f, 0x6f, 0x74, 0x20, 0x43, 0x41, - 0x31, 0x1b, 0x30, 0x19, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x12, 0x47, - 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x53, 0x69, 0x67, 0x6e, 0x20, 0x52, 0x6f, - 0x6f, 0x74, 0x20, 0x43, 0x41, -}; - -static const unsigned char TA_RSA_N0[] = { - 0xda, 0x0e, 0xe6, 0x99, 0x8d, 0xce, 0xa3, 0xe3, 0x4f, 0x8a, 0x7e, 0xfb, - 0xf1, 0x8b, 0x83, 0x25, 0x6b, 0xea, 0x48, 0x1f, 0xf1, 0x2a, 0xb0, 0xb9, - 0x95, 0x11, 0x04, 0xbd, 0xf0, 0x63, 0xd1, 0xe2, 0x67, 0x66, 0xcf, 0x1c, - 0xdd, 0xcf, 0x1b, 0x48, 0x2b, 0xee, 0x8d, 0x89, 0x8e, 0x9a, 0xaf, 0x29, - 0x80, 0x65, 0xab, 0xe9, 0xc7, 0x2d, 0x12, 0xcb, 0xab, 0x1c, 0x4c, 0x70, - 0x07, 0xa1, 0x3d, 0x0a, 0x30, 0xcd, 0x15, 0x8d, 0x4f, 0xf8, 0xdd, 0xd4, - 0x8c, 0x50, 0x15, 0x1c, 0xef, 0x50, 0xee, 0xc4, 0x2e, 0xf7, 0xfc, 0xe9, - 0x52, 0xf2, 0x91, 0x7d, 0xe0, 0x6d, 0xd5, 0x35, 0x30, 0x8e, 0x5e, 0x43, - 0x73, 0xf2, 0x41, 0xe9, 0xd5, 0x6a, 0xe3, 0xb2, 0x89, 0x3a, 0x56, 0x39, - 0x38, 0x6f, 0x06, 0x3c, 0x88, 0x69, 0x5b, 0x2a, 0x4d, 0xc5, 0xa7, 0x54, - 0xb8, 0x6c, 0x89, 0xcc, 0x9b, 0xf9, 0x3c, 0xca, 0xe5, 0xfd, 0x89, 0xf5, - 0x12, 0x3c, 0x92, 0x78, 0x96, 0xd6, 0xdc, 0x74, 0x6e, 0x93, 0x44, 0x61, - 0xd1, 0x8d, 0xc7, 0x46, 0xb2, 0x75, 0x0e, 0x86, 0xe8, 0x19, 0x8a, 0xd5, - 0x6d, 0x6c, 0xd5, 0x78, 0x16, 0x95, 0xa2, 0xe9, 0xc8, 0x0a, 0x38, 0xeb, - 0xf2, 0x24, 0x13, 0x4f, 0x73, 0x54, 0x93, 0x13, 0x85, 0x3a, 0x1b, 0xbc, - 0x1e, 0x34, 0xb5, 0x8b, 0x05, 0x8c, 0xb9, 0x77, 0x8b, 0xb1, 0xdb, 0x1f, - 0x20, 0x91, 0xab, 0x09, 0x53, 0x6e, 0x90, 0xce, 0x7b, 0x37, 0x74, 0xb9, - 0x70, 0x47, 0x91, 0x22, 0x51, 0x63, 0x16, 0x79, 0xae, 0xb1, 0xae, 0x41, - 0x26, 0x08, 0xc8, 0x19, 0x2b, 0xd1, 0x46, 0xaa, 0x48, 0xd6, 0x64, 0x2a, - 0xd7, 0x83, 0x34, 0xff, 0x2c, 0x2a, 0xc1, 0x6c, 0x19, 0x43, 0x4a, 0x07, - 0x85, 0xe7, 0xd3, 0x7c, 0xf6, 0x21, 0x68, 0xef, 0xea, 0xf2, 0x52, 0x9f, - 0x7f, 0x93, 0x90, 0xcf, -}; - -static const unsigned char TA_RSA_E0[] = { - 0x01, 0x00, 0x01, -}; - -static const br_x509_trust_anchor TAs[] = { - { - { (unsigned char *)TA_DN0, sizeof TA_DN0 }, - BR_X509_TA_CA, - { - BR_KEYTYPE_RSA, - { .rsa = { - (unsigned char *)TA_RSA_N0, sizeof TA_RSA_N0, - (unsigned char *)TA_RSA_E0, sizeof TA_RSA_E0, - } } - } - }, -}; - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* ifndef _CERTIFICATES_H_ */ diff --git a/examples/RTDB/WiFi/Basic/Basic.ino b/examples/RTDB/WiFi/Basic/Basic.ino deleted file mode 100644 index 8ae06233..00000000 --- a/examples/RTDB/WiFi/Basic/Basic.ino +++ /dev/null @@ -1,149 +0,0 @@ - -/** - * 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 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 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); -} - -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 - - // The WiFi credentials are required for SAMD21 - // due to it does not have reconnect feature. - config.wifi.clearAP(); - config.wifi.addAP(WIFI_SSID, WIFI_PASSWORD); - - /* fbdo.setExternalClient and fbdo.setExternalClientCallbacks must be called before Firebase.begin */ - - /* Assign the pointer to global defined external SSL Client object */ - fbdo.setExternalClient(&client); - - /* Assign the required callback functions */ - fbdo.setExternalClientCallbacks(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/RTDB/WiFi/StreamCallback/StreamCallback.ino b/examples/RTDB/WiFi/StreamCallback/StreamCallback.ino deleted file mode 100644 index 16445c30..00000000 --- a/examples/RTDB/WiFi/StreamCallback/StreamCallback.ino +++ /dev/null @@ -1,206 +0,0 @@ -/** - * 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 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 client1; - -WiFiSSLClient 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); -} - -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 - - // The WiFi credentials are required for SAMD21 - // due to it does not have reconnect feature. - config.wifi.clearAP(); - config.wifi.addAP(WIFI_SSID, WIFI_PASSWORD); - - // 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(&client1); - - /* Assign the required callback functions */ - fbdo.setExternalClientCallbacks(networkConnection, networkStatusRequestCallback); - - /* Assign the pointer to global defined external SSL Client object */ - stream.setExternalClient(&client2); - - /* Assign the required callback functions */ - stream.setExternalClientCallbacks(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/ShallowedData/ShallowedData.ino b/examples/ShallowedData/ShallowedData.ino index 72da26a9..ae2fff41 100644 --- a/examples/ShallowedData/ShallowedData.ino +++ b/examples/ShallowedData/ShallowedData.ino @@ -18,7 +18,7 @@ #elif defined(ESP8266) #include #include -#elif defined(PICO_RP2040) +#elif defined(ARDUINO_RASPBERRY_PI_PICO_W) #include #include #endif diff --git a/examples/Timestamp/Timestamp.ino b/examples/Timestamp/Timestamp.ino index f0d5f709..cd40f6fe 100644 --- a/examples/Timestamp/Timestamp.ino +++ b/examples/Timestamp/Timestamp.ino @@ -19,7 +19,7 @@ #elif defined(ESP8266) #include #include -#elif defined(PICO_RP2040) +#elif defined(ARDUINO_RASPBERRY_PI_PICO_W) #include #include #endif diff --git a/library.json b/library.json index ce9e0183..dd6fd9fb 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "Firebase ESP8266 Client", - "version": "4.3.5", + "version": "4.3.6", "keywords": "communication, REST, esp8266, arduino", "description": "The secure, fast and reliable Firebase Realtime database library to read, store, update, delete, listen, backup, and restore data. You can also read and modify the database security rules with this library.", "repository": { diff --git a/library.properties b/library.properties index 41488801..22cb926f 100644 --- a/library.properties +++ b/library.properties @@ -1,6 +1,6 @@ name=Firebase ESP8266 Client -version=4.3.5 +version=4.3.6 author=Mobizt @@ -14,4 +14,4 @@ category=Communication url=https://github.com/mobizt/Firebase-ESP8266 -architectures=esp8266,esp32,sam,samd,stm32,STM32F1,STM32F4,teensy,avr,megaavr,mbed_nano,mbed_rp2040 +architectures=esp8266,esp32,sam,samd,stm32,STM32F1,STM32F4,teensy,avr,megaavr,mbed_nano,mbed_rp2040,rp2040 diff --git a/src/FB_Const.h b/src/FB_Const.h index 0f2f40ad..63c4b4c0 100644 --- a/src/FB_Const.h +++ b/src/FB_Const.h @@ -593,26 +593,41 @@ struct fb_esp_wifi_credentials_t { credentials.clear(); } + size_t size() + { + return credentials.size(); + } + + fb_esp_wifi_credential_t operator[](size_t index) + { + return credentials[index]; + } private: MB_List credentials; }; -static fb_esp_wifi_credentials_t WiFiCreds; - class fb_esp_wifi { + friend class Firebase_Signer; + public: fb_esp_wifi(){}; - ~fb_esp_wifi() { WiFiCreds.clearAP(); }; + ~fb_esp_wifi() + { + wifiCreds.clearAP(); + }; void addAP(const String &ssid, const String &password) { - WiFiCreds.addAP(ssid, password); + wifiCreds.addAP(ssid, password); } void clearAP() { - WiFiCreds.clearAP(); + wifiCreds.clearAP(); } + +private: + fb_esp_wifi_credentials_t wifiCreds; }; template diff --git a/src/FirebaseESP8266.h b/src/FirebaseESP8266.h index b07942ca..897e3460 100644 --- a/src/FirebaseESP8266.h +++ b/src/FirebaseESP8266.h @@ -1,16 +1,17 @@ #ifndef FIREBASE_CLIENT_VERSION -#define FIREBASE_CLIENT_VERSION "4.3.5" +#define FIREBASE_CLIENT_VERSION "4.3.6" #endif /** - * Google's Firebase Realtime Database Arduino Library for ESP8266 and RP2040 Pico, v4.3.5 + * Google's Firebase Realtime Database Arduino Library for ESP8266 and RP2040 Pico, v4.3.6 * - * Created January 27, 2023 + * Created February 7, 2023 * * Updates: - * - Fix ESP8266 SDK lwip driver with Ethernet.h compilation error. - * - Update examples. + * - Fix access and custom tokens generation is not finished due to exchange process fail. + * - Fix non-ESP devices WiFi reconnection issue. + * - Fix LittleFS error log issue. * * * This library provides ESP8266 to perform REST API by GET PUT, POST, PATCH, DELETE data from/to with Google's Firebase database using get, set, update diff --git a/src/mbfs/MB_FS.h b/src/mbfs/MB_FS.h index 69e7e553..4bd82967 100644 --- a/src/mbfs/MB_FS.h +++ b/src/mbfs/MB_FS.h @@ -1,9 +1,9 @@ /** - * The MB_FS, filesystems wrapper class v1.0.12 + * The MB_FS, filesystems wrapper class v1.0.13 * * This wrapper class is for SD and Flash filesystems interface which supports SdFat (//https://github.com/greiman/SdFat) * - * Created January 20, 2023 + * Created February 4, 2023 * * The MIT License (MIT) * Copyright (c) 2023 K. Suwatchai (Mobizt) @@ -38,6 +38,23 @@ #include MB_STRING_INCLUDE_CLASS #include "SPI.h" +#if defined(ESP32) && __has_include() +#if MBFS_FLASH_FS == LittleFS +#define MB_FS_USE_POSIX_STAT +#include +namespace mb_fs_ns +{ + inline bool exists(const char *mountPoint, const char *filename) + { + MB_String path = mountPoint; + path += filename; + struct stat st; + return stat(path.c_str(), &st) == 0; + } +}; +#endif +#endif + using namespace mb_string; #if defined(BOARD_HAS_PSRAM) && defined(MB_STRING_USE_PSRAM) @@ -636,7 +653,17 @@ class MB_FS #if defined(MBFS_FLASH_FS) if (type == mbfs_flash) + { + +// The workaround for ESP32 LittleFS when calling vfs_api.cpp open() issue. +// See https://github.com/espressif/arduino-esp32/issues/7615 +#if defined(MB_FS_USE_POSIX_STAT) + return mb_fs_ns::exists("/littlefs", filename.c_str()); +#else return MBFS_FLASH_FS.exists(filename.c_str()); +#endif + } + #endif #if defined(MBFS_SD_FS) diff --git a/src/signer/Signer.cpp b/src/signer/Signer.cpp index a36fe4d0..eecd36bc 100644 --- a/src/signer/Signer.cpp +++ b/src/signer/Signer.cpp @@ -1,9 +1,9 @@ /** - * Google's Firebase Token Management class, Signer.cpp version 1.3.7 + * Google's Firebase Token Management class, Signer.cpp version 1.3.8 * - * This library supports Espressif ESP8266, ESP32 and RP2040 Pico + * This library supports Espressif ESP8266, ESP32 and Raspberry Pi Pico * - * Created January 16, 2023 + * Created February 7, 2023 * * This work is a part of Firebase ESP Client library * Copyright (c) 2023 K. Suwatchai (Mobizt) @@ -56,7 +56,7 @@ void Firebase_Signer::end() { freeJson(); - WiFiCreds.clearAP(); + wifiCreds.clearAP(); #if defined(HAS_WIFIMULTI) if (multi) delete multi; @@ -490,24 +490,27 @@ bool Firebase_Signer::handleToken() // handle the jwt token processing // if it is the first step and no task is currently running - if (config->signer.step == fb_esp_jwt_generation_step_begin && !config->signer.tokenTaskRunning) + if (!config->signer.tokenTaskRunning) { - // if service account key json file assigned and no private key parsing data - if (config->service_account.json.path.length() > 0 && config->signer.pk.length() == 0) + if (config->signer.step == fb_esp_jwt_generation_step_begin) { - // if fail to parse the private key from service account json file, reset the token status - if (!parseSAFile()) - config->signer.tokens.status = token_status_uninitialized; - } + // if service account key json file assigned and no private key parsing data + if (config->service_account.json.path.length() > 0 && config->signer.pk.length() == 0) + { + // if fail to parse the private key from service account json file, reset the token status + if (!parseSAFile()) + config->signer.tokens.status = token_status_uninitialized; + } - // if no token status set, set the states - if (config->signer.tokens.status != token_status_on_initialize) - { - config->signer.tokens.status = token_status_on_initialize; - config->signer.tokens.error.code = 0; - config->signer.tokens.error.message.clear(); - config->internal.fb_last_jwt_generation_error_cb_millis = 0; - sendTokenStatusCB(); + // if no token status set, set the states + if (config->signer.tokens.status != token_status_on_initialize) + { + config->signer.tokens.status = token_status_on_initialize; + config->signer.tokens.error.code = 0; + config->signer.tokens.error.message.clear(); + config->internal.fb_last_jwt_generation_error_cb_millis = 0; + sendTokenStatusCB(); + } } // set the token processing task started flag and run the task @@ -759,7 +762,7 @@ bool Firebase_Signer::refreshToken() struct fb_esp_auth_token_error_t error; - int httpCode = 0; + int httpCode = FIREBASE_ERROR_TCP_RESPONSE_PAYLOAD_READ_TIMED_OUT; if (handleTokenResponse(httpCode)) { if (JsonHelper::parse(jsonPtr, resultPtr, fb_esp_pgm_str_257 /* "error/code" */)) @@ -883,7 +886,6 @@ bool Firebase_Signer::handleTaskError(int code, int httpCode) { // Show error based on request time out setTokenError(code); - config->signer.tokens.error.message.clear(); } else { @@ -1420,7 +1422,7 @@ bool Firebase_Signer::getIdToken(bool createUser, MB_StringPtr email, MB_StringP jsonPtr->clear(); - int httpCode = 0; + int httpCode = FIREBASE_ERROR_TCP_RESPONSE_PAYLOAD_READ_TIMED_OUT; if (handleTokenResponse(httpCode)) { struct fb_esp_auth_token_error_t error; @@ -1527,7 +1529,7 @@ bool Firebase_Signer::deleteIdToken(MB_StringPtr idToken) jsonPtr->clear(); - int httpCode = 0; + int httpCode = FIREBASE_ERROR_TCP_RESPONSE_PAYLOAD_READ_TIMED_OUT; if (handleTokenResponse(httpCode)) { struct fb_esp_auth_token_error_t error; @@ -1742,7 +1744,11 @@ void Firebase_Signer::resumeWiFi(FB_TCP_CLIENT *client, bool &net_once_connected #if defined(ESP32) || defined(ESP8266) WiFi.reconnect(); #else - if (WiFiCreds.credentials.size() > 0) + // If config exists, use wifi credentials from config instead of local wifi creds. + // The local wifi creds can be accessed trough FCM class in case legacy API used. + fb_esp_wifi_credentials_t *_wifiCreds = config ? &config->wifi.wifiCreds : &wifiCreds; + + if (_wifiCreds->size() > 0) { #if __has_include() || __has_include() || __has_include() if (!networkStatus) @@ -1754,13 +1760,13 @@ void Firebase_Signer::resumeWiFi(FB_TCP_CLIENT *client, bool &net_once_connected multi = nullptr; multi = new WiFiMulti(); - for (size_t i = 0; i < WiFiCreds.credentials.size(); i++) - multi->addAP(WiFiCreds.credentials[i].ssid.c_str(), WiFiCreds.credentials[i].password.c_str()); + for (size_t i = 0; i < _wifiCreds->size(); i++) + multi->addAP((*_wifiCreds)[i].ssid.c_str(), (*_wifiCreds)[i].password.c_str()); - if (WiFiCreds.credentials.size() > 0) + if (_wifiCreds->size() > 0) multi->run(); #else - WiFi.begin(WiFiCreds.credentials[0].ssid.c_str(), WiFiCreds.credentials[0].password.c_str()); + WiFi.begin((*_wifiCreds)[0].ssid.c_str(), (*_wifiCreds)[0].password.c_str()); #endif } #endif @@ -1926,7 +1932,7 @@ bool Firebase_Signer::requestTokens(bool refresh) struct fb_esp_auth_token_error_t error; - int httpCode = 0; + int httpCode = FIREBASE_ERROR_TCP_RESPONSE_PAYLOAD_READ_TIMED_OUT; if (handleTokenResponse(httpCode)) { config->signer.tokens.jwt.clear(); @@ -2073,7 +2079,7 @@ bool Firebase_Signer::handleEmailSending(MB_StringPtr payload, fb_esp_user_email jsonPtr->clear(); - int httpCode = 0; + int httpCode = FIREBASE_ERROR_TCP_RESPONSE_PAYLOAD_READ_TIMED_OUT; if (handleTokenResponse(httpCode)) { struct fb_esp_auth_token_error_t error; diff --git a/src/signer/Signer.h b/src/signer/Signer.h index ef6200c6..c0edcfd3 100644 --- a/src/signer/Signer.h +++ b/src/signer/Signer.h @@ -1,9 +1,9 @@ /** - * Google's Firebase Token Management class, Signer.h version 1.3.7 + * Google's Firebase Token Management class, Signer.h version 1.3.8 * - * This library supports Espressif ESP8266, ESP32 and RP2040 Pico + * This library supports Espressif ESP8266, ESP32 and Raspberry Pi Pico * - * Created January 16, 2023 + * Created February 7, 2023 * * This work is a part of Firebase ESP Client library * Copyright (c) 2023 K. Suwatchai (Mobizt) @@ -76,7 +76,8 @@ class Firebase_Signer uint32_t *mb_ts = nullptr; uint32_t *mb_ts_offset = nullptr; MB_NTP ntpClient; - UDP *udp= nullptr; + UDP *udp = nullptr; + fb_esp_wifi_credentials_t wifiCreds; float gmtOffset = 0; #if defined(ESP8266) callback_function_t esp8266_cb = nullptr; @@ -191,6 +192,9 @@ class Firebase_Signer uint32_t *getTS(); /* get the pointer to user defined auth data*/ FirebaseAuth *getAuth(); + /* get the pointer to wifi crendentials object */ + fb_esp_wifi_credentials_t *getCred(); + /* prepare or initialize the external/internal TCP client */ bool initClient(PGM_P subDomain, fb_esp_auth_token_status status = token_status_uninitialized); /* resume network connection */ @@ -219,7 +223,7 @@ class Firebase_Signer esp8266_cb(); } #endif -#if defined(PICO_RP2040) +#if defined(ARDUINO_RASPBERRY_PI_PICO_W) #if __has_include() #define HAS_WIFIMULTI WiFiMulti *multi = nullptr;