Skip to content
This repository was archived by the owner on Mar 17, 2025. It is now read-only.

New Firebase Fingerprint #540

Open
wants to merge 85 commits into
base: contrib
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
7144703
Merge pull request #241 from firebase/contrib
proppy Feb 3, 2017
6072f19
Fixed a code comment
Kevinwlee Feb 9, 2017
53aaae1
FirebaseHttpClient: add forceReuse
proppy Apr 10, 2017
3a68e6c
FirebaseHttpClient_Esp8266: fix trailing space
proppy Apr 10, 2017
1d1830e
The signature for Firebase seems to have changed
salqadri Apr 25, 2017
c9496bd
Merge pull request #261 from salqadri/master
proppy Apr 27, 2017
a23fb4e
updated the firebase sha1 fingerprint.
RaemondBW Aug 18, 2017
147ec30
Merge pull request #277 from RaemondBW/master
proppy Aug 21, 2017
e6445d1
Merge pull request #248 from Kevinwlee/patch-2
proppy Sep 8, 2017
08bed6b
Merge pull request #1 from firebase/master
kotl Sep 22, 2017
df523c0
reuse HTTPClient::end
proppy Oct 27, 2017
c73ca0e
Merge pull request #260 from firebase/force-reuse
proppy Oct 27, 2017
d62b9cb
FirebaseArduino: allow mixing stream and non-stream commands
proppy Nov 2, 2017
d7aebba
Add ability to detect null string (happens when nodes gets deleted)
kotl Nov 7, 2017
d2138bf
Crazy update to use shared_ptr and get rid of old ArduinoJson library…
kotl Nov 7, 2017
f022066
Merge pull request #294 from proppy/fix-stream
kotl Nov 11, 2017
ae903b0
Add changes/info needed to pass CI build.
kotl Nov 11, 2017
b6712d2
Forgot to add symbolic link.
kotl Nov 11, 2017
e175110
And finally removing symbolic link created for json library previousl…
kotl Nov 11, 2017
6b768f9
Fix contrib directory to use external ArduinoJson library.
kotl Nov 11, 2017
651a5b9
More fixes for contrib test to use external JSON library.
kotl Nov 11, 2017
7c89e0d
fix issues with travis build
kotl Nov 12, 2017
1f8746d
Add back getPtr functions.
kotl Nov 12, 2017
02cfb98
Fixing modem tests
kotl Nov 12, 2017
57df59e
add build.f_cpu preference
kotl Nov 12, 2017
90ce6f1
Avoid crashes when .available() is called by detecting that underlyin…
kotl Nov 13, 2017
b8c152f
Merge branch 'master' of https://github.com/kotl/firebase-arduino
kotl Nov 13, 2017
702d9f3
remove duplicates
ikshitiz Dec 27, 2017
09cd329
Add back nightly build environment
kotl Jan 22, 2018
bdfe2bc
Added section about ArduinoJson dependency
kotl Jan 22, 2018
4276c99
Merge branch 'master' into master
kotl Jan 22, 2018
ed75682
Remove trailing space from the comment
kotl Jan 29, 2018
96eab42
Merge pull request #296 from kotl/master
proppy Jan 31, 2018
3d05b41
Refactoring into on-demand classes and http connections
kotl Apr 11, 2018
55a2ec6
Attempt to fix mocks
kotl Apr 11, 2018
37e0c43
attempt to fix test 2
kotl Apr 12, 2018
b81f286
Add mock response
kotl Apr 12, 2018
a3d0e36
fixed typo
kotl Apr 12, 2018
3558351
Fixing a problem with reusing same client.
kotl Apr 18, 2018
4fc8da2
Fix modem contrib
kotl Apr 18, 2018
353a6d7
Remove dead code.
kotl Apr 18, 2018
8bce695
Added proper mock object and method for modem tests
kotl Apr 18, 2018
82cd290
fix param definition in mock-firebase.h
kotl Apr 18, 2018
95ce5ec
remove test / mock dead code
kotl Apr 18, 2018
38575e3
Fix error() mock definition
kotl Apr 18, 2018
905c4bc
use explicit string comparison
kotl Apr 18, 2018
721a3c4
fix error empty checks, header files and makefile for modem test
kotl Apr 18, 2018
7dc2fea
fixing compilation and some of the tests. disabled stream test for now
kotl May 6, 2018
4c5a98c
remaining unit tests for push/set/remove for modem
kotl May 7, 2018
a7bf160
Enabling and fix stream unit test for modem code
kotl May 7, 2018
de3874e
Merge pull request #330 from kotl/master
proppy Jun 15, 2018
0c1b046
Merge pull request #307 from iKshitiz/patch-1
proppy Jun 15, 2018
30ca778
remove duplicates (#2)
kotl Jun 21, 2018
2347c48
Update README.md
kotl Jun 21, 2018
2f76fae
Update README.md
kotl Jun 21, 2018
88170c8
Manually merge: "Report error when streaming loses connection. #179"
kotl Jun 21, 2018
9dcf205
Removed temp files
kotl Jun 21, 2018
26a87d4
Merge pull request #356 from kotl/master
proppy Jun 21, 2018
1bc2263
Updating firebase fingerprint
yehiyam Aug 2, 2018
e197696
Merge pull request #368 from yehiyam/patch-1
proppy Aug 3, 2018
e62c217
Firebase.readEvent() returns "type" instead "put" while getting data …
kptdobe Aug 8, 2018
b14884a
Use proper API
kptdobe Aug 15, 2018
50a5865
Use correct syntax and api
kptdobe Aug 15, 2018
434df1c
Try with explicit objects
kptdobe Aug 15, 2018
a2a9896
Issue comes from the set during the tests...
kptdobe Aug 15, 2018
5746cb5
Checking tests with latest ArduinoJson lib version
kptdobe Aug 15, 2018
d330ced
Maybe...
kptdobe Aug 15, 2018
e4713f7
Another test
kptdobe Aug 15, 2018
2b47534
Another test...
kptdobe Aug 15, 2018
f1c940d
Give up...
kptdobe Aug 15, 2018
728dd9d
Test with ESP8266 2.4.1
kptdobe Aug 15, 2018
74f63e2
Revert "Test with ESP8266 2.4.1"
kptdobe Aug 15, 2018
db84569
Quick final test
kptdobe Aug 15, 2018
f08825d
Revert "Quick final test"
kptdobe Aug 15, 2018
3af3a1a
Fixed!
kptdobe Aug 15, 2018
3195d23
Integrated feedback
kptdobe Aug 15, 2018
33363f7
Merge pull request #374 from kptdobe/issue/364
kotl Aug 15, 2018
fb31f8e
[FirebaseObject] Error message is never reset #390 (#391)
kptdobe Nov 20, 2018
3530f7d
Fix issue #388 ESP8266 fails to reconnect to FIREBASE #388
Jan 25, 2019
cd5681f
New fingerprint update
kotl Mar 2, 2019
f152bd0
Update to latest RTDB SSL fingerprint (#438)
avolkovi Apr 19, 2019
90c0ce4
Merge pull request #401 from philipnguyen8588/master
kotl Apr 19, 2019
f02bf47
SSL Fingerprint Update
TrickSumo Mar 2, 2020
ad782fd
Merge pull request #479 from TrickSumo/patch-3
kotl Mar 4, 2020
c2b39a3
Update README.md (#498)
samtstern Aug 7, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Crazy update to use shared_ptr and get rid of old ArduinoJson library…
… and use latest one.
  • Loading branch information
kotl committed Nov 7, 2017
commit d2138bf3e4317e0d6edc070a2e36369fa80b6b9f
56 changes: 17 additions & 39 deletions src/Firebase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "Firebase.h"

using std::unique_ptr;
using std::shared_ptr;

namespace {
std::string makeFirebaseURL(const std::string& path, const std::string& auth) {
Expand All @@ -42,55 +43,30 @@ const std::string& Firebase::auth() const {
}

FirebaseGet Firebase::get(const std::string& path) {
return FirebaseGet(host_, auth_, path, http_.get());
}

unique_ptr<FirebaseGet> Firebase::getPtr(const std::string& path) {
return unique_ptr<FirebaseGet>(new FirebaseGet(host_, auth_, path, http_.get()));
return FirebaseGet(host_, auth_, path, http_);
}

FirebaseSet Firebase::set(const std::string& path, const std::string& value) {
return FirebaseSet(host_, auth_, path, value, http_.get());
}

unique_ptr<FirebaseSet> Firebase::setPtr(const std::string& path,
const std::string& value) {
return unique_ptr<FirebaseSet>(
new FirebaseSet(host_, auth_, path, value, http_.get()));
return FirebaseSet(host_, auth_, path, value, http_);
}

FirebasePush Firebase::push(const std::string& path, const std::string& value) {
return FirebasePush(host_, auth_, path, value, http_.get());
}
unique_ptr<FirebasePush> Firebase::pushPtr(const std::string& path, const std::string& value) {
return unique_ptr<FirebasePush>(
new FirebasePush(host_, auth_, path, value, http_.get()));
return FirebasePush(host_, auth_, path, value, http_);
}

FirebaseRemove Firebase::remove(const std::string& path) {
return FirebaseRemove(host_, auth_, path, http_.get());
}

unique_ptr<FirebaseRemove> Firebase::removePtr(const std::string& path) {
return unique_ptr<FirebaseRemove>(
new FirebaseRemove(host_, auth_, path, http_.get()));
return FirebaseRemove(host_, auth_, path, http_);
}

FirebaseStream Firebase::stream(const std::string& path) {
// TODO: create new client dedicated to stream.
return FirebaseStream(host_, auth_, path, http_.get());
}

unique_ptr<FirebaseStream> Firebase::streamPtr(const std::string& path) {
// TODO: create new client dedicated to stream.
return unique_ptr<FirebaseStream>(
new FirebaseStream(host_, auth_, path, http_.get()));
return FirebaseStream(host_, auth_, path, http_);
}

// FirebaseCall
FirebaseCall::FirebaseCall(const std::string& host, const std::string& auth,
const char* method, const std::string& path,
const std::string& data, FirebaseHttpClient* http) : http_(http) {
const std::string& data, const std::shared_ptr<FirebaseHttpClient> http) : http_(http) {
std::string path_with_auth = makeFirebaseURL(path, auth);
http_->setReuseConnection(true);
http_->begin(host, path_with_auth);
Expand Down Expand Up @@ -141,22 +117,24 @@ FirebaseCall::~FirebaseCall() {

const JsonObject& FirebaseCall::json() {
//TODO(edcoyne): This is not efficient, we should do something smarter with
//the buffers.
buffer_ = DynamicJsonBuffer();
return buffer_.parseObject(response().c_str());
//the buffers. kotl: Is this still valid?
if (buffer_.get() == NULL) {
buffer_.reset(new StaticJsonBuffer<FIREBASE_JSONBUFFER_SIZE>());
}
return buffer_.get()->parseObject(response().c_str());
}

// FirebaseGet
FirebaseGet::FirebaseGet(const std::string& host, const std::string& auth,
const std::string& path,
FirebaseHttpClient* http)
const std::shared_ptr<FirebaseHttpClient> http)
: FirebaseCall(host, auth, "GET", path, "", http) {
}

// FirebaseSet
FirebaseSet::FirebaseSet(const std::string& host, const std::string& auth,
const std::string& path, const std::string& value,
FirebaseHttpClient* http)
const std::shared_ptr<FirebaseHttpClient> http)
: FirebaseCall(host, auth, "PUT", path, value, http) {
if (!error()) {
// TODO: parse json
Expand All @@ -167,7 +145,7 @@ FirebaseSet::FirebaseSet(const std::string& host, const std::string& auth,
// FirebasePush
FirebasePush::FirebasePush(const std::string& host, const std::string& auth,
const std::string& path, const std::string& value,
FirebaseHttpClient* http)
const std::shared_ptr<FirebaseHttpClient> http)
: FirebaseCall(host, auth, "POST", path, value, http) {
if (!error()) {
name_ = json()["name"].as<const char*>();
Expand All @@ -177,14 +155,14 @@ FirebasePush::FirebasePush(const std::string& host, const std::string& auth,
// FirebaseRemove
FirebaseRemove::FirebaseRemove(const std::string& host, const std::string& auth,
const std::string& path,
FirebaseHttpClient* http)
const std::shared_ptr<FirebaseHttpClient> http)
: FirebaseCall(host, auth, "DELETE", path, "", http) {
}

// FirebaseStream
FirebaseStream::FirebaseStream(const std::string& host, const std::string& auth,
const std::string& path,
FirebaseHttpClient* http)
const std::shared_ptr<FirebaseHttpClient> http)
: FirebaseCall(host, auth, "STREAM", path, "", http) {
}

Expand Down
29 changes: 12 additions & 17 deletions src/Firebase.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@

#include <Arduino.h>
#include <memory>
#include <ArduinoJson.h>

#include "FirebaseHttpClient.h"
#include "FirebaseError.h"
#define ARDUINOJSON_USE_ARDUINO_STRING 1
#include "third-party/arduino-json-5.6.7/include/ArduinoJson.h"
#include "FirebaseObject.h"

class FirebaseGet;
class FirebaseSet;
Expand All @@ -42,30 +43,24 @@ class Firebase {

// Fetch json encoded `value` at `path`.
FirebaseGet get(const std::string& path);
virtual std::unique_ptr<FirebaseGet> getPtr(const std::string& path);

// Set json encoded `value` at `path`.
FirebaseSet set(const std::string& path, const std::string& json);
virtual std::unique_ptr<FirebaseSet> setPtr(const std::string& path, const std::string& json);

// Add new json encoded `value` to list at `path`.
FirebasePush push(const std::string& path, const std::string& json);
virtual std::unique_ptr<FirebasePush> pushPtr(const std::string& path, const std::string& json);

// Delete value at `path`.
FirebaseRemove remove(const std::string& path);
virtual std::unique_ptr<FirebaseRemove> removePtr(const std::string& path);

// Start a stream of events that affect value at `path`.
FirebaseStream stream(const std::string& path);
virtual std::unique_ptr<FirebaseStream> streamPtr(const std::string& path);

protected:
// Used for testing.
Firebase() {}

private:
std::unique_ptr<FirebaseHttpClient> http_;
std::shared_ptr<FirebaseHttpClient> http_;
std::string host_;
std::string auth_;
};
Expand All @@ -76,7 +71,7 @@ class FirebaseCall {
FirebaseCall(const std::string& host, const std::string& auth,
const char* method, const std::string& path,
const std::string& data = "",
FirebaseHttpClient* http = NULL);
const std::shared_ptr<FirebaseHttpClient> http = NULL);
virtual ~FirebaseCall();

virtual const FirebaseError& error() const {
Expand All @@ -90,17 +85,17 @@ class FirebaseCall {
const JsonObject& json();

protected:
FirebaseHttpClient* http_;
const std::shared_ptr<FirebaseHttpClient> http_;
FirebaseError error_;
std::string response_;
DynamicJsonBuffer buffer_;
std::shared_ptr<StaticJsonBuffer<FIREBASE_JSONBUFFER_SIZE>> buffer_;
};

class FirebaseGet : public FirebaseCall {
public:
FirebaseGet() {}
FirebaseGet(const std::string& host, const std::string& auth,
const std::string& path, FirebaseHttpClient* http = NULL);
const std::string& path, const std::shared_ptr<FirebaseHttpClient> http = NULL);

private:
std::string json_;
Expand All @@ -110,7 +105,7 @@ class FirebaseSet: public FirebaseCall {
public:
FirebaseSet() {}
FirebaseSet(const std::string& host, const std::string& auth,
const std::string& path, const std::string& value, FirebaseHttpClient* http = NULL);
const std::string& path, const std::string& value, const std::shared_ptr<FirebaseHttpClient> http = NULL);


private:
Expand All @@ -121,7 +116,7 @@ class FirebasePush : public FirebaseCall {
public:
FirebasePush() {}
FirebasePush(const std::string& host, const std::string& auth,
const std::string& path, const std::string& value, FirebaseHttpClient* http = NULL);
const std::string& path, const std::string& value, const std::shared_ptr<FirebaseHttpClient> http = NULL);
virtual ~FirebasePush() {}

virtual const std::string& name() const {
Expand All @@ -136,15 +131,15 @@ class FirebaseRemove : public FirebaseCall {
public:
FirebaseRemove() {}
FirebaseRemove(const std::string& host, const std::string& auth,
const std::string& path, FirebaseHttpClient* http = NULL);
const std::string& path, const std::shared_ptr<FirebaseHttpClient> http = NULL);
};


class FirebaseStream : public FirebaseCall {
public:
FirebaseStream() {}
FirebaseStream(const std::string& host, const std::string& auth,
const std::string& path, FirebaseHttpClient* http = NULL);
const std::string& path, const std::shared_ptr<FirebaseHttpClient> http = NULL);
virtual ~FirebaseStream() {}

// Return if there is any event available to read.
Expand Down
18 changes: 9 additions & 9 deletions src/FirebaseArduino.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ String FirebaseArduino::pushString(const String& path, const String& value) {
String FirebaseArduino::push(const String& path, const JsonVariant& value) {
String buf;
value.printTo(buf);
auto push = FirebasePush(host_, auth_, path.c_str(), buf.c_str(), http_.get());
auto push = FirebasePush(host_, auth_, path.c_str(), buf.c_str(), http_);
error_ = push.error();
return push.name().c_str();
}
Expand All @@ -71,12 +71,12 @@ void FirebaseArduino::setString(const String& path, const String& value) {
void FirebaseArduino::set(const String& path, const JsonVariant& value) {
String buf;
value.printTo(buf);
auto set = FirebaseSet(host_, auth_, path.c_str(), buf.c_str(), http_.get());
auto set = FirebaseSet(host_, auth_, path.c_str(), buf.c_str(), http_);
error_ = set.error();
}

FirebaseObject FirebaseArduino::get(const String& path) {
auto get = FirebaseGet(host_, auth_, path.c_str(), http_.get());
auto get = FirebaseGet(host_, auth_, path.c_str(), http_);
error_ = get.error();
if (failed()) {
return FirebaseObject{""};
Expand All @@ -85,7 +85,7 @@ FirebaseObject FirebaseArduino::get(const String& path) {
}

int FirebaseArduino::getInt(const String& path) {
auto get = FirebaseGet(host_, auth_, path.c_str(), http_.get());
auto get = FirebaseGet(host_, auth_, path.c_str(), http_);
error_ = get.error();
if (failed()) {
return 0;
Expand All @@ -95,7 +95,7 @@ int FirebaseArduino::getInt(const String& path) {


float FirebaseArduino::getFloat(const String& path) {
auto get = FirebaseGet(host_, auth_, path.c_str(), http_.get());
auto get = FirebaseGet(host_, auth_, path.c_str(), http_);
error_ = get.error();
if (failed()) {
return 0.0f;
Expand All @@ -104,7 +104,7 @@ float FirebaseArduino::getFloat(const String& path) {
}

String FirebaseArduino::getString(const String& path) {
auto get = FirebaseGet(host_, auth_, path.c_str(), http_.get());
auto get = FirebaseGet(host_, auth_, path.c_str(), http_);
error_ = get.error();
if (failed()) {
return "";
Expand All @@ -113,20 +113,20 @@ String FirebaseArduino::getString(const String& path) {
}

bool FirebaseArduino::getBool(const String& path) {
auto get = FirebaseGet(host_, auth_, path.c_str(), http_.get());
auto get = FirebaseGet(host_, auth_, path.c_str(), http_);
error_ = get.error();
if (failed()) {
return "";
}
return FirebaseObject(get.response().c_str()).getBool();
}
void FirebaseArduino::remove(const String& path) {
auto remove = FirebaseRemove(host_, auth_, path.c_str(), http_.get());
auto remove = FirebaseRemove(host_, auth_, path.c_str(), http_);
error_ = remove.error();
}

void FirebaseArduino::stream(const String& path) {
auto stream = FirebaseStream(host_, auth_, path.c_str(), http_.get());
auto stream = FirebaseStream(host_, auth_, path.c_str(), http_);
error_ = stream.error();
}

Expand Down
2 changes: 1 addition & 1 deletion src/FirebaseArduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ class FirebaseArduino {
std::string host_;
std::string auth_;
FirebaseError error_;
std::unique_ptr<FirebaseHttpClient> http_;
std::shared_ptr<FirebaseHttpClient> http_;
};

extern FirebaseArduino Firebase;
Expand Down
2 changes: 1 addition & 1 deletion src/FirebaseCloudMessaging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const FirebaseError FirebaseCloudMessaging::SendMessageToTopic(

const FirebaseError FirebaseCloudMessaging::SendPayload(
const char* payload) {
std::unique_ptr<FirebaseHttpClient> client(FirebaseHttpClient::create());
std::shared_ptr<FirebaseHttpClient> client(FirebaseHttpClient::create());
client->begin("http://fcm.googleapis.com/fcm/send");
client->addHeader("Authorization", auth_header_.c_str());
client->addHeader("Content-Type", "application/json");
Expand Down
3 changes: 1 addition & 2 deletions src/FirebaseCloudMessaging.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
#include <vector>
#include "FirebaseHttpClient.h"
#include "FirebaseError.h"
#define ARDUINOJSON_USE_ARDUINO_STRING 1
#include "third-party/arduino-json-5.6.7/include/ArduinoJson.h"
#include <ArduinoJson.h>

// Defines the actual message to the client, for more detail on
// options and settings see:
Expand Down
5 changes: 3 additions & 2 deletions src/FirebaseObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
// We need to make a copy of data here, even though it may be large.
// It will need to be long lived.
FirebaseObject::FirebaseObject(const char* data) : data_{data} {
json_ = buffer_.parse(&data_[0]);
buffer_.reset(new StaticJsonBuffer<FIREBASE_JSONBUFFER_SIZE>);
json_ = buffer_.get()->parse(&data_[0]);
// TODO(proppy): find a way to check decoding error, tricky because
// ArduinoJson doesn't surface error for variant parsing.
// See: https://github.com/bblanchon/ArduinoJson/issues/279
Expand Down Expand Up @@ -83,7 +84,7 @@ JsonVariant FirebaseObject::getJsonVariant(const String& path) const {
// make `start` a C string.
*p = 0;
// return json variant at `start`.
json = json.asObject().get(start);
json = json.asObject().get<JsonVariant>(start);
// advance to next path element.
start = p + 1;
}
Expand Down
Loading