AndBondStyle / niimprint

Python library for Niimbot label printers. Supports D11/B21/B1 via bluetooth or USB.
MIT License
224 stars 32 forks source link

Auto-detect address and printer model #7

Open AndBondStyle opened 10 months ago

AndBondStyle commented 10 months ago

As a quality of life update, we can detect printer model and connection address automatically. For USB initial guessing can be done with vendor/product ID, then using a 0x40 (GET_INFO) serial command. For bluetooth I'm not sure yet if the addresses are consistent, but we can also scan by name (e.g. B21 is always named like "B21-"), and then verify with the magic command again.

MultiMote commented 4 months ago

You can get printer model by sending packet (0x40 - GetInfo, 0x08 - GetPrinterModel):

55 55 40 01 08 49 aa aa

For example, D110 returned this packet:

55 55 48 02 09 00 43 aa aa

0x0900 => 2304 (D110 printer id)

Here is a list of printers (simplified version of this)