Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 all commits
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
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
- ${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
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,15 @@

This repo contains a collection of samples and an Arduino library that show how to call the [Firebase](https://www.firebase.com/) API from the [ESP8266 Arduino core](https://github.com/esp8266/Arduino).

The Arduino library is [under heavy development](https://github.com/googlesamples/firebase-arduino/issues), **experimental**, **unversioned** and its API is **not stable**.

## Status

![Status: Frozen](https://img.shields.io/badge/Status-Frozen-yellow)

This repository is no longer under active development. No new features will be added and issues are not actively triaged. Pull Requests which fix bugs are welcome and will be reviewed on a best-effort basis.

If you maintain a fork of this repository that you believe is healthier than the official version, we may consider recommending your fork. Please open a Pull Request if you believe that is the case.


## Samples

Expand All @@ -19,6 +27,11 @@ 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. We recommend that ArduinoJson is at least version [5.13.1](https://github.com/bblanchon/ArduinoJson/tree/v5.13.1)

- ESP8266 Core SDK. We recommend using officially tagged releases and it should be at least [2.4.1](https://github.com/esp8266/Arduino/tree/2.4.1)

## 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
in Arduino environment yourself. (through Board manager or download+unpack from master:
https://github.com/bblanchon/ArduinoJson)

----------------------------------
8 changes: 4 additions & 4 deletions contrib/src/modem/command.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef MODEM_COMMAND_H
#define MODEM_COMMAND_H

#include "Firebase.h"
#include "FirebaseArduino.h"
#include "modem/output-stream.h"
#include "modem/input-stream.h"

Expand All @@ -10,19 +10,19 @@ namespace modem {

class Command {
public:
Command(Firebase* fbase) : fbase_(fbase) {}
Command(FirebaseArduino* fbase) : fbase_(fbase) {}

// Execute command, reading any additional data needed from stream.
// Return false if execution failed.
virtual bool execute(const String& command,
InputStream* in, OutputStream* out) = 0;
protected:
Firebase& fbase() {
FirebaseArduino& fbase() {
return *fbase_;
}

private:
Firebase* fbase_;
FirebaseArduino* fbase_;
};

} // modem
Expand Down
2 changes: 1 addition & 1 deletion contrib/src/modem/db/DatabaseProtocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void DatabaseProtocol::Execute(const String& command_name, InputStream* in,
}

std::unique_ptr<Command> DatabaseProtocol::CreateCommand(const String& text,
Firebase* fbase) {
FirebaseArduino* fbase) {
std::unique_ptr<Command> command;
if (text == "GET") {
command.reset(new GetCommand(fbase));
Expand Down
4 changes: 2 additions & 2 deletions contrib/src/modem/db/DatabaseProtocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ class DatabaseProtocol : public SerialProtocol {
const std::vector<String>& commands() const override;
void Execute(const String& command, InputStream* in, OutputStream* out) override;
private:
std::unique_ptr<Command> CreateCommand(const String& text, Firebase* fbase);
std::unique_ptr<Command> CreateCommand(const String& text, FirebaseArduino* fbase);

std::unique_ptr<Firebase> fbase_;
std::unique_ptr<FirebaseArduino> fbase_;
};


Expand Down
5 changes: 3 additions & 2 deletions contrib/src/modem/db/begin-command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,14 @@ bool BeginCommand::execute(const String& command,
return false;
}

new_firebase_.reset(new Firebase(host.c_str(), auth.c_str()));
new_firebase_.reset(new FirebaseArduino());
new_firebase_.get()->begin(host.c_str(), auth.c_str());

out->println("+OK");
return true;
}

std::unique_ptr<Firebase> BeginCommand::firebase() {
std::unique_ptr<FirebaseArduino> BeginCommand::firebase() {
return std::move(new_firebase_);
}

Expand Down
16 changes: 8 additions & 8 deletions contrib/src/modem/db/commands.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef MODEM_DB_COMMANDS_H
#define MODEM_DB_COMMANDS_H

#include "Firebase.h"
#include "FirebaseArduino.h"
#include "modem/command.h"
#include "modem/output-stream.h"
#include "modem/input-stream.h"
Expand All @@ -11,28 +11,28 @@ namespace modem {

class GetCommand : public Command {
public:
GetCommand(Firebase* fbase) : Command(fbase) {}
GetCommand(FirebaseArduino* fbase) : Command(fbase) {}

bool execute(const String& command, InputStream* in, OutputStream* out);
};

class SetCommand : public Command {
public:
SetCommand(Firebase* fbase) : Command(fbase) {}
SetCommand(FirebaseArduino* fbase) : Command(fbase) {}

bool execute(const String& command, InputStream* in, OutputStream* out);
};

class RemoveCommand : public Command {
public:
RemoveCommand(Firebase* fbase) : Command(fbase) {}
RemoveCommand(FirebaseArduino* fbase) : Command(fbase) {}

bool execute(const String& command, InputStream* in, OutputStream* out);
};

class PushCommand : public Command {
public:
PushCommand(Firebase* fbase) : Command(fbase) {}
PushCommand(FirebaseArduino* fbase) : Command(fbase) {}

bool execute(const String& command, InputStream* in, OutputStream* out);
};
Expand All @@ -44,15 +44,15 @@ class BeginCommand : public Command {
bool execute(const String& command, InputStream* in, OutputStream* out);

// This can only be called once.
std::unique_ptr<Firebase> firebase();
std::unique_ptr<FirebaseArduino> firebase();

private:
std::unique_ptr<Firebase> new_firebase_;
std::unique_ptr<FirebaseArduino> new_firebase_;
};

class StreamCommand : public Command {
public:
StreamCommand(Firebase* fbase) : Command(fbase) {}
StreamCommand(FirebaseArduino* fbase) : Command(fbase) {}

bool execute(const String& command, InputStream* in, OutputStream* out);
};
Expand Down
10 changes: 4 additions & 6 deletions contrib/src/modem/db/get-command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,14 @@ bool GetCommand::execute(const String& command,
return false;
}

std::string path = in->readLine().c_str();
std::unique_ptr<FirebaseGet> get(fbase().getPtr(path));

if (get->error()) {
String path = in->readLine();
String value = fbase().getString(path);
if (fbase().error().length() != 0) {
out->print("-FAIL ");
out->println(get->error().message().c_str());
out->println(fbase().error().c_str());
return false;
}

String value(get->response().c_str());
// TODO implement json parsing to pull and process value.
out->print("+");
out->println(value);
Expand Down
11 changes: 5 additions & 6 deletions contrib/src/modem/db/push-command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@ bool PushCommand::execute(const String& command,
return false;
}

std::string path(in->readStringUntil(' ').c_str());
std::string data(in->readLine().c_str());
String path = in->readStringUntil(' ');
String data = in->readLine();

std::unique_ptr<FirebasePush> push(
fbase().pushPtr(path, EncodeForJson(data)));
fbase().pushString(path, data);

if (push->error()) {
if (fbase().error().length() != 0) {
out->print("-FAIL ");
out->println(push->error().message().c_str());
out->println(fbase().error().c_str());
return false;
} else {
out->println("+OK");
Expand Down
6 changes: 3 additions & 3 deletions contrib/src/modem/db/remove-command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ bool RemoveCommand::execute(const String& command,
}

String path = in->readLine();
std::unique_ptr<FirebaseRemove> get(fbase().removePtr(path.c_str()));
fbase().remove(path);

if (get->error()) {
if (fbase().error().length() != 0) {
out->print("-FAIL ");
out->println(get->error().message().c_str());
out->println(fbase().error().c_str());
return false;
}

Expand Down
11 changes: 5 additions & 6 deletions contrib/src/modem/db/set-command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@ bool SetCommand::execute(const String& command,
return false;
}

std::string path(in->readStringUntil(' ').c_str());
std::string data(in->readLine().c_str());
String path = in->readStringUntil(' ');
String data = in->readLine();

std::unique_ptr<FirebaseSet> set(fbase().setPtr(path,
EncodeForJson(data)));
fbase().setString(path, data);

if (set->error()) {
if (fbase().error().length() != 0) {
out->print("-FAIL ");
out->println(set->error().message().c_str());
out->println(fbase().error().c_str());
return false;
} else {
out->println("+OK");
Expand Down
21 changes: 9 additions & 12 deletions contrib/src/modem/db/stream-command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,24 @@ bool StreamCommand::execute(const String& command,
return false;
}

std::string path = in->readLine().c_str();
std::unique_ptr<FirebaseStream> stream(fbase().streamPtr(path));
String path = in->readLine().c_str();
fbase().stream(path);

if (stream->error()) {
if (fbase().error().length() != 0) {
out->print("-FAIL ");
out->println(stream->error().message().c_str());
out->println(fbase().error().c_str());
return false;
}

bool running = true;
DynamicJsonBuffer buffer;
while(running) {
if (stream->available()) {
std::string json;
FirebaseStream::Event event = stream->read(json);
if (fbase().available()) {
FirebaseObject event = fbase().readEvent();
out->print("+");
out->print(FirebaseStream::EventToName(event).c_str());
out->print(event.getString("type").c_str());
out->print(" ");
const auto& object = buffer.parseObject(json.c_str());
String data = object["data"];
out->println(object["path"].asString());
String data = event.getString("data");
out->println(event.getString("path"));
out->println(data.length());
out->println(data);
} else if (in->available()) {
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
Loading