29 Commits

Author SHA1 Message Date
Jonas Niesner
a251ed10e7 Cleaned up release.yml and added 2 new platforms 2023-06-26 09:51:21 +02:00
Jonas Niesner
65410e3e8d Improve push/pr test pipeline 2023-06-26 09:46:57 +02:00
Jonas Niesner
b2174c2980 cleaned up platformio.ini 2023-06-26 09:44:30 +02:00
Jelmer
7db482a6ba Delete AP_force_flash.bin 2023-06-26 09:02:53 +02:00
Jelmer
bac7cf7ab5 Merge pull request #71 from Mimoja/misc
Misc changes to for low-effort setups
2023-06-25 15:17:52 +02:00
Jelmer
a3e739b8da Merge pull request #72 from slimline33/master
Thank you for your contribution!
2023-06-25 15:16:47 +02:00
Mimoja
cc1dcd9d29 ESP: split esp2buffer into two calls
Sprite rendering is the most heap hungry operation in during
content generation. This can lead to ESP panics as the exception
for the failing "new" is not handled.
To further half the required the memory we are doing it in two passes
for black and red independant. While this add a few ms to the rendering
the main time of the rendering is writing to the FS anyways so the overhead
neglectable after all.

Signed-off-by: Mimoja <git@mimoja.de>
2023-06-25 13:12:56 +02:00
Mimoja
10468313e1 Print free disk space in human readable numbers
Signed-off-by: Mimoja <git@mimoja.de>
2023-06-25 13:12:56 +02:00
Mimoja
2e55c49a92 main: Print free heap in parallel to web interface
Signed-off-by: Mimoja <git@mimoja.de>
2023-06-25 13:12:56 +02:00
Mimoja
e45845e00e Add SPIFFSEditor header to match imported source file
The SPIFFSEditor.h header is being imported from the .platformio folder
while the corresponding .cpp is actually stored with the project.
To ensure we can not accidentally edit the wrong file in the future import
the header as well

Signed-off-by: Mimoja <git@mimoja.de>
2023-06-25 13:12:56 +02:00
Mimoja
940795d05d Dont attack the ledc to the LED pin if no LED is available
Signed-off-by: Mimoja <git@mimoja.de>
2023-06-25 13:12:56 +02:00
Mimoja
a3fc1da6d2 Add Flash Timeout parameter
Signed-off-by: Mimoja <git@mimoja.de>
2023-06-25 13:12:56 +02:00
Bimmi
d778aab553 Add favicon.ico
upload favicon.ico
2023-06-25 08:45:00 +02:00
Bimmi
f460046c51 Update index.html
added code for favicon.ico
2023-06-25 08:44:07 +02:00
Jelmer
e5ddba02ff Merge pull request #70 from Mimoja/SDCard
Add Support for an SDCard and SoftSPI
2023-06-24 23:29:24 +02:00
Jonas Niesner
7ba80f57c9 Merge branch 'master' into SDCard 2023-06-21 21:41:08 +02:00
Jonas Niesner
d6feb5a8ca Update platformio.ini
Added M5 core build config
2023-06-20 21:24:46 +02:00
Jonas Niesner
1e034c83fa Merge pull request #68 from Mimoja/weemos
Add Weemos D1 mini 32 as target
2023-06-20 21:20:43 +02:00
Mimoja
1e93a24b53 Allow the usage of SoftSPI for AP flashing
The AP-Tags are not very fast at flashing. SoftSPI is fast enough for the
rare flashing.
This gives us the ability to move the AP connection to arbitrary pins.

Signed-off-by: Mimoja <git@mimoja.de>
2023-06-20 17:55:41 +02:00
Mimoja
dbf76e2176 Expose flasher speed to config via define
Signed-off-by: Mimoja <git@mimoja.de>
2023-06-20 17:51:10 +02:00
Mimoja
93639ff8ac Disconnect SDCard if it shares the pins with the flasher
Signed-off-by: Mimoja <git@mimoja.de>
2023-06-20 17:51:10 +02:00
Mimoja
48b2925b9f Reset flasher if it shared the pins with the SDCard
If the flasher and the SDCard share pins the ESP will need to be reset
to bring VSPI and HSPI back into sane states. Trying to reinit them
without a reset will lead to heap corruptions.
Better safe than sorry.

Signed-off-by: Mimoja <git@mimoja.de>
2023-06-20 17:51:10 +02:00
Mimoja
9c83d8b5a5 Use SDCard usage where available
When an SD Card is available it is the more interesing
metric in terms of space usage. We are therefore using
it here.

Signed-off-by: Mimoja <git@mimoja.de>
2023-06-20 17:51:10 +02:00
Mimoja
f487092f7f Add SDCard support
To be able to store more images and never worry about running
out of storage again we are adding support of SDCards.

We are faced with two options:
1) Remove the LittleFS code
2) Allow for both FSs but increase the app partition as we run
out of space.

We have opted for 2 for two reasons:
1) Unformated SDCards can be initialized from the littleFS
2) If the SDCard and the flasher share the same SPI pins
the SDCard needs to be completely disconnected so there needs
to be a FS in that rare case.

Performance wise the SDCard is not slowing the system down.
Writing the AP db with 70 APs takes 2.5 seconds, on the SD
only 800ms. This however is SD and setup depending.

By default the SDCard is expected on pins 18,19,23 however this
is configurable via preprocessor defines.

Globally we replace LittleFS with a new pointer to the currently
used FS allowing for hotswapping where the FS pointer is not saved.
One case which is therefore not working is the SPIFSEditor which
copies the FS interally.

Signed-off-by: Mimoja <git@mimoja.de>
2023-06-20 17:51:10 +02:00
Mimoja
eae7c3a159 ESP: Delete files after transfer where requested
Beyond around 20 APs the littleFs will no longer provide enough
space to add .pending files. The original .raw files are premarily
held to be able to send them to the web interface.
In those rare cases where this is not strictly needed we can
allow specific setups to auto-delete them.

Signed-off-by: Mimoja <git@mimoja.de>
2023-06-20 17:51:10 +02:00
Mimoja
4d78df09cc Add M5stack (original core) config
The M5stack board offers three interesting features for use with
OpenEPaperLink:
- LCD
- SDCard slot
- Modules including a batters

Which means it can easily be used to walk around with an AP for testing
purposes.
The LCD is currely not used as the M5Stack library is so old that it collides
with newer versions of eTFT which we are importing already.

Signed-off-by: Mimoja <git@mimoja.de>
2023-06-20 17:51:09 +02:00
Mimoja
e8740b2022 Add Weemos D1 mini 32 as target
The original weemos D1 mini was one of the most popular
ESP8266 boards. To this day many designs are designed around its
formfactor.
The successor is the here added D1 mini 32. It brings the same
"core" header with 8 GPIO but also additional io.

We are adding a default config which is workable with the old
pinconfig as those are usually the only ones exposed on the
breakout boards.
2023-06-20 17:24:53 +02:00
atc1441
6c4e254db0 Update NanoAP_Case.jpg 2023-06-19 22:43:48 +02:00
atc1441
5ccbcb4719 Nano AP Infos and Files added 2023-06-19 22:42:24 +02:00
30 changed files with 645 additions and 240 deletions

View File

@@ -1,4 +1,4 @@
name: ESP32 build
name: ESP32 firmware builf test
on: [push,pull_request]
@@ -20,32 +20,38 @@ jobs:
- name: Install PlatformIO Core
run: pip install --upgrade platformio
- name: Build firmware for ESP32
- name: Build Simple_AP
run: |
cd ESP32_AP-Flasher
pio run --environment Simple_AP
- name: Build filesystem for ESP32
run: |
cd ESP32_AP-Flasher
pio run --target buildfs --environment Simple_AP
- name: Build firmware for ESP32-S2
- name: Build OpenEPaperLink_Mini_AP
run: |
cd ESP32_AP-Flasher
pio run --environment OpenEPaperLink_Mini_AP
pio run --target buildfs --environment OpenEPaperLink_Mini_AP
- name: Build filesystem for ESP32-S2
- name: Build OpenEPaperLink_Nano_AP
run: |
cd ESP32_AP-Flasher
pio run --target buildfs --environment OpenEPaperLink_Mini_AP
pio run --environment OpenEPaperLink_Nano_AP
pio run --target buildfs --environment OpenEPaperLink_Nano_AP
- name: Build firmware for ESP32-S3
- name: Build OpenEPaperLink_AP_and_Flasher
run: |
cd ESP32_AP-Flasher
pio run --environment OpenEPaperLink_AP_and_Flasher
- name: Build filesystem for ESP32-S3
pio run --target buildfs --environment OpenEPaperLink_AP_and_Flasher
- name: Build Weemos_AP
run: |
cd ESP32_AP-Flasher
pio run --target buildfs --environment OpenEPaperLink_AP_and_Flasher
pio run --environment Weemos_AP
pio run --target buildfs --environment Weemos_AP
- name: Build M5Stack_Core_ONE_AP
run: |
cd ESP32_AP-Flasher
pio run --environment M5Stack_Core_ONE_AP
pio run --target buildfs --environment M5Stack_Core_ONE_AP

View File

