|
24 | 24 | #defineFIREBASE_JSONBUFFER_SIZE200
|
25 | 25 | #endif// FIREBASE_JSONBUFFER_SIZE
|
26 | 26 |
|
| 27 | +/** |
| 28 | + * Gateway class for Arduino clients to interact with the Firebase backend. |
| 29 | + * This implementation is designed to follow Arduino best practices and favor |
| 30 | + * simplicity over all else. For more complicated usecases and more control |
| 31 | + * see the Firebase class in Firebase.h. |
| 32 | +*/ |
27 | 33 | classFirebaseArduino {
|
28 | 34 | public:
|
| 35 | +/** |
| 36 | + * Must be called first. This sets the class up for use. |
| 37 | + * \param host Your firebase db server domain name, usually X.firebaseIO.com. |
| 38 | + * \param auth Optional authentication for the db, a Secret or Token. |
| 39 | +*/ |
29 | 40 | voidbegin(constchar* host,constchar* auth ="");
|
| 41 | + |
| 42 | +/** |
| 43 | + * Adds the data in value to the list located at path. Equivilent to the |
| 44 | + * REST API's POST. |
| 45 | + * You should check success() after calling. |
| 46 | + * \param path The path inside of your db to the list you wish to update. |
| 47 | + * \param value Data that you wish to add to the list. |
| 48 | + * \return The child name where the data was written. |
| 49 | +*/ |
30 | 50 | Stringpush(const String& path,const JsonVariant& value);
|
| 51 | + |
| 52 | +/** |
| 53 | + * Writes the data in value to the node located at path Equivilent to the |
| 54 | + * REST API's PUT. |
| 55 | + * You should check success() after calling. |
| 56 | + * \param path The path inside of your db to the node you wish to update. |
| 57 | + * \param value Data that you wish to write. |
| 58 | +*/ |
31 | 59 | voidset(const String& path,const JsonVariant& value);
|
| 60 | + |
| 61 | + |
| 62 | +/** |
| 63 | + * Gets the value located at path. |
| 64 | + * You should check success() after calling. |
| 65 | + * \param path The path inside of your db of the node you wish to retrieve. |
| 66 | + * \return The data located at that path. This may either be a single element |
| 67 | + * or it may be a json structure. Will only be populated if success() is true. |
| 68 | +*/ |
32 | 69 | FirebaseObjectget(constchar* path);
|
| 70 | + |
| 71 | +/** |
| 72 | + * Remove the variable, and possibly entire tree, located at path. |
| 73 | + * You should check success() after calling. |
| 74 | + * \param path The path inside of your db to the node you wish to remove, |
| 75 | + * including all of its children. |
| 76 | +*/ |
33 | 77 | voidremove(constchar* path);
|
| 78 | + |
| 79 | +/** |
| 80 | + * Starts streaming any changes made to the node located at path, including |
| 81 | + * any of its children. |
| 82 | + * You should check success() after calling. |
| 83 | + * This changes the state of this object. Once this is called you may start |
| 84 | + * monitoring available() and calling readEvent() to get new events. |
| 85 | + * \param path The path inside of your db to the node you wish to monitor. |
| 86 | +*/ |
34 | 87 | voidstream(constchar* path);
|
| 88 | + |
| 89 | +/** |
| 90 | + * Checks if there are new events available. This is only meaningful once |
| 91 | + * stream() has been called. |
| 92 | + * \return If a new event is ready. |
| 93 | +*/ |
35 | 94 | boolavailable();
|
| 95 | + |
| 96 | +/** |
| 97 | + * Reads the next event in a stream. This is only meaningful once stream() has |
| 98 | + * been called. |
| 99 | + * \return Object will have ["type"] that describes the event type, ["path"] |
| 100 | + * that describes the effected path and ["data"] that was updated. |
| 101 | +*/ |
36 | 102 | FirebaseObjectreadEvent();
|
| 103 | + |
| 104 | +/** |
| 105 | + * \return Whether the last command was successful. |
| 106 | +*/ |
37 | 107 | boolsuccess();
|
| 108 | + |
| 109 | +/** |
| 110 | + * \return Whether the last command failed. |
| 111 | +*/ |
38 | 112 | boolfailed();
|
| 113 | + |
| 114 | +/** |
| 115 | + * \return Error message from last command if failed() is true. |
| 116 | +*/ |
39 | 117 | const String&error();
|
40 | 118 | private:
|
41 | 119 | String host_;
|
|