57 Commits

Author SHA1 Message Date
Mimoja
aff20e272c Add updateRemote.sh script to update the contentFs on multiple APs at once
As flashing a new LittleFS in case of e.g. a changed main.js is taking time and
the provided web interface is not the fastest to navigate we are introducing a
small script to upload the whole data folder to the esp.
It can also be sourced into a shell allowing for manual file uploads to the esp.

In addition we are also adding a "push_ota.sh" script designed to show its use as
well as uploading the recenty build firmware to the esp where future commits will
allow of SDCard based updates.

Signed-off-by: Mimoja <git@mimoja.de>
2023-07-08 01:21:29 +02:00
Mimoja
8078b4aeed Refactor build flags
So far the platform-io build-flags config option was a copy&paste
situation from one board to the next.
With the recently introduced new supported board these build-flags
are redundant and difficult to oversee.
Longterm they should ideally be partially generated to ensure a good
customizability but for now we are moving the common ones into the
base env where they can be imported by all the boards.

Signed-off-by: Mimoja <git@mimoja.de>
2023-07-08 01:21:29 +02:00
Mimoja
fd22bc0378 Fix: Properly calculate db size for SystemInfo
So far the calculated size for the tagDB in the frontend was
purely based on the size of each of its static entries.
However the data pointer as well as the json based config string
can occupy additional memory which is not accounted for.

We are therefore introducing a helper function to properly
calculate the DBs size.

Signed-off-by: Mimoja <git@mimoja.de>
2023-07-08 01:21:29 +02:00
atc1441
63463435cd Updated NanoAp 3D Printed case to a new version 2023-07-05 22:56:58 +02:00
Jelmer
3dd4f23880 Update README.md
added license
2023-07-04 22:22:18 +02:00
Jelmer
9891d23db1 Create LICENSE
Added CC-BY-NC-SA
2023-07-04 22:04:03 +02:00
Jelmer
4ed9d2e2e9 Merge pull request #77 from Mimoja/powerPins
ESP: Fix Powermanagement for non-configured POWER

Sensible changes, thank you!
2023-07-04 20:42:33 +02:00
Mimoja
a60bc91205 ESP: Fix Powermanagement for non-configured POWER
We currently have two ways of undefining the PowerPin in software for the ESP32
For once we can set POWER_NO_SOFT_POWER which will lead to some helpful screen
messages _but_ will still require the definition of the FLASHER_AP_POWER pin.

The second way (which was replaced with POWER_NO_SOFT_POWER) allowed to set the
powerPin array to {-1} to indicate that the pin is undefined. This would then be
handled in pretty far down the call stack right before toggeling the pin in powerControl:

```
 void powerControl(bool powerState, uint8_t* pin, uint8_t pincount) {
    if (pin[0] == -1) return;
```

This however is leading to an error: pin is n pointer (here an array with additional length)
to an uint8_t which can never be -1. Therefore the check wont ever be reached and an invalid
gpio number is passed to the gpio hal.
This caused the error:
```
  E (XXXX) gpio: gpio_set_level(226): GPIO output gpio_num error
```
to show up in the logs.
We are now proposing three seperate changes to mitigate this behaviour:
1) We are addng the POWER_NO_SOFT_POWER to the Wemos and the M5Stack boards default configs
for new users to find.
2) We are replacing the pin[0] check in powerControl with a check on the pincount and a
nullptr check as the zbs_interface->begin() allows for no powerPin to be passed in which
case we are dereferencing a nullptr.
3) ZBS_interface->begin() is losing its powerPin related default configurations and
sanity checks are put in place before every calling.

We have opted to do 3) in this way and not adding the checked into the ZBS_interface->begin()
function which is also passed an uint8_t pointer to keep the API of the class stable
for reuse in other projects. Changing the interface however would be ideal here

Signed-off-by: Mimoja <git@mimoja.de>
2023-07-03 21:39:41 +02:00
Jonas Niesner
9f86c9ef2c Update main.js
fix
2023-07-02 08:40:37 +02:00
Jonas Niesner
f7078363a4 Update main.js
added ap temp
2023-07-02 08:39:22 +02:00
Jonas Niesner
e0fd1e0f86 Update index.html
added ap temp
2023-07-02 08:38:07 +02:00
Jonas Niesner
057cf14298 Added additional system info to websocket 2023-07-01 11:51:20 +02:00
Nic Limper
51da22b0d4 small fix 2023-06-28 13:52:30 +02:00
Nic Limper
42a3651075 channel id, tag fw version and tag commands integrated in webinterface 2023-06-28 13:11:33 +02:00
Nic Limper
56dfd0c2f0 fix Weemos typo in automatic builds 2023-06-28 11:34:09 +02:00
Nic Limper
716d9823db various small fixes
- cleanup font in flash. Don't forget to update content_template.json in the file system after updating fw.
- fix layout issue in update window
- better error handling + auto retry during fw update
- fixed spelling 'weemos' -> 'wemos_d1_mini32' in build name
2023-06-28 11:01:08 +02:00
Jelmer
da6d783e3b added new larger availdatareq struct for esp32 2023-06-27 23:17:01 +02:00
jjwbruijn
306e5aaf00 bigger availdatareq struct with version 2023-06-27 23:00:11 +02:00
Nic Limper
5376f2540e layout bugfix
fixes issue #74
2023-06-27 14:14:52 +02:00
Jonas Niesner
a251ed10e7 Cleaned up release.yml and added 2 new platforms 2023-06-26 09:51:21 +02:00
Jonas Niesner
65410e3e8d Improve push/pr test pipeline 2023-06-26 09:46:57 +02:00
Jonas Niesner
b2174c2980 cleaned up platformio.ini 2023-06-26 09:44:30 +02:00
Jelmer
7db482a6ba Delete AP_force_flash.bin 2023-06-26 09:02:53 +02:00
Jelmer
bac7cf7ab5 Merge pull request #71 from Mimoja/misc
Misc changes to for low-effort setups
2023-06-25 15:17:52 +02:00
Jelmer
a3e739b8da Merge pull request #72 from slimline33/master
Thank you for your contribution!
2023-06-25 15:16:47 +02:00
Mimoja
cc1dcd9d29 ESP: split esp2buffer into two calls
Sprite rendering is the most heap hungry operation in during
content generation. This can lead to ESP panics as the exception
for the failing "new" is not handled.
To further half the required the memory we are doing it in two passes
for black and red independant. While this add a few ms to the rendering
the main time of the rendering is writing to the FS anyways so the overhead
neglectable after all.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

We are adding a default config which is workable with the old
pinconfig as those are usually the only ones exposed on the
breakout boards.
2023-06-20 17:24:53 +02:00
atc1441
6c4e254db0 Update NanoAP_Case.jpg 2023-06-19 22:43:48 +02:00
atc1441
5ccbcb4719 Nano AP Infos and Files added 2023-06-19 22:42:24 +02:00
atc1441
617b49eb86 Yep, Pinout of NanoAP fixed... 2023-06-19 11:47:46 +02:00
Jelmer
5868abf189 Merge pull request #64 from jjwbruijn/customLUTTest
Tag-side config options with binaries
2023-06-15 14:35:14 +02:00
Jelmer
94be1ea3aa Added possibility to xfer tag-side config options 2023-06-15 13:18:12 +02:00
jjwbruijn
5190327d5a optimized i2c, disabled for 4.2 2023-06-15 11:42:15 +02:00
jjwbruijn
6ecf6410ee moved some defaults, fixed typo 2023-06-14 22:11:30 +02:00
jjwbruijn
e72e89d85e Added settings/config for tags 2023-06-14 21:45:36 +02:00
Jonas Niesner
054146677f Fixed release description overwrite 2023-06-13 18:22:46 +02:00
Jonas Niesner
58d9fe2217 Split json file list 2023-06-13 18:21:33 +02:00
jjwbruijn
5196c1b212 76 bytes custom OTA Lut and changes location of the init 2023-06-09 14:59:00 +02:00
77 changed files with 1871 additions and 667 deletions

View File

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

View File

@@ -26,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 Wemos_d1_mini32_AP
run: |
cd ESP32_AP-Flasher
export PLATFORMIO_BUILD_FLAGS="-D BUILD_VERSION=${{ github.ref_name }} -D SHA=$GITHUB_SHA"
pio run --environment Wemos_d1_mini32_AP
pio run --target buildfs --environment Wemos_d1_mini32_AP
mkdir /home/runner/work/OpenEPaperLink/OpenEPaperLink/Wemos_d1_mini32_AP
cp ~/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin /home/runner/work/OpenEPaperLink/OpenEPaperLink/Wemos_d1_mini32_AP/boot_app0.bin
cp .pio/build/Wemos_d1_mini32_AP/firmware.bin /home/runner/work/OpenEPaperLink/OpenEPaperLink/Wemos_d1_mini32_AP/firmware.bin
cp .pio/build/Wemos_d1_mini32_AP/bootloader.bin /home/runner/work/OpenEPaperLink/OpenEPaperLink/Wemos_d1_mini32_AP/bootloader.bin
cp .pio/build/Wemos_d1_mini32_AP/partitions.bin /home/runner/work/OpenEPaperLink/OpenEPaperLink/Wemos_d1_mini32_AP/partitions.bin
cp .pio/build/Wemos_d1_mini32_AP/littlefs.bin /home/runner/work/OpenEPaperLink/OpenEPaperLink/Wemos_d1_mini32_AP/littlefs.bin
cd /home/runner/work/OpenEPaperLink/OpenEPaperLink/Wemos_d1_mini32_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 Wemos_d1_mini32_AP/firmware.bin espbinaries/Wemos_d1_mini32_AP.bin
cp Wemos_d1_mini32_AP/merged-firmware.bin espbinaries/Wemos_d1_mini32_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

