diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..a41c078a --- /dev/null +++ b/.travis.yml @@ -0,0 +1,15 @@ +language: c +sudo: false +env: +- ARDUINO_VERSION=1.6.8 ARDUINO_ESP8266_VERSION=2.1.0 ARDUINO_ROOT=${HOME}/arduino-${ARDUINO_VERSION} ARDUINO_ESP8266_ROOT=${ARDUINO_ROOT}/hardware/esp8266com/esp8266 ARDUINO_HOME=${HOME}/Arduino +- ARDUINO_VERSION=1.6.8 ARDUINO_ESP8266_VERSION=2.2.0-rc1 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 ARDUINO_ROOT=${HOME}/arduino-${ARDUINO_VERSION} ARDUINO_ESP8266_ROOT=${ARDUINO_ROOT}/hardware/esp8266com/esp8266 ARDUINO_HOME=${HOME}/Arduino +install: +- ( cd ${HOME} && curl -O https://downloads.arduino.cc/arduino-${ARDUINO_VERSION}-linux64.tar.xz && tar xvf arduino-${ARDUINO_VERSION}-linux64.tar.xz ) +- git clone --branch ${ARDUINO_ESP8266_VERSION} https://github.com/esp8266/Arduino.git ${ARDUINO_ESP8266_ROOT} +- ( 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.1.1 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/FirebasePush_ESP8266/FirebasePush_ESP8266.ino diff --git a/examples/FirebasePush_ESP8266/FirebasePush_ESP8266.ino b/examples/FirebasePush_ESP8266/FirebasePush_ESP8266.ino index 37cbea2e..2075e99d 100644 --- a/examples/FirebasePush_ESP8266/FirebasePush_ESP8266.ino +++ b/examples/FirebasePush_ESP8266/FirebasePush_ESP8266.ino @@ -20,8 +20,8 @@ #include // create firebase client. -Firebase fbase = Firebase("example.firebaseio.com") - .auth("secret_or_token"); +Firebase fbase("example.firebaseio.com", "secret_or_token"); + void setup() { Serial.begin(9600); diff --git a/src/Firebase.cpp b/src/Firebase.cpp index 08c2ebbe..bc392750 100644 --- a/src/Firebase.cpp +++ b/src/Firebase.cpp @@ -32,17 +32,12 @@ String makeFirebaseURL(const String& path, const String& auth) { } // namespace -Firebase::Firebase(const String& host) : host_(host) { +Firebase::Firebase(const String& host, const String& auth) : host_(host), auth_(auth) { http_.reset(FirebaseHttpClient::create()); http_->setReuseConnection(true); } -Firebase& Firebase::auth(const String& auth) { - auth_ = auth; - return *this; -} - -const String& Firebase::auth() { +const String& Firebase::auth() const { return auth_; } @@ -168,7 +163,7 @@ FirebasePush::FirebasePush(const String& host, const String& auth, FirebaseHttpClient* http) : FirebaseCall(host, auth, "POST", path, value, http) { if (!error()) { - //name_ = json()["name"].as(); + name_ = json()["name"].as(); } } diff --git a/src/Firebase.h b/src/Firebase.h index b511914c..b0f00895 100644 --- a/src/Firebase.h +++ b/src/Firebase.h @@ -37,14 +37,9 @@ class FirebaseStream; // Firebase REST API client. class Firebase { public: - explicit Firebase(const String& host); - Firebase& auth(const String& auth); - virtual ~Firebase() = default; + Firebase(const String& host, const String& auth = ""); - Firebase(const Firebase&) = delete; - - // Fetch auth string back. - const String& auth(); + const String& auth() const; // Fetch json encoded `value` at `path`. FirebaseGet get(const String& path); diff --git a/src/modem/begin-command.cpp b/src/modem/begin-command.cpp index 4f7cb34d..97de7a09 100644 --- a/src/modem/begin-command.cpp +++ b/src/modem/begin-command.cpp @@ -33,10 +33,7 @@ bool BeginCommand::execute(const String& command, return false; } - new_firebase_.reset(new Firebase(host)); - if (auth.length() != 0) { - new_firebase_->auth(auth); - } + new_firebase_.reset(new Firebase(host, auth)); out->println("+OK"); return true;