Expand description
Typed commands, decoded notifications, and chessboard values. Typed values and codecs for the Chessnut Move byte protocol.
Applications normally construct a Command and
consume BoardEvent values through a session in the
transport module. Transport implementers can use
decode_position_notification and
decode_response_notification
when they need direct access to the protocol codecs.
Board positions use canonical A1-to-H8 indexing through
Square, while encoding and decoding preserve the Move
board’s reversed wire order.
§Examples
Consumers can handle decoded events without depending on a particular Bluetooth library:
use chessnut_move::protocol::{
BoardEvent, File, Rank, Square,
};
fn occupied(event: BoardEvent, square: Square) -> Option<bool> {
match event {
BoardEvent::PositionChanged(position) => {
Some(position.piece_at(square).is_some())
}
BoardEvent::BatteryStatus(_) | BoardEvent::PieceStatus(_) => None,
}
}
let e4 = Square::new(File::E, Rank::Four);Structs§
- Battery
Status - Charging state and battery percentage reported by the board.
- Command
- An encoded command ready to write to the board’s command characteristic.
- LedPattern
- LED colors for all 64 squares in canonical A1-to-H8 order.
- Notification
TooShort Error - Reports that a notification does not contain its complete required payload.
- Parse
Square Error - Reports that a string is not exactly one valid file and one valid rank.
- Piece
- A chess piece described by its color and kind.
- Piece
Status - Status records for every physical piece tracked by the board.
- Position
- Piece occupancy for all 64 squares.
- Square
- A chessboard square stored in canonical A1-to-H8 order.
- Tracked
Piece Status - Status reported for one tracked physical chess piece.
Enums§
- Auto
Move Mode - Selects how an automatic movement reacts to user interaction.
- Battery
Status Error - Reports an invalid field in a board battery response.
- Board
Event - A decoded board-state or status notification.
- Color
- Side to which a chess piece belongs.
- Decode
Position Notification Error - Reports why a position notification could not be decoded.
- Decode
Response Notification Error - Reports why a command-response notification could not be decoded.
- File
- A chessboard file from A through H.
- LedColor
- A color supported by a Chessnut Move square LED.
- Piece
Kind - Chess role of a piece.
- Piece
Status Error - Reports an invalid field in a piece status response.
- Rank
- A chessboard rank from one through eight.
- Write
Kind - Selects the GATT write operation required by a
Command.
Constants§
- BOARD_
STATE_ LENGTH - Number of packed bytes used to encode all 64 board squares.
- MAX_
COMMAND_ LEN - Maximum number of bytes in a command, defined by the Move’s public API surface.
- SQUARE_
COUNT - Number of squares on a chessboard.
- TRACKED_
PIECE_ COUNT - Number of physical piece records in a tracked-piece response.
Functions§
- decode_
position_ notification - Decodes a position notification emitted by the position characteristic.
- decode_
response_ notification - Decodes a battery or tracked-piece response notification.