-
-
Notifications
You must be signed in to change notification settings - Fork 104
/
Copy pathFirebase.h
2628 lines (2322 loc) · 119 KB
/
Firebase.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "./core/Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40408)
#error "Mixed versions compilation."
#endif
/**
* The Firebase class, Firebase.h v1.2.8
*
* Created September 13, 2023
*
* The MIT License (MIT)
* Copyright (c) 2023 K. Suwatchai (Mobizt)
*
*
* Permission is hereby granted, free of charge, to any person returning a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef Firebase_H
#define Firebase_H
#include <Arduino.h>
#include "./mbfs/MB_MCU.h"
#include "./FirebaseFS.h"
#include "./FB_Const.h"
#if defined(ESP8266)
#include <SPI.h>
#include <time.h>
#include <vector>
#include <functional>
#include <Schedule.h>
#include <ets_sys.h>
#endif
#include "FB_Utils.h"
#include "client/FB_TCP_Client.h"
#include "core/FirebaseCore.h"
#include "session/FB_Session.h"
#include "FB_Utils.h"
#if defined(DEFAULT_SD_FS) && defined(CARD_TYPE_SD) && defined(ESP32) && defined(SD_FAT_VERSION)
class SdSpiConfig;
#endif
#if defined(ENABLE_RTDB) || defined(FIREBASE_ENABLE_RTDB)
#include "rtdb/FB_RTDB.h"
#endif
#if defined(ENABLE_FCM) || defined(FIREBASE_ENABLE_FCM)
#include "message/FCM.h"
#endif
#if defined(ENABLE_FB_STORAGE) || defined(FIREBASE_ENABLE_FB_STORAGE)
#include "storage/FCS.h"
#endif
#if defined(ENABLE_GC_STORAGE) || defined(FIREBASE_ENABLE_GC_STORAGE)
#include "gcs/GCS.h"
#endif
#if defined(ENABLE_FIRESTORE) || defined(FIREBASE_ENABLE_FIRESTORE)
#include "firestore/FB_Firestore.h"
#endif
#if defined(ENABLE_FB_FUNCTIONS) || defined(FIREBASE_ENABLE_FB_FUNCTIONS)
#include "functions/FB_Functions.h"
#include "functions/FunctionsConfig.h"
#endif
#ifndef FPSTR
#define FPSTR MBSTRING_FLASH_MCR
#endif
class FIREBASE_CLASS
{
friend class QueryFilter;
friend class FirebaseSession;
public:
#if defined(FIREBASE_ESP_CLIENT)
#if defined(ENABLE_RTDB) || defined(FIREBASE_ENABLE_RTDB)
FB_RTDB RTDB;
#endif
#endif
#if defined(ENABLE_FCM) || defined(FIREBASE_ENABLE_FCM)
FB_CM FCM;
#endif
#if defined(ENABLE_FB_STORAGE) || defined(FIREBASE_ENABLE_FB_STORAGE)
FB_Storage Storage;
#endif
#if defined(ENABLE_FIRESTORE) || defined(FIREBASE_ENABLE_FIRESTORE)
FB_Firestore Firestore;
#endif
#if defined(ENABLE_FB_FUNCTIONS) || defined(FIREBASE_ENABLE_FB_FUNCTIONS)
FB_Functions Functions;
#endif
#if defined(ENABLE_GC_STORAGE) || defined(FIREBASE_ENABLE_GC_STORAGE)
GG_CloudStorage GCStorage;
#endif
FIREBASE_CLASS();
~FIREBASE_CLASS();
/** Initialize Firebase with the config and Firebase's authentication credentials.
*
* @param config The pointer to FirebaseConfig data.
* @param auth The pointer to FirebaseAuth data.
*
* @note For FirebaseConfig and FirebaseAuth data usage, see the examples.
*/
void begin(FirebaseConfig *config, FirebaseAuth *auth);
/** Setup the ID token for authentication.
*
* @param config The pointer to FirebaseConfig data.
* @param idToken The ID Token.
* @param expire The expired interval in seeconds (max.3600 sec).
* @param refreshToken The refresh token for token refreshment.
*
* @note For FirebaseConfig and FirebaseAuth data usage, see the examples.
*/
template <typename T1 = const char *, typename T2 = const char *>
void setIdToken(FirebaseConfig *config, T1 idToken, size_t expire = 3600, T2 refreshToken = "")
{
return mSetAuthToken(config, toStringPtr(idToken), expire, toStringPtr(refreshToken),
token_type_id_token, toStringPtr(""), toStringPtr(""));
}
/** Setup the access token for authentication.
*
* @param config The pointer to FirebaseConfig data.
* @param accessToken The access Token.
* @param expire The expired interval in seeconds (max.3600 sec).
* @param refreshToken The refresh token for token refreshment.
* @param clientId The The client identifier issued to the client during the registration process.
* @param clientSecret The client secret.
*
* @note For FirebaseConfig and FirebaseAuth data usage, see the examples.
*/
template <typename T1 = const char *, typename T2 = const char *, typename T3 = const char *, typename T4 = const char *>
void setAccessToken(FirebaseConfig *config, T1 accessToken, size_t expire = 3600, T2 refreshToken = "",
T3 clientId = "", T4 clientSecret = "")
{
return mSetAuthToken(config, toStringPtr(accessToken), expire,
toStringPtr(refreshToken), token_type_oauth2_access_token,
toStringPtr(clientId), toStringPtr(clientSecret));
}
/** Setup the custom token for authentication.
*
* @param config The pointer to FirebaseConfig data.
* @param customToken The Identity Platform custom token.
*
* If the refresh token from Custom token verification or sign in, was assigned here instead of
* custom token (signed JWT token), the token refresh process will be performed immediately.
*
* Any token that is not in the form header.payload.signature i.e., xxxxx.yyyyy.zzzzz will be treated as refresh token.
*
* @note For FirebaseConfig and FirebaseAuth data usage, see the examples.
*/
template <typename T1 = const char *>
void setCustomToken(FirebaseConfig *config, T1 customToken)
{
return mSetAuthToken(config, toStringPtr(customToken), 0, toStringPtr(""),
token_type_custom_token, toStringPtr(""), toStringPtr(""));
}
/** Check for token expiry status.
*
* @return bool of expiry status.
*/
bool isTokenExpired();
/** Force the token to expire immediately and refresh.
*
* @param config The pointer to FirebaseConfig data.
*/
void refreshToken(FirebaseConfig *config);
/** Reset stored config and auth credentials.
*
* @param config The pointer to FirebaseConfig data.
*
*/
void reset(FirebaseConfig *config);
/** Provide the details of token generation.
*
* @return token_info_t The token_info_t structured data that indicates the status.
*
* @note Use type property to get the type enum value.
* token_type_undefined or 0,
* token_type_legacy_token or 1,
* token_type_id_token or 2,
* token_type_custom_token or 3,
* token_type_oauth2_access_token or 4
*
* Use status property to get the status enum value.
* token_status_uninitialized or 0,
* token_status_on_signing or 1,
* token_status_on_request or 2,
* token_status_on_refresh or 3,
* token_status_ready or 4
*
* In case of token generation and refreshment errors,
* use error.code property to get the error code number.
* Use error.message property to get the error message string.
*
*/
struct token_info_t authTokenInfo();
/** Provide the ready status of token generation.
*
* This function should be called repeatedly to handle authentication tasks.
*
* @return Boolean type status indicates the token generation is completed.
*/
bool ready();
/** Provide the grant access status for Firebase Services.
*
* @return Boolean type status indicates the device can access to the services
*
* This returns false if ready() returns false (token generation is not ready).
*/
bool authenticated();
/** Sign up for a new user.
*
* @param config The pointer to FirebaseConfig data.
* @param auth The pointer to FirebaseAuth data.
* @param email The user Email.
* @param password The user password.
* @return Boolean type status indicates the success of the operation.
*
* @note By calling Firebase.begin with config and auth after sign up will be signed in.
*
* This required Email/Password provider to be enabled,
* From Firebase console, select Authentication, select Sign-in method tab,
* under the Sign-in providers list, enable Email/Password provider.
*
* If the assigned email and passowrd are empty,
* the anonymous user will be created if Anonymous provider is enabled.
*
* To enable Anonymous provider,
* from Firebase console, select Authentication, select Sign-in method tab,
* under the Sign-in providers list, enable Anonymous provider.
*/
template <typename T1 = const char *, typename T2 = const char *>
bool signUp(FirebaseConfig *config, FirebaseAuth *auth, T1 email, T2 password)
{
return mSignUp(config, auth, toStringPtr(email), toStringPtr(password));
}
/** Delete user from project.
*
* @param config The pointer to FirebaseConfig data.
* @param auth The pointer to FirebaseAuth data.
* @param idToken (optional) The id token of user, leave blank to delete the current sign in user.
* @return Boolean type status indicates the success of the operation.
*/
template <typename T = const char *>
bool deleteUser(FirebaseConfig *config, FirebaseAuth *auth, T idToken = "")
{
return mDeleteUser(config, auth, toStringPtr(idToken));
}
/** Send a user a verification Email.
*
* @param config The pointer to FirebaseConfig data.
* @param idToken The id token of user that was already signed in with Email and password (optional).
* @return Boolean type status indicates the success of the operation.
*
* @note The id token can be obtained from Firebase.getToken()
* after begin with config and auth data.
*
* If the idToken is not assigned, the internal id_token will be used.
*
* See the Templates of Email address verification in the Firebase console
* , Authentication.
*/
template <typename T = const char *>
bool sendEmailVerification(FirebaseConfig *config, T idToken = "")
{
return msendEmailVerification(config, toStringPtr(idToken));
}
/** Send a user a password reset link to Email.
*
* @param config The pointer to FirebaseConfig data.
* @param email The user Email to send the password resset link.
* @return Boolean type status indicates the success of the operation.
*/
template <typename T = const char *>
bool sendResetPassword(FirebaseConfig *config, T email) { return mSendResetPassword(config, toStringPtr(email)); }
/** Reconnect network if lost connection.
*
* @param reconnect The boolean to set/unset WiFi AP reconnection.
*/
void reconnectNetwork(bool reconnect);
/* Deprecated, use reconnectNetwork instead. */
void reconnectWiFi(bool reconnect);
/** Get currently used auth token string.
*
* @return constant char* of currently used auth token.
*/
const char *getToken();
/** Get refresh token string.
*
* @return constant char* of refresh token.
*/
const char *getRefreshToken();
/** Get free Heap memory.
*
* @return free Heap memory size.
*/
int getFreeHeap();
/** Get current timestamp.
*
* @return current timestamp.
*/
time_t getCurrentTime();
/** Set the decimal places for float value to be stored in database.
*
* @param digits The decimal places.
*/
void setFloatDigits(uint8_t digits);
/** Set the decimal places for double value to be stored in database.
*
* @param digits The decimal places.
*/
void setDoubleDigits(uint8_t digits);
#if defined(FIREBASE_ESP32_CLIENT) || defined(FIREBASE_ESP8266_CLIENT)
#if defined(ENABLE_RTDB) || defined(FIREBASE_ENABLE_RTDB)
/** Set the timeout of Firebase.get functions.
*
* @param fbdo Firebase Data Object to hold data and instance.
* @param millisec The milliseconds to limit the request (0 900,000 ms or 15 min).
*/
void setReadTimeout(FirebaseData &fbdo, int millisec) { RTDB.setReadTimeout(&fbdo, millisec); }
/** Set the size limit of payload data that will write to the database for each request.
*
* @param fbdo Firebase Data Object to hold data and instance.
* @param size The size identified string e.g. tiny, small, medium, large and unlimited.
*
* @note Size string and its write timeout in seconds e.g. tiny (1s), small (10s), medium (30s) and large (60s).
*/
template <typename T = const char *>
void setwriteSizeLimit(FirebaseData &fbdo, T size) { return RTDB.setwriteSizeLimit(&fbdo, size); }
/** Read the database rules.
*
* @param fbdo Firebase Data Object to hold data and instance.
* @return Boolean type status indicates the success of the operation.
*
* @note Call [FirebaseData object].jsonData will return the JSON string value of
* database rules returned from the server.
*/
bool getRules(FirebaseData &fbdo) { return RTDB.getRules(&fbdo); }
/** Save the database rules to file.
*
* @param fbdo The pointer to Firebase Data Object.
* @param storageType Type of storage to read file data, StorageType::FLASH or StorageType::SD.
* @param filename Filename to save rules.
* @param callback Optional. The callback function that accept RTDB_DownloadStatusInfo data.
* @return Boolean value, indicates the success of the operation.
*
*/
template <typename T = const char *>
bool getRules(FirebaseData &fbdo, uint8_t storageType, T filename, RTDB_DownloadProgressCallback callback = NULL)
{
return RTDB.getRules(&fbdo, getMemStorageType(storageType), filename, callback);
}
/** Write the database rules.
*
* @param fbdo Firebase Data Object to hold data and instance.
* @param rules Database rules in JSON String format.
* @return Boolean type status indicates the success of the operation.
*/
template <typename T = const char *>
bool setRules(FirebaseData &fbdo, T rules) { return RTDB.setRules(&fbdo, rules); }
/** Write the database rules from file.
*
* @param fbdo Firebase Data Object to hold data and instance.
* @param storageType Type of storage to read file data, StorageType::FLASH or StorageType::SD.
* @param filename Filename to read the rules from.
* @param callback Optional. The callback function that accept RTDB_UploadStatusInfo data.
* @return Boolean type status indicates the success of the operation.
*/
template <typename T = const char *>
bool setRules(FirebaseData &fbdo, uint8_t storageType, T filename, RTDB_UploadProgressCallback callback = NULL)
{
return RTDB.setRules(&fbdo, getMemStorageType(storageType), filename, callback);
}
/** Set the .read and .write database rules.
*
* @param fbdo The pointer to Firebase Data Object.
* @param path The parent path of child's node that the .read and .write rules are being set.
* @param var The child node key that the .read and .write rules are being set.
* @param readVal The child node key .read value.
* @param writeVal The child node key .write value.
* @param databaseSecret The database secret.
* @return Boolean value, indicates the success of the operation.
*
* @note The databaseSecret can be empty if the auth type is OAuth2.0 or legacy and required if auth type
* is Email/Password sign-in.
*/
template <typename T1 = const char *, typename T2 = const char *, typename T3 = const char *, typename T4 = const char *, typename T5 = const char *>
bool setReadWriteRules(FirebaseData &fbdo, T1 path, T2 var, T3 readVal, T4 writeVal, T5 databaseSecret)
{
return RTDB.setReadWriteRules(&fbdo, path, var, readVal, writeVal, databaseSecret);
}
/** Set the query index to the database rules.
*
* @param fbdo The pointer to Firebase Data Object.
* @param path The parent path of child's node that is being queried.
* @param node The child node key that is being queried.
* @param databaseSecret The database secret.
* @return Boolean value, indicates the success of the operation.
*
* @note The databaseSecret can be empty if the auth type is OAuth2.0 or legacy and required if auth type
* is Email/Password sign-in.
*/
template <typename T1 = const char *, typename T2 = const char *, typename T3 = const char *>
bool setQueryIndex(FirebaseData &fbdo, T1 path, T2 node, T3 databaseSecret)
{
return RTDB.setQueryIndex(&fbdo, path, node, databaseSecret);
}
/** Remove the query index from the database rules.
*
* @param fbdo The pointer to Firebase Data Object.
* @param path The parent path of child's node that the index is being removed.
* @param databaseSecret The database secret.
* @return Boolean value, indicates the success of the operation.
*
* @note The databaseSecret can be empty if the auth type is OAuth2.0 or legacy and required if auth type
* is Email/Password sign-in.
*/
template <typename T1 = const char *, typename T2 = const char *>
bool removeQueryIndex(FirebaseData &fbdo, T1 path, T2 databaseSecret)
{
return RTDB.removeQueryIndex(&fbdo, path, databaseSecret);
}
/** Determine whether the defined database path exists or not.
*
* @param fbdo Firebase Data Object to hold data and instance.
* @param path Database path to be checked.
* @return Boolean type result indicates whether the defined path existed or not.
*/
template <typename T = const char *>
bool pathExisted(FirebaseData &fbdo, T path) { return RTDB.pathExisted(&fbdo, path); }
/** Deprecated */
template <typename T = const char *>
bool pathExist(FirebaseData &fbdo, T path) { return RTDB.pathExisted(&fbdo, path); }
/** Determine the unique identifier (ETag) of current data at the defined database path.
*
* @return String of unique identifier.
*/
template <typename T = const char *>
String getETag(FirebaseData &fbdo, T path) { return RTDB.getETag(&fbdo, path); }
/** Get the shallowed data at a defined node path.
*
* @param fbdo Firebase Data Object to hold data and instance.
* @param path Database path that is being read the data.
* @return Boolean type status indicates the success of the operation.
*
* @note Return the child data with its value or JSON object (its values will be truncated to true).
* The data can be read from FirebaseData object.
*/
template <typename T = const char *>
bool getShallowData(FirebaseData &fbdo, T path) { return RTDB.getShallowData(&fbdo, path); }
/** Enable the library to use only classic HTTP GET and POST methods.
*
* @param fbdo Firebase Data Object to hold data and instance.
* @param flag Boolean value to enable.
*
* @note This option used to escape the Firewall restriction (if the device is connected through
* Firewall) that allows only HTTP GET and POST
* HTTP PATCH request was sent as PATCH which not affected by this option.
*/
void enableClassicRequest(FirebaseData &fbdo, bool flag) { RTDB.enableClassicRequest(&fbdo, flag); }
/** Set the virtual child node ".priority" to the defined database path.
*
* @param fbdo Firebase Data Object to hold data and instance.
* @param path Target database path which to set the priority value.
* @param priority The priority value.
* @return Boolean type status indicates the success of the operation.
*
* @note This allows us to set priority to any node other than a priority that set through setJSON,
* pushJSON, updateNode, and updateNodeSilent functions.
* The returned priority value from server can read from function [FirebaseData object].priority().
*/
template <typename T = const char *>
bool setPriority(FirebaseData &fbdo, T path, float priority) { return RTDB.setPriority(&fbdo, path, priority); }
template <typename T = const char *>
bool setPriorityAsync(FirebaseData &fbdo, T path, float &priority) { return RTDB.setPriorityAsync(&fbdo, path, priority); }
/** Read the virtual child node ".priority" value at the defined database path.
*
* @param fbdo Firebase Data Object to hold data and instance.
* @param path Target database path which to set the priority value.
* @return Boolean type status indicates the success of the operation.
*
* @note The priority value from server can read from function [FirebaseData object].priority().
*/
template <typename T = const char *>
bool getPriority(FirebaseData &fbdo, T path) { return RTDB.getPriority(&fbdo, path); }
/** Append new integer value to the defined database path.
*
* @param fbdo Firebase Data Object to hold data and instance.
* @param path Target database path which integer value will be appended.
* @param value The appended value.
* @return Boolean type status indicates the success of the operation.
*
* @note The new appended node's key will be stored in Firebase Data object,
* which its value can be accessed via function [FirebaseData object].pushName().
*/
template <typename T1 = const char *, typename T2 = int>
bool pushInt(FirebaseData &fbdo, T1 path, T2 value) { return RTDB.pushInt(&fbdo, path, value); }
template <typename T1 = const char *, typename T2 = int>
bool pushIntAsync(FirebaseData &fbdo, T1 path, T2 value) { return RTDB.pushIntAsync(&fbdo, path, value); }
/** Append new integer value and the virtual child ".priority" to the defined database path.
*/
template <typename T1 = const char *, typename T2 = int>
bool pushInt(FirebaseData &fbdo, T1 path, T2 value, float priority) { return RTDB.pushInt(&fbdo, path, value, priority); }
template <typename T1 = const char *, typename T2 = int>
bool pushIntAsync(FirebaseData &fbdo, T1 path, T2 value, float priority)
{
return RTDB.pushIntAsync(&fbdo, path, value, priority);
}
/** Append new float value to the defined database path.
*
* @param fbdo Firebase Data Object to hold data and instance.
* @param path Target database path in which float value will be appended.
* @param value The appended value.
* @return Boolean type status indicates the success of the operation.
*
* @note The new appended node's key will be stored in Firebase Data object,
* which its value can be accessed via function [FirebaseData object].pushName().
*/
template <typename T = const char *>
bool pushFloat(FirebaseData &fbdo, T path, float value) { return RTDB.pushFloat(&fbdo, path, value); }
template <typename T = const char *>
bool pushFloatAsync(FirebaseData &fbdo, T path, float value) { return RTDB.pushFloatAsync(&fbdo, path, value); }
/** Append new float value and the virtual child ".priority" to the defined database path.
*/
template <typename T = const char *>
bool pushFloat(FirebaseData &fbdo, T path, float value, float priority)
{
return RTDB.pushFloat(&fbdo, path, value, priority);
}
template <typename T = const char *>
bool pushFloatAsync(FirebaseData &fbdo, T path, float value, float priority)
{
return RTDB.pushFloat(&fbdo, path, value, priority);
}
/** Append new double value (8 bytes) to the defined database path.
*
* @param fbdo Firebase Data Object to hold data and instance.
* @param path Target database path in which float value will be appended.
* @param value The appended value.
* @return Boolean type status indicates the success of the operation.
*
* @note The new appended node's key will be stored in Firebase Data object,
* which its value can be accessed via function [FirebaseData object].pushName().
*/
template <typename T = const char *>
bool pushDouble(FirebaseData &fbdo, T path, double value) { return RTDB.pushDouble(&fbdo, path, value); }
template <typename T = const char *>
bool pushDoubleAsync(FirebaseData &fbdo, T path, double value) { return RTDB.pushDoubleAsync(&fbdo, path, value); }
/** Append new double value (8 bytes) and the virtual child ".priority" to the defined database path.
*/
template <typename T = const char *>
bool pushDouble(FirebaseData &fbdo, T path, double value, float priority)
{
return RTDB.pushDouble(&fbdo, path, value, priority);
}
template <typename T = const char *>
bool pushDoubleAsync(FirebaseData &fbdo, T path, double value, float priority)
{
return RTDB.pushDoubleAsync(&fbdo, path, value, priority);
}
/** Append new Boolean value to the defined database path.
*
* @param fbdo Firebase Data Object to hold data and instance.
* @param path Target database path which Boolean value will be appended.
* @param value The appended value.
* @return Boolean type status indicates the success of the operation.
*
* @note The new appended node's key will be stored in Firebase Data object,
* which its value can be accessed via function [FirebaseData object].pushName().
*/
template <typename T = const char *>
bool pushBool(FirebaseData &fbdo, T path, bool value) { return RTDB.pushBool(&fbdo, path, value); }
template <typename T = const char *>
bool pushBoolAsync(FirebaseData &fbdo, T path, bool value) { return RTDB.pushBoolAsync(&fbdo, path, value); }
/** Append the new Boolean value and the virtual child ".priority" to the defined database path.
*/
template <typename T = const char *>
bool pushBool(FirebaseData &fbdo, T path, bool value, float priority)
{
return RTDB.pushBool(&fbdo, path, value, priority);
}
template <typename T = const char *>
bool pushBoolAsync(FirebaseData &fbdo, T path, bool value, float priority)
{
return RTDB.pushBoolAsync(&fbdo, path, value, priority);
}
/** Append a new string (text) to the defined database path.
*
* @param fbdo Firebase Data Object to hold data and instance.
* @param path Target database path which string will be appended.
* @param value The appended value.
* @return Boolean type status indicates the success of the operation.
*
* @note The new appended node's key stored in Firebase Data object,
* which can be accessed via function [FirebaseData object].pushName().
*/
template <typename T1 = const char *, typename T2 = const char *>
bool pushString(FirebaseData &fbdo, T1 path, T2 value) { return RTDB.pushString(&fbdo, path, value); }
template <typename T1 = const char *, typename T2 = const char *>
bool pushStringAsync(FirebaseData &fbdo, T1 path, const T2 value) { return RTDB.pushStringAsync(&fbdo, path, value); }
/** Append new string (text) and the virtual child ".priority" to the defined database path.
*/
template <typename T1 = const char *, typename T2 = const char *>
bool pushString(FirebaseData &fbdo, T1 path, T2 value, float priority)
{
return RTDB.pushString(&fbdo, path, value, priority);
}
template <typename T1 = const char *, typename T2 = const char *>
bool pushStringAsync(FirebaseData &fbdo, T1 path, T2 value, float priority)
{
return RTDB.pushStringAsync(&fbdo, path, value, priority);
}
/** Append new child nodes key and value (using FirebaseJson object) to the defined database path.
*
* @param fbdo Firebase Data Object to hold data and instance.
* @param path Target database path which key and value in FirebaseJson object will be appended.
* @param json The appended FirebaseJson object.
* @return Boolean type status indicates the success of the operation.
*
* @note The new appended node key will be stored in Firebase Data object,
* which its value can be accessed via function [FirebaseData object].pushName().
*/
template <typename T = const char *>
bool pushJSON(FirebaseData &fbdo, T path, FirebaseJson &json) { return RTDB.pushJSON(&fbdo, path, &json); }
template <typename T = const char *>
bool pushJSONAsync(FirebaseData &fbdo, T path, FirebaseJson &json)
{
return RTDB.pushJSONAsync(&fbdo, path, &json);
}
/** Append new child node key and value (FirebaseJson object) and the virtual child ".priority" to the defined database path.
*/
template <typename T = const char *>
bool pushJSON(FirebaseData &fbdo, T path, FirebaseJson &json, float priority)
{
return RTDB.pushJSON(&fbdo, path, &json, priority);
}
template <typename T = const char *>
bool pushJSONAsync(FirebaseData &fbdo, T path, FirebaseJson &json, float priority)
{
return RTDB.pushJSONAsync(&fbdo, path, &json, priority);
}
/** Append child node array (using FirebaseJsonArray object) to the defined database path.
* This will replace any child nodes inside the defined path with array defined in FirebaseJsonArray object.
*
* @param fbdo Firebase Data Object to hold data and instance.
* @param path Target database path which key and value in FirebaseJsonArray object will be appended.
* @param arr The appended FirebaseJsonArray object.
* @return Boolean type status indicates the success of the operation.
*
* @note The new appended node's key will be stored in Firebase Data object,
* which its value can be accessed via function [FirebaseData object].pushName().
*/
template <typename T = const char *>
bool pushArray(FirebaseData &fbdo, T path, FirebaseJsonArray &arr) { return RTDB.pushArray(&fbdo, path, &arr); }
template <typename T = const char *>
bool pushArrayAsync(FirebaseData &fbdo, T path, FirebaseJsonArray &arr) { return RTDB.pushArrayAsync(&fbdo, path, &arr); }
/** Append FirebaseJsonArray object and virtual child ".priority" at the defined database path.
*/
template <typename T = const char *>
bool pushArray(FirebaseData &fbdo, T path, FirebaseJsonArray &arr, float priority)
{
return RTDB.pushArray(&fbdo, path, &arr, priority);
}
template <typename T = const char *>
bool pushArrayAsync(FirebaseData &fbdo, T path, FirebaseJsonArray &arr, float priority)
{
return RTDB.pushArrayAsync(&fbdo, path, &arr, priority);
}
/** Append new blob (binary data) to the defined database path.
*
* @param fbdo Firebase Data Object to hold data and instance.
* @param path Target database path which binary data will be appended.
* @param blob Byte array of data.
* @param size Size of the byte array.
* @return Boolean type status indicates the success of the operation.
*
* @note The new appended node's key will be stored in Firebase Data object,
* which its value can be accessed via function [FirebaseData object].pushName().
*/
template <typename T = const char *>
bool pushBlob(FirebaseData &fbdo, T path, uint8_t *blob, size_t size) { return RTDB.pushBlob(&fbdo, path, blob, size); }
template <typename T = const char *>
bool pushBlobAsync(FirebaseData &fbdo, T path, uint8_t *blob, size_t size)
{
return RTDB.pushBlobAsync(&fbdo, path, blob, size);
}
/** Append new binary data from the file stores on SD card/Flash memory to the defined database path.
*
* @param fbdo Firebase Data Object to hold data and instance.
* @param storageType Type of storage to read file data, StorageType::FLASH or StorageType::SD.
* @param path Target database path in which binary data from the file will be appended.
* @param fileName File name included its path in SD card/Flash memory.
* @param callback Optional. The callback function that accept RTDB_UploadStatusInfo data.
* @return Boolean type status indicates the success of the operation.
*
* @note The new appended node's key will be stored in Firebase Data object,
* which its value can be accessed via function [FirebaseData object].pushName().
*
* The file systems for flash and sd memory can be changed in FirebaseFS.h.
*/
template <typename T1 = const char *, typename T2 = const char *>
bool pushFile(FirebaseData &fbdo, uint8_t storageType, T1 path, T2 fileName, RTDB_UploadProgressCallback callback = NULL)
{
return RTDB.pushFile(&fbdo, getMemStorageType(storageType), path, fileName, callback);
}
template <typename T1 = const char *, typename T2 = const char *>
bool pushFileAsync(FirebaseData &fbdo, uint8_t storageType, T1 path, T2 fileName, RTDB_UploadProgressCallback callback = NULL)
{
return RTDB.pushFileAsync(&fbdo, getMemStorageType(storageType), path, fileName, callback);
}
/** Append the new Firebase server's timestamp to the defined database path.*
*
* @param fbdo Firebase Data Object to hold data and instance.
* @param path Target database path which timestamp will be appended.
* @return Boolean type status indicates the success of the operation.
*
* @note The new appended node's key will be stored in Firebase Data object,
* which its value can be accessed via function [FirebaseData object].pushName().
*/
template <typename T = const char *>
bool pushTimestamp(FirebaseData &fbdo, T path) { return RTDB.pushTimestamp(&fbdo, path); }
template <typename T = const char *>
bool pushTimestampAsync(FirebaseData &fbdo, T path) { return RTDB.pushTimestampAsync(&fbdo, path); }
/** Set integer data at the defined database path.
*
* @param fbdo Firebase Data Object to hold data and instance.
* @param path Target database path which integer data will be set.
* @param value Integer value to set.
* @return Boolean type status indicates the success of the operation.
*
* @note Call [FirebaseData object].dataType to determine what type of data that successfully stores in the database.
* Call [FirebaseData object].intData will return the integer value of
* payload returned from server.
*/
template <typename T1 = const char *, typename T2 = int>
bool setInt(FirebaseData &fbdo, T1 path, T2 value) { return RTDB.setInt(&fbdo, path, value); }
template <typename T1 = const char *, typename T2 = int>
bool setIntAsync(FirebaseData &fbdo, T1 path, T2 value) { return RTDB.setIntAsync(&fbdo, path, value); }
/** Set integer data and virtual child ".priority" at the defined database path.
*/
template <typename T1 = const char *, typename T2 = int>
bool setInt(FirebaseData &fbdo, T1 path, T2 value, float priority) { return RTDB.setInt(&fbdo, path, value, priority); }
template <typename T1 = const char *, typename T2 = int>
bool setIntAsync(FirebaseData &fbdo, T1 path, T2 value, float priority)
{
return RTDB.setIntAsync(&fbdo, path, value, priority);
}
/** Set integer data at the defined database path if defined database path's ETag matched the ETag value.
*
* @param fbdo Firebase Data Object to hold data and instance.
* @param path Target database path which integer data will be set.
* @param value Integer value to set.
* @param ETag Known unique identifier string (ETag) of defined database path.
* @return Boolean type status indicates the success of the operation.
*
* @note Call [FirebaseData object].dataType to determine what type of data successfully stores in the database.
* If ETag at the defined database path does not match the provided ETag parameter,
* the operation will fail with HTTP code 412, Precondition Failed (ETag is not matched).
*
* If the operation failed due to ETag is not match, call [FirebaseData object].ETag() to get the current ETag value.
* Also call [FirebaseData object].intData to get the current integer value.
*/
template <typename T1 = const char *, typename T2 = int, typename T3 = const char *>
bool setInt(FirebaseData &fbdo, T1 path, T2 value, T3 ETag) { return RTDB.setInt(&fbdo, path, value, ETag); }
template <typename T1 = const char *, typename T2 = int, typename T3 = const char *>
bool setIntAsync(FirebaseData &fbdo, T1 path, T2 value, T3 ETag) { return RTDB.setIntAsync(&fbdo, path, value, ETag); }
/** Set integer data and the virtual child ".priority" if defined ETag matches at the defined database path
*/
template <typename T1 = const char *, typename T2 = int, typename T3 = const char *>
bool setInt(FirebaseData &fbdo, T1 path, T2 value, float priority, T3 ETag)
{
return RTDB.setInt(&fbdo, path, value, priority, ETag);
}
template <typename T1 = const char *, typename T2 = int, typename T3 = const char *>
bool setIntAsync(FirebaseData &fbdo, T1 path, T2 value, float priority, T3 ETag)
{
return RTDB.setIntAsync(&fbdo, path, value, priority, ETag);
}
/** Set float data at the defined database path.
*
* @param fbdo Firebase Data Object to hold data and instance.
* @param path Target database path in which float data will be set.
* @param value Float value to set.
* @return Boolean type status indicates the success of the operation.
*
* @note Call [FirebaseData object].dataType to determine what type of data successfully stores in the database.
* Call [FirebaseData object].floatData will return the float value of
* payload returned from server.
*/
template <typename T = const char *>
bool setFloat(FirebaseData &fbdo, T path, float value) { return RTDB.setFloat(&fbdo, path, value); }
template <typename T = const char *>
bool setFloatAsync(FirebaseData &fbdo, T path, float value) { return RTDB.setFloatAsync(&fbdo, path, value); }
/** Set float data and virtual child ".priority" at the defined database path.
*/
template <typename T = const char *>
bool setFloat(FirebaseData &fbdo, T path, float value, float priority)
{
return RTDB.setFloat(&fbdo, path, value, priority);
}
template <typename T = const char *>
bool setFloatAsync(FirebaseData &fbdo, T path, float value, float priority)
{
return RTDB.setFloatAsync(&fbdo, path, value, priority);
}
/** Set float data at the defined database path if defined database path's ETag matched the ETag value.
*
* @param fbdo Firebase Data Object to hold data and instance.
* @param path Target database path in which float data will be set.
* @param value Float value to set.
* @param ETag Known unique identifier string (ETag) of defined database path.
* @return Boolean type status indicates the success of the operation.
*
* @note Call [FirebaseData object].dataType to determine what type of data successfully stores in the database.
* Call [FirebaseData object].floatData will return the float value of payload returned from server.
*
* If ETag at the defined database path does not match the provided ETag parameter,
* the operation will fail with HTTP code 412, Precondition Failed (ETag is not matched).
*
* If the operation failed due to ETag is not match, call [FirebaseData object].ETag() to get the current ETag value.
* Also call [FirebaseData object].floatData to get the current float value.
*/
template <typename T1 = const char *, typename T2 = const char *>
bool setFloat(FirebaseData &fbdo, T1 path, float value, T2 ETag) { return RTDB.setFloat(&fbdo, path, value, ETag); }
template <typename T1 = const char *, typename T2 = const char *>
bool setFloatAsync(FirebaseData &fbdo, T1 path, float value, T2 ETag)
{
return RTDB.setFloatAsync(&fbdo, path, value, ETag);
}
/** Set float data and the virtual child ".priority" if defined ETag matches at the defined database path
*/
template <typename T1 = const char *, typename T2 = const char *>
bool setFloat(FirebaseData &fbdo, T1 path, float value, float priority, T2 ETag)
{
return RTDB.setFloat(&fbdo, path, value, priority, ETag);
}
template <typename T1 = const char *, typename T2 = const char *>
bool setFloatAsync(FirebaseData &fbdo, T1 path, float value, float priority, T2 ETag)
{
return RTDB.setFloatAsync(&fbdo, path, value, priority, ETag);
}
/** Set double data at the defined database path.
*
* @param fbdo Firebase Data Object to hold data and instance.
* @param path Target database path in which float data will be set.
* @param value Double value to set.
* @return Boolean type status indicates the success of the operation.
*
* @note Call [FirebaseData object].dataType to determine what type of data successfully stores in the database.
* Call [FirebaseData object].doubleData will return the double value of the payload returned from the server.
*
* Due to bugs in Serial.print in Arduino, to print large double value with zero decimal place,
* use printf("%.9lf\n", firebaseData.doubleData()); for print the returned double value up to 9 decimal places.
*/
template <typename T = const char *>
bool setDouble(FirebaseData &fbdo, T path, double value) { return RTDB.setDouble(&fbdo, path, value); }
template <typename T = const char *>
bool setDoubleAsync(FirebaseData &fbdo, T path, double value) { return RTDB.setDoubleAsync(&fbdo, path, value); }
/** Set double data and virtual child ".priority" at the defined database path.
*/
template <typename T = const char *>
bool setDouble(FirebaseData &fbdo, T path, double value, float priority)
{
return RTDB.setDouble(&fbdo, path, value, priority);
}
template <typename T = const char *>
bool setDoubleAsync(FirebaseData &fbdo, T path, double value, float priority)
{
return RTDB.setDoubleAsync(&fbdo, path, value, priority);
}
/** Set double data at the defined database path if defined database path's ETag matched the ETag value.
*
* @param fbdo Firebase Data Object to hold data and instance.
* @param path Target database path in which float data will be set.
* @param value Double value to set.