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

Improve stability of the repo #296

Merged
merged 18 commits into from
Jan 31, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
15 changes: 8 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,27 @@ addons:
packages:
- g++-4.8
env:
- ARDUINO_VERSION=1.6.9 ARDUINO_ESP8266_VERSION=2.3.0 LIB_NEOPIXEL_VERSION=v1.0.5 LIB_GFX_VERSION=v1.1.5 LIB_SSD1306_VERSION=1.1.0 ARDUINO_ROOT=${HOME}/arduino-${ARDUINO_VERSION} ARDUINO_ESP8266_ROOT=${ARDUINO_ROOT}/hardware/esp8266com/esp8266 ARDUINO_HOME=${HOME}/Arduino
- ARDUINO_VERSION=nightly ARDUINO_ESP8266_VERSION=master LIB_NEOPIXEL_VERSION=master LIB_GFX_VERSION=master LIB_SSD1306_VERSION=master ARDUINO_ROOT=${HOME}/arduino-${ARDUINO_VERSION} ARDUINO_ESP8266_ROOT=${ARDUINO_ROOT}/hardware/esp8266com/esp8266 ARDUINO_HOME=${HOME}/Arduino
- ARDUINO_VERSION=1.6.9 ARDUINO_ESP8266_VERSION=2.3.0 LIB_NEOPIXEL_VERSION=v1.0.5 LIB_GFX_VERSION=v1.1.5 LIB_SSD1306_VERSION=1.1.0 LIB_JSON_VERSION=v5.11.2 ARDUINO_ROOT=${HOME}/arduino-${ARDUINO_VERSION} ARDUINO_ESP8266_ROOT=${ARDUINO_ROOT}/hardware/esp8266com/esp8266 ARDUINO_HOME=${HOME}/Arduino
- ARDUINO_VERSION=nightly ARDUINO_ESP8266_VERSION=master LIB_NEOPIXEL_VERSION=master LIB_GFX_VERSION=master LIB_SSD1306_VERSION=master LIB_JSON_VERSION=master ARDUINO_ROOT=${HOME}/arduino-${ARDUINO_VERSION} ARDUINO_ESP8266_ROOT=${ARDUINO_ROOT}/hardware/esp8266com/esp8266 ARDUINO_HOME=${HOME}/Arduino
install:
- if [ "$CXX" = "g++" ]; then export CXX="g++-4.8" CC="gcc-4.8"; fi
- ( cd ${HOME} && wget https://downloads.arduino.cc/arduino-${ARDUINO_VERSION}-linux64.tar.xz && tar xf arduino-${ARDUINO_VERSION}-linux64.tar.xz )
- ( LIB=SoftwareSerial VERSION=097712eb07f5b3a70ef419b6e7a7ed2ada5aab85 && cd ${HOME} && wget https://github.com/plerup/espsoftwareserial/archive/${VERSION}.zip -q -O ${LIB}.zip && unzip -q ${LIB}.zip && rm ${LIB}.zip && mv espsoftwareserial-* ${LIB} )
- ( LIB=Adafruit_NeoPixel VERSION=${LIB_NEOPIXEL_VERSION} && cd ${HOME} && wget https://github.com/adafruit/${LIB}/archive/${VERSION}.zip -q -O ${LIB}.zip && unzip -q ${LIB}.zip && rm ${LIB}.zip && mv ${LIB}-* ${LIB} )
- ( LIB=Adafruit-GFX-Library VERSION=${LIB_GFX_VERSION} && cd ${HOME} && wget https://github.com/adafruit/${LIB}/archive/${VERSION}.zip -q -O ${LIB}.zip && unzip -q ${LIB}.zip && rm ${LIB}.zip && mv ${LIB}-* ${LIB} )
- ( LIB=Adafruit_SSD1306 VERSION=${LIB_SSD1306_VERSION} && cd ${HOME} && wget https://github.com/adafruit/${LIB}/archive/${VERSION}.zip -q -O ${LIB}.zip && unzip -q ${LIB}.zip && rm ${LIB}.zip && mv ${LIB}-* ${LIB} )
- ( LIB=ArduinoJson VERSION=${LIB_JSON_VERSION} && cd ${HOME} && wget https://github.com/bblanchon/${LIB}/archive/${VERSION}.zip -q -O ${LIB}.zip && unzip -q ${LIB}.zip && rm ${LIB}.zip && mv ${LIB}-* ${LIB} )
- git clone --branch ${ARDUINO_ESP8266_VERSION} https://github.com/esp8266/Arduino.git ${ARDUINO_ESP8266_ROOT}
- git submodule init && git submodule update
- ( cd ${ARDUINO_ESP8266_ROOT}/tools && python get.py )
before_script:
- mkdir -p ${ARDUINO_HOME}/libraries
- ( cd ${ARDUINO_HOME}/libraries && ln -s ${TRAVIS_BUILD_DIR} firebase-arduino && ln -s ${TRAVIS_BUILD_DIR}/src/third-party/arduino-json-5.6.7 ArduinoJson && ln -s ${HOME}/SoftwareSerial ./ && ln -s ${HOME}/Adafruit_NeoPixel ./ && ln -s ${HOME}/Adafruit-GFX-Library ./ && ln -s ${HOME}/Adafruit_SSD1306 ./)
- ( cd ${ARDUINO_HOME}/libraries && ln -s ${TRAVIS_BUILD_DIR} firebase-arduino && ln -s ${HOME}/SoftwareSerial ./ && ln -s ${HOME}/Adafruit_NeoPixel ./ && ln -s ${HOME}/Adafruit-GFX-Library ./ && ln -s ${HOME}/Adafruit_SSD1306 ./ && ln -s ${HOME}/ArduinoJson ./)
script:
- ${ARDUINO_ROOT}/arduino-builder -verbose -hardware ${ARDUINO_ROOT}/hardware/ -tools ${ARDUINO_ESP8266_ROOT}/tools/ -tools ${ARDUINO_ROOT}/tools-builder/ -fqbn esp8266com:esp8266:nodemcuv2 -libraries ${ARDUINO_HOME}/libraries/ -prefs build.flash_ld=${ARDUINO_ESP8266_ROOT}/tools/sdk/ld/eagle.flash.4m.ld -prefs build.flash_freq=40 -prefs build.flash_size=4M examples/FirebaseDemo_ESP8266/FirebaseDemo_ESP8266.ino
- ${ARDUINO_ROOT}/arduino-builder -verbose -hardware ${ARDUINO_ROOT}/hardware/ -tools ${ARDUINO_ESP8266_ROOT}/tools/ -tools ${ARDUINO_ROOT}/tools-builder/ -fqbn esp8266com:esp8266:nodemcuv2 -libraries ${ARDUINO_HOME}/libraries/ -prefs build.flash_ld=${ARDUINO_ESP8266_ROOT}/tools/sdk/ld/eagle.flash.4m.ld -prefs build.flash_freq=40 -prefs build.flash_size=4M examples/FirebaseNeoPixel_ESP8266/FirebaseNeoPixel_ESP8266.ino
- ${ARDUINO_ROOT}/arduino-builder -verbose -hardware ${ARDUINO_ROOT}/hardware/ -tools ${ARDUINO_ESP8266_ROOT}/tools/ -tools ${ARDUINO_ROOT}/tools-builder/ -fqbn esp8266com:esp8266:nodemcuv2 -libraries ${ARDUINO_HOME}/libraries/ -prefs build.flash_ld=${ARDUINO_ESP8266_ROOT}/tools/sdk/ld/eagle.flash.4m.ld -prefs build.flash_freq=40 -prefs build.flash_size=4M examples/FirebaseStream_ESP8266/FirebaseStream_ESP8266.ino
- ${ARDUINO_ROOT}/arduino-builder -verbose -hardware ${ARDUINO_ROOT}/hardware/ -tools ${ARDUINO_ESP8266_ROOT}/tools/ -tools ${ARDUINO_ROOT}/tools-builder/ -fqbn esp8266com:esp8266:nodemcuv2 -libraries ${ARDUINO_HOME}/libraries/ -prefs build.flash_ld=${ARDUINO_ESP8266_ROOT}/tools/sdk/ld/eagle.flash.4m.ld -prefs build.flash_freq=40 -prefs build.flash_size=4M examples/FirebaseRoom_ESP8266/FirebaseRoom_ESP8266.ino
- ${ARDUINO_ROOT}/arduino-builder -verbose -hardware ${ARDUINO_ROOT}/hardware/ -tools ${ARDUINO_ESP8266_ROOT}/tools/ -tools ${ARDUINO_ROOT}/tools-builder/ -fqbn esp8266com:esp8266:nodemcuv2 -libraries ${ARDUINO_HOME}/libraries/ -prefs build.flash_ld=${ARDUINO_ESP8266_ROOT}/tools/sdk/ld/eagle.flash.4m.ld -prefs build.flash_freq=40 -prefs build.flash_size=4M -prefs build.f_cpu=80000000 examples/FirebaseDemo_ESP8266/FirebaseDemo_ESP8266.ino
Copy link
Contributor

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

Copy link
Collaborator Author

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.

- ${ARDUINO_ROOT}/arduino-builder -verbose -hardware ${ARDUINO_ROOT}/hardware/ -tools ${ARDUINO_ESP8266_ROOT}/tools/ -tools ${ARDUINO_ROOT}/tools-builder/ -fqbn esp8266com:esp8266:nodemcuv2 -libraries ${ARDUINO_HOME}/libraries/ -prefs build.flash_ld=${ARDUINO_ESP8266_ROOT}/tools/sdk/ld/eagle.flash.4m.ld -prefs build.flash_freq=40 -prefs build.flash_size=4M -prefs build.f_cpu=80000000 examples/FirebaseNeoPixel_ESP8266/FirebaseNeoPixel_ESP8266.ino
- ${ARDUINO_ROOT}/arduino-builder -verbose -hardware ${ARDUINO_ROOT}/hardware/ -tools ${ARDUINO_ESP8266_ROOT}/tools/ -tools ${ARDUINO_ROOT}/tools-builder/ -fqbn esp8266com:esp8266:nodemcuv2 -libraries ${ARDUINO_HOME}/libraries/ -prefs build.flash_ld=${ARDUINO_ESP8266_ROOT}/tools/sdk/ld/eagle.flash.4m.ld -prefs build.flash_freq=40 -prefs build.flash_size=4M -prefs build.f_cpu=80000000 examples/FirebaseStream_ESP8266/FirebaseStream_ESP8266.ino
- ${ARDUINO_ROOT}/arduino-builder -verbose -hardware ${ARDUINO_ROOT}/hardware/ -tools ${ARDUINO_ESP8266_ROOT}/tools/ -tools ${ARDUINO_ROOT}/tools-builder/ -fqbn esp8266com:esp8266:nodemcuv2 -libraries ${ARDUINO_HOME}/libraries/ -prefs build.flash_ld=${ARDUINO_ESP8266_ROOT}/tools/sdk/ld/eagle.flash.4m.ld -prefs build.flash_freq=40 -prefs build.flash_size=4M -prefs build.f_cpu=80000000 examples/FirebaseRoom_ESP8266/FirebaseRoom_ESP8266.ino
- ( cd contrib/test && make check )
- ( cd contrib/test/modem/ && make test )
- contrib/test/travis/check_all_examples_use_standard_init.sh
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ The Arduino library is [under heavy development](https://github.com/googlesample

- [FirebaseArduino API Reference](http://firebase-arduino.readthedocs.io/)

## Dependencies
- FirebaseArduino now depends on [ArduinoJson library](https://github.com/bblanchon/ArduinoJson) instead of containing it's own version of it. Please either use Library Manager or download specific version of the library from github.

## Disclaimer

*This is not an official Google product*.
7 changes: 5 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should add a new # DEPENDENCIES sections in the README?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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)

----------------------------------
2 changes: 1 addition & 1 deletion contrib/src/modem/db/stream-command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ bool StreamCommand::execute(const String& command,
out->print(FirebaseStream::EventToName(event).c_str());
out->print(" ");
const auto& object = buffer.parseObject(json.c_str());
String data = object["data"];
String data = object["data"].asString();
out->println(object["path"].asString());
out->println(data.length());
out->println(data);
Expand Down
2 changes: 1 addition & 1 deletion contrib/src/thing/Config.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "Arduino.h"
#include "thing/Config.h"
#include "third-party/arduino-json-5.6.7/include/ArduinoJson.h"
#include <ArduinoJson.h>

namespace thing {

Expand Down
2 changes: 1 addition & 1 deletion contrib/src/thing/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "Arduino.h"
#include <string>
#include <functional>
#include "third-party/arduino-json-5.6.7/include/ArduinoJson.h"
#include <ArduinoJson.h>

namespace thing {

Expand Down
2 changes: 1 addition & 1 deletion contrib/src/thing/Portal.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "thing/Portal.h"
#include "third-party/arduino-json-5.6.7/include/ArduinoJson.h"
#include <ArduinoJson.h>

namespace thing {

Expand Down
1 change: 1 addition & 0 deletions contrib/test/FirebaseArduino_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "FirebaseObject.h"
#include "gtest/gtest.h"


TEST(FirebaseObjectTest, GetBool) {
FirebaseObject obj("true");
EXPECT_EQ(true, obj.getBool());
Expand Down
4 changes: 2 additions & 2 deletions contrib/test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

FIREBASE_DIR=../..
GTEST_DIR=googletest/googletest
ARDUINOJSON_DIR=../../src/third-party/arduino-json-5.6.7
ARDUINOJSON_DIR=${ARDUINO_HOME}/libraries/ArduinoJson

FIREBASE_SRCS=${FIREBASE_DIR}/src/FirebaseObject.cpp
GTEST_SRCS=${GTEST_DIR}/src/gtest-all.cpp
Expand All @@ -27,7 +27,7 @@ SRCS=FirebaseArduino_test.cpp\

OBJS=${SRCS:.cpp=.o}

CXXFLAGS=-I. -I${FIREBASE_DIR}/src -Igoogletest/googletest/include -Igoogletest/googletest -std=c++11 -g
CXXFLAGS=-I. -I${FIREBASE_DIR}/src -I${ARDUINOJSON_DIR}/src -Igoogletest/googletest/include -Igoogletest/googletest -std=c++11 -g
LDFLAGS=-lpthread

all: check
Expand Down
2 changes: 2 additions & 0 deletions contrib/test/modem/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ FIREBASE_ROOT = ../../..
PROJECT_ROOT = ../..
SRC_ROOT = $(PROJECT_ROOT)/src
FIREBASE_SRC_ROOT = $(FIREBASE_ROOT)/src
ARDUINOJSON_DIR=$(ARDUINO_HOME)/libraries/ArduinoJson

# Flags passed to the preprocessor.
# Set Google Test and Google Mock's header directories as system
Expand All @@ -45,6 +46,7 @@ CPPFLAGS += -isystem $(GTEST_DIR)/include -isystem $(GMOCK_DIR)/include \
-I$(PROJECT_ROOT)/test/dummies \
-I$(PROJECT_ROOT)/src \
-I$(FIREBASE_ROOT)/src \
-I$(ARDUINOJSON_DIR)/src \
-I$(PROJECT_ROOT)

# Flags passed to the C++ compiler.
Expand Down
3 changes: 3 additions & 0 deletions contrib/test/modem/WString.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include <string>

typedef std::string String;
73 changes: 39 additions & 34 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,56 @@ const std::string& Firebase::auth() const {
}

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

unique_ptr<FirebaseGet> Firebase::getPtr(const std::string& path) {
return unique_ptr<FirebaseGet>(new 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_));
}

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

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()));
unique_ptr<FirebaseSet> Firebase::setPtr(const std::string& path,
const std::string& value) {
return unique_ptr<FirebaseSet>(
new 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());
return FirebasePush(host_, auth_, path, value, http_);
}
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()));

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

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

unique_ptr<FirebaseRemove> Firebase::removePtr(const std::string& path) {
return unique_ptr<FirebaseRemove>(
new 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_));
}

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

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()));
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_));
}

// 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);
if ((method == "STREAM") && (path == http->getStreamingPath())){
// already streaming requested path.
Expand Down Expand Up @@ -153,22 +155,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 @@ -179,7 +183,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 @@ -189,26 +193,27 @@ 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) {
}

bool FirebaseStream::available() {
if (http_->getStreamPtr() == nullptr) {
return false;
}
return http_->getStreamPtr()->available();
auto client = http_->getStreamPtr();
return (client == nullptr) ? false : client->available();
}

FirebaseStream::Event FirebaseStream::read(std::string& event) {
auto client = http_->getStreamPtr();
if (client == nullptr) {
return Event();
}
Event type;
std::string typeStr = client->readStringUntil('\n').substring(7).c_str();
if (typeStr == "put") {
Expand Down
Loading