rfid-poker

module
v0.0.0-...-73c2e26 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 22, 2025 License: MIT

README

Equity viewer for poker (No-limit Texas Hold'em)

demo

Requirements

  • M5Stack + RFID module
    • Players x N (N is the number of players) + 1 (for muck) + 1 (for board)
    • We tested with...
  • Player cards with NFC chip (ISO/IEC 14443 Type A)
    • We tested player cards include MIFARE Ultralight EV1

Setup

Prepare a config file
$ cat config.yaml
card_ids:  ## UID of NEC card
  040e3bd2286b85: As
  040f43d2286b85: Qc
  04101b9a776b85: Kc
  ...
Run the server

Run the server using the following environment variables

# Set the path to the config file
# You can set path as `http://` or `https://` to get the config file from the server.
export RFID_POKER_CONFIG_PATH="./config.yaml"

# Set MySQL connection information
export RFID_POKER_MYSQL_USER=<your_mysql_user>
export RFID_POKER_MYSQL_PASS=<your_mysql_password>
export RFID_POKER_MYSQL_HOST=<your_mysql_host>
export RFID_POKER_MYSQL_PORT=<your_mysql_port>
export RFID_POKER_MYSQL_DATABASE=<your_mysql_database>

# Optional: Auto-clear game when players/board stop sending cards.
# 0 disables timeout. Default: 10
export RFID_POKER_CLIENT_TIMEOUT_SECONDS=10

# Run the server
$ go run ./cmd/server

Components

Server

The server is a golang application that runs on a server.

GET /ws (websocket)

The server will upgrade the connection to a websocket. The server send an info about players to the client.

The body of the message is as follows:

{
  "board": [
    {
      "rank": "A",
      "suit": "hearts"
    },
    {
      "rank": "K",
      "suit": "hearts"
    },
    {
      "rank": "Q",
      "suit": "hearts"
    },
    {
      "rank": "J",
      "suit": "hearts"
    },
    {
      "rank": "T",
      "suit": "hearts"
    }
  ],
  "players": [
    {
      "name": "Player 1",
      "hand": [
        {
          "rank": "A",
          "suit": "spades"
        },
        {
          "rank": "K",
          "suit": "spades"
        }
      ],
      "equity": 0.5
    },
    {
      "name": "Player 2",
      "hand": [
        {
          "rank": "A",
          "suit": "clubs"
        },
        {
          "rank": "K",
          "suit": "clubs"
        }
      ],
      "equity": 0.5
    }
  ]
}
POST /device/boot

The device should POST this message when it boots.

{
  "device_id": "device_id",  // as Mac address (in M5stack)
  "pair_ids": [1, 2, 3, ...] // antenna pair ids
}
POST /card

The device (or wired client) should POST this message when it reads a card.

{
  "device_id": "device_id",    // as Mac address (in M5stack)
  "pair_id": 1,                // antenna pair id
  "uid": "040e3bd2286b85"      // as UID of NFC card (spaces are allowed)
}
ui

This ui is a Next.js application that runs on a client.

ui directory is a Next.js application.

You can use the newest code in GitHub Pages (https://whywaita.github.io/rfid-poker/).

Client

This is a M5Stack application that runs on a M5Stack device.

clients/m5stack directory is a M5Stack application.

Directories

Path Synopsis
cmd
server command
wired-client command
pkg
scripts

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL