Replies: 1 comment
-
What is the version of the firebase library ? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am working on a project and wanted a help to this.
Here i am streaiming path switch 1 and switch 2 using multipathstreaming.
But i wanted to get both the values : pin and status when switch child gets triggered.
How can i archive this?
should i use json parsing ?or any other method.
My code of multiStreamingPath :
FirebaseData firebaseData1;
String parentPath = "/Devices";
String childPath[1] = {"/Room1"};
size_t childPathSize = 1;
void handlePin(String path,String value)
{
if(path == "/Board1/Switch1")
{
Serial.println("Switch 1 data recieved");
Serial.println(value);
}
else if(path=="/Board1/Switch2")
{
Serial.println("Switch 2 data recieved");
Serial.println(value);
}
}
void streamCallback(MultiPathStreamData stream)
{
Serial.println();
Serial.println("Stream Data1 available");
size_t numChild = sizeof(childPath) / sizeof(childPath[0]);
for (size_t i = 0; i < numChild; i++)
{
if (stream.get(childPath[i]))
{
Serial.println("stream ");
Serial.println(stream.get(childPath[i]));
}
Serial.println();
}
void streamTimeoutCallback(bool timeout)
{
if (timeout)
Serial.println("stream timeout, resuming...\n");
}
void setup()
{
Serial.begin(115200);
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
Serial.print("Connecting to Wi-Fi");
while (WiFi.status() != WL_CONNECTED)
{
Serial.print(".");
delay(300);
}
Serial.println();
Serial.print("Connected with IP: ");
Serial.println(WiFi.localIP());
Serial.println();
Firebase.begin(FIREBASE_HOST,FIREBASE_AUTH);
Firebase.reconnectWiFi(true);
//Check stream is working or not
if (!Firebase.beginMultiPathStream(firebaseData1, parentPath,childPath,childPathSize))
{
Serial.println("cant begin stream connection\n");
Serial.println("Reason: "+firebaseData1.errorReason());
}
Firebase.setMultiPathStreamCallback(firebaseData1,streamCallback,streamTimeoutCallback);
}
void loop()
{
Beta Was this translation helpful? Give feedback.
All reactions