[FREE] BLE “CHESSNUT AIR” Board control extension

This Extension allows your application to control the CHESSNUT AIR Electronic Chessboard:
board

The smart board determines the placement of chess pieces and can highlight moves using green LEDs.

The board comes with some very nice apps. However, I always prefer to be able to control my electronic devices myself. The device manufacturer does not explicitly open the communication protocol, but information can be found on the Internet. I learned the exchange protocol on this resource, thanks to him.

Methods:

ConnectToBoard
Connect to a Chessnut Air. OnDeviceStatusChange events occurs.

Note: During the first synchronization, the application may ask for ACCESS_FINE_LOCATION permission. This is due to the fact that the application, when connected to a BLE device, can read its signal level. Which, in turn, can be used to calculate the exact location of the device in the room using triangulation (there must be at least 3 connected devices). In our case, this is not used, but permission will still have to be given. For devices with Android 12+,extension will ask for BLUETOOTH_SCAN and BLUETOOTH_CONNECT permissions too.

Disconnect
Close connection with the Chessnut Air. OnDeviceStatusChange events occurs.


Get current chess game position on FEN notation.
For example: “rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR”.


Convert FEN notation to Text notation to visually represent a chess position:

I got the idea from here.

InitNewGame
Init New Game. LEDs highlight chess pieces and empty squares that are not in the correct position to start the game:


OnBoardNewPositionIsSet events occurs after completing the placement of chess pieces.


Set current chess game position on FEN notation. For example: “rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR”. Returns false if the annotation is invalid.
OnBoardNewPositionIsSet events occurs after completing the placement of chess pieces.


Set current chess move on numeric notation. For example: 52-54 (corresponds to e2-e4). Returns false if the annotation is invalid or there is no chess piece in the first field. The correctness of the move is not checked. Perhaps in future versions I will add this.

LEDs highlight the move that needs to be implemented:


OnBoardNewPositionIsSet events occurs after completing the placement of chess pieces.

Properties:

IsDevFound

IsConnected

IsSetNewPos

Events:

OnError
Possible error codes:

ERR_BLE_NOT_SUPORTED=1;

ERR_API_LEVEL_NOT_SUPORTED =2;

ERR_SYSTEM_NOT_SUPORTED =3;

ERR_BLE_IS_DISABLED =4;

ERR_SCANNER_ALREADY_RUNNING =5;

ERR_BLE_ALREADY_CONNECTED =6;

ERR_BLE_DISCONNECTED =7;

ERR_ CHESSNUT_NOT_FOUND =8;

ERR_ CHESSNUT_NOT_CONNECTED =9;

ERR_BLE_SEND=10;


Possible status codes:

ST_INIT_SCAN = 1;

ST_STOP_SCAN = 2;

ST_BLE_DEV_FOUND = 3;

ST_ CHESSNUT_FOUND = 4;

ST_ CHESSNUT_INIT_CONNECT = 5;

ST_ CHESSNUT_CONNECTED = 6;

ST_ CHESSNUT_DESCONNECTED = 7;


Event occurs when position on the chessboard has changed.


The event occurs when the chessboard begins to match the specified position.

Current Version:
ScBleChessnutAir.aix (41.6 KB)

Test Project:
ScBleChessNutAirTest.aia (44.3 KB)

5 Likes