View File

@@ -31,7 +31,7 @@
},
"4": {
"0": {
"location": [ 10, 130, 2 ],
"location": [ 10, 145, "t0_14b_tf" ],
"wind": [ 140, 10, "fonts/bahnschrift30" ],
"temp": [ 10, 10, "fonts/bahnschrift30" ],
"icon": [ 33, 33, "fonts/weathericons78" ],
@@ -57,7 +57,7 @@
},
"8": {
"1": {
"location": [ 5, 0, 2 ],
"location": [ 5, 12, "t0_14b_tf" ],
"column": [ 5, 59 ],
"day": [ 30, 18, "fonts/twcondensed20", 41, 108 ],
"icon": [ 12, 58, "fonts/weathericons30" ],
@@ -90,7 +90,7 @@
},
"10": {
"0": {
"title": [ 10, 3, 2 ],
"title": [ 10, 15, "t0_14b_tf" ],
"pos": [ 76, 20 ]
},
"1": {
@@ -122,7 +122,7 @@
"1": {
"location": [ 5, 5, "fonts/bahnschrift30" ],
"title": [ 247, 11, "glasstown_nbp_tf" ],
"cols": [ 1, 125, 12 ],
"cols": [ 1, 125, 12, "glasstown_nbp_tf" ],
"bars": [ 5, 111, 10 ]
}
}

View File

@@ -406,5 +406,132 @@
"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"
}
}
]
}
]

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

View File

@@ -7,7 +7,7 @@
<title>Open EPaper Link Access Point</title>
<link rel="stylesheet" href="main.css" type="text/css" />
<link rel="icon" href="data:,">
<link rel="icon" type="image/vnd.icon" href="favicon.ico">
</head>
<body>
@@ -43,11 +43,13 @@
<option value="0">auto</option>
</select>
</p>
<p>
<p class="tagbuttons">
<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>
<button id="cfgtagreboot">reboot</button>
<button id="cfgscan">scan</button>
<button id="cfgreset">reset settings</button>
<button id="cfgdelete" title="remove"><img src="data:image/gif;base64,R0lGODlhEAAQAPMAANXV1e3t7d/f39HR0dvb2/Hx8dTU1OLi4urq6mZmZpmZmf///wAAAAAAAAAAAAAAACH5BAEAAAwALAAAAAAQABAAAARBkMlJq71Yrp3ZXkr4WWCYnOZSgQVyEMYwJCq1nHhe20qgCAoA7QLyAYU7njE4JPV+zOSkCEUSFbmTVPPpbjvgTAQAOw== "></button>
</p>
</div>
<p id="savebar">
@@ -157,10 +159,11 @@ Latency will be around 40 seconds.">
<div class="actionbox">
<div>
<div>Currently active tags:</div>
<div><span id="temp"></div>
<div><span id="runstate"></div>
<div><span id="apstatecolor">&#11044;</span> <span id="apstate">loading</span></div>
<div><span id="apconfigbutton">AP config</span></div>
<div><a href="/edit" target="littlefs" class="filebutton">edit littleFS</a></div>
<div><a href="/edit" target="littlefs" class="filebutton">edit contentFS</a></div>
</div>
</div>
@@ -171,9 +174,7 @@ Latency will be around 40 seconds.">
<div class="alias"></div>
<div class="model"></div>
<div class="received">
RSSI&nbsp;<div class="rssi"></div>, LQI&nbsp;<div class="lqi"></div><div class="temperature"></div><div class="batt"></div>
</div>
<div class="received"></div>
<div class="contentmode"></div>
<div class="lastseen"></div>
@@ -206,4 +207,4 @@ Latency will be around 40 seconds.">
</body>
</html>
</html>

View File

@@ -120,6 +120,8 @@ select {
background-color: #f0e6d3;
z-index: 999;
box-shadow: 7px 10px 52px -19px rgba(0, 0, 0, 0.63);
overflow: auto;
max-height: calc(100vh - 75px);
}
#configbox p, #apconfigbox p, #apupdatebox p {
@@ -152,6 +154,15 @@ select {
font-size: 1.2em;
}
.tagbuttons {
flex-flow: wrap;
}
.tagbuttons button {
font-size: 0.95em;
padding: 2px 4px;
}
#savebar {
display: flex;
align-items: flex-end;
@@ -482,6 +493,11 @@ ul.messages li.new {
background-color: #ffffff;
padding: 1px 5px;
min-width: 70px;
vertical-align: baseline;
}
#releasetable td:nth-child(2) {
word-wrap: nowrap;
}
#releasetable button {

View File

@@ -24,13 +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;
@@ -48,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;
@@ -94,11 +94,12 @@ function connect() {
processTags(msg.tags);
}
if (msg.sys) {
$('#sysinfo').innerHTML = 'free heap: ' + msg.sys.heap + ' bytes &#x2507; db size: ' + msg.sys.dbsize + ' bytes &#x2507; db record count: ' + msg.sys.recordcount + ' &#x2507; littlefs free: ' + msg.sys.littlefsfree + ' bytes';
$('#sysinfo').innerHTML = 'free heap: ' + msg.sys.heap + ' bytes &#x2507; db size: ' + convertSize(msg.sys.dbsize) + " ("+ msg.sys.dbsize + ' bytes) &#x2507; db record count: ' + msg.sys.recordcount + ' &#x2507; filesystem free: ' + 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;
$("#temp").innerHTML = msg.sys.temp.toFixed(1) + '°C';
}
servertimediff = (Date.now() / 1000) - msg.sys.currtime;
}
@@ -127,6 +128,16 @@ function connect() {
});
}
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;
@@ -165,14 +176,22 @@ function processTags(tagArray) {
if (element.RSSI) {
div.dataset.hwtype = element.hwType;
$('#tag' + tagmac + ' .model').innerHTML = models[element.hwType];
$('#tag' + tagmac + ' .rssi').innerHTML = element.RSSI;
$('#tag' + tagmac + ' .lqi').innerHTML = element.LQI;
$('#tag' + tagmac + ' .temperature').innerHTML = (element.temperature > 0 ? ", " + element.temperature + "&deg;C": "");
if (element.batteryMv == 0 || element.batteryMv == 1337) {
$('#tag' + tagmac + ' .batt').innerHTML = "";
let statusline = "";
if (element.RSSI != 100) {
if (element.ch > 0) statusline += `CH ${element.ch}, `;
statusline += `RSSI ${element.RSSI}, LQI ${element.LQI}`;
} else {
$('#tag' + tagmac + ' .batt').innerHTML = ", " + (element.batteryMv >= 2600 ? "&#x2265;" : "") + (element.batteryMv / 1000) + "V";
statusline = "AP";
}
if (element.batteryMv != 0 && element.batteryMv != 1337) {
statusline += ", " + (element.batteryMv >= 2600 ? "&#x2265;" : "") + (element.batteryMv / 1000) + "V";
}
if (element.ver != 0 && element.ver != 1) {
$('#tag' + tagmac + ' .received').title = `fw: ${element.ver}`;
} else {
$('#tag' + tagmac + ' .received').title = "";
}
$('#tag' + tagmac + ' .received').innerHTML = statusline;
$('#tag' + tagmac + ' .received').style.opacity = "1";
} else {
$('#tag' + tagmac + ' .model').innerHTML = "waiting for hardware type";
@@ -307,7 +326,7 @@ $('#taglist').addEventListener("click", (event) => {
$('#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();
@@ -354,7 +373,7 @@ $('#cfgsave').onclick = function () {
formData.append("rotate", $('#cfgrotate').value);
formData.append("lut", $('#cfglut').value);
fetch("/save_cfg", {
method: "POST",
body: formData
@@ -398,6 +417,18 @@ $('#cfgrefresh').onclick = function () {
sendCmd($('#cfgmac').dataset.mac, "refresh");
}
$('#cfgtagreboot').onclick = function () {
sendCmd($('#cfgmac').dataset.mac, "reboot");
}
$('#cfgscan').onclick = function () {
sendCmd($('#cfgmac').dataset.mac, "scan");
}
$('#cfgreset').onclick = function () {
sendCmd($('#cfgmac').dataset.mac, "reset");
}
$('#rebootbutton').onclick = function () {
showMessage("rebooting AP....", true);
fetch("/reboot", {
@@ -530,6 +561,12 @@ function contentselected() {
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;

View File

@@ -95,13 +95,13 @@ export async function initUpdate() {
const table = document.createElement('table');
const tableHeader = document.createElement('tr');
tableHeader.innerHTML = '<th>Release</th><th>Date</th><th>Name</th><th>Author</th><th colspan="2">Update:</th><th>Remark</th>';
tableHeader.innerHTML = '<th>Release</th><th>Date</th><th>Name</th><th colspan="2">Update:</th><th>Remark</th>';
table.appendChild(tableHeader);
releaseDetails.forEach(release => {
if (release && release.html_url) {
const tableRow = document.createElement('tr');
let tablerow = `<td><a href="${release.html_url}" target="_new">${release.tag_name}</a></td><td>${release.date}</td><td>${release.name}</td><td>${release.author}</td><td><button onclick="otamodule.updateESP('${release.file_url}', true)">ESP32</button></td><td><button onclick="otamodule.updateWebpage('${release.file_url}','${release.tag_name}', true)">Filesystem</button></td>`;
let tablerow = `<td><a href="${release.html_url}" target="_new">${release.tag_name}</a></td><td>${release.date}</td><td>${release.name}</td><td><button onclick="otamodule.updateESP('${release.file_url}', true)">ESP32</button></td><td><button onclick="otamodule.updateWebpage('${release.file_url}','${release.tag_name}', true)">Filesystem</button></td>`;
if (release.tag_name == currentVer) {
tablerow += "<td>current version</td>";
} else if (release.date < formatEpoch(currentBuildtime)) {
@@ -245,46 +245,68 @@ export async function updateESP(fileUrl, showConfirm) {
let binurl, binmd5, binsize;
try {
const response = await fetch("/getexturl?url=" + fileUrl);
const data = await response.json();
const file = data.binaries.find((entry) => entry.name == env + '.bin');
if (file) {
binurl = file.url;
binmd5 = file.md5;
binsize = file.size;
console.log(`URL for "${file.name}": ${binurl}`);
let retryCount = 0;
const maxRetries = 5;
try {
const response = await fetch('/update_ota', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
body: new URLSearchParams({
url: binurl,
md5: binmd5,
size: binsize
})
});
while (retryCount < maxRetries) {
try {
const response = await fetch("/getexturl?url=" + fileUrl);
if (response.ok) {
const result = await response.text();
print('OTA update initiated.');
} else {
print('Failed to initiate OTA update: ' + response.status, "red");
}
} catch (error) {
print('Error during OTA update: ' + error, "red");
if (!response.ok) {
throw new Error("Network response was not OK");
}
} else {
print(`File "${fileName}" not found.`, "red");
const responseBody = await response.text();
if (responseBody.trim()[0] !== "{") {
throw new Error("Failed to fetch the release info file");
}
const data = JSON.parse(responseBody);
const file = data.binaries?.find((entry) => entry.name == env + '.bin');
if (file) {
binurl = file.url;
binmd5 = file.md5;
binsize = file.size;
console.log(`URL for "${file.name}": ${binurl}`);
try {
const response = await fetch('/update_ota', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
body: new URLSearchParams({
url: binurl,
md5: binmd5,
size: binsize
})
});
if (response.ok) {
const result = await response.text();
print('OTA update initiated.');
} else {
print('Failed to initiate OTA update: ' + response.status, "red");
}
} catch (error) {
print('Error during OTA update: ' + error, "red");
}
break;
} else {
print(`No info about "${env}" found in the release.`, "red");
}
} catch (error) {
print('Error: ' + error.message, "yellow");
retryCount++;
print(`Retrying... attempt ${retryCount}`);
await new Promise((resolve) => setTimeout(resolve, 3000));
}
} catch (error) {
print('Error: ' + error, "red");
print("Something went wrong, try again.");
}
if (retryCount === maxRetries) {
print("Reached maximum retry count. Failed to execute the update.", "red");
}
running = false;
disableButtons(false);
}

View File

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

View File

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

View File

@@ -36,6 +36,10 @@ struct AvailDataReq {
uint8_t hwType;
uint8_t wakeupReason;
uint8_t capabilities;
uint16_t tagSoftwareVersion;
uint8_t currentChannel;
uint8_t customMode;
uint8_t reserved[8];
} __packed;
struct espAvailDataReq {
@@ -107,4 +111,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)

View File

@@ -37,5 +37,6 @@ String windDirectionIcon(int degrees);
void getLocation(JsonObject &cfgobj);
void prepareNFCReq(uint8_t* dst, const char* url);
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);

View File

@@ -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);

View File

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

View File

@@ -18,7 +18,7 @@
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), rotate(0), lut(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), tagSoftwareVersion(0), currentChannel(0),
dataType(0), filename(""), data(nullptr), len(0) {}
uint8_t mac[8];
@@ -44,6 +44,8 @@ class tagRecord {
bool hasCustomLUT;
uint8_t rotate;
uint8_t lut;
uint16_t tagSoftwareVersion;
uint8_t currentChannel;
uint8_t dataType;
String filename;

View File

@@ -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 = nullptr, uint8_t powerPins = 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, uint8_t powerPins, uint32_t spi_speed = 8000000);
void setSpeed(uint32_t speed);
void set_power(uint8_t state);
void enable_debug();

View File

@@ -21,15 +21,24 @@ 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
build_flags =
-D BUILD_ENV_NAME=$PIOENV
-D BUILD_TIME=$UNIX_TIME
-D USER_SETUP_LOADED
-D DISABLE_ALL_LIBRARY_WARNINGS
-D ILI9341_DRIVER
-D SMOOTH_FONT
; ----------------------------------------------------------------------------------------
; !!! this configuration expects the Mini_AP
;
; ----------------------------------------------------------------------------------------
[env:OpenEPaperLink_Mini_AP]
platform = https://github.com/platformio/platform-espressif32.git
board=lolin_s2_mini
@@ -37,18 +46,14 @@ board_build.partitions = default.csv
build_unflags =
-D CONFIG_MBEDTLS_INTERNAL_MEM_ALLOC=y
build_flags =
-D BUILD_ENV_NAME=$PIOENV
-D BUILD_TIME=$UNIX_TIME
${env.build_flags}
-D OPENEPAPERLINK_MINI_AP_PCB
-D ARDUINO_USB_MODE=0
-D CONFIG_SPIRAM_USE_MALLOC=1
-D CONFIG_MBEDTLS_EXTERNAL_MEM_ALLOC=y
-D HAS_RGB_LED
-D BOARD_HAS_PSRAM
-D POWER_NO_SOFT_POWER
-D FLASHER_AP_SS=11
-D FLASHER_AP_CLK=9
-D FLASHER_AP_MOSI=10
@@ -60,23 +65,17 @@ build_flags =
-D FLASHER_AP_TEST=12
-D FLASHER_LED=15
-D FLASHER_RGB_LED=33
-D USER_SETUP_LOADED
-D DISABLE_ALL_LIBRARY_WARNINGS
-D ILI9341_DRIVER
-D SMOOTH_FONT
-D LOAD_FONT2
build_src_filter =
+<*>-<usbflasher.cpp>-<serialconsole.cpp>
board_build.psram_type=qspi_opi
board_upload.maximum_size = 4194304
;board_upload.maximum_ram_size = 2097152
board_upload.maximum_ram_size = 327680
board_upload.flash_size = 4MB
; ----------------------------------------------------------------------------------------
; !!! this configuration expects the Nano_AP
;
; ----------------------------------------------------------------------------------------
[env:OpenEPaperLink_Nano_AP]
platform = https://github.com/platformio/platform-espressif32.git
board=lolin_s2_mini
@@ -84,15 +83,12 @@ board_build.partitions = default.csv
build_unflags =
-D CONFIG_MBEDTLS_INTERNAL_MEM_ALLOC=y
build_flags =
-D BUILD_ENV_NAME=$PIOENV
-D BUILD_TIME=$UNIX_TIME
${env.build_flags}
-D OPENEPAPERLINK_NANO_AP_PCB
-D ARDUINO_USB_MODE=0
-D CONFIG_SPIRAM_USE_MALLOC=1
-D CONFIG_MBEDTLS_EXTERNAL_MEM_ALLOC=y
-D BOARD_HAS_PSRAM
-D FLASHER_AP_SS=38
-D FLASHER_AP_CLK=40
-D FLASHER_AP_MOSI=39
@@ -100,27 +96,17 @@ build_flags =
-D FLASHER_AP_RESET=37
-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
;
@@ -129,13 +115,11 @@ 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
build_flags =
-D BUILD_ENV_NAME=$PIOENV
-D BUILD_TIME=$UNIX_TIME
${env.build_flags}
-D OPENEPAPERLINK_PCB
-D ARDUINO_USB_MODE=0
-D CONFIG_ESP32S3_SPIRAM_SUPPORT=1
@@ -144,10 +128,8 @@ build_flags =
-D HAS_RGB_LED
-D BOARD_HAS_PSRAM
-D CONFIG_MBEDTLS_EXTERNAL_MEM_ALLOC=y
-D POWER_RAMPING
-D POWER_HIGH_SIDE_DRIVER
-D FLASHER_AP_SS=4
-D FLASHER_AP_CLK=5
-D FLASHER_AP_MOSI=7
@@ -157,7 +139,6 @@ build_flags =
-D FLASHER_AP_TXD=16
-D FLASHER_AP_RXD=18
-D FLASHER_AP_TEST=17
-D FLASHER_EXT_SS=40
-D FLASHER_EXT_CLK=41
-D FLASHER_EXT_MOSI=2
@@ -167,7 +148,6 @@ build_flags =
-D FLASHER_EXT_TXD=38
-D FLASHER_EXT_RXD=39
-D FLASHER_EXT_TEST=47
-D FLASHER_ALT_SS=3
-D FLASHER_ALT_CLK=46
-D FLASHER_ALT_MOSI=10
@@ -177,34 +157,26 @@ build_flags =
-D FLASHER_ALT_TXD=12
-D FLASHER_ALT_RXD=14
-D FLASHER_ALT_TEST=13
-D FLASHER_LED=21
-D FLASHER_RGB_LED=48
-D USER_SETUP_LOADED
-D DISABLE_ALL_LIBRARY_WARNINGS
-D ILI9341_DRIVER
-D SMOOTH_FONT
-D LOAD_FONT2
board_build.flash_mode=qio
board_build.arduino.memory_type = qio_opi
board_build.psram_type=qspi_opi
board_upload.maximum_size = 16777216
board_upload.maximum_ram_size = 327680
board_upload.flash_size = 16MB
; ----------------------------------------------------------------------------------------
; !!! this configuration expects an esp32
;
; ----------------------------------------------------------------------------------------
[env:Simple_AP]
board = esp32dev
board_build.partitions = default.csv
build_flags =
-D BUILD_ENV_NAME=$PIOENV
-D BUILD_TIME=$UNIX_TIME
${env.build_flags}
-D CORE_DEBUG_LEVEL=0
-D SIMPLE_AP
-D FLASHER_AP_SS=5
-D FLASHER_AP_CLK=18
-D FLASHER_AP_MOSI=23
@@ -215,38 +187,68 @@ build_flags =
-D FLASHER_AP_TXD=17
-D FLASHER_AP_RXD=16
-D FLASHER_LED=22
build_src_filter =
+<*>-<usbflasher.cpp>-<serialconsole.cpp>
; ----------------------------------------------------------------------------------------
; !!! this configuration expects an wemos_d1_mini32
;
; ----------------------------------------------------------------------------------------
[env:Wemos_d1_mini32_AP]
board = wemos_d1_mini32
board_build.partitions = default.csv
build_flags =
${env.build_flags}
-D CORE_DEBUG_LEVEL=0
-D POWER_NO_SOFT_POWER
-D FLASHER_AP_SS=5
-D FLASHER_AP_CLK=18
-D FLASHER_AP_MOSI=23
-D FLASHER_AP_MISO=19
-D FLASHER_AP_RESET=14
-D FLASHER_AP_POWER={-1}
-D FLASHER_AP_TEST=-1
-D FLASHER_AP_TXD=16
-D FLASHER_AP_RXD=17
-D FLASHER_LED=22
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 =
${env.build_flags}
-D CORE_DEBUG_LEVEL=0
-D POWER_NO_SOFT_POWER
-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>
; ----------------------------------------------------------------------------------------
; !!! this configuration expects the alternative 2.9" Flasher PCB
; ----------------------------------------------------------------------------------------
[env:Alternative_PCB]
board = esp32dev
board_build.partitions = no_ota.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 FLASHER_AP_MOSI=23
-D FLASHER_AP_MISO=33
-D FLASHER_AP_RESET=27
-D FLASHER_AP_POWER={4}
-D FLASHER_AP_TEST=-1
-D FLASHER_AP_TXD=26
-D FLASHER_AP_RXD=25
-D FLASHER_LED=19
build_src_filter =
+<*>-<usbflasher.cpp>-<serialconsole.cpp>

19
ESP32_AP-Flasher/push_ota.sh Executable file
View File

@@ -0,0 +1,19 @@
#!/bin/bash
source updateRemote.sh > /dev/null
if [ -z "$IP" ]
then
echo "ERROR: Empty IP variable"
exit 1
fi
if [ -z "$PIOENV" ]
then
echo "ERROR: Empty PIOENV variable"
exit 1
fi
md5sum .pio/build/$PIOENV/firmware.bin | tee .pio/build/$PIOENV/firmware.md5
upload_file .pio/build/$PIOENV/firmware.md5:ota_md5.txt
upload_file .pio/build/$PIOENV/firmware.bin:ota.bin

View File

@@ -13,7 +13,7 @@
#ifdef CONTENT_RSS
#include <rssClass.h>
#endif
#include <LittleFS.h>
#include "storage.h"
#include <time.h>
#include <map>
@@ -143,7 +143,7 @@ void drawNew(uint8_t mac[8], bool buttonPressed, tagRecord *&taginfo) {
if (imageParams.hasRed) imageParams.dataType = DATATYPE_IMG_RAW_2BPP;
if (prepareDataAvail(&filename, imageParams.dataType, mac, cfgobj["timetolive"].as<int>())) {
cfgobj["#fetched"] = true;
if (cfgobj["delete"].as<String>() == "1") LittleFS.remove("/" + cfgobj["filename"].as<String>());
if (cfgobj["delete"].as<String>() == "1") contentFS->remove("/" + cfgobj["filename"].as<String>());
} else {
wsErr("Error accessing " + filename);
}
@@ -286,6 +286,20 @@ void drawNew(uint8_t mac[8], bool buttonPressed, tagRecord *&taginfo) {
taginfo->nextupdate = now + (cfgobj["ttl"].as<int>() < 5 ? 5 : cfgobj["ttl"].as<int>()) * 60;
updateTagImage(filename, mac, (cfgobj["ttl"].as<int>() < 5 ? 5 : cfgobj["ttl"].as<int>()), taginfo, imageParams);
break;
case 17: // tag command
sendTagCommand(mac, cfgobj["cmd"].as<int>(), (taginfo->isExternal == false));
cfgobj["filename"] = "";
taginfo->nextupdate = 3216153600;
taginfo->contentMode = Image;
break;
case 18: // tag config
prepareConfigFile(mac, cfgobj);
cfgobj["filename"] = "";
taginfo->nextupdate = 3216153600;
taginfo->contentMode = Image;
break;
}
taginfo->modeConfigJson = doc.as<String>();
@@ -305,12 +319,16 @@ void drawString(TFT_eSprite &spr, String content, uint16_t posx, uint16_t posy,
// drawString(spr,"test",100,10,"bahnschrift30",TC_DATUM,PAL_RED);
spr.setTextDatum(align);
if (font == "2") {
spr.setTextFont(2);
spr.setTextColor(PAL_BLACK, PAL_WHITE);
spr.drawString(content, posx, posy);
if (font != "" && !font.startsWith("fonts/")) {
U8g2_for_TFT_eSPI u8f;
u8f.begin(spr);
setU8G2Font(font, u8f);
u8f.setForegroundColor(color);
u8f.setBackgroundColor(PAL_WHITE);
u8f.setCursor(posx, posy);
u8f.print(content);
} else {
if (font != "") spr.loadFont(font, LittleFS);
if (font != "") spr.loadFont(font, *contentFS);
spr.setTextColor(color, PAL_WHITE);
spr.drawString(content, posx, posy);
if (font != "") spr.unloadFont();
@@ -407,7 +425,7 @@ void drawNumber(String &filename, int32_t count, int32_t thresholdred, tagRecord
if (count > 99) font = loc["fonts"][1].as<String>();
if (count > 999) font = loc["fonts"][2].as<String>();
if (count > 9999) font = loc["fonts"][3].as<String>();
spr.loadFont(font, LittleFS);
spr.loadFont(font, *contentFS);
spr.drawString(String(count), loc["xy"][0].as<uint16_t>(), loc["xy"][1].as<uint16_t>());
spr.unloadFont();
@@ -492,7 +510,7 @@ void drawWeather(String &filename, JsonObject &cfgobj, tagRecord *&taginfo, imgP
dtostrf(temperature, 2, 1, tmpOutput);
drawString(spr, String(tmpOutput), loc["temp"][0], loc["temp"][1], loc["temp"][2], TL_DATUM, (temperature < 0 ? PAL_RED : PAL_BLACK));
spr.loadFont(loc["icon"][2], LittleFS);
spr.loadFont(loc["icon"][2], *contentFS);
if (weathercode == 55 || weathercode == 65 || weathercode == 75 || weathercode == 82 || weathercode == 86 || weathercode == 95 || weathercode == 99) {
spr.setTextColor(PAL_RED, PAL_WHITE);
} else {
@@ -502,7 +520,7 @@ void drawWeather(String &filename, JsonObject &cfgobj, tagRecord *&taginfo, imgP
spr.printToSprite(weatherIcons[weathercode]);
spr.unloadFont();
spr.loadFont(loc["dir"][2], LittleFS);
spr.loadFont(loc["dir"][2], *contentFS);
spr.setTextColor(PAL_BLACK, PAL_WHITE);
spr.setCursor(loc["dir"][0], loc["dir"][1]);
spr.printToSprite(windDirectionIcon(winddirection));
@@ -565,7 +583,7 @@ void drawForecast(String &filename, JsonObject &cfgobj, tagRecord *&taginfo, img
uint8_t weathercode = doc["daily"]["weathercode"][dag].as<int>();
if (weathercode > 40) weathercode -= 40;
spr.loadFont(loc["icon"][2], LittleFS);
spr.loadFont(loc["icon"][2], *contentFS);
if (weathercode == 55 || weathercode == 65 || weathercode == 75 || weathercode == 82 || weathercode == 86 || weathercode == 95 || weathercode == 99) {
spr.setTextColor(PAL_RED, PAL_WHITE);
} else {
@@ -584,11 +602,13 @@ void drawForecast(String &filename, JsonObject &cfgobj, tagRecord *&taginfo, img
int8_t tmax = round(doc["daily"]["temperature_2m_max"][dag].as<double>());
uint8_t wind = windSpeedToBeaufort(doc["daily"]["windspeed_10m_max"][dag].as<double>());
spr.loadFont(loc["day"][2], LittleFS);
spr.loadFont(loc["day"][2], *contentFS);
if (loc["rain"]) {
int8_t rain = round(doc["daily"]["precipitation_sum"][dag].as<double>());
drawString(spr, String(rain) + "mm", dag * loc["column"][1].as<int>() + loc["rain"][0].as<int>(), loc["rain"][1], "", TC_DATUM, (rain > 10 ? PAL_RED : PAL_BLACK));
if (rain > 0) {
drawString(spr, String(rain) + "mm", dag * loc["column"][1].as<int>() + loc["rain"][0].as<int>(), loc["rain"][1], "", TC_DATUM, (rain > 10 ? PAL_RED : PAL_BLACK));
}
}
drawString(spr, String(tmin) + " ", dag * loc["column"][1].as<int>() + loc["day"][0].as<int>(), loc["day"][4], "", TR_DATUM, (tmin < 0 ? PAL_RED : PAL_BLACK));
@@ -611,7 +631,7 @@ void drawForecast(String &filename, JsonObject &cfgobj, tagRecord *&taginfo, img
int getImgURL(String &filename, String URL, time_t fetched, imgParam &imageParams, String MAC) {
// https://images.klari.net/kat-bw29.jpg
LittleFS.begin();
Storage.begin();
Serial.println("get external " + URL);
HTTPClient http;
@@ -621,7 +641,7 @@ int getImgURL(String &filename, String URL, time_t fetched, imgParam &imageParam
http.setTimeout(5000); // timeout in ms
int httpCode = http.GET();
if (httpCode == 200) {
File f = LittleFS.open("/temp/temp.jpg", "w");
File f = contentFS->open("/temp/temp.jpg", "w");
if (f) {
http.writeToStream(&f);
f.close();
@@ -783,7 +803,7 @@ void drawQR(String &filename, String qrcontent, String title, tagRecord *&taginf
#ifdef CONTENT_QR
TFT_eSPI tft = TFT_eSPI();
TFT_eSprite spr = TFT_eSprite(&tft);
LittleFS.begin();
Storage.begin();
const char *text = qrcontent.c_str();
QRCode qrcode;
@@ -874,10 +894,7 @@ void drawBuienradar(String &filename, JsonObject &cfgobj, tagRecord *&taginfo, i
spr.fillRect(i * loc["cols"][2].as<int>() + loc["bars"][0].as<int>(), loc["bars"][1].as<int>() - (value - 60), loc["bars"][2], (value - 60), (value > 130 ? PAL_RED : PAL_BLACK));
if (minutes % 15 == 0) {
spr.setTextFont(2);
spr.setTextColor(PAL_BLACK, PAL_WHITE);
u8f.setCursor(i * loc["cols"][2].as<int>() + loc["cols"][0].as<int>(), loc["cols"][1]);
u8f.print(timestring);
drawString(spr, timestring, i * loc["cols"][2].as<int>() + loc["cols"][0].as<int>(), loc["cols"][1], loc["cols"][3]);
}
}
@@ -1000,8 +1017,25 @@ void prepareLUTreq(uint8_t *dst, String input) {
prepareDataAvail(waveform, waveformLen, DATATYPE_CUSTOM_LUT_OTA, dst);
}
void prepareConfigFile(uint8_t *dst, JsonObject config) {
struct tagsettings tagSettings;
tagSettings.settingsVer = 1;
tagSettings.enableFastBoot = config["fastboot"].as<int>();
tagSettings.enableRFWake = config["rfwake"].as<int>();
tagSettings.enableTagRoaming = config["tagroaming"].as<int>();
tagSettings.enableScanForAPAfterTimeout = config["tagscanontimeout"].as<int>();
tagSettings.enableLowBatSymbol = config["showlowbat"].as<int>();
tagSettings.enableNoRFSymbol = config["shownorf"].as<int>();
tagSettings.customMode = 0;
tagSettings.fastBootCapabilities = 0;
tagSettings.minimumCheckInTime = 1;
tagSettings.fixedChannel = config["fixedchannel"].as<int>();
tagSettings.batLowVoltage = config["lowvoltage"].as<int>();
prepareDataAvail((uint8_t *)&tagSettings, sizeof(tagSettings), 0xA8, dst);
}
void getTemplate(JsonDocument &json, const char *filePath, uint8_t id, uint8_t hwtype) {
File jsonFile = LittleFS.open(filePath, "r");
File jsonFile = contentFS->open(filePath, "r");
if (!jsonFile) {
Serial.println("Failed to open content template file " + String(filePath));
return;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -75,7 +75,8 @@ void rampTagPower(uint8_t* pin, bool up) {
}
void powerControl(bool powerState, uint8_t* pin, uint8_t pincount) {
if (pin[0] == -1) return;
if (pincount == 0) return;
if (pin == nullptr) return;
#ifdef POWER_RAMPING
if (powerState == true) {

View File

@@ -2,7 +2,6 @@
#include <Arduino.h>
#include <HardwareSerial.h>
#include <LittleFS.h>
#include "commstructs.h"
#include "flasher.h"
@@ -10,6 +9,7 @@
#include "newproto.h"
#include "powermgt.h"
#include "settings.h"
#include "storage.h"
#include "web.h"
#include "zbs_interface.h"
@@ -134,12 +134,15 @@ void APEnterEarlyReset() {
// Reset the tag
void APTagReset() {
uint8_t powerPins = sizeof(APpowerPins);
if (powerPins > 0 && APpowerPins[0] == -1)
powerPins = 0;
pinMode(AP_RESET_PIN, OUTPUT);
digitalWrite(AP_RESET_PIN, LOW);
vTaskDelay(50 / portTICK_PERIOD_MS);
powerControl(false, (uint8_t*)APpowerPins, sizeof(APpowerPins));
powerControl(false, (uint8_t*)APpowerPins, powerPins);
vTaskDelay(300 / portTICK_PERIOD_MS);
powerControl(true, (uint8_t*)APpowerPins, sizeof(APpowerPins));
powerControl(true, (uint8_t*)APpowerPins, powerPins);
vTaskDelay(100 / portTICK_PERIOD_MS);
digitalWrite(AP_RESET_PIN, HIGH);
vTaskDelay(100 / portTICK_PERIOD_MS);
@@ -205,6 +208,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();
@@ -606,7 +610,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)
@@ -687,6 +691,10 @@ void APTask(void* parameter) {
}
refreshAllPending();
} else {
#ifndef FLASH_TIMEOUT
#define FLASH_TIMEOUT 30
#endif
// AP unavailable, maybe time to flash?
apInfo.isOnline = false;
apInfo.state = AP_STATE_OFFLINE;
@@ -694,8 +702,8 @@ void APTask(void* parameter) {
Serial.printf("This could be the first time this AP is booted and the AP-tag may be unflashed. We'll try to flash it!\n");
Serial.printf("If this tag was previously flashed succesfully but this message still shows up, there's probably something wrong with the serial connections.\n");
Serial.printf("The build of this firmware expects an AP tag with TXD/RXD on ESP32 pins %d and %d, does this match with your wiring?\n", FLASHER_AP_RXD, FLASHER_AP_TXD);
Serial.println("Performing firmware flash in about 30 seconds!\n");
flashCountDown(30);
Serial.printf("Performing firmware flash in about %d seconds!\n", FLASH_TIMEOUT);
flashCountDown(FLASH_TIMEOUT);
if (doAPFlash()) {
checkWaitPowerCycle();
if (bringAPOnline()) {
@@ -747,6 +755,15 @@ void APTask(void* parameter) {
#endif
Serial.println("Please verify your wiring and try again!");
}
#ifdef HAS_SDCARD
if (SD_CARD_CLK == FLASHER_AP_CLK ||
SD_CARD_MISO == FLASHER_AP_MISO ||
SD_CARD_MOSI == FLASHER_AP_MOSI) {
Serial.println("Reseting in 30 seconds to restore SPI state!\n");
flashCountDown(30);
ESP.restart();
}
#endif
}
uint8_t attempts = 0;

View File

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

View File

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

View File

@@ -5,7 +5,7 @@
#include <FS.h>
#include <vector>
#include "LittleFS.h"
#include "storage.h"
#include "language.h"
std::vector<tagRecord*> tagDB;
@@ -63,7 +63,7 @@ bool hex2mac(const String& hexString, uint8_t* mac) {
}
String tagDBtoJson(uint8_t mac[8], uint8_t startPos) {
DynamicJsonDocument doc(2500);
DynamicJsonDocument doc(5000);
JsonArray tags = doc.createNestedArray("tags");
for (int16_t c = startPos; c < tagDB.size(); c++) {
@@ -85,7 +85,7 @@ String tagDBtoJson(uint8_t mac[8], uint8_t startPos) {
break;
}
}
if (doc.capacity()-doc.memoryUsage() < doc.memoryUsage()/(c+1) + 100) {
if (doc.capacity() - doc.memoryUsage() < doc.memoryUsage()/(c+1) + 150) {
doc["continu"] = c+1;
break;
}
@@ -119,6 +119,8 @@ void fillNode(JsonObject &tag, tagRecord* &taginfo) {
tag["isexternal"] = taginfo->isExternal;
tag["rotate"] = taginfo->rotate;
tag["lut"] = taginfo->lut;
tag["ch"] = taginfo->currentChannel;
tag["ver"] = taginfo->tagSoftwareVersion;
}
void saveDB(String filename) {
@@ -126,8 +128,8 @@ void saveDB(String filename) {
long t = millis();
LittleFS.begin();
fs::File file = LittleFS.open(filename, "w");
Storage.begin();
fs::File file = contentFS->open(filename, "w");
if (!file) {
Serial.println("saveDB: Failed to open file");
return;
@@ -161,8 +163,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;
@@ -214,6 +216,8 @@ void loadDB(String filename) {
taginfo->isExternal = tag["isexternal"].as<bool>();
taginfo->rotate = tag["rotate"] | 0;
taginfo->lut = tag["lut"] | 0;
taginfo->currentChannel = tag["ch"] | 0;
taginfo->tagSoftwareVersion = tag["ver"] | 0;
}
} else {
Serial.print(F("deserializeJson() failed: "));
@@ -264,9 +268,9 @@ void clearPending(tagRecord* taginfo) {
}
void initAPconfig() {
LittleFS.begin(true);
Storage.begin();
DynamicJsonDocument APconfig(500);
File configFile = LittleFS.open("/current/apconfig.json", "r");
File configFile = contentFS->open("/current/apconfig.json", "r");
if (configFile) {
DeserializationError error = deserializeJson(APconfig, configFile);
if (error) {
@@ -285,7 +289,7 @@ void initAPconfig() {
}
void saveAPconfig() {
fs::File configFile = LittleFS.open("/current/apconfig.json", "w");
fs::File configFile = contentFS->open("/current/apconfig.json", "w");
DynamicJsonDocument APconfig(500);
APconfig["channel"] = config.channel;
APconfig["alias"] = config.alias;

View File

@@ -46,23 +46,31 @@ void UDPcomm::processPacket(AsyncUDPPacket packet) {
switch (packet.data()[0]) {
case PKT_AVAIL_DATA_INFO: {
espAvailDataReq* adr = (espAvailDataReq*)&packet.data()[1];
processDataReq(adr, false);
espAvailDataReq adr;
memset(&adr, 0, sizeof(espAvailDataReq));
memcpy(&adr, &packet.data()[1], std::min(packet.length() - 1, sizeof(espAvailDataReq)));
processDataReq(&adr, false);
break;
}
case PKT_XFER_COMPLETE: {
espXferComplete* xfc = (espXferComplete*)&packet.data()[1];
processXferComplete(xfc, false);
espXferComplete xfc;
memset(&xfc, 0, sizeof(espXferComplete));
memcpy(&xfc, &packet.data()[1], std::min(packet.length() - 1, sizeof(espXferComplete)));
processXferComplete(&xfc, false);
break;
}
case PKT_XFER_TIMEOUT: {
espXferComplete* xfc = (espXferComplete*)&packet.data()[1];
processXferTimeout(xfc, false);
espXferComplete xfc;
memset(&xfc, 0, sizeof(espXferComplete));
memcpy(&xfc, &packet.data()[1], std::min(packet.length() - 1, sizeof(espXferComplete)));
processXferTimeout(&xfc, false);
break;
}
case PKT_AVAIL_DATA_REQ: {
pendingData* pending = (pendingData*)&packet.data()[1];
prepareExternalDataAvail(pending, packet.remoteIP());
pendingData pending;
memset(&pending, 0, sizeof(pendingData));
memcpy(&pending, &packet.data()[1], std::min(packet.length() - 1, sizeof(pendingData)));
prepareExternalDataAvail(&pending, packet.remoteIP());
break;
}
case PKT_APLIST_REQ: {
@@ -82,18 +90,20 @@ void UDPcomm::processPacket(AsyncUDPPacket packet) {
break;
}
case PKT_APLIST_REPLY: {
APlist* APreply = (APlist*)&packet.data()[1];
//remove active channel from list
APlist APreply;
memset(&APreply, 0, sizeof(APlist));
memcpy(&APreply, &packet.data()[1], std::min(packet.length() - 1, sizeof(APlist)));
// remove active channel from list
for (int i = 0; i < 6; i++) {
if (channelList[i] == APreply->channelId) channelList[i] = 0;
if (channelList[i] == APreply.channelId) channelList[i] = 0;
}
wsSendAPitem(APreply);
wsSendAPitem(&APreply);
break;
}
case PKT_TAGINFO: {
uint16_t syncversion = (packet.data()[2] << 8) | packet.data()[1];
if (syncversion != SYNC_VERSION) {
Serial.println("Got a packet from " + packet.remoteIP().toString() + " with mismatched udp sync version. Update firmware!");
wsErr("Got a packet from " + packet.remoteIP().toString() + " with mismatched udp sync version. Update firmware!");
} else {
TagInfo* taginfoitem = (TagInfo*)&packet.data()[1];
updateTaginfoitem(taginfoitem);

View File

@@ -239,6 +239,7 @@ void processFlasherCommand(struct flasherCommand* cmd) {
uint8_t* tempbuffer;
uint8_t temp_buff[16];
uint32_t spi_speed = 0;
uint8_t powerPinCount = 1;
static uint32_t curspeed = 0;
switch (cmd->command) {
@@ -267,14 +268,17 @@ void processFlasherCommand(struct flasherCommand* cmd) {
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, (uint8_t*)powerPins, spi_speed);
powerPinCount = powerPins[0] != -1 ? sizeof(powerPins) : 0;
temp_buff[0] = zbs->begin(FLASHER_AP_SS, FLASHER_AP_CLK, FLASHER_AP_MOSI, FLASHER_AP_MISO, FLASHER_AP_RESET, (uint8_t*)powerPins, powerPinCount, 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, (uint8_t*)powerPins3, spi_speed);
powerPinCount = powerPins3[0] != -1 ? sizeof(powerPins3) : 0;
temp_buff[0] = zbs->begin(FLASHER_ALT_SS, FLASHER_ALT_CLK, FLASHER_ALT_MOSI, FLASHER_ALT_MISO, FLASHER_ALT_RESET, (uint8_t*)powerPins3, powerPinCount, 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, (uint8_t*)powerPins2, spi_speed);
powerPinCount = powerPins2[0] != -1 ? sizeof(powerPins2) : 0;
temp_buff[0] = zbs->begin(FLASHER_EXT_SS, FLASHER_EXT_CLK, FLASHER_EXT_MOSI, FLASHER_EXT_MISO, FLASHER_EXT_RESET, (uint8_t*)powerPins2, powerPinCount, spi_speed);
#endif
}
sendFlasherAnswer(cmd->command, temp_buff, 1);

View File

@@ -6,8 +6,9 @@
#include <ESPAsyncWebServer.h>
#include <ESPmDNS.h>
#include <FS.h>
#include <LittleFS.h>
#include <SPIFFSEditor.h>
#include "storage.h"
#include "LittleFS.h"
#include "SPIFFSEditor.h"
#include <WiFi.h>
#include <WiFiManager.h> // https://github.com/tzapu/WiFiManager/tree/feature_asyncwebserver
@@ -126,18 +127,32 @@ void wsErr(String text) {
if (wsMutex) xSemaphoreGive(wsMutex);
}
size_t dbSize(){
size_t size = tagDB.size() * sizeof(tagRecord);
for(auto &tag : tagDB) {
if (tag->data)
size += tag->len;
size += tag->modeConfigJson.length();
}
return size;
}
void wsSendSysteminfo() {
DynamicJsonDocument doc(150);
DynamicJsonDocument doc(250);
JsonObject sys = doc.createNestedObject("sys");
time_t now;
time(&now);
sys["currtime"] = now;
sys["heap"] = ESP.getFreeHeap();
sys["recordcount"] = tagDB.size();
sys["dbsize"] = tagDB.size() * sizeof(tagRecord);
sys["littlefsfree"] = LittleFS.totalBytes() - LittleFS.usedBytes();
sys["dbsize"] = dbSize();
sys["littlefsfree"] = Storage.freeSpace();
sys["apstate"] = apInfo.state;
sys["runstate"] = config.runStatus;
sys["temp"] = temperatureRead();
sys["rssi"] = WiFi.RSSI();
sys["wifistatus"] = WiFi.status();
sys["wifissid"] = WiFi.SSID();
xSemaphoreTake(wsMutex, portMAX_DELAY);
ws.textAll(doc.as<String>());
@@ -215,15 +230,7 @@ uint8_t wsClientCount() {
}
void init_web() {
LittleFS.begin(true);
if (!LittleFS.exists("/current")) {
LittleFS.mkdir("/current");
}
if (!LittleFS.exists("/temp")) {
LittleFS.mkdir("/temp");
}
Storage.begin();
WiFi.mode(WIFI_STA);
WiFiManager wm;
@@ -243,8 +250,8 @@ void init_web() {
Serial.print("Connected! IP address: ");
Serial.println(WiFi.localIP());
// server.addHandler(new SPIFFSEditor(LittleFS, http_username, http_password));
server.addHandler(new SPIFFSEditor(LittleFS));
// server.addHandler(new SPIFFSEditor(*contentFS, http_username, http_password));
server.addHandler(new SPIFFSEditor(*contentFS));
ws.onEvent(onEvent);
server.addHandler(&ws);
@@ -260,8 +267,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) {
@@ -358,6 +365,15 @@ void init_web() {
if (strcmp(cmdValue, "refresh") == 0) {
updateContent(mac);
}
if (strcmp(cmdValue, "reboot") == 0) {
sendTagCommand(mac, CMD_DO_REBOOT, !taginfo->isExternal);
}
if (strcmp(cmdValue, "scan") == 0) {
sendTagCommand(mac, CMD_DO_SCAN, !taginfo->isExternal);
}
if (strcmp(cmdValue, "reset") == 0) {
sendTagCommand(mac, CMD_DO_RESET_SETTINGS, !taginfo->isExternal);
}
request->send(200, "text/plain", "Ok, done");
} else {
request->send(200, "text/plain", "Error: mac not found");
@@ -371,7 +387,7 @@ void init_web() {
server.on("/get_ap_config", HTTP_GET, [](AsyncWebServerRequest *request) {
UDPcomm udpsync;
udpsync.getAPList();
File configFile = LittleFS.open("/current/apconfig.json", "r");
File configFile = contentFS->open("/current/apconfig.json", "r");
if (!configFile) {
request->send(500, "text/plain", "Error opening apconfig.json file");
return;
@@ -411,7 +427,7 @@ void init_web() {
server.on("/backup_db", HTTP_GET, [](AsyncWebServerRequest *request) {
saveDB("/current/tagDB.json");
File file = LittleFS.open("/current/tagDB.json", "r");
File file = contentFS->open("/current/tagDB.json", "r");
AsyncWebServerResponse *response = request->beginResponse(file, "tagDB.json", String(), true);
request->send(response);
file.close();
@@ -449,7 +465,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
@@ -481,4 +497,4 @@ void doImageUpload(AsyncWebServerRequest *request, String filename, size_t index
request->send(500, "text/plain", "parameters incomplete");
}
}
}
}

View File

@@ -7,6 +7,10 @@
#include <stdint.h>
#include <stdio.h>
#ifdef USE_SOFTSPI
#include <SoftSPI.h>
#endif
#include "powermgt.h"
uint8_t ZBS_interface::begin(uint8_t SS, uint8_t CLK, uint8_t MOSI, uint8_t MISO, uint8_t RESET, uint8_t* POWER, uint8_t powerPins, uint32_t spi_speed) {
@@ -15,7 +19,10 @@ uint8_t ZBS_interface::begin(uint8_t SS, uint8_t CLK, uint8_t MOSI, uint8_t MISO
_MOSI_PIN = MOSI;
_MISO_PIN = MISO;
_RESET_PIN = RESET;
_POWER_PIN = POWER;
if (powerPins > 0)
_POWER_PIN = POWER;
else
_POWER_PIN = nullptr;
pinMode(_SS_PIN, OUTPUT);
pinMode(_RESET_PIN, OUTPUT);
digitalWrite(_SS_PIN, HIGH);
@@ -27,7 +34,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;

View File

@@ -0,0 +1,50 @@
#!/bin/bash
(return 0 2>/dev/null) && sourced=1 || sourced=0
if [ $sourced -eq 0 ]; then
if [ $# -eq 0 ]
then
echo "No IP address provided"
exit 1
fi
IP=$1
if [ -z "$IP" ]
then
echo "ERROR: Empty IP"
exit 1
fi
fi
upload_file () {
for file in "$@"
do
split=( $(echo $file | tr ":" " ") )
echo $split
filename=${split[0]}
if [ -z ${split[1]} ]; then
filepath=$(echo ${filename} | cut -d'/' -f2-)
else
filepath=${split[1]}
fi
echo $filename "-->" $filepath
curl "http://${IP}/edit" -X POST \
-H "Origin: http://${IP}" \
-H 'Connection: keep-alive' \
-H "Referer: http://${IP}/edit" \
-F "data=@${filename};filename=\"${filepath}\""
echo ""
done
}
export -f upload_file
if [ $sourced -eq 0 ]; then
export IP
find data -type f -exec bash -c "upload_file {} $IP" \;
else
echo "You can now call "
echo "IP=1.2.3.4 upload_file data/file1.txt data/file2.txt:target.txt"
fi

Binary file not shown.

After

Width:  |  Height:  |  Size: 233 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 344 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 565 KiB

View File

@@ -0,0 +1,16 @@
# 3D-printed ESP32-S2 Mini NanoAP with Flex PCB
## NanoAP by [ATC1441](https://github.com/atc1441)
The NanoAP is build by using an 1.54" Display with an ZBS243 SoC and an ESP32 S2-Mini Dev-board(2MB SRAM Version)
The Flex PCB does also fit on the 2.9" Display, the case will not fit then :D
<img width="600" alt="NanoAP_Case" src="NanoAP_Case.jpg">
<img width="600" alt="NanoAP_PCB_soldered" src="NanoAP_PCB_soldered.jpg">
<img width="600" alt="NanoAP_Flapped" src="NanoAP_Flapped.jpg">
- The "NanoAP_Case_V4.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"

104
LICENSE Normal file
View File

@@ -0,0 +1,104 @@
Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Public License
By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions.
Section 1 Definitions.
Adapted Material means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image.
Adapter's License means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this Public License.
BY-NC-SA Compatible License means a license listed at creativecommons.org/compatiblelicenses, approved by Creative Commons as essentially the equivalent of this Public License.
Copyright and Similar Rights means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights.
Effective Technological Measures means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements.
Exceptions and Limitations means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material.
License Elements means the license attributes listed in the name of a Creative Commons Public License. The License Elements of this Public License are Attribution, NonCommercial, and ShareAlike.
Licensed Material means the artistic or literary work, database, or other material to which the Licensor applied this Public License.
Licensed Rights means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license.
Licensor means the individual(s) or entity(ies) granting rights under this Public License.
NonCommercial means not primarily intended for or directed towards commercial advantage or monetary compensation. For purposes of this Public License, the exchange of the Licensed Material for other material subject to Copyright and Similar Rights by digital file-sharing or similar means is NonCommercial provided there is no payment of monetary compensation in connection with the exchange.
Share means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them.
Sui Generis Database Rights means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world.
You means the individual or entity exercising the Licensed Rights under this Public License. Your has a corresponding meaning.
Section 2 Scope.
License grant.
Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to:
reproduce and Share the Licensed Material, in whole or in part, for NonCommercial purposes only; and
produce, reproduce, and Share Adapted Material for NonCommercial purposes only.
Exceptions and Limitations. For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions.
Term. The term of this Public License is specified in Section 6(a).
Media and formats; technical modifications allowed. The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a)(4) never produces Adapted Material.
Downstream recipients.
Offer from the Licensor Licensed Material. Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License.
Additional offer from the Licensor Adapted Material. Every recipient of Adapted Material from You automatically receives an offer from the Licensor to exercise the Licensed Rights in the Adapted Material under the conditions of the Adapters License You apply.
No downstream restrictions. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material.
No endorsement. Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i).
Other rights.
Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise.
Patent and trademark rights are not licensed under this Public License.
To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties, including when the Licensed Material is used other than for NonCommercial purposes.
Section 3 License Conditions.
Your exercise of the Licensed Rights is expressly made subject to the following conditions.
Attribution.
If You Share the Licensed Material (including in modified form), You must:
retain the following if it is supplied by the Licensor with the Licensed Material:
identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated);
a copyright notice;
a notice that refers to this Public License;
a notice that refers to the disclaimer of warranties;
a URI or hyperlink to the Licensed Material to the extent reasonably practicable;
indicate if You modified the Licensed Material and retain an indication of any previous modifications; and
indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License.
You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information.
If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable.
ShareAlike.
In addition to the conditions in Section 3(a), if You Share Adapted Material You produce, the following conditions also apply.
The Adapters License You apply must be a Creative Commons license with the same License Elements, this version or later, or a BY-NC-SA Compatible License.
You must include the text of, or the URI or hyperlink to, the Adapter's License You apply. You may satisfy this condition in any reasonable manner based on the medium, means, and context in which You Share Adapted Material.
You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, Adapted Material that restrict exercise of the rights granted under the Adapter's License You apply.
Section 4 Sui Generis Database Rights.
Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material:
for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database for NonCommercial purposes only;
if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material, including for purposes of Section 3(b); and
You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database.
For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights.
Section 5 Disclaimer of Warranties and Limitation of Liability.
Unless otherwise separately undertaken by the Licensor, to the extent possible, the Licensor offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You.
To the extent possible, in no event will the Licensor be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this Public License or use of the Licensed Material, even if the Licensor has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You.
The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability.
Section 6 Term and Termination.
This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically.
Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates:
automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or
upon express reinstatement by the Licensor.
For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License.
For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License.
Sections 1, 5, 6, 7, and 8 survive termination of this Public License.
Section 7 Other Terms and Conditions.
The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed.
Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License.
Section 8 Interpretation.
For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License.
To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions.
No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor.
Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority.

View File

@@ -76,3 +76,8 @@ Hats off to these legends!
![Test](https://github.com/jjwbruijn/OpenEPaperLink/actions/workflows/build-esp32.yml/badge.svg)
![Release](https://github.com/jjwbruijn/OpenEPaperLink/actions/workflows/release.yml/badge.svg)
## License
[Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)](https://creativecommons.org/licenses/by-nc-sa/4.0/)
<img width="150" src="https://github.com/jjwbruijn/OpenEPaperLink/assets/2544995/0f3c945f-377e-49a4-a431-cd9e111f997f">

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.

Binary file not shown.

Binary file not shown.

View File

@@ -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)

View File

@@ -6,6 +6,7 @@
#define SOLUM_SEG_EU 0xF1
#define SOLUM_NODISPLAY 0xFF
#define CAPABILITY_SUPPORTS_COMPRESSION 0x02
#define CAPABILITY_SUPPORTS_CUSTOM_LUTS 0x04
#define CAPABILITY_ALT_LUT_SIZE 0x08
#define CAPABILITY_HAS_EXT_POWER 0x10
@@ -20,7 +21,21 @@
#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
#define WAKEUP_REASON_TIMED 0
#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

View File

@@ -23,8 +23,8 @@ $stackdisturbed = false;
$mem = checkmem();
while(1){
$errlist = array();
//exec("make BUILD=zbs154v033 CPU=8051 SOC=zbs243 2>&1 | grep error | grep -v make", $errlist);
exec("make BUILD=zbs_segmented_uk CPU=8051 SOC=zbs243 2>&1 | grep error | grep -v make", $errlist);
exec("make BUILD=zbs154_ssd1619 CPU=8051 SOC=zbs243 2>&1 | grep error | grep -v make", $errlist);
//exec("make BUILD=zbs_segmented_uk CPU=8051 SOC=zbs243 2>&1 | grep error | grep -v make", $errlist);
if(checkmem()!=$mem){
$stackdisturbed = true;
echo "Stack size was $mem, is now ".checkmem()." !!!\n";

View File

@@ -163,8 +163,9 @@ void fakeTagCheckIn() {
adr->lastPacketLQI = 100;
adr->lastPacketRSSI = 100;
adr->capabilities |= CAPABILITY_HAS_EXT_POWER;
adr->tagSoftwareVersion = 1;
if (firstboot) {
adr->wakeupReason = 0xFC;
adr->wakeupReason = WAKEUP_REASON_FIRSTBOOT;
firstboot = false;
} else {
adr->wakeupReason = 0;

View File

@@ -24,13 +24,13 @@
#include "emulateTag.h"
#endif
#define MAX_PENDING_MACS 55
#define MAX_PENDING_MACS 50
#define HOUSEKEEPING_INTERVAL 60UL
struct pendingData __xdata pendingDataArr[MAX_PENDING_MACS];
// VERSION GOES HERE!
uint16_t __xdata version = 0x0016;
uint16_t __xdata version = 0x0017;
#define RAW_PKT_PADDING 2
@@ -416,9 +416,9 @@ void espNotifyAPInfo() {
countSlots();
pr("PEN>%02X\n", curPendingData);
pr("NOP>%02X\n", curNoUpdate);
#if (AP_EMULATE_TAG == 1)
fakeTagCheckIn();
#endif
//#if (AP_EMULATE_TAG == 1)
// fakeTagCheckIn(); // removed this for now to ensure IP info is properly displayed; first tag check in now happens after the first round of housekeeping (30s)
//#endif
}
// process data from tag
@@ -741,6 +741,11 @@ void main(void) {
switch (getPacketType(radiorxbuffer)) {
case PKT_AVAIL_DATA_REQ:
if (ret == 28) {
// old version of the AvailDataReq struct, set all the new fields to zero, so it will pass the CRC
processAvailDataReq(radiorxbuffer);
memset(radiorxbuffer + 1 + sizeof(struct MacFrameBcast) + sizeof(struct oldAvailDataReq), 0, sizeof(struct AvailDataReq) - sizeof(struct oldAvailDataReq) + 2);
} else if (ret == 40) {
// new version of the AvailDataReq struct
processAvailDataReq(radiorxbuffer);
}
break;

View File

@@ -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

View File

@@ -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;

View File

@@ -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;
}
}
}
}

View File

@@ -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;
}

View File

@@ -2,13 +2,6 @@
#define _POWERMGT_H_
#include <stdint.h>
#define WAKEUP_REASON_TIMED 0
#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
#define DETECT_P1_0_NOTHING 0
#define DETECT_P1_0_BUTTON 1
#define DETECT_P1_0_JIG 2
@@ -55,6 +48,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
View 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");
}

View File

@@ -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 19 // version number (max 2.5.5 :) )
#define FW_VERSION_SUFFIX "-VER" // 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

View File

@@ -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;
@@ -194,6 +196,9 @@ static void sendAvailDataReq() {
availreq->temperature = temperature;
availreq->batteryMv = batteryVoltage;
availreq->capabilities = capabilities;
availreq->tagSoftwareVersion = fwVersion;
availreq->currentChannel = currentChannel;
availreq->customMode = tagSettings.customMode;
addCRC(availreq, sizeof(struct AvailDataReq));
commsTxNoCpy(outBuffer);
}
@@ -471,6 +476,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 +576,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 +854,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 +912,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 +926,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
View 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);

View File

@@ -27,7 +27,7 @@
// extern uint8_t __xdata APmac[];
// extern uint16_t __xdata batteryVoltage;
const uint8_t __code fwVersion = FW_VERSION;
const uint16_t __code fwVersion = FW_VERSION;
const char __code fwVersionSuffix[] = FW_VERSION_SUFFIX;
extern uint8_t __xdata capabilities;
@@ -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();

View File

@@ -15,7 +15,7 @@ void showLongTermSleep();
void showNoEEPROM();
void showNoMAC();
extern const uint8_t __code fwVersion;
extern const uint16_t __code fwVersion;
extern const char __code fwVersionSuffix[];
extern bool __xdata lowBatteryShown;
extern bool __xdata noAPShown;

View File

@@ -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);

View File

@@ -22,6 +22,7 @@
#define HAS_EEPROM 1
#define HAS_SCREEN 1
#define NFC_TYPE 1
#define AP_EMULATE_TAG 1
//hw types

View File

@@ -21,6 +21,7 @@
#define HAS_EEPROM 1
#define HAS_SCREEN 1
#define NFC_TYPE 1
#define AP_EMULATE_TAG 1
//hw types

View File

@@ -21,6 +21,7 @@
#define HAS_EEPROM 1
#define HAS_SCREEN 1
#define NFC_TYPE 1
#define AP_EMULATE_TAG 1
//hw types

View File

@@ -22,6 +22,7 @@
#define HAS_EEPROM 1
#define HAS_SCREEN 1
#define NFC_TYPE 2
#define AP_EMULATE_TAG 1
//hw types

View File

@@ -31,7 +31,6 @@ enum TagScreenType {
TagScreenTypeOther = 0x7f,
};
#ifndef __packed
#define __packed __attribute__((packed))
#endif
@@ -110,9 +109,23 @@ struct AvailDataReq {
uint16_t batteryMv;
uint8_t hwType;
uint8_t wakeupReason;
uint8_t capabilities; // undefined, as of now
uint8_t capabilities;
uint16_t tagSoftwareVersion;
uint8_t currentChannel;
uint8_t customMode;
uint8_t reserved[8];
} __packed;
struct oldAvailDataReq {
uint8_t checksum;
uint8_t lastPacketLQI;
int8_t lastPacketRSSI;
int8_t temperature;
uint16_t batteryMv;
uint8_t hwType;
uint8_t wakeupReason;
uint8_t capabilities;
} __packed;
struct AvailDataInfo {
uint8_t checksum;
@@ -190,7 +203,6 @@ struct espSetChannelPower {
uint8_t power;
} __packed;
#define MACFMT "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x"
#define MACCVT(x) ((const uint8_t*)(x))[7], ((const uint8_t*)(x))[6], ((const uint8_t*)(x))[5], ((const uint8_t*)(x))[4], ((const uint8_t*)(x))[3], ((const uint8_t*)(x))[2], ((const uint8_t*)(x))[1], ((const uint8_t*)(x))[0]