vovagorodok / ArduinoBleChess

Connect your chess eboard over Bluetooth
MIT License
4 stars 1 forks source link

Lichess with Arduino Nano 33 IoT #1

Closed vovagorodok closed 2 years ago

vovagorodok commented 2 years ago

Ok, lets summarize issues that we need to solve in order to simply track it:

1. When a game is already running in the app and the device is reconnected, no game data is received.  How to reproduce it?

I receive the FEN but not the last move played. How to test it:

1. start a game and play some moves

2. restart/reprogram peripheral device

3. reconnect bluetooth

4. received game data:
   `moved from phone: xboard please move: moved from phone: accepted setboard stop move:  new game: rnbqkb1r/pp1ppp1p/6p1/2p5/3Pn3/1P3N2/P1P2PPP/RNBQKB1R w please move: `

moved from phone: xboard already fixed on latest ArduinoBleChess. Are You updated?

TimoKropp commented 2 years ago

now updated: moved from phone: accepted setboard please move: stop move: new game: rnbqkb1r/pp1ppp1p/6p1/2p5/3Pn3/1P3N2/P1P2PPP/RNBQKB1R w please move: still not the last move shown.

vovagorodok commented 2 years ago

Fixed. Please update.

TimoKropp commented 2 years ago

updated. but still not fixed :)

vovagorodok commented 2 years ago

what :) and you see: moved from phone: accepted ? on latest version of library?

TimoKropp commented 2 years ago

I imported the projectv again and this is the only result:

new game: rnbqkbnr/pp2pppp/2p5/3p4/4P3/5N2/PPPP1PPP/RNBQKB1R w please move:

that is all I see after a peripheral device reprogramming and then opening the ongoing game in the app.

TimoKropp commented 2 years ago

I guess the last move was already send and received previously to/by the peripheral device. But I would suggest that it will be resend if you click on the game again in the app. So a device restart is able to catch the last move even if it was send from the app previously.

vovagorodok commented 2 years ago

According to:

still not the last move shown.

I think we have misunderstanding of each outer. There no concept of last move in xboard protocol and it's not consider only board with LEDs. It's more universal and for example LEDs can be replaced by motors. As I understand you need it for indicate last move using LEDs. When we have a motors we will have motors move each time when restarted because same move will be send each time. From protocol PoV it's redundant/unneeded information. I understand that it will be easier for you just port code from lichess web protocol. But it's not correct for universal protocol PoV (we tried make it universal). Only solution that I see i to remember last move on board side if it's needed

Are you agree?

TimoKropp commented 2 years ago

I agree that the protocol needs to be generic/universal. The issue with the peripheral device is that most of the time you only store the move history in ram. This info is lost at a restart. If you want to keep the moves stored permanently you need to write to the flash which is not the most elegant way :(. Maybe you have an idea to request the last move separately outside of the standard protocol? This would also be useful for analysis mode of the chess board to be able to play through lines requested by the board.

vovagorodok commented 2 years ago

Understand. For me is ok to save one move on flash/eeprom. I'll save even more (options, last board state if we play with AI inside board). Checked protocol and there no such options, because protocol is not hardware related and I thing shouldn't be. Each additional command/exception will complicate it and I think we should avoid that. Using Arduino EEPROM library for save one move will be most elegant way as I see

TimoKropp commented 2 years ago

I am not sure about that, the EEPROM has 100,000 write/erase cycles which could be an issue for the device lifetime. Most users would never play/abort that much games but you never know :). But I think it is okay to lose the last move functionality currently or live the limited live time.

TimoKropp commented 2 years ago

I am in contact with Erik from chess.com and he is interested in adding compatibility for the cecp protocol in the chess.com app. Would you mind if I take you on the email exchange? Just link me your email and I will take you in for the discussion.

vovagorodok commented 2 years ago

Nice step! yes of course.

vovagorodok commented 2 years ago
  1. When using the tablet, the device is stuck at "stop move: ", not clear why. Reproduced and under investigation

Nice finding. Issue reported to https://github.com/capacitor-community/bluetooth-le/issues/341 Now under discussion, which is better way to solve it

TimoKropp commented 2 years ago

I also put you in the discussion with Khadim, to work on an integration to the white pawn app ;)

TimoKropp commented 2 years ago

Still getting permanently disconnects on my Nokia 7.2 after successful testing yesterday. It seems very unstable for this device. Not clear why. Now I also get disconnects with Huawei Tablet. solved: I broke something :)

vovagorodok commented 2 years ago

Still getting permanently disconnects on my Nokia 7.2 after successful testing yesterday. It seems very unstable for this device. Not clear why. Now I also get disconnects with Huawei Tablet. solved: I broke something :)

Ok, no issue here?

A I understand currently we have two issues to solve:

  1. Stuck at "stop move: ". Workaround found. Under discussion wit BLE library authors
  2. Online play. Waiting response from lichobile guys
TimoKropp commented 2 years ago

Yes, those are the open points. Still no answer from the lichobile devs unfortunately :(. In the meentime, I posted a video of the Bluetooth integration on my discord. https://discord.gg/MFmSyHWzbK It works really well with your Bluetooth driver :)

vovagorodok commented 2 years ago

Love it! You can show it with information about responsiveness and blitz possibility in lichobile topic