firebase-arduino
firebase-arduino copied to clipboard
Stream() doesnt provide the path with eventType "patch"
When using stream() and the eventType is "patch" it doesnt show the "path" of the patched object.
Any suggestions?
Even I am deling with the same issue. I am getting the path but path before the expected child and not getting data at all. ex. (Database/Artist/Singer) --> This is what I am recieving. (Database/Artist/Singer/SingerName) --> This is what I am expecting
In stream function when I am giving the complete path (i.e Database/Artist/Singer/SingerName), at that time I am recieveing the correct data but it prints eventType as "put"
I am uploading the data on the Firebase using the android app and recieving the data using Nodemcu
I searched a lot for this on net but miserably failed to get the solution, I request contributors to have a look on this issue. I wil really appreciate that.
Sorry for the late reply
Seems similar to #335
Can you turn on debugging:
http://arduino-esp8266.readthedocs.io/en/latest/Troubleshooting/debugging.html
And paste the serial log from HttpClient
here?
Thanks in advance.
Actually, it works but really not straight forward to use...
If you output the JsonVariant from the event, data are here:
FirebaseObject event = Firebase.readEvent();
JsonVariant v = event.getJsonVariant("data");
String data = v.as<String>();
println(data);
This outputs something like:
{"sensor1":"value1","sensor2":"value2",}
(assuming you patch sensor1
and sensor2
values).
To fetch the data you need to prefix the paths with /data
: event.getString("/data/sensor1")
gives you value1
!!
There is one thing which is not possible to achieve: test if a property has been changed or read multiple properties. You would need to use event.failed()
or event.success()
to know if the previous getString
was successful, this would allow you to do something like:
FirebaseObject event = Firebase.readEvent();
String v1 = event.getString("/data/sensor1");
if(event.success()) {
// do something with new v1 value
}
String v2 = event.getString("/data/sensor2");
if(event.success()) {
// do something with new v2 value
}
The error mechanism in FirebaseObject
never resets the error message which mean you cannot "inspect" the payload and check if one of your property has been changed or read 2 of them and know if they have been changed.
I'll provide a PR to fix that but the whole logic would need to be reviewed because it is really complex to have a common code to handle put
and patch
...
anybody solve that yet...
I also want that if data triggering on firebase so I got data and path.
and if its not possible so plz suggest me other solution/way for the same problem.