Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite326b43

Browse files
committed
Merge pull requestFirebaseExtended#123 from ed7coyne/add-docs
Add javadocs to Arduino API.
2 parents0229661 +36e2182 commite326b43

File tree

2 files changed

+115
-0
lines changed

2 files changed

+115
-0
lines changed

‎src/FirebaseArduino.h

Lines changed: 80 additions & 0 deletions
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
classFirebaseArduino {
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
voidbegin(constchar* host,constchar* 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
Stringpush(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
voidset(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
FirebaseObjectget(constchar* 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
voidremove(constchar* 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
voidstream(constchar* 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
boolavailable();
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
FirebaseObjectreadEvent();
101+
102+
/**
103+
* \return Whether the last command was successful.
104+
*/
33105
boolsuccess();
106+
107+
/**
108+
* \return Whether the last command failed.
109+
*/
34110
boolfailed();
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

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,49 @@
2323
#defineFIREBASE_JSONBUFFER_SIZE200
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
classFirebaseObject {
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
operatorbool();
43+
44+
/**
45+
* Interpret result as a int, only applicable if result is a single element
46+
* and not a tree.
47+
*/
3048
operatorint();
49+
50+
/**
51+
* Interpret result as a float, only applicable if result is a single element
52+
* and not a tree.
53+
*/
3154
operatorfloat();
55+
56+
/**
57+
* Interpret result as a String, only applicable if result is a single element
58+
* and not a tree.
59+
*/
3260
operatorconst 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
operatorconst JsonObject&();
67+
68+
//TODO(proppy): Add comments to these.
3469
JsonObjectSubscript<constchar*>operator[](constchar* key);
3570
JsonObjectSubscript<const String&>operator[](const String& key);
3671
JsonVariantoperator[](JsonObjectKey key)const;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp