Compare commits
	
		
			28 Commits
		
	
	
		
			v1.2.99
			...
			d058397fa2
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| d058397fa2 | |||
| 622f5403a7 | |||
| 92b78a86dd | |||
| ec399390e8 | |||
| 909c4e9b5e | |||
| f4b20bfffd | |||
| 78464215a9 | |||
| 4365f0463a | |||
| 727bc0e760 | |||
| 04604013eb | |||
| cf5fc5f6f1 | |||
| 945a4ccce6 | |||
| 7cf9e2d145 | |||
| 9db4e338ea | |||
| dea6ca2c66 | |||
| e224e72e41 | |||
| 306c517da7 | |||
| 0337bbabe0 | |||
| bde14e50e0 | |||
| 9c656a9bd0 | |||
| eae552017d | |||
| a77918da41 | |||
| 262dad38a6 | |||
| cfc9f103cf | |||
| 0117302672 | |||
| 1de283b62f | |||
| f1eb78eb38 | |||
| 8a65b86475 | 
| @@ -74,21 +74,18 @@ jobs: | |||||||
|         # Copy firmware binary |         # Copy firmware binary | ||||||
|         cp .pio/build/esp32dev/firmware.bin .pio/build/esp32dev/filaman_${VERSION}.bin |         cp .pio/build/esp32dev/firmware.bin .pio/build/esp32dev/filaman_${VERSION}.bin | ||||||
|          |          | ||||||
|         # Copy SPIFFS binary if SPIFFS changed |         # Always create SPIFFS binary | ||||||
|         if [[ "${{ steps.check_spiffs.outputs.SPIFFS_CHANGED }}" == "true" ]]; then |  | ||||||
|           echo "SPIFFS changes detected, copying SPIFFS binary..." |  | ||||||
|         cp .pio/build/esp32dev/spiffs.bin .pio/build/esp32dev/webpage_${VERSION}.bin |         cp .pio/build/esp32dev/spiffs.bin .pio/build/esp32dev/webpage_${VERSION}.bin | ||||||
|         fi |  | ||||||
|          |          | ||||||
|         # Create full binary (always) |         # Create full binary (always) | ||||||
|         (cd .pio/build/esp32dev && \ |         (cd .pio/build/esp32dev &&  | ||||||
|         esptool.py --chip esp32 merge_bin \ |         esptool.py --chip esp32 merge_bin \ | ||||||
|           --fill-flash-size 4MB \ |           --fill-flash-size 4MB \ | ||||||
|           --flash_mode dio \ |           --flash_mode dio \ | ||||||
|           --flash_freq 40m \ |           --flash_freq 40m \ | ||||||
|           --flash_size 4MB \ |           --flash_size 4MB \ | ||||||
|           -o filaman_full_${VERSION}.bin \ |           -o filaman_full_${VERSION}.bin \ | ||||||
|           0x0000 bootloader.bin \ |           0x1000 bootloader.bin \ | ||||||
|           0x8000 partitions.bin \ |           0x8000 partitions.bin \ | ||||||
|           0x10000 firmware.bin \ |           0x10000 firmware.bin \ | ||||||
|           0x390000 spiffs.bin) |           0x390000 spiffs.bin) | ||||||
| @@ -60,31 +60,22 @@ jobs: | |||||||
|         # Copy firmware binary |         # Copy firmware binary | ||||||
|         cp .pio/build/esp32dev/firmware.bin .pio/build/esp32dev/filaman_${VERSION}.bin |         cp .pio/build/esp32dev/firmware.bin .pio/build/esp32dev/filaman_${VERSION}.bin | ||||||
|          |          | ||||||
|         # Copy SPIFFS binary if SPIFFS changed |         # Always create SPIFFS binary | ||||||
|         if [[ "${{ steps.check_spiffs.outputs.SPIFFS_CHANGED }}" == "true" ]]; then |  | ||||||
|           echo "SPIFFS changes detected, copying SPIFFS binary..." |  | ||||||
|         cp .pio/build/esp32dev/spiffs.bin .pio/build/esp32dev/webpage_${VERSION}.bin |         cp .pio/build/esp32dev/spiffs.bin .pio/build/esp32dev/webpage_${VERSION}.bin | ||||||
|         fi |  | ||||||
|          |          | ||||||
|         # Create full binary (always) |         # Create full binary (always) | ||||||
|         (cd .pio/build/esp32dev && \ |         (cd .pio/build/esp32dev &&  | ||||||
|         esptool.py --chip esp32 merge_bin \ |         esptool.py --chip esp32 merge_bin \ | ||||||
|           --fill-flash-size 4MB \ |           --fill-flash-size 4MB \ | ||||||
|           --flash_mode dio \ |           --flash_mode dio \ | ||||||
|           --flash_freq 40m \ |           --flash_freq 40m \ | ||||||
|           --flash_size 4MB \ |           --flash_size 4MB \ | ||||||
|           -o filaman_full_${VERSION}.bin \ |           -o filaman_full_${VERSION}.bin \ | ||||||
|           0x0000 bootloader.bin \ |           0x1000 bootloader.bin \ | ||||||
|           0x8000 partitions.bin \ |           0x8000 partitions.bin \ | ||||||
|           0x10000 firmware.bin \ |           0x10000 firmware.bin \ | ||||||
|           0x390000 spiffs.bin) |           0x390000 spiffs.bin) | ||||||
|          |          | ||||||
|         # Only copy SPIFFS binary if data changed |  | ||||||
|         if [[ "${{ steps.check_data.outputs.DATA_CHANGED }}" == "true" ]]; then |  | ||||||
|           echo "Data changes detected, copying SPIFFS binary..." |  | ||||||
|           cp .pio/build/esp32dev/spiffs.bin .pio/build/esp32dev/webpage_${VERSION}.bin |  | ||||||
|         fi |  | ||||||
|          |  | ||||||
|         # Verify file sizes |         # Verify file sizes | ||||||
|         echo "File sizes:" |         echo "File sizes:" | ||||||
|         (cd .pio/build/esp32dev && ls -lh *.bin) |         (cd .pio/build/esp32dev && ls -lh *.bin) | ||||||
							
								
								
									
										202
									
								
								.github/workflows/release.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										202
									
								
								.github/workflows/release.yml
									
									
									
									
										vendored
									
									
								
							| @@ -56,15 +56,203 @@ jobs: | |||||||
|   github-release: |   github-release: | ||||||
|     needs: [route, verify-provider] |     needs: [route, verify-provider] | ||||||
|     if: needs.route.outputs.provider == 'github' |     if: needs.route.outputs.provider == 'github' | ||||||
|     uses: ./.github/workflows/providers/github-release.yml |     runs-on: ubuntu-latest | ||||||
|  |     permissions: | ||||||
|  |       contents: write | ||||||
|  |     steps: | ||||||
|  |     - uses: actions/checkout@v4 | ||||||
|  |     - name: Set up Python | ||||||
|  |       uses: actions/setup-python@v4 | ||||||
|  |       with: | ||||||
|  |         python-version: '3.x' | ||||||
|  |     - name: Install PlatformIO | ||||||
|  |       run: | | ||||||
|  |         python -m pip install --upgrade pip | ||||||
|  |         pip install --upgrade platformio esptool | ||||||
|  |     - name: Install xxd | ||||||
|  |       run: | | ||||||
|  |         sudo apt-get update | ||||||
|  |         sudo apt-get install xxd | ||||||
|  |     - name: Check for Data changes | ||||||
|  |       id: check_data | ||||||
|  |       run: | | ||||||
|  |         git fetch --unshallow || true | ||||||
|  |         CHANGED_FILES=$(git diff --name-only HEAD^..HEAD) | ||||||
|  |         if echo "$CHANGED_FILES" | grep -q "^data/"; then | ||||||
|  |           echo "DATA_CHANGED=true" >> $GITHUB_OUTPUT | ||||||
|  |         else | ||||||
|  |           echo "DATA_CHANGED=false" >> $GITHUB_OUTPUT | ||||||
|  |         fi | ||||||
|  |     - name: Check for SPIFFS changes | ||||||
|  |       id: check_spiffs | ||||||
|  |       run: | | ||||||
|  |         git fetch --unshallow || true | ||||||
|  |         CHANGED_FILES=$(git diff --name-only HEAD^..HEAD) | ||||||
|  |         if echo "$CHANGED_FILES" | grep -q "^data/\|^html/"; then | ||||||
|  |           echo "SPIFFS_CHANGED=true" >> $GITHUB_OUTPUT | ||||||
|  |         else | ||||||
|  |           echo "SPIFFS_CHANGED=false" >> $GITHUB_OUTPUT | ||||||
|  |         fi | ||||||
|  |     - name: Build Firmware | ||||||
|  |       run: | | ||||||
|  |         VERSION=$(grep '^version = ' platformio.ini | cut -d'"' -f2) | ||||||
|  |         echo "Building firmware and SPIFFS..." | ||||||
|  |         pio run -e esp32dev | ||||||
|  |         pio run -t buildfs | ||||||
|  |         cp .pio/build/esp32dev/firmware.bin .pio/build/esp32dev/filaman_${VERSION}.bin | ||||||
|  |         cp .pio/build/esp32dev/spiffs.bin .pio/build/esp32dev/webpage_${VERSION}.bin | ||||||
|  |         (cd .pio/build/esp32dev && esptool.py --chip esp32 merge_bin --fill-flash-size 4MB --flash_mode dio --flash_freq 40m --flash_size 4MB -o filaman_full_${VERSION}.bin 0x1000 bootloader.bin 0x8000 partitions.bin 0x10000 firmware.bin 0x390000 spiffs.bin) | ||||||
|  |         echo "File sizes:" | ||||||
|  |         (cd .pio/build/esp32dev && ls -lh *.bin) | ||||||
|  |     - name: Get version from platformio.ini | ||||||
|  |       id: get_version | ||||||
|  |       run: | | ||||||
|  |         VERSION=$(grep '^version = ' platformio.ini | cut -d'"' -f2) | ||||||
|  |         echo "VERSION=$VERSION" >> $GITHUB_OUTPUT | ||||||
|  |     - name: Read CHANGELOG.md | ||||||
|  |       id: changelog | ||||||
|  |       run: | | ||||||
|  |         VERSION=${{ steps.get_version.outputs.VERSION }} | ||||||
|  |         CHANGELOG=$(awk "/## \[$VERSION\]/{p=1;print;next} /## \[/{p=0} p" CHANGELOG.md) | ||||||
|  |         echo "CHANGES<<EOF" >> $GITHUB_OUTPUT | ||||||
|  |         echo "$CHANGELOG" >> $GITHUB_OUTPUT | ||||||
|  |         echo "EOF" >> $GITHUB_OUTPUT | ||||||
|  |     - name: Create GitHub Release | ||||||
|  |       env: | ||||||
|  |         GH_TOKEN: ${{ github.token }} | ||||||
|  |       run: | | ||||||
|  |         VERSION=${{ steps.get_version.outputs.VERSION }} | ||||||
|  |         cd .pio/build/esp32dev | ||||||
|  |         FILES_TO_UPLOAD="" | ||||||
|  |         if [ -f "filaman_${VERSION}.bin" ]; then | ||||||
|  |           FILES_TO_UPLOAD="$FILES_TO_UPLOAD filaman_${VERSION}.bin" | ||||||
|  |         fi | ||||||
|  |         if [ -f "webpage_${VERSION}.bin" ]; then | ||||||
|  |           FILES_TO_UPLOAD="$FILES_TO_UPLOAD webpage_${VERSION}.bin" | ||||||
|  |         fi | ||||||
|  |         if [ -f "filaman_full_${VERSION}.bin" ]; then | ||||||
|  |           FILES_TO_UPLOAD="$FILES_TO_UPLOAD filaman_full_${VERSION}.bin" | ||||||
|  |         fi | ||||||
|  |         if [ -n "$FILES_TO_UPLOAD" ]; then | ||||||
|  |           if [ "${{ needs.route.outputs.provider }}" = "github" ]; then | ||||||
|  |             gh release create "v${VERSION}" --title "Release ${VERSION}" --notes "${{ steps.changelog.outputs.CHANGES }}" $FILES_TO_UPLOAD | ||||||
|  |           elif [ "${{ needs.route.outputs.provider }}" = "gitea" ]; then | ||||||
|  |             API_URL="${{ needs.route.outputs.gitea_server_url }}/api/v1" | ||||||
|  |             REPO="${{ needs.route.outputs.gitea_repository }}" | ||||||
|  |             RESPONSE=$(curl -k -s -X POST -H "Authorization: token ${TOKEN}" -H "Content-Type: application/json" -d "{\"tag_name\":\"v${VERSION}\",\"name\":\"Release ${VERSION}\",\"body\":\"${{ steps.changelog.outputs.CHANGES }}\"}" "${API_URL}/repos/${REPO}/releases") | ||||||
|  |             RELEASE_ID=$(echo "$RESPONSE" | grep -o '"id":[0-9]*' | cut -d':' -f2 | head -n1) | ||||||
|  |             if [ -n "$RELEASE_ID" ]; then | ||||||
|  |               echo "Release created with ID: $RELEASE_ID" | ||||||
|  |               for file in $FILES_TO_UPLOAD; do | ||||||
|  |                 echo "Uploading $file..." | ||||||
|  |                 curl -k -s -X POST -H "Authorization: token ${TOKEN}" -H "Content-Type: application/octet-stream" --data-binary "@.pio/build/esp32dev/$file" "${API_URL}/repos/${REPO}/releases/${RELEASE_ID}/assets?name=$file" | ||||||
|  |               done | ||||||
|  |             else | ||||||
|  |               echo "Failed to create release. Response:" | ||||||
|  |               echo "$RESPONSE" | ||||||
|  |               exit 1 | ||||||
|  |             fi | ||||||
|  |           else | ||||||
|  |             echo "Error: Unknown provider" | ||||||
|  |             exit 1 | ||||||
|  |           fi | ||||||
|  |         else | ||||||
|  |           echo "Error: No files found to upload" | ||||||
|  |           exit 1 | ||||||
|  |  | ||||||
|   gitea-release: |   gitea-release: | ||||||
|     needs: [route, verify-provider] |     needs: [route, verify-provider] | ||||||
|     if: needs.route.outputs.provider == 'gitea' |     if: needs.route.outputs.provider == 'gitea' | ||||||
|     uses: ./.github/workflows/providers/gitea-release.yml |     runs-on: ubuntu-latest | ||||||
|  |     steps: | ||||||
|  |     - uses: actions/checkout@v4 | ||||||
|  |     - name: Set up Python | ||||||
|  |       uses: actions/setup-python@v4 | ||||||
|       with: |       with: | ||||||
|       gitea_ref_name: ${{ needs.route.outputs.gitea_ref_name }} |         python-version: '3.x' | ||||||
|       gitea_server_url: ${{ needs.route.outputs.gitea_server_url }} |     - name: Install PlatformIO | ||||||
|       gitea_repository: ${{ needs.route.outputs.gitea_repository }} |       run: | | ||||||
|     secrets: |         python -m pip install --upgrade pip | ||||||
|       GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} |         pip install --upgrade platformio esptool | ||||||
|  |     - name: Install xxd | ||||||
|  |       run: | | ||||||
|  |         sudo apt-get update | ||||||
|  |         sudo apt-get install xxd | ||||||
|  |     - name: Check for SPIFFS changes | ||||||
|  |       id: check_spiffs | ||||||
|  |       run: | | ||||||
|  |         git fetch --unshallow || true | ||||||
|  |         CHANGED_FILES=$(git diff --name-only HEAD^..HEAD) | ||||||
|  |         if echo "$CHANGED_FILES" | grep -q "^data/\|^html/"; then | ||||||
|  |           echo "SPIFFS_CHANGED=true" >> $GITHUB_OUTPUT | ||||||
|  |         else | ||||||
|  |           echo "SPIFFS_CHANGED=false" >> $GITHUB_OUTPUT | ||||||
|  |         fi | ||||||
|  |     - name: Check for Data changes | ||||||
|  |       id: check_data | ||||||
|  |       run: | | ||||||
|  |         git fetch --unshallow || true | ||||||
|  |         CHANGED_FILES=$(git diff --name-only HEAD^..HEAD) | ||||||
|  |         if echo "$CHANGED_FILES" | grep -q "^data/"; then | ||||||
|  |           echo "DATA_CHANGED=true" >> $GITHUB_OUTPUT | ||||||
|  |         else | ||||||
|  |           echo "DATA_CHANGED=false" >> $GITHUB_OUTPUT | ||||||
|  |         fi | ||||||
|  |     - name: Get version from platformio.ini | ||||||
|  |       id: get_version | ||||||
|  |       run: | | ||||||
|  |         VERSION=$(grep '^version = ' platformio.ini | cut -d'"' -f2) | ||||||
|  |         echo "VERSION=$VERSION" >> $GITHUB_OUTPUT | ||||||
|  |     - name: Build Firmware | ||||||
|  |       run: | | ||||||
|  |         VERSION=${{ steps.get_version.outputs.VERSION }} | ||||||
|  |         echo "Building firmware and SPIFFS..." | ||||||
|  |         pio run -e esp32dev | ||||||
|  |         pio run -t buildfs | ||||||
|  |         cp .pio/build/esp32dev/firmware.bin .pio/build/esp32dev/filaman_${VERSION}.bin | ||||||
|  |         cp .pio/build/esp32dev/spiffs.bin .pio/build/esp32dev/webpage_${VERSION}.bin | ||||||
|  |         (cd .pio/build/esp32dev && esptool.py --chip esp32 merge_bin --fill-flash-size 4MB --flash_mode dio --flash_freq 40m --flash_size 4MB -o filaman_full_${VERSION}.bin 0x1000 bootloader.bin 0x8000 partitions.bin 0x10000 firmware.bin 0x390000 spiffs.bin) | ||||||
|  |         echo "File sizes:" | ||||||
|  |         (cd .pio/build/esp32dev && ls -lh *.bin) | ||||||
|  |     - name: Prepare binaries | ||||||
|  |       run: | | ||||||
|  |         VERSION=${{ steps.get_version.outputs.VERSION }} | ||||||
|  |         if [[ "${{ steps.check_spiffs.outputs.SPIFFS_CHANGED }}" == "true" ]]; then | ||||||
|  |           echo "Creating full binary..." | ||||||
|  |           cd .pio/build/esp32dev && esptool.py --chip esp32 merge_bin --fill-flash-size 4MB --flash_mode dio --flash_freq 40m --flash_size 4MB -o filaman_full_${VERSION}.bin 0x0000 bootloader.bin 0x8000 partitions.bin 0x10000 firmware.bin 0x390000 spiffs.bin | ||||||
|  |         fi | ||||||
|  |         echo "File sizes:" | ||||||
|  |         cd .pio/build/esp32dev && ls -lh *.bin | ||||||
|  |     - name: Read CHANGELOG.md | ||||||
|  |       id: changelog | ||||||
|  |       run: | | ||||||
|  |         VERSION=${{ steps.get_version.outputs.VERSION }} | ||||||
|  |         CHANGELOG=$(awk "/## \[$VERSION\]/{p=1;print;next} /## \[/{p=0} p" CHANGELOG.md) | ||||||
|  |         echo "CHANGES<<EOF" >> $GITHUB_OUTPUT | ||||||
|  |         echo "$CHANGELOG" >> $GITHUB_OUTPUT | ||||||
|  |         echo "EOF" >> $GITHUB_OUTPUT | ||||||
|  |     - name: Create Release | ||||||
|  |       env: | ||||||
|  |         TOKEN: ${{ secrets.GITEA_TOKEN }} | ||||||
|  |       run: | | ||||||
|  |         API_URL="${{ needs.route.outputs.gitea_server_url }}/api/v1" | ||||||
|  |         REPO="${{ needs.route.outputs.gitea_repository }}" | ||||||
|  |         VERSION=${{ steps.get_version.outputs.VERSION }} | ||||||
|  |         RESPONSE=$(curl -k -s -X POST -H "Authorization: token ${TOKEN}" -H "Content-Type: application/json" -d "{\"tag_name\":\"v${VERSION}\",\"name\":\"Release ${VERSION}\",\"body\":\"${{ steps.changelog.outputs.CHANGES }}\"}" "${API_URL}/repos/${REPO}/releases") | ||||||
|  |         RELEASE_ID=$(echo "$RESPONSE" | grep -o '"id":[0-9]*' | cut -d':' -f2 | head -n1) | ||||||
|  |         if [ -n "$RELEASE_ID" ]; then | ||||||
|  |           echo "Release created with ID: $RELEASE_ID" | ||||||
|  |           for file in filaman_${VERSION}.bin filaman_full_${VERSION}.bin; do | ||||||
|  |             if [ -f ".pio/build/esp32dev/$file" ]; then | ||||||
|  |               echo "Uploading $file..." | ||||||
|  |               curl -k -s -X POST -H "Authorization: token ${TOKEN}" -H "Content-Type: application/octet-stream" --data-binary "@.pio/build/esp32dev/$file" "${API_URL}/repos/${REPO}/releases/${RELEASE_ID}/assets?name=$file" | ||||||
|  |             fi | ||||||
|  |           done | ||||||
|  |           if [ -f ".pio/build/esp32dev/webpage_${VERSION}.bin" ]; then | ||||||
|  |             echo "Uploading webpage binary..." | ||||||
|  |             curl -k -s -X POST -H "Authorization: token ${TOKEN}" -H "Content-Type: application/octet-stream" --data-binary "@.pio/build/esp32dev/webpage_${VERSION}.bin" "${API_URL}/repos/${REPO}/releases/${RELEASE_ID}/assets?name=webpage_${VERSION}.bin" | ||||||
|  |           fi | ||||||
|  |         else | ||||||
|  |           echo "Failed to create release. Response:" | ||||||
|  |           echo "$RESPONSE" | ||||||
|  |           exit 1 | ||||||
							
								
								
									
										67
									
								
								CHANGELOG.md
									
									
									
									
									
								
							
							
						
						
									
										67
									
								
								CHANGELOG.md
									
									
									
									
									
								
							| @@ -1,5 +1,72 @@ | |||||||