@@ -26,129 +26,117 @@ jobs:
- name: Install esptool
run: pip install esptool
# - name: Add www folder to release
# uses: svenstaro/upload-release-action@v2
# with:
# repo_token: ${{ secrets.GITHUB_TOKEN }}
# file: ESP32_AP-Flasher/data/www/*
# tag: ${{ github.ref }}
# file_glob: true
# - name: Add fonts folder to release
# uses: svenstaro/upload-release-action@v2
# with:
# repo_token: ${{ secrets.GITHUB_TOKEN }}
# file: ESP32_AP-Flasher/data/fonts/*
# tag: ${{ github.ref }}
# file_glob: true
# - name: Add data folder to release
# uses: svenstaro/upload-release-action@v2
# with:
# repo_token: ${{ secrets.GITHUB_TOKEN }}
# file: ESP32_AP-Flasher/data/*
# tag: ${{ github.ref }}
# file_glob: true
- name: create folders
run: |
mkdir espbinaries
- name: Build firmware for Simple_AP
run: |
cd ESP32_AP-Flasher
export PLATFORMIO_BUILD_FLAGS="-D BUILD_VERSION=${{ github.ref_name }} -D SHA=$GITHUB_SHA"
pio run --environment Simple_AP
pio run --target buildfs --environment Simple_AP
mkdir /home/runner/work/OpenEPaperLink/OpenEPaperLink/Simple_AP
cp ~/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin /home/runner/work/OpenEPaperLink/OpenEPaperLink/Simple_AP/boot_app0.bin
cp .pio/build/Simple_AP/firmware.bin /home/runner/work/OpenEPaperLink/OpenEPaperLink/Simple_AP/firmware.bin
cp .pio/build/Simple_AP/bootloader.bin /home/runner/work/OpenEPaperLink/OpenEPaperLink/Simple_AP/bootloader.bin
cp .pio/build/Simple_AP/partitions.bin /home/runner/work/OpenEPaperLink/OpenEPaperLink/Simple_AP/partitions.bin
- name: Build filesystem for Simple_AP
run: |
cd ESP32_AP-Flasher
pio run --target buildfs --environment Simple_AP
cp .pio/build/Simple_AP/littlefs.bin /home/runner/work/OpenEPaperLink/OpenEPaperLink/Simple_AP/littlefs.bin
- name: Combine binaries for Simple_AP
run: |
cd /home/runner/work/OpenEPaperLink/OpenEPaperLink/Simple_AP
esptool.py --chip esp32 merge_bin -o merged-firmware.bin --flash_mode dio --flash_freq 40m --flash_size 4MB 0x1000 bootloader.bin 0x8000 partitions.bin 0xe000 boot_app0.bin 0x10000 firmware.bin 0x290000 littlefs.bin
cd /home/runner/work/OpenEPaperLink/OpenEPaperLink
cp Simple_AP/firmware.bin espbinaries/Simple_AP.bin
cp Simple_AP/merged-firmware.bin espbinaries/Simple_AP_full.bin
- name: Build firmware for Weemos_AP
run: |
cd ESP32_AP-Flasher
export PLATFORMIO_BUILD_FLAGS="-D BUILD_VERSION=${{ github.ref_name }} -D SHA=$GITHUB_SHA"
pio run --environment Weemos_AP
pio run --target buildfs --environment Weemos_AP
mkdir /home/runner/work/OpenEPaperLink/OpenEPaperLink/Weemos_AP
cp ~/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin /home/runner/work/OpenEPaperLink/OpenEPaperLink/Weemos_AP/boot_app0.bin
cp .pio/build/Weemos_AP/firmware.bin /home/runner/work/OpenEPaperLink/OpenEPaperLink/Weemos_AP/firmware.bin
cp .pio/build/Weemos_AP/bootloader.bin /home/runner/work/OpenEPaperLink/OpenEPaperLink/Weemos_AP/bootloader.bin
cp .pio/build/Weemos_AP/partitions.bin /home/runner/work/OpenEPaperLink/OpenEPaperLink/Weemos_AP/partitions.bin
cp .pio/build/Weemos_AP/littlefs.bin /home/runner/work/OpenEPaperLink/OpenEPaperLink/Weemos_AP/littlefs.bin
cd /home/runner/work/OpenEPaperLink/OpenEPaperLink/Weemos_AP
esptool.py --chip esp32 merge_bin -o merged-firmware.bin --flash_mode dio --flash_freq 40m --flash_size 4MB 0x1000 bootloader.bin 0x8000 partitions.bin 0xe000 boot_app0.bin 0x10000 firmware.bin 0x290000 littlefs.bin
cd /home/runner/work/OpenEPaperLink/OpenEPaperLink
cp Weemos_AP/firmware.bin espbinaries/Weemos_AP.bin
cp Weemos_AP/merged-firmware.bin espbinaries/Weemos_AP_full.bin
- name: Build firmware for M5Stack_Core_ONE_AP
run: |
cd ESP32_AP-Flasher
export PLATFORMIO_BUILD_FLAGS="-D BUILD_VERSION=${{ github.ref_name }} -D SHA=$GITHUB_SHA"
pio run --environment M5Stack_Core_ONE_AP
pio run --target buildfs --environment M5Stack_Core_ONE_AP
mkdir /home/runner/work/OpenEPaperLink/OpenEPaperLink/M5Stack_Core_ONE_AP
cp ~/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin /home/runner/work/OpenEPaperLink/OpenEPaperLink/M5Stack_Core_ONE_AP/boot_app0.bin
cp .pio/build/M5Stack_Core_ONE_AP/firmware.bin /home/runner/work/OpenEPaperLink/OpenEPaperLink/M5Stack_Core_ONE_AP/firmware.bin
cp .pio/build/M5Stack_Core_ONE_AP/bootloader.bin /home/runner/work/OpenEPaperLink/OpenEPaperLink/M5Stack_Core_ONE_AP/bootloader.bin
cp .pio/build/M5Stack_Core_ONE_AP/partitions.bin /home/runner/work/OpenEPaperLink/OpenEPaperLink/M5Stack_Core_ONE_AP/partitions.bin
cp .pio/build/M5Stack_Core_ONE_AP/littlefs.bin /home/runner/work/OpenEPaperLink/OpenEPaperLink/M5Stack_Core_ONE_AP/littlefs.bin
cd /home/runner/work/OpenEPaperLink/OpenEPaperLink/M5Stack_Core_ONE_AP
esptool.py --chip esp32 merge_bin -o merged-firmware.bin --flash_mode dio --flash_freq 40m --flash_size 4MB 0x1000 bootloader.bin 0x8000 partitions.bin 0xe000 boot_app0.bin 0x10000 firmware.bin 0x2B0000 littlefs.bin
cd /home/runner/work/OpenEPaperLink/OpenEPaperLink
cp M5Stack_Core_ONE_AP/firmware.bin espbinaries/M5Stack_Core_ONE_AP.bin
cp M5Stack_Core_ONE_AP/merged-firmware.bin espbinaries/M5Stack_Core_ONE_AP_full.bin
- name: Build firmware for OpenEPaperLink_Mini_AP
run: |
cd ESP32_AP-Flasher
export PLATFORMIO_BUILD_FLAGS="-D BUILD_VERSION=${{ github.ref_name }} -D SHA=$GITHUB_SHA"
pio run --environment OpenEPaperLink_Mini_AP
pio run --target buildfs --environment OpenEPaperLink_Mini_AP
mkdir /home/runner/work/OpenEPaperLink/OpenEPaperLink/OpenEPaperLink_Mini_AP
cp ~/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin /home/runner/work/OpenEPaperLink/OpenEPaperLink/OpenEPaperLink_Mini_AP/boot_app0.bin
cp .pio/build/OpenEPaperLink_Mini_AP/firmware.bin /home/runner/work/OpenEPaperLink/OpenEPaperLink/OpenEPaperLink_Mini_AP/firmware.bin
cp .pio/build/OpenEPaperLink_Mini_AP/bootloader.bin /home/runner/work/OpenEPaperLink/OpenEPaperLink/OpenEPaperLink_Mini_AP/bootloader.bin
cp .pio/build/OpenEPaperLink_Mini_AP/partitions.bin /home/runner/work/OpenEPaperLink/OpenEPaperLink/OpenEPaperLink_Mini_AP/partitions.bin
- name: Build filesystem for OpenEPaperLink_Mini_AP
run: |
cd ESP32_AP-Flasher
pio run --target buildfs --environment OpenEPaperLink_Mini_AP
cp .pio/build/OpenEPaperLink_Mini_AP/littlefs.bin /home/runner/work/OpenEPaperLink/OpenEPaperLink/OpenEPaperLink_Mini_AP/littlefs.bin
- name: Combine binaries for OpenEPaperLink_Mini_AP
run: |
cd /home/runner/work/OpenEPaperLink/OpenEPaperLink/OpenEPaperLink_Mini_AP
esptool.py --chip esp32-s2 merge_bin -o merged-firmware.bin --flash_mode dio --flash_freq 80m --flash_size 4MB 0x1000 bootloader.bin 0x8000 partitions.bin 0xe000 boot_app0.bin 0x10000 firmware.bin 0x290000 littlefs.bin
cd /home/runner/work/OpenEPaperLink/OpenEPaperLink
cp OpenEPaperLink_Mini_AP/firmware.bin espbinaries/OpenEPaperLink_Mini_AP.bin
cp OpenEPaperLink_Mini_AP/merged-firmware.bin espbinaries/OpenEPaperLink_Mini_AP_full.bin
- name: Build firmware for OpenEPaperLink_Nano_AP
run: |
cd ESP32_AP-Flasher
export PLATFORMIO_BUILD_FLAGS="-D BUILD_VERSION=${{ github.ref_name }} -D SHA=$GITHUB_SHA"
pio run --environment OpenEPaperLink_Nano_AP
pio run --target buildfs --environment OpenEPaperLink_Nano_AP
mkdir /home/runner/work/OpenEPaperLink/OpenEPaperLink/OpenEPaperLink_Nano_AP
cp ~/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin /home/runner/work/OpenEPaperLink/OpenEPaperLink/OpenEPaperLink_Nano_AP/boot_app0.bin
cp .pio/build/OpenEPaperLink_Nano_AP/firmware.bin /home/runner/work/OpenEPaperLink/OpenEPaperLink/OpenEPaperLink_Nano_AP/firmware.bin
cp .pio/build/OpenEPaperLink_Nano_AP/bootloader.bin /home/runner/work/OpenEPaperLink/OpenEPaperLink/OpenEPaperLink_Nano_AP/bootloader.bin
cp .pio/build/OpenEPaperLink_Nano_AP/partitions.bin /home/runner/work/OpenEPaperLink/OpenEPaperLink/OpenEPaperLink_Nano_AP/partitions.bin
- name: Build filesystem for OpenEPaperLink_Nano_AP
run: |
cd ESP32_AP-Flasher
pio run --target buildfs --environment OpenEPaperLink_Nano_AP
cp .pio/build/OpenEPaperLink_Nano_AP/littlefs.bin /home/runner/work/OpenEPaperLink/OpenEPaperLink/OpenEPaperLink_Nano_AP/littlefs.bin
- name: Combine binaries for OpenEPaperLink_Nano_AP
run: |
cd /home/runner/work/OpenEPaperLink/OpenEPaperLink/OpenEPaperLink_Nano_AP
esptool.py --chip esp32-s2 merge_bin -o merged-firmware.bin --flash_mode dio --flash_freq 80m --flash_size 4MB 0x1000 bootloader.bin 0x8000 partitions.bin 0xe000 boot_app0.bin 0x10000 firmware.bin 0x290000 littlefs.bin
cd /home/runner/work/OpenEPaperLink/OpenEPaperLink
cp OpenEPaperLink_Nano_AP/firmware.bin espbinaries/OpenEPaperLink_Nano_AP.bin
cp OpenEPaperLink_Nano_AP/merged-firmware.bin espbinaries/OpenEPaperLink_Nano_AP_full.bin
- name: Build firmware for OpenEPaperLink_AP_and_Flasher
run: |
cd ESP32_AP-Flasher
export PLATFORMIO_BUILD_FLAGS="-D BUILD_VERSION=${{ github.ref_name }} -D SHA=$GITHUB_SHA"
pio run --environment OpenEPaperLink_AP_and_Flasher
pio run --target buildfs --environment OpenEPaperLink_AP_and_Flasher
mkdir /home/runner/work/OpenEPaperLink/OpenEPaperLink/OpenEPaperLink_AP_and_Flasher
cp ~/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin /home/runner/work/OpenEPaperLink/OpenEPaperLink/OpenEPaperLink_AP_and_Flasher/boot_app0.bin
cp .pio/build/OpenEPaperLink_AP_and_Flasher/firmware.bin /home/runner/work/OpenEPaperLink/OpenEPaperLink/OpenEPaperLink_AP_and_Flasher/firmware.bin
cp .pio/build/OpenEPaperLink_AP_and_Flasher/bootloader.bin /home/runner/work/OpenEPaperLink/OpenEPaperLink/OpenEPaperLink_AP_and_Flasher/bootloader.bin
cp .pio/build/OpenEPaperLink_AP_and_Flasher/partitions.bin /home/runner/work/OpenEPaperLink/OpenEPaperLink/OpenEPaperLink_AP_and_Flasher/partitions.bin
- name: Build filesystem for OpenEPaperLink_AP_and_Flasher
run: |
cd ESP32_AP-Flasher
pio run --target buildfs --environment OpenEPaperLink_AP_and_Flasher
cp .pio/build/OpenEPaperLink_AP_and_Flasher/littlefs.bin /home/runner/work/OpenEPaperLink/OpenEPaperLink/OpenEPaperLink_AP_and_Flasher/littlefs.bin
- name: Combine binaries for OpenEPaperLink_AP_and_Flasher
run: |
cd /home/runner/work/OpenEPaperLink/OpenEPaperLink/OpenEPaperLink_AP_and_Flasher
esptool.py --chip esp32-s3 merge_bin -o merged-firmware.bin --flash_mode dio --flash_freq 80m --flash_size 16MB 0x0000 bootloader.bin 0x8000 partitions.bin 0xe000 boot_app0.bin 0x10000 firmware.bin 0x00c90000 littlefs.bin
- name: move binaries
run: |
mkdir espbinaries
cp Simple_AP/firmware.bin espbinaries/Simple_AP.bin
cp OpenEPaperLink_Mini_AP/firmware.bin espbinaries/OpenEPaperLink_Mini_AP.bin
cp OpenEPaperLink_Nano_AP/firmware.bin espbinaries/OpenEPaperLink_Nano_AP.bin
cd /home/runner/work/OpenEPaperLink/OpenEPaperLink
cp OpenEPaperLink_AP_and_Flasher/firmware.bin espbinaries/OpenEPaperLink_AP_and_Flasher.bin
cp Simple_AP/merged-firmware.bin espbinaries/Simple_AP_full.bin
cp OpenEPaperLink_Mini_AP/merged-firmware.bin espbinaries/OpenEPaperLink_Mini_AP_full.bin
cp OpenEPaperLink_Nano_AP/merged-firmware.bin espbinaries/OpenEPaperLink_Nano_AP_full.bin
cp OpenEPaperLink_AP_and_Flasher/merged-firmware.bin espbinaries/OpenEPaperLink_AP_and_Flasher_full.bin
- name: generate release json file
@@ -182,3 +170,27 @@ jobs:
tag: ${{ github.ref }}
file_glob: true
overwrite: true
# - name: Add www folder to release
# uses: svenstaro/upload-release-action@v2
# with:
# repo_token: ${{ secrets.GITHUB_TOKEN }}
# file: ESP32_AP-Flasher/data/www/*
# tag: ${{ github.ref }}
# file_glob: true
# - name: Add fonts folder to release
# uses: svenstaro/upload-release-action@v2
# with:
# repo_token: ${{ secrets.GITHUB_TOKEN }}
# file: ESP32_AP-Flasher/data/fonts/*
# tag: ${{ github.ref }}
# file_glob: true
# - name: Add data folder to release
# uses: svenstaro/upload-release-action@v2
# with:
# repo_token: ${{ secrets.GITHUB_TOKEN }}
# file: ESP32_AP-Flasher/data/*
# tag: ${{ github.ref }}
# file_glob: true

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

