on device wifi
All checks were successful
ESP32 Build & Release / build (push) Successful in 6m41s

This commit is contained in:
2026-09-12 13:09:47 +02:00
parent 80eab1752c
commit d691febfe4
13 changed files with 1340 additions and 224 deletions

View File

@@ -80,50 +80,52 @@ Never dig through your token box again for missing tokens:
* Rotate the knob each time your commander is recast from the command zone; the screen calculates the extra mana required (e.g. `Cast 3 = +4 Mana`).
* Click to switch to the table turn counter.
#### 6. Pairing Cards from your Phone (No App Needed!)
When you scan a new card tag that hasn't been programmed yet:
1. The screen displays:
```
PAIR VIA WI-FI:
http://192.168.0.57
(or Hotspot: MTG-Companion @ 192.168.4.1)
```
2. Open that address in your smartphone or laptop browser.
3. Tap the card sleeve to the device—its unique ID pops up in the web form automatically.
4. Start typing the card name (e.g. `"Sol Ring"`). Real-time Scryfall suggestions appear.
5. Click **Pair Card**. The device downloads the high-res card art and text and saves it to its permanent memory.
6. **Deck Overview:** The web page also lets you view your entire scanned deck with card art thumbnails and unbind old cards with one click.
#### 6. Pairing Cards & On-Device Wi-Fi Setup (No App Needed!)
The device runs a built-in web portal that works on any smartphone, tablet, or laptop:
* **Connecting to the Portal:**
* **Option A (Instant Captive Portal):** Connect your phone to the Wi-Fi network named **`MTG-Companion`** (no password). Your phone will automatically pop up the setup screen! (Or open `http://192.168.4.1` in your browser).
* **Option B (Home Wi-Fi):** If connected to your home network, simply browse to the device's IP shown on screen (e.g. `http://192.168.0.57`).
* **🎴 Card Pairing Tab:**
1. Tap an unmapped card sleeve to the reader—its unique tag ID appears instantly in the form.
2. Type the card name (e.g. `"Sol Ring"`); Scryfall auto-complete displays live suggestions.
3. Click **Pair Card**. The device downloads high-resolution illustration art and official oracle text into permanent flash memory.
4. Browse and manage all paired cards in your deck with illustration thumbnails and 1-click unbind.
* **📶 Wi-Fi Settings Tab:**
1. Click **Scan Networks** to see all nearby Wi-Fi networks with signal strength and security indicators.
2. Select your network (or mobile hotspot) from the dropdown, enter the password, and click **Connect & Save**.
3. **Multi-Network Memory:** The device remembers up to 5 Wi-Fi profiles in permanent flash. When you turn the companion on, it automatically scans and connects to whichever saved network is in range (e.g. seamlessly switching between Home Wi-Fi and your Phone's Mobile Hotspot)!
4. Forget unwanted networks anytime with one click.
#### 7. Over-The-Air (OTA) Updates
* Select **8. CHECK FIRMWARE OTA** from the menu (or let it auto-check on boot when connected to Wi-Fi).
* If a new version is detected, the screen shows the new version number and asks you to click to install or turn the knob to dismiss.
* While updating, a live progress bar shows the download. When finished, the device verifies the update and restarts automatically.
The companion automatically fetches firmware releases directly from:
**`https://git.rasmusbendtsen.dk/rasmus/MTGcompanion/releases`**
* **Automatic Hash Verification:** Whenever you push code to `main`, Gitea Actions builds the new firmware and computes its cryptographic SHA-256 hash.
* **Instant Detection:** Select **8. CHECK FIRMWARE OTA** from the menu (or let it auto-check on boot when connected to Wi-Fi). The device compares its currently running image hash against the latest build on your server:
* If a new build is available, the screen shows the new target hash and invites you to click the knob to install.
* If the hashes match, it confirms the firmware is up to date and skips unnecessary flashing.
* **Safe Dual-Slot Flashing:** While updating, a live progress bar streams the binary over HTTPS into the inactive partition slot. The device validates the new image and reboots automatically with rollback protection.
---
### 💡 Pro-Tip: Changing Wi-Fi Networks on the Go (Home Wi-Fi ↔ Phone Hotspot)
### 💡 Switching Wi-Fi Networks on the Go (Home Wi-Fi ↔ Phone Hotspot)
When heading to your Local Game Store (LGS), a friend's house, or a tournament, you may want your companion connected to your phone's mobile hotspot so it can fetch fresh card data from Scryfall on the fly.
When heading to your Local Game Store (LGS), a friend's house, or a tournament, switching between your home Wi-Fi and phone hotspot is completely effortless:
Because your Companion supports Over-The-Air updates through Gitea, **you never need a USB cable or computer to change Wi-Fi credentials!**
1. **One-Time Setup via Phone Hotspot:**
- Turn on your phone's personal hotspot.
- Connect your phone to the **`MTG-Companion`** hotspot.
- In the pop-up portal under **📶 Wi-Fi Settings**, click **Scan Networks**, select your phone hotspot, enter the password, and click **Connect & Save**.
2. **Automatic Hand-off:**
- The device stores both your Home Wi-Fi and Phone Hotspot.
- At home: it automatically joins Home Wi-Fi.
- At the game store: turn on your phone's hotspot and turn on the companion—it locks onto your phone automatically!
#### Switching from Home Wi-Fi to Phone Hotspot (Before heading out):
1. **Update Wi-Fi in Gitea:** Open your Gitea repository in your browser (even on your phone) and edit `sdkconfig.defaults`:
```ini
CONFIG_MTG_WIFI_SSID="MyPhoneHotspot"
CONFIG_MTG_WIFI_PASS="MyHotspotPassword"
```
2. **Commit to `main`:** Gitea Actions will automatically compile your new firmware in ~1–2 minutes.
3. **Trigger OTA Update:** While still on your home Wi-Fi, select **8. CHECK FIRMWARE OTA** on your device and click to install.
4. **Ready for the Game Store!** The device reboots with your hotspot credentials saved. When you turn on your phone's personal hotspot at the store, the companion connects automatically.
#### Switching Back to Home Wi-Fi:
Simply revert or update `sdkconfig.defaults` in Gitea back to your home Wi-Fi name, trigger the OTA update over your phone hotspot, and you're back on your home network.
> 🛟 **Forgot to update before leaving home?**
> No problem:
> - **The "Mirror" Hotspot Trick:** Set your phone's personal hotspot name and password to match your home Wi-Fi network. The companion will connect to your phone immediately, thinking it's at home!
> - **Offline Play Always Works:** All previously scanned cards and art are stored safely in local flash memory, and the device's built-in `MTG-Companion` pairing page works offline with zero internet required.
> 🛟 **Offline Play Always Works:**
> All previously scanned cards and art are stored in local flash memory, and the device's built-in `MTG-Companion` pairing portal works offline with zero internet required.
---
@@ -235,14 +237,13 @@ idf.py --version
```
#### 2. Configuration
Configure Wi-Fi credentials and Gitea instance details:
Configure initial Wi-Fi credentials (or use on-device Wi-Fi setup):
```powershell
idf.py menuconfig
# Navigate to: "MTG RFID Companion"
# - Wi-Fi SSID & Password
# - Gitea instance base URL (e.g. https://git.example.com)
# - Gitea repository owner & repo name
# - Wi-Fi SSID & Password (Optional - can also be configured via captive portal)
```
*(The firmware is pre-configured to check updates directly from `https://git.rasmusbendtsen.dk/rasmus/MTGcompanion/releases`)*
#### 3. Build & Flash (Initial USB Provisioning)
```powershell
@@ -256,9 +257,10 @@ idf.py -p COM4 erase-flash flash monitor
### Automated CI / Gitea Actions Workflow
The repository includes a Gitea Actions workflow in [`.gitea/workflows/releases.yml`](file:///c:/Users/rsben/Desktop/Rasmus/Programmering/espMTG/.gitea/workflows/releases.yml):
* **Trigger:** Pushing any version tag (e.g. `git tag v1.0.1 && git push origin v1.0.1`).
* **Trigger:** Pushes to the `main` branch.
* **Environment:** Official `docker://espressif/idf:v5.5` container.
* **Artifacts:** Compiles the firmware and automatically attaches `mtg-rfid-companion.bin` (for wireless OTA updates) and `full-flash-bundle-*.tar.gz` (for USB cable flashing) directly to the Gitea release.
* **Artifacts & Hashes:** Compiles the firmware, generates SHA-256 hashes (`firmware.sha256`), and automatically releases `mtg-rfid-companion.bin` (for wireless OTA updates) to the Gitea repository at `https://git.rasmusbendtsen.dk/rasmus/MTGcompanion/releases`.
* **Hash-Based Verification:** Embeds the Git commit SHA and binary SHA-256 hash in the release metadata so the ESP32 can verify whether an update is available without relying on manual version bumps.
---