A Rust-based command-line tool for monitoring Bambu Labs 3D printers via MQTT with TLS encryption.
- π Secure MQTT Connection: TLS-encrypted connections to Bambu Labs printers
- π Auto-Retry Logic: Robust connection handling with configurable retry attempts
- π Real-time Monitoring: Live status updates from printer MQTT topics
- π οΈ CLI Interface: Easy-to-use command-line interface with comprehensive help
- βοΈ Configuration Management: JSON-based configuration system for managing multiple printers
- π Cross-Platform Config: Automatic configuration directory detection (Linux/macOS/Windows)
- Rust (latest stable version)
- Access to a Bambu Labs printer on your local network
git clone <repository-url>
cd pulseprint-cli
cargo build --release
First, add your printer to the configuration:
cargo run -- add \
--name "my-x1c" \
--ip 192.168.1.100 \
--device-id 01S00A000000000 \
--access-code 12345678 \
--set-default
List all configured printers:
cargo run -- list
Monitor your default printer:
cargo run -- monitor
Monitor a specific printer by name:
cargo run -- monitor --name "my-x1c"
Or provide connection details directly:
cargo run -- monitor \
--ip 192.168.1.100 \
--device-id 01S00A000000000 \
--access-code 12345678
# General help
cargo run -- --help
# Monitor command help
cargo run -- monitor --help
PulsePrint-CLI connects to Bambu Labs printers using the following specifications:
- Protocol: MQTT over TLS
- Port: 8883
- Username:
bblp
- Password: Your printer's LAN access code
- Topic:
device/{DEVICE_ID}/report
(for status monitoring)
- Printer IP: Check your router's admin panel or use network discovery tools
- Device ID: Found in your printer's network settings or Bambu Studio
- Access Code: Located in your printer's network settings (LAN access code)
-h, --help
: Print help information-V, --version
: Print version information
Add a new printer configuration.
Arguments:
-n, --name <NAME>
: Printer name (unique identifier)-i, --ip <IP>
: Printer IP address-d, --device-id <ID>
: Device ID of the printer-a, --access-code <CODE>
: LAN access code for the printer--set-default
: Set as default printer (optional)
List all configured printers.
Remove a printer configuration.
Arguments:
<NAME>
: Name of the printer to remove
Set the default printer.
Arguments:
<NAME>
: Name of the printer to set as default
Monitor a Bambu Labs printer via MQTT.
Arguments (all optional):
-n, --name <NAME>
: Printer name from config (uses default if not specified)-i, --ip <IP>
: Printer IP address (overrides config)-d, --device-id <ID>
: Device ID of the printer (overrides config)-a, --access-code <CODE>
: LAN access code for authentication (overrides config)
Usage patterns:
monitor
- Monitor the default printermonitor --name my-printer
- Monitor a specific configured printermonitor --ip 192.168.1.100 --device-id ... --access-code ...
- Direct connection without config
Monitor output example:
π¨οΈ Print Status: Printing - Remaining: 16m 55s
π¨οΈ Printer Status: π‘οΈ Nozzle: 219.8Β°C | ποΈ Bed: 45.0Β°C | π Layer: 10 | β±οΈ Remaining: 16m | πΆ WiFi: -30dBm
cargo build # Debug build
cargo build --release # Release build
cargo test # Run all tests (unit + integration)
cargo test --bin pulseprint-cli # Run unit tests only
cargo test --tests # Run integration tests only
cargo test test_printer_config # Run specific test by name
cargo check # Check code without building
Test Structure:
- Unit tests:
src/config/tests.rs
- Configuration management tests - Unit tests:
src/mqtt/tests.rs
- MQTT client and connection tests - Integration tests:
tests/integration_tests.rs
- CLI commands and full workflows
Test Coverage:
- β Printer configuration creation and validation
- β Configuration file save/load operations
- β Printer management (add, remove, default selection)
- β MQTT client configuration and creation
- β Connection parameter validation
- β CLI argument parsing and validation
- β Help command functionality
- β Error handling for invalid inputs
- β Topic format generation
- β MQTT message parsing (JSON structure)
- β Bambu Labs printer status parsing
- β Print state inference and display
- β Temperature and progress monitoring
cargo clippy # Run linter
cargo fmt # Format code
src/
βββ main.rs # CLI entry point and command handling
βββ config/
β βββ mod.rs # Configuration management and data structures
β βββ tests.rs # Configuration unit tests
βββ messages/
β βββ mod.rs # MQTT message parsing and printer status
β βββ tests.rs # Message parsing unit tests
βββ mqtt/
βββ mod.rs # MQTT client implementation with TLS
βββ tests.rs # MQTT-specific unit tests
- Client Library: rumqttc v0.24
- TLS Support: Native TLS with certificate validation
- Connection Handling: Automatic retry with exponential backoff
- Topic Subscription: Automatic subscription to device report topics
Runtime Dependencies:
- clap: Command-line argument parsing with derive macros
- tokio: Async runtime for MQTT operations
- rumqttc: MQTT client with TLS support
- serde: JSON serialization for configuration and MQTT messages
- serde_json: JSON parsing and generation
- rustls: Modern TLS library for secure connections
- thiserror: Derive macros for error handling
- dirs: Cross-platform configuration directory detection
Development Dependencies:
- tokio-test: Testing utilities for async code
- mockall: Mock object library for testing
- tempfile: Temporary file creation for testing file operations
This project implements the OpenBambuAPI specification for communicating with Bambu Labs printers.
device/{DEVICE_ID}/report
- Device status and information (subscribed automatically)
device/{DEVICE_ID}/request
- Commands to device (planned)
- "Connection failed": Verify printer IP address and network connectivity
- "Authentication failed": Check that the access code is correct
- "TLS handshake failed": Ensure the printer supports TLS on port 8883
- Printer and client must be on the same network
- Port 8883 must be accessible (check firewall settings)
- Printer must have network access enabled
We follow a Git flow branching model:
main
- Stable releases onlydevelop
- Active development branch
- Fork the repository
- Create a feature branch from
develop
(git checkout -b feature/amazing-feature develop
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request targeting the
develop
branch
This project is licensed under the MIT License - see the LICENSE file for details.
PulsePrint-CLI includes a comprehensive configuration system for managing multiple printers with support for both TOML and JSON formats.
PulsePrint-CLI supports both TOML (preferred) and JSON configuration formats:
- New installations: Default to TOML format (
config.toml
) - Existing installations: Continue to support JSON format (
config.json
) - Format detection: Automatic based on file extension
- Backward compatibility: Existing JSON configs work seamlessly
Configuration files are automatically stored in the appropriate location for your operating system:
- Linux:
~/.config/pulseprint-cli/config.toml
(orconfig.json
) - macOS:
~/Library/Application Support/pulseprint-cli/config.toml
(orconfig.json
) - Windows:
%APPDATA%\pulseprint-cli\config.toml
(orconfig.json
)
default_printer = "my_printer"
[printers.my_printer]
name = "my_printer"
ip = "192.168.1.100"
device_id = "01S00A000000000"
access_code = "12345678"
port = 8883
use_tls = true
[mqtt_settings]
keep_alive_secs = 30
connection_timeout_secs = 10
retry_attempts = 5
retry_delay_secs = 5
queue_size = 10
{
"printers": {
"my_printer": {
"name": "my_printer",
"ip": "192.168.1.100",
"device_id": "01S00A000000000",
"access_code": "12345678",
"port": 8883,
"use_tls": true,
"model": null,
"firmware_version": null
}
},
"default_printer": "my_printer",
"mqtt_settings": {
"keep_alive_secs": 30,
"connection_timeout_secs": 10,
"retry_attempts": 5,
"retry_delay_secs": 5,
"queue_size": 10
}
}
π§ Currently in Development
- β MQTT connection with TLS support (issue #14)
- β Basic printer monitoring
- β CLI interface with help system
- β Error handling and retry logic
- β Configuration management system with TOML and JSON support (issue #17)
- β Multiple printer support with named configurations
- β Printer management CLI commands (add, remove, list, set-default)
- β Message parsing for MQTT JSON messages (issue #15)
- β Real-time status display with print progress
- β Simple status polling functionality (issue #16)
- β Bambu Labs printer status parsing with temperatures, layers, and timing
- β Print state inference and visual status indicators
- π§ Advanced status monitoring and display (planned for issue #6)
- π§ Command sending capabilities (planned)
- π§ File upload support (planned)
- OpenBambuAPI for the API specification
- Bambu Labs for creating awesome 3D printers
- The Rust community for excellent crates and tools