Skip to content

Separated async from sync in bare minimum real time database example code to avoid confusion#276

Closed
mWaleedh wants to merge 3 commits intomobizt:mainfrom
mWaleedh:patch-3
Closed

Separated async from sync in bare minimum real time database example code to avoid confusion#276
mWaleedh wants to merge 3 commits intomobizt:mainfrom
mWaleedh:patch-3

Conversation

@mWaleedh
Copy link
Contributor

@mWaleedh mWaleedh commented Jul 31, 2025

The existing BareMinimum example can be confusing for developers using an RTOS, as it mixes both synchronous (blocking) and asynchronous (non-blocking) function calls. For a multi-tasking environment, relying on purely asynchronous patterns is a critical best practice to prevent tasks from blocking the scheduler.

This commit introduces a new RealTimeDatabase_Async.ino example to serve as a clean, unambiguous starting point for this common use case.

I have not changed the code I just separated the async from sync so that it is more clearer for beginners.

Also the setConnectionTimeout function has been deprecated from the WifiClientSecure library which causes compilation errors on newer ESP32 cores. That is why I added comments for someone facing this issue.

mWaleedh added 2 commits July 31, 2025 19:53
The existing BareMinimum example can be confusing for developers using an RTOS, as it mixes both synchronous (blocking) and asynchronous (non-blocking) function calls. For a multi-tasking environment, relying on purely asynchronous patterns is a critical best practice to prevent tasks from blocking the scheduler.

This commit introduces a new `RealTimeDatabase_Async.ino` example to serve as a clean, unambiguous starting point for this common use case.
separated sync from async
also added comments for possible compilation errors on modern esp32 cores related to setConnectionTimeout and setHandShakeTimeout (deprecated in newer version of WifiClientSecure)
@mWaleedh mWaleedh changed the title Create RealTimeDatabase_Async.ino Separated async from sync in bare minimum read time database example code to avoid confusion Jul 31, 2025
@mWaleedh mWaleedh changed the title Separated async from sync in bare minimum read time database example code to avoid confusion Separated async from sync in bare minimum real time database example code to avoid confusion Jul 31, 2025
@mobizt
Copy link
Owner

mobizt commented Jul 31, 2025

Thanks for the PR but I don't want to categorize the example like ever been before.

In v1.x, and earlier, the examples are categorized by the service and usage modes like this
https://github.com/mobizt/FirebaseClient/tree/v1.5.11/examples

The bare minimum is not designed for covering all use cases but to demonstrate the minimum requirements and operating concepts plus some simple Firebase functions. For elaborate usage, other examples are provided the application details.

It differs than the conventional Arduino library API like starting with ::begin() and finalize with ::end(). User needs to follow the steps to initialize the FirebaseApp class object which handles the authentication and async tasks.


#CambodiaOpemedFire
#กัมพูชายิงก่อน
#TruthFromThailand

@mobizt
Copy link
Owner

mobizt commented Jul 31, 2025

Also the setConnectionTimeout function has been deprecated from the WifiClientSecure library which causes compilation errors on newer ESP32 cores. That is why I added comments for someone facing this issue.

It's not true, the NetworkClient::setConnectionTimeout() is here.

https://github.com/espressif/arduino-esp32/blob/4eff7f9ae408a9fdd5d15c86184bda785d881aa3/libraries/Network/src/NetworkClient.h#L97

@mobizt
Copy link
Owner

mobizt commented Jul 31, 2025

I cannot accept the example changes unless the typo in document.

@mobizt
Copy link
Owner

mobizt commented Jul 31, 2025

The NetworkClientSecure::setConnectionTimeout() and NetworkClientSecure::setHandshakeTimeout() are available only in ESP32 Arduino Core SDK v3.x and newer.

Those methods are used for timeout customization otherwise the default timeout will be used. Your device will get stuck there for 10 seconds for server connection failure.

The timeout was set for waiting time reduction when server is unreachable or not responding.

It does not mean anything for usage modes (async and await) as NetworkClientSecure is not async SSL client.

@mWaleedh
Copy link
Contributor Author

mWaleedh commented Aug 1, 2025

Thank you for your time man.
And also for the knowledge. Appreciate it.

@mWaleedh mWaleedh closed this Aug 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants