-
Notifications
You must be signed in to change notification settings - Fork 493
Improve stability of the repo #296
Changes from 12 commits
08bed6b
d7aebba
d2138bf
ae903b0
b6712d2
e175110
6b768f9
651a5b9
7c89e0d
1f8746d
02cfb98
57df59e
90ce6f1
b8c152f
09cd329
bdfe2bc
4276c99
ed75682
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,10 @@ FirebaseArduino is a library to simplify connecting to the Firebase database fro | |
arduino clients. | ||
|
||
It is a full abstraction of Firebase's REST API exposed through C++ calls in a wiring | ||
friendly way. All Json parsing is handled by the library and you may deal in pure C/Arduino | ||
types. | ||
friendly way. | ||
|
||
ArduinoJson is no longer part of this library and you will have to install latest version | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we should add a new There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
in Arduino environment yourself. (through Board manager or download+unpack from master: | ||
https://github.com/bblanchon/ArduinoJson ) | ||
|
||
---------------------------------- |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#include <string> | ||
|
||
typedef std::string String; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,12 +20,14 @@ | |
#ifndef firebase_h | ||
#define firebase_h | ||
|
||
#include "WString.h" | ||
#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; | ||
|
@@ -65,7 +67,7 @@ class Firebase { | |
Firebase() {} | ||
|
||
private: | ||
std::unique_ptr<FirebaseHttpClient> http_; | ||
std::shared_ptr<FirebaseHttpClient> http_; | ||
std::string host_; | ||
std::string auth_; | ||
}; | ||
|
@@ -76,7 +78,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 { | ||
|
@@ -90,17 +92,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_; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe this could simply be statically allocated as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't remember the details, but I am pretty sure latest version of JSONArduino is very strict on memory allocations so passing this buffer around as-is results in compilation errors. |
||
}; | ||
|
||
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_; | ||
|
@@ -110,7 +112,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: | ||
|
@@ -121,7 +123,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 { | ||
|
@@ -136,15 +138,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. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious why this is not already added by the board package:
https://github.com/esp8266/Arduino/blob/master/boards.txt#L1353
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It did not work without it, I had to create my own travis docker container to figure out why the heck it was failing.