Skip to content

Commit

Permalink
Update BlobConfig and FileConfig classes
Browse files Browse the repository at this point in the history
  • Loading branch information
mobizt committed Jul 11, 2024
1 parent bcc16fb commit 68812ed
Show file tree
Hide file tree
Showing 23 changed files with 115 additions and 51 deletions.
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/mobizt/FirebaseClient/.github%2Fworkflows%2Fcompile_library.yml?logo=github&label=compile) [![Github Stars](https://img.shields.io/github/stars/mobizt/FirebaseClient?logo=github)](https://github.com/mobizt/FirebaseClient/stargazers) ![Github Issues](https://img.shields.io/github/issues/mobizt/FirebaseClient?logo=github)

![GitHub Release](https://img.shields.io/github/v/release/mobizt/FirebaseClient) ![Arduino](https://img.shields.io/badge/Arduino-v1.3.4-57C207?logo=arduino) ![PlatformIO](https://badges.registry.platformio.org/packages/mobizt/library/FirebaseClient.svg) ![GitHub Release Date](https://img.shields.io/github/release-date/mobizt/FirebaseClient)
![GitHub Release](https://img.shields.io/github/v/release/mobizt/FirebaseClient) ![Arduino](https://img.shields.io/badge/Arduino-v1.3.5-57C207?logo=arduino) ![PlatformIO](https://badges.registry.platformio.org/packages/mobizt/library/FirebaseClient.svg) ![GitHub Release Date](https://img.shields.io/github/release-date/mobizt/FirebaseClient)

[![GitHub Sponsors](https://img.shields.io/github/sponsors/mobizt?logo=github)](https://github.com/sponsors/mobizt)

Revision `2024-07-06T17:01:03Z`
Revision `2024-07-11T01:22:56Z`

## Table of Contents

Expand Down Expand Up @@ -1215,6 +1215,12 @@ The `FileConfig` class parameters are included the following.
```cpp
FileConfig::FileConfig(<filename>, <file_callback>)
void FileConfig::setFile(<filename>, <file_callback>)
FileConfig &FileConfig::setFilename(<filename>)
FileConfig &FileConfig::setCallback(<file_callback>)
```

`<filename>` The full file name included its path.
Expand Down Expand Up @@ -1290,10 +1296,12 @@ void download()
The blob config class ([BlobConfig](examples/RealtimeDatabase/Async/Callback/BLOB/)) provides the in/out data for upload and download functions.
The `BlobConfig` class constructor parameters class parameters are included the following.
The `BlobConfig` class constructor and function parameters are included the following.
```cpp
BlobConfig::BlobConfig(<blob>, <blob_size>)
void BlobConfig::setBlob(<blob>, <blob_size>);
```

`<blob>` The BLOB data (byte array).
Expand Down
2 changes: 1 addition & 1 deletion examples/CloudStorage/Async/Callback/Download/Download.ino
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ void printResult(AsyncResult &aResult);
#if defined(ENABLE_FS)

void fileCallback(File &file, const char *filename, file_operating_mode mode);
FileConfig media_file("/media.mp4", fileCallback);
FileConfig media_file("/media.mp4", fileCallback); // Can be set later with media_file.setFile("/media.mp4", fileCallback);

#endif

Expand Down
2 changes: 1 addition & 1 deletion examples/CloudStorage/Async/Callback/Upload/Upload.ino
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void printResult(AsyncResult &aResult);

void fileCallback(File &file, const char *filename, file_operating_mode mode);

FileConfig media_file("/media.mp4", fileCallback);
FileConfig media_file("/media.mp4", fileCallback); // Can be set later with media_file.setFile("/media.mp4", fileCallback);

#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ void printResult(AsyncResult &aResult);
#if defined(ENABLE_FS)

void fileCallback(File &file, const char *filename, file_operating_mode mode);
FileConfig media_file("/media.mp4", fileCallback);
FileConfig media_file("/media.mp4", fileCallback); // Can be set later with media_file.setFile("/media.mp4", fileCallback);

#endif

Expand Down
2 changes: 1 addition & 1 deletion examples/CloudStorage/Async/NoCallback/Upload/Upload.ino
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void printResult(AsyncResult &aResult);

void fileCallback(File &file, const char *filename, file_operating_mode mode);

FileConfig media_file("/media.mp4", fileCallback);
FileConfig media_file("/media.mp4", fileCallback); // Can be set later with media_file.setFile("/media.mp4", fileCallback);

#endif

Expand Down
2 changes: 1 addition & 1 deletion examples/CloudStorage/Sync/Download/Download.ino
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void printError(int code, const String &msg);
#if defined(ENABLE_FS)

void fileCallback(File &file, const char *filename, file_operating_mode mode);
FileConfig media_file("/media.mp4", fileCallback);
FileConfig media_file("/media.mp4", fileCallback); // Can be set later with media_file.setFile("/media.mp4", fileCallback);

#endif

Expand Down
2 changes: 1 addition & 1 deletion examples/CloudStorage/Sync/Upload/Upload.ino
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ void printError(int code, const String &msg);

void fileCallback(File &file, const char *filename, file_operating_mode mode);

FileConfig media_file("/media.mp4", fileCallback);
FileConfig media_file("/media.mp4", fileCallback); // Can be set later with media_file.setFile("/media.mp4", fileCallback);

#endif

Expand Down
4 changes: 2 additions & 2 deletions examples/RealtimeDatabase/Async/Callback/BLOB/BLOB.ino
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ RealtimeDatabase Database;
uint8_t source[2048];
uint8_t dest[2048];

BlobConfig upload_data(source, 2048);
BlobConfig download_data(dest, 2048);
BlobConfig upload_data(source, 2048); // Can be set later with upload_data.setBlob(source, 2048);
BlobConfig download_data(dest, 2048); // Can be set later with download_data.setBlob(dest, 2048);

bool taskComplete = false;

Expand Down
4 changes: 2 additions & 2 deletions examples/RealtimeDatabase/Async/Callback/File/File.ino
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ AsyncClient aClient(ssl_client, getNetwork(network));
RealtimeDatabase Database;

#if defined(ENABLE_FS)
FileConfig upload_data("/upload.bin", fileCallback);
FileConfig upload_data("/upload.bin", fileCallback); // Can be set later with upload_data.setFile("/upload.bin", fileCallback);

FileConfig download_data("/download.bin", fileCallback);
FileConfig download_data("/download.bin", fileCallback); // Can be set later with download_data.setFile("/download.bin", fileCallback);
#endif

bool taskComplete = false;
Expand Down
4 changes: 2 additions & 2 deletions examples/RealtimeDatabase/Async/NoCallback/BLOB/BLOB.ino
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ AsyncResult aResult_no_callback;
uint8_t source[2048];
uint8_t dest[2048];

BlobConfig upload_data(source, 2048);
BlobConfig download_data(dest, 2048);
BlobConfig upload_data(source, 2048); // Can be set later with upload_data.setBlob(source, 2048);
BlobConfig download_data(dest, 2048); // Can be set later with download_data.setBlob(dest, 2048);

bool taskComplete = false;

Expand Down
4 changes: 2 additions & 2 deletions examples/RealtimeDatabase/Async/NoCallback/File/File.ino
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ RealtimeDatabase Database;
AsyncResult aResult_no_callback;

#if defined(ENABLE_FS)
FileConfig upload_data("/upload.bin", fileCallback);
FileConfig upload_data("/upload.bin", fileCallback); // Can be set later with upload_data.setFile("/upload.bin", fileCallback);

FileConfig download_data("/download.bin", fileCallback);
FileConfig download_data("/download.bin", fileCallback); // Can be set later with download_data.setFile("/download.bin", fileCallback);
#endif

bool taskComplete = false;
Expand Down
2 changes: 1 addition & 1 deletion examples/Storage/Async/Callback/Download/Download.ino
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void printResult(AsyncResult &aResult);

void fileCallback(File &file, const char *filename, file_operating_mode mode);

FileConfig media_file("/media.mp4", fileCallback);
FileConfig media_file("/media.mp4", fileCallback); // Can be set later with media_file.setFile("/media.mp4", fileCallback);

#endif

Expand Down
2 changes: 1 addition & 1 deletion examples/Storage/Async/Callback/Upload/Upload.ino
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void printResult(AsyncResult &aResult);

void fileCallback(File &file, const char *filename, file_operating_mode mode);

FileConfig media_file("/media.mp4", fileCallback);
FileConfig media_file("/media.mp4", fileCallback); // Can be set later with media_file.setFile("/media.mp4", fileCallback);

#endif

Expand Down
2 changes: 1 addition & 1 deletion examples/Storage/Async/NoCallback/Download/Download.ino
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void printResult(AsyncResult &aResult);

void fileCallback(File &file, const char *filename, file_operating_mode mode);

FileConfig media_file("/media.mp4", fileCallback);
FileConfig media_file("/media.mp4", fileCallback); // Can be set later with media_file.setFile("/media.mp4", fileCallback);

#endif

Expand Down
2 changes: 1 addition & 1 deletion examples/Storage/Async/NoCallback/Upload/Upload.ino
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void printResult(AsyncResult &aResult);

void fileCallback(File &file, const char *filename, file_operating_mode mode);

FileConfig media_file("/media.mp4", fileCallback);
FileConfig media_file("/media.mp4", fileCallback); // Can be set later with media_file.setFile("/media.mp4", fileCallback);

#endif

Expand Down
2 changes: 1 addition & 1 deletion examples/Storage/Sync/Download/Download.ino
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ void printError(int code, const String &msg);

void fileCallback(File &file, const char *filename, file_operating_mode mode);

FileConfig media_file("/media.mp4", fileCallback);
FileConfig media_file("/media.mp4", fileCallback); // Can be set later with media_file.setFile("/media.mp4", fileCallback);

#endif

Expand Down
2 changes: 1 addition & 1 deletion examples/Storage/Sync/Upload/Upload.ino
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ void printError(int code, const String &msg);

void fileCallback(File &file, const char *filename, file_operating_mode mode);

FileConfig media_file("/media.mp4", fileCallback);
FileConfig media_file("/media.mp4", fileCallback); // Can be set later with media_file.setFile("/media.mp4", fileCallback);

#endif

Expand Down
2 changes: 2 additions & 0 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,8 @@ setJWTProcessor KEYWORD2
setSessionTimeout KEYWORD2
setOTAStorage KEYWORD2
setNetwork KEYWORD2
setBlob KEYWORD2
setFile KEYWORD2

###################
# Struct (KEYWORD3)
Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "FirebaseClient",
"version": "1.3.4",
"version": "1.3.5",
"keywords": "communication, REST, esp32, esp8266, arduino",
"description": "Async Firebase Client library for Arduino.",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name=FirebaseClient

version=1.3.4
version=1.3.5

author=Mobizt

Expand Down
51 changes: 39 additions & 12 deletions resources/docs/file_config.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ class FileConfig
## Constructors
1. ### 🔹 FileConfig(const String &filename, FileConfigCallback cb)
1. ### 🔹 FileConfig(const String &filename = "", FileConfigCallback cb = NULL)
```cpp
FileConfig(const String &filename, FileConfigCallback cb)
FileConfig(const String &filename = "", FileConfigCallback cb = NULL)
```
**Params:**
Expand All @@ -34,15 +34,31 @@ class FileConfig
## Functions
1. ### 🔹 void clear()
1. ### 🔹 void setFile(const String &filename, FileConfigCallback cb)
Set the File config.
```cpp
void setFile(const String &filename, FileConfigCallback cb)
```
**Params:**
- `filename` - The file name of file to be read and write.
- `cb` - The FileConfigCallback function that accepts File object, file name and `file_operating_mode` to be processed.
The `file_operating_mode` enums are included `file_mode_open_read`, `file_mode_open_write`, `file_mode_open_append`, and `file_mode_remove`.
2. ### 🔹 void clear()
Clear the internal data.
```cpp
void clear()
```
2. ### 🔹 FileConfig &setFilename(const String &filename)
3. ### 🔹 FileConfig &setFilename(const String &filename)
Set the file name.
Expand All @@ -58,7 +74,7 @@ class FileConfig
- `FileConfig &` - The reference to the `FileConfig` itself.
3. ### 🔹 FileConfig &setFilename(const String &filename)
4. ### 🔹 FileConfig &setFilename(const String &filename)
Set the file name.
Expand All @@ -77,7 +93,7 @@ class FileConfig
- `FileConfig &` - The reference to the `FileConfig` itself.
4. ### 🔹 file_config_data &get()
5. ### 🔹 file_config_data &get()
Get the reference to the internal `file_config_data`.
Expand Down Expand Up @@ -108,8 +124,6 @@ class BlobConfig

1. ### 🔹 BlobConfig(uint8_t *data = nullptr, size_t size = 0)

In the networkConnectionCB function, the complete operations for the carier (network) and internet connection should be performed

```cpp
BlobConfig(uint8_t *data = nullptr, size_t size = 0)
```
Expand All @@ -121,15 +135,28 @@ class BlobConfig

## Functions

1. ### 🔹 void clear()
1. ### 🔹 void setBlob(uint8_t *data, size_t size)

Set the BLOB config.

```cpp
void setBlob(uint8_t *data, size_t size)
```

**Params:**

- `data` - The pointer to the uint8_t data array.
- `size` - The size of data in bytes.

2. ### 🔹 void clear()

Clear the internal data.

```cpp
void clear()
```

2. ### 🔹 uint8_t *blob() const
3. ### 🔹 uint8_t *blob() const

Get the pointer to the internal BLOB data.

Expand All @@ -141,7 +168,7 @@ class BlobConfig

- `uint8_t *` - The pointer to uint8_t data array.

3. ### 🔹 size_t size()
4. ### 🔹 size_t size()

Get the size of data.

Expand All @@ -153,7 +180,7 @@ class BlobConfig

- `size_t` - The size of data in bytes.

4. ### 🔹 file_config_data &getData()
5. ### 🔹 file_config_data &getData()

Get the reference to the internal file_config_data.

Expand Down
2 changes: 1 addition & 1 deletion src/core/Core.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#undef FIREBASE_CLIENT_VERSION
#endif

#define FIREBASE_CLIENT_VERSION "1.3.4"
#define FIREBASE_CLIENT_VERSION "1.3.5"

static void sys_idle()
{
Expand Down
Loading

0 comments on commit 68812ed

Please sign in to comment.