Skip to content

Commit

Permalink
Added examples
Browse files Browse the repository at this point in the history
  • Loading branch information
tobozo committed Jan 26, 2020
1 parent d278391 commit a6a9dc2
Show file tree
Hide file tree
Showing 21 changed files with 669 additions and 304 deletions.
Binary file added ESP32-targz.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
63 changes: 56 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# ESP32-targz


![](ESP32-targz.png)



This library is a wrapper for the following two great libraries:

- uzlib https://github.com/pfalcon/uzlib
Expand All @@ -10,17 +15,61 @@ Decompression support for .tar and .gz files
This is a work in progress



Extract content from `.gz` file
-------------------------------

```C

// mount spiffs (or any other filesystem)
SPIFFS.begin(true);

// expand one file
gzExpander(SPIFFS, "/index_html.gz", SPIFFS, "/index.html");

// expand another file
gzExpander(SPIFFS, "/tbz.gz", SPIFFS, "/tbz.jpg");


```
Expand contents from `.tar` file to `/tmp` folder
-------------------------------------------------
```C
#include <ESP32-targz.h>
void setup() {
// mount spiffs (or any other filesystem)
SPIFFS.begin(true);
uzFileExpander(SPIFFS, "/menu.tar.gz", SPIFFS, "/menu.tar");
untarFile(SPIFFS, "/menu.tar");
}
void loop() {
tarExpander(SPIFFS, "/tobozo.tar", SPIFFS, "/tmp");
```



Expand contents from `.tar.gz` to `/tmp` folder
------------------------------------------------

```C

// mount spiffs (or any other filesystem)
SPIFFS.begin(true);

tarGzExpander(SPIFFS, "/tbz.tar.gz", SPIFFS, "/tmp");

```
Flash the ESP with contents from `.gz` file
-------------------------------------------
```C
// mount spiffs (or any other filesystem)
SPIFFS.begin(true);
gzUpdater(SPIFFS, "/menu_bin.gz");
}
```
20 changes: 20 additions & 0 deletions examples/Unpack_gz_file/Unpack_gz_file.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <ESP32-targz.h>

void setup() {

Serial.begin( 115200 );

SPIFFS.begin( true );

// extract content from gz file
gzExpander(SPIFFS, "/index_html.gz", SPIFFS, "/index.html");

gzExpander(SPIFFS, "/tbz.gz", SPIFFS, "/tbz.jpg");

tarGzListDir( SPIFFS, "/");

}

void loop() {

}
Binary file added examples/Unpack_gz_file/data/index_html.gz
Binary file not shown.
Binary file added examples/Unpack_gz_file/data/tbz.gz
Binary file not shown.
Binary file added examples/Unpack_gz_file/data/tbz.tar.gz
Binary file not shown.
Binary file added examples/Unpack_gz_file/data/tobozo.tar
Binary file not shown.
18 changes: 18 additions & 0 deletions examples/Unpack_tar_file/Unpack_tar_file.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include <ESP32-targz.h>

void setup() {

Serial.begin( 115200 );

SPIFFS.begin(true);

// expand tar contents to /tmp folder
tarExpander(SPIFFS, "/tobozo.tar", SPIFFS, "/tmp");

tarGzListDir( SPIFFS, "/tmp");

}

void loop() {

}
Binary file added examples/Unpack_tar_file/data/index_html.gz
Binary file not shown.
Binary file added examples/Unpack_tar_file/data/tbz.gz
Binary file not shown.
Binary file added examples/Unpack_tar_file/data/tbz.tar.gz
Binary file not shown.
Binary file added examples/Unpack_tar_file/data/tobozo.tar
Binary file not shown.
18 changes: 18 additions & 0 deletions examples/Unpack_targz_file/Unpack_targz_file.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include <ESP32-targz.h>

void setup() {

Serial.begin( 115200 );

SPIFFS.begin(true);

// direct .tar.gz to file expanding
tarGzExpander(SPIFFS, "/tbz.tar.gz", SPIFFS, "/tmp");

tarGzListDir( SPIFFS, "/tmp");

}

void loop() {

}
Binary file added examples/Unpack_targz_file/data/index_html.gz
Binary file not shown.
Binary file added examples/Unpack_targz_file/data/tbz.gz
Binary file not shown.
Binary file added examples/Unpack_targz_file/data/tbz.tar.gz
Binary file not shown.
Binary file added examples/Unpack_targz_file/data/tobozo.tar
Binary file not shown.
24 changes: 24 additions & 0 deletions examples/Update_from_gz/Update_from_gz.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <ESP32-targz.h>

#define BUTTON_PIN 32

void setup() {

Serial.begin( 115200 );

pinMode( BUTTON_PIN, INPUT_PULLUP );

}

void loop() {

if( digitalRead( BUTTON_PIN ) == LOW ) {

SPIFFS.begin(true);

// flash the ESP with gz's contents (gzip the bin yourself and use the spiffs uploader)
gzUpdater(SPIFFS, "/menu_bin.gz");

}

}
Loading

0 comments on commit a6a9dc2

Please sign in to comment.