Support for external chess devices via bluetooth
We can imagin electronic board, which can detect user moves and perform/indicate oponent moves. With proposed implementation device can be connected with app via Bluetooth - it can read and send moves using simple protocol.
We found electronics boards DGT, ChessLink (Milenium), Certabo, which has different protocols and usually different applications to play in chess.
Lichess and chess.com are supporting DGT from the web app. There is also app WhitePawn, which supports a few of boards (different diriver for each device).
Our idea is to have something universal and common to simplify creation of new devices and limit product related protocols. After research we decided to reuse two existing protocols:
- universals chess interface
UCI - chess engine communication protocol
XBoard(CECP).
Everyone who wants create his chess device can just choose protocol and advertise it on unique uuid. From lichobile app user can turn on Bluetooth and serach for device with this uuid to play with their favorite electronic board.
More about protocols: README.md
Videos with example: playlist
Device side exaples: link (implemented in python and tested on raspberry pi)
Next steps:
- Add support of
SANnotation - Add support of
crazyhouseand other game types - Support more protocol features
- Populating this concept in other applications:
WhitePawn,chess.com
❗
Closes #1998?
Whoa! I'll need some time to look at it. I don't have an electronic board so I won't be able to test it fyi. Could you add a summary about all the possible use cases this PR enable @vovagorodok ? I saw The videos but since they are demos with a terminal I may miss some of the use cases for this. Thanks!
exclamation
Closes #1998?
yes
Whoa! I'll need some time to look at it. I don't have an electronic board so I won't be able to test it fyi. Could you add a summary about all the possible use cases this PR enable @vovagorodok ? I saw The videos but since they are demos with a terminal I may miss some of the use cases for this. Thanks!
I and @dkwach are under prototype development. When we finish we can add videos with it. About use cases: We are assuming that this implementation would work with any external device (via bluetooth for now), which can be
- Electronic/mechanical board, which can detect pieces movement and indicate oppenent move.
- sending moves from application
- sending moves from device
- promotion select popup after move on device
- initiating game/offer draw/resign from application
- initiating game/offer draw/resign from application (not implemented now - can be added in next pull request)
- support rest of UCI and Xboard features (sending commands in specyfic moment) - for now we implemented some full minimal version, which allows for rest mentioned cases (additional features can be turned on by
featurecommand)
- External game analyzer
- sending moves from app
- Exteranal display
- sending moves from/to app
We prepared some tangible demo for this pull request. You can watch a few examples on real demo:
- how to connect app with electronic board and play otb (based on raspberry pi)
- how electronic board can indicate movements
- play on app and on electronic board on the same time
- illegal move detection
- promotion
Moves are indicated by voice to speech on electronic board side - sory for long delay between move and speech (some problems with configuration). Let us know what do you thing.
For some reason YouTube channel with real chess demo was removed. I will try to restore it. If I couldn't do this I will upload demo somewhere else.
EDIT: link with video: https://drive.google.com/drive/folders/1NqTjfQgMXmbGiKlOg6P63qK8qe0-jW_p
I would like to test the PR with the openchessboard. Do you have an apk available so I could skip the building process?
I would like to test the PR with the openchessboard. Do you have an apk available so I could skip the building process?
Great that you would like to test it:)
We added demo apk to demo
Are you going to test it with ARDUINO NANO? If yes please let us know with which library for BLE? We would be interested with adding examples for arduino.
And thanks for openchessboard - I've just discovered it.
I would like to test the PR with the openchessboard. Do you have an apk available so I could skip the building process?
Great that you would like to test it:)
We added demo apk to demo
Are you going to test it with ARDUINO NANO? If yes please let us know with which library for BLE? We would be interested with adding examples for arduino.
And thanks for openchessboard - I've just discovered it.
Thanks for the demo. Do you support BLE? The scan seems to not discover the Arduino, however, my smartphone does discover it and also connects to the device.
Yes, we support BLE. It has to be peripheral device with service_uuid, rx_uuid and tx_uuid (we defined dedicated for CECP and UCI protocol). It is better to use CECP protocol:
SERVICE_UUID = 'f5351050-b2c9-11ec-a0c0-b3bc53b08d33'
TX_UUID = 'f53513ca-b2c9-11ec-a0c1-639b8957db99'
RX_UUID = 'f535147e-b2c9-11ec-a0c2-8bbd706ec4e6'
Please look at https://github.com/vovagorodok/lichobile/tree/master/src/externalDevice/example how we did this for raspberry PI.
For Arduino or any other BLE device it has to be done in similar way - it is important to have the same uuid on both sides. If you have some code, which you prepared for the test please you could share it and we will try to help
I am using the ArduinoBLE library. Do you scan for specific advertisement data? I am not sure how to setup the advertisement properly.
I am using the ArduinoBLE library. Do you scan for specific advertisement data? I am not sure how to setup the advertisement properly.
Hi @TimoKropp,
I've prepared example for ESP32 and AVR microcontrollers in Arduino/PlatformIO:
https://github.com/vovagorodok/ArduinoBleChess
I have plan to make universal and simple library in future with supporting more microcontrollers.
Currently I haven't Arduino Nano 33 IoT board to test AVR case, only ESP32 Wroom was fully tested on device.
Please try to test it on Your Arduino Nano 33 IoT board, and geave me feedback.
Lets switch to this topic and continue there:
https://github.com/vovagorodok/ArduinoBleChess/issues/1
Thanks!
@TimoKropp helps us to test all. A I'm c++/python dev it's my first experience with typescript/mobile. At builded apk we have following warrning:
And it's impossible to test online play with apk
@veloce @jas14 any trick how to build apk correctly? Or you can just build apk for us? Thanks
I have tested the Bluetooth integration with the openchessboard. You can check out a video on discord: https://discord.gg/MFmSyHWzbK The responsiveness is great and at the BLE connection is stable. I strongly recommend to get the PR to main :).
@veloce @jas14 any trick how to build apk correctly? Or you can just build apk for us? Thanks
The message is there because the app is broken on webview versions < 69 - see https://github.com/lichess-org/lichobile/commit/04d66e3c8f84bb42a37a9f73cf9f3f1ea59984c5. This is a device-specific message, so you should first try updating you Android System Webview and/or Chrome. If you can't for some reason, you can try tweaking https://github.com/lichess-org/lichobile/blob/abd9c94bc474813327a25e6c39946861e7105e38/android/app/src/main/java/org/lichess/mobileapp/MainActivity.java#L27 and compiling, but your mileage may vary!
Hello, @jas14 @veloce Just want to ask if is any plan to merge this pull request?
How can we help or what can we do to help with integrating it into main branch?
@dkwach , veloce is the maintainer of this repo, so I'm deferring to him
I made some more testing and most recently I am not able to connect to my device via nokia 7.2 but still with tablet it immediately connects. This seems kind of strange to me since It was working before on nokia but it is somehow stuck now and does not work on this phone. I reinstalled the apk but no changes. I guess it is an issue with the phone but I am not sure how to debug this. Do you have a new apk which has the solved bug for the tablet?
I made some more testing and most recently I am not able to connect to my device via nokia 7.2 but still with tablet it immediately connects. This seems kind of strange to me since It was working before on nokia but it is somehow stuck now and does not work on this phone. I reinstalled the apk but no changes. I guess it is an issue with the phone but I am not sure how to debug this. Do you have a new apk which has the solved bug for the tablet?
Hi Timmo, Based on your description it looks like some config/phone problem. We can help in resolving this issue. However before we would do this lets wait for @veloce opinion about this pull request. We still don't know if it is considered to be a part of lichobile.
Hi there, I have bad news concerning the PR. I got in contact with veloce via discord and this was his reply on asking to look into the PR:
"Sorry @timokko while this is a cool feature the changes are too important for a merge, as I won’t be able to maintain it. Also I don’t’ think it would be useful to a lot of users (relatively to our user base which is huge of course) as it’s kind of an advanced feature. Thus it’s perfectly fine to keep it as a fork imo"
dkwach @.***> schrieb am Di., 30. Aug. 2022, 22:05:
I made some more testing and most recently I am not able to connect to my device via nokia 7.2 but still with tablet it immediately connects. This seems kind of strange to me since It was working before on nokia but it is somehow stuck now and does not work on this phone. I reinstalled the apk but no changes. I guess it is an issue with the phone but I am not sure how to debug this. Do you have a new apk which has the solved bug for the tablet?
Hi Timmo, Based on your description it looks like some config/phone problem. We can help in resolving this issue. However before we would do this lets wait for @veloce https://github.com/veloce opinion about this pull request. We still don't know if it is considered to be a part of lichobile.
— Reply to this email directly, view it on GitHub https://github.com/lichess-org/lichobile/pull/2101#issuecomment-1232110999, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALLNAF6FREJHVQCINEF6RCLV3ZSOZANCNFSM5UV3MWBA . You are receiving this because you were mentioned.Message ID: @.***>
I wonder if you guys would be interested in working on e-board support for the new lichess mobile app. Say hi in the lichess-mobile-app discord if you're interested.
Implementation moved to branch in forked repo: https://github.com/lichess-org/lichobile/compare/master...vovagorodok:lichobile:bluetooth