View File

@@ -7,7 +7,7 @@
<title>Open EPaper Link Access Point</title>
<link rel="stylesheet" href="main.css" type="text/css" />
<link rel="icon" href="data:,">
<link rel="icon" type="image/vnd.icon" href="favicon.ico">
</head>
<body>
@@ -160,7 +160,7 @@ Latency will be around 40 seconds.">
<div><span id="runstate"></div>
<div><span id="apstatecolor">&#11044;</span> <span id="apstate">loading</span></div>
<div><span id="apconfigbutton">AP config</span></div>
<div><a href="/edit" target="littlefs" class="filebutton">edit littleFS</a></div>
<div><a href="/edit" target="littlefs" class="filebutton">edit contentFS</a></div>
</div>
</div>
@@ -206,4 +206,4 @@ Latency will be around 40 seconds.">
</body>
</html>
</html>

View File

@@ -94,7 +94,7 @@ function connect() {
processTags(msg.tags);
}
if (msg.sys) {
$('#sysinfo').innerHTML = 'free heap: ' + msg.sys.heap + ' bytes &#x2507; db size: ' + msg.sys.dbsize + ' bytes &#x2507; db record count: ' + msg.sys.recordcount + ' &#x2507; littlefs free: ' + msg.sys.littlefsfree + ' bytes';
$('#sysinfo').innerHTML = 'free heap: ' + msg.sys.heap + ' bytes &#x2507; db size: ' + msg.sys.dbsize + ' bytes &#x2507; db record count: ' + msg.sys.recordcount + ' &#x2507; active filesystem free: ' + msg.sys.littlefsfree + ' bytes ' + convertSize(msg.sys.littlefsfree);
if (msg.sys.apstate) {
$("#apstatecolor").style.color = apstate[msg.sys.apstate].color;
$("#apstate").innerHTML = apstate[msg.sys.apstate].state;
@@ -127,6 +127,18 @@ function connect() {
});
}
// Copied from
// https://stackoverflow.com/questions/15900485/correct-way-to-convert-size-in-bytes-to-kb-mb-gb-in-javascript
function convertSize(bytes){
if (bytes >= 1073741824) { bytes = (bytes / 1073741824).toFixed(2) + " GB"; }
else if (bytes >= 1048576) { bytes = (bytes / 1048576).toFixed(2) + " MB"; }
else if (bytes >= 1024) { bytes = (bytes / 1024).toFixed(2) + " KB"; }
else if (bytes > 1) { bytes = bytes + " bytes"; }
else if (bytes == 1) { bytes = bytes + " byte"; }
else { bytes = "0 bytes"; }
return "(" + bytes + ")";
}
function processTags(tagArray) {
for (const element of tagArray) {
tagmac = element.mac;

View File

@@ -0,0 +1,7 @@
# Name, Type, SubType, Offset, Size, Flags
nvs, data, nvs, 0x9000, 0x5000,
otadata, data, ota, 0xe000, 0x2000,
app0, app, ota_0, 0x10000, 0x150000,
app1, app, ota_1, 0x160000,0x150000,
spiffs, data, spiffs, 0x2B0000,0x140000,
coredump, data, coredump,0x3F0000,0x10000,
1 # Name Type SubType Offset Size Flags
2 nvs data nvs 0x9000 0x5000
3 otadata data ota 0xe000 0x2000
4 app0 app ota_0 0x10000 0x150000
5 app1 app ota_1 0x160000 0x150000
6 spiffs data spiffs 0x2B0000 0x140000
7 coredump data coredump 0x3F0000 0x10000

View File

@@ -0,0 +1,24 @@
#ifndef SPIFFSEditor_H_
#define SPIFFSEditor_H_
#include <ESPAsyncWebServer.h>
class SPIFFSEditor: public AsyncWebHandler {
private:
fs::FS _fs;
String _username;
String _password;
bool _authenticated;
uint32_t _startTime;
public:
#ifdef ESP32
SPIFFSEditor(const fs::FS& fs, const String& username=String(), const String& password=String());
#else
SPIFFSEditor(const String& username=String(), const String& password=String(), const fs::FS& fs=SPIFFS);
#endif
virtual bool canHandle(AsyncWebServerRequest *request) override final;
virtual void handleRequest(AsyncWebServerRequest *request) override final;
virtual void handleUpload(AsyncWebServerRequest *request, const String& filename, size_t index, uint8_t *data, size_t len, bool final) override final;
virtual bool isRequestHandlerTrivial() override final {return false;}
};
#endif

View File

@@ -0,0 +1,39 @@
#ifndef _DYN_STORAGE_H_
#define _DYN_STORAGE_H_
#include "FS.h"
#ifdef HAS_SDCARD
#ifndef SD_CARD_SS
#error SD_CARD_SS UNDEFINED
#endif
#ifndef SD_CARD_CLK
#define SD_CARD_CLK 18
#endif
#ifndef SD_CARD_MISO
#define SD_CARD_MISO 19
#endif
#ifndef SD_CARD_MOSI
#define SD_CARD_MOSI 23
#endif
#endif
class DynStorage {
public:
DynStorage();
void begin();
void end();
void listFiles();
size_t freeSpace();
private:
bool isInited;
};
extern DynStorage Storage;
extern fs::FS *contentFS;
#endif

View File

@@ -21,15 +21,17 @@ lib_deps =
https://github.com/Bodmer/U8g2_for_TFT_eSPI
https://github.com/ricmoo/qrcode
fastled/FastLED
https://github.com/MajenkoLibraries/SoftSPI
platform_packages =
board_build.filesystem = littlefs
monitor_filters = esp32_exception_decoder
monitor_speed = 115200
board_build.f_cpu = 240000000L
;upload_port = COM30
;monitor_port = COM30
; ----------------------------------------------------------------------------------------
; !!! this configuration expects the Mini_AP
;
; ----------------------------------------------------------------------------------------
[env:OpenEPaperLink_Mini_AP]
platform = https://github.com/platformio/platform-espressif32.git
board=lolin_s2_mini
@@ -43,12 +45,9 @@ build_flags =
-D ARDUINO_USB_MODE=0
-D CONFIG_SPIRAM_USE_MALLOC=1
-D CONFIG_MBEDTLS_EXTERNAL_MEM_ALLOC=y
-D HAS_RGB_LED
-D BOARD_HAS_PSRAM
-D POWER_NO_SOFT_POWER
-D FLASHER_AP_SS=11
-D FLASHER_AP_CLK=9
-D FLASHER_AP_MOSI=10
@@ -60,23 +59,22 @@ build_flags =
-D FLASHER_AP_TEST=12
-D FLASHER_LED=15
-D FLASHER_RGB_LED=33
-D USER_SETUP_LOADED
-D DISABLE_ALL_LIBRARY_WARNINGS
-D ILI9341_DRIVER
-D SMOOTH_FONT
-D LOAD_FONT2
build_src_filter =
+<*>-<usbflasher.cpp>-<serialconsole.cpp>
board_build.psram_type=qspi_opi
board_upload.maximum_size = 4194304
;board_upload.maximum_ram_size = 2097152
board_upload.maximum_ram_size = 327680
board_upload.flash_size = 4MB
; ----------------------------------------------------------------------------------------
; !!! this configuration expects the Nano_AP
;
; ----------------------------------------------------------------------------------------
[env:OpenEPaperLink_Nano_AP]
platform = https://github.com/platformio/platform-espressif32.git
board=lolin_s2_mini
@@ -90,9 +88,7 @@ build_flags =
-D ARDUINO_USB_MODE=0
-D CONFIG_SPIRAM_USE_MALLOC=1
-D CONFIG_MBEDTLS_EXTERNAL_MEM_ALLOC=y
-D BOARD_HAS_PSRAM
-D FLASHER_AP_SS=38
-D FLASHER_AP_CLK=40
-D FLASHER_AP_MOSI=39
@@ -104,23 +100,18 @@ build_flags =
-D FLASHER_AP_TEST=36
-D FLASHER_LED=15
-D FLASHER_RGB_LED=-1
-D USER_SETUP_LOADED
-D DISABLE_ALL_LIBRARY_WARNINGS
-D ILI9341_DRIVER
-D SMOOTH_FONT
-D LOAD_FONT2
build_src_filter =
+<*>-<usbflasher.cpp>-<serialconsole.cpp>
board_build.psram_type=qspi_opi
board_upload.maximum_size = 4194304
;board_upload.maximum_ram_size = 2097152
board_upload.maximum_ram_size = 327680
board_upload.flash_size = 4MB
; ----------------------------------------------------------------------------------------
; !!! this configuration expects the 16MB Flash / 8MB Ram version of the ESP32-S3-DevkitC1
;
@@ -129,7 +120,6 @@ board_upload.flash_size = 4MB
platform = https://github.com/platformio/platform-espressif32.git
board = esp32-s3-devkitc-1
board_build.partitions = default_16MB.csv
build_unflags =
-D ARDUINO_USB_MODE=1
-D CONFIG_MBEDTLS_INTERNAL_MEM_ALLOC=y
@@ -144,10 +134,8 @@ build_flags =
-D HAS_RGB_LED
-D BOARD_HAS_PSRAM
-D CONFIG_MBEDTLS_EXTERNAL_MEM_ALLOC=y
-D POWER_RAMPING
-D POWER_HIGH_SIDE_DRIVER
-D FLASHER_AP_SS=4
-D FLASHER_AP_CLK=5
-D FLASHER_AP_MOSI=7
@@ -157,7 +145,6 @@ build_flags =
-D FLASHER_AP_TXD=16
-D FLASHER_AP_RXD=18
-D FLASHER_AP_TEST=17
-D FLASHER_EXT_SS=40
-D FLASHER_EXT_CLK=41
-D FLASHER_EXT_MOSI=2
@@ -167,7 +154,6 @@ build_flags =
-D FLASHER_EXT_TXD=38
-D FLASHER_EXT_RXD=39
-D FLASHER_EXT_TEST=47
-D FLASHER_ALT_SS=3
-D FLASHER_ALT_CLK=46
-D FLASHER_ALT_MOSI=10
@@ -177,34 +163,32 @@ build_flags =
-D FLASHER_ALT_TXD=12
-D FLASHER_ALT_RXD=14
-D FLASHER_ALT_TEST=13
-D FLASHER_LED=21
-D FLASHER_RGB_LED=48
-D USER_SETUP_LOADED
-D DISABLE_ALL_LIBRARY_WARNINGS
-D ILI9341_DRIVER
-D SMOOTH_FONT
-D LOAD_FONT2
board_build.flash_mode=qio
board_build.arduino.memory_type = qio_opi
board_build.psram_type=qspi_opi
board_upload.maximum_size = 16777216
board_upload.maximum_ram_size = 327680
board_upload.flash_size = 16MB
; ----------------------------------------------------------------------------------------
; !!! this configuration expects an esp32
;
; ----------------------------------------------------------------------------------------
[env:Simple_AP]
board = esp32dev
board_build.partitions = default.csv
build_flags =
-D BUILD_ENV_NAME=$PIOENV
-D BUILD_TIME=$UNIX_TIME
-D CORE_DEBUG_LEVEL=0
-D SIMPLE_AP
-D FLASHER_AP_SS=5
-D FLASHER_AP_CLK=18
-D FLASHER_AP_MOSI=23
@@ -215,38 +199,76 @@ build_flags =
-D FLASHER_AP_TXD=17
-D FLASHER_AP_RXD=16
-D FLASHER_LED=22
-D USER_SETUP_LOADED
-D DISABLE_ALL_LIBRARY_WARNINGS
-D ILI9341_DRIVER
-D SMOOTH_FONT
-D LOAD_FONT2
build_src_filter =
+<*>-<usbflasher.cpp>-<serialconsole.cpp>
; ----------------------------------------------------------------------------------------
; !!! this configuration expects the alternative 2.9" Flasher PCB
; ----------------------------------------------------------------------------------------
[env:Alternative_PCB]
board = esp32dev
board_build.partitions = no_ota.csv
; ----------------------------------------------------------------------------------------
; !!! this configuration expects an wemos_d1_mini32
;
; ----------------------------------------------------------------------------------------
[env:Weemos_AP]
board = wemos_d1_mini32
board_build.partitions = default.csv
build_flags =
-D BUILD_ENV_NAME=$PIOENV
-D BUILD_TIME=$UNIX_TIME
-D ALTERNATIVE_PCB
-D FLASHER_AP_SS=22
-D FLASHER_AP_CLK=13
-D CORE_DEBUG_LEVEL=0
-D FLASHER_AP_SS=5
-D FLASHER_AP_CLK=18
-D FLASHER_AP_MOSI=23
-D FLASHER_AP_MISO=33
-D FLASHER_AP_RESET=27
-D FLASHER_AP_POWER={4}
-D FLASHER_AP_MISO=19
-D FLASHER_AP_RESET=14
-D FLASHER_AP_POWER={-1}
-D FLASHER_AP_TEST=-1
-D FLASHER_AP_TXD=26
-D FLASHER_AP_RXD=25
-D FLASHER_LED=19
-D FLASHER_AP_TXD=16
-D FLASHER_AP_RXD=17
-D FLASHER_LED=22
-D USER_SETUP_LOADED
-D DISABLE_ALL_LIBRARY_WARNINGS
-D ILI9341_DRIVER
-D SMOOTH_FONT
-D LOAD_FONT2
build_src_filter =
+<*>-<usbflasher.cpp>-<serialconsole.cpp>
; ----------------------------------------------------------------------------------------
; !!! this configuration expects an m5stack esp32
;
; ----------------------------------------------------------------------------------------
[env:M5Stack_Core_ONE_AP]
platform = espressif32
board = m5stack-core-esp32
board_build.partitions = esp32_sdcard.csv
build_flags =
-D BUILD_ENV_NAME=$PIOENV
-D BUILD_TIME=$UNIX_TIME
-D CORE_DEBUG_LEVEL=0
-D HAS_SDCARD
-D USE_SOFTSPI
-D SD_CARD_SS=4
-D SD_CARD_CLK=18
-D SD_CARD_MISO=19
-D SD_CARD_MOSI=23
-D FLASHER_AP_SS=5
-D FLASHER_AP_CLK=36
-D FLASHER_AP_MOSI=26
-D FLASHER_AP_MISO=35
-D FLASHER_AP_RESET=2
-D FLASHER_AP_POWER={-1}
-D FLASHER_AP_TEST=-1
-D FLASHER_AP_TXD=16
-D FLASHER_AP_RXD=17
-D FLASHER_LED=-1
-D FLASH_TIMEOUT=10
-D USER_SETUP_LOADED
-D DISABLE_ALL_LIBRARY_WARNINGS
-D ILI9341_DRIVER
-D SMOOTH_FONT
-D LOAD_FONT2
build_src_filter =
+<*>-<usbflasher.cpp>-<serialconsole.cpp>

View File

@@ -13,7 +13,7 @@
#ifdef CONTENT_RSS
#include <rssClass.h>
#endif
#include <LittleFS.h>
#include "storage.h"
#include <time.h>
#include <map>
@@ -143,7 +143,7 @@ void drawNew(uint8_t mac[8], bool buttonPressed, tagRecord *&taginfo) {
if (imageParams.hasRed) imageParams.dataType = DATATYPE_IMG_RAW_2BPP;
if (prepareDataAvail(&filename, imageParams.dataType, mac, cfgobj["timetolive"].as<int>())) {
cfgobj["#fetched"] = true;
if (cfgobj["delete"].as<String>() == "1") LittleFS.remove("/" + cfgobj["filename"].as<String>());
if (cfgobj["delete"].as<String>() == "1") contentFS->remove("/" + cfgobj["filename"].as<String>());
} else {
wsErr("Error accessing " + filename);
}
@@ -323,7 +323,7 @@ void drawString(TFT_eSprite &spr, String content, uint16_t posx, uint16_t posy,
spr.setTextColor(PAL_BLACK, PAL_WHITE);
spr.drawString(content, posx, posy);
} else {
if (font != "") spr.loadFont(font, LittleFS);
if (font != "") spr.loadFont(font, *contentFS);
spr.setTextColor(color, PAL_WHITE);
spr.drawString(content, posx, posy);
if (font != "") spr.unloadFont();
@@ -420,7 +420,7 @@ void drawNumber(String &filename, int32_t count, int32_t thresholdred, tagRecord
if (count > 99) font = loc["fonts"][1].as<String>();
if (count > 999) font = loc["fonts"][2].as<String>();
if (count > 9999) font = loc["fonts"][3].as<String>();
spr.loadFont(font, LittleFS);
spr.loadFont(font, *contentFS);
spr.drawString(String(count), loc["xy"][0].as<uint16_t>(), loc["xy"][1].as<uint16_t>());
spr.unloadFont();
@@ -505,7 +505,7 @@ void drawWeather(String &filename, JsonObject &cfgobj, tagRecord *&taginfo, imgP
dtostrf(temperature, 2, 1, tmpOutput);
drawString(spr, String(tmpOutput), loc["temp"][0], loc["temp"][1], loc["temp"][2], TL_DATUM, (temperature < 0 ? PAL_RED : PAL_BLACK));
spr.loadFont(loc["icon"][2], LittleFS);
spr.loadFont(loc["icon"][2], *contentFS);
if (weathercode == 55 || weathercode == 65 || weathercode == 75 || weathercode == 82 || weathercode == 86 || weathercode == 95 || weathercode == 99) {
spr.setTextColor(PAL_RED, PAL_WHITE);
} else {
@@ -515,7 +515,7 @@ void drawWeather(String &filename, JsonObject &cfgobj, tagRecord *&taginfo, imgP
spr.printToSprite(weatherIcons[weathercode]);
spr.unloadFont();
spr.loadFont(loc["dir"][2], LittleFS);
spr.loadFont(loc["dir"][2], *contentFS);
spr.setTextColor(PAL_BLACK, PAL_WHITE);
spr.setCursor(loc["dir"][0], loc["dir"][1]);
spr.printToSprite(windDirectionIcon(winddirection));
@@ -578,7 +578,7 @@ void drawForecast(String &filename, JsonObject &cfgobj, tagRecord *&taginfo, img
uint8_t weathercode = doc["daily"]["weathercode"][dag].as<int>();
if (weathercode > 40) weathercode -= 40;
spr.loadFont(loc["icon"][2], LittleFS);
spr.loadFont(loc["icon"][2], *contentFS);
if (weathercode == 55 || weathercode == 65 || weathercode == 75 || weathercode == 82 || weathercode == 86 || weathercode == 95 || weathercode == 99) {
spr.setTextColor(PAL_RED, PAL_WHITE);
} else {
@@ -597,7 +597,7 @@ void drawForecast(String &filename, JsonObject &cfgobj, tagRecord *&taginfo, img
int8_t tmax = round(doc["daily"]["temperature_2m_max"][dag].as<double>());
uint8_t wind = windSpeedToBeaufort(doc["daily"]["windspeed_10m_max"][dag].as<double>());
spr.loadFont(loc["day"][2], LittleFS);
spr.loadFont(loc["day"][2], *contentFS);
if (loc["rain"]) {
int8_t rain = round(doc["daily"]["precipitation_sum"][dag].as<double>());
@@ -624,7 +624,7 @@ void drawForecast(String &filename, JsonObject &cfgobj, tagRecord *&taginfo, img
int getImgURL(String &filename, String URL, time_t fetched, imgParam &imageParams, String MAC) {
// https://images.klari.net/kat-bw29.jpg
LittleFS.begin();
Storage.begin();
Serial.println("get external " + URL);
HTTPClient http;
@@ -634,7 +634,7 @@ int getImgURL(String &filename, String URL, time_t fetched, imgParam &imageParam
http.setTimeout(5000); // timeout in ms
int httpCode = http.GET();
if (httpCode == 200) {
File f = LittleFS.open("/temp/temp.jpg", "w");
File f = contentFS->open("/temp/temp.jpg", "w");
if (f) {
http.writeToStream(&f);
f.close();
@@ -796,7 +796,7 @@ void drawQR(String &filename, String qrcontent, String title, tagRecord *&taginf
#ifdef CONTENT_QR
TFT_eSPI tft = TFT_eSPI();
TFT_eSprite spr = TFT_eSprite(&tft);
LittleFS.begin();
Storage.begin();
const char *text = qrcontent.c_str();
QRCode qrcode;
@@ -1031,7 +1031,7 @@ void prepareConfigFile(uint8_t *dst, JsonObject config) {
}
void getTemplate(JsonDocument &json, const char *filePath, uint8_t id, uint8_t hwtype) {
File jsonFile = LittleFS.open(filePath, "r");
File jsonFile = contentFS->open(filePath, "r");
if (!jsonFile) {
Serial.println("Failed to open content template file " + String(filePath));
return;

View File

@@ -2,7 +2,8 @@
#include <Arduino.h>
#include <ArduinoJson.h>
#include <LittleFS.h>
#include "storage.h"
#include "LittleFS.h"
#include <MD5Builder.h>
// #include <FS.h>
@@ -109,24 +110,29 @@ class flasher {
flasher::flasher() {
zbs = new ZBS_interface;
Storage.end();
}
flasher::~flasher() {
delete zbs;
Storage.begin();
}
#ifndef FLASHER_AP_SPEED
#define FLASHER_AP_SPEED 4000000
#endif
bool flasher::connectTag(uint8_t port) {
bool result;
switch (port) {
case 0:
result = zbs->begin(FLASHER_AP_SS, FLASHER_AP_CLK, FLASHER_AP_MOSI, FLASHER_AP_MISO, FLASHER_AP_RESET, (uint8_t *)powerPinsAP, sizeof(powerPinsAP), 8000000);
result = zbs->begin(FLASHER_AP_SS, FLASHER_AP_CLK, FLASHER_AP_MOSI, FLASHER_AP_MISO, FLASHER_AP_RESET, (uint8_t *)powerPinsAP, sizeof(powerPinsAP), FLASHER_AP_SPEED);
break;
#ifdef OPENEPAPERLINK_PCB
case 1:
result = zbs->begin(FLASHER_EXT_SS, FLASHER_EXT_CLK, FLASHER_EXT_MOSI, FLASHER_EXT_MISO, FLASHER_EXT_RESET, (uint8_t *)powerPinsExt, sizeof(powerPinsExt), 8000000);
result = zbs->begin(FLASHER_EXT_SS, FLASHER_EXT_CLK, FLASHER_EXT_MOSI, FLASHER_EXT_MISO, FLASHER_EXT_RESET, (uint8_t *)powerPinsExt, sizeof(powerPinsExt), FLASHER_AP_SPEED);
break;
case 2:
result = zbs->begin(FLASHER_ALT_SS, FLASHER_ALT_CLK, FLASHER_ALT_MOSI, FLASHER_ALT_MISO, FLASHER_ALT_RESET, (uint8_t *)powerPinsAlt, sizeof(powerPinsAlt), 8000000);
result = zbs->begin(FLASHER_ALT_SS, FLASHER_ALT_CLK, FLASHER_ALT_MOSI, FLASHER_ALT_MISO, FLASHER_ALT_RESET, (uint8_t *)powerPinsAlt, sizeof(powerPinsAlt), FLASHER_AP_SPEED);
break;
#endif
default:
@@ -206,7 +212,7 @@ bool flasher::getInfoBlockType() {
bool flasher::findTagByMD5() {
StaticJsonDocument<3000> doc;
DynamicJsonDocument APconfig(600);
fs::File readfile = LittleFS.open("/tag_md5_db.json", "r");
fs::File readfile = contentFS->open("/tag_md5_db.json", "r");
DeserializationError err = deserializeJson(doc, readfile);
if (!err) {
for (JsonObject elem : doc.as<JsonArray>()) {
@@ -236,7 +242,7 @@ bool flasher::findTagByMD5() {
bool flasher::findTagByType(uint8_t type) {
StaticJsonDocument<3000> doc;
DynamicJsonDocument APconfig(600);
fs::File readfile = LittleFS.open("/tag_md5_db.json", "r");
fs::File readfile = contentFS->open("/tag_md5_db.json", "r");
DeserializationError err = deserializeJson(doc, readfile);
if (!err) {
for (JsonObject elem : doc.as<JsonArray>()) {
@@ -300,7 +306,7 @@ bool flasher::backupFlash() {
getFirmwareMD5();
if (!zbs->select_flash(0)) return false;
md5char[16] = 0x00;
fs::File backup = LittleFS.open("/" + (String)md5char + "_backup.bin", "w", true);
fs::File backup = contentFS->open("/" + (String)md5char + "_backup.bin", "w", true);
for (uint32_t c = 0; c < 65535; c++) {
backup.write(zbs->read_flash(c));
}
@@ -474,7 +480,7 @@ bool flasher::writeFlashFromPackOffset(fs::File *file, uint16_t length) {
bool flasher::writeFlashFromPack(String filename, uint8_t type) {
StaticJsonDocument<512> doc;
DynamicJsonDocument APconfig(512);
fs::File readfile = LittleFS.open(filename, "r");
fs::File readfile = contentFS->open(filename, "r");
DeserializationError err = deserializeJson(doc, readfile);
if (!err) {
for (JsonObject elem : doc.as<JsonArray>()) {
@@ -505,7 +511,7 @@ bool flasher::writeFlashFromPack(String filename, uint8_t type) {
uint16_t getAPUpdateVersion(uint8_t type) {
StaticJsonDocument<512> doc;
DynamicJsonDocument APconfig(512);
fs::File readfile = LittleFS.open("/AP_FW_Pack.bin", "r");
fs::File readfile = contentFS->open("/AP_FW_Pack.bin", "r");
DeserializationError err = deserializeJson(doc, readfile);
if (!err) {
for (JsonObject elem : doc.as<JsonArray>()) {
@@ -529,7 +535,7 @@ uint16_t getAPUpdateVersion(uint8_t type) {
}
bool checkForcedAPFlash() {
return LittleFS.exists("/AP_force_flash.bin");
return contentFS->exists("/AP_force_flash.bin");
}
bool doForcedAPFlash() {
@@ -547,14 +553,14 @@ bool doForcedAPFlash() {
f->writeInfoBlock();
}
fs::File readfile = LittleFS.open("/AP_force_flash.bin", "r");
fs::File readfile = contentFS->open("/AP_force_flash.bin", "r");
bool res = f->writeFlashFromPackOffset(&readfile, readfile.size());
#ifdef HAS_RGB_LED
if (res) addFadeColor(CRGB::Green);
if (!res) addFadeColor(CRGB::Red);
#endif
readfile.close();
if (res) LittleFS.remove("/AP_force_flash.bin");
if (res) contentFS->remove("/AP_force_flash.bin");
f->zbs->reset();
delete f;
return res;

View File

@@ -263,10 +263,12 @@ void ledTask(void* parameter) {
ledQueue = xQueueCreate(30, sizeof(struct ledInstruction*));
digitalWrite(FLASHER_LED, HIGH);
pinMode(FLASHER_LED, OUTPUT);
ledcSetup(7, 5000, 8);
ledcAttachPin(FLASHER_LED, 7);
if (FLASHER_LED != -1) {
digitalWrite(FLASHER_LED, HIGH);
pinMode(FLASHER_LED, OUTPUT);
ledcAttachPin(FLASHER_LED, 7);
}
struct ledInstruction* monoled = nullptr;

View File

@@ -1,8 +1,10 @@
#include <Arduino.h>
#include <WiFi.h>
#include <WiFiManager.h>
#include <time.h>
#include "storage.h"
#include "contentmanager.h"
#include "flasher.h"
#include "makeimage.h"
@@ -33,12 +35,15 @@ void delayedStart(void* parameter) {
void timeTask(void* parameter) {
wsSendSysteminfo();
Serial.printf("Free heap: %.2f KB\n", ESP.getFreeHeap() / 1024.0f);
while (1) {
time_t now;
time(&now);
if (now % 5 == 0 || apInfo.state != AP_STATE_ONLINE || config.runStatus != RUNSTATUS_RUN) wsSendSysteminfo();
if (now % 5 == 0) Serial.printf("Free heap: %.2f KB\n", ESP.getFreeHeap() / 1024.0f);
if (now % 300 == 6 && config.runStatus != RUNSTATUS_STOP) saveDB("/current/tagDB.json");
if (apInfo.state == AP_STATE_ONLINE) contentRunner();
vTaskDelay(1000 / portTICK_PERIOD_MS);
@@ -84,6 +89,8 @@ void setup() {
heap_caps_malloc_extmem_enable(64);
#endif
Storage.begin();
/*
Serial.println("\n\n##################################");
Serial.printf("Internal Total heap %d, internal Free Heap %d\n", ESP.getHeapSize(), ESP.getFreeHeap());

View File

@@ -1,6 +1,6 @@
#include <Arduino.h>
#include <FS.h>
#include <LittleFS.h>
#include "storage.h"
#include <TFT_eSPI.h>
#include <TJpg_Decoder.h>
#include <makeimage.h>
@@ -15,7 +15,7 @@ bool spr_output(int16_t x, int16_t y, uint16_t w, uint16_t h, uint16_t *bitmap)
}
void jpg2buffer(String filein, String fileout, imgParam &imageParams) {
LittleFS.begin();
Storage.begin();
TJpgDec.setSwapBytes(true);
TJpgDec.setJpgScale(1);
TJpgDec.setCallback(spr_output);
@@ -23,7 +23,7 @@ void jpg2buffer(String filein, String fileout, imgParam &imageParams) {
if (filein.c_str()[0] != '/') {
filein = "/" + filein;
}
TJpgDec.getFsJpgSize(&w, &h, filein, LittleFS);
TJpgDec.getFsJpgSize(&w, &h, filein, *contentFS);
if (w==0 && h==0) {
wsErr("invalid jpg");
return;
@@ -47,7 +47,7 @@ void jpg2buffer(String filein, String fileout, imgParam &imageParams) {
wsErr("Failed to create sprite in jpg2buffer");
} else {
spr.fillSprite(TFT_WHITE);
TJpgDec.drawFsJpg(0, 0, filein, LittleFS);
TJpgDec.drawFsJpg(0, 0, filein, *contentFS);
spr2buffer(spr, fileout, imageParams);
spr.deleteSprite();
@@ -74,11 +74,7 @@ uint32_t colorDistance(const Color &c1, const Color &c2, const Error &e1) {
return 3 * r_diff * r_diff + 6 * g_diff * g_diff + 1 * b_diff * b_diff;
}
void spr2buffer(TFT_eSprite &spr, String &fileout, imgParam &imageParams) {
long t = millis();
LittleFS.begin();
fs::File f_out = LittleFS.open(fileout, "w");
uint8_t *spr2color(TFT_eSprite &spr, imgParam &imageParams, size_t *buffer_size, bool is_red) {
bool dither = true;
uint8_t rotate = imageParams.rotate;
@@ -90,11 +86,13 @@ void spr2buffer(TFT_eSprite &spr, String &fileout, imgParam &imageParams) {
bufh = spr.width();
}
int bufferSize = (bufw * bufh) / 8;
uint8_t *blackBuffer = new uint8_t[bufferSize];
uint8_t *redBuffer = new uint8_t[bufferSize];
memset(blackBuffer, 0, bufferSize);
memset(redBuffer, 0, bufferSize);
*buffer_size = (bufw * bufh) / 8;
uint8_t *buffer = (uint8_t*) malloc(*buffer_size);
if (!buffer) {
Serial.println("Fallied to allocated buffer");
return nullptr;
}
memset(buffer, 0, *buffer_size);
std::vector<Color> palette = {
{255, 255, 255}, // White
@@ -147,15 +145,16 @@ void spr2buffer(TFT_eSprite &spr, String &fileout, imgParam &imageParams) {
// this looks a bit ugly, but it's performing better than shorter notations
switch (best_color_index) {
case 1:
blackBuffer[byteIndex] |= (1 << bitIndex);
if(!is_red)
buffer[byteIndex] |= (1 << bitIndex);
break;
case 2:
imageParams.hasRed = true;
redBuffer[byteIndex] |= (1 << bitIndex);
if(is_red)
buffer[byteIndex] |= (1 << bitIndex);
break;
case 3:
blackBuffer[byteIndex] |= (1 << bitIndex);
redBuffer[byteIndex] |= (1 << bitIndex);
buffer[byteIndex] |= (1 << bitIndex);
imageParams.hasRed = true;
break;
}
@@ -199,14 +198,32 @@ void spr2buffer(TFT_eSprite &spr, String &fileout, imgParam &imageParams) {
}
memcpy(error_bufferold, error_buffernew, bufw * sizeof(Error));
}
delete[] error_buffernew;
delete[] error_bufferold;
f_out.write(blackBuffer, bufferSize);
if (imageParams.hasRed) f_out.write(redBuffer, bufferSize);
return buffer;
}
delete[] blackBuffer;
delete[] redBuffer;
void spr2buffer(TFT_eSprite &spr, String &fileout, imgParam &imageParams) {
long t = millis();
Storage.begin();
fs::File f_out = contentFS->open(fileout, "w");
size_t bufferSize;
uint8_t *blackBuffer = (uint8_t*) spr2color(spr, imageParams, &bufferSize, false);
if(!blackBuffer)
return;
f_out.write(blackBuffer, bufferSize);
free(blackBuffer);
if (imageParams.hasRed) {
uint8_t *redBuffer = (uint8_t*) spr2color(spr, imageParams, &bufferSize, true);
if(!redBuffer)
return;
f_out.write(redBuffer, bufferSize);
free(redBuffer);
}
f_out.close();
Serial.println("finished writing buffer " + String(millis() - t) + "ms");

View File

@@ -3,12 +3,12 @@
#include <Arduino.h>
#include <FS.h>
#include <HTTPClient.h>
#include <LittleFS.h>
#include "storage.h"
#include <MD5Builder.h>
#include <makeimage.h>
#include <time.h>
#include "LittleFS.h"
#include "storage.h"
#include "commstructs.h"
#include "serialap.h"
#include "settings.h"
@@ -130,14 +130,14 @@ bool prepareDataAvail(String* filename, uint8_t dataType, uint8_t* dst, uint16_t
}
*filename = "/" + *filename;
LittleFS.begin();
Storage.begin();
if (!LittleFS.exists(*filename)) {
if (!contentFS->exists(*filename)) {
wsErr("File not found. " + *filename);
return false;
}
fs::File file = LittleFS.open(*filename);
fs::File file = contentFS->open(*filename);
uint32_t filesize = file.size();
if (filesize == 0) {
file.close();
@@ -161,8 +161,8 @@ bool prepareDataAvail(String* filename, uint8_t dataType, uint8_t* dst, uint16_t
if (memcmp(md5bytes, taginfo->md5pending, 16) == 0) {
wsLog("new image is the same as current or already pending image. not updating tag.");
wsSendTaginfo(dst, SYNC_TAGSTATUS);
if (LittleFS.exists(*filename)) {
LittleFS.remove(*filename);
if (contentFS->exists(*filename)) {
contentFS->remove(*filename);
}
return true;
}
@@ -182,10 +182,10 @@ bool prepareDataAvail(String* filename, uint8_t dataType, uint8_t* dst, uint16_t
if (dataType != DATATYPE_FW_UPDATE) {
char dst_path[64];
sprintf(dst_path, "/current/%02X%02X%02X%02X%02X%02X%02X%02X.pending\0", dst[7], dst[6], dst[5], dst[4], dst[3], dst[2], dst[1], dst[0]);
if (LittleFS.exists(dst_path)) {
LittleFS.remove(dst_path);
if (contentFS->exists(dst_path)) {
contentFS->remove(dst_path);
}
LittleFS.rename(*filename, dst_path);
contentFS->rename(*filename, dst_path);
*filename = String(dst_path);
wsLog("new image: " + String(dst_path));
@@ -241,7 +241,7 @@ void prepareExternalDataAvail(struct pendingData* pending, IPAddress remoteIP) {
case DATATYPE_IMG_RAW_1BPP:
case DATATYPE_IMG_RAW_2BPP:
case DATATYPE_IMG_RAW_1BPP_DIRECT: {
LittleFS.begin();
Storage.begin();
char hexmac[17];
mac2hex(pending->targetMac, hexmac);
@@ -252,13 +252,13 @@ void prepareExternalDataAvail(struct pendingData* pending, IPAddress remoteIP) {
http.begin(imageUrl);
int httpCode = http.GET();
if (httpCode == 200) {
File file = LittleFS.open(filename, "w");
File file = contentFS->open(filename, "w");
http.writeToStream(&file);
file.close();
}
http.end();
fs::File file = LittleFS.open(filename);
fs::File file = contentFS->open(filename);
uint32_t filesize = file.size();
if (filesize == 0) {
file.close();
@@ -338,7 +338,7 @@ void processBlockRequest(struct espBlockRequest* br) {
if (taginfo->data == nullptr) {
// not cached. open file, cache the data
fs::File file = LittleFS.open(taginfo->filename);
fs::File file = contentFS->open(taginfo->filename);
if (!file) {
Serial.print("No current file. Canceling request\n");
prepareCancelPending(br->src);
@@ -380,11 +380,15 @@ void processXferComplete(struct espXferComplete* xfc, bool local) {
char dst_path[64];
sprintf(src_path, "/current/%02X%02X%02X%02X%02X%02X%02X%02X.pending\0", xfc->src[7], xfc->src[6], xfc->src[5], xfc->src[4], xfc->src[3], xfc->src[2], xfc->src[1], xfc->src[0]);
sprintf(dst_path, "/current/%02X%02X%02X%02X%02X%02X%02X%02X.raw\0", xfc->src[7], xfc->src[6], xfc->src[5], xfc->src[4], xfc->src[3], xfc->src[2], xfc->src[1], xfc->src[0]);
if (LittleFS.exists(dst_path) && LittleFS.exists(src_path)) {
LittleFS.remove(dst_path);
if (contentFS->exists(dst_path) && contentFS->exists(src_path)) {
contentFS->remove(dst_path);
}
if (LittleFS.exists(src_path)) {
LittleFS.rename(src_path, dst_path);
if (contentFS->exists(src_path)) {
#ifndef REMOVE_RAW
contentFS->rename(src_path, dst_path);
#else
contentFS->remove(src_path);
#endif
}
time_t now;
@@ -396,8 +400,8 @@ void processXferComplete(struct espXferComplete* xfc, bool local) {
clearPending(taginfo);
taginfo->wakeupReason = 0;
if (taginfo->contentMode == 12 && local == false) {
if (LittleFS.exists(dst_path)) {
LittleFS.remove(dst_path);
if (contentFS->exists(dst_path)) {
contentFS->remove(dst_path);
}
}
}

View File

@@ -4,7 +4,7 @@
#include <ArduinoJson.h>
#include <FS.h>
#include <HTTPClient.h>
#include <LittleFS.h>
#include "storage.h"
#include <MD5Builder.h>
#include <Update.h>
@@ -51,7 +51,7 @@ void handleCheckFile(AsyncWebServerRequest* request) {
}
String filePath = request->getParam("path")->value();
File file = LittleFS.open(filePath, "r");
File file = contentFS->open(filePath, "r");
if (!file) {
StaticJsonDocument<64> doc;
doc["filesize"] = 0;
@@ -121,7 +121,7 @@ void handleLittleFSUpload(AsyncWebServerRequest* request, String filename, size_
} else {
path = request->getParam("path", true)->value();
Serial.println("update " + path);
request->_tempFile = LittleFS.open(path, "w", true);
request->_tempFile = contentFS->open(path, "w", true);
}
}
if (len) {
@@ -268,7 +268,7 @@ void handleRollback(AsyncWebServerRequest* request) {
void handleUpdateActions(AsyncWebServerRequest* request) {
wsSerial("Performing cleanup");
File file = LittleFS.open("/update_actions.json", "r");
File file = contentFS->open("/update_actions.json", "r");
if (!file) {
wsSerial("No update_actions.json present");
request->send(200, "No update actions needed");
@@ -278,12 +278,12 @@ void handleUpdateActions(AsyncWebServerRequest* request) {
DeserializationError error = deserializeJson(doc, file);
JsonArray deleteFiles = doc["deletefile"].as<JsonArray>();
for (const auto& filePath : deleteFiles) {
if (LittleFS.remove(filePath.as<const char*>())) {
if (contentFS->remove(filePath.as<const char*>())) {
wsSerial("deleted file: " + filePath.as<String>());
}
}
file.close();
wsSerial("Cleanup finished");
request->send(200, "Clean up finished");
LittleFS.remove("/update_actions.json");
contentFS->remove("/update_actions.json");
}

View File

@@ -2,7 +2,6 @@
#include <Arduino.h>
#include <HardwareSerial.h>
#include <LittleFS.h>
#include "commstructs.h"
#include "flasher.h"
@@ -10,6 +9,7 @@
#include "newproto.h"
#include "powermgt.h"
#include "settings.h"
#include "storage.h"
#include "web.h"
#include "zbs_interface.h"
@@ -205,6 +205,7 @@ bool sendDataAvail(struct pendingData* pending) {
}
if (waitCmdReply()) goto sdasend;
Serial.printf("SDA send failed in try %d\n", attempt);
delay(200);
}
Serial.print("SDA failed to send...\n");
txEnd();
@@ -687,6 +688,10 @@ void APTask(void* parameter) {
}
refreshAllPending();
} else {
#ifndef FLASH_TIMEOUT
#define FLASH_TIMEOUT 30
#endif
// AP unavailable, maybe time to flash?
apInfo.isOnline = false;
apInfo.state = AP_STATE_OFFLINE;
@@ -694,8 +699,8 @@ void APTask(void* parameter) {
Serial.printf("This could be the first time this AP is booted and the AP-tag may be unflashed. We'll try to flash it!\n");
Serial.printf("If this tag was previously flashed succesfully but this message still shows up, there's probably something wrong with the serial connections.\n");
Serial.printf("The build of this firmware expects an AP tag with TXD/RXD on ESP32 pins %d and %d, does this match with your wiring?\n", FLASHER_AP_RXD, FLASHER_AP_TXD);
Serial.println("Performing firmware flash in about 30 seconds!\n");
flashCountDown(30);
Serial.printf("Performing firmware flash in about %d seconds!\n", FLASH_TIMEOUT);
flashCountDown(FLASH_TIMEOUT);
if (doAPFlash()) {
checkWaitPowerCycle();
if (bringAPOnline()) {
@@ -747,6 +752,15 @@ void APTask(void* parameter) {
#endif
Serial.println("Please verify your wiring and try again!");
}
#ifdef HAS_SDCARD
if (SD_CARD_CLK == FLASHER_AP_CLK ||
SD_CARD_MISO == FLASHER_AP_MISO ||
SD_CARD_MOSI == FLASHER_AP_MOSI) {
Serial.println("Reseting in 30 seconds to restore SPI state!\n");
flashCountDown(30);
ESP.restart();
}
#endif
}
uint8_t attempts = 0;

View File

@@ -0,0 +1,215 @@
#include "storage.h"
#ifdef HAS_SDCARD
#include "FS.h"
#include "SD.h"
#include "SPI.h"
#endif
#include "LittleFS.h"
DynStorage::DynStorage() : isInited(0) {}
static void initLittleFS() {
LittleFS.begin();
contentFS = &LittleFS;
}
#ifdef HAS_SDCARD
static SPIClass* spi;
static void initSDCard() {
uint8_t spi_bus = VSPI;
// SD.begin and spi.begin are allocating memory so we dont want to do that
if(!spi) {
spi = new SPIClass(spi_bus);
spi->begin(SD_CARD_CLK, SD_CARD_MISO, SD_CARD_MOSI, SD_CARD_SS);
bool res = SD.begin(SD_CARD_SS, *spi, 40000000);
if (!res) {
Serial.println("Card Mount Failed");
return;
}
}
uint8_t cardType = SD.cardType();
if (cardType == CARD_NONE) {
Serial.println("No SD card attached");
return;
}
contentFS = &SD;
}
#endif
size_t DynStorage::freeSpace(){
this->begin();
#ifdef HAS_SDCARD
return SD.totalBytes() - SD.usedBytes();
#endif
return LittleFS.totalBytes() - LittleFS.usedBytes();
}
void copyFile(File in, File out) {
Serial.print("Copying ");
Serial.print(in.path());
Serial.print(" to ");
Serial.println(out.path());
size_t n;
uint8_t buf[64];
while ((n = in.read(buf, sizeof(buf))) > 0) {
out.write(buf, n);
}
}
void copyBetweenFS(FS& sourceFS, const char* source_path, FS& targetFS) {
File root = sourceFS.open(source_path);
char next_path[128];
if (root.isDirectory()) {
if (!contentFS->exists(root.path())) {
if (!contentFS->mkdir(root.path())) {
Serial.print("Failed to create directory ");
Serial.println(root.path());
return;
}
}
File file = root.openNextFile();
while (file) {
if (file.isDirectory()) {
sprintf(next_path, "%s/%s\0", root.path(), file.path());
copyBetweenFS(sourceFS, file.path(), targetFS);
} else {
File target = contentFS->open(file.path(), "w");
if (target) {
copyFile(file, target);
target.close();
file.close();
} else {
Serial.print("Couldn't create high target file");
Serial.println(file.path());
return;
}
}
file = root.openNextFile();
}
} else {
File target = contentFS->open(root.path(), "w");
if (target) {
copyFile(root, target);
} else {
Serial.print("Couldn't create target file ");
Serial.println(root.path());
return;
}
}
}
#ifdef HAS_SDCARD
void copyIfNeeded(const char* path) {
if (!contentFS->exists(path) && LittleFS.exists(path)) {
Serial.printf("SDCard does not contain %s, littleFS does, copying\n", path);
copyBetweenFS(LittleFS, path, *contentFS);
}
}
#endif
void DynStorage::begin() {
initLittleFS();
#ifdef HAS_SDCARD
initSDCard();
copyIfNeeded("/index.html");
copyIfNeeded("/fonts");
copyIfNeeded("/www");
copyIfNeeded("/AP_FW_Pack.bin");
copyIfNeeded("/tag_md5_db.json");
copyIfNeeded("/update_actions.json");
copyIfNeeded("/content_template.json");
#endif
if (!contentFS->exists("/current")) {
contentFS->mkdir("/current");
}
if (!contentFS->exists("/temp")) {
contentFS->mkdir("/temp");
}
}
void DynStorage::end() {
#ifdef HAS_SDCARD
initLittleFS();
if (SD_CARD_CLK == FLASHER_AP_CLK ||
SD_CARD_MISO == FLASHER_AP_MISO ||
SD_CARD_MOSI == FLASHER_AP_MOSI) {
Serial.println("Tearing down SD card connection");
copyBetweenFS(*contentFS, "/tag_md5_db.json", LittleFS);
copyBetweenFS(*contentFS, "/AP_FW_Pack.bin", LittleFS);
if (contentFS->exists("/AP_force_flash.bin")) {
copyBetweenFS(*contentFS, "/AP_force_flash.bin", LittleFS);
contentFS->remove("/AP_force_flash.bin");
}
Serial.println("Swapping to LittleFS");
contentFS = &LittleFS;
}
#endif
}
void listDir(fs::FS& fs, const char* dirname, uint8_t levels) {
Storage.begin();
// Print blank line on screen
Serial.printf(" \n ");
Serial.printf("Listing directory: %s\n", dirname);
File root = fs.open(dirname);
if (!root) {
Serial.println("Failed to open directory");
return;
}
if (!root.isDirectory()) {
Serial.println("Not a directory");
return;
}
File file = root.openNextFile();
while (file) {
if (!strcmp("System Volume Information", file.name())) {
file = root.openNextFile();
continue;
}
if (file.isDirectory()) {
Serial.print(" DIR : ");
Serial.println(file.name());
if (levels) {
listDir(fs, file.path(), levels - 1);
}
Serial.println();
} else {
Serial.print(" FILE: ");
Serial.print(file.name());
Serial.print(" SIZE: ");
Serial.println(file.size());
}
file = root.openNextFile();
}
}
void DynStorage::listFiles() {
listDir(LittleFS, "/", 1);
#ifdef HAS_SDCARD
listDir(*contentFS, "/", 1);
#endif
}
fs::FS* contentFS;
DynStorage Storage;

View File

@@ -3,7 +3,7 @@
#include <Arduino.h>
#include <FS.h>
#include "LittleFS.h"
#include "storage.h"
void init_time() {
struct tm timeinfo;
@@ -28,7 +28,7 @@ void logLine(String text) {
char timeStr[24];
strftime(timeStr, sizeof(timeStr), "%Y-%m-%d %H:%M:%S ", localtime(&now));
File logFile = LittleFS.open("/log.txt", "a");
File logFile = contentFS->open("/log.txt", "a");
if (logFile) {
logFile.print(timeStr);
logFile.println(text);

View File

@@ -5,7 +5,7 @@
#include <FS.h>
#include <vector>
#include "LittleFS.h"
#include "storage.h"
#include "language.h"
std::vector<tagRecord*> tagDB;
@@ -126,8 +126,8 @@ void saveDB(String filename) {
long t = millis();
LittleFS.begin();
fs::File file = LittleFS.open(filename, "w");
Storage.begin();
fs::File file = contentFS->open(filename, "w");
if (!file) {
Serial.println("saveDB: Failed to open file");
return;
@@ -161,8 +161,8 @@ void loadDB(String filename) {
Serial.println("reading DB from file");
long t = millis();
LittleFS.begin();
fs::File readfile = LittleFS.open(filename, "r");
Storage.begin();
fs::File readfile = contentFS->open(filename, "r");
if (!readfile) {
Serial.println("loadDB: Failed to open file");
return;
@@ -264,9 +264,9 @@ void clearPending(tagRecord* taginfo) {
}
void initAPconfig() {
LittleFS.begin(true);
Storage.begin();
DynamicJsonDocument APconfig(500);
File configFile = LittleFS.open("/current/apconfig.json", "r");
File configFile = contentFS->open("/current/apconfig.json", "r");
if (configFile) {
DeserializationError error = deserializeJson(APconfig, configFile);
if (error) {
@@ -285,7 +285,7 @@ void initAPconfig() {
}
void saveAPconfig() {
fs::File configFile = LittleFS.open("/current/apconfig.json", "w");
fs::File configFile = contentFS->open("/current/apconfig.json", "w");
DynamicJsonDocument APconfig(500);
APconfig["channel"] = config.channel;
APconfig["alias"] = config.alias;

View File

@@ -6,8 +6,9 @@
#include <ESPAsyncWebServer.h>
#include <ESPmDNS.h>
#include <FS.h>
#include <LittleFS.h>
#include <SPIFFSEditor.h>
#include "storage.h"
#include "LittleFS.h"
#include "SPIFFSEditor.h"
#include <WiFi.h>
#include <WiFiManager.h> // https://github.com/tzapu/WiFiManager/tree/feature_asyncwebserver
@@ -135,7 +136,7 @@ void wsSendSysteminfo() {
sys["heap"] = ESP.getFreeHeap();
sys["recordcount"] = tagDB.size();
sys["dbsize"] = tagDB.size() * sizeof(tagRecord);
sys["littlefsfree"] = LittleFS.totalBytes() - LittleFS.usedBytes();
sys["littlefsfree"] = Storage.freeSpace();
sys["apstate"] = apInfo.state;
sys["runstate"] = config.runStatus;
@@ -215,15 +216,7 @@ uint8_t wsClientCount() {
}
void init_web() {
LittleFS.begin(true);
if (!LittleFS.exists("/current")) {
LittleFS.mkdir("/current");
}
if (!LittleFS.exists("/temp")) {
LittleFS.mkdir("/temp");
}
Storage.begin();
WiFi.mode(WIFI_STA);
WiFiManager wm;
@@ -243,8 +236,8 @@ void init_web() {
Serial.print("Connected! IP address: ");
Serial.println(WiFi.localIP());
// server.addHandler(new SPIFFSEditor(LittleFS, http_username, http_password));
server.addHandler(new SPIFFSEditor(LittleFS));
// server.addHandler(new SPIFFSEditor(*contentFS, http_username, http_password));
server.addHandler(new SPIFFSEditor(*contentFS));
ws.onEvent(onEvent);
server.addHandler(&ws);
@@ -260,8 +253,8 @@ void init_web() {
ESP.restart();
});
server.serveStatic("/current", LittleFS, "/current/");
server.serveStatic("/", LittleFS, "/www/").setDefaultFile("index.html");
server.serveStatic("/current", *contentFS, "/current/");
server.serveStatic("/", *contentFS, "/www/").setDefaultFile("index.html");
server.on(
"/imgupload", HTTP_POST, [](AsyncWebServerRequest *request) {
@@ -371,7 +364,7 @@ void init_web() {
server.on("/get_ap_config", HTTP_GET, [](AsyncWebServerRequest *request) {
UDPcomm udpsync;
udpsync.getAPList();
File configFile = LittleFS.open("/current/apconfig.json", "r");
File configFile = contentFS->open("/current/apconfig.json", "r");
if (!configFile) {
request->send(500, "text/plain", "Error opening apconfig.json file");
return;
@@ -411,7 +404,7 @@ void init_web() {
server.on("/backup_db", HTTP_GET, [](AsyncWebServerRequest *request) {
saveDB("/current/tagDB.json");
File file = LittleFS.open("/current/tagDB.json", "r");
File file = contentFS->open("/current/tagDB.json", "r");
AsyncWebServerResponse *response = request->beginResponse(file, "tagDB.json", String(), true);
request->send(response);
file.close();
@@ -449,7 +442,7 @@ void doImageUpload(AsyncWebServerRequest *request, String filename, size_t index
} else {
filename = "unknown.jpg";
}
request->_tempFile = LittleFS.open("/" + filename, "w");
request->_tempFile = contentFS->open("/" + filename, "w");
}
if (len) {
// stream the incoming chunk to the opened file

View File

@@ -7,6 +7,10 @@
#include <stdint.h>
#include <stdio.h>
#ifdef USE_SOFTSPI
#include <SoftSPI.h>
#endif
#include "powermgt.h"
uint8_t ZBS_interface::begin(uint8_t SS, uint8_t CLK, uint8_t MOSI, uint8_t MISO, uint8_t RESET, uint8_t* POWER, uint8_t powerPins, uint32_t spi_speed) {
@@ -27,7 +31,12 @@ uint8_t ZBS_interface::begin(uint8_t SS, uint8_t CLK, uint8_t MOSI, uint8_t MISO
digitalWrite(_CLK_PIN, LOW);
digitalWrite(_MOSI_PIN, HIGH);
#ifdef USE_SOFTSPI
if (!spi) spi = new SoftSPI(_MOSI_PIN, _MISO_PIN, _CLK_PIN);
#else
if (!spi) spi = new SPIClass(HSPI);
#endif
spiSettings = SPISettings(spi_speed, MSBFIRST, SPI_MODE0);
spi_ready = 0;

Binary file not shown.

After

Width:  |  Height:  |  Size: 233 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 344 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 565 KiB

View File

@@ -0,0 +1,16 @@
# 3D-printed ESP32-S2 Mini NanoAP with Flex PCB
## NanoAP by [ATC1441](https://github.com/atc1441)
The NanoAP is build by using an 1.54" Display with an ZBS243 SoC and an ESP32 S2-Mini Dev-board(2MB SRAM Version)
The Flex PCB does also fit on the 2.9" Display, the case will not fit then :D
<img width="600" alt="NanoAP_Case" src="NanoAP_Case.jpg">
<img width="600" alt="NanoAP_PCB_soldered" src="NanoAP_PCB_soldered.jpg">
<img width="600" alt="NanoAP_Flapped" src="NanoAP_Flapped.jpg">
- The "NanoAP_Case_V3.stl" Case is printed in one go standing up, 0.2mm Layer height no support, infill 20%
- The Flex PCB can be ordered via the Gerber File "NanoAP_Gerber.rar"
- The Antenna from the Original case needs to be replaced by either a ~3cm wire or the "Antenna_FlexPCB_Gerber.rar"

Binary file not shown.