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

Commit e326b43

Browse files
committed
Merge pull request #123 from ed7coyne/add-docs
Add javadocs to Arduino API.
2 parents 0229661 + 36e2182 commit e326b43

File tree

2 files changed

+115
-0
lines changed

2 files changed

+115
-0
lines changed

src/FirebaseArduino.h

+80
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,98 @@
2020
#include "Firebase.h"
2121
#include "FirebaseObject.h"
2222

23+
/**
24+
* Main class for Arduino clients to interact with Firebase.
25+
* This implementation is designed to follow Arduino best practices and favor
26+
* simplicity over all else.
27+
* For more complicated usecases and more control see the Firebase class in
28+
* Firebase.h.
29+
*/
2330
class FirebaseArduino {
2431
public:
32+
/**
33+
* Must be called first. This initialize the client with the given
34+
* firebase host and credentials.
35+
* \param host Your firebase db host, usually X.firebaseio.com.
36+
* \param auth Optional credentials for the db, a secret or token.
37+
*/
2538
void begin(const char* host, const char* auth = "");
39+
40+
/**
41+
* Writes data to a new child location under the parent at path.
42+
* Equivalent to the REST API's POST.
43+
* You should check success() after calling.
44+
* \param path The path inside of your db to the parent object.
45+
* \param value Data that you wish to add under the parent.
46+
* \return The unique child key where the data was written.
47+
*/
2648
String push(const String& path, const JsonVariant& value);
49+
50+
/**
51+
* Writes the data in value to the node located at path equivalent to the
52+
* REST API's PUT.
53+
* You should check success() after calling.
54+
* \param path The path inside of your db to the node you wish to update.
55+
* \param value Data that you wish to write.
56+
*/
2757
void set(const String& path, const JsonVariant& value);
58+
59+
60+
/**
61+
* Gets the value located at path.
62+
* You should check success() after calling.
63+
* \param path The path to the node you wish to retrieve.
64+
* \return The data located at that path. This may either be a single element
65+
* or it may be a json structure. Will only be populated if success() is true.
66+
*/
2867
FirebaseObject get(const char* path);
68+
69+
/**
70+
* Remove the node, and possibly entire tree, located at path.
71+
* You should check success() after calling.
72+
* \param path The path to the node you wish to remove,
73+
* including all of its children.
74+
*/
2975
void remove(const char* path);
76+
77+
/**
78+
* Starts streaming any changes made to the node located at path, including
79+
* any of its children.
80+
* You should check success() after calling.
81+
* This changes the state of this object. Once this is called you may start
82+
* monitoring available() and calling readEvent() to get new events.
83+
* \param path The path inside of your db to the node you wish to monitor.
84+
*/
3085
void stream(const char* path);
86+
87+
/**
88+
* Checks if there are new events available. This is only meaningful once
89+
* stream() has been called.
90+
* \return If a new event is ready.
91+
*/
3192
bool available();
93+
94+
/**
95+
* Reads the next event in a stream. This is only meaningful once stream() has
96+
* been called.
97+
* \return Object will have ["type"] that describes the event type, ["path"]
98+
* that describes the effected path and ["data"] that was updated.
99+
*/
32100
FirebaseObject readEvent();
101+
102+
/**
103+
* \return Whether the last command was successful.
104+
*/
33105
bool success();
106+
107+
/**
108+
* \return Whether the last command failed.
109+
*/
34110
bool failed();
111+
112+
/**
113+
* \return Error message from last command if failed() is true.
114+
*/
35115
const String& error();
36116
private:
37117
String host_;

src/FirebaseObject.h

+35
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,49 @@
2323
#define FIREBASE_JSONBUFFER_SIZE 200
2424
#endif // FIREBASE_JSONBUFFER_SIZE
2525

26+
/**
27+
* Represents value stored in firebase, may be a singular value (leaf node) or
28+
* a tree structure.
29+
*/
2630
class FirebaseObject {
2731
public:
32+
/**
33+
* Construct from json.
34+
* \param data Json formatted string.
35+
*/
2836
FirebaseObject(const String& data);
37+
38+
/**
39+
* Interpret result as a bool, only applicable if result is a single element
40+
* and not a tree.
41+
*/
2942
operator bool();
43+
44+
/**
45+
* Interpret result as a int, only applicable if result is a single element
46+
* and not a tree.
47+
*/
3048
operator int();
49+
50+
/**
51+
* Interpret result as a float, only applicable if result is a single element
52+
* and not a tree.
53+
*/
3154
operator float();
55+
56+
/**
57+
* Interpret result as a String, only applicable if result is a single element
58+
* and not a tree.
59+
*/
3260
operator const String&();
61+
62+
/**
63+
* Interpret result as a JsonObject, if the result is a tree use this or the
64+
* operator[] methods below.
65+
*/
3366
operator const JsonObject&();
67+
68+
//TODO(proppy): Add comments to these.
3469
JsonObjectSubscript<const char*> operator[](const char* key);
3570
JsonObjectSubscript<const String&> operator[](const String& key);
3671
JsonVariant operator[](JsonObjectKey key) const;

0 commit comments

Comments
 (0)