From 5d4f73d1dad6361a2960be2de373b8a1b083c9eb Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 7 Nov 2022 09:52:18 +0700 Subject: [PATCH] Fix upload/download progress elapsed time. --- library.json | 2 +- library.properties | 2 +- src/Firebase_ESP_Client.h | 6 +++--- src/gcs/GCS.cpp | 8 +++++++- src/gcs/GCS.h | 2 +- src/rtdb/FB_RTDB.cpp | 10 ++++++++-- src/rtdb/FB_RTDB.h | 4 ++-- src/storage/FCS.cpp | 5 ++++- src/storage/FCS.h | 2 +- 9 files changed, 28 insertions(+), 13 deletions(-) diff --git a/library.json b/library.json index c8f684f0f..b3ce262c9 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "Firebase Arduino Client Library for ESP8266 and ESP32", - "version": "4.2.2", + "version": "4.2.3", "keywords": "communication, REST, esp32, esp8266, arduino", "description": "The library supports Firebase products e.g. Realtime database, Cloud Firestore database, Firebase Storage and Google Cloud Storage, Cloud Functions for Firebase and Cloud Messaging. The library also supported other Arduino devices using Clients interfaces e.g. WiFiClient, EthernetClient, and GSMClient.", "repository": { diff --git a/library.properties b/library.properties index 4bd283bfa..ac842b9a4 100644 --- a/library.properties +++ b/library.properties @@ -1,6 +1,6 @@ name=Firebase Arduino Client Library for ESP8266 and ESP32 -version=4.2.2 +version=4.2.3 author=Mobizt diff --git a/src/Firebase_ESP_Client.h b/src/Firebase_ESP_Client.h index e7e4c9f5d..8ad73eb50 100644 --- a/src/Firebase_ESP_Client.h +++ b/src/Firebase_ESP_Client.h @@ -1,16 +1,16 @@ #ifndef FIREBASE_CLIENT_VERSION -#define FIREBASE_CLIENT_VERSION "4.2.2" +#define FIREBASE_CLIENT_VERSION "4.2.3" #endif /** - * Google's Firebase ESP Client Main class, Firebase_ESP_Client.h v4.2.2 + * Google's Firebase ESP Client Main class, Firebase_ESP_Client.h v4.2.3 * * This library supports Espressif ESP8266 and ESP32 MCUs * * Created November 7, 2022 * * Updates: - * - Fix FirebaseData object issue that refused to connect in FCS and GCS classes. + * - Fix upload/download progress elapsed time. * * * This work is a part of Firebase ESP Client library diff --git a/src/gcs/GCS.cpp b/src/gcs/GCS.cpp index e3066397f..30ab1646e 100644 --- a/src/gcs/GCS.cpp +++ b/src/gcs/GCS.cpp @@ -1,5 +1,5 @@ /** - * Google's Cloud Storage class, GCS.cpp version 1.1.21 + * Google's Cloud Storage class, GCS.cpp version 1.1.22 * * This library supports Espressif ESP8266 and ESP32 * @@ -285,6 +285,9 @@ void GG_CloudStorage::reportUploadProgress(FirebaseData *fbdo, struct fb_esp_gcs int p = (float)readBytes / req->fileSize * 100; + if (readBytes == 0) + fbdo->tcpClient.dataStart = millis(); + if (req->progress != p && (p == 0 || p == 100 || req->progress + ESP_REPORT_PROGRESS_INTERVAL <= p)) { req->progress = p; @@ -309,6 +312,9 @@ void GG_CloudStorage::reportDownloadProgress(FirebaseData *fbdo, struct fb_esp_g int p = (float)readBytes / req->fileSize * 100; + if (readBytes == 0) + fbdo->tcpClient.dataStart = millis(); + if (req->progress != p && (p == 0 || p == 100 || req->progress + ESP_REPORT_PROGRESS_INTERVAL <= p)) { req->progress = p; diff --git a/src/gcs/GCS.h b/src/gcs/GCS.h index f8d3d4dfd..ace38d2a2 100644 --- a/src/gcs/GCS.h +++ b/src/gcs/GCS.h @@ -1,5 +1,5 @@ /** - * Google's Cloud Storage class, GCS.h version 1.1.21 + * Google's Cloud Storage class, GCS.h version 1.1.22 * * This library supports Espressif ESP8266 and ESP32 * diff --git a/src/rtdb/FB_RTDB.cpp b/src/rtdb/FB_RTDB.cpp index fc5b4f5f1..d35d045a2 100644 --- a/src/rtdb/FB_RTDB.cpp +++ b/src/rtdb/FB_RTDB.cpp @@ -1,9 +1,9 @@ /** - * Google's Firebase Realtime Database class, FB_RTDB.cpp version 2.0.5 + * Google's Firebase Realtime Database class, FB_RTDB.cpp version 2.0.6 * * This library supports Espressif ESP8266 and ESP32 * - * Created November 1, 2022 + * Created November 7, 2022 * * This work is a part of Firebase ESP Client library * Copyright (c) 2022 K. Suwatchai (Mobizt) @@ -1899,6 +1899,9 @@ void FB_RTDB::reportUploadProgress(FirebaseData *fbdo, struct fb_esp_rtdb_reques int p = (float)readBytes / req->fileSize * 100; + if (readBytes == 0) + fbdo->tcpClient.dataStart = millis(); + if (req->progress != p && (p == 0 || p == 100 || req->progress + ESP_REPORT_PROGRESS_INTERVAL <= p)) { fbdo->tcpClient.dataTime = millis() - fbdo->tcpClient.dataStart; @@ -1926,6 +1929,9 @@ void FB_RTDB::reportDownloadProgress(FirebaseData *fbdo, struct fb_esp_rtdb_requ int p = (float)readBytes / req->fileSize * 100; + if (readBytes == 0) + fbdo->tcpClient.dataStart = millis(); + if (req->progress != p && (p == 0 || p == 100 || req->progress + ESP_REPORT_PROGRESS_INTERVAL <= p)) { req->progress = p; diff --git a/src/rtdb/FB_RTDB.h b/src/rtdb/FB_RTDB.h index 4cfa6f564..0f621bf69 100644 --- a/src/rtdb/FB_RTDB.h +++ b/src/rtdb/FB_RTDB.h @@ -1,9 +1,9 @@ /** - * Google's Firebase Realtime Database class, FB_RTDB.h version 2.0.5 + * Google's Firebase Realtime Database class, FB_RTDB.h version 2.0.6 * * This library supports Espressif ESP8266 and ESP32 * - * Created November 1, 2022 + * Created November 7, 2022 * * This work is a part of Firebase ESP Client library * Copyright (c) 2022 K. Suwatchai (Mobizt) diff --git a/src/storage/FCS.cpp b/src/storage/FCS.cpp index be74b9431..2a009d17a 100644 --- a/src/storage/FCS.cpp +++ b/src/storage/FCS.cpp @@ -1,5 +1,5 @@ /** - * Google's Firebase Storage class, FCS.cpp version 1.1.24 + * Google's Firebase Storage class, FCS.cpp version 1.1.25 * * This library supports Espressif ESP8266 and ESP32 * @@ -345,6 +345,9 @@ void FB_Storage::reportDownloadProgress(FirebaseData *fbdo, struct fb_esp_fcs_re int p = (float)readBytes / req->fileSize * 100; + if (readBytes == 0) + fbdo->tcpClient.dataStart = millis(); + if (req->progress != p && (p == 0 || p == 100 || req->progress + ESP_REPORT_PROGRESS_INTERVAL <= p)) { req->progress = p; diff --git a/src/storage/FCS.h b/src/storage/FCS.h index a098853e2..1de7f93b5 100644 --- a/src/storage/FCS.h +++ b/src/storage/FCS.h @@ -1,5 +1,5 @@ /** - * Google's Firebase Storage class, FCS.h version 1.1.24 + * Google's Firebase Storage class, FCS.h version 1.1.25 * * This library supports Espressif ESP8266 and ESP32 *