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

Commit 26a87d4

Browse files
authored
Merge pull request #356 from kotl/master
Update suggested versions and manually merge connection error check
2 parents 0c1b046 + 9dcf205 commit 26a87d4

6 files changed

+26
-1
lines changed

Diff for: README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ The Arduino library is [under heavy development](https://github.com/googlesample
2020
- [FirebaseArduino API Reference](http://firebase-arduino.readthedocs.io/)
2121

2222
## Dependencies
23-
- 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.
23+
- 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)
24+
25+
- 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)
2426

2527
## Disclaimer
2628

Diff for: contrib/test/dummies/FirebaseHttpClient_dummy.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ class FirebaseHttpClientDummy : public FirebaseHttpClient {
2323
void addHeader(const std::string& UNUSED_ARG(name), const std::string& UNUSED_ARG(value)) override {
2424
}
2525

26+
bool connected() override {
27+
return true;
28+
}
29+
2630
void collectHeaders(const char* UNUSED_ARG(header_keys[]), const int UNUSED_ARG(count)) override {
2731
}
2832

Diff for: src/FirebaseArduino.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,11 @@ void FirebaseArduino::stream(const String& path) {
156156

157157
bool FirebaseArduino::available() {
158158
if (stream_http_.get() == nullptr) {
159+
error_ = FirebaseError(FIREBASE_ERROR_CODES::STREAM_NOT_INITIALIZED, "HTTP stream is not initialized");
160+
return 0;
161+
}
162+
if (!stream_http_.get()->connected()) {
163+
error_ = FirebaseError(FIREBASE_ERROR_CODES::HTTP_CONNECTION_LOST, "Connection Lost");
159164
return 0;
160165
}
161166
auto client = stream_http_.get()->getStreamPtr();

Diff for: src/FirebaseError.h

+8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
#ifndef firebase_error_h
22
#define firebase_error_h
33

4+
5+
// These error codes are used in addition to regular HTTP error codes.
6+
// Same error space is shared between HTTP errors and these values.
7+
enum FIREBASE_ERROR_CODES {
8+
HTTP_CONNECTION_LOST = -5,
9+
STREAM_NOT_INITIALIZED = -6
10+
};
11+
412
class FirebaseError {
513
public:
614
// Make it explicit that the empty constructor mean no error.

Diff for: src/FirebaseHttpClient.h

+2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ class FirebaseHttpClient {
3333

3434
virtual std::string errorToString(int error_code) = 0;
3535

36+
virtual bool connected() = 0;
37+
3638
protected:
3739
static const uint16_t kFirebasePort = 443;
3840
};

Diff for: src/FirebaseHttpClient_Esp8266.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ class FirebaseHttpClientEsp8266 : public FirebaseHttpClient {
8383
return HTTPClient::errorToString(error_code).c_str();
8484
}
8585

86+
bool connected() override {
87+
return http_.connected();
88+
}
89+
8690
private:
8791
ForceReuseHTTPClient http_;
8892
};

0 commit comments

Comments
 (0)