A distributed chime network system implementing the Local Chime Gating Protocol (LCGP) as defined in the RFC.
ChimeNet allows users to create and manage distributed chime networks where:
- Users can have multiple chime instances
- Each chime can expose notes and chords
- Chimes implement the LCGP protocol for "Do Not Disturb" functionality
- Chime ringers can discover and invoke chimes
- Everything operates over MQTT
- types.rs: Core data structures and MQTT topic builders
- lcgp.rs: Local Chime Gating Protocol implementation
- mqtt.rs: MQTT client wrapper with ChimeNet-specific functionality
- audio.rs: Audio playback using system speakers
- chime.rs: Chime instance management
A software-based chime that plays audio through computer speakers.
Usage:
cargo run --bin virtual_chime -- --user alice --name "Alice's Chime" --broker tcp://localhost:1883Commands:
mode <mode>- Set LCGP mode (DoNotDisturb, Available, ChillGrinding, Grinding)ring <user> <chime_id>- Ring another chimerespond <pos|neg>- Respond to a chimestatus- Show current status
REST API service for monitoring chime networks.
Usage:
cargo run --bin http_service -- --users alice,bob --port 3030Endpoints:
GET /status- Service statusGET /users- List monitored usersGET /users/:user/chimes- List user's chimesGET /users/:user/chimes/:chime_id/status- Chime statusGET /events- Recent eventsPOST /users/:user/chimes/:chime_id/ring- Ring a chime
Discovers and rings chimes by name.
Usage:
cargo run --bin ringer_client -- --user ringer --discovery-interval 30Commands:
discover- Trigger discoverylist [user]- List available chimesring <user> <chime_name>- Ring a chime by namestatus- Show ringer status
Testing utility for invoking chimes.
Usage:
cargo run --bin test_client -- --target-user alice --command "test-all"Advanced example showing how to define custom LCGP states with time-based activation, conditions, and custom behaviors.
Usage:
cargo run --bin custom_states -- --user alice --name "Alice's Smart Chime"Features:
- Meeting state: Silent with auto-decline
- Focus state: Delayed response with state transitions
- Lunch state: Auto-accept during lunch hours
- Condition-based state activation
- Custom behavior implementations
Commands:
custom <state>- Set custom statelist-custom- List available custom statescondition <key> <value>- Set condition for state evaluation
See Custom States Documentation for details.
Hardware implementation for ESP32 with buzzer and LED.
Hardware Requirements:
- ESP32 or similar WiFi-enabled microcontroller
- Buzzer or speaker (GPIO 5)
- Status LED (GPIO 2)
- User button (GPIO 4)
The system uses the following MQTT topic structure:
/<user>/chime/list # List of user's chimes
/<user>/chime/<chime_id>/notes # Available notes for a chime
/<user>/chime/<chime_id>/chords # Available chords for a chime
/<user>/chime/<chime_id>/status # Chime status (LCGP mode, online/offline)
/<user>/chime/<chime_id>/ring # Ring/invoke a chime
/<user>/chime/<chime_id>/response # Response to chime (POSITIVE/NEGATIVE)
/<user>/ringer/discover # Ringer discovery requests
/<user>/ringer/available # Available ringers
The LCGP defines four standard modes:
- DoNotDisturb: Do not chime, ignore all requests
- Available: Chime and wait for user response
- ChillGrinding: Chime and auto-respond positive after 10 seconds
- Grinding: Chime and immediately respond positive
The system also supports custom LCGP states with advanced features:
- Time-based activation: States active during specific hours/days
- Condition-based triggers: Calendar, presence, system load conditions
- Custom behaviors: Programmable response logic
- State transitions: Automatic transitions between states
- Priority levels: Higher priority states override lower ones
See the Custom States Example for implementation details.
Mode updates are sent every 5 minutes to inform other nodes.
- Rust (latest stable)
- MQTT broker (e.g., Mosquitto)
- System dependencies:
- Linux:
pkg-config,libssl-dev,libasound2-dev,cmake,build-essential - macOS:
cmake(audio frameworks are built-in) - Windows: Visual Studio Build Tools or similar
- Linux:
# Install Mosquitto
sudo apt install mosquitto mosquitto-clients
# Start broker
sudo systemctl start mosquitto
# Test broker
mosquitto_pub -h localhost -t test -m "Hello World"
mosquitto_sub -h localhost -t testsudo apt-get update
sudo apt-get install -y pkg-config libssl-dev libasound2-dev cmake build-essential# CentOS/RHEL
sudo yum install -y pkgconfig openssl-devel alsa-lib-devel cmake gcc-c++ make
# Fedora
sudo dnf install -y pkgconfig openssl-devel alsa-lib-devel cmake gcc-c++ makebrew install cmakeInstall Visual Studio Build Tools or Visual Studio Community with C++ support.
# Clone repository
git clone <repository-url>
cd chimenet
# Option 1: Use the build script (recommended)
./build.sh
# Option 2: Manual build
# Install dependencies (see above)
# Build all components
cargo build --release
# Run virtual chime
cargo run --bin virtual_chime -- --user alice --name "Alice's Chime"
# In another terminal, run HTTP service
cargo run --bin http_service -- --users alice
# In another terminal, run ringer client
cargo run --bin ringer_client -- --user ringer
# Test the system
cargo run --bin test_client -- --target-user alice --command discoverThe build.sh script supports several options:
./build.sh --help # Show help
./build.sh --deps-only # Only install dependencies
./build.sh --build-only # Only build (skip dependency installation)
./build.sh --no-tests # Skip running testscurl -X POST http://localhost:3030/users/alice/chimes/chime_id/ring \
-H "Content-Type: application/json" \
-d '{"notes": ["C4", "E4", "G4"], "duration_ms": 1000}'curl http://localhost:3030/events?user=alice&limit=10MQTT_BROKER: MQTT broker URL (default: tcp://localhost:1883)RUST_LOG: Log level (default: info)
The virtual chime uses the system's default audio output. Ensure your system has working audio drivers.
- Implement the
ChimeInstancetrait - Add MQTT message handling
- Implement audio playback for your platform
- Use the
ChimeNetMqttwrapper for MQTT communication - Handle the standard topic structure
- Implement LCGP protocol compliance
This project is open source. See the LICENSE file for details.
Contributions are welcome! Please ensure:
- Code follows Rust best practices
- LCGP protocol compliance
- Comprehensive testing
- Documentation updates
-
MQTT Connection Failed
- Check broker is running:
sudo systemctl status mosquitto - Verify broker URL and port
- Check firewall settings
- Check broker is running:
-
Audio Issues
- Verify system audio is working
- Check audio dependencies are installed
- Try different audio backends
-
Topic Permissions
- Ensure MQTT broker allows topic subscriptions
- Check user permissions if using authentication
RUST_LOG=debug cargo run --bin virtual_chime┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Virtual │ │ Hardware │ │ Ringer │
│ Chime │ │ Chime │ │ Client │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│ │ │
└───────────────────────┼───────────────────────┘
│
┌─────────────────┐
│ MQTT Broker │
└─────────────────┘
│
┌─────────────────┐
│ HTTP Service │
│ (Monitoring) │
└─────────────────┘
The system is designed to be:
- Distributed: No central server required
- Resilient: Nodes can join/leave dynamically
- Extensible: Easy to add new chime types and clients
- Standards-based: Uses MQTT for reliable messaging