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

Call setString crash white Stream #185

Closed
tabvn opened this issue Jul 1, 2016 · 5 comments
Closed

Call setString crash white Stream #185

tabvn opened this issue Jul 1, 2016 · 5 comments

Comments

@tabvn
Copy link

tabvn commented Jul 1, 2016

#include 
#include 

// Set these to run example.
#define FIREBASE_HOST "**"
#define FIREBASE_AUTH "***"
#define WIFI_SSID "***"
#define WIFI_PASSWORD "****"
#define UID "abc"
#define url "/users/abc/devices"


FirebaseArduino FirebaseStream;

void setup() {
  Serial.begin(9600);

  // connect to wifi.
  WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
  Serial.print("Connecting to wifi");
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print(".");
    delay(500);
  }
  Serial.println();
  Serial.print("connected: ");
  Serial.println(WiFi.localIP());
  
  

  FirebaseStream.begin(FIREBASE_HOST, FIREBASE_AUTH);
  Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
  FirebaseStream.stream(url); 
  
}

int n;
void loop() {

  Serial.println("loop");
  Firebase.setInt("data", n++);
  
  if (FirebaseStream.failed()) {
    Serial.println("streaming error");
    Serial.println(FirebaseStream.error());
  }

  if (FirebaseStream.available()) {
     FirebaseObject event = FirebaseStream.readEvent();
     String eventType = event.getString("type");
     eventType.toLowerCase();
            
     if (eventType == "put") {
     //  message = state ? "Device now is On": "Devive now is off";
       JsonVariant json = event.getJsonVariant();
       
       String path = json["path"].asString();
       if (path != "/"){
        // first loading seem it load all the devices. So we dont need it 
         Serial.println("");
         json.printTo(Serial);

         // if data: TRUE this mean device status change in this case we only take care when device status change.
         
          
         Serial.println(event.getBool("data"));
         String message = event.getBool("data") ? "Device is on now" : "Devive is off now";

         Serial.println("Sending message to server.");

         //Firebase.setString("message", "hello world");
         delay(1000);
         
        // If data: Null this mean device just deleted see screenshot: http://cloud.tabvn.com/rax3i8.png 

        // Else String or object  (this could be adding new item or update device title .... 
         
       }
       
   
     }
  } 

  
}

programe.txt
screen shot 2016-07-01 at 12 14 28 pm

@tabvn
Copy link
Author

tabvn commented Jul 1, 2016

program crash at line

Firebase.setInt("data", n++);

@tabvn
Copy link
Author

tabvn commented Aug 1, 2016

Hey Google Team, Any chance to look and improve stream features ? look still bug with calling get or set during streaming.
that could be great.

@proppy
Copy link
Contributor

proppy commented Aug 1, 2016

hey tabvn@, thanks for the report.

Can you confirm:

Thanks in advance.

Please also note this is not an official Google nor Firebase product: https://github.com/googlesamples/firebase-arduino#disclaimer :)

@tabvn
Copy link
Author

tabvn commented Aug 1, 2016

HI proppy ,

Thanks for quick reply. it is current version on github because it seem 2-3 months there are no update yet.

@proppy
Copy link
Contributor

proppy commented Oct 4, 2016

merging with #48

@proppy proppy closed this as completed Oct 4, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants