mirror of
https://github.com/OpenEPaperLink/OpenEPaperLink.git
synced 2026-03-22 05:07:05 +01:00
Compare commits
44 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a251ed10e7 | ||
|
|
65410e3e8d | ||
|
|
b2174c2980 | ||
|
|
7db482a6ba | ||
|
|
bac7cf7ab5 | ||
|
|
a3e739b8da | ||
|
|
cc1dcd9d29 | ||
|
|
10468313e1 | ||
|
|
2e55c49a92 | ||
|
|
e45845e00e | ||
|
|
940795d05d | ||
|
|
a3fc1da6d2 | ||
|
|
d778aab553 | ||
|
|
f460046c51 | ||
|
|
e5ddba02ff | ||
|
|
7ba80f57c9 | ||
|
|
d6feb5a8ca | ||
|
|
1e034c83fa | ||
|
|
1e93a24b53 | ||
|
|
dbf76e2176 | ||
|
|
93639ff8ac | ||
|
|
48b2925b9f | ||
|
|
9c83d8b5a5 | ||
|
|
f487092f7f | ||
|
|
eae7c3a159 | ||
|
|
4d78df09cc | ||
|
|
e8740b2022 | ||
|
|
6c4e254db0 | ||
|
|
5ccbcb4719 | ||
|
|
617b49eb86 | ||
|
|
5868abf189 | ||
|
|
94be1ea3aa | ||
|
|
5190327d5a | ||
|
|
6ecf6410ee | ||
|
|
e72e89d85e | ||
|
|
054146677f | ||
|
|
58d9fe2217 | ||
|
|
205dfa0ce2 | ||
|
|
5c7b53b740 | ||
|
|
5196c1b212 | ||
|
|
e7fbaffbab | ||
|
|
c68b582be7 | ||
|
|
9d07df27f0 | ||
|
|
064bd4258c |
@@ -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
|
||||
276
.github/workflows/release.yml
vendored
276
.github/workflows/release.yml
vendored
@@ -26,6 +26,150 @@ jobs:
|
||||
|
||||
- name: Install esptool
|
||||
run: pip install esptool
|
||||
|
||||
- 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
|
||||
cp .pio/build/Simple_AP/littlefs.bin /home/runner/work/OpenEPaperLink/OpenEPaperLink/Simple_AP/littlefs.bin
|
||||
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
|
||||
cp .pio/build/OpenEPaperLink_Mini_AP/littlefs.bin /home/runner/work/OpenEPaperLink/OpenEPaperLink/OpenEPaperLink_Mini_AP/littlefs.bin
|
||||
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
|
||||
cp .pio/build/OpenEPaperLink_Nano_AP/littlefs.bin /home/runner/work/OpenEPaperLink/OpenEPaperLink/OpenEPaperLink_Nano_AP/littlefs.bin
|
||||
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
|
||||
cp .pio/build/OpenEPaperLink_AP_and_Flasher/littlefs.bin /home/runner/work/OpenEPaperLink/OpenEPaperLink/OpenEPaperLink_AP_and_Flasher/littlefs.bin
|
||||
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
|
||||
cd /home/runner/work/OpenEPaperLink/OpenEPaperLink
|
||||
cp OpenEPaperLink_AP_and_Flasher/firmware.bin espbinaries/OpenEPaperLink_AP_and_Flasher.bin
|
||||
cp OpenEPaperLink_AP_and_Flasher/merged-firmware.bin espbinaries/OpenEPaperLink_AP_and_Flasher_full.bin
|
||||
|
||||
- name: generate release json file
|
||||
run: |
|
||||
mkdir jsonfiles
|
||||
python genfilelist.py ${{ github.ref_name }} $GITHUB_REPOSITORY $GITHUB_SHA
|
||||
|
||||
- name: Add file lists to release
|
||||
uses: svenstaro/upload-release-action@v2
|
||||
with:
|
||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
file: jsonfiles/*
|
||||
tag: ${{ github.ref }}
|
||||
file_glob: true
|
||||
overwrite: true
|
||||
|
||||
- name: Add esp bins to release
|
||||
uses: svenstaro/upload-release-action@v2
|
||||
with:
|
||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
file: espbinaries/*
|
||||
tag: ${{ github.ref }}
|
||||
file_glob: true
|
||||
overwrite: true
|
||||
|
||||
- name: Add tag bins to release
|
||||
uses: svenstaro/upload-release-action@v2
|
||||
with:
|
||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
file: binaries/*
|
||||
tag: ${{ github.ref }}
|
||||
file_glob: true
|
||||
overwrite: true
|
||||
|
||||
# - name: Add www folder to release
|
||||
# uses: svenstaro/upload-release-action@v2
|
||||
@@ -50,135 +194,3 @@ jobs:
|
||||
# file: ESP32_AP-Flasher/data/*
|
||||
# tag: ${{ github.ref }}
|
||||
# file_glob: true
|
||||
|
||||
- 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
|
||||
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
|
||||
|
||||
- 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
|
||||
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
|
||||
|
||||
- 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
|
||||
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
|
||||
|
||||
- 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
|
||||
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
|
||||
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
|
||||
run: |
|
||||
python genfilelist.py ${{ github.ref_name }} $GITHUB_REPOSITORY $GITHUB_SHA
|
||||
|
||||
- name: Add file list to release
|
||||
uses: svenstaro/upload-release-action@v2
|
||||
with:
|
||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
file: /home/runner/work/OpenEPaperLink/OpenEPaperLink/files.json
|
||||
asset_name: files.json
|
||||
tag: ${{ github.ref }}
|
||||
overwrite: true
|
||||
body: "file list"
|
||||
|
||||
- name: Add esp bins to release
|
||||
uses: svenstaro/upload-release-action@v2
|
||||
with:
|
||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
file: espbinaries/*
|
||||
tag: ${{ github.ref }}
|
||||
file_glob: true
|
||||
overwrite: true
|
||||
|
||||
- name: Add tag bins to release
|
||||
uses: svenstaro/upload-release-action@v2
|
||||
with:
|
||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
file: binaries/*
|
||||
tag: ${{ github.ref }}
|
||||
file_glob: true
|
||||
overwrite: true
|
||||
|
||||
129
ESP32_AP-Flasher/data/content_template.json
Normal file
129
ESP32_AP-Flasher/data/content_template.json
Normal file
@@ -0,0 +1,129 @@
|
||||
{
|
||||
"1": {
|
||||
"0": {
|
||||
"weekday": [ 76, 10, "fonts/calibrib30" ],
|
||||
"month": [ 76, 120, "fonts/calibrib30" ],
|
||||
"day": [ 76, 42, "fonts/calibrib100" ]
|
||||
},
|
||||
"1": {
|
||||
"weekday": [ 148, 10, "fonts/calibrib60" ],
|
||||
"date": [ 148, 73, "fonts/calibrib50" ]
|
||||
},
|
||||
"2": {
|
||||
"weekday": [ 200, 25, "fonts/calibrib60" ],
|
||||
"month": [ 200, 225, "fonts/calibrib60" ],
|
||||
"day": [ 200, 95, "fonts/calibrib150" ]
|
||||
}
|
||||
},
|
||||
"2": {
|
||||
"0": {
|
||||
"fonts": [ "fonts/calibrib120", "fonts/calibrib80", "fonts/calibrib50", "fonts/calibrib50" ],
|
||||
"xy": [ 76, 83 ]
|
||||
},
|
||||
"1": {
|
||||
"fonts": [ "fonts/calibrib150", "fonts/calibrib150", "fonts/calibrib120", "fonts/calibrib100" ],
|
||||
"xy": [ 148, 74 ]
|
||||
},
|
||||
"2": {
|
||||
"fonts": [ "fonts/calibrib150", "fonts/calibrib150", "fonts/calibrib150", "fonts/calibrib120" ],
|
||||
"xy": [ 200, 148 ]
|
||||
}
|
||||
},
|
||||
"4": {
|
||||
"0": {
|
||||
"location": [ 10, 130, 2 ],
|
||||
"wind": [ 140, 10, "fonts/bahnschrift30" ],
|
||||
"temp": [ 10, 10, "fonts/bahnschrift30" ],
|
||||
"icon": [ 33, 33, "fonts/weathericons78" ],
|
||||
"dir": [ 100, -2, "fonts/weathericons30" ],
|
||||
"umbrella": [ 115, 110 ]
|
||||
},
|
||||
"1": {
|
||||
"location": [ 5, 5, "fonts/bahnschrift30" ],
|
||||
"wind": [ 280, 5, "fonts/bahnschrift30" ],
|
||||
"temp": [ 5, 65, "fonts/bahnschrift70" ],
|
||||
"icon": [ 185, 32, "fonts/weathericons70" ],
|
||||
"dir": [ 240, -3, "fonts/weathericons30" ],
|
||||
"umbrella": [ 190, 0 ]
|
||||
},
|
||||
"2": {
|
||||
"location": [ 20, 20, "fonts/calibrib30" ],
|
||||
"wind": [ 290, 83, "fonts/calibrib60" ],
|
||||
"temp": [ 20, 170, "fonts/calibrib150" ],
|
||||
"icon": [ 100, 50, "fonts/weathericons78" ],
|
||||
"dir": [ 220, 50, "fonts/weathericons78" ],
|
||||
"umbrella": [ 330, 10 ]
|
||||
}
|
||||
},
|
||||
"8": {
|
||||
"1": {
|
||||
"location": [ 5, 0, 2 ],
|
||||
"column": [ 5, 59 ],
|
||||
"day": [ 30, 18, "fonts/twcondensed20", 41, 108 ],
|
||||
"icon": [ 12, 58, "fonts/weathericons30" ],
|
||||
"wind": [ 17, 25 ],
|
||||
"line": [ 20, 128 ]
|
||||
},
|
||||
"2": {
|
||||
"location": [ 10, 10, "fonts/calibrib30" ],
|
||||
"column": [ 6, 66 ],
|
||||
"day": [ 33, 60, "fonts/bahnschrift20", 104, 230 ],
|
||||
"rain": [ 34, 260 ],
|
||||
"icon": [ 15, 145, "fonts/weathericons30" ],
|
||||
"wind": [ 17, 90 ],
|
||||
"line": [ 50, 300 ]
|
||||
}
|
||||
},
|
||||
"9": {
|
||||
"1": {
|
||||
"title": [ 5, 3, "fonts/bahnschrift20" ],
|
||||
"items": 8,
|
||||
"line": [ 5, 34, 13 ],
|
||||
"font": "glasstown_nbp_tf"
|
||||
},
|
||||
"2": {
|
||||
"title": [ 10, 10, "fonts/calibrib30" ],
|
||||
"items": 12,
|
||||
"line": [ 10, 60, 20 ],
|
||||
"font": "7x14_tf"
|
||||
}
|
||||
},
|
||||
"10": {
|
||||
"0": {
|
||||
"title": [ 10, 3, 2 ],
|
||||
"pos": [ 76, 20 ]
|
||||
},
|
||||
"1": {
|
||||
"title": [ 10, 5, "fonts/bahnschrift20" ],
|
||||
"pos": [ 149, 25 ]
|
||||
},
|
||||
"2": {
|
||||
"title": [ 10, 10, "fonts/bahnschrift20" ],
|
||||
"pos": [ 200, 30 ]
|
||||
}
|
||||
},
|
||||
"11": {
|
||||
"1": {
|
||||
"title": [ 5, 2, "fonts/bahnschrift20" ],
|
||||
"date": [ 290, 2 ],
|
||||
"items": 7,
|
||||
"red": [ 0, 21, 296, 14 ],
|
||||
"line": [ 5, 32, 15, "t0_14b_tf", 50 ]
|
||||
},
|
||||
"2": {
|
||||
"title": [ 10, 10, "fonts/bahnschrift30" ],
|
||||
"date": [ 390, 10 ],
|
||||
"items": 12,
|
||||
"red": [ 0, 48, 400, 17 ],
|
||||
"line": [ 10, 61, 18, "7x14_tf", 60 ]
|
||||
}
|
||||
},
|
||||
"16": {
|
||||
"1": {
|
||||
"location": [ 5, 5, "fonts/bahnschrift30" ],
|
||||
"title": [ 247, 11, "glasstown_nbp_tf" ],
|
||||
"cols": [ 1, 125, 12 ],
|
||||
"bars": [ 5, 111, 10 ]
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -21,6 +21,16 @@
|
||||
"name": "TimeToLive",
|
||||
"desc": "Amount (minutes) that this image will stay valid. The tag might not respond meanwhile",
|
||||
"type": "int"
|
||||
},
|
||||
{
|
||||
"key": "dither",
|
||||
"name": "Dithering",
|
||||
"desc": "Turn halftone dithering on or off. Turn it on when displaying photos. For texts, you better leave if off",
|
||||
"type": "select",
|
||||
"options": {
|
||||
"0": "off",
|
||||
"1": "on"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -168,7 +178,8 @@
|
||||
"name": "Buienradar",
|
||||
"desc": "Dutch rain predictions for the next two hours. Only works for locations in the Netherlands and Belgium.",
|
||||
"hwtype": [
|
||||
1
|
||||
1,
|
||||
17
|
||||
],
|
||||
"param": [
|
||||
{
|
||||
@@ -331,7 +342,7 @@
|
||||
"id": 12,
|
||||
"name": "Remote content",
|
||||
"desc": "Content is generated by a different Access Point",
|
||||
"hwtype": []
|
||||
"hwtype": []
|
||||
},
|
||||
{
|
||||
"id": 13,
|
||||
@@ -393,7 +404,134 @@
|
||||
"name": "bytes",
|
||||
"desc": "76 bytes, formatted as 0x00,0x00,...",
|
||||
"type": "text"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 17,
|
||||
"name": "Send Command",
|
||||
"desc": "Send a command to a tag to execute",
|
||||
"hwtype": [
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
17,
|
||||
240
|
||||
],
|
||||
"param": [
|
||||
{
|
||||
"key": "cmd",
|
||||
"name": "CMD",
|
||||
"desc": "Action",
|
||||
"type": "select",
|
||||
"options": {
|
||||
"0": "Reboot",
|
||||
"1": "Scan Channels",
|
||||
"2": "Clear settings"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 18,
|
||||
"name": "Set Tag Config",
|
||||
"desc": "Sets tag options. The options you see below are the default options. This may or may not match current tag settings",
|
||||
"hwtype": [
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
17,
|
||||
240
|
||||
],
|
||||
"param": [
|
||||
{
|
||||
"key": "fastboot",
|
||||
"name": "Boot method",
|
||||
"desc": "How the tag should boot, fast or normal",
|
||||
"type": "select",
|
||||
"options": {
|
||||
"0": "-Normal boot",
|
||||
"1": "Fast boot"
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "rfwake",
|
||||
"name": "RF Wake",
|
||||
"desc": "If the tag should support RF wake or not. This adds a 0.9µA current draw",
|
||||
"type": "select",
|
||||
"options": {
|
||||
"0": "-Disabled",
|
||||
"1": "Enabled"
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "tagroaming",
|
||||
"name": "Tag Roaming",
|
||||
"desc": "If enabled, the tag will periodically scan for AP's and will switch to a different channel if a stronger signal is found",
|
||||
"type": "select",
|
||||
"options": {
|
||||
"0": "-Disabled",
|
||||
"1": "Enabled"
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "tagscanontimeout",
|
||||
"name": "Scan for AP on timeout",
|
||||
"desc": "If a tag hasn't found an AP for an hour, should it rescan the channels for another AP?",
|
||||
"type": "select",
|
||||
"options": {
|
||||
"1": "-Enabled",
|
||||
"0": "Disabled"
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "showlowbat",
|
||||
"name": "Low Battery symbol",
|
||||
"desc": "Should the tag display the 'low battery' symbol if the battery a voltage threshold has been reached?",
|
||||
"type": "select",
|
||||
"options": {
|
||||
"1": "-Enabled",
|
||||
"0": "Disabled"
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "shownorf",
|
||||
"name": "No AP symbol",
|
||||
"desc": "Should the tag display the 'No-signal/AP' symbol if it hasn't been able to contact an AP?",
|
||||
"type": "select",
|
||||
"options": {
|
||||
"1": "-Enabled",
|
||||
"0": "Disabled"
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "lowvoltage",
|
||||
"name": "Low voltage threshold",
|
||||
"desc": "Below what voltage should the tag display the 'low bat' symbol?",
|
||||
"type": "select",
|
||||
"options": {
|
||||
"2600": "-2.6v",
|
||||
"2500": "2.5v",
|
||||
"2400": "2.4v",
|
||||
"2300": "2.3v",
|
||||
"2200": "2.2v"
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "fixedchannel",
|
||||
"name": "Fixed Channel",
|
||||
"desc": "What channel should the tag initially join?",
|
||||
"type": "select",
|
||||
"options": {
|
||||
"0": "-Auto",
|
||||
"11": "11",
|
||||
"15": "15",
|
||||
"20": "20",
|
||||
"25": "25",
|
||||
"26": "26",
|
||||
"27": "27"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
BIN
ESP32_AP-Flasher/data/www/favicon.ico
Normal file
BIN
ESP32_AP-Flasher/data/www/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.0 KiB |
@@ -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>
|
||||
@@ -29,10 +29,30 @@
|
||||
<button id="paintbutton"><i>A</i>🖌</button>
|
||||
</p>
|
||||
<div id="customoptions"></div>
|
||||
<p>
|
||||
<input type="button" value="Save" id="cfgsave">
|
||||
<span id="cfgdelete"><img src="data:image/gif;base64,R0lGODlhEAAQAPMAANXV1e3t7d/f39HR0dvb2/Hx8dTU1OLi4urq6mZmZpmZmf///wAAAAAAAAAAAAAAACH5BAEAAAwALAAAAAAQABAAAARBkMlJq71Yrp3ZXkr4WWCYnOZSgQVyEMYwJCq1nHhe20qgCAoA7QLyAYU7njE4JPV+zOSkCEUSFbmTVPPpbjvgTAQAOw==
|
||||
"></span>
|
||||
<div id="advancedoptions" style="height: 0px;">
|
||||
<p>Advanced options</p>
|
||||
<p>
|
||||
<label for="cfgrotate">Rotate image</label>
|
||||
<select id="cfgrotate">
|
||||
<option value="0">0 degrees</option>
|
||||
</select>
|
||||
</p>
|
||||
<p>
|
||||
<label for="cfglut">LUT</label>
|
||||
<select id="cfglut">
|
||||
<option value="0">auto</option>
|
||||
</select>
|
||||
</p>
|
||||
<p>
|
||||
<button id="cfgrefresh">force refresh</button>
|
||||
<button id="cfgclrpending">clear pending</button>
|
||||
<button id="cfgdelete"><img src="data:image/gif;base64,R0lGODlhEAAQAPMAANXV1e3t7d/f39HR0dvb2/Hx8dTU1OLi4urq6mZmZpmZmf///wAAAAAAAAAAAAAAACH5BAEAAAwALAAAAAAQABAAAARBkMlJq71Yrp3ZXkr4WWCYnOZSgQVyEMYwJCq1nHhe20qgCAoA7QLyAYU7njE4JPV+zOSkCEUSFbmTVPPpbjvgTAQAOw==
|
||||
"></button>
|
||||
</p>
|
||||
</div>
|
||||
<p id="savebar">
|
||||
<span><input type="button" value="Save" id="cfgsave"></span>
|
||||
<span id="cfgmore" title="advanced options">🞃</span>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@@ -105,7 +125,7 @@ Latency will be around 40 seconds.">
|
||||
<th>alias</th>
|
||||
<th>tags</th>
|
||||
<th>ch</th>
|
||||
<th>fw ver</th>
|
||||
<th>AP ver</th>
|
||||
</tr>
|
||||
</table>
|
||||
</p>
|
||||
@@ -137,9 +157,10 @@ Latency will be around 40 seconds.">
|
||||
<div class="actionbox">
|
||||
<div>
|
||||
<div>Currently active tags:</div>
|
||||
<div><span id="runstate"></div>
|
||||
<div><span id="apstatecolor">⬤</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>
|
||||
|
||||
@@ -159,8 +180,8 @@ Latency will be around 40 seconds.">
|
||||
<div class="nextcheckin"></div>
|
||||
<div class="nextupdate"></div>
|
||||
<div class="corner">
|
||||
<div class="pendingicon">↻</div>
|
||||
<div class="warningicon">⚠</div>
|
||||
<div class="pendingicon" title="A new message is waiting for the tag to pick up">↻</div>
|
||||
<div class="warningicon" title="This tag has not been seen for a long time">⚠</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -185,4 +206,4 @@ Latency will be around 40 seconds.">
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
</html>
|
||||
|
||||
@@ -142,6 +142,33 @@ select {
|
||||
width: 80px;
|
||||
}
|
||||
|
||||
#advancedoptions {
|
||||
overflow: hidden;
|
||||
transition: height 0.3s ease;
|
||||
}
|
||||
|
||||
#advancedoptions p:first-child {
|
||||
font-weight: 700;
|
||||
font-size: 1.2em;
|
||||
}
|
||||
|
||||
#savebar {
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
#savebar:first-child {
|
||||
flex-grow: 2;
|
||||
}
|
||||
|
||||
#cfgmore {
|
||||
padding: 2px 5px;
|
||||
font-weight: 700;
|
||||
font-size: 1.2em;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#apconfigbox {
|
||||
background-color: #e6f0d3;
|
||||
}
|
||||
@@ -179,10 +206,8 @@ select {
|
||||
}
|
||||
|
||||
#cfgdelete {
|
||||
position: absolute;
|
||||
bottom: 15px;
|
||||
right: 15px;
|
||||
cursor:pointer;
|
||||
cursor: pointer;
|
||||
padding: 2px 10px;
|
||||
}
|
||||
|
||||
.closebtn {
|
||||
@@ -245,7 +270,7 @@ select {
|
||||
}
|
||||
|
||||
.tagpending {
|
||||
animation: pending 1s ease infinite;
|
||||
animation: pending 1.5s ease infinite;
|
||||
}
|
||||
|
||||
.currimg {
|
||||
@@ -514,9 +539,9 @@ ul.messages li.new {
|
||||
}
|
||||
|
||||
@keyframes pending {
|
||||
0% { background-color: #d0d0e0;}
|
||||
50% { background-color: #b0b0e0;}
|
||||
100% { background-color: #d0d0e0;}
|
||||
0% { }
|
||||
50% { background-color: #d4d4f5;}
|
||||
100% { }
|
||||
}
|
||||
|
||||
@media screen and (max-width: 480px) {
|
||||
@@ -562,5 +587,10 @@ ul.messages li.new {
|
||||
|
||||
.actionbox>div {
|
||||
gap: 5px;
|
||||
flex-flow: wrap;
|
||||
}
|
||||
|
||||
.actionbox>div:first-child>div:first-child {
|
||||
flex-basis: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,8 +11,9 @@ const WAKEUP_REASON_WDT_RESET = 0xFE;
|
||||
const models = ["1.54\" 152x152px", "2.9\" 296x128px", "4.2\" 400x300px"];
|
||||
models[240] = "Segmented tag"
|
||||
models[17] = "2.9\" 296x128px (UC8151)"
|
||||
const displaySizeLookup = { 0: [152, 152], 1: [128, 296], 2: [400, 300] };
|
||||
displaySizeLookup[17] = [128, 296];
|
||||
const displaySizeLookup = { 0: [152, 152, 4], 1: [128, 296, 2], 2: [400, 300, 2] }; // w, h, rotate
|
||||
displaySizeLookup[17] = [128, 296, 2];
|
||||
displaySizeLookup[240] = [0, 0, 0];
|
||||
const colorTable = { 0: [255, 255, 255], 1: [0, 0, 0], 2: [255, 0, 0], 3: [150, 150, 150] };
|
||||
|
||||
const apstate = [
|
||||
@@ -23,7 +24,13 @@ const apstate = [
|
||||
{ state: "requires power cycle", color: "purple" },
|
||||
{ state: "failed", color: "red" },
|
||||
{ state: "coming online", color: "yellow" }
|
||||
];
|
||||
];
|
||||
const runstate = [
|
||||
{ state: "⏹︎ stopped" },
|
||||
{ state: "⏸pause" },
|
||||
{ state: "" }, // hide running
|
||||
{ state: "⏳︎ init" }
|
||||
];
|
||||
|
||||
const imageQueue = [];
|
||||
let isProcessing = false;
|
||||
@@ -41,7 +48,7 @@ window.addEventListener("load", function () {
|
||||
this.document.title = data.alias;
|
||||
}
|
||||
});
|
||||
fetch('/content_cards.json')
|
||||
fetch('/content_cards.json')
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
cardconfig = data;
|
||||
@@ -87,10 +94,11 @@ function connect() {
|
||||
processTags(msg.tags);
|
||||
}
|
||||
if (msg.sys) {
|
||||
$('#sysinfo').innerHTML = 'free heap: ' + msg.sys.heap + ' bytes ┇ db size: ' + msg.sys.dbsize + ' bytes ┇ db record count: ' + msg.sys.recordcount + ' ┇ littlefs free: ' + msg.sys.littlefsfree + ' bytes';
|
||||
$('#sysinfo').innerHTML = 'free heap: ' + msg.sys.heap + ' bytes ┇ db size: ' + msg.sys.dbsize + ' bytes ┇ db record count: ' + msg.sys.recordcount + ' ┇ 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;
|
||||
$("#runstate").innerHTML = runstate[msg.sys.runstate].state;
|
||||
}
|
||||
servertimediff = (Date.now() / 1000) - msg.sys.currtime;
|
||||
}
|
||||
@@ -119,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;
|
||||
@@ -208,6 +228,7 @@ function processTags(tagArray) {
|
||||
break;
|
||||
case WAKEUP_REASON_GPIO:
|
||||
$('#tag' + tagmac + ' .nextcheckin').innerHTML = "GPIO wakeup"
|
||||
$('#tag' + tagmac).style.background = "#c8f1bb";
|
||||
break;
|
||||
case WAKEUP_REASON_NFC:
|
||||
$('#tag' + tagmac + ' .nextcheckin').innerHTML = "NFC wakeup"
|
||||
@@ -272,6 +293,7 @@ $('#clearlog').onclick = function () {
|
||||
document.querySelectorAll('.closebtn').forEach(button => {
|
||||
button.addEventListener('click', (event) => {
|
||||
event.target.parentNode.style.display = 'none';
|
||||
$('#advancedoptions').style.height = '0px';
|
||||
});
|
||||
});
|
||||
|
||||
@@ -295,19 +317,29 @@ $('#taglist').addEventListener("click", (event) => {
|
||||
.then(data => {
|
||||
var tagdata = data.tags[0];
|
||||
$('#cfgalias').value = tagdata.alias;
|
||||
$('#cfgmore').style.display = "none";
|
||||
if (populateSelectTag(tagdata.hwType, tagdata.capabilities)) {
|
||||
$('#cfgcontent').parentNode.style.display = "flex";
|
||||
$('#cfgcontent').parentNode.style.display = "flex";
|
||||
$('#cfgcontent').value = tagdata.contentMode;
|
||||
$('#cfgcontent').dataset.json = tagdata.modecfgjson;
|
||||
contentselected();
|
||||
if (tagdata.contentMode != 12) $('#cfgmore').style.display = 'block';
|
||||
} else {
|
||||
$('#customoptions').innerHTML = "";
|
||||
$('#cfgcontent').parentNode.style.display = "none";
|
||||
}
|
||||
$('#cfgrotate').value = tagdata.rotate;
|
||||
$('#cfglut').value = tagdata.lut;
|
||||
$('#cfgmore').innerHTML = '🞃';
|
||||
$('#configbox').style.display = 'block';
|
||||
})
|
||||
})
|
||||
|
||||
$('#cfgmore').onclick = function () {
|
||||
$('#cfgmore').innerHTML = $('#advancedoptions').style.height == '0px' ? '🞁' : '🞃';
|
||||
$('#advancedoptions').style.height = $('#advancedoptions').style.height == '0px' ? $('#advancedoptions').scrollHeight + 'px' : '0px';
|
||||
};
|
||||
|
||||
$('#cfgsave').onclick = function () {
|
||||
let contentMode = $('#cfgcontent').value;
|
||||
let contentDef = getContentDefById(contentMode);
|
||||
@@ -332,6 +364,9 @@ $('#cfgsave').onclick = function () {
|
||||
formData.append("modecfgjson", String());
|
||||
}
|
||||
|
||||
formData.append("rotate", $('#cfgrotate').value);
|
||||
formData.append("lut", $('#cfglut').value);
|
||||
|
||||
fetch("/save_cfg", {
|
||||
method: "POST",
|
||||
body: formData
|
||||
@@ -340,26 +375,41 @@ $('#cfgsave').onclick = function () {
|
||||
.then(data => showMessage(data))
|
||||
.catch(error => showMessage('Error: ' + error));
|
||||
|
||||
$('#advancedoptions').style.height = '0px';
|
||||
$('#configbox').style.display = 'none';
|
||||
}
|
||||
|
||||
$('#cfgdelete').onclick = function () {
|
||||
function sendCmd(mac, cmd) {
|
||||
let formData = new FormData();
|
||||
formData.append("mac", $('#cfgmac').dataset.mac);
|
||||
fetch("/delete_cfg", {
|
||||
formData.append("mac", mac);
|
||||
formData.append("cmd", cmd);
|
||||
fetch("/tag_cmd", {
|
||||
method: "POST",
|
||||
body: formData
|
||||
})
|
||||
.then(response => response.text())
|
||||
.then(data => {
|
||||
var div = $('#tag' + $('#cfgmac').dataset.mac);
|
||||
div.remove();
|
||||
if (cmd == "del") div.remove();
|
||||
showMessage(data);
|
||||
})
|
||||
.catch(error => showMessage('Error: ' + error));
|
||||
$('#advancedoptions').style.height = '0px';
|
||||
$('#configbox').style.display = 'none';
|
||||
}
|
||||
|
||||
$('#cfgdelete').onclick = function () {
|
||||
sendCmd($('#cfgmac').dataset.mac, "del");
|
||||
}
|
||||
|
||||
$('#cfgclrpending').onclick = function () {
|
||||
sendCmd($('#cfgmac').dataset.mac, "clear");
|
||||
}
|
||||
|
||||
$('#cfgrefresh').onclick = function () {
|
||||
sendCmd($('#cfgmac').dataset.mac, "refresh");
|
||||
}
|
||||
|
||||
$('#rebootbutton').onclick = function () {
|
||||
showMessage("rebooting AP....", true);
|
||||
fetch("/reboot", {
|
||||
@@ -459,7 +509,6 @@ function contentselected() {
|
||||
obj = JSON.parse($('#cfgcontent').dataset.json);
|
||||
}
|
||||
$('#paintbutton').style.display = 'none';
|
||||
|
||||
if (contentMode) {
|
||||
let contentDef = getContentDefById(contentMode);
|
||||
if (contentDef) {
|
||||
@@ -487,6 +536,21 @@ function contentselected() {
|
||||
input.type = "text";
|
||||
input.disabled = true;
|
||||
break;
|
||||
case 'select':
|
||||
input = document.createElement("select");
|
||||
for (const key in element.options) {
|
||||
const optionElement = document.createElement("option");
|
||||
optionElement.value = key;
|
||||
optionElement.text = element.options[key];
|
||||
if (element.options[key].substring(0,1)=="-") {
|
||||
optionElement.text = element.options[key].substring(1);
|
||||
optionElement.selected = true;
|
||||
} else {
|
||||
optionElement.selected = false;
|
||||
}
|
||||
input.appendChild(optionElement);
|
||||
}
|
||||
break;
|
||||
}
|
||||
input.id = 'opt' + element.key;
|
||||
input.title = element.desc;
|
||||
@@ -505,17 +569,46 @@ function populateSelectTag(hwtype, capabilities) {
|
||||
var selectTag = $("#cfgcontent");
|
||||
selectTag.innerHTML = "";
|
||||
var optionsAdded = false;
|
||||
var option;
|
||||
cardconfig.forEach(item => {
|
||||
var capcheck = item.capabilities ?? 0;
|
||||
var hwtypeArray = item.hwtype;
|
||||
if (hwtypeArray.includes(hwtype) && (capabilities & capcheck || capcheck == 0)) {
|
||||
var option = document.createElement("option");
|
||||
option = document.createElement("option");
|
||||
option.value = item.id;
|
||||
option.text = item.name;
|
||||
selectTag.appendChild(option);
|
||||
optionsAdded = true;
|
||||
}
|
||||
});
|
||||
|
||||
var rotateTag = $("#cfgrotate");
|
||||
rotateTag.innerHTML = "";
|
||||
|
||||
for (let i = 0; i < 4; i++) {
|
||||
if (i == 0 || displaySizeLookup[hwtype][2] == 4 || (i == 2 && displaySizeLookup[hwtype][2] == 2)) {
|
||||
option = document.createElement("option");
|
||||
option.value = i;
|
||||
option.text = (i * 90) + " degrees";
|
||||
rotateTag.appendChild(option);
|
||||
}
|
||||
}
|
||||
|
||||
var lutTag = $("#cfglut");
|
||||
lutTag.innerHTML = "";
|
||||
|
||||
option = document.createElement("option");
|
||||
option.value = "0";
|
||||
option.text = "auto";
|
||||
lutTag.appendChild(option);
|
||||
|
||||
if (hwtype != 240) {
|
||||
option = document.createElement("option");
|
||||
option.value = "1";
|
||||
option.text = "Always full refresh";
|
||||
lutTag.appendChild(option);
|
||||
}
|
||||
|
||||
return optionsAdded;
|
||||
}
|
||||
|
||||
|
||||
7
ESP32_AP-Flasher/esp32_sdcard.csv
Normal file
7
ESP32_AP-Flasher/esp32_sdcard.csv
Normal 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,
|
||||
|
24
ESP32_AP-Flasher/include/SPIFFSEditor.h
Normal file
24
ESP32_AP-Flasher/include/SPIFFSEditor.h
Normal 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
|
||||
@@ -107,4 +107,19 @@ struct TagInfo {
|
||||
uint8_t contentMode;
|
||||
} __packed;
|
||||
|
||||
struct tagsettings {
|
||||
uint8_t settingsVer; // the version of the struct as written to the infopage
|
||||
uint8_t enableFastBoot; // default 0; if set, it will skip splashscreen
|
||||
uint8_t enableRFWake; // default 0; if set, it will enable RF wake. This will add about ~0.9µA idle power consumption
|
||||
uint8_t enableTagRoaming; // default 0; if set, the tag will scan for an accesspoint every few check-ins. This will increase power consumption quite a bit
|
||||
uint8_t enableScanForAPAfterTimeout; // default 1; if a the tag failed to check in, after a few attempts it will try to find a an AP on other channels
|
||||
uint8_t enableLowBatSymbol; // default 1; tag will show 'low battery' icon on screen if the battery is depleted
|
||||
uint8_t enableNoRFSymbol; // default 1; tag will show 'no signal' icon on screen if it failed to check in for a longer period of time
|
||||
uint8_t fastBootCapabilities; // holds the byte with 'capabilities' as detected during a normal tag boot; allows the tag to skip detecting buttons and NFC chip
|
||||
uint8_t customMode; // default 0; if anything else, tag will bootup in a different 'mode'
|
||||
uint16_t batLowVoltage; // Low battery threshold voltage (2450 for 2.45v). defaults to BATTERY_VOLTAGE_MINIMUM from powermgt.h
|
||||
uint16_t minimumCheckInTime; // defaults to BASE_INTERVAL from powermgt.h
|
||||
uint8_t fixedChannel; // default 0; if set to a valid channel number, the tag will stick to that channel
|
||||
} __packed;
|
||||
|
||||
#pragma pack(pop)
|
||||
@@ -2,6 +2,7 @@
|
||||
#include <LittleFS.h>
|
||||
#include <TFT_eSPI.h>
|
||||
|
||||
#include "U8g2_for_TFT_eSPI.h"
|
||||
#include "makeimage.h"
|
||||
#include "tag_db.h"
|
||||
|
||||
@@ -18,7 +19,7 @@ void contentRunner();
|
||||
void drawNew(uint8_t mac[8], bool buttonPressed, tagRecord *&taginfo);
|
||||
bool updateTagImage(String &filename, uint8_t *dst, uint16_t nextCheckin, tagRecord *&taginfo, imgParam &imageParams);
|
||||
void drawString(TFT_eSprite &spr, String content, uint16_t posx, uint16_t posy, String font, byte align = 0, uint16_t color = TFT_BLACK);
|
||||
void initSprite(TFT_eSprite &spr, int w, int h);
|
||||
void initSprite(TFT_eSprite &spr, int w, int h, imgParam &imageParams);
|
||||
void drawDate(String &filename, tagRecord *&taginfo, imgParam &imageParams);
|
||||
void drawNumber(String &filename, int32_t count, int32_t thresholdred, tagRecord *&taginfo, imgParam &imageParams);
|
||||
void drawWeather(String &filename, JsonObject &cfgobj, tagRecord *&taginfo, imgParam &imageParams);
|
||||
@@ -35,4 +36,7 @@ int windSpeedToBeaufort(float windSpeed);
|
||||
String windDirectionIcon(int degrees);
|
||||
void getLocation(JsonObject &cfgobj);
|
||||
void prepareNFCReq(uint8_t* dst, const char* url);
|
||||
void prepareLUTreq(uint8_t *dst, String input);
|
||||
void prepareLUTreq(uint8_t *dst, String input);
|
||||
void prepareConfigFile(uint8_t *dst, JsonObject config);
|
||||
void getTemplate(JsonDocument &json, const char *filePath, uint8_t id, uint8_t hwtype);
|
||||
void setU8G2Font(const String &title, U8g2_for_TFT_eSPI &u8f);
|
||||
|
||||
@@ -8,6 +8,8 @@ struct imgParam {
|
||||
uint8_t dataType;
|
||||
bool dither;
|
||||
bool grayLut = false;
|
||||
uint8_t bpp = 8;
|
||||
uint8_t rotate = 0;
|
||||
|
||||
char segments[12];
|
||||
uint16_t symbols;
|
||||
|
||||
@@ -12,6 +12,7 @@ extern void processXferComplete(struct espXferComplete* xfc, bool local);
|
||||
extern void processXferTimeout(struct espXferComplete* xfc, bool local);
|
||||
extern void processDataReq(struct espAvailDataReq* adr, bool local);
|
||||
|
||||
extern bool sendTagCommand(uint8_t* dst, uint8_t cmd, bool local);
|
||||
extern bool sendAPSegmentedData(uint8_t* dst, String data, uint16_t icons, bool inverted, bool local);
|
||||
extern bool showAPSegmentedInfo(uint8_t* dst, bool local);
|
||||
extern void updateTaginfoitem(struct TagInfo* taginfoitem);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <Arduino.h>
|
||||
|
||||
|
||||
void doLeds();
|
||||
void rampTagPower(uint8_t pin, bool up);
|
||||
//void doLeds();
|
||||
void powerControl(bool powerState, uint8_t* pin, uint8_t pincount);
|
||||
|
||||
39
ESP32_AP-Flasher/include/storage.h
Normal file
39
ESP32_AP-Flasher/include/storage.h
Normal 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
|
||||
14
ESP32_AP-Flasher/include/system.h
Normal file
14
ESP32_AP-Flasher/include/system.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#include <Arduino.h>
|
||||
|
||||
#define WAKEUP_REASON_TIMED 0
|
||||
#define WAKEUP_REASON_BOOT 1
|
||||
#define WAKEUP_REASON_GPIO 2
|
||||
#define WAKEUP_REASON_NFC 3
|
||||
#define WAKEUP_REASON_FIRSTBOOT 0xFC
|
||||
#define WAKEUP_REASON_NETWORK_SCAN 0xFD
|
||||
#define WAKEUP_REASON_WDT_RESET 0xFE
|
||||
|
||||
void init_time();
|
||||
void logLine(char* buffer);
|
||||
void logLine(String text);
|
||||
void logStartUp();
|
||||
@@ -14,11 +14,12 @@
|
||||
#define RUNSTATUS_STOP 0
|
||||
#define RUNSTATUS_PAUSE 1
|
||||
#define RUNSTATUS_RUN 2
|
||||
#define RUNSTATUS_INIT 3
|
||||
|
||||
class tagRecord {
|
||||
public:
|
||||
tagRecord() : mac{0}, alias(""), lastseen(0), nextupdate(0), contentMode(0), pending(false), md5{0}, md5pending{0}, expectedNextCheckin(0), modeConfigJson(""), LQI(0), RSSI(0), temperature(0), batteryMv(0), hwType(0), wakeupReason(0), capabilities(0), lastfullupdate(0), isExternal(false), pendingIdle(0), hasCustomLUT(false),
|
||||
filename(""), data(nullptr), len(0) {}
|
||||
tagRecord() : mac{0}, alias(""), lastseen(0), nextupdate(0), contentMode(0), pending(false), md5{0}, md5pending{0}, expectedNextCheckin(0), modeConfigJson(""), LQI(0), RSSI(0), temperature(0), batteryMv(0), hwType(0), wakeupReason(0), capabilities(0), lastfullupdate(0), isExternal(false), pendingIdle(0), hasCustomLUT(false), rotate(0), lut(0),
|
||||
dataType(0), filename(""), data(nullptr), len(0) {}
|
||||
|
||||
uint8_t mac[8];
|
||||
String alias;
|
||||
@@ -41,6 +42,10 @@ class tagRecord {
|
||||
bool isExternal;
|
||||
uint16_t pendingIdle;
|
||||
bool hasCustomLUT;
|
||||
uint8_t rotate;
|
||||
uint8_t lut;
|
||||
|
||||
uint8_t dataType;
|
||||
String filename;
|
||||
uint8_t* data;
|
||||
uint32_t len;
|
||||
@@ -58,7 +63,7 @@ struct Config {
|
||||
uint8_t runStatus;
|
||||
};
|
||||
|
||||
extern SemaphoreHandle_t tagDBOwner;
|
||||
// extern SemaphoreHandle_t tagDBOwner;
|
||||
extern Config config;
|
||||
extern std::vector<tagRecord*> tagDB;
|
||||
extern DynamicJsonDocument APconfig;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
class ZBS_interface
|
||||
{
|
||||
public:
|
||||
uint8_t begin(uint8_t SS, uint8_t CLK, uint8_t MOSI, uint8_t MISO, uint8_t RESET, uint8_t POWER = -1, uint32_t spi_speed = 8000000);
|
||||
uint8_t begin(uint8_t SS, uint8_t CLK, uint8_t MOSI, uint8_t MISO, uint8_t RESET, uint8_t* POWER = nullptr, uint8_t powerPins = 1, uint32_t spi_speed = 8000000);
|
||||
void setSpeed(uint32_t speed);
|
||||
void set_power(uint8_t state);
|
||||
void enable_debug();
|
||||
@@ -38,7 +38,8 @@ private:
|
||||
uint8_t _MOSI_PIN = -1;
|
||||
uint8_t _MISO_PIN = -1;
|
||||
uint8_t _RESET_PIN = -1;
|
||||
uint8_t _POWER_PIN = -1;
|
||||
uint8_t* _POWER_PIN = nullptr;
|
||||
uint8_t _POWER_PINS = 1;
|
||||
int ZBS_spi_delay = 1;
|
||||
uint8_t spi_ready = 0;
|
||||
uint32_t after_byte_delay = 10;
|
||||
|
||||
@@ -21,14 +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
|
||||
@@ -42,40 +45,36 @@ build_flags =
|
||||
-D ARDUINO_USB_MODE=0
|
||||
-D CONFIG_SPIRAM_USE_MALLOC=1
|
||||
-D CONFIG_MBEDTLS_EXTERNAL_MEM_ALLOC=y
|
||||
;-D DEBUG_VERSION
|
||||
|
||||
-D HAS_RGB_LED
|
||||
-D BOARD_HAS_PSRAM
|
||||
;-D HAS_USB
|
||||
|
||||
-D POWER_NO_SOFT_POWER
|
||||
-D FLASHER_AP_SS=11
|
||||
-D FLASHER_AP_CLK=9
|
||||
-D FLASHER_AP_MOSI=10
|
||||
-D FLASHER_AP_MISO=8
|
||||
-D FLASHER_AP_RESET=13
|
||||
-D FLASHER_AP_POWER=-1 ;this board has no soft power control
|
||||
-D FLASHER_AP_POWER={-1} ;this board has no soft power control
|
||||
-D FLASHER_AP_TXD=7
|
||||
-D FLASHER_AP_RXD=6
|
||||
-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
|
||||
@@ -85,47 +84,34 @@ build_unflags =
|
||||
build_flags =
|
||||
-D BUILD_ENV_NAME=$PIOENV
|
||||
-D BUILD_TIME=$UNIX_TIME
|
||||
-D OPENEPAPERLINK_MINI_AP_PCB
|
||||
-D OPENEPAPERLINK_NANO_AP_PCB
|
||||
-D ARDUINO_USB_MODE=0
|
||||
-D CONFIG_SPIRAM_USE_MALLOC=1
|
||||
-D CONFIG_MBEDTLS_EXTERNAL_MEM_ALLOC=y
|
||||
;-D DEBUG_VERSION
|
||||
|
||||
;-D HAS_RGB_LED
|
||||
-D BOARD_HAS_PSRAM
|
||||
;-D HAS_USB
|
||||
|
||||
-D FLASHER_AP_SS=38
|
||||
-D FLASHER_AP_CLK=40
|
||||
-D FLASHER_AP_MOSI=39
|
||||
-D FLASHER_AP_MISO=33
|
||||
-D FLASHER_AP_RESET=37
|
||||
-D FLASHER_AP_POWER=-1 ;18
|
||||
;-D FLASHER_AP_POWER2=21
|
||||
;-D FLASHER_AP_POWER3=16
|
||||
;-D FLASHER_AP_POWER4=17
|
||||
-D FLASHER_AP_POWER={16,17,18,21}
|
||||
-D FLASHER_AP_TXD=35
|
||||
-D FLASHER_AP_RXD=36
|
||||
-D FLASHER_AP_TEST=34
|
||||
-D FLASHER_AP_RXD=34
|
||||
-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
|
||||
;
|
||||
@@ -134,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
|
||||
@@ -149,107 +134,141 @@ 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
|
||||
-D FLASHER_AP_MISO=6
|
||||
-D FLASHER_AP_RESET=15
|
||||
-D FLASHER_AP_POWER=0
|
||||
-D FLASHER_AP_POWER={0}
|
||||
-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
|
||||
-D FLASHER_EXT_MISO=42
|
||||
-D FLASHER_EXT_RESET=1
|
||||
-D FLASHER_EXT_POWER=8
|
||||
-D FLASHER_EXT_POWER={8}
|
||||
-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
|
||||
-D FLASHER_ALT_MISO=9
|
||||
-D FLASHER_ALT_RESET=11
|
||||
-D FLASHER_ALT_POWER={-1}
|
||||
-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
|
||||
-D FLASHER_AP_MISO=19
|
||||
-D FLASHER_AP_RESET=2
|
||||
-D FLASHER_AP_POWER=13 ;// switching HIGH side; connect to 3V3 of tag
|
||||
-D FLASHER_AP_POWER2=15
|
||||
-D FLASHER_AP_POWER={13,15}
|
||||
-D FLASHER_AP_TEST=-1
|
||||
-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_POWER2=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>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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>
|
||||
|
||||
@@ -50,6 +51,16 @@ void dump(uint8_t *a, uint16_t l) {
|
||||
Serial.printf("\n");
|
||||
}
|
||||
|
||||
int8_t powerPinsAP[] = FLASHER_AP_POWER;
|
||||
int8_t pinsAP[] = {FLASHER_AP_CLK, FLASHER_AP_MISO, FLASHER_AP_MOSI, FLASHER_AP_RESET, FLASHER_AP_RXD, FLASHER_AP_SS, FLASHER_AP_TEST, FLASHER_AP_TXD};
|
||||
|
||||
#ifdef OPENEPAPERLINK_PCB
|
||||
int8_t powerPinsExt[] = FLASHER_EXT_POWER;
|
||||
int8_t powerPinsAlt[] = FLASHER_ALT_POWER;
|
||||
uint8_t pinsExt[] = {FLASHER_EXT_CLK, FLASHER_EXT_MISO, FLASHER_EXT_MOSI, FLASHER_EXT_RESET, FLASHER_EXT_RXD, FLASHER_EXT_SS, FLASHER_EXT_TEST, FLASHER_EXT_TXD};
|
||||
|
||||
#endif
|
||||
|
||||
class flasher {
|
||||
public:
|
||||
class ZBS_interface *zbs = nullptr;
|
||||
@@ -99,23 +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, FLASHER_AP_POWER, 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, FLASHER_EXT_POWER, 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, 255, 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:
|
||||
@@ -195,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>()) {
|
||||
@@ -225,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>()) {
|
||||
@@ -289,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));
|
||||
}
|
||||
@@ -463,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>()) {
|
||||
@@ -494,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>()) {
|
||||
@@ -518,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() {
|
||||
@@ -536,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;
|
||||
@@ -625,6 +642,42 @@ void flashCountDown(uint8_t c) {
|
||||
}
|
||||
}
|
||||
|
||||
void pinTest() {
|
||||
uint8_t *pintest;
|
||||
pintest = (uint8_t *)pinsAP;
|
||||
for (uint8_t c = 0; c < 8; c++) {
|
||||
if (pintest[c] != -1) {
|
||||
pinMode(pintest[c], INPUT_PULLDOWN);
|
||||
vTaskDelay(10 / portTICK_PERIOD_MS);
|
||||
if (digitalRead(pintest[c])) {
|
||||
Serial.printf("Pin %d failed to become low\n", c);
|
||||
} else {
|
||||
pinMode(pintest[c], INPUT_PULLUP);
|
||||
bool pinChange = false;
|
||||
uint16_t pinTime = 0;
|
||||
for (uint16_t t = 0; t < 65535; t++) {
|
||||
if (digitalRead(pintest[c])) {
|
||||
pinChange = true;
|
||||
pinTime = t;
|
||||
break;
|
||||
}
|
||||
ets_delay_us(1);
|
||||
}
|
||||
if (pinChange) {
|
||||
Serial.printf("Pin %d went high in %d µS\n", pintest[c], pinTime);
|
||||
} else {
|
||||
Serial.printf("Pin %d timeout becoming high\n", pintest[c]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (uint8_t c = 0; c < 8; c++) {
|
||||
if (pintest[c] != -1) {
|
||||
pinMode(pintest[c], INPUT_PULLDOWN);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef OPENEPAPERLINK_PCB
|
||||
// perform device flash, save mac, everything
|
||||
bool doTagFlash() {
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <WiFi.h>
|
||||
#include <WiFiManager.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "storage.h"
|
||||
#include "contentmanager.h"
|
||||
#include "flasher.h"
|
||||
#include "makeimage.h"
|
||||
#include "serialap.h"
|
||||
#include "settings.h"
|
||||
#include "system.h"
|
||||
#include "tag_db.h"
|
||||
|
||||
#ifdef HAS_USB
|
||||
@@ -19,24 +22,30 @@
|
||||
#include "udp.h"
|
||||
#include "web.h"
|
||||
|
||||
void timeTask(void* parameter) {
|
||||
void pinTest();
|
||||
|
||||
void delayedStart(void* parameter) {
|
||||
vTaskDelay(30000 / portTICK_PERIOD_MS);
|
||||
Serial.println("Resuming content generation");
|
||||
wsLog("resuming content generation");
|
||||
config.runStatus = RUNSTATUS_RUN;
|
||||
esp_reset_reason_t resetReason = esp_reset_reason();
|
||||
// if (resetReason == ESP_RST_PANIC) config.runStatus = RUNSTATUS_PAUSE;
|
||||
vTaskDelay(10 / portTICK_PERIOD_MS);
|
||||
vTaskDelete(NULL);
|
||||
}
|
||||
|
||||
void timeTask(void* parameter) {
|
||||
wsSendSysteminfo();
|
||||
Serial.printf("Free heap: %.2f KB\n", ESP.getFreeHeap() / 1024.0f);
|
||||
while (1) {
|
||||
time_t now;
|
||||
time(&now);
|
||||
tm tm;
|
||||
if (!getLocalTime(&tm)) {
|
||||
Serial.println("Waiting for valid time from NTP-server");
|
||||
} else {
|
||||
if (now % 5 == 0 || apInfo.state != AP_STATE_ONLINE) {
|
||||
wsSendSysteminfo();
|
||||
}
|
||||
if (now % 300 == 6 && config.runStatus != RUNSTATUS_STOP) saveDB("/current/tagDB.json");
|
||||
|
||||
if (apInfo.state == AP_STATE_ONLINE) contentRunner();
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -51,7 +60,7 @@ void setup() {
|
||||
showColorPattern(CRGB::Aqua, CRGB::Green, CRGB::Blue);
|
||||
#endif
|
||||
|
||||
#ifdef OPENEPAPERLINK_MINI_AP_PCB
|
||||
#if defined(OPENEPAPERLINK_MINI_AP_PCB) || defined(OPENEPAPERLINK_NANO_AP_PCB)
|
||||
APEnterEarlyReset();
|
||||
// this allows us to view the booting process. After the device showing up, you have 3 seconds to open a terminal on the COM port
|
||||
vTaskDelay(3000 / portTICK_PERIOD_MS);
|
||||
@@ -66,6 +75,7 @@ void setup() {
|
||||
Serial.begin(115200);
|
||||
Serial.print(">\n");
|
||||
|
||||
pinTest();
|
||||
#ifdef BOARD_HAS_PSRAM
|
||||
if (!psramInit()) {
|
||||
Serial.printf("This build of the AP expects PSRAM, but we couldn't find/init any. Something is terribly wrong here! System halted.");
|
||||
@@ -79,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());
|
||||
@@ -124,16 +136,37 @@ void setup() {
|
||||
rgbIdle();
|
||||
#endif
|
||||
loadDB("/current/tagDB.json");
|
||||
tagDBOwner = xSemaphoreCreateMutex();
|
||||
// tagDBOwner = xSemaphoreCreateMutex();
|
||||
xTaskCreate(APTask, "AP Process", 6000, NULL, 2, NULL);
|
||||
xTaskCreate(webSocketSendProcess, "ws", 2000, NULL, configMAX_PRIORITIES - 10, NULL);
|
||||
vTaskDelay(10 / portTICK_PERIOD_MS);
|
||||
|
||||
config.runStatus = RUNSTATUS_INIT;
|
||||
|
||||
xTaskCreate(timeTask, "timed tasks", 12000, NULL, 2, NULL);
|
||||
|
||||
init_time();
|
||||
logStartUp();
|
||||
|
||||
esp_reset_reason_t resetReason = esp_reset_reason();
|
||||
if (resetReason == ESP_RST_PANIC) {
|
||||
Serial.println("Panic! Pausing content generation for 30 seconds");
|
||||
config.runStatus = RUNSTATUS_PAUSE;
|
||||
xTaskCreate(delayedStart, "delaystart", 2000, NULL, 2, NULL);
|
||||
} else {
|
||||
config.runStatus = RUNSTATUS_RUN;
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
vTaskDelay(10000 / portTICK_PERIOD_MS);
|
||||
// performDeviceFlash();
|
||||
while (1) {
|
||||
// pinTest();
|
||||
while (1) {
|
||||
vTaskDelay(10000 / portTICK_PERIOD_MS);
|
||||
// pinTest();
|
||||
}
|
||||
#ifdef OPENEPAPERLINK_PCB
|
||||
if (extTagConnected()) {
|
||||
flashCountDown(3);
|
||||
|
||||
@@ -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;
|
||||
@@ -37,16 +37,17 @@ void jpg2buffer(String filein, String fileout, imgParam &imageParams) {
|
||||
#endif
|
||||
spr.createSprite(w, h);
|
||||
if (spr.getPointer() == nullptr) {
|
||||
//no heap space for 8bpp, fallback to 1bpp
|
||||
wsErr("fallback to 1bpp");
|
||||
wsErr("low on memory. Fallback to 1bpp");
|
||||
spr.setColorDepth(1);
|
||||
spr.setBitmapColor(TFT_WHITE, TFT_BLACK);
|
||||
imageParams.bpp = 1;
|
||||
spr.createSprite(w, h);
|
||||
}
|
||||
if (spr.getPointer() == nullptr) {
|
||||
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();
|
||||
@@ -73,26 +74,25 @@ 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();
|
||||
uint8_t *spr2color(TFT_eSprite &spr, imgParam &imageParams, size_t *buffer_size, bool is_red) {
|
||||
|
||||
fs::File f_out = LittleFS.open(fileout, "w");
|
||||
|
||||
bool dither = true, rotated = false;
|
||||
bool dither = true;
|
||||
uint8_t rotate = imageParams.rotate;
|
||||
long bufw = spr.width(), bufh = spr.height();
|
||||
|
||||
if (bufw > bufh && bufw!=400 && bufh!=300) {
|
||||
rotated = true;
|
||||
rotate = (rotate + 3) % 4;
|
||||
bufw = spr.height();
|
||||
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
|
||||
@@ -105,6 +105,7 @@ void spr2buffer(TFT_eSprite &spr, String &fileout, imgParam &imageParams) {
|
||||
Serial.println("rendering with gray");
|
||||
}
|
||||
int num_colors = palette.size();
|
||||
if (imageParams.bpp == 1) num_colors = 2;
|
||||
Color color;
|
||||
Error *error_bufferold = new Error[bufw + 4];
|
||||
Error *error_buffernew = new Error[bufw + 4];
|
||||
@@ -113,10 +114,19 @@ void spr2buffer(TFT_eSprite &spr, String &fileout, imgParam &imageParams) {
|
||||
for (uint16_t y = 0; y < bufh; y++) {
|
||||
memset(error_buffernew, 0, bufw * sizeof(Error));
|
||||
for (uint16_t x = 0; x < bufw; x++) {
|
||||
if (rotated) {
|
||||
color = Color(spr.readPixel(bufh - 1 - y, x));
|
||||
} else {
|
||||
color = Color(spr.readPixel(x, y));
|
||||
switch (rotate) {
|
||||
case 0:
|
||||
color = Color(spr.readPixel(x, y));
|
||||
break;
|
||||
case 1:
|
||||
color = Color(spr.readPixel(y, bufw - 1 - x));
|
||||
break;
|
||||
case 2:
|
||||
color = Color(spr.readPixel(bufw - 1 - x, bufh - 1 - y));
|
||||
break;
|
||||
case 3:
|
||||
color = Color(spr.readPixel(bufh - 1 - y, x));
|
||||
break;
|
||||
}
|
||||
|
||||
int best_color_index = 0;
|
||||
@@ -135,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;
|
||||
}
|
||||
@@ -187,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");
|
||||
|
||||
@@ -3,15 +3,16 @@
|
||||
#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"
|
||||
#include "system.h"
|
||||
#include "tag_db.h"
|
||||
#include "udp.h"
|
||||
#include "web.h"
|
||||
@@ -98,6 +99,7 @@ void prepareDataAvail(uint8_t* data, uint16_t len, uint8_t dataType, uint8_t* ds
|
||||
taginfo->len = len;
|
||||
taginfo->expectedNextCheckin = 0;
|
||||
taginfo->filename = String();
|
||||
taginfo->dataType = dataType;
|
||||
memset(taginfo->md5pending, 0, 16 * sizeof(uint8_t));
|
||||
|
||||
struct pendingData pending = {0};
|
||||
@@ -128,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();
|
||||
@@ -159,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;
|
||||
}
|
||||
@@ -168,11 +170,11 @@ bool prepareDataAvail(String* filename, uint8_t dataType, uint8_t* dst, uint16_t
|
||||
time_t now;
|
||||
time(&now);
|
||||
time_t last_midnight = now - now % (24 * 60 * 60) + 3 * 3600; // somewhere in the middle of the night
|
||||
if (taginfo->lastfullupdate < last_midnight || taginfo->hwType == SOLUM_29_UC8151) {
|
||||
if (taginfo->lastfullupdate < last_midnight || taginfo->hwType == SOLUM_29_UC8151 || taginfo->lut == 1) {
|
||||
lut = EPD_LUT_DEFAULT; // full update once a day
|
||||
taginfo->lastfullupdate = now;
|
||||
}
|
||||
if (taginfo->hasCustomLUT && taginfo->capabilities & CAPABILITY_SUPPORTS_CUSTOM_LUTS) {
|
||||
if (taginfo->hasCustomLUT && taginfo->capabilities & CAPABILITY_SUPPORTS_CUSTOM_LUTS && taginfo->lut != 1) {
|
||||
Serial.println("using custom LUT");
|
||||
lut = EPD_LUT_OTA;
|
||||
}
|
||||
@@ -180,26 +182,28 @@ 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));
|
||||
time_t now;
|
||||
time(&now);
|
||||
taginfo->expectedNextCheckin = now + nextCheckin * 60 + 60;
|
||||
clearPending(taginfo);
|
||||
taginfo->filename = *filename;
|
||||
taginfo->len = filesize;
|
||||
clearPending(taginfo);
|
||||
taginfo->dataType = dataType;
|
||||
taginfo->pending = true;
|
||||
memcpy(taginfo->md5pending, md5bytes, sizeof(md5bytes));
|
||||
} else {
|
||||
wsLog("firmware upload pending");
|
||||
clearPending(taginfo);
|
||||
taginfo->filename = *filename;
|
||||
taginfo->len = filesize;
|
||||
clearPending(taginfo);
|
||||
taginfo->dataType = dataType;
|
||||
taginfo->pending = true;
|
||||
}
|
||||
|
||||
@@ -237,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);
|
||||
@@ -248,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();
|
||||
@@ -272,9 +276,10 @@ void prepareExternalDataAvail(struct pendingData* pending, IPAddress remoteIP) {
|
||||
}
|
||||
|
||||
file.close();
|
||||
clearPending(taginfo);
|
||||
taginfo->filename = filename;
|
||||
taginfo->len = filesize;
|
||||
clearPending(taginfo);
|
||||
taginfo->dataType = pending->availdatainfo.dataType;
|
||||
taginfo->pending = true;
|
||||
memcpy(taginfo->md5pending, md5bytes, sizeof(md5bytes));
|
||||
break;
|
||||
@@ -296,6 +301,7 @@ void prepareExternalDataAvail(struct pendingData* pending, IPAddress remoteIP) {
|
||||
taginfo->data = new uint8_t[len];
|
||||
WiFiClient* stream = http.getStreamPtr();
|
||||
stream->readBytes(taginfo->data, len);
|
||||
taginfo->dataType = pending->availdatainfo.dataType;
|
||||
taginfo->pending = true;
|
||||
taginfo->len = len;
|
||||
}
|
||||
@@ -332,9 +338,9 @@ 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("Dunno how this happened... File pending but deleted in the meantime?\n");
|
||||
Serial.print("No current file. Canceling request\n");
|
||||
prepareCancelPending(br->src);
|
||||
return;
|
||||
}
|
||||
@@ -374,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;
|
||||
@@ -390,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -463,6 +473,23 @@ void processDataReq(struct espAvailDataReq* eadr, bool local) {
|
||||
taginfo->lastseen = now;
|
||||
|
||||
if (eadr->adr.lastPacketRSSI != 0) {
|
||||
if (eadr->adr.wakeupReason >= 0xF0) {
|
||||
if (!taginfo->pending) taginfo->nextupdate = 0;
|
||||
memset(taginfo->md5, 0, 16 * sizeof(uint8_t));
|
||||
memset(taginfo->md5pending, 0, 16 * sizeof(uint8_t));
|
||||
|
||||
const char* reason = "";
|
||||
if (eadr->adr.wakeupReason == WAKEUP_REASON_FIRSTBOOT) reason = "Booting";
|
||||
else if (eadr->adr.wakeupReason == WAKEUP_REASON_NETWORK_SCAN) reason = "Network scan";
|
||||
else if (eadr->adr.wakeupReason == WAKEUP_REASON_WDT_RESET) reason = "Watchdog reset";
|
||||
sprintf(buffer, "%02X%02X%02X%02X%02X%02X%02X%02X %s", eadr->src[7], eadr->src[6], eadr->src[5], eadr->src[4], eadr->src[3], eadr->src[2], eadr->src[1], eadr->src[0], reason);
|
||||
logLine(buffer);
|
||||
}
|
||||
if (taginfo->batteryMv != eadr->adr.batteryMv) {
|
||||
sprintf(buffer, "%02X%02X%02X%02X%02X%02X%02X%02X battery went from %.2fV to %.2fV", eadr->src[7], eadr->src[6], eadr->src[5], eadr->src[4], eadr->src[3], eadr->src[2], eadr->src[1], eadr->src[0], static_cast<float>(taginfo->batteryMv) / 1000.0, static_cast<float>(eadr->adr.batteryMv) / 1000.0);
|
||||
logLine(buffer);
|
||||
}
|
||||
|
||||
taginfo->LQI = eadr->adr.lastPacketLQI;
|
||||
taginfo->hwType = eadr->adr.hwType;
|
||||
taginfo->RSSI = eadr->adr.lastPacketRSSI;
|
||||
@@ -471,11 +498,6 @@ void processDataReq(struct espAvailDataReq* eadr, bool local) {
|
||||
taginfo->hwType = eadr->adr.hwType;
|
||||
taginfo->wakeupReason = eadr->adr.wakeupReason;
|
||||
taginfo->capabilities = eadr->adr.capabilities;
|
||||
if (eadr->adr.wakeupReason >= 0xF0) {
|
||||
if (!taginfo->pending) taginfo->nextupdate = 0;
|
||||
memset(taginfo->md5, 0, 16 * sizeof(uint8_t));
|
||||
memset(taginfo->md5pending, 0, 16 * sizeof(uint8_t));
|
||||
}
|
||||
}
|
||||
if (local) {
|
||||
sprintf(buffer, "<ADR %02X%02X%02X%02X%02X%02X%02X%02X\n\0", eadr->src[7], eadr->src[6], eadr->src[5], eadr->src[4], eadr->src[3], eadr->src[2], eadr->src[1], eadr->src[0]);
|
||||
@@ -569,6 +591,26 @@ bool showAPSegmentedInfo(uint8_t* dst, bool local) {
|
||||
}
|
||||
}
|
||||
|
||||
bool sendTagCommand(uint8_t* dst, uint8_t cmd, bool local) {
|
||||
struct pendingData pending = {0};
|
||||
memcpy(pending.targetMac, dst, 8);
|
||||
pending.availdatainfo.dataType = 0xAF;
|
||||
pending.availdatainfo.dataTypeArgument = cmd;
|
||||
pending.availdatainfo.nextCheckIn = 0;
|
||||
pending.attemptsLeft = 120;
|
||||
char buffer[64];
|
||||
sprintf(buffer, ">Tag CMD %02X%02X%02X%02X%02X%02X%02X%02X\n\0", dst[7], dst[6], dst[5], dst[4], dst[3], dst[2], dst[1], dst[0]);
|
||||
Serial.print(buffer);
|
||||
if (local) {
|
||||
return sendDataAvail(&pending);
|
||||
} else {
|
||||
udpsync.netSendDataAvail(&pending);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void updateTaginfoitem(struct TagInfo* taginfoitem) {
|
||||
tagRecord* taginfo = nullptr;
|
||||
taginfo = tagRecord::findByMAC(taginfoitem->mac);
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
@@ -9,31 +9,35 @@
|
||||
#include "soc/soc.h"
|
||||
#endif
|
||||
|
||||
#ifdef SIMPLE_AP
|
||||
void simpleAPPower(bool state) {
|
||||
if (FLASHER_AP_POWER >= 0 && FLASHER_AP_POWER2 >= 0) {
|
||||
pinMode(FLASHER_AP_POWER, INPUT);
|
||||
pinMode(FLASHER_AP_POWER2, INPUT);
|
||||
digitalWrite(FLASHER_AP_POWER, state);
|
||||
digitalWrite(FLASHER_AP_POWER2, state);
|
||||
pinMode(FLASHER_AP_POWER, OUTPUT);
|
||||
pinMode(FLASHER_AP_POWER2, OUTPUT);
|
||||
void simpleAPPower(uint8_t* pin, uint8_t pincount, bool state) {
|
||||
for (uint8_t c = 0; c < pincount; c++) {
|
||||
pinMode(pin[c], INPUT);
|
||||
}
|
||||
for (uint8_t c = 0; c < pincount; c++) {
|
||||
#ifdef POWER_HIGH_SIDE_DRIVER
|
||||
digitalWrite(pin[c], !state);
|
||||
#else
|
||||
digitalWrite(pin[c], state);
|
||||
#endif
|
||||
}
|
||||
for (uint8_t c = 0; c < pincount; c++) {
|
||||
pinMode(pin[c], OUTPUT);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// On the OpenEPaperLink board, there is no in-rush current limiting. The tags that can be connected to the board can have significant capacity, which,
|
||||
// when drained if the board applies power, will cause the 3v3 rail to sag enough to reset the ESP32. This is obviously not great. To prevent this from happening,
|
||||
// we ramp up/down the voltage with PWM. Ramping down really is unnecessary, as the board has a resistor to dump the charge into.
|
||||
void rampTagPower(uint8_t pin, bool up) {
|
||||
void rampTagPower(uint8_t* pin, bool up) {
|
||||
#ifdef OPENEPAPERLINK_PCB
|
||||
WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0);
|
||||
#endif
|
||||
if (up) {
|
||||
ledcSetup(0, 152000, 8); // 141251 okay // 101251 okay
|
||||
ledcWrite(0, 254);
|
||||
vTaskDelay(1 / portTICK_PERIOD_MS);
|
||||
ledcAttachPin(pin, 0);
|
||||
pinMode(pin, OUTPUT);
|
||||
ledcAttachPin(pin[0], 0);
|
||||
pinMode(pin[0], OUTPUT);
|
||||
vTaskDelay(10 / portTICK_PERIOD_MS);
|
||||
for (uint8_t c = 254; c != 0xFF; c--) {
|
||||
ledcWrite(0, c);
|
||||
@@ -43,18 +47,54 @@ void rampTagPower(uint8_t pin, bool up) {
|
||||
delayMicroseconds(100);
|
||||
}
|
||||
}
|
||||
digitalWrite(pin, LOW);
|
||||
ledcDetachPin(pin);
|
||||
digitalWrite(pin, LOW);
|
||||
digitalWrite(pin[0], LOW);
|
||||
ledcDetachPin(pin[0]);
|
||||
digitalWrite(pin[0], LOW);
|
||||
} else {
|
||||
pinMode(pin, OUTPUT);
|
||||
digitalWrite(pin, HIGH);
|
||||
ledcSetup(0, 152000, 8); // 141251 okay // 101251 okay
|
||||
ledcWrite(0, 0);
|
||||
vTaskDelay(1 / portTICK_PERIOD_MS);
|
||||
ledcAttachPin(pin[0], 0);
|
||||
pinMode(pin[0], OUTPUT);
|
||||
vTaskDelay(10 / portTICK_PERIOD_MS);
|
||||
for (uint8_t c = 0; c < 0xFF; c++) {
|
||||
ledcWrite(0, c);
|
||||
if (c > 250) {
|
||||
vTaskDelay(2 / portTICK_PERIOD_MS);
|
||||
} else {
|
||||
delayMicroseconds(100);
|
||||
}
|
||||
}
|
||||
digitalWrite(pin[0], HIGH);
|
||||
ledcDetachPin(pin[0]);
|
||||
digitalWrite(pin[0], HIGH);
|
||||
}
|
||||
#ifdef OPENEPAPERLINK_PCB
|
||||
WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 1);
|
||||
#endif
|
||||
#ifdef SIMPLE_AP
|
||||
simpleAPPower(false);
|
||||
}
|
||||
|
||||
void powerControl(bool powerState, uint8_t* pin, uint8_t pincount) {
|
||||
if (pin[0] == -1) return;
|
||||
|
||||
#ifdef POWER_RAMPING
|
||||
if (powerState == true) {
|
||||
#ifdef POWER_HIGH_SIDE_DRIVER
|
||||
rampTagPower(pin, true);
|
||||
#else
|
||||
rampTagPower(pin, false);
|
||||
#endif
|
||||
} else {
|
||||
pinMode(pin[0], OUTPUT);
|
||||
#ifdef POWER_HIGH_SIDE_DRIVER
|
||||
digitalWrite(pin[0], HIGH);
|
||||
#else
|
||||
digitalWrite(pin[0], LOW);
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
simpleAPPower(pin, pincount, false);
|
||||
delay(500);
|
||||
simpleAPPower(up);
|
||||
simpleAPPower(pin, pincount, true);
|
||||
#endif
|
||||
}
|
||||
@@ -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"
|
||||
|
||||
@@ -110,15 +110,18 @@ bool waitCmdReply() {
|
||||
}
|
||||
|
||||
#if (AP_PROCESS_PORT == FLASHER_AP_PORT)
|
||||
int8_t APpowerPins[] = FLASHER_AP_POWER;
|
||||
#define AP_RESET_PIN FLASHER_AP_RESET
|
||||
#define AP_POWER_PIN FLASHER_AP_POWER
|
||||
#endif
|
||||
#ifdef OPENEPAPERLINK_PCB
|
||||
#if (AP_PROCESS_PORT == FLASHER_EXT_PORT)
|
||||
int8_t APpowerPins[] = FLASHER_EXT_POWER;
|
||||
#define AP_RESET_PIN FLASHER_EXT_RESET
|
||||
#define AP_POWER_PIN FLASHER_EXT_POWER
|
||||
#endif
|
||||
#if (AP_PROCESS_PORT == FLASHER_ALTRADIO_PORT)
|
||||
int8_t APpowerPins[] = FLASHER_ALT_POWER;
|
||||
#define AP_RESET_PIN FLASHER_ALT_RESET
|
||||
#define AP_POWER_PIN FLASHER_ALT_POWER
|
||||
#endif
|
||||
@@ -134,9 +137,9 @@ void APTagReset() {
|
||||
pinMode(AP_RESET_PIN, OUTPUT);
|
||||
digitalWrite(AP_RESET_PIN, LOW);
|
||||
vTaskDelay(50 / portTICK_PERIOD_MS);
|
||||
rampTagPower(AP_POWER_PIN, false);
|
||||
powerControl(false, (uint8_t*)APpowerPins, sizeof(APpowerPins));
|
||||
vTaskDelay(300 / portTICK_PERIOD_MS);
|
||||
rampTagPower(AP_POWER_PIN, true);
|
||||
powerControl(true, (uint8_t*)APpowerPins, sizeof(APpowerPins));
|
||||
vTaskDelay(100 / portTICK_PERIOD_MS);
|
||||
digitalWrite(AP_RESET_PIN, HIGH);
|
||||
vTaskDelay(100 / portTICK_PERIOD_MS);
|
||||
@@ -202,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();
|
||||
@@ -538,7 +542,7 @@ void ShowAPInfo() {
|
||||
void notifySegmentedFlash() {
|
||||
sendAPSegmentedData(apInfo.mac, (String) "Fl ash", 0x0800, false, true);
|
||||
vTaskDelay(2000 / portTICK_PERIOD_MS);
|
||||
#if (FLASHER_AP_POWER == -1)
|
||||
#ifdef POWER_NO_SOFT_POWER
|
||||
sendAPSegmentedData(apInfo.mac, (String) "If done", 0x0800, false, true);
|
||||
vTaskDelay(2000 / portTICK_PERIOD_MS);
|
||||
sendAPSegmentedData(apInfo.mac, (String) "RE boot", 0x0800, false, true);
|
||||
@@ -547,7 +551,7 @@ void notifySegmentedFlash() {
|
||||
}
|
||||
void checkWaitPowerCycle() {
|
||||
// check if we should wait for a power cycle. If we do, try to inform the user the best we can, and hang.
|
||||
#if (FLASHER_AP_POWER == -1)
|
||||
#ifdef POWER_NO_SOFT_POWER
|
||||
apInfo.isOnline = false;
|
||||
apInfo.state = AP_STATE_REQUIRED_POWER_CYCLE;
|
||||
// If we have no soft power control, we'll now wait until the device is power-cycled
|
||||
@@ -603,7 +607,7 @@ bool bringAPOnline() {
|
||||
}
|
||||
|
||||
void APTask(void* parameter) {
|
||||
xTaskCreate(rxCmdProcessor, "rxCmdProcessor", 3000, NULL, configMAX_PRIORITIES - 10, NULL);
|
||||
xTaskCreate(rxCmdProcessor, "rxCmdProcessor", 4000, NULL, configMAX_PRIORITIES - 10, NULL);
|
||||
xTaskCreate(rxSerialTask, "rxSerialTask", 1750, NULL, configMAX_PRIORITIES - 4, NULL);
|
||||
|
||||
#if (AP_PROCESS_PORT == FLASHER_AP_PORT)
|
||||
@@ -684,15 +688,19 @@ 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;
|
||||
Serial.println("I wasn't able to connect to a ZBS (AP) tag.\n");
|
||||
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 RXD/TXD 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("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.printf("Performing firmware flash in about %d seconds!\n", FLASH_TIMEOUT);
|
||||
flashCountDown(FLASH_TIMEOUT);
|
||||
if (doAPFlash()) {
|
||||
checkWaitPowerCycle();
|
||||
if (bringAPOnline()) {
|
||||
@@ -708,10 +716,11 @@ void APTask(void* parameter) {
|
||||
Serial.printf("This generally means that the flasher connections (MISO/MOSI/CLK/RESET/CS) are okay,\n");
|
||||
Serial.printf("but we can't (yet) talk to the AP over serial lines. Verify the pins mentioned above.\n\n");
|
||||
|
||||
if (FLASHER_AP_POWER != -1) {
|
||||
Serial.printf("The firmware you're using expects soft power control over the AP tag; if it can't\n");
|
||||
Serial.printf("power-cycle the AP-tag using GPIO pin %d, this can cause this very same issue.\n", FLASHER_AP_POWER);
|
||||
}
|
||||
#ifndef POWER_NO_SOFT_POWER
|
||||
Serial.printf("The firmware you're using expects soft power control over the AP tag; if it can't\n");
|
||||
Serial.printf("power-cycle the AP-tag using GPIO pin %d, this can cause this very same issue.\n", APpowerPins[0]);
|
||||
#endif
|
||||
|
||||
#ifdef HAS_RGB_LED
|
||||
showColorPattern(CRGB::Red, CRGB::Yellow, CRGB::Red);
|
||||
#endif
|
||||
@@ -729,20 +738,29 @@ void APTask(void* parameter) {
|
||||
Serial.println("Seems like you're running into some issues with the wiring, or (very small chance) the tag itself");
|
||||
Serial.println("This ESP32-build expects the following pins connected to the ZBS243:");
|
||||
Serial.println("--- ZBS243 based tag ESP32 ---");
|
||||
Serial.printf(" RXD ---------------- %02d\n", FLASHER_AP_RXD);
|
||||
Serial.printf(" TXD ---------------- %02d\n", FLASHER_AP_TXD);
|
||||
Serial.printf(" TXD ---------------- %02d\n", FLASHER_AP_RXD);
|
||||
Serial.printf(" RXD ---------------- %02d\n", FLASHER_AP_TXD);
|
||||
Serial.printf(" CS/SS ---------------- %02d\n", FLASHER_AP_SS);
|
||||
Serial.printf(" MOSI ---------------- %02d\n", FLASHER_AP_MOSI);
|
||||
Serial.printf(" MISO ---------------- %02d\n", FLASHER_AP_MISO);
|
||||
Serial.printf(" CLK ---------------- %02d\n", FLASHER_AP_CLK);
|
||||
Serial.printf(" RSET ---------------- %02d\n", FLASHER_AP_RESET);
|
||||
#if (FLASHER_AP_POWER == -1)
|
||||
#ifdef POWER_NO_SOFT_POWER
|
||||
Serial.printf("Your firmware is configured without soft power control. This means you'll have to manually power-cycle the tag after flashing.\n");
|
||||
#else
|
||||
Serial.printf(" POWER ---------------- %02d\n", FLASHER_AP_POWER);
|
||||
Serial.printf(" POWER ---------------- %02d\n", APpowerPins[0]);
|
||||
#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;
|
||||
|
||||
215
ESP32_AP-Flasher/src/storage.cpp
Normal file
215
ESP32_AP-Flasher/src/storage.cpp
Normal 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;
|
||||
80
ESP32_AP-Flasher/src/system.cpp
Normal file
80
ESP32_AP-Flasher/src/system.cpp
Normal file
@@ -0,0 +1,80 @@
|
||||
#include "system.h"
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <FS.h>
|
||||
|
||||
#include "storage.h"
|
||||
|
||||
void init_time() {
|
||||
struct tm timeinfo;
|
||||
while (true) {
|
||||
if (!getLocalTime(&timeinfo)) {
|
||||
Serial.println("Waiting for valid time from NTP-server");
|
||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void logLine(char* buffer) {
|
||||
logLine(String(buffer));
|
||||
}
|
||||
|
||||
void logLine(String text) {
|
||||
time_t now;
|
||||
time(&now);
|
||||
|
||||
char timeStr[24];
|
||||
strftime(timeStr, sizeof(timeStr), "%Y-%m-%d %H:%M:%S ", localtime(&now));
|
||||
|
||||
File logFile = contentFS->open("/log.txt", "a");
|
||||
if (logFile) {
|
||||
logFile.print(timeStr);
|
||||
logFile.println(text);
|
||||
logFile.close();
|
||||
}
|
||||
}
|
||||
|
||||
void logStartUp() {
|
||||
esp_reset_reason_t resetReason = esp_reset_reason();
|
||||
|
||||
String logEntry = "Reboot. Reason: ";
|
||||
switch (resetReason) {
|
||||
case ESP_RST_POWERON:
|
||||
logEntry += "Power-on";
|
||||
break;
|
||||
case ESP_RST_EXT:
|
||||
logEntry += "External";
|
||||
break;
|
||||
case ESP_RST_SW:
|
||||
logEntry += "Software";
|
||||
break;
|
||||
case ESP_RST_PANIC:
|
||||
logEntry += "Panic";
|
||||
break;
|
||||
case ESP_RST_INT_WDT:
|
||||
logEntry += "Watchdog";
|
||||
break;
|
||||
case ESP_RST_TASK_WDT:
|
||||
logEntry += "Task Watchdog";
|
||||
break;
|
||||
case ESP_RST_WDT:
|
||||
logEntry += "Other Watchdog";
|
||||
break;
|
||||
case ESP_RST_DEEPSLEEP:
|
||||
logEntry += "Deep Sleep";
|
||||
break;
|
||||
case ESP_RST_BROWNOUT:
|
||||
logEntry += "Brownout";
|
||||
break;
|
||||
case ESP_RST_SDIO:
|
||||
logEntry += "SDIO";
|
||||
break;
|
||||
default:
|
||||
logEntry += "Unknown";
|
||||
break;
|
||||
}
|
||||
|
||||
logLine(logEntry);
|
||||
}
|
||||
@@ -5,13 +5,13 @@
|
||||
#include <FS.h>
|
||||
#include <vector>
|
||||
|
||||
#include "LittleFS.h"
|
||||
#include "storage.h"
|
||||
#include "language.h"
|
||||
|
||||
std::vector<tagRecord*> tagDB;
|
||||
|
||||
Config config;
|
||||
SemaphoreHandle_t tagDBOwner;
|
||||
// SemaphoreHandle_t tagDBOwner;
|
||||
|
||||
tagRecord* tagRecord::findByMAC(uint8_t mac[8]) {
|
||||
for (int16_t c = 0; c < tagDB.size(); c++) {
|
||||
@@ -117,6 +117,8 @@ void fillNode(JsonObject &tag, tagRecord* &taginfo) {
|
||||
tag["capabilities"] = taginfo->capabilities;
|
||||
tag["modecfgjson"] = taginfo->modeConfigJson;
|
||||
tag["isexternal"] = taginfo->isExternal;
|
||||
tag["rotate"] = taginfo->rotate;
|
||||
tag["lut"] = taginfo->lut;
|
||||
}
|
||||
|
||||
void saveDB(String filename) {
|
||||
@@ -124,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;
|
||||
@@ -159,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;
|
||||
@@ -210,6 +212,8 @@ void loadDB(String filename) {
|
||||
taginfo->capabilities = tag["capabilities"];
|
||||
taginfo->modeConfigJson = tag["modecfgjson"].as<String>();
|
||||
taginfo->isExternal = tag["isexternal"].as<bool>();
|
||||
taginfo->rotate = tag["rotate"] | 0;
|
||||
taginfo->lut = tag["lut"] | 0;
|
||||
}
|
||||
} else {
|
||||
Serial.print(F("deserializeJson() failed: "));
|
||||
@@ -251,6 +255,7 @@ uint8_t getTagCount() {
|
||||
}
|
||||
|
||||
void clearPending(tagRecord* taginfo) {
|
||||
taginfo->filename = String();
|
||||
if (taginfo->data != nullptr) {
|
||||
free(taginfo->data);
|
||||
taginfo->data = nullptr;
|
||||
@@ -259,14 +264,15 @@ void clearPending(tagRecord* taginfo) {
|
||||
}
|
||||
|
||||
void initAPconfig() {
|
||||
LittleFS.begin(true);
|
||||
DynamicJsonDocument APconfig(150);
|
||||
File configFile = LittleFS.open("/current/apconfig.json", "r");
|
||||
Storage.begin();
|
||||
DynamicJsonDocument APconfig(500);
|
||||
File configFile = contentFS->open("/current/apconfig.json", "r");
|
||||
if (configFile) {
|
||||
DeserializationError error = deserializeJson(APconfig, configFile);
|
||||
if (error) {
|
||||
configFile.close();
|
||||
Serial.println("failed to read apconfig.json. Using default config");
|
||||
Serial.println(error.c_str());
|
||||
}
|
||||
configFile.close();
|
||||
}
|
||||
@@ -279,8 +285,8 @@ void initAPconfig() {
|
||||
}
|
||||
|
||||
void saveAPconfig() {
|
||||
fs::File configFile = LittleFS.open("/current/apconfig.json", "w");
|
||||
DynamicJsonDocument APconfig(150);
|
||||
fs::File configFile = contentFS->open("/current/apconfig.json", "w");
|
||||
DynamicJsonDocument APconfig(500);
|
||||
APconfig["channel"] = config.channel;
|
||||
APconfig["alias"] = config.alias;
|
||||
APconfig["led"] = config.led;
|
||||
|
||||
@@ -36,6 +36,12 @@ void enterConsoleMode() {
|
||||
xTaskCreate(consoleTask, "consoleTask", 10000, NULL, 2, &consoleTaskHandle);
|
||||
}
|
||||
|
||||
int8_t powerPins[] = FLASHER_AP_POWER;
|
||||
#ifdef OPENEPAPERLINK_PCB
|
||||
int8_t powerPins2[] = FLASHER_EXT_POWER;
|
||||
int8_t powerPins3[] = FLASHER_ALT_POWER;
|
||||
#endif
|
||||
|
||||
void sendFlasherAnswer(uint8_t answer_cmd, uint8_t* ans_buff, uint8_t len) {
|
||||
uint8_t* answer_buffer = (uint8_t*)calloc(2 + 2 + len + 2, 1);
|
||||
if (answer_buffer == nullptr) return;
|
||||
@@ -259,16 +265,17 @@ void processFlasherCommand(struct flasherCommand* cmd) {
|
||||
spi_speed = 8000000;
|
||||
}
|
||||
curspeed = spi_speed;
|
||||
|
||||
if (cmd->data[0] & 2) {
|
||||
temp_buff[0] = zbs->begin(FLASHER_AP_SS, FLASHER_AP_CLK, FLASHER_AP_MOSI, FLASHER_AP_MISO, FLASHER_AP_RESET, FLASHER_AP_POWER, spi_speed);
|
||||
temp_buff[0] = zbs->begin(FLASHER_AP_SS, FLASHER_AP_CLK, FLASHER_AP_MOSI, FLASHER_AP_MISO, FLASHER_AP_RESET, (uint8_t*)powerPins, spi_speed);
|
||||
} else if (cmd->data[0] & 4) {
|
||||
#ifdef OPENEPAPERLINK_PCB
|
||||
temp_buff[0] = zbs->begin(FLASHER_ALT_SS, FLASHER_ALT_CLK, FLASHER_ALT_MOSI, FLASHER_ALT_MISO, FLASHER_ALT_RESET, 255, spi_speed);
|
||||
#endif
|
||||
#ifdef OPENEPAPERLINK_PCB
|
||||
temp_buff[0] = zbs->begin(FLASHER_ALT_SS, FLASHER_ALT_CLK, FLASHER_ALT_MOSI, FLASHER_ALT_MISO, FLASHER_ALT_RESET, (uint8_t*)powerPins3, spi_speed);
|
||||
#endif
|
||||
} else {
|
||||
#ifdef OPENEPAPERLINK_PCB
|
||||
temp_buff[0] = zbs->begin(FLASHER_EXT_SS, FLASHER_EXT_CLK, FLASHER_EXT_MOSI, FLASHER_EXT_MISO, FLASHER_EXT_RESET, FLASHER_EXT_POWER, spi_speed);
|
||||
#endif
|
||||
#ifdef OPENEPAPERLINK_PCB
|
||||
temp_buff[0] = zbs->begin(FLASHER_EXT_SS, FLASHER_EXT_CLK, FLASHER_EXT_MOSI, FLASHER_EXT_MISO, FLASHER_EXT_RESET, (uint8_t*)powerPins2, spi_speed);
|
||||
#endif
|
||||
}
|
||||
sendFlasherAnswer(cmd->command, temp_buff, 1);
|
||||
break;
|
||||
|
||||
@@ -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,35 +216,28 @@ 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;
|
||||
bool res;
|
||||
#ifdef OPENEPAPERLINK_MINI_AP_PCB
|
||||
#if defined(OPENEPAPERLINK_MINI_AP_PCB) || defined(OPENEPAPERLINK_NANO_AP_PCB)
|
||||
WiFi.setTxPower(WIFI_POWER_15dBm);
|
||||
#endif
|
||||
wm.setWiFiAutoReconnect(true);
|
||||
res = wm.autoConnect("OpenEPaperLink Setup");
|
||||
if (!res) {
|
||||
Serial.println("Failed to connect");
|
||||
ESP.restart();
|
||||
}
|
||||
#ifdef OPENEPAPERLINK_MINI_AP_PCB
|
||||
#if defined(OPENEPAPERLINK_MINI_AP_PCB) || defined(OPENEPAPERLINK_NANO_AP_PCB)
|
||||
WiFi.setTxPower(WIFI_POWER_19_5dBm);
|
||||
#endif
|
||||
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);
|
||||
@@ -259,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) {
|
||||
@@ -318,6 +312,12 @@ void init_web() {
|
||||
taginfo->modeConfigJson = request->getParam("modecfgjson", true)->value();
|
||||
taginfo->contentMode = atoi(request->getParam("contentmode", true)->value().c_str());
|
||||
taginfo->nextupdate = 0;
|
||||
if (request->hasParam("rotate", true)) {
|
||||
taginfo->rotate = atoi(request->getParam("rotate", true)->value().c_str());
|
||||
}
|
||||
if (request->hasParam("lut", true)) {
|
||||
taginfo->lut = atoi(request->getParam("lut", true)->value().c_str());
|
||||
}
|
||||
// memset(taginfo->md5, 0, 16 * sizeof(uint8_t));
|
||||
// memset(taginfo->md5pending, 0, 16 * sizeof(uint8_t));
|
||||
wsSendTaginfo(mac, SYNC_USERCFG);
|
||||
@@ -331,27 +331,40 @@ void init_web() {
|
||||
request->send(200, "text/plain", "Ok, saved");
|
||||
});
|
||||
|
||||
server.on("/delete_cfg", HTTP_POST, [](AsyncWebServerRequest *request) {
|
||||
if (request->hasParam("mac", true)) {
|
||||
String dst = request->getParam("mac", true)->value();
|
||||
server.on("/tag_cmd", HTTP_POST, [](AsyncWebServerRequest *request) {
|
||||
if (request->hasParam("mac", true) && request->hasParam("cmd", true)) {
|
||||
uint8_t mac[8];
|
||||
if (hex2mac(dst, mac)) {
|
||||
wsSendTaginfo(mac, SYNC_DELETE);
|
||||
if (deleteRecord(mac)) {
|
||||
request->send(200, "text/plain", "Ok, deleted");
|
||||
if (hex2mac(request->getParam("mac", true)->value(), mac)) {
|
||||
tagRecord *taginfo = nullptr;
|
||||
taginfo = tagRecord::findByMAC(mac);
|
||||
if (taginfo != nullptr) {
|
||||
const char *cmdValue = request->getParam("cmd", true)->value().c_str();
|
||||
if (strcmp(cmdValue, "del") == 0) {
|
||||
wsSendTaginfo(mac, SYNC_DELETE);
|
||||
deleteRecord(mac);
|
||||
}
|
||||
if (strcmp(cmdValue, "clear") == 0) {
|
||||
clearPending(taginfo);
|
||||
memcpy(taginfo->md5pending, taginfo->md5, sizeof(taginfo->md5pending));
|
||||
wsSendTaginfo(mac, SYNC_TAGSTATUS);
|
||||
}
|
||||
if (strcmp(cmdValue, "refresh") == 0) {
|
||||
updateContent(mac);
|
||||
}
|
||||
request->send(200, "text/plain", "Ok, done");
|
||||
} else {
|
||||
request->send(200, "text/plain", "Error while saving: mac not found");
|
||||
request->send(200, "text/plain", "Error: mac not found");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
request->send(500, "text/plain", "no mac");
|
||||
request->send(500, "text/plain", "param error");
|
||||
}
|
||||
});
|
||||
|
||||
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;
|
||||
@@ -391,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();
|
||||
@@ -429,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
|
||||
|
||||
@@ -7,9 +7,13 @@
|
||||
#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, uint32_t spi_speed) {
|
||||
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) {
|
||||
_SS_PIN = SS;
|
||||
_CLK_PIN = CLK;
|
||||
_MOSI_PIN = MOSI;
|
||||
@@ -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;
|
||||
@@ -49,9 +58,7 @@ ZBS_interface::~ZBS_interface() {
|
||||
if(spi)delete spi;
|
||||
}
|
||||
void ZBS_interface::set_power(uint8_t state) {
|
||||
if (_POWER_PIN != 255) {
|
||||
rampTagPower(_POWER_PIN, state);
|
||||
}
|
||||
powerControl(state, _POWER_PIN, _POWER_PINS);
|
||||
}
|
||||
|
||||
void ZBS_interface::enable_debug() {
|
||||
|
||||
BIN
Hardware/2.9-1.54 NanoAP by ATC1441/Antenna_FlexPCB_Gerber.rar
Normal file
BIN
Hardware/2.9-1.54 NanoAP by ATC1441/Antenna_FlexPCB_Gerber.rar
Normal file
Binary file not shown.
BIN
Hardware/2.9-1.54 NanoAP by ATC1441/NanoAP_Case.jpg
Normal file
BIN
Hardware/2.9-1.54 NanoAP by ATC1441/NanoAP_Case.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 233 KiB |
BIN
Hardware/2.9-1.54 NanoAP by ATC1441/NanoAP_Case_V3.stl
Normal file
BIN
Hardware/2.9-1.54 NanoAP by ATC1441/NanoAP_Case_V3.stl
Normal file
Binary file not shown.
BIN
Hardware/2.9-1.54 NanoAP by ATC1441/NanoAP_Flapped.jpg
Normal file
BIN
Hardware/2.9-1.54 NanoAP by ATC1441/NanoAP_Flapped.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 344 KiB |
BIN
Hardware/2.9-1.54 NanoAP by ATC1441/NanoAP_Gerber.rar
Normal file
BIN
Hardware/2.9-1.54 NanoAP by ATC1441/NanoAP_Gerber.rar
Normal file
Binary file not shown.
BIN
Hardware/2.9-1.54 NanoAP by ATC1441/NanoAP_PCB_soldered.jpg
Normal file
BIN
Hardware/2.9-1.54 NanoAP by ATC1441/NanoAP_PCB_soldered.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 565 KiB |
16
Hardware/2.9-1.54 NanoAP by ATC1441/README.md
Normal file
16
Hardware/2.9-1.54 NanoAP by ATC1441/README.md
Normal 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.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -67,6 +67,14 @@ jsonarray = {
|
||||
"tagota": tagota,
|
||||
}
|
||||
|
||||
json_file_path = "files.json"
|
||||
with open(json_file_path, "w") as json_file:
|
||||
with open("jsonfiles/binaries.json", "w") as json_file:
|
||||
json.dump(binaries, json_file, indent=4)
|
||||
|
||||
with open("jsonfiles/files.json", "w") as json_file:
|
||||
json.dump(jsonarray, json_file, indent=4)
|
||||
|
||||
with open("jsonfiles/tagota.json", "w") as json_file:
|
||||
json.dump(tagota, json_file, indent=4)
|
||||
|
||||
with open("jsonfiles/filesystem.json", "w") as json_file:
|
||||
json.dump(files1, json_file, indent=4)
|
||||
|
||||
@@ -20,7 +20,14 @@
|
||||
#define DATATYPE_IMG_RAW_1BPP 0x20 // 2888 bytes for 1.54" / 4736 2.9" / 15000 4.2"
|
||||
#define DATATYPE_IMG_RAW_2BPP 0x21 // 5776 bytes for 1.54" / 9472 2.9" / 30000 4.2"
|
||||
#define DATATYPE_IMG_RAW_1BPP_DIRECT 0x3F // only for 1.54", don't write to EEPROM, but straightaway to the EPD
|
||||
#define DATATYPE_UK_SEGMENTED 0x51 // Segmented data for the UK Segmented display type
|
||||
#define DATATYPE_UK_SEGMENTED 0x51 // Segmented data for the UK Segmented display type (contained in availableData Reply)
|
||||
#define DATATYPE_EU_SEGMENTED 0x52 // Segmented data for the EU/DE Segmented display type (contained in availableData Reply)
|
||||
#define DATATYPE_NFC_RAW_CONTENT 0xA0 // raw memory content for the NT3H1101
|
||||
#define DATATYPE_NFC_URL_DIRECT 0xA1 // URL format for NT3H1101
|
||||
#define DATATYPE_TAG_CONFIG_DATA 0xA8 // Config data for tag
|
||||
#define DATATYPE_COMMAND_DATA 0xAF // Command for the tag to execute (contained in availableData Reply)
|
||||
#define DATATYPE_CUSTOM_LUT_OTA 0xB0 // Custom OTA updated LUT
|
||||
|
||||
#define CMD_DO_REBOOT 0
|
||||
#define CMD_DO_SCAN 1
|
||||
#define CMD_DO_RESET_SETTINGS 2
|
||||
@@ -5,7 +5,7 @@ BUILD ?= zbs29_ssd1619
|
||||
SOURCES += main.c eeprom.c drawing.c
|
||||
SOURCES += comms.c
|
||||
SOURCES += syncedproto.c userinterface.c
|
||||
SOURCES += powermgt.c barcode.c i2cdevices.c
|
||||
SOURCES += powermgt.c barcode.c i2cdevices.c settings.c
|
||||
|
||||
all: #make sure it is the first target
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ bool supportsNFCWake() {
|
||||
}
|
||||
if (pcount < 10000) {
|
||||
// P1_3 (Field Detect) dropped to 'low' pretty fast, this means the load on this pin is high
|
||||
pr("This tag currently does not support NFC wake, load on the FD pin (P1.3) is pretty high.\nOn some boards, a pull-up resistor backpowers the NFC IC. Consider removing it!\n");
|
||||
pr("NFC: This tag currently does not support NFC wake, load on the FD pin (P1.3) is pretty high.\nOn some boards, a pull-up resistor backpowers the NFC IC. Consider removing it!\n");
|
||||
return false;
|
||||
} else {
|
||||
// No reason to believe this pin is currently loaded down severely
|
||||
@@ -121,7 +121,7 @@ bool i2cCheckDevice(uint8_t address) {
|
||||
iictest.deviceAddr = address << 1;
|
||||
uint8_t res = i2cTransact(&iictest, 1);
|
||||
if (res == 0) {
|
||||
pr("Found i2c device at 0x%02X\n", address);
|
||||
pr("I2C: Device found at 0x%02X\n", address);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -23,6 +23,12 @@
|
||||
|
||||
// #define DEBUG_MODE
|
||||
|
||||
static const uint64_t __code __at(0x008b) mVersionRom = 0x1000011300000000ull;
|
||||
|
||||
#define TAG_MODE_CHANSEARCH 0
|
||||
#define TAG_MODE_ASSOCIATED 1
|
||||
uint8_t currentTagMode = TAG_MODE_CHANSEARCH;
|
||||
|
||||
void displayLoop() {
|
||||
powerUp(INIT_BASE | INIT_UART);
|
||||
|
||||
@@ -118,6 +124,7 @@ uint8_t showChannelSelect() { // returns 0 if no accesspoints were found
|
||||
return highestSlot;
|
||||
}
|
||||
uint8_t channelSelect() { // returns 0 if no accesspoints were found
|
||||
powerUp(INIT_RADIO);
|
||||
uint8_t __xdata result[16];
|
||||
memset(result, 0, sizeof(result));
|
||||
|
||||
@@ -128,7 +135,7 @@ uint8_t channelSelect() { // returns 0 if no accesspoints were found
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
powerDown(INIT_RADIO);
|
||||
uint8_t __xdata highestLqi = 0;
|
||||
uint8_t __xdata highestSlot = 0;
|
||||
for (uint8_t c = 0; c < sizeof(result); c++) {
|
||||
@@ -142,79 +149,54 @@ uint8_t channelSelect() { // returns 0 if no accesspoints were found
|
||||
return highestSlot;
|
||||
}
|
||||
|
||||
void main() {
|
||||
// displayLoop(); // remove me
|
||||
setupPortsInitial();
|
||||
powerUp(INIT_BASE | INIT_UART);
|
||||
|
||||
void validateMacAddress() {
|
||||
// check if the mac contains at least some non-0xFF values
|
||||
for (uint8_t __xdata c = 0; c < 8; c++) {
|
||||
if (mSelfMac[c] != 0xFF) goto macIsValid;
|
||||
}
|
||||
// invalid mac address. Display warning screen and sleep forever
|
||||
pr("Mac can't be all FF's.\n");
|
||||
powerUp(INIT_EPD);
|
||||
showNoMAC();
|
||||
powerDown(INIT_EPD | INIT_UART | INIT_EEPROM);
|
||||
doSleep(-1);
|
||||
wdtDeviceReset();
|
||||
macIsValid:
|
||||
return;
|
||||
}
|
||||
uint8_t getFirstWakeUpReason() {
|
||||
if (RESET & 0x01) {
|
||||
wakeUpReason = WAKEUP_REASON_WDT_RESET;
|
||||
pr("WDT reset!\n");
|
||||
} else {
|
||||
wakeUpReason = WAKEUP_REASON_FIRSTBOOT;
|
||||
return WAKEUP_REASON_WDT_RESET;
|
||||
}
|
||||
|
||||
wdt10s();
|
||||
|
||||
boardGetOwnMac(mSelfMac);
|
||||
|
||||
{
|
||||
bool __xdata macSet = false;
|
||||
for (uint8_t __xdata c = 0; c < 8; c++) {
|
||||
if (mSelfMac[c] != 0xFF) {
|
||||
macSet = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!macSet) {
|
||||
pr("Mac can't be all FF's.\n");
|
||||
powerUp(INIT_EPD);
|
||||
showNoMAC();
|
||||
powerDown(INIT_EPD | INIT_UART | INIT_EEPROM);
|
||||
doSleep(-1);
|
||||
wdtDeviceReset();
|
||||
}
|
||||
}
|
||||
|
||||
pr("BOOTED> %d.%d.%d%s\n", fwVersion / 100, (fwVersion % 100) / 10, (fwVersion % 10), fwVersionSuffix);
|
||||
|
||||
return WAKEUP_REASON_FIRSTBOOT;
|
||||
}
|
||||
void checkI2C() {
|
||||
powerUp(INIT_I2C);
|
||||
|
||||
//i2cBusScan();
|
||||
|
||||
// i2cBusScan();
|
||||
if (i2cCheckDevice(0x55)) {
|
||||
powerDown(INIT_I2C);
|
||||
// found something!
|
||||
capabilities |= CAPABILITY_HAS_NFC;
|
||||
if (supportsNFCWake()) {
|
||||
pr("This board supports NFC wake!\n");
|
||||
pr("NFC: NFC Wake Supported\n");
|
||||
capabilities |= CAPABILITY_NFC_WAKE;
|
||||
}
|
||||
} else {
|
||||
pr("I2C: No devices found");
|
||||
// didn't find a NFC chip on the expected ID
|
||||
powerDown(INIT_I2C);
|
||||
}
|
||||
}
|
||||
|
||||
pr("MAC>%02X%02X", mSelfMac[0], mSelfMac[1]);
|
||||
pr("%02X%02X", mSelfMac[2], mSelfMac[3]);
|
||||
pr("%02X%02X", mSelfMac[4], mSelfMac[5]);
|
||||
pr("%02X%02X\n", mSelfMac[6], mSelfMac[7]);
|
||||
|
||||
powerUp(INIT_RADIO); // load down the battery using the radio to get a good voltage reading
|
||||
powerUp(INIT_EPD_VOLTREADING | INIT_TEMPREADING);
|
||||
powerDown(INIT_RADIO);
|
||||
|
||||
powerUp(INIT_EEPROM);
|
||||
// get the highest slot number, number of slots
|
||||
initializeProto();
|
||||
powerDown(INIT_EEPROM);
|
||||
|
||||
void detectButtonOrJig() {
|
||||
switch (checkButtonOrJig()) {
|
||||
case DETECT_P1_0_BUTTON:
|
||||
capabilities |= CAPABILITY_HAS_WAKE_BUTTON;
|
||||
break;
|
||||
case DETECT_P1_0_JIG:
|
||||
wdt120s();
|
||||
// show the screensaver (minimal text to prevent image burn-in)
|
||||
// show the screensaver, full LUT (minimal text to prevent image burn-in)
|
||||
powerUp(INIT_EPD);
|
||||
afterFlashScreenSaver();
|
||||
while (1)
|
||||
@@ -225,161 +207,258 @@ void main() {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// show the splashscreen
|
||||
powerUp(INIT_EPD);
|
||||
showSplashScreen();
|
||||
void TagAssociated() {
|
||||
// associated
|
||||
struct AvailDataInfo *__xdata avail;
|
||||
// Is there any reason why we should do a long (full) get data request (including reason, status)?
|
||||
if ((longDataReqCounter > LONG_DATAREQ_INTERVAL) || wakeUpReason != WAKEUP_REASON_TIMED) {
|
||||
// check if we should do a voltage measurement (those are pretty expensive)
|
||||
if (voltageCheckCounter == VOLTAGE_CHECK_INTERVAL) {
|
||||
doVoltageReading();
|
||||
voltageCheckCounter = 0;
|
||||
} else {
|
||||
powerUp(INIT_TEMPREADING);
|
||||
}
|
||||
voltageCheckCounter++;
|
||||
|
||||
// check if the battery level is below minimum, and force a redraw of the screen
|
||||
|
||||
if ((lowBattery && !lowBatteryShown && tagSettings.enableLowBatSymbol) || (noAPShown && tagSettings.enableNoRFSymbol)) {
|
||||
// Check if we were already displaying an image
|
||||
if (curImgSlot != 0xFF) {
|
||||
powerUp(INIT_EEPROM | INIT_EPD);
|
||||
wdt60s();
|
||||
drawImageFromEeprom(curImgSlot);
|
||||
powerDown(INIT_EEPROM | INIT_EPD);
|
||||
} else {
|
||||
powerUp(INIT_EPD);
|
||||
showAPFound();
|
||||
powerDown(INIT_EPD);
|
||||
}
|
||||
}
|
||||
|
||||
powerUp(INIT_RADIO);
|
||||
avail = getAvailDataInfo();
|
||||
powerDown(INIT_RADIO);
|
||||
|
||||
if (avail != NULL) {
|
||||
// we got some data!
|
||||
longDataReqCounter = 0;
|
||||
// since we've had succesful contact, and communicated the wakeup reason succesfully, we can now reset to the 'normal' status
|
||||
wakeUpReason = WAKEUP_REASON_TIMED;
|
||||
}
|
||||
if (tagSettings.enableTagRoaming) {
|
||||
uint8_t roamChannel = channelSelect();
|
||||
if (roamChannel) currentChannel = roamChannel;
|
||||
}
|
||||
} else {
|
||||
powerUp(INIT_RADIO);
|
||||
avail = getShortAvailDataInfo();
|
||||
powerDown(INIT_RADIO);
|
||||
}
|
||||
|
||||
addAverageValue();
|
||||
|
||||
if (avail == NULL) {
|
||||
// no data :( this means no reply from AP
|
||||
nextCheckInFromAP = 0; // let the power-saving algorithm determine the next sleep period
|
||||
} else {
|
||||
nextCheckInFromAP = avail->nextCheckIn;
|
||||
// got some data from the AP!
|
||||
if (avail->dataType != DATATYPE_NOUPDATE) {
|
||||
// data transfer
|
||||
if (processAvailDataInfo(avail)) {
|
||||
// succesful transfer, next wake time is determined by the NextCheckin;
|
||||
} else {
|
||||
// failed transfer, let the algorithm determine next sleep interval (not the AP)
|
||||
nextCheckInFromAP = 0;
|
||||
}
|
||||
} else {
|
||||
// no data transfer, just sleep.
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t nextCheckin = getNextSleep();
|
||||
longDataReqCounter += nextCheckin;
|
||||
|
||||
if (nextCheckin == INTERVAL_AT_MAX_ATTEMPTS) {
|
||||
// We've averaged up to the maximum interval, this means the tag hasn't been in contact with an AP for some time.
|
||||
if (tagSettings.enableScanForAPAfterTimeout) {
|
||||
currentTagMode = TAG_MODE_CHANSEARCH;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// if the AP told us to sleep for a specific period, do so.
|
||||
if (nextCheckInFromAP) {
|
||||
doSleep(nextCheckInFromAP * 60000UL);
|
||||
} else {
|
||||
doSleep(getNextSleep() * 1000UL);
|
||||
}
|
||||
}
|
||||
|
||||
void TagChanSearch() {
|
||||
// not associated
|
||||
if (((scanAttempts != 0) && (scanAttempts % VOLTAGEREADING_DURING_SCAN_INTERVAL == 0)) || (scanAttempts > (INTERVAL_1_ATTEMPTS + INTERVAL_2_ATTEMPTS))) {
|
||||
doVoltageReading();
|
||||
}
|
||||
|
||||
// try to find a working channel
|
||||
currentChannel = channelSelect();
|
||||
|
||||
// Check if we should redraw the screen with icons, info screen or screensaver
|
||||
if ((!currentChannel && !noAPShown && tagSettings.enableNoRFSymbol) ||
|
||||
(lowBattery && !lowBatteryShown && tagSettings.enableLowBatSymbol) ||
|
||||
(scanAttempts == (INTERVAL_1_ATTEMPTS + INTERVAL_2_ATTEMPTS - 1))) {
|
||||
powerUp(INIT_EPD);
|
||||
wdt60s();
|
||||
if (curImgSlot != 0xFF) {
|
||||
powerUp(INIT_EEPROM);
|
||||
drawImageFromEeprom(curImgSlot);
|
||||
powerDown(INIT_EEPROM);
|
||||
} else if ((scanAttempts >= (INTERVAL_1_ATTEMPTS + INTERVAL_2_ATTEMPTS - 1))) {
|
||||
showLongTermSleep();
|
||||
} else {
|
||||
showNoAP();
|
||||
}
|
||||
powerDown(INIT_EPD);
|
||||
}
|
||||
|
||||
// did we find a working channel?
|
||||
if (currentChannel) {
|
||||
// now associated! set up and bail out of this loop.
|
||||
scanAttempts = 0;
|
||||
wakeUpReason = WAKEUP_REASON_NETWORK_SCAN;
|
||||
initPowerSaving(INTERVAL_BASE);
|
||||
doSleep(getNextSleep() * 1000UL);
|
||||
currentTagMode = TAG_MODE_ASSOCIATED;
|
||||
return;
|
||||
} else {
|
||||
// still not associated
|
||||
doSleep(getNextScanSleep(true) * 1000UL);
|
||||
}
|
||||
}
|
||||
|
||||
void executeCommand(uint8_t cmd) {
|
||||
switch (cmd) {
|
||||
case CMD_DO_REBOOT:
|
||||
wdtDeviceReset();
|
||||
break;
|
||||
case CMD_DO_RESET_SETTINGS:
|
||||
loadDefaultSettings();
|
||||
writeSettings();
|
||||
break;
|
||||
case CMD_DO_SCAN:
|
||||
currentChannel = channelSelect();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
// displayLoop(); // remove me
|
||||
setupPortsInitial();
|
||||
powerUp(INIT_BASE | INIT_UART);
|
||||
pr("BOOTED> %d.%d.%d%s\n", fwVersion / 100, (fwVersion % 100) / 10, (fwVersion % 10), fwVersionSuffix);
|
||||
|
||||
// Find the reason why we're booting; is this a WDT?
|
||||
wakeUpReason = getFirstWakeUpReason();
|
||||
|
||||
// get our own mac address. this is stored in Infopage at offset 0x10-onwards
|
||||
boardGetOwnMac(mSelfMac);
|
||||
pr("MAC>%02X%02X", mSelfMac[0], mSelfMac[1]);
|
||||
pr("%02X%02X", mSelfMac[2], mSelfMac[3]);
|
||||
pr("%02X%02X", mSelfMac[4], mSelfMac[5]);
|
||||
pr("%02X%02X\n", mSelfMac[6], mSelfMac[7]);
|
||||
|
||||
// load settings from infopage
|
||||
loadSettings();
|
||||
|
||||
// get the highest slot number, number of slots
|
||||
initializeProto();
|
||||
|
||||
if (tagSettings.enableFastBoot) {
|
||||
// Fastboot
|
||||
pr("Doing fast boot\n");
|
||||
capabilities = tagSettings.fastBootCapabilities;
|
||||
if (tagSettings.fixedChannel) {
|
||||
currentChannel = tagSettings.fixedChannel;
|
||||
} else {
|
||||
currentChannel = channelSelect();
|
||||
}
|
||||
} else {
|
||||
// Normal boot/startup
|
||||
|
||||
// validate the mac address; this will display a warning on the screen if the mac address is invalid
|
||||
validateMacAddress();
|
||||
|
||||
#if (NFC_TYPE == 1)
|
||||
// initialize I2C
|
||||
checkI2C();
|
||||
#endif
|
||||
|
||||
// Get a voltage reading on the tag, loading down the battery with the radio
|
||||
doVoltageReading();
|
||||
|
||||
// detect button or jig
|
||||
detectButtonOrJig();
|
||||
|
||||
// show the splashscreen
|
||||
pr("EPD: First powerup\n");
|
||||
powerUp(INIT_EPD);
|
||||
showSplashScreen();
|
||||
|
||||
// we've now displayed something on the screen; for the SSD1619, we are now aware of the lut-size
|
||||
#ifdef EPD_SSD1619
|
||||
capabilities |= CAPABILITY_SUPPORTS_CUSTOM_LUTS;
|
||||
if (dispLutSize != 7) {
|
||||
capabilities |= CAPABILITY_ALT_LUT_SIZE;
|
||||
}
|
||||
capabilities |= CAPABILITY_SUPPORTS_CUSTOM_LUTS;
|
||||
if (dispLutSize != 7) {
|
||||
capabilities |= CAPABILITY_ALT_LUT_SIZE;
|
||||
}
|
||||
#endif
|
||||
tagSettings.fastBootCapabilities = capabilities;
|
||||
|
||||
powerUp(INIT_EPD);
|
||||
wdt30s();
|
||||
currentChannel = showChannelSelect();
|
||||
// now that we've collected all possible capabilities, save it to settings
|
||||
writeSettings();
|
||||
|
||||
// scan for channels
|
||||
powerUp(INIT_EPD);
|
||||
wdt30s();
|
||||
if (tagSettings.fixedChannel) {
|
||||
currentChannel = tagSettings.fixedChannel;
|
||||
} else {
|
||||
currentChannel = showChannelSelect();
|
||||
}
|
||||
}
|
||||
|
||||
// end of the fastboot option split
|
||||
wdt10s();
|
||||
|
||||
powerUp(INIT_EPD);
|
||||
if (currentChannel) {
|
||||
showAPFound();
|
||||
initPowerSaving(INTERVAL_BASE);
|
||||
powerDown(INIT_EPD | INIT_UART);
|
||||
currentTagMode = TAG_MODE_ASSOCIATED;
|
||||
doSleep(5000UL);
|
||||
} else {
|
||||
showNoAP();
|
||||
initPowerSaving(INTERVAL_AT_MAX_ATTEMPTS);
|
||||
powerDown(INIT_EPD | INIT_UART);
|
||||
currentTagMode = TAG_MODE_CHANSEARCH;
|
||||
doSleep(120000UL);
|
||||
}
|
||||
|
||||
// this is the loop we'll stay in forever, basically.
|
||||
while (1) {
|
||||
powerUp(INIT_UART);
|
||||
wdt10s();
|
||||
if (currentChannel) {
|
||||
// associated
|
||||
|
||||
struct AvailDataInfo *__xdata avail;
|
||||
// Is there any reason why we should do a long (full) get data request (including reason, status)?
|
||||
if ((longDataReqCounter > LONG_DATAREQ_INTERVAL) || wakeUpReason != WAKEUP_REASON_TIMED) {
|
||||
// check if we should do a voltage measurement (those are pretty expensive)
|
||||
if (voltageCheckCounter == VOLTAGE_CHECK_INTERVAL) {
|
||||
powerUp(INIT_RADIO); // load down the battery using the radio to get a good reading
|
||||
powerUp(INIT_TEMPREADING | INIT_EPD_VOLTREADING);
|
||||
powerDown(INIT_RADIO);
|
||||
voltageCheckCounter = 0;
|
||||
} else {
|
||||
powerUp(INIT_TEMPREADING);
|
||||
}
|
||||
voltageCheckCounter++;
|
||||
|
||||
// check if the battery level is below minimum, and force a redraw of the screen
|
||||
if ((lowBattery && !lowBatteryShown) || (noAPShown)) {
|
||||
// Check if we were already displaying an image
|
||||
if (curImgSlot != 0xFF) {
|
||||
powerUp(INIT_EEPROM | INIT_EPD);
|
||||
wdt60s();
|
||||
drawImageFromEeprom(curImgSlot);
|
||||
powerDown(INIT_EEPROM | INIT_EPD);
|
||||
} else {
|
||||
powerUp(INIT_EPD);
|
||||
showAPFound();
|
||||
powerDown(INIT_EPD);
|
||||
}
|
||||
}
|
||||
powerUp(INIT_RADIO);
|
||||
avail = getAvailDataInfo();
|
||||
powerDown(INIT_RADIO);
|
||||
|
||||
if (avail != NULL) {
|
||||
// we got some data!
|
||||
longDataReqCounter = 0;
|
||||
// since we've had succesful contact, and communicated the wakeup reason succesfully, we can now reset to the 'normal' status
|
||||
wakeUpReason = WAKEUP_REASON_TIMED;
|
||||
}
|
||||
} else {
|
||||
powerUp(INIT_RADIO);
|
||||
avail = getShortAvailDataInfo();
|
||||
powerDown(INIT_RADIO);
|
||||
}
|
||||
|
||||
addAverageValue();
|
||||
|
||||
if (avail == NULL) {
|
||||
// no data :(
|
||||
nextCheckInFromAP = 0; // let the power-saving algorithm determine the next sleep period
|
||||
} else {
|
||||
nextCheckInFromAP = avail->nextCheckIn;
|
||||
// got some data from the AP!
|
||||
if (avail->dataType != DATATYPE_NOUPDATE) {
|
||||
// data transfer
|
||||
if (processAvailDataInfo(avail)) {
|
||||
// succesful transfer, next wake time is determined by the NextCheckin;
|
||||
} else {
|
||||
// failed transfer, let the algorithm determine next sleep interval (not the AP)
|
||||
nextCheckInFromAP = 0;
|
||||
}
|
||||
} else {
|
||||
// no data transfer, just sleep.
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t nextCheckin = getNextSleep();
|
||||
longDataReqCounter += nextCheckin;
|
||||
if (nextCheckin == INTERVAL_AT_MAX_ATTEMPTS) {
|
||||
// disconnected, obviously...
|
||||
currentChannel = 0;
|
||||
}
|
||||
|
||||
// if the AP told us to sleep for a specific period, do so.
|
||||
if (nextCheckInFromAP) {
|
||||
doSleep(nextCheckInFromAP * 60000UL);
|
||||
} else {
|
||||
doSleep(getNextSleep() * 1000UL);
|
||||
}
|
||||
|
||||
} else {
|
||||
// not associated
|
||||
if (((scanAttempts != 0) && (scanAttempts % VOLTAGEREADING_DURING_SCAN_INTERVAL == 0)) || (scanAttempts > (INTERVAL_1_ATTEMPTS + INTERVAL_2_ATTEMPTS))) {
|
||||
powerUp(INIT_RADIO); // load down the battery using the radio to get a good reading
|
||||
powerUp(INIT_EPD_VOLTREADING);
|
||||
powerDown(INIT_RADIO);
|
||||
}
|
||||
// try to find a working channel
|
||||
powerUp(INIT_RADIO);
|
||||
currentChannel = channelSelect();
|
||||
powerDown(INIT_RADIO);
|
||||
|
||||
if ((!currentChannel && !noAPShown) || (lowBattery && !lowBatteryShown) || (scanAttempts == (INTERVAL_1_ATTEMPTS + INTERVAL_2_ATTEMPTS - 1))) {
|
||||
powerUp(INIT_EPD);
|
||||
wdt60s();
|
||||
if (curImgSlot != 0xFF) {
|
||||
powerUp(INIT_EEPROM);
|
||||
drawImageFromEeprom(curImgSlot);
|
||||
powerDown(INIT_EEPROM);
|
||||
} else if ((scanAttempts >= (INTERVAL_1_ATTEMPTS + INTERVAL_2_ATTEMPTS - 1))) {
|
||||
showLongTermSleep();
|
||||
} else {
|
||||
showNoAP();
|
||||
}
|
||||
powerDown(INIT_EPD);
|
||||
}
|
||||
|
||||
// did we find a working channel?
|
||||
if (currentChannel) {
|
||||
// now associated!
|
||||
scanAttempts = 0;
|
||||
wakeUpReason = WAKEUP_REASON_NETWORK_SCAN;
|
||||
initPowerSaving(INTERVAL_BASE);
|
||||
doSleep(getNextSleep() * 1000UL);
|
||||
|
||||
} else {
|
||||
// still not associated
|
||||
doSleep(getNextScanSleep(true) * 1000UL);
|
||||
}
|
||||
switch (currentTagMode) {
|
||||
case TAG_MODE_ASSOCIATED:
|
||||
TagAssociated();
|
||||
break;
|
||||
case TAG_MODE_CHANSEARCH:
|
||||
TagChanSearch();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
45
zbs243_Tag_FW/main.lk
Normal file
45
zbs243_Tag_FW/main.lk
Normal file
@@ -0,0 +1,45 @@
|
||||
-muwx
|
||||
-i main.ihx
|
||||
-M
|
||||
-X 0x2000
|
||||
-C 0xfc00
|
||||
-b HOME = 0x0000
|
||||
-b XSEG = 0xe000
|
||||
-b PSEG = 0xe000
|
||||
-b ISEG = 0x0000
|
||||
-b BSEG = 0x0000
|
||||
-k /usr/local/bin/../share/sdcc/lib/large
|
||||
-k /usr/local/share/sdcc/lib/large
|
||||
-l mcs51
|
||||
-l libsdcc
|
||||
-l libint
|
||||
-l liblong
|
||||
-l libfloat
|
||||
main.rel
|
||||
eeprom.rel
|
||||
drawing.rel
|
||||
comms.rel
|
||||
syncedproto.rel
|
||||
userinterface.rel
|
||||
powermgt.rel
|
||||
barcode.rel
|
||||
i2cdevices.rel
|
||||
settings.rel
|
||||
soc/zbs243/soc.rel
|
||||
soc/zbs243/wdt.rel
|
||||
soc/zbs243/sleep.rel
|
||||
soc/zbs243/spi.rel
|
||||
soc/zbs243/uart.rel
|
||||
soc/zbs243/timer.rel
|
||||
soc/zbs243/radio.rel
|
||||
soc/zbs243/flash.rel
|
||||
soc/zbs243/temperature.rel
|
||||
cpu/8051/random.rel
|
||||
cpu/8051/printf.rel
|
||||
soc/zbs243/i2c.rel
|
||||
cpu/8051/asmUtil.rel
|
||||
cpu/8051/cpu.rel
|
||||
board/zbs29_uc8151/board.rel
|
||||
board/zbs29_uc8151/screen.rel
|
||||
|
||||
-e
|
||||
@@ -34,7 +34,7 @@ uint8_t __xdata wakeUpReason = 0;
|
||||
uint8_t __xdata scanAttempts = 0;
|
||||
|
||||
int8_t __xdata temperature = 0;
|
||||
uint16_t __xdata batteryVoltage = 0;
|
||||
uint16_t __xdata batteryVoltage = 2600;
|
||||
bool __xdata lowBattery = false;
|
||||
uint16_t __xdata longDataReqCounter = 0;
|
||||
uint16_t __xdata voltageCheckCounter = 0;
|
||||
@@ -153,10 +153,11 @@ static void configI2C(const bool setup) {
|
||||
if (setup) {
|
||||
P1DIR &= ~(1 << 6);
|
||||
P1_6 = 1;
|
||||
timerDelay(13330);
|
||||
P1FUNC |= (1 << 4) | (1 << 5);
|
||||
P1PULL |= (1 << 4) | (1 << 5);
|
||||
i2cInit();
|
||||
i2cCheckDevice(0x50); // first transaction after init fails, this makes sure everything is ready for the first transaction
|
||||
// i2cCheckDevice(0x50); // first transaction after init fails, this makes sure everything is ready for the first transaction
|
||||
} else {
|
||||
P1DIR |= (1 << 6);
|
||||
P1_6 = 0;
|
||||
@@ -174,6 +175,7 @@ void powerUp(const uint8_t parts) {
|
||||
timerInit();
|
||||
irqsOn();
|
||||
wdtOn();
|
||||
wdt10s();
|
||||
}
|
||||
|
||||
if (parts & INIT_EPD) {
|
||||
@@ -186,7 +188,7 @@ void powerUp(const uint8_t parts) {
|
||||
epdConfigGPIO(true);
|
||||
configSPI(true);
|
||||
batteryVoltage = epdGetBattery();
|
||||
if (batteryVoltage < BATTERY_VOLTAGE_MINIMUM) {
|
||||
if (batteryVoltage < tagSettings.batLowVoltage) {
|
||||
lowBattery = true;
|
||||
} else {
|
||||
lowBattery = false;
|
||||
@@ -302,7 +304,12 @@ void doSleep(const uint32_t __xdata t) {
|
||||
P1CHSTA &= ~(1 << 3);
|
||||
}
|
||||
|
||||
// sleepy
|
||||
if (tagSettings.enableRFWake) {
|
||||
// enabled RF wake, adds a little extra energy draw!
|
||||
RADIO_RadioPowerCtl &= 0xFB;
|
||||
}
|
||||
|
||||
// sleepy time
|
||||
sleepForMsec(t);
|
||||
P1INTEN = 0;
|
||||
if ((P1CHSTA & (1 << 0)) && (capabilities & CAPABILITY_HAS_WAKE_BUTTON)) {
|
||||
@@ -316,6 +323,12 @@ void doSleep(const uint32_t __xdata t) {
|
||||
}
|
||||
}
|
||||
|
||||
void doVoltageReading() {
|
||||
powerUp(INIT_RADIO); // load down the battery using the radio to get a good voltage reading
|
||||
powerUp(INIT_EPD_VOLTREADING | INIT_TEMPREADING);
|
||||
powerDown(INIT_RADIO);
|
||||
}
|
||||
|
||||
uint32_t getNextScanSleep(const bool increment) {
|
||||
if (increment) {
|
||||
if (scanAttempts < 255)
|
||||
@@ -346,5 +359,8 @@ uint16_t getNextSleep() {
|
||||
avg += dataReqAttemptArr[c];
|
||||
}
|
||||
avg /= POWER_SAVING_SMOOTHING;
|
||||
|
||||
// check if we should sleep longer due to an override in the config
|
||||
if (avg < tagSettings.minimumCheckInTime) return tagSettings.minimumCheckInTime;
|
||||
return avg;
|
||||
}
|
||||
@@ -55,6 +55,8 @@ extern void powerDown(const uint8_t parts);
|
||||
extern void initAfterWake();
|
||||
extern void doSleep(const uint32_t __xdata t);
|
||||
|
||||
void doVoltageReading();
|
||||
|
||||
extern void addAverageValue();
|
||||
extern uint16_t getNextSleep();
|
||||
|
||||
|
||||
95
zbs243_Tag_FW/settings.c
Executable file
95
zbs243_Tag_FW/settings.c
Executable file
@@ -0,0 +1,95 @@
|
||||
#include "settings.h"
|
||||
|
||||
#include <flash.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "asmUtil.h"
|
||||
#include "powermgt.h"
|
||||
#include "printf.h"
|
||||
#include "syncedproto.h"
|
||||
|
||||
struct tagsettings __xdata tagSettings = {0};
|
||||
extern uint8_t __xdata blockXferBuffer[];
|
||||
uint8_t* __xdata infopageTempBuffer = 1024 + blockXferBuffer;
|
||||
|
||||
#define INFOPAGE_SETTINGS_OFFSET 0x50
|
||||
|
||||
void loadDefaultSettings() {
|
||||
tagSettings.settingsVer = SETTINGS_STRUCT_VERSION;
|
||||
tagSettings.enableFastBoot = DEFAULT_SETTING_FASTBOOT;
|
||||
tagSettings.enableRFWake = DEFAULT_SETTING_RFWAKE;
|
||||
tagSettings.enableTagRoaming = DEFAULT_SETTING_TAGROAMING;
|
||||
tagSettings.enableScanForAPAfterTimeout = DEFAULT_SETTING_SCANFORAP;
|
||||
tagSettings.enableLowBatSymbol = DEFAULT_SETTING_LOWBATSYMBOL;
|
||||
tagSettings.enableNoRFSymbol = DEFAULT_SETTING_NORFSYMBOL;
|
||||
tagSettings.customMode = 0;
|
||||
tagSettings.fastBootCapabilities = 0;
|
||||
tagSettings.minimumCheckInTime = INTERVAL_BASE;
|
||||
tagSettings.fixedChannel = 0;
|
||||
tagSettings.batLowVoltage = BATTERY_VOLTAGE_MINIMUM;
|
||||
}
|
||||
|
||||
void loadSettingsFromBuffer(uint8_t* p) {
|
||||
pr("SETTINGS: received settings from AP\n");
|
||||
switch (*p) {
|
||||
case SETTINGS_STRUCT_VERSION: // the current tag struct
|
||||
pr("SETTINGS: received matching version\n");
|
||||
memcpy((void*)tagSettings, (void*)p, sizeof(struct tagsettings));
|
||||
break;
|
||||
default:
|
||||
pr("SETTINGS: received something we couldn't really process, version %d\n");
|
||||
break;
|
||||
}
|
||||
tagSettings.fastBootCapabilities = capabilities;
|
||||
writeSettings();
|
||||
}
|
||||
|
||||
static bool compareSettings() {
|
||||
// check if the settings match the settings in the infopage
|
||||
flashRead(FLASH_INFOPAGE_ADDR + INFOPAGE_SETTINGS_OFFSET, (void*)infopageTempBuffer, sizeof(struct tagsettings));
|
||||
if (memcmp((void*)infopageTempBuffer, (void*)tagSettings, sizeof(struct tagsettings)) == 0) {
|
||||
// same
|
||||
return true;
|
||||
}
|
||||
// different
|
||||
return false;
|
||||
}
|
||||
|
||||
static void upgradeSettings() {
|
||||
// add an upgrade strategy whenever you update the struct version
|
||||
}
|
||||
|
||||
void loadSettings() {
|
||||
flashRead((FLASH_INFOPAGE_ADDR + INFOPAGE_SETTINGS_OFFSET), (void*)infopageTempBuffer, sizeof(struct tagsettings));
|
||||
xMemCopy((void*)tagSettings, (void*)infopageTempBuffer, sizeof(struct tagsettings));
|
||||
if (tagSettings.settingsVer == 0xFF) {
|
||||
// settings not set. load the defaults
|
||||
loadDefaultSettings();
|
||||
pr("SETTINGS: Loaded default settings\n");
|
||||
} else {
|
||||
if (tagSettings.settingsVer < SETTINGS_STRUCT_VERSION) {
|
||||
// upgrade
|
||||
upgradeSettings();
|
||||
pr("SETTINGS: Upgraded from previous version\n");
|
||||
} else {
|
||||
// settings are valid
|
||||
pr("SETTINGS: Loaded from infopage\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void writeSettings() {
|
||||
if (compareSettings()) {
|
||||
pr("SETTINGS: Settings matched current settings\n");
|
||||
return;
|
||||
}
|
||||
flashRead(FLASH_INFOPAGE_ADDR, (void*)infopageTempBuffer, 1024);
|
||||
xMemCopy((void*)(infopageTempBuffer + INFOPAGE_SETTINGS_OFFSET), (void*)tagSettings, sizeof(tagSettings));
|
||||
flashErase(FLASH_INFOPAGE_ADDR + 1);
|
||||
flashWrite(FLASH_INFOPAGE_ADDR, (void*)infopageTempBuffer, 1024, false);
|
||||
pr("SETTINGS: Updated settings in infopage\n");
|
||||
}
|
||||
@@ -3,8 +3,39 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define FW_VERSION 017 // version number (max 2.5.5 :) )
|
||||
#define FW_VERSION_SUFFIX "-CLUT" // suffix, like -RC1 or whatever.
|
||||
#define FW_VERSION 18 // version number (max 2.5.5 :) )
|
||||
#define FW_VERSION_SUFFIX "-RW" // suffix, like -RC1 or whatever.
|
||||
// #define DEBUGBLOCKS // uncomment to enable extra debug information on the block transfers
|
||||
// #define PRINT_LUT // uncomment if you want the tag to print the LUT for the current temperature bracket
|
||||
|
||||
#define SETTINGS_STRUCT_VERSION 0x01
|
||||
|
||||
#define DEFAULT_SETTING_FASTBOOT 0
|
||||
#define DEFAULT_SETTING_RFWAKE 0
|
||||
#define DEFAULT_SETTING_TAGROAMING 0
|
||||
#define DEFAULT_SETTING_SCANFORAP 1
|
||||
#define DEFAULT_SETTING_LOWBATSYMBOL 1
|
||||
#define DEFAULT_SETTING_NORFSYMBOL 1
|
||||
|
||||
struct tagsettings {
|
||||
uint8_t settingsVer; // the version of the struct as written to the infopage
|
||||
uint8_t enableFastBoot; // default 0; if set, it will skip splashscreen
|
||||
uint8_t enableRFWake; // default 0; if set, it will enable RF wake. This will add about ~0.9µA idle power consumption
|
||||
uint8_t enableTagRoaming; // default 0; if set, the tag will scan for an accesspoint every few check-ins. This will increase power consumption quite a bit
|
||||
uint8_t enableScanForAPAfterTimeout; // default 1; if a the tag failed to check in, after a few attempts it will try to find a an AP on other channels
|
||||
uint8_t enableLowBatSymbol; // default 1; tag will show 'low battery' icon on screen if the battery is depleted
|
||||
uint8_t enableNoRFSymbol; // default 1; tag will show 'no signal' icon on screen if it failed to check in for a longer period of time
|
||||
uint8_t fastBootCapabilities; // holds the byte with 'capabilities' as detected during a normal tag boot; allows the tag to skip detecting buttons and NFC chip
|
||||
uint8_t customMode; // default 0; if anything else, tag will bootup in a different 'mode'
|
||||
uint16_t batLowVoltage; // Low battery threshold voltage (2450 for 2.45v). defaults to BATTERY_VOLTAGE_MINIMUM from powermgt.h
|
||||
uint16_t minimumCheckInTime; // defaults to BASE_INTERVAL from powermgt.h
|
||||
uint8_t fixedChannel; // default 0; if set to a valid channel number, the tag will stick to that channel
|
||||
} __packed;
|
||||
|
||||
extern struct tagsettings tagSettings;
|
||||
|
||||
void loadDefaultSettings();
|
||||
void writeSettings();
|
||||
void loadSettings();
|
||||
void loadSettingsFromBuffer(uint8_t* p);
|
||||
#endif
|
||||
@@ -50,6 +50,8 @@ uint8_t __xdata currentChannel = 0;
|
||||
static uint8_t __xdata inBuffer[128] = {0};
|
||||
static uint8_t __xdata outBuffer[128] = {0};
|
||||
|
||||
extern void executeCommand(uint8_t cmd); // this is defined in main.c
|
||||
|
||||
// tools
|
||||
static uint8_t __xdata getPacketType(const void *__xdata buffer) {
|
||||
const struct MacFcs *__xdata fcs = buffer;
|
||||
@@ -471,6 +473,7 @@ static uint32_t getHighSlotId() {
|
||||
return temp;
|
||||
}
|
||||
|
||||
// data transfer stuff
|
||||
static uint8_t __xdata partsThisBlock = 0;
|
||||
static uint8_t __xdata blockAttempts = 0; // these CAN be local to the function, but for some reason, they won't survive sleep?
|
||||
// they get overwritten with 7F 32 44 20 00 00 00 00 11, I don't know why.
|
||||
@@ -570,6 +573,7 @@ static bool getDataBlock(const uint16_t blockSize) {
|
||||
pr("failed getting block\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
uint16_t __xdata dataRequestSize = 0;
|
||||
static bool downloadFWUpdate(const struct AvailDataInfo *__xdata avail) {
|
||||
// check if we already started the transfer of this information & haven't completed it
|
||||
@@ -847,6 +851,37 @@ bool processAvailDataInfo(struct AvailDataInfo *__xdata avail) {
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
case DATATYPE_TAG_CONFIG_DATA:
|
||||
if (curDataInfo.dataSize == 0 && xMemEqual((const void *__xdata) & avail->dataVer, (const void *__xdata) & curDataInfo.dataVer, 8)) {
|
||||
pr("this was the same as the last transfer, disregard\n");
|
||||
powerUp(INIT_RADIO);
|
||||
sendXferComplete();
|
||||
powerDown(INIT_RADIO);
|
||||
return true;
|
||||
}
|
||||
curBlock.blockId = 0;
|
||||
xMemCopy8(&(curBlock.ver), &(avail->dataVer));
|
||||
curBlock.type = avail->dataType;
|
||||
xMemCopyShort(&curDataInfo, (void *)avail, sizeof(struct AvailDataInfo));
|
||||
wdt10s();
|
||||
if (getDataBlock(avail->dataSize)) {
|
||||
curDataInfo.dataSize = 0; // mark as transfer not pending
|
||||
loadSettingsFromBuffer(sizeof(struct blockData) + blockXferBuffer);
|
||||
powerUp(INIT_RADIO);
|
||||
sendXferComplete();
|
||||
powerDown(INIT_RADIO);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
case DATATYPE_COMMAND_DATA:
|
||||
pr("CMD received\n");
|
||||
powerUp(INIT_RADIO);
|
||||
sendXferComplete();
|
||||
powerDown(INIT_RADIO);
|
||||
executeCommand(avail->dataTypeArgument);
|
||||
return true;
|
||||
break;
|
||||
case DATATYPE_CUSTOM_LUT_OTA:
|
||||
// Handle data for the NFC IC (if we have it)
|
||||
|
||||
@@ -874,7 +909,7 @@ bool processAvailDataInfo(struct AvailDataInfo *__xdata avail) {
|
||||
wdt10s();
|
||||
if (getDataBlock(avail->dataSize)) {
|
||||
curDataInfo.dataSize = 0; // mark as transfer not pending
|
||||
memcpy(customLUT, sizeof(struct blockData) + blockXferBuffer, dispLutSize * 10);
|
||||
memcpy(customLUT, sizeof(struct blockData) + blockXferBuffer, 6 + (dispLutSize * 10));
|
||||
powerUp(INIT_RADIO);
|
||||
sendXferComplete();
|
||||
powerDown(INIT_RADIO);
|
||||
@@ -888,6 +923,8 @@ bool processAvailDataInfo(struct AvailDataInfo *__xdata avail) {
|
||||
}
|
||||
|
||||
void initializeProto() {
|
||||
powerUp(INIT_EEPROM);
|
||||
getNumSlots();
|
||||
curHighSlotId = getHighSlotId();
|
||||
powerDown(INIT_EEPROM);
|
||||
}
|
||||
2
zbs243_Tag_FW/syncedproto.h
Normal file → Executable file
2
zbs243_Tag_FW/syncedproto.h
Normal file → Executable file
@@ -13,7 +13,7 @@ extern uint8_t __xdata curImgSlot;
|
||||
extern void setupRadio(void);
|
||||
extern void killRadio(void);
|
||||
|
||||
|
||||
void dump(const uint8_t *__xdata a, const uint16_t __xdata l);
|
||||
extern struct AvailDataInfo *__xdata getAvailDataInfo();
|
||||
extern struct AvailDataInfo *__xdata getShortAvailDataInfo();
|
||||
extern void drawImageFromEeprom(const uint8_t imgSlot);
|
||||
|
||||
@@ -51,7 +51,7 @@ void addCapabilities() {
|
||||
}
|
||||
|
||||
void addOverlay() {
|
||||
if (currentChannel == 0) {
|
||||
if ((currentChannel == 0)&&(tagSettings.enableNoRFSymbol)) {
|
||||
#if (SCREEN_WIDTH == 152)
|
||||
loadRawBitmap(ant, SCREEN_WIDTH - 16, 0, EPD_COLOR_BLACK);
|
||||
loadRawBitmap(cross, SCREEN_WIDTH - 8, 7, EPD_COLOR_RED);
|
||||
@@ -67,7 +67,7 @@ void addOverlay() {
|
||||
noAPShown = false;
|
||||
}
|
||||
|
||||
if (batteryVoltage != 2600) {
|
||||
if ((batteryVoltage < tagSettings.batLowVoltage) && (tagSettings.enableLowBatSymbol)) {
|
||||
#if (SCREEN_WIDTH == 152)
|
||||
loadRawBitmap(battery, SCREEN_WIDTH - 16, SCREEN_HEIGHT - 10, EPD_COLOR_BLACK);
|
||||
#elif (SCREEN_WIDTH == 400)
|
||||
@@ -81,7 +81,6 @@ void addOverlay() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void afterFlashScreenSaver() {
|
||||
selectLUT(EPD_LUT_DEFAULT);
|
||||
clearScreen();
|
||||
@@ -106,7 +105,6 @@ void afterFlashScreenSaver() {
|
||||
drawWithSleep();
|
||||
}
|
||||
|
||||
|
||||
void showSplashScreen() {
|
||||
selectLUT(EPD_LUT_NO_REPEATS);
|
||||
clearScreen();
|
||||
|
||||
@@ -42,6 +42,11 @@
|
||||
#define CMD_YSTART_POS 0x4F
|
||||
#define CMD_ANALOG_BLK_CTRL 0x74
|
||||
#define CMD_DIGITAL_BLK_CTRL 0x7E
|
||||
// added for OTA LUT-support
|
||||
#define CMD_GATE_LEVEL 0x03
|
||||
#define CMD_SOURCE_LEVEL 0x04
|
||||
#define CMD_DUMMY_PERIOD 0x3A
|
||||
#define CMD_GATE_LINE_WIDTH 0x3B
|
||||
|
||||
#define SCREEN_CMD_CLOCK_ON 0x80
|
||||
#define SCREEN_CMD_CLOCK_OFF 0x01
|
||||
@@ -83,7 +88,7 @@ bool __xdata epdGPIOActive = false;
|
||||
|
||||
#define LUT_BUFFER_SIZE 128
|
||||
static uint8_t waveformbuffer[LUT_BUFFER_SIZE];
|
||||
uint8_t __xdata customLUT[LUT_BUFFER_SIZE] = {0};
|
||||
uint8_t __xdata customLUT[LUT_BUFFER_SIZE] = {0};
|
||||
|
||||
struct waveform10* __xdata waveform10 = (struct waveform10*)waveformbuffer; // holds the LUT/waveform
|
||||
struct waveform* __xdata waveform7 = (struct waveform*)waveformbuffer; // holds the LUT/waveform
|
||||
@@ -378,14 +383,6 @@ void selectLUT(uint8_t lut) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Handling if we received an OTA LUT
|
||||
if (lut == EPD_LUT_OTA) {
|
||||
memcpy(waveformbuffer, customLUT, dispLutSize * 10);
|
||||
writeLut();
|
||||
currentLut = lut;
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentLut != EPD_LUT_DEFAULT) {
|
||||
// load the 'default' LUT for the current temperature in the EPD lut register
|
||||
shortCommand1(CMD_DISP_UPDATE_CTRL2, 0xB1); // mode 1?
|
||||
@@ -447,6 +444,22 @@ void selectLUT(uint8_t lut) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Handling if we received an OTA LUT
|
||||
if (lut == EPD_LUT_OTA) {
|
||||
memcpy(waveformbuffer, customLUT, dispLutSize * 10);
|
||||
writeLut();
|
||||
shortCommand1(CMD_GATE_LEVEL, customLUT[70]);
|
||||
commandBegin(CMD_SOURCE_LEVEL);
|
||||
epdSend(customLUT[71]);
|
||||
epdSend(customLUT[72]);
|
||||
epdSend(customLUT[73]);
|
||||
commandEnd();
|
||||
shortCommand1(CMD_DUMMY_PERIOD, customLUT[74]);
|
||||
shortCommand1(CMD_GATE_LINE_WIDTH, customLUT[75]);
|
||||
currentLut = lut;
|
||||
return;
|
||||
}
|
||||
|
||||
if (dispLutSize == 10) {
|
||||
lutGroupDisable(LUTGROUP_UNUSED);
|
||||
lutGroupDisable(LUTGROUP_UNKNOWN);
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
#define HAS_EEPROM 1
|
||||
#define HAS_SCREEN 1
|
||||
#define NFC_TYPE 1
|
||||
#define AP_EMULATE_TAG 1
|
||||
|
||||
//hw types
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
#define HAS_EEPROM 1
|
||||
#define HAS_SCREEN 1
|
||||
#define NFC_TYPE 1
|
||||
#define AP_EMULATE_TAG 1
|
||||
|
||||
//hw types
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
#define HAS_EEPROM 1
|
||||
#define HAS_SCREEN 1
|
||||
#define NFC_TYPE 1
|
||||
#define AP_EMULATE_TAG 1
|
||||
|
||||
//hw types
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
#define HAS_EEPROM 1
|
||||
#define HAS_SCREEN 1
|
||||
#define NFC_TYPE 2
|
||||
#define AP_EMULATE_TAG 1
|
||||
|
||||
//hw types
|
||||
|
||||
Reference in New Issue
Block a user