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

FirebaseArduino: allow mixing stream and non-stream commands #294

Merged
merged 1 commit into from
Nov 11, 2017

Conversation

proppy
Copy link
Contributor

@proppy proppy commented Nov 2, 2017

With this change non-streaming operation will stop the stream and
reuse the underlying http client.

Call FirebaseArduino::stream again in order to reuse the stream.

This is similar to what @ed7coyne did in the contrib/modem

/cc @salqadri @kotl

Fixes: #48 #266

With this change non-streaming operation will stop the stream and
reuse the underlying http client.

Call FirebaseArduino::stream again in order to reuse the stream.

Fixes: FirebaseExtended#48
@proppy proppy requested a review from ed7coyne November 2, 2017 08:14
@kotl
Copy link
Collaborator

kotl commented Nov 11, 2017

I have reviewed this change and it looks good to me. thanks.

@proppy proppy requested a review from kotl November 11, 2017 02:22
@kotl kotl removed the request for review from ed7coyne November 11, 2017 02:22
Copy link
Collaborator

@kotl kotl left a comment

Choose a reason for hiding this comment

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

Great, this should properly close connection or reuse existing one as well as resume streaming.

@kotl kotl merged commit f022066 into FirebaseExtended:master Nov 11, 2017
@Xmanu12
Copy link

Xmanu12 commented Nov 27, 2017

Great solution @proppy, thanks for fix it.
Now, my sketch dont generate an exception and not reset when make a Firebase.set() inside a Firebase.stream loop.
However, after I make the Firebase.set() (that works and the new value is correctly store on the FirebaseDB server) I was unable to re-start the streaming listening loop.
Please can you give me an example of how to "Call FirebaseArduino::stream again in order to reuse the stream."
I can not find the correct command. Many thanks.ML

@proppy
Copy link
Contributor Author

proppy commented Nov 28, 2017

@Xmanu12 did you try calling ::stream again in loop?

@Xmanu12
Copy link

Xmanu12 commented Nov 28, 2017

thanks for your faster answer @proppy.
Do you mean ?
Firebase.stream("/listening_path");
if I call again, let the stream function inoperative, dont return any value.

@milinddhanke
Copy link

As I use Firebase.stream("/listening_path"); at beginning of the void loop every thing is working properly, though I use some non stream commands in loop. Thanks friends.

@ahmedezzatmtc
Copy link

please @proppy tell us what do you mean by simple example
another question
why we use stream ? is it to just listen to changes on a specific path and how to read the change?
my code crashes in>>>>> if (stream.available())
thank you for your effort

@milinddhanke
Copy link

milinddhanke commented Dec 5, 2017

Hi friends, here is my code, working properly, though I use some non stream commands in loop.
BUT!!!!!
As my internet connection is interrupted firebase stream disconnected, and when internet connection will ok firebase stream will not automatically connected.
I gone through all (latest) comments/changes to reuse HTTPClient.
Please tell me what changes/additions should i made in my program.

#include <FirebaseArduino.h>
#include <ESP8266WiFi.h>
int led = 13;

void setup() {
pinMode(led, OUTPUT);
WiFi.begin("ssid", "pass");
Firebase.begin("abc.firebaseio.com");
Firebase.setInt("abc", 000);
}

void loop() {
Firebase.stream("/abc");

if (Firebase.available()) {
FirebaseObject event = Firebase.readEvent();
String eventType = event.getString("type");
eventType.toLowerCase();

if (eventType == "put") {          
  String path = event.getString("path");
  String data = event.getString("data");
  if (data == "123")
   {digitalWrite(led, HIGH);
    Firebase.setInt("123/out", 111);}
  if (data == "456")
   {digitalWrite(led, LOW);
    Firebase.setInt("456/out", 000);}
   }
  }
 }

@maherahmed
Copy link

@milinddhanke the same issue here

@milinddhanke
Copy link

Hello friends please help me to resolve my problem

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants