Skip to content

Commit a0c317f

Browse files
committed
ChessConnect
1 parent 6ddcbb0 commit a0c317f

19 files changed

Lines changed: 324 additions & 28 deletions

.gitattributes

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
* text=auto eol=lf
1+
* text=auto eol=lf
2+
3+
# git-crypt: encrypt all ChessConnect source files
4+
src/chessconnect/** filter=git-crypt diff=git-crypt

.github/workflows/release.yml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,23 @@ jobs:
3232
- name: Install PlatformIO
3333
run: pip install platformio
3434

35+
- name: Install git-crypt
36+
run: sudo apt-get update && sudo apt-get install -y git-crypt
37+
38+
- name: Unlock encrypted sources
39+
run: |
40+
printf '%s' "${{ secrets.GIT_CRYPT_KEY }}" | base64 -d > /tmp/git-crypt-key
41+
git-crypt unlock /tmp/git-crypt-key
42+
rm /tmp/git-crypt-key
43+
3544
- name: Extract version from tag
3645
id: version
3746
run: echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
3847

3948
- name: Inject version into firmware
4049
run: |
4150
sed -i 's/#define FIRMWARE_VERSION "dev"/#define FIRMWARE_VERSION "${{ steps.version.outputs.version }}"/' src/version.h
51+
sed -i '/#define DEV_BUILD/d' src/version.h
4252
echo "Firmware version set to: ${{ steps.version.outputs.version }}"
4353
cat src/version.h
4454
@@ -91,7 +101,7 @@ jobs:
91101
## OpenChess ${{ github.ref_name }}
92102
93103
### Flash via Browser (ESP Web Tools)
94-
Visit the [OpenChess Web Installer](https://joojoooo.github.io/OpenChess/flash.html) to flash your ESP32 directly from your browser.
104+
Use the [OpenChess Web Installer](https://joojoooo.github.io/OpenChess/flash.html) to flash your ESP32 directly from the browser.
95105
96106
### Release Files
97107
| File | Description |
@@ -100,13 +110,8 @@ jobs:
100110
| `bootloader.bin` | ESP32 bootloader |
101111
| `partitions.bin` | Partition table |
102112
| `boot_app0.bin` | OTA boot selector |
103-
| `littlefs.bin` | Web UI filesystem image (initial flash only) |
104-
| `web_assets.tar` | Web UI assets for OTA updates (preserves saved games) |
105-
106-
### OTA Updates
107-
The board checks for updates automatically at boot (can be disabled in Board Settings).
108-
- **Firmware**: Updated via `firmware.bin`
109-
- **Web UI**: Updated via `web_assets.tar` (preserves saved games on LittleFS)
113+
| `littlefs.bin` | Web UI filesystem image |
114+
| `web_assets.tar` | Web UI assets for OTA updates |
110115
111116
# Deploy GitHub Pages with the new release firmware so the Web Installer can fetch
112117
# binaries from the same origin (GitHub Pages has CORS headers, GitHub Releases does not).

README.md

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# OpenChess - Smart Chess Board [![Build & Release](https://github.com/joojoooo/OpenChess/actions/workflows/release.yml/badge.svg)](https://github.com/joojoooo/OpenChess/actions/workflows/release.yml)
2-
OpenChess is a smart chessboard, it can show legal moves, plays against you using Stockfish or let you play online games from Chess.com, Lichess, etc. on your physical board.
2+
OpenChess is a smart chessboard, it can show legal moves, plays against you using Stockfish or let you play online games on your physical board.
33

44
<p align="center"><img src="docs/BuildGuide/OpenChess - Plastic PCB (Bot config).webp" width="50%"></p>
55

@@ -12,18 +12,31 @@ Love this project? You can [support it on Ko-fi](https://ko-fi.com/joojooo) Ever
1212
- **👣 [Step-by-step build guide](https://joojoooo.github.io/OpenChess)** - covers materials, schematics, assembly, and [software setup](https://joojoooo.github.io/OpenChess/index.html#software)
1313
- **[Web Flasher](https://joojoooo.github.io/OpenChess/flash.html)** - easily flash your ESP32 directly from the browser
1414

15+
## ♟️ ChessConnect
16+
OpenChess can emulate BLE (Bluetooth Low Energy) chess boards and is compatible with [ChessConnect](https://chessconnect.de/) for playing on Chess.com, Lichess and many other platforms.
17+
18+
### How to use
19+
1. Download the [ChessConnect](https://chessconnect.de) app or extension
20+
2. In the OpenChess WebUI, choose a board to emulate and start the BLE server
21+
3. In ChessConnect, select the emulated board and connect
22+
4. Start a game right from ChessConnect
23+
5. Watch the [video guide](https://youtu.be/bYm5_dK6EnQ)
24+
25+
> [!NOTE]
26+
> This feature is **closed-source** and only included in precompiled [GitHub releases](https://github.com/joojoooo/OpenChess/releases). Works fully offline, no Internet required.
27+
1528
## ✨ Features
1629
Features that differentiate this fork from the original Concept-Bytes project:
1730

1831
### 🕹️ Gameplay
19-
- **Lichess**: Play online Lichess games using the Lichess API directly over WiFi
32+
- **Lichess**: Play online Lichess games using the Lichess API directly over WiFi (no ChessConnect)
2033
- **Game history**: Saves local (not-online) games so they can be reviewed later. If power is lost during gameplay, the game is automatically recovered on reboot.
2134
- **Check**: Shows a blinking animation on the checked king square and doesn't display or allow illegal moves that would put or leave the king in check
2235
- **GameOver**: Detects when the game is over and shows an animation with the winner color. Enforces 50-move, 3-fold repetition and insufficient material rules
2336
- **Draw/Resign**: Buttons in the WebUI can be used to Draw/Resign or Lift both kings off the board and hold them lifted for 2 seconds to end the game in a Draw.
2437
- **Castling**: Castling is possible by moving the king 2 squares towards the side you want to castle and it will show you where to move the rook.
2538
- **En passant**: Lift the pawn to show the destination square in red and the captured pawn square in purple
26-
- **Promotion**: Can be picked from the WebUI or the ChessUp app. If the WebUI or app are not open, a Queen is automatically picked.
39+
- **Promotion**: Can be picked from the WebUI or ChessConnect app. If the WebUI or app are not open, a Queen is automatically picked.
2740
- **Fixes**: Glaring bugs from the Concept-Bytes code that were fixed: Board is rotated correctly (white on the right), Queen and King are on the correct squares and playing infinite moves in a row is no longer possible.
2841

2942
### 🖥️ Hardware & Software
@@ -38,7 +51,11 @@ Features that differentiate this fork from the original Concept-Bytes project:
3851

3952
## 🤝 Contributing
4053
Contributions are welcome! If you have any new ideas to add or feedback to share, I'd love to hear it!
54+
</br></br>
4155
Please read the [Contributing Guidelines](/CONTRIBUTING.md) before submitting a PR.
56+
</br></br>
57+
[ChessConnect code](/src/chessconnect/) is [git-crypt](https://github.com/AGWA/git-crypt) encrypted. Access to the decryption key may be granted to trusted contributors.
58+
You can still contribute to the open-source parts of the project without the key: the ChessConnect feature is automatically disabled when building from encrypted sources.
4259

4360
## 📄 License
4461
This project is based on [Open-Chess](https://github.com/Concept-Bytes/Open-Chess) by [Concept-Bytes](https://github.com/Concept-Bytes), which is licensed under the [MIT License](/LICENSE-MIT).

platformio.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ monitor_speed = 115200
1616
board_build.filesystem = littlefs
1717
board_build.partitions = min_spiffs_nocore.csv
1818
extra_scripts =
19+
pre:scripts/chessconnect.py
1920
pre:src/web/build/minify.py
2021
pre:src/web/build/prepare_littlefs.py
2122
src/web/build/upload_fs.py
@@ -24,7 +25,9 @@ lib_deps =
2425
bblanchon/ArduinoJson@^7.4.3
2526
esp32async/AsyncTCP@^3.4.10
2627
esp32async/ESPAsyncWebServer@^3.10.1
28+
h2zero/NimBLE-Arduino@^2.3.9
2729
lib_ignore =
2830
ESPAsyncTCP
2931
RPAsyncTCP
32+
ESP32 BLE Arduino
3033
lib_ldf_mode = deep

scripts/chessconnect.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
"""PlatformIO pre-build script for ChessConnect private source handling.
2+
3+
All files in src/chessconnect/ are git-crypt encrypted in the public repo.
4+
When any file is encrypted (or missing), this script excludes the entire folder
5+
from compilation and builds without ChessConnect features.
6+
7+
When all sources are decrypted, they compile normally and CHESSCONNECT_ENABLED is
8+
defined, enabling ChessConnect support in the firmware.
9+
10+
The CI workflow (release.yml) unlocks via git-crypt and builds with full features.
11+
"""
12+
13+
import os
14+
Import("env")
15+
16+
CHESSCONNECT_DIR = os.path.join(env.subst("$PROJECT_SRC_DIR"), "chessconnect")
17+
18+
19+
def is_encrypted_or_missing(filepath):
20+
"""Return True if the file is git-crypt encrypted or missing."""
21+
try:
22+
with open(filepath, "rb") as f:
23+
return f.read(10).startswith(b"\x00GITCRYPT")
24+
except (FileNotFoundError, IOError):
25+
return True
26+
27+
28+
# Check every file in the chessconnect folder
29+
all_files = os.listdir(CHESSCONNECT_DIR) if os.path.isdir(CHESSCONNECT_DIR) else []
30+
sources_available = len(all_files) > 0 and not any(
31+
is_encrypted_or_missing(os.path.join(CHESSCONNECT_DIR, f))
32+
for f in all_files
33+
)
34+
35+
if sources_available:
36+
print(">> ChessConnect: sources available - building with CHESSCONNECT_ENABLED")
37+
env.Append(CPPDEFINES=["CHESSCONNECT_ENABLED"])
38+
else:
39+
print(">> ChessConnect: sources encrypted/missing - building without CHESSCONNECT_ENABLED")
40+
41+
def skip_chessconnect(node):
42+
path = node.get_path().replace("\\", "/")
43+
if "/chessconnect/" in path:
44+
return None
45+
return node
46+
47+
env.AddBuildMiddleware(skip_chessconnect)

src/chessconnect/ble_board.h

973 Bytes
Binary file not shown.

src/chessconnect/chess_connect.cpp

6.79 KB
Binary file not shown.

src/chessconnect/chess_connect.h

449 Bytes
Binary file not shown.
14.7 KB
Binary file not shown.
656 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)