forked from mobizt/Firebase-ESP-Client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFirebaseFS.h
186 lines (145 loc) · 5.1 KB
/
FirebaseFS.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
#include "Firebase_Client_Version.h"
#if !FIREBASE_CLIENT_VERSION_CHECK(40310)
#error "Mixed versions compilation."
#endif
#ifndef FirebaseFS_H
#define FirebaseFS_H
#include <Arduino.h>
#include "mbfs/MB_MCU.h"
#define FIREBASE_ESP_CLIENT 1
#define FB_DEFAULT_DEBUG_PORT Serial
/**
* To use other flash file systems
*
* LittleFS File system
*
* #include <LittleFS.h>
* #define DEFAULT_FLASH_FS LittleFS //For ESP8266 or RPI2040 LitteFS
*
*
* FAT File system
*
* #include <FFat.h>
* #define DEFAULT_FLASH_FS FFat //For ESP32 FAT
*
*/
#if defined(ESP32)
#include <SPIFFS.h>
#endif
#if defined(ESP32) || defined(ESP8266)
#define DEFAULT_FLASH_FS SPIFFS
#elif defined(ARDUINO_ARCH_RP2040) && !defined(ARDUINO_NANO_RP2040_CONNECT)
#include <LittleFS.h>
#define DEFAULT_FLASH_FS LittleFS
#endif
/**
* To use SD card file systems with different hardware interface
* e.g. SDMMC hardware bus on the ESP32
* https://github.com/espressif/arduino-esp32/tree/master/libraries/SD#faq
*
#include <SD_MMC.h>
#define DEFAULT_SD_FS SD_MMC //For ESP32 SDMMC
#define CARD_TYPE_SD_MMC 1 //For ESP32 SDMMC
*
*/
/**
* To use SdFat on ESP32
#if defined(ESP32)
#include <SdFat.h> // https://github.com/greiman/SdFat
static SdFat sd_fat_fs; // should declare as static here
#define DEFAULT_SD_FS sd_fat_fs
#define CARD_TYPE_SD 1
#define SD_FS_FILE SdFile
#endif
* The SdFat (https://github.com/greiman/SdFat) is already implemented as wrapper class in ESP8266 and RP2040 core libraries.
* Do not include SdFat.h library in ESP8266 and RP2040 target codes which it conflicts with the wrapper one.
*/
#if defined(ESP32) || defined(ESP8266)
#include <SD.h>
#define DEFAULT_SD_FS SD
#define CARD_TYPE_SD 1
#elif defined(ARDUINO_ARCH_RP2040) && !defined(ARDUINO_NANO_RP2040_CONNECT)
// Use SDFS (ESP8266SdFat) instead of SD
#include <SDFS.h>
#define DEFAULT_SD_FS SDFS
#define CARD_TYPE_SD 1
#endif
// For RTDB legacy token usage only
// #define USE_LEGACY_TOKEN_ONLY
// Enable the error string from fbdo.errorReason */
// You can get the error code from fbdo.errorCode() when disable this option
#define ENABLE_ERROR_STRING
// For ESP32, format SPIFFS or FFat if mounting failed
#define FORMAT_FLASH_IF_MOUNT_FAILED 1
// Comment to exclude the Firebase Realtime Database
#define ENABLE_RTDB
#define ENABLE_ERROR_QUEUE
// Comment to exclude Cloud Firestore
#define ENABLE_FIRESTORE
// Comment to exclude Firebase Cloud Messaging
#define ENABLE_FCM
// Comment to exclude Firebase Storage
#define ENABLE_FB_STORAGE
// Comment to exclude Cloud Storage
#define ENABLE_GC_STORAGE
// Comment to exclude Cloud Function for Firebase
#define ENABLE_FB_FUNCTIONS
/** Use PSRAM for supported ESP32/ESP8266 module */
#if defined(ESP32) || defined(ESP8266)
#define FIREBASE_USE_PSRAM
#endif
// To enable OTA updates via RTDB, Firebase Storage and Google Cloud Storage buckets
#define ENABLE_OTA_FIRMWARE_UPDATE
// Use Keep Alive connection mode
#define USE_CONNECTION_KEEP_ALIVE_MODE
// To enable external Client for ESP8266, ESP32 and Raspberry Pi Pico.
// This will enable automatically for other devices.
// #define FB_ENABLE_EXTERNAL_CLIENT
// For ESP8266 ENC28J60 Ethernet module
// #define ENABLE_ESP8266_ENC28J60_ETH
// For ESP8266 W5100 Ethernet module
// #define ENABLE_ESP8266_W5100_ETH
// For ESP8266 W5500 Ethernet module
// #define ENABLE_ESP8266_W5500_ETH
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::://
// You can create your own header file "CustomFirebaseFS.h" in the same diectory of
// "FirebaseFS.h" and put your own custom config to overwrite or
// change the default config in "FirebaseFS.h".
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::://
/** This is an example of "CustomFirebaseFS.h"
#pragma once
#ifndef CustomFirebaseFS_H
#define CustomFirebaseFS_H
// Use external client instead of internal client
#define FB_ENABLE_EXTERNAL_CLIENT // define to use external client
// Use LittleFS instead of SPIFFS
#include "LittleFS.h"
#undef DEFAULT_FLASH_FS // remove Flash FS defined macro
#define DEFAULT_FLASH_FS LittleFS
// Use SD_MMC instead of SD
#if defined(ESP32)
#include <SD_MMC.h>
#undef DEFAULT_SD_FS // remove SD defined macro
#undef CARD_TYPE_SD // remove SD defined macro
#define DEFAULT_SD_FS SD_MMC
#define CARD_TYPE_SD_MMC 1
#endif
// Disable Error Queue, Firestore, FCM, Firebase Storage, Google Cloud Storage
// and Functions for Firebase.
#undef ENABLE_ERROR_QUEUE
#undef ENABLE_FIRESTORE
#undef ENABLE_FCM
#undef ENABLE_FB_STORAGE
#undef ENABLE_GC_STORAGE
#undef ENABLE_FB_FUNCTIONS
#endif
*/
#if __has_include("CustomFirebaseFS.h")
#include "CustomFirebaseFS.h"
#endif
#endif
/////////////////////////////////// WARNING ///////////////////////////////////
// Using RP2040 Pico Arduino SDK, FreeRTOS with LittleFS will cause device hangs
// when write the data to flash filesystem.
// Do not include free rtos dot h or even it excluded from compilation by using macro
// or even comment it out with "//"".