| # Changelog | # Changelog | ||||||
|  |  | ||||||
|  | ## [1.3.5] - 2025-02-21 | ||||||
|  | ### Added | ||||||
|  | - enhance release workflow to support Gitea alongside GitHub | ||||||
|  |  | ||||||
|  | ### Changed | ||||||
|  | - update webpages for version v1.3.5 | ||||||
|  |  | ||||||
|  |  | ||||||
|  | ## [1.3.4] - 2025-02-21 | ||||||
|  | ### Added | ||||||
|  | - add Gitea and GitHub release workflows | ||||||
|  |  | ||||||
|  | ### Changed | ||||||
|  | - update webpages for version v1.3.4 | ||||||
|  | - Merge branch 'old' | ||||||
|  |  | ||||||
|  |  | ||||||
|  | ## [1.3.3] - 2025-02-21 | ||||||
|  | ### Changed | ||||||
|  | - update webpages for version v1.3.3 | ||||||
|  |  | ||||||
|  | ### Fixed | ||||||
|  | - correct directory path in GitHub workflows for SPIFFS binary | ||||||
|  |  | ||||||
|  |  | ||||||
|  | ## [1.3.2] - 2025-02-21 | ||||||
|  | ### Added | ||||||
|  | - add missing conditional exit in release workflow | ||||||
|  |  | ||||||
|  | ### Changed | ||||||
|  | - update webpages for version v1.3.2 | ||||||
|  |  | ||||||
|  |  | ||||||
|  | ## [1.3.1] - 2025-02-21 | ||||||
|  | ### Added | ||||||
|  | - enhance GitHub and Gitea release workflows with Python setup and binary preparation | ||||||
|  |  | ||||||
|  | ### Changed | ||||||
|  | - update webpages for version v1.3.1 | ||||||
|  |  | ||||||
|  |  | ||||||
|  | ## [1.3.0] - 2025-02-21 | ||||||
|  | ### Changed | ||||||
|  | - bump version to 1.3.0 in platformio.ini | ||||||
|  |  | ||||||
|  |  | ||||||
|  | ## [1.2.102] - 2025-02-21 | ||||||
|  | ### Changed | ||||||
|  | - update webpages for version v1.2.102 | ||||||
|  |  | ||||||
|  | ### Fixed | ||||||
|  | - adjust bootloader offset in binary merge for Gitea and GitHub workflows | ||||||
|  |  | ||||||
|  |  | ||||||
|  | ## [1.2.101] - 2025-02-21 | ||||||
|  | ### Changed | ||||||
|  | - update webpages for version v1.2.101 | ||||||
|  | - always create SPIFFS binary in release workflows | ||||||
|  | - migrate calibration value storage from EEPROM to NVS | ||||||
|  |  | ||||||
|  |  | ||||||
|  | ## [1.2.100] - 2025-02-21 | ||||||
|  | ### Changed | ||||||
|  | - update webpages for version v1.2.100 | ||||||
|  | - remove OTA handling and JSON backup/restore functions | ||||||
|  |  | ||||||
|  |  | ||||||
| ## [1.2.99] - 2025-02-21 | ## [1.2.99] - 2025-02-21 | ||||||
| ### Added | ### Added | ||||||
| - add SPIFFS change detection and binary copying to release workflows | - add SPIFFS change detection and binary copying to release workflows | ||||||
|   | |||||||
| @@ -9,7 +9,7 @@ | |||||||
| ; https://docs.platformio.org/page/projectconf.html | ; https://docs.platformio.org/page/projectconf.html | ||||||
|  |  | ||||||
| [common] | [common] | ||||||
| version = "1.2.99" | version = "1.3.5" | ||||||
|  |  | ||||||
| [env:esp32dev] | [env:esp32dev] | ||||||
| platform = espressif32 | platform = espressif32 | ||||||
|   | |||||||
							
								
								
									
										269
									
								
								src/ota.cpp
									
									
									
									
									
								
							
							
						
						
									
										269
									
								
								src/ota.cpp
									
									
									
									
									
								
							| @@ -1,269 +0,0 @@ | |||||||
| #include <Arduino.h> |  | ||||||
| #include "ota.h" |  | ||||||
| #include <Update.h> |  | ||||||
| #include <SPIFFS.h> |  | ||||||
| #include "commonFS.h" |  | ||||||
| #include "bambu.h" |  | ||||||
| #include "scale.h" |  | ||||||
| #include "nfc.h" |  | ||||||
|  |  | ||||||
| #define UPLOAD_TIMEOUT_MS 60000  // 60 Sekunden Timeout für den gesamten Upload |  | ||||||
| #define CHUNK_RESPONSE_TIMEOUT_MS 10000  // 10 Sekunden Timeout pro Chunk |  | ||||||
| #define MAX_FAILED_CHUNKS 3  // Maximale Anzahl fehlgeschlagener Chunks bevor Abbruch |  | ||||||
| #define MAX_FILE_SIZE 4194304    // 4MB Limit |  | ||||||
|  |  | ||||||
| static bool tasksAreStopped = false; |  | ||||||
| static uint32_t lastChunkTime = 0; |  | ||||||
| static size_t failedChunks = 0; |  | ||||||
| static size_t expectedOffset = 0; |  | ||||||
| static size_t totalSize = 0; |  | ||||||
|  |  | ||||||
| void stopAllTasks() { |  | ||||||
|     Serial.println("Stopping RFID Reader"); |  | ||||||
|     if (RfidReaderTask) vTaskSuspend(RfidReaderTask); |  | ||||||
|     Serial.println("Stopping Bambu"); |  | ||||||
|     if (BambuMqttTask) vTaskSuspend(BambuMqttTask); |  | ||||||
|     Serial.println("Stopping Scale"); |  | ||||||
|     if (ScaleTask) vTaskSuspend(ScaleTask); |  | ||||||
|     vTaskDelay(100 / portTICK_PERIOD_MS); |  | ||||||
|     Serial.println("All tasks stopped"); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| void backupJsonConfigs() { |  | ||||||
|     const char* configs[] = {"/bambu_credentials.json", "/spoolman_url.json"}; |  | ||||||
|     for (const char* config : configs) { |  | ||||||
|         if (SPIFFS.exists(config)) { |  | ||||||
|             String backupPath = String(config) + ".bak"; |  | ||||||
|             SPIFFS.remove(backupPath); |  | ||||||
|             SPIFFS.rename(config, backupPath); |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
|  |  | ||||||
| void restoreJsonConfigs() { |  | ||||||
|     const char* configs[] = {"/bambu_credentials.json", "/spoolman_url.json"}; |  | ||||||
|     for (const char* config : configs) { |  | ||||||
|         String backupPath = String(config) + ".bak"; |  | ||||||
|         if (SPIFFS.exists(backupPath)) { |  | ||||||
|             SPIFFS.remove(config); |  | ||||||
|             SPIFFS.rename(backupPath, config); |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
|  |  | ||||||
| void performStageTwo() { |  | ||||||
|     if (!SPIFFS.begin(true)) { |  | ||||||
|         Serial.println("Error: Could not mount SPIFFS for stage 2"); |  | ||||||
|         return; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     // Backup JSON configs before update |  | ||||||
|     backupJsonConfigs(); |  | ||||||
|  |  | ||||||
|     File firmwareFile = SPIFFS.open("/firmware.bin", "r"); |  | ||||||
|     if (!firmwareFile) { |  | ||||||
|         Serial.println("Error: Could not open firmware.bin from SPIFFS"); |  | ||||||
|         return; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     size_t firmwareSize = firmwareFile.size(); |  | ||||||
|     size_t maxAppSpace = (ESP.getFreeSketchSpace() - 0x1000) & 0xFFFFF000; |  | ||||||
|  |  | ||||||
|     Serial.printf("Stage 2 - Firmware size: %u bytes\n", firmwareSize); |  | ||||||
|     Serial.printf("Available space: %u bytes\n", maxAppSpace); |  | ||||||
|  |  | ||||||
|     if (firmwareSize > maxAppSpace) { |  | ||||||
|         Serial.printf("Error: Not enough space for firmware. Need %u bytes but only have %u bytes\n",  |  | ||||||
|                     firmwareSize, maxAppSpace); |  | ||||||
|         return; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     if (!Update.begin(firmwareSize)) { |  | ||||||
|         Update.printError(Serial); |  | ||||||
|         return; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     size_t written = Update.writeStream(firmwareFile); |  | ||||||
|     if (written != firmwareSize) { |  | ||||||
|         Update.printError(Serial); |  | ||||||
|         return; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     if (!Update.end(true)) { |  | ||||||
|         Update.printError(Serial); |  | ||||||
|         return; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     firmwareFile.close(); |  | ||||||
|     SPIFFS.remove("/firmware.bin"); // Cleanup |  | ||||||
|  |  | ||||||
|     // Restore JSON configs after update |  | ||||||
|     restoreJsonConfigs(); |  | ||||||
|  |  | ||||||
|     Serial.println("Stage 2 update successful, restarting..."); |  | ||||||
|     delay(500); |  | ||||||
|     ESP.restart(); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| void checkForStagedUpdate() { |  | ||||||
|     if (!SPIFFS.begin(true)) { |  | ||||||
|         return; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     if (SPIFFS.exists("/firmware.bin")) { |  | ||||||
|         Serial.println("Found staged firmware update, initiating stage 2..."); |  | ||||||
|         performStageTwo(); |  | ||||||
|     } |  | ||||||
| } |  | ||||||
|  |  | ||||||
| void handleOTAUpload(AsyncWebServerRequest *request, String filename, size_t index, uint8_t *data, size_t len, bool final) { |  | ||||||
|     static File stagingFile; |  | ||||||
|     static uint32_t uploadStartTime = 0; |  | ||||||
|      |  | ||||||
|     if (!index) { |  | ||||||
|         // Überprüfe Gesamtgröße im Header |  | ||||||
|         if (request->hasHeader("X-Total-Size")) { |  | ||||||
|             totalSize = request->header("X-Total-Size").toInt(); |  | ||||||
|             if (totalSize > MAX_FILE_SIZE) { |  | ||||||
|                 request->send(413, "application/json",  |  | ||||||
|                             "{\"status\":\"error\",\"message\":\"File too large\"}"); |  | ||||||
|                 return; |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         uploadStartTime = millis(); |  | ||||||
|         lastChunkTime = millis(); |  | ||||||
|         expectedOffset = 0; |  | ||||||
|         failedChunks = 0; |  | ||||||
|          |  | ||||||
|         bool isSpiffsUpdate = filename.endsWith("_spiffs.bin"); |  | ||||||
|         Serial.printf("Update Start: %s (type: %s)\n", filename.c_str(), isSpiffsUpdate ? "SPIFFS" : "OTA"); |  | ||||||
|         Serial.printf("Total size: %u bytes\n", totalSize); |  | ||||||
|          |  | ||||||
|         // Überprüfe Header für Chunk-Informationen |  | ||||||
|         if (request->hasHeader("X-Chunk-Offset")) { |  | ||||||
|             String offsetStr = request->header("X-Chunk-Offset"); |  | ||||||
|             expectedOffset = offsetStr.toInt(); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         if (request->contentLength() == 0) { |  | ||||||
|             request->send(400, "application/json", "{\"status\":\"error\",\"message\":\"Invalid file size\"}"); |  | ||||||
|             return; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         if (!tasksAreStopped) { |  | ||||||
|             stopAllTasks(); |  | ||||||
|             tasksAreStopped = true; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         if (isSpiffsUpdate) { |  | ||||||
|             if (!SPIFFS.begin(true)) { |  | ||||||
|                 request->send(400, "application/json",  |  | ||||||
|                             "{\"status\":\"error\",\"message\":\"Could not mount SPIFFS\"}"); |  | ||||||
|                 return; |  | ||||||
|             } |  | ||||||
|              |  | ||||||
|             if (!Update.begin(totalSize > 0 ? totalSize : request->contentLength(), U_SPIFFS)) { |  | ||||||
|                 Update.printError(Serial); |  | ||||||
|                 request->send(400, "application/json",  |  | ||||||
|                             "{\"status\":\"error\",\"message\":\"SPIFFS update initialization failed\"}"); |  | ||||||
|                 return; |  | ||||||
|             } |  | ||||||
|         } else { |  | ||||||
|             stagingFile = SPIFFS.open("/firmware.bin", "w"); |  | ||||||
|             if (!stagingFile) { |  | ||||||
|                 request->send(400, "application/json",  |  | ||||||
|                             "{\"status\":\"error\",\"message\":\"Could not create staging file\"}"); |  | ||||||
|                 return; |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     // Chunk Validierung |  | ||||||
|     if (request->hasHeader("X-Chunk-Offset")) { |  | ||||||
|         size_t chunkOffset = request->header("X-Chunk-Offset").toInt(); |  | ||||||
|         if (chunkOffset != expectedOffset) { |  | ||||||
|             failedChunks++; |  | ||||||
|             if (failedChunks >= MAX_FAILED_CHUNKS) { |  | ||||||
|                 if (stagingFile) { |  | ||||||
|                     stagingFile.close(); |  | ||||||
|                     SPIFFS.remove("/firmware.bin"); |  | ||||||
|                 } |  | ||||||
|                 Update.abort(); |  | ||||||
|                 request->send(400, "application/json",  |  | ||||||
|                             "{\"status\":\"error\",\"message\":\"Too many failed chunks\"}"); |  | ||||||
|                 return; |  | ||||||
|             } |  | ||||||
|             request->send(400, "application/json",  |  | ||||||
|                         "{\"status\":\"error\",\"message\":\"Invalid chunk offset\"}"); |  | ||||||
|             return; |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     // Timeout Überprüfungen |  | ||||||
|     uint32_t currentTime = millis(); |  | ||||||
|     if (currentTime - uploadStartTime > UPLOAD_TIMEOUT_MS) { |  | ||||||
|         if (stagingFile) { |  | ||||||
|             stagingFile.close(); |  | ||||||
|             SPIFFS.remove("/firmware.bin"); |  | ||||||
|         } |  | ||||||
|         Update.abort(); |  | ||||||
|         request->send(408, "application/json", "{\"status\":\"error\",\"message\":\"Upload timeout\"}"); |  | ||||||
|         return; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     if (currentTime - lastChunkTime > CHUNK_RESPONSE_TIMEOUT_MS) { |  | ||||||
|         if (stagingFile) { |  | ||||||
|             stagingFile.close(); |  | ||||||
|             SPIFFS.remove("/firmware.bin"); |  | ||||||
|         } |  | ||||||
|         Update.abort(); |  | ||||||
|         request->send(408, "application/json", "{\"status\":\"error\",\"message\":\"Chunk timeout\"}"); |  | ||||||
|         return; |  | ||||||
|     } |  | ||||||
|     lastChunkTime = currentTime; |  | ||||||
|  |  | ||||||
|     if (stagingFile) { |  | ||||||
|         size_t written = stagingFile.write(data, len); |  | ||||||
|         if (written != len) { |  | ||||||
|             stagingFile.close(); |  | ||||||
|             SPIFFS.remove("/firmware.bin"); |  | ||||||
|             request->send(400, "application/json",  |  | ||||||
|                         "{\"status\":\"error\",\"message\":\"Write to SPIFFS failed\"}"); |  | ||||||
|             return; |  | ||||||
|         } |  | ||||||
|     } else { |  | ||||||
|         if (Update.write(data, len) != len) { |  | ||||||
|             Update.printError(Serial); |  | ||||||
|             request->send(400, "application/json",  |  | ||||||
|                         "{\"status\":\"error\",\"message\":\"Write failed\"}"); |  | ||||||
|             return; |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     expectedOffset += len; |  | ||||||
|  |  | ||||||
|     if (final) { |  | ||||||
|         if (stagingFile) { |  | ||||||
|             stagingFile.close(); |  | ||||||
|             Serial.println("Stage 1 complete - firmware staged in SPIFFS"); |  | ||||||
|             request->send(200, "application/json",  |  | ||||||
|                         "{\"status\":\"success\",\"message\":\"Update staged successfully! Starting stage 2...\"}"); |  | ||||||
|             delay(100); |  | ||||||
|             performStageTwo(); |  | ||||||
|         } else { |  | ||||||
|             if (!Update.end(true)) { |  | ||||||
|                 Update.printError(Serial); |  | ||||||
|                 request->send(400, "application/json",  |  | ||||||
|                             "{\"status\":\"error\",\"message\":\"Update failed\"}"); |  | ||||||
|                 return; |  | ||||||
|             } |  | ||||||
|             Serial.println("SPIFFS update successful, restarting..."); |  | ||||||
|             request->send(200, "application/json",  |  | ||||||
|                         "{\"status\":\"success\",\"message\":\"SPIFFS update successful! Device will restart...\",\"restart\":true}"); |  | ||||||
|             delay(500); |  | ||||||
|             ESP.restart(); |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
|  |  | ||||||
							
								
								
									
										18
									
								
								src/ota.h
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								src/ota.h
									
									
									
									
									
								
							| @@ -1,18 +0,0 @@ | |||||||
| #ifndef OTA_H |  | ||||||
| #define OTA_H |  | ||||||
|  |  | ||||||
| #include <ESPAsyncWebServer.h> |  | ||||||
|  |  | ||||||
| // Update size unknown constant, falls nicht bereits definiert |  | ||||||
| #ifndef UPDATE_SIZE_UNKNOWN |  | ||||||
| #define UPDATE_SIZE_UNKNOWN 0xFFFFFFFF |  | ||||||
| #endif |  | ||||||
|  |  | ||||||
| void handleOTAUpload(AsyncWebServerRequest *request, const String& filename, size_t index, uint8_t *data, size_t len, bool final); |  | ||||||
| void checkForStagedUpdate(); |  | ||||||
| void performStageTwo(); |  | ||||||
| void stopAllTasks(); |  | ||||||
| void backupJsonConfigs(); |  | ||||||
| void restoreJsonConfigs(); |  | ||||||
|  |  | ||||||
| #endif |  | ||||||
| @@ -3,9 +3,9 @@ | |||||||
| #include <ArduinoJson.h> | #include <ArduinoJson.h> | ||||||
| #include "config.h" | #include "config.h" | ||||||
| #include "HX711.h" | #include "HX711.h" | ||||||
| #include <EEPROM.h> |  | ||||||
| #include "display.h" | #include "display.h" | ||||||
| #include "esp_task_wdt.h" | #include "esp_task_wdt.h" | ||||||
|  | #include <Preferences.h> | ||||||
|  |  | ||||||
| HX711 scale; | HX711 scale; | ||||||
|  |  | ||||||
| @@ -17,6 +17,10 @@ uint8_t weigthCouterToApi = 0; | |||||||
| uint8_t scale_tare_counter = 0; | uint8_t scale_tare_counter = 0; | ||||||
| uint8_t pauseMainTask = 0; | uint8_t pauseMainTask = 0; | ||||||
|  |  | ||||||
|  | Preferences preferences; | ||||||
|  | const char* NVS_NAMESPACE = "scale"; | ||||||
|  | const char* NVS_KEY_CALIBRATION = "cal_value"; | ||||||
|  |  | ||||||
| // ##### Funktionen für Waage ##### | // ##### Funktionen für Waage ##### | ||||||
| uint8_t tareScale() { | uint8_t tareScale() { | ||||||
|   Serial.println("Tare scale"); |   Serial.println("Tare scale"); | ||||||
| @@ -48,13 +52,12 @@ void scale_loop(void * parameter) { | |||||||
|  |  | ||||||
| void start_scale() { | void start_scale() { | ||||||
|   Serial.println("Prüfe Calibration Value"); |   Serial.println("Prüfe Calibration Value"); | ||||||
|   long calibrationValue; // calibration value (see example file "Calibration.ino") |   long calibrationValue; | ||||||
|   //calibrationValue = 696.0; // uncomment this if you want to set the calibration value in the sketch |  | ||||||
|  |  | ||||||
|   EEPROM.begin(512); |   // NVS | ||||||
|   EEPROM.get(calVal_eepromAdress, calibrationValue); // uncomment this if you want to fetch the calibration value from eeprom |   preferences.begin(NVS_NAMESPACE, true); // true = readonly | ||||||
|  |   calibrationValue = preferences.getLong(NVS_KEY_CALIBRATION, defaultScaleCalibrationValue); | ||||||
|   //calibrationValue = EEPROM.read(calVal_eepromAdress); |   preferences.end(); | ||||||
|  |  | ||||||
|   Serial.print("Read Scale Calibration Value "); |   Serial.print("Read Scale Calibration Value "); | ||||||
|   Serial.println(calibrationValue); |   Serial.println(calibrationValue); | ||||||
| @@ -137,18 +140,19 @@ uint8_t calibrate_scale() { | |||||||
|     { |     { | ||||||
|       Serial.print("New calibration value has been set to: "); |       Serial.print("New calibration value has been set to: "); | ||||||
|       Serial.println(newCalibrationValue); |       Serial.println(newCalibrationValue); | ||||||
|       Serial.print("Save this value to EEPROM adress "); |  | ||||||
|       Serial.println(calVal_eepromAdress); |  | ||||||
|  |  | ||||||
|       //EEPROM.put(calVal_eepromAdress, newCalibrationValue); |       // Speichern mit NVS | ||||||
|       EEPROM.put(calVal_eepromAdress, newCalibrationValue); |       preferences.begin(NVS_NAMESPACE, false); // false = readwrite | ||||||
|       EEPROM.commit(); |       preferences.putLong(NVS_KEY_CALIBRATION, newCalibrationValue); | ||||||
|  |       preferences.end(); | ||||||
|  |  | ||||||
|       EEPROM.get(calVal_eepromAdress, newCalibrationValue); |       // Verifizieren | ||||||
|       //newCalibrationValue = EEPROM.read(calVal_eepromAdress); |       preferences.begin(NVS_NAMESPACE, true); | ||||||
|  |       long verifyValue = preferences.getLong(NVS_KEY_CALIBRATION, 0); | ||||||
|  |       preferences.end(); | ||||||
|  |  | ||||||
|       Serial.print("Read Value "); |       Serial.print("Verified stored value: "); | ||||||
|       Serial.println(newCalibrationValue); |       Serial.println(verifyValue); | ||||||
|  |  | ||||||
|       Serial.println("End calibration, revome weight"); |       Serial.println("End calibration, revome weight"); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -29,4 +29,8 @@ void sendNfcData(AsyncWebSocketClient *client); | |||||||
| void foundNfcTag(AsyncWebSocketClient *client, uint8_t success); | void foundNfcTag(AsyncWebSocketClient *client, uint8_t success); | ||||||
| void sendWriteResult(AsyncWebSocketClient *client, uint8_t success); | void sendWriteResult(AsyncWebSocketClient *client, uint8_t success); | ||||||
|  |  | ||||||
|  | // Upgrade-Funktionen | ||||||
|  | void backupJsonConfigs(); | ||||||
|  | void restoreJsonConfigs(); | ||||||
|  |  | ||||||
| #endif | #endif | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user