diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0495887..102a6da 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,7 +21,7 @@ jobs: run: pip install --upgrade platformio - name: Install ESPTool run: pip install --upgrade esptool - - name: Build PlatformIO Project esp32 + - name: Build PlatformIO Project esp32dev run: | pio run --environment esp32dev mkdir -p release/esp32dev @@ -33,21 +33,21 @@ jobs: - name: Build PlatformIO Project esp32-s3 run: | pio run --environment esp32-s3 - mkdir -p release/esp32-s3 - cp .pio/build/esp32-s3/firmware.bin release/esp32-s3/nuki_hub_esp32s3.bin - cp .pio/build/esp32-s3/partitions.bin release/esp32-s3/nuki_hub.partitions.bin - cp .pio/build/esp32-s3/bootloader.bin release/esp32-s3/bootloader.bin - esptool.py --chip esp32s3 merge_bin -o release/esp32-s3/webflash_nuki_hub_esp32s3.bin --flash_mode dio --flash_freq keep --flash_size keep 0x0 release/esp32-s3/bootloader.bin 0x10000 release/esp32-s3/nuki_hub_esp32s3.bin 0x8000 release/esp32-s3/nuki_hub.partitions.bin - echo "esptool.py --chip esp32s3 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq keep --flash_size detect 0x0 bootloader.bin 0x10000 nuki_hub_esp32s3.bin 0x8000 nuki_hub.partitions.bin" > release/esp32-s3/flash.sh + mkdir -p release/esp32s3 + cp .pio/build/esp32-s3/firmware.bin release/esp32s3/nuki_hub_esp32s3.bin + cp .pio/build/esp32-s3/partitions.bin release/esp32s3/nuki_hub.partitions.bin + cp .pio/build/esp32-s3/bootloader.bin release/esp32s3/bootloader.bin + esptool.py --chip esp32s3 merge_bin -o release/esp32s3/webflash_nuki_hub_esp32s3.bin --flash_mode dio --flash_freq keep --flash_size keep 0x0 release/esp32s3/bootloader.bin 0x10000 release/esp32s3/nuki_hub_esp32s3.bin 0x8000 release/esp32s3/nuki_hub.partitions.bin + echo "esptool.py --chip esp32s3 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq keep --flash_size detect 0x0 bootloader.bin 0x10000 nuki_hub_esp32s3.bin 0x8000 nuki_hub.partitions.bin" > release/esp32s3/flash.sh - name: Build PlatformIO Project esp32-c3 run: | pio run --environment esp32-c3 - mkdir -p release/esp32-c3 - cp .pio/build/esp32-c3/firmware.bin release/esp32-c3/nuki_hub_esp32c3.bin - cp .pio/build/esp32-c3/partitions.bin release/esp32-c3/nuki_hub.partitions.bin - cp .pio/build/esp32-c3/bootloader.bin release/esp32-c3/bootloader.bin - esptool.py --chip esp32c3 merge_bin -o release/esp32-c3/webflash_nuki_hub_esp32c3.bin --flash_mode dio --flash_freq keep --flash_size keep 0x0 release/esp32-c3/bootloader.bin 0x10000 release/esp32-c3/nuki_hub_esp32c3.bin 0x8000 release/esp32-c3/nuki_hub.partitions.bin - echo "esptool.py --chip esp32c3 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq keep --flash_size detect 0x0 bootloader.bin 0x10000 nuki_hub_esp32c3.bin 0x8000 nuki_hub.partitions.bin" > release/esp32-c3/flash.sh + mkdir -p release/esp32c3 + cp .pio/build/esp32-c3/firmware.bin release/esp32c3/nuki_hub_esp32c3.bin + cp .pio/build/esp32-c3/partitions.bin release/esp32c3/nuki_hub.partitions.bin + cp .pio/build/esp32-c3/bootloader.bin release/esp32c3/bootloader.bin + esptool.py --chip esp32c3 merge_bin -o release/esp32c3/webflash_nuki_hub_esp32c3.bin --flash_mode dio --flash_freq keep --flash_size keep 0x0 release/esp32c3/bootloader.bin 0x10000 release/esp32c3/nuki_hub_esp32c3.bin 0x8000 release/esp32c3/nuki_hub.partitions.bin + echo "esptool.py --chip esp32c3 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq keep --flash_size detect 0x0 bootloader.bin 0x10000 nuki_hub_esp32c3.bin 0x8000 nuki_hub.partitions.bin" > release/esp32c3/flash.sh - name: Build PlatformIO Project esp32solo1 run: | pio run --environment esp32solo1 @@ -56,7 +56,7 @@ jobs: cp .pio/build/esp32solo1/partitions.bin release/esp32solo1/nuki_hub.partitions.bin cp .pio/build/esp32solo1/bootloader.bin release/esp32solo1/bootloader.bin echo "esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq keep --flash_size detect 0x1000 bootloader.bin 0x10000 nuki_hub_esp32solo1.bin 0x8000 nuki_hub.partitions.bin" > release/esp32solo1/flash.sh - - name: Upload Artifact esp32 + - name: Upload Artifact esp32dev uses: actions/upload-artifact@v4 with: name: esp32-assets @@ -65,14 +65,73 @@ jobs: uses: actions/upload-artifact@v4 with: name: esp32-s3-assets - path: release/esp32-s3 + path: release/esp32s3 - name: Upload Artifact esp32-c3 uses: actions/upload-artifact@v4 with: name: esp32-c3-assets - path: release/esp32-c3 + path: release/esp32c3 - name: Upload Artifact esp32solo1 uses: actions/upload-artifact@v4 with: name: esp32solo1-assets - path: release/esp32solo1 \ No newline at end of file + path: release/esp32solo1 + - name: Build PlatformIO Project esp32dev_dbg + run: | + pio run --environment esp32dev_dbg + mkdir -p debug/esp32dev + cp .pio/build/esp32dev_dbg/bootloader.bin debug/esp32dev/bootloader.bin + cp .pio/build/esp32dev_dbg/firmware.bin debug/esp32dev/nuki_hub_esp32.bin + cp .pio/build/esp32dev_dbg/partitions.bin debug/esp32dev/nuki_hub.partitions.bin + cp .pio/build/esp32dev_dbg/firmware.elf debug/esp32dev/nuki_hub_esp32.elf + esptool.py --chip esp32 merge_bin -o debug/esp32dev/webflash_nuki_hub_esp32.bin --flash_mode dio --flash_freq keep --flash_size keep 0x1000 .pio/build/esp32dev_dbg/bootloader.bin 0x10000 .pio/build/esp32dev_dbg/firmware.bin 0x8000 .pio/build/esp32dev_dbg/partitions.bin + echo "esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq keep --flash_size detect 0x1000 bootloader.bin 0x10000 nuki_hub_esp32.bin 0x8000 nuki_hub.partitions.bin" > debug/esp32dev/flash.sh + - name: Build PlatformIO Project esp32-s3_dbg + run: | + pio run --environment esp32-s3_dbg + mkdir -p debug/esp32s3 + cp .pio/build/esp32-s3_dbg/bootloader.bin debug/esp32s3/bootloader.bin + cp .pio/build/esp32-s3_dbg/firmware.bin debug/esp32s3/nuki_hub_esp32s3.bin + cp .pio/build/esp32-s3_dbg/partitions.bin debug/esp32s3/nuki_hub.partitions.bin + cp .pio/build/esp32-s3_dbg/firmware.elf debug/esp32s3/nuki_hub_esp32s3.elf + esptool.py --chip esp32s3 merge_bin -o debug/webflash_nuki_hub_esp32s3.bin --flash_mode dio --flash_freq keep --flash_size keep 0x0 .pio/build/esp32-s3_dbg/bootloader.bin 0x10000 .pio/build/esp32-s3_dbg/firmware.bin 0x8000 .pio/build/esp32-s3_dbg/partitions.bin + echo "esptool.py --chip esp32s3 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq keep --flash_size detect 0x0 bootloader.bin 0x10000 nuki_hub_esp32s3.bin 0x8000 nuki_hub.partitions.bin" > debug/esp32s3/flash.sh + - name: Build PlatformIO Project esp32-c3_dbg + run: | + pio run --environment esp32-c3_dbg + mkdir -p debug/esp32c3 + cp .pio/build/esp32-c3_dbg/bootloader.bin debug/esp32c3/bootloader.bin + cp .pio/build/esp32-c3_dbg/firmware.bin debug/esp32c3/nuki_hub_esp32c3.bin + cp .pio/build/esp32-c3_dbg/partitions.bin debug/esp32c3/nuki_hub.partitions.bin + cp .pio/build/esp32-c3_dbg/firmware.elf debug/esp32c3/nuki_hub_esp32c3.elf + esptool.py --chip esp32c3 merge_bin -o debug/webflash_nuki_hub_esp32c3.bin --flash_mode dio --flash_freq keep --flash_size keep 0x0 .pio/build/esp32-c3_dbg/bootloader.bin 0x10000 .pio/build/esp32-c3_dbg/firmware.bin 0x8000 .pio/build/esp32-c3_dbg/partitions.bin && \ + echo "esptool.py --chip esp32c3 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq keep --flash_size detect 0x0 bootloader.bin 0x10000 nuki_hub_esp32c3.bin 0x8000 nuki_hub.partitions.bin" > debug/esp32c3/flash.sh + - name: Build PlatformIO Project esp32solo1_dbg + run: | + pio run --environment esp32solo1_dbg + mkdir -p debug/esp32solo1 + cp .pio/build/esp32solo1_dbg/bootloader.bin debug/esp32solo1/bootloader.bin + cp .pio/build/esp32solo1_dbg/firmware.bin debug/esp32solo1/nuki_hub_esp32solo1.bin + cp .pio/build/esp32solo1_dbg/partitions.bin debug/esp32solo1/nuki_hub.partitions.bin + cp .pio/build/esp32solo1_dbg/firmware.elf debug/esp32solo1/nuki_hub_esp32solo1.elf + echo "esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq keep --flash_size detect 0x1000 bootloader.bin 0x10000 nuki_hub_esp32solo1.bin 0x8000 nuki_hub.partitions.bin" > debug/esp32solo1/flash.sh + - name: Upload Artifact esp32dev-debug + uses: actions/upload-artifact@v4 + with: + name: esp32-debug-assets + path: debug/esp32dev + - name: Upload Artifact esp32-s3-debug + uses: actions/upload-artifact@v4 + with: + name: esp32-s3-debug-assets + path: debug/esp32s3 + - name: Upload Artifact esp32-c3-debug + uses: actions/upload-artifact@v4 + with: + name: esp32-c3-debug-assets + path: debug/esp32c3 + - name: Upload Artifact esp32solo1-debug + uses: actions/upload-artifact@v4 + with: + name: esp32solo1-debug-assets + path: debug/esp32solo1 \ No newline at end of file diff --git a/Docker/Dockerfile b/Docker/Dockerfile_cmake similarity index 100% rename from Docker/Dockerfile rename to Docker/Dockerfile_cmake diff --git a/Docker/Dockerfile_pio b/Docker/Dockerfile_pio new file mode 100644 index 0000000..26e7792 --- /dev/null +++ b/Docker/Dockerfile_pio @@ -0,0 +1,45 @@ +FROM eclipse-temurin:11-jdk-jammy AS builder + +RUN set -ex && \ + apt-get update && \ + apt-get install -y git python3 pip && \ + pip install --upgrade platformio && \ + pip install --upgrade esptool + +COPY icon /usr/src/nuki_hub/icon +COPY include /usr/src/nuki_hub/include +COPY lib /usr/src/nuki_hub/lib +COPY networkDevices /usr/src/nuki_hub/networkDevices +COPY partitions.csv /usr/src/nuki_hub +COPY platformio.ini /usr/src/nuki_hub +COPY index.html /usr/src/nuki_hub +COPY *.h /usr/src/nuki_hub/ +COPY *.cpp /usr/src/nuki_hub/ + +RUN set -ex && \ + cd /usr/src/nuki_hub && \ + mkdir -p release/esp32 && \ + mkdir -p release/esp32s3 && \ + mkdir -p release/esp32c3 && \ + mkdir -p release/esp32solo1 && \ + pio run --environment esp32dev && \ + esptool.py --chip esp32 merge_bin -o release/webflash_nuki_hub_esp32.bin --flash_mode dio --flash_freq keep --flash_size keep 0x1000 .pio/build/esp32dev/bootloader.bin 0x10000 .pio/build/esp32dev/firmware.bin 0x8000 .pio/build/esp32dev/partitions.bin && \ + cp .pio/build/esp32dev/bootloader.bin release/esp32/bootloader.bin && \ + cp .pio/build/esp32dev/firmware.bin release/esp32/nuki_hub_esp32.bin && \ + cp .pio/build/esp32dev/partitions.bin release/esp32/nuki_hub.partitions.bin && \ + pio run --environment esp32-s3 && \ + esptool.py --chip esp32s3 merge_bin -o release/webflash_nuki_hub_esp32s3.bin --flash_mode dio --flash_freq keep --flash_size keep 0x0 .pio/build/esp32-s3/bootloader.bin 0x10000 .pio/build/esp32-s3/firmware.bin 0x8000 .pio/build/esp32-s3/partitions.bin && \ + cp .pio/build/esp32-s3/bootloader.bin release/esp32s3/bootloader.bin && \ + cp .pio/build/esp32-s3/firmware.bin release/esp32s3/nuki_hub_esp32s3.bin && \ + cp .pio/build/esp32-s3/partitions.bin release/esp32s3/nuki_hub.partitions.bin && \ + pio run --environment esp32-c3 && \ + esptool.py --chip esp32c3 merge_bin -o release/webflash_nuki_hub_esp32c3.bin --flash_mode dio --flash_freq keep --flash_size keep 0x0 .pio/build/esp32-c3/bootloader.bin 0x10000 .pio/build/esp32-c3/firmware.bin 0x8000 .pio/build/esp32-c3/partitions.bin && \ + cp .pio/build/esp32-c3/bootloader.bin release/esp32c3/bootloader.bin && \ + cp .pio/build/esp32-c3/firmware.bin release/esp32c3/nuki_hub_esp32c3.bin && \ + cp .pio/build/esp32-c3/partitions.bin release/esp32c3/nuki_hub.partitions.bin && \ + pio run --environment esp32solo1 && \ + cp .pio/build/esp32solo1/bootloader.bin release/esp32solo1/bootloader.bin && \ + cp .pio/build/esp32solo1/firmware.bin release/esp32solo1/nuki_hub_esp32solo1.bin && \ + cp .pio/build/esp32solo1/partitions.bin release/esp32solo1/nuki_hub.partitions.bin + +CMD ["/bin/bash"] \ No newline at end of file diff --git a/Docker/Dockerfile_pio_debug b/Docker/Dockerfile_pio_debug new file mode 100644 index 0000000..09602b3 --- /dev/null +++ b/Docker/Dockerfile_pio_debug @@ -0,0 +1,49 @@ +FROM eclipse-temurin:11-jdk-jammy AS builder + +RUN set -ex && \ + apt-get update && \ + apt-get install -y git python3 pip && \ + pip install --upgrade platformio && \ + pip install --upgrade esptool + +COPY icon /usr/src/nuki_hub/icon +COPY include /usr/src/nuki_hub/include +COPY lib /usr/src/nuki_hub/lib +COPY networkDevices /usr/src/nuki_hub/networkDevices +COPY partitions.csv /usr/src/nuki_hub +COPY platformio.ini /usr/src/nuki_hub +COPY index.html /usr/src/nuki_hub +COPY *.h /usr/src/nuki_hub/ +COPY *.cpp /usr/src/nuki_hub/ + +RUN set -ex && \ + cd /usr/src/nuki_hub && \ + mkdir -p debug/esp32 && \ + mkdir -p debug/esp32s3 && \ + mkdir -p debug/esp32c3 && \ + mkdir -p debug/esp32solo1 && \ + pio run --environment esp32dev_dbg && \ + esptool.py --chip esp32 merge_bin -o debug/webflash_nuki_hub_esp32.bin --flash_mode dio --flash_freq keep --flash_size keep 0x1000 .pio/build/esp32dev_dbg/bootloader.bin 0x10000 .pio/build/esp32dev_dbg/firmware.bin 0x8000 .pio/build/esp32dev_dbg/partitions.bin && \ + cp .pio/build/esp32dev_dbg/bootloader.bin debug/esp32/bootloader.bin && \ + cp .pio/build/esp32dev_dbg/firmware.bin debug/esp32/nuki_hub_esp32.bin && \ + cp .pio/build/esp32dev_dbg/partitions.bin debug/esp32/nuki_hub.partitions.bin && \ + cp .pio/build/esp32dev_dbg/firmware.elf debug/esp32/nuki_hub_esp32.elf && \ + pio run --environment esp32-s3_dbg && \ + esptool.py --chip esp32s3 merge_bin -o debug/webflash_nuki_hub_esp32s3.bin --flash_mode dio --flash_freq keep --flash_size keep 0x0 .pio/build/esp32-s3_dbg/bootloader.bin 0x10000 .pio/build/esp32-s3_dbg/firmware.bin 0x8000 .pio/build/esp32-s3_dbg/partitions.bin && \ + cp .pio/build/esp32-s3_dbg/bootloader.bin debug/esp32s3/bootloader.bin && \ + cp .pio/build/esp32-s3_dbg/firmware.bin debug/esp32s3/nuki_hub_esp32s3.bin && \ + cp .pio/build/esp32-s3_dbg/partitions.bin debug/esp32s3/nuki_hub.partitions.bin && \ + cp .pio/build/esp32-s3_dbg/firmware.elf debug/esp32s3/nuki_hub_esp32s3.elf && \ + pio run --environment esp32-c3_dbg && \ + esptool.py --chip esp32c3 merge_bin -o debug/webflash_nuki_hub_esp32c3.bin --flash_mode dio --flash_freq keep --flash_size keep 0x0 .pio/build/esp32-c3_dbg/bootloader.bin 0x10000 .pio/build/esp32-c3_dbg/firmware.bin 0x8000 .pio/build/esp32-c3_dbg/partitions.bin && \ + cp .pio/build/esp32-c3_dbg/bootloader.bin debug/esp32c3/bootloader.bin && \ + cp .pio/build/esp32-c3_dbg/firmware.bin debug/esp32c3/nuki_hub_esp32c3.bin && \ + cp .pio/build/esp32-c3_dbg/partitions.bin debug/esp32c3/nuki_hub.partitions.bin && \ + cp .pio/build/esp32-c3_dbg/firmware.elf debug/esp32c3/nuki_hub_esp32c3.elf && \ + pio run --environment esp32solo1_dbg && \ + cp .pio/build/esp32solo1_dbg/bootloader.bin debug/esp32solo1/bootloader.bin && \ + cp .pio/build/esp32solo1_dbg/firmware.bin debug/esp32solo1/nuki_hub_esp32solo1.bin && \ + cp .pio/build/esp32solo1_dbg/partitions.bin debug/esp32solo1/nuki_hub.partitions.bin && \ + cp .pio/build/esp32solo1_dbg/firmware.elf debug/esp32solo1/nuki_hub_esp32solo1.elf + +CMD ["/bin/bash"] \ No newline at end of file diff --git a/Docker/README.md b/Docker/README.md index 17caad5..207f12b 100644 --- a/Docker/README.md +++ b/Docker/README.md @@ -1,10 +1,21 @@ -# Build with Docker +# Build with Docker You can build this project using Docker. Just run the following commands in the console: +## Build with PlatformIO (will build for the ESP32, ESP32-S3, ESP32-C3 and ESP32-solo1) ```console -cd Docker -./build_with_docker.sh +git clone https://github.com/technyon/nuki_hub --recursive +cd nuki_hub/Docker +./build_with_docker_pio.sh ``` -once the script is complete you will find the nuki_nub binary in the `nuki_hub/build/release` folder. +once the script is complete you will find the nuki_hub binaries in the `nuki_hub/build_pio` folder. + +## Build with CMake (will only build for the ESP32) +```console +git clone https://github.com/technyon/nuki_hub --recursive +cd nuki_hub/Docker +./build_with_docker_cmake.sh +``` + +once the script is complete you will find the nuki_hub binary in the `nuki_hub/build_cmake` folder. diff --git a/Docker/build_with_docker.sh b/Docker/build_with_docker.sh deleted file mode 100755 index 8ec1712..0000000 --- a/Docker/build_with_docker.sh +++ /dev/null @@ -1,6 +0,0 @@ -set -ex -docker build -f ./Dockerfile -t nuki_hub .. -docker create --name nuki_hub nuki_hub -rm -rf ../build -docker cp nuki_hub:/usr/src/nuki_hub/build/ ../ -docker rm -f nuki_hub diff --git a/Docker/build_with_docker_cmake.sh b/Docker/build_with_docker_cmake.sh new file mode 100755 index 0000000..7f1b43a --- /dev/null +++ b/Docker/build_with_docker_cmake.sh @@ -0,0 +1,6 @@ +set -ex +docker build -f ./Dockerfile_cmake -t nuki_hub_cmake .. +docker create --name nuki_hub_cmake nuki_hub_cmake +rm -rf ../build_cmake +docker cp nuki_hub_cmake:/usr/src/nuki_hub/build/ ../build_cmake +docker rm -f nuki_hub_cmake \ No newline at end of file diff --git a/Docker/build_with_docker_pio.sh b/Docker/build_with_docker_pio.sh new file mode 100755 index 0000000..513a270 --- /dev/null +++ b/Docker/build_with_docker_pio.sh @@ -0,0 +1,6 @@ +set -ex +docker build -f ./Dockerfile_pio -t nuki_hub_pio .. +docker create --name nuki_hub_pio nuki_hub_pio +rm -rf ../build_pio +docker cp nuki_hub_pio:/usr/src/nuki_hub/release/ ../build_pio +docker rm -f nuki_hub_pio diff --git a/Docker/build_with_docker_pio_debug.sh b/Docker/build_with_docker_pio_debug.sh new file mode 100644 index 0000000..8f7c554 --- /dev/null +++ b/Docker/build_with_docker_pio_debug.sh @@ -0,0 +1,6 @@ +set -ex +docker build -f ./Dockerfile_pio_debug -t nuki_hub_pio_dbg .. +docker create --name nuki_hub_pio_dbg nuki_hub_pio_dbg +rm -rf ../build_pio_dbg +docker cp nuki_hub_pio_dbg:/usr/src/nuki_hub/debug/ ../build_pio_dbg +docker rm -f nuki_hub_pio_dbg diff --git a/README.md b/README.md index 1bb6722..efeaa46 100644 --- a/README.md +++ b/README.md @@ -655,10 +655,41 @@ To prevent this behaviour, unpair Nuki Hub, disable "Register as app", and re-pa Never enable "Register as app" unless you intend to use a Nuki Bridge in addition to Nuki Hub! ## Building from source - Docker (Preferred)
See the [README](/Docker/README.md) in the Docker directory for instructions on building using Docker.

+Platform IO, instructions for Debian-based Linux distro (e.g. Ubuntu)
+```console +apt-get update +apt-get install -y git python3 pip +python3 -m venv .venv +source .venv/bin/activate +pip install --upgrade platformio +pip install --upgrade esptool +git clone https://github.com/technyon/nuki_hub --recursive +cd nuki_hub +mkdir -p release/esp32 +mkdir -p release/esp32s3 +mkdir -p release/esp32c3 +mkdir -p release/esp32solo1 +pio run --environment esp32dev +cp .pio/build/esp32dev/bootloader.bin release/esp32/bootloader.bin +cp .pio/build/esp32dev/firmware.bin release/esp32/nuki_hub_esp32.bin +cp .pio/build/esp32dev/partitions.bin release/esp32/nuki_hub.partitions.bin +pio run --environment esp32-s3 +cp .pio/build/esp32-s3/bootloader.bin release/esp32s3/bootloader.bin +cp .pio/build/esp32-s3/firmware.bin release/esp32s3/nuki_hub_esp32s3.bin +cp .pio/build/esp32-s3/partitions.bin release/esp32s3/nuki_hub.partitions.bin +pio run --environment esp32-c3 +cp .pio/build/esp32-c3/bootloader.bin release/esp32c3/bootloader.bin +cp .pio/build/esp32-c3/firmware.bin release/esp32c3/nuki_hub_esp32c3.bin +cp .pio/build/esp32-c3/partitions.bin release/esp32c3/nuki_hub.partitions.bin +pio run --environment esp32solo1 +cp .pio/build/esp32solo1/bootloader.bin release/esp32solo1/bootloader.bin +cp .pio/build/esp32solo1/firmware.bin release/esp32solo1/nuki_hub_esp32solo1.bin +cp .pio/build/esp32solo1/partitions.bin release/esp32solo1/nuki_hub.partitions.bin +``` +
VMWare image (Not preferred, not using the latest Arduino ESP32 release at this time)
A virtual machine (VMWare image) that is setup to compile Nuki Hub is available for download at:
https://drive.google.com/file/d/1fUVYHDtxXAZOAfQ321iRNIwkqFwuDsBp/view?usp=share_link
diff --git a/ota/nuki_hub_esp32.bin b/ota/nuki_hub_esp32.bin index 540c3c3..a6ccfb7 100644 Binary files a/ota/nuki_hub_esp32.bin and b/ota/nuki_hub_esp32.bin differ diff --git a/ota/nuki_hub_esp32c3.bin b/ota/nuki_hub_esp32c3.bin index bfa5e0d..b189f84 100644 Binary files a/ota/nuki_hub_esp32c3.bin and b/ota/nuki_hub_esp32c3.bin differ diff --git a/ota/nuki_hub_esp32s3.bin b/ota/nuki_hub_esp32s3.bin index dcea3f2..fd47d49 100644 Binary files a/ota/nuki_hub_esp32s3.bin and b/ota/nuki_hub_esp32s3.bin differ diff --git a/ota/nuki_hub_esp32solo1.bin b/ota/nuki_hub_esp32solo1.bin index 960aeb7..3878f61 100644 Binary files a/ota/nuki_hub_esp32solo1.bin and b/ota/nuki_hub_esp32solo1.bin differ diff --git a/platformio.ini b/platformio.ini index 332c71b..dd721bf 100644 --- a/platformio.ini +++ b/platformio.ini @@ -16,7 +16,7 @@ platform = espressif32 framework = arduino build_type = release board_build.partitions = partitions.csv -build_flags = +build_flags = -fexceptions -DTLS_CA_MAX_SIZE=2200 -DTLS_CERT_MAX_SIZE=1500 @@ -32,10 +32,10 @@ build_flags = ; -DDEBUG_NUKI_COMMUNICATION ; -DDEBUG_NUKI_HEX_DATA ; -DDEBUG_NUKI_READABLE_DATA -lib_deps = +lib_deps = monitor_speed = 115200 -monitor_filters = +monitor_filters = esp32_exception_decoder time @@ -48,9 +48,54 @@ board = esp32-c3-devkitc-02 [env:esp32solo1] platform = https://github.com/tasmota/platform-espressif32/releases/download/2023.10.03/platform-espressif32-2023.10.03.zip board = esp32-solo1 -build_flags = +build_flags = ${env.build_flags} -DFRAMEWORK_ARDUINO_SOLO1 [env:esp32-s3] -board = esp32-s3-devkitc-1 \ No newline at end of file +board = esp32-s3-devkitc-1 + +[env:esp32dev_dbg] +extends = env:esp32dev +build_flags = + ${env.build_flags} + -DDEBUG_SENSE_NUKI + -DDEBUG_NUKI_COMMAND + -DDEBUG_NUKI_CONNECT + -DDEBUG_NUKI_COMMUNICATION + -DDEBUG_NUKI_HEX_DATA + -DDEBUG_NUKI_READABLE_DATA + +[env:esp32-s3_dbg] +extends = env:esp32-s3 +build_flags = + ${env.build_flags} + -DDEBUG_SENSE_NUKI + -DDEBUG_NUKI_COMMAND + -DDEBUG_NUKI_CONNECT + -DDEBUG_NUKI_COMMUNICATION + -DDEBUG_NUKI_HEX_DATA + -DDEBUG_NUKI_READABLE_DATA + +[env:esp32-c3_dbg] +extends = env:esp32-c3 +build_flags = + ${env.build_flags} + -DDEBUG_SENSE_NUKI + -DDEBUG_NUKI_COMMAND + -DDEBUG_NUKI_CONNECT + -DDEBUG_NUKI_COMMUNICATION + -DDEBUG_NUKI_HEX_DATA + -DDEBUG_NUKI_READABLE_DATA + +[env:esp32solo1_dbg] +extends = env:esp32solo1 +build_flags = + ${env.build_flags} + -DFRAMEWORK_ARDUINO_SOLO1 + -DDEBUG_SENSE_NUKI + -DDEBUG_NUKI_COMMAND + -DDEBUG_NUKI_CONNECT + -DDEBUG_NUKI_COMMUNICATION + -DDEBUG_NUKI_HEX_DATA + -DDEBUG_NUKI_READABLE_DATA \ No newline at end of file diff --git a/src/NukiOpenerWrapper.cpp b/src/NukiOpenerWrapper.cpp index 177509a..a8bba92 100644 --- a/src/NukiOpenerWrapper.cpp +++ b/src/NukiOpenerWrapper.cpp @@ -470,7 +470,7 @@ void NukiOpenerWrapper::updateConfig() void NukiOpenerWrapper::updateAuthData() { - if(_nukiOpener.getSecurityPincode() == 0) return; + if(!isPinSet()) return; Nuki::CmdResult result = _nukiOpener.retrieveLogEntries(0, 0, 0, true); if(result != Nuki::CmdResult::Success) @@ -768,10 +768,19 @@ Nuki::BatteryType NukiOpenerWrapper::batteryTypeToEnum(const char* str) void NukiOpenerWrapper::onConfigUpdateReceived(const char *value) { + JsonDocument jsonResult; char _resbuf[2048]; - if(_nukiOpener.getSecurityPincode() == 0) + if(!_configRead || !_nukiConfigValid) + { + jsonResult["general"] = "configNotReady"; + serializeJson(jsonResult, _resbuf, sizeof(_resbuf)); + _network->publishConfigCommandResult(_resbuf); + return; + } + + if(!isPinSet()) { jsonResult["general"] = "noPinSet"; serializeJson(jsonResult, _resbuf, sizeof(_resbuf)); @@ -1403,7 +1412,7 @@ void NukiOpenerWrapper::onKeypadCommandReceived(const char *command, const uint void NukiOpenerWrapper::onKeypadJsonCommandReceived(const char *value) { - if(_nukiOpener.getSecurityPincode() == 0) + if(!isPinSet()) { _network->publishKeypadJsonCommandResult("noPinSet"); return; @@ -1746,7 +1755,13 @@ void NukiOpenerWrapper::onKeypadJsonCommandReceived(const char *value) void NukiOpenerWrapper::onTimeControlCommandReceived(const char *value) { - if(_nukiOpener.getSecurityPincode() == 0) + if(!_configRead || !_nukiConfigValid) + { + _network->publishTimeControlCommandResult("configNotReady"); + return; + } + + if(!isPinSet()) { _network->publishTimeControlCommandResult("noPinSet"); return; diff --git a/src/NukiWrapper.cpp b/src/NukiWrapper.cpp index 27d85b0..46c7564 100644 --- a/src/NukiWrapper.cpp +++ b/src/NukiWrapper.cpp @@ -451,7 +451,7 @@ void NukiWrapper::updateConfig() void NukiWrapper::updateAuthData() { - if(_nukiLock.getSecurityPincode() == 0) return; + if(!isPinSet()) return; Nuki::CmdResult result = _nukiLock.retrieveLogEntries(0, 0, 0, true); if(result != Nuki::CmdResult::Success) @@ -490,7 +490,7 @@ void NukiWrapper::updateKeypad() { std::list entries; _nukiLock.getKeypadEntries(&entries); - + Log->print(F("Lock keypad codes: ")); Log->println(entries.size()); @@ -534,7 +534,7 @@ void NukiWrapper::updateTimeControl(bool retrieved) { std::list timeControlEntries; _nukiLock.getTimeControlEntries(&timeControlEntries); - + Log->print(F("Lock time control entries: ")); Log->println(timeControlEntries.size()); @@ -549,7 +549,7 @@ void NukiWrapper::updateTimeControl(bool retrieved) _timeControlIds.push_back(entry.entryId); } } - + postponeBleWatchdog(); } @@ -575,13 +575,13 @@ NukiLock::LockAction NukiWrapper::lockActionToEnum(const char *str) LockActionResult NukiWrapper::onLockActionReceivedCallback(const char *value) { NukiLock::LockAction action; - + if(value) { if(strlen(value) > 0) { action = nukiInst->lockActionToEnum(value); - + if((int)action == 0xff) { return LockActionResult::UnknownAction; @@ -708,7 +708,15 @@ void NukiWrapper::onConfigUpdateReceived(const char *value) JsonDocument jsonResult; char _resbuf[2048]; - if(_nukiLock.getSecurityPincode() == 0) + if(!_configRead || !_nukiConfigValid) + { + jsonResult["general"] = "configNotReady"; + serializeJson(jsonResult, _resbuf, sizeof(_resbuf)); + _network->publishConfigCommandResult(_resbuf); + return; + } + + if(!isPinSet()) { jsonResult["general"] = "noPinSet"; serializeJson(jsonResult, _resbuf, sizeof(_resbuf)); @@ -745,7 +753,7 @@ void NukiWrapper::onConfigUpdateReceived(const char *value) if(json[basicKeys[i]]) { const char *jsonchar = json[basicKeys[i]].as(); - + if(strlen(jsonchar) == 0) { jsonResult[basicKeys[i]] = "noValueSet"; @@ -948,7 +956,7 @@ void NukiWrapper::onConfigUpdateReceived(const char *value) if(json[advancedKeys[i]]) { const char *jsonchar = json[advancedKeys[i]].as(); - + if(strlen(jsonchar) == 0) { jsonResult[advancedKeys[i]] = "noValueSet"; @@ -1390,7 +1398,7 @@ void NukiWrapper::onKeypadCommandReceived(const char *command, const uint &id, c void NukiWrapper::onKeypadJsonCommandReceived(const char *value) { - if(_nukiLock.getSecurityPincode() == 0) + if(!isPinSet()) { _network->publishKeypadJsonCommandResult("noPinSet"); return; @@ -1653,7 +1661,7 @@ void NukiWrapper::onKeypadJsonCommandReceived(const char *value) _network->publishKeypadJsonCommandResult("noCodeIdSet"); return; } - + if(!idExists) { _network->publishKeypadJsonCommandResult("noExistingCodeIdSet"); @@ -1733,7 +1741,13 @@ void NukiWrapper::onKeypadJsonCommandReceived(const char *value) void NukiWrapper::onTimeControlCommandReceived(const char *value) { - if(_nukiLock.getSecurityPincode() == 0) + if(!_configRead || !_nukiConfigValid) + { + _network->publishTimeControlCommandResult("configNotReady"); + return; + } + + if(!isPinSet()) { _network->publishTimeControlCommandResult("noPinSet"); return; diff --git a/src/main.cpp b/src/main.cpp index 05329b4..e3f158f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -112,9 +112,9 @@ void setupTasks() { // configMAX_PRIORITIES is 25 - xTaskCreatePinnedToCore(networkTask, "ntw", 10240, NULL, 3, &networkTaskHandle, 1); - xTaskCreatePinnedToCore(nukiTask, "nuki", 5120, NULL, 2, &nukiTaskHandle, 1); - xTaskCreatePinnedToCore(presenceDetectionTask, "prdet", 896, NULL, 5, &presenceDetectionTaskHandle, 1); + xTaskCreatePinnedToCore(networkTask, "ntw", 12288, NULL, 3, &networkTaskHandle, 1); + xTaskCreatePinnedToCore(nukiTask, "nuki", 8192, NULL, 2, &nukiTaskHandle, 1); + xTaskCreatePinnedToCore(presenceDetectionTask, "prdet", 1024, NULL, 5, &presenceDetectionTaskHandle, 1); } void initEthServer(const NetworkDeviceType device) diff --git a/webflash/boot_app0.bin b/webflash/boot_app0.bin deleted file mode 100755 index 13562ca..0000000 Binary files a/webflash/boot_app0.bin and /dev/null differ diff --git a/webflash/bootloader_qio_80m.bin b/webflash/bootloader_qio_80m.bin deleted file mode 100755 index 82fd51d..0000000 Binary files a/webflash/bootloader_qio_80m.bin and /dev/null differ diff --git a/webflash/manifest.json b/webflash/manifest.json index 268a542..2be602d 100644 --- a/webflash/manifest.json +++ b/webflash/manifest.json @@ -5,10 +5,7 @@ { "chipFamily": "ESP32", "parts": [ - { "path": "boot_app0.bin", "offset": 57344 }, - { "path": "bootloader_qio_80m.bin", "offset": 4096 }, - { "path": "nuki_hub.bin", "offset": 65536 }, - { "path": "nuki_hub.partitions.bin", "offset": 32768 } + { "path": "webflash_nuki_hub_esp32.bin", "offset": 0 } ] }, { diff --git a/webflash/nuki_hub.bin b/webflash/nuki_hub.bin deleted file mode 100644 index a7c27f7..0000000 Binary files a/webflash/nuki_hub.bin and /dev/null differ diff --git a/webflash/nuki_hub.partitions.bin b/webflash/nuki_hub.partitions.bin deleted file mode 100644 index fa042d6..0000000 Binary files a/webflash/nuki_hub.partitions.bin and /dev/null differ