Skip to content

lsongdev/luckjingle-d1-printer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LuckJingle Printer

[🛒 Buy now]

Setup

~$ pip install -r requirements.txt
~$ python3 printer.py

Example

import asyncio
from luck_printer import LuckPrinter, BluetoothDevice

async def main():
  # BLE示例 // run scan.py to get address
  device = BluetoothDevice("028EBD80-9CCC-AD10-E727-8715AF47A664")
  await device.open()

  # 串口示例
  # from serial import Serial
  # device = Serial("/dev/rfcomm1")

  printer = LuckPrinter(device)

  try:
    await printer.initialize()
    await printer.print_text("Hello, World!")
    await printer.print_end()
  finally:
    await printer.close()

if __name__ == "__main__":
  asyncio.run(main())

rfcomm

~$ bluetoothctl
[bluetoothctl]# agent on
[bluetoothctl]# discoverable on
[bluetoothctl]# scan on
[bluetoothctl]# trust <address>
[bluetoothctl]# pair <address>

~$ sudo rfcomm connect 1 <address>

Credits