Quickstart Guide
This guide walks through establishing a connection, querying device telemetry, and printing your first document.
Prerequisites
- A computer equipped with a functional Bluetooth 4.0+ (BLE) adapter.
- An active, supported thermal printer powered on and loaded with paper.
- Important: Ensure the printer is not actively connected to a smartphone application. Bluetooth Low Energy thermal printers accept only one active connection at a time and stop broadcasting when paired.
1. Discovering Nearby Printers
Use the discovery API to locate printers within radio range:
2. Connecting to a Printer
The connection helper connects to the nearest recognized printer if no identifier is passed, or accepts a name fragment or MAC address:
import purrint
# Connect to the nearest detected printer
with purrint.connect_sync() as printer:
print(f"Connected to model: {printer.model.name} (Protocol: {printer.family.name})")
To target a specific printer:
# Match by device name fragment
with purrint.connect_sync("MX10") as printer:
...
# Match by explicit MAC / UUID address
with purrint.connect_sync("AA:BB:CC:DD:EE:FF") as printer:
...
3. Querying Hardware Telemetry
You can read diagnostic status, battery levels, head temperatures, and firmware details:
import purrint
with purrint.connect_sync() as printer:
# Diagnostic flags
status = printer.refresh_status()
print("Paper present:", not status.out_of_paper)
print("Cover closed:", not status.cover_open)
print("Temperature:", printer.temperature, "Celsius")
# Hardware info
info = printer.get_info()
print("Firmware:", info.firmware)
print("Serial:", info.serial)
4. One-Shot Quick Printing
For scripts that simply need to send an image or text without manually managing connection handles: