Skip to content

Commit

Permalink
Fix pushTimestamp bad request issue and update timestamp example.
Browse files Browse the repository at this point in the history
  • Loading branch information
mobizt committed Aug 31, 2021
1 parent 18b9b76 commit e8df939
Show file tree
Hide file tree
Showing 25 changed files with 56 additions and 40 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.4390794.svg)](https://doi.org/10.5281/zenodo.4390794)


Google's Firebase Realtime Database Arduino Library for ESP8266 v3.4.2
Google's Firebase Realtime Database Arduino Library for ESP8266 v3.4.3


This library supports ESP8266 MCU from Espressif. The following are platforms in which libraries are also available.
Expand Down
2 changes: 1 addition & 1 deletion examples/BackupRestore/Flash/Flash.ino
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void setup()

void loop()
{
//Flash string (PROGMEM and (FPSTR), String C/C++ string, const char, char array, string literal are supported
//Flash string (PROGMEM and (FPSTR), String,, String C/C++ string, const char, char array, string literal are supported
//in all Firebase and FirebaseJson functions, unless F() macro is not supported.

if (Firebase.ready() && !taskCompleted)
Expand Down
2 changes: 1 addition & 1 deletion examples/BackupRestore/SD/SD.ino
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ void setup()

void loop()
{
//Flash string (PROGMEM and (FPSTR), String C/C++ string, const char, char array, string literal are supported
//Flash string (PROGMEM and (FPSTR), String,, String C/C++ string, const char, char array, string literal are supported
//in all Firebase and FirebaseJson functions, unless F() macro is not supported.

if (Firebase.ready() && !taskCompleted)
Expand Down
2 changes: 1 addition & 1 deletion examples/Basic/Basic.ino
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ void setup()

void loop()
{
//Flash string (PROGMEM and (FPSTR), String C/C++ string, const char, char array, string literal are supported
//Flash string (PROGMEM and (FPSTR), String,, String C/C++ string, const char, char array, string literal are supported
//in all Firebase and FirebaseJson functions, unless F() macro is not supported.

if (Firebase.ready() && (millis() - sendDataPrevMillis > 15000 || sendDataPrevMillis == 0))
Expand Down
2 changes: 1 addition & 1 deletion examples/BasicCert/BasicCert.ino
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ void setup()

void loop()
{
//Flash string (PROGMEM and (FPSTR), String C/C++ string, const char, char array, string literal are supported
//Flash string (PROGMEM and (FPSTR), String,, String C/C++ string, const char, char array, string literal are supported
//in all Firebase and FirebaseJson functions, unless F() macro is not supported.

if (Firebase.ready() && (millis() - sendDataPrevMillis > 15000 || sendDataPrevMillis == 0))
Expand Down
2 changes: 1 addition & 1 deletion examples/Blob/Blob.ino
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void setup()

void loop()
{
//Flash string (PROGMEM and (FPSTR), String C/C++ string, const char, char array, string literal are supported
//Flash string (PROGMEM and (FPSTR), String,, String C/C++ string, const char, char array, string literal are supported
//in all Firebase and FirebaseJson functions, unless F() macro is not supported.

if (Firebase.ready() && (millis() - sendDataPrevMillis > 15000 || sendDataPrevMillis == 0))
Expand Down
2 changes: 1 addition & 1 deletion examples/DataChangesListener/Callback/Callback.ino
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ void setup()

void loop()
{
//Flash string (PROGMEM and (FPSTR), String C/C++ string, const char, char array, string literal are supported
//Flash string (PROGMEM and (FPSTR), String,, String C/C++ string, const char, char array, string literal are supported
//in all Firebase and FirebaseJson functions, unless F() macro is not supported.

if (Firebase.ready() && (millis() - sendDataPrevMillis > 15000 || sendDataPrevMillis == 0))
Expand Down
2 changes: 1 addition & 1 deletion examples/DataChangesListener/MultiPath/MultiPath.ino
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ void setup()
void loop()
{

//Flash string (PROGMEM and (FPSTR), String C/C++ string, const char, char array, string literal are supported
//Flash string (PROGMEM and (FPSTR), String,, String C/C++ string, const char, char array, string literal are supported
//in all Firebase and FirebaseJson functions, unless F() macro is not supported.

if (Firebase.ready() && (millis() - sendDataPrevMillis > 15000 || sendDataPrevMillis == 0))
Expand Down
2 changes: 1 addition & 1 deletion examples/DataChangesListener/NoCallback/NoCallback.ino
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ void setup()
void loop()
{

//Flash string (PROGMEM and (FPSTR), String C/C++ string, const char, char array, string literal are supported
//Flash string (PROGMEM and (FPSTR), String,, String C/C++ string, const char, char array, string literal are supported
//in all Firebase and FirebaseJson functions, unless F() macro is not supported.

if (!Firebase.ready())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void setup()

void loop()
{
//Flash string (PROGMEM and (FPSTR), String C/C++ string, const char, char array, string literal are supported
//Flash string (PROGMEM and (FPSTR), String,, String C/C++ string, const char, char array, string literal are supported
//in all Firebase and FirebaseJson functions, unless F() macro is not supported.

if (Firebase.ready() && (millis() - sendDataPrevMillis > idleTimeForStream || sendDataPrevMillis == 0))
Expand Down
2 changes: 1 addition & 1 deletion examples/DataFilter/DataFilter.ino
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ void setup()

void loop()
{
//Flash string (PROGMEM and (FPSTR), String C/C++ string, const char, char array, string literal are supported
//Flash string (PROGMEM and (FPSTR), String,, String C/C++ string, const char, char array, string literal are supported
//in all Firebase and FirebaseJson functions, unless F() macro is not supported.

if (Firebase.ready() && !taskCompleted)
Expand Down
2 changes: 1 addition & 1 deletion examples/DatabaseRules/DatabaseRules.ino
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ void setup()

void loop()
{
//Flash string (PROGMEM and (FPSTR), String C/C++ string, const char, char array, string literal are supported
//Flash string (PROGMEM and (FPSTR), String,, String C/C++ string, const char, char array, string literal are supported
//in all Firebase and FirebaseJson functions, unless F() macro is not supported.

if (Firebase.ready() && !taskCompleted)
Expand Down
2 changes: 1 addition & 1 deletion examples/ETag/ETag.ino
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ void setup()

void loop()
{
//Flash string (PROGMEM and (FPSTR), String C/C++ string, const char, char array, string literal are supported
//Flash string (PROGMEM and (FPSTR), String,, String C/C++ string, const char, char array, string literal are supported
//in all Firebase and FirebaseJson functions, unless F() macro is not supported.

if (Firebase.ready() && !taskCompleted)
Expand Down
2 changes: 1 addition & 1 deletion examples/FastSend/FastSend.ino
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void setup()

void loop()
{
//Flash string (PROGMEM and (FPSTR), String C/C++ string, const char, char array, string literal are supported
//Flash string (PROGMEM and (FPSTR), String,, String C/C++ string, const char, char array, string literal are supported
//in all Firebase and FirebaseJson functions, unless F() macro is not supported.

if (Firebase.ready() && (millis() - sendDataPrevMillis > 15000 || sendDataPrevMillis == 0))
Expand Down
2 changes: 1 addition & 1 deletion examples/File/Flash/Flash.ino
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ void setup()

void loop()
{
//Flash string (PROGMEM and (FPSTR), String C/C++ string, const char, char array, string literal are supported
//Flash string (PROGMEM and (FPSTR), String,, String C/C++ string, const char, char array, string literal are supported
//in all Firebase and FirebaseJson functions, unless F() macro is not supported.

if (Firebase.ready() && !taskCompleted)
Expand Down
2 changes: 1 addition & 1 deletion examples/File/SD/SD.ino
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ void setup()

void loop()
{
//Flash string (PROGMEM and (FPSTR), String C/C++ string, const char, char array, string literal are supported
//Flash string (PROGMEM and (FPSTR), String,, String C/C++ string, const char, char array, string literal are supported
//in all Firebase and FirebaseJson functions, unless F() macro is not supported.

if (Firebase.ready() && !taskCompleted)
Expand Down
2 changes: 1 addition & 1 deletion examples/Priority/Priority.ino
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void setup()

void loop()
{
//Flash string (PROGMEM and (FPSTR), String C/C++ string, const char, char array, string literal are supported
//Flash string (PROGMEM and (FPSTR), String,, String C/C++ string, const char, char array, string literal are supported
//in all Firebase and FirebaseJson functions, unless F() macro is not supported.

if (Firebase.ready() && !taskCompleted)
Expand Down
2 changes: 1 addition & 1 deletion examples/Queue/Queue.ino
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ void setup()

void loop()
{
//Flash string (PROGMEM and (FPSTR), String C/C++ string, const char, char array, string literal are supported
//Flash string (PROGMEM and (FPSTR), String,, String C/C++ string, const char, char array, string literal are supported
//in all Firebase and FirebaseJson functions, unless F() macro is not supported.

if (Firebase.ready() && !taskCompleted)
Expand Down
2 changes: 1 addition & 1 deletion examples/ShallowedData/ShallowedData.ino
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void setup()

void loop()
{
//Flash string (PROGMEM and (FPSTR), String C/C++ string, const char, char array, string literal are supported
//Flash string (PROGMEM and (FPSTR), String,, String C/C++ string, const char, char array, string literal are supported
//in all Firebase and FirebaseJson functions, unless F() macro is not supported.

if (Firebase.ready() && !taskCompleted)
Expand Down
18 changes: 17 additions & 1 deletion examples/Timestamp/Timestamp.ino
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ void setup()

void loop()
{
//Flash string (PROGMEM and (FPSTR), String C/C++ string, const char, char array, string literal are supported
//Flash string (PROGMEM and (FPSTR), String, C/C++ string, const char, char array, string literal are supported
//in all Firebase and FirebaseJson functions, unless F() macro is not supported.

if (Firebase.ready() && !taskCompleted)
Expand All @@ -115,5 +115,21 @@ void loop()
Serial.printf("Get timestamp... %s\n", Firebase.getDouble(fbdo, "/test/timestamp") ? "ok" : fbdo.errorReason().c_str());
if (fbdo.httpCode() == FIREBASE_ERROR_HTTP_CODE_OK)
printf("TIMESTAMP: %lld\n", fbdo.to<uint64_t>());

//To set and push data with timestamp, requires the JSON data with .sv placeholder
FirebaseJson json;

json.set("Data", "Hello");
//now we will set the timestamp value at Ts
json.set("Ts/.sv", "timestamp"); // .sv is the required place holder for sever value which currently supports only string "timestamp" as a value

//Set data with timestamp
Serial.printf("Set data with timestamp... %s\n", Firebase.setJSON(fbdo, "/test/set/data", json) ? fbdo.to<FirebaseJson>().raw() : fbdo.errorReason().c_str());

//Push data with timestamp
Serial.printf("Push data with timestamp... %s\n", Firebase.pushJSON(fbdo, "/test/push/data", json) ? "ok" : fbdo.errorReason().c_str());

//Get previous pushed data
Serial.printf("Get previous pushed data... %s\n", Firebase.getJSON(fbdo, "/test/push/data/" + fbdo.pushName()) ? fbdo.to<FirebaseJson>().raw() : fbdo.errorReason().c_str());
}
}
4 changes: 2 additions & 2 deletions library.properties
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name=Firebase ESP8266 Client

version=3.4.2
version=3.4.3

author=Mobizt

maintainer=Mobizt <[email protected]>

sentence=Google Firebase Realtime Database Arduino Client Library for Espressif ESP8266

paragraph=This client library provides the most reliable operations for read, store, update, delete, backup and restore the Firebase Realtime database data.
paragraph=This client library provides the complete, fast, secured and reliable operations to read, store, update, delete, monitor the value changes, backup, restore, read and modify the security rules of the Firebase Realtime database.

category=Communication

Expand Down
10 changes: 5 additions & 5 deletions src/FirebaseESP8266.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@

#ifndef FIREBASE_CLIENT_VERSION
#define FIREBASE_CLIENT_VERSION "3.4.2"
#define FIREBASE_CLIENT_VERSION "3.4.3"
#endif

/**
* Google's Firebase Realtime Database Arduino Library for ESP8266, v3.4.2
* Google's Firebase Realtime Database Arduino Library for ESP8266, v3.4.3
*
* August 21, 2021
* Created August 31, 2021
*
* Updates:
*
* - Add supports generic string and number.
* - Fix pushTimestamp bad request issue.
* - Update timestamp example.
*
* 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
* and delete calls.
Expand Down
2 changes: 1 addition & 1 deletion src/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Firebase Realtime Database Arduino Library for ESP8266


Google's Firebase Realtime Database Arduino Library for ESP8266 v3.4.2
Google's Firebase Realtime Database Arduino Library for ESP8266 v3.4.3


## Global functions
Expand Down
10 changes: 5 additions & 5 deletions src/rtdb/FB_RTDB.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/**
* Google's Firebase Realtime Database class, FB_RTDB.cpp version 1.2.1
* Google's Firebase Realtime Database class, FB_RTDB.cpp version 1.2.2
*
* This library supports Espressif ESP8266 and ESP32
*
* Created August 21, 2021
* Created August 31, 2021
*
* This work is a part of Firebase ESP Client library
* Copyright (c) 2021 K. Suwatchai (Mobizt)
Expand Down Expand Up @@ -59,7 +59,7 @@ void FB_RTDB::end(FirebaseData *fbdo)
fbdo->clear();
}

void FB_RTDB::mSetReadTimeout(FirebaseData *fbdo, const char* millisec)
void FB_RTDB::mSetReadTimeout(FirebaseData *fbdo, const char *millisec)
{
if ((int)millisec <= 900000)
fbdo->_ss.rtdb.read_tmo = (int)millisec;
Expand Down Expand Up @@ -416,7 +416,7 @@ bool FB_RTDB::buildRequest(FirebaseData *fbdo, fb_esp_method method, const char
return processRequest(fbdo, &req);
}

bool FB_RTDB::mDeleteNodesByTimestamp(FirebaseData *fbdo, const char *path, const char *timestampNode, const char* limit, const char* dataRetentionPeriod)
bool FB_RTDB::mDeleteNodesByTimestamp(FirebaseData *fbdo, const char *path, const char *timestampNode, const char *limit, const char *dataRetentionPeriod)
{
if (fbdo->_ss.rtdb.pause)
return true;
Expand All @@ -435,7 +435,7 @@ bool FB_RTDB::mDeleteNodesByTimestamp(FirebaseData *fbdo, const char *path, cons

if (_limit > 30)
_limit = 30;

char *pEnd;
uint32_t pr = strtoull(dataRetentionPeriod, &pEnd, 10);

Expand Down
14 changes: 7 additions & 7 deletions src/rtdb/FB_RTDB.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/**
* Google's Firebase Realtime Database class, FB_RTDB.h version 1.2.1
* Google's Firebase Realtime Database class, FB_RTDB.h version 1.2.2
*
* This library supports Espressif ESP8266 and ESP32
*
* Created August 21, 2021
* Created August 31, 2021
*
* This work is a part of Firebase ESP Client library
* Copyright (c) 2021 K. Suwatchai (Mobizt)
Expand Down Expand Up @@ -433,10 +433,10 @@ class FB_RTDB
* call [FirebaseData object].pushName() to get the key.
*/
template <typename T = const char *>
bool pushTimestamp(FirebaseData *fbdo, T path) { return buildRequest(fbdo, m_post, toString(path), _NO_PAYLOAD, d_timestamp, _NO_SUB_TYPE, _NO_REF, _NO_QUERY, _NO_PRIORITY, _NO_ETAG, _NO_ASYNC, _NO_QUEUE); }
bool pushTimestamp(FirebaseData *fbdo, T path) { return buildRequest(fbdo, m_post, toString(path), PGM2S(fb_esp_pgm_str_154).get(), d_timestamp, _NO_SUB_TYPE, _NO_REF, _NO_QUERY, _NO_PRIORITY, _NO_ETAG, _NO_ASYNC, _NO_QUEUE); }

template <typename T = const char *>
bool pushTimestampAsync(FirebaseData *fbdo, T path) { return buildRequest(fbdo, m_post, toString(path), _NO_PAYLOAD, d_timestamp, _NO_SUB_TYPE, _NO_REF, _NO_QUERY, _NO_PRIORITY, _NO_ETAG, _IS_ASYNC, _NO_QUEUE); }
bool pushTimestampAsync(FirebaseData *fbdo, T path) { return buildRequest(fbdo, m_post, toString(path), PGM2S(fb_esp_pgm_str_154).get(), d_timestamp, _NO_SUB_TYPE, _NO_REF, _NO_QUERY, _NO_PRIORITY, _NO_ETAG, _IS_ASYNC, _NO_QUEUE); }

/** Set (put) the integer value at the defined node.
*
Expand Down Expand Up @@ -1749,7 +1749,7 @@ class FB_RTDB
bool mPathExisted(FirebaseData *fbdo, const char *path);
String mGetETag(FirebaseData *fbdo, const char *path);
bool mGetShallowData(FirebaseData *fbdo, const char *path);
bool mDeleteNodesByTimestamp(FirebaseData *fbdo, const char *path, const char *timestampNode, const char* limit, const char* dataRetentionPeriod);
bool mDeleteNodesByTimestamp(FirebaseData *fbdo, const char *path, const char *timestampNode, const char *limit, const char *dataRetentionPeriod);
bool mBeginMultiPathStream(FirebaseData *fbdo, const char *parentPath);
bool mBackup(FirebaseData *fbdo, fb_esp_mem_storage_type storageType, const char *nodePath, const char *fileName);
bool mRestore(FirebaseData *fbdo, fb_esp_mem_storage_type storageType, const char *nodePath, const char *fileName);
Expand All @@ -1769,9 +1769,9 @@ class FB_RTDB
bool mBeginStream(FirebaseData *fbdo, const char *path);
void mSetReadTimeout(FirebaseData *fbdo, const char *millisec);
#if defined(ESP32)
void runStreamTask(FirebaseData *fbdo, const char *taskName);
void runStreamTask(FirebaseData *fbdo, const char *taskName);
#elif defined(ESP8266)
void runStreamTask();
void runStreamTask();
void runErrorQueueTask();
#endif
uint8_t openErrorQueue(FirebaseData *fbdo, const char *filename, fb_esp_mem_storage_type storageType, uint8_t mode);
Expand Down

0 comments on commit e8df939

Please sign in to comment.