piksel / pytouch-cube

Qt5 Label Editor for Brother P-Touch Cube label maker
MIT License
49 stars 9 forks source link

Linux: Support Bluetooth without /dev/rfcomm #39

Open tyalie opened 2 years ago

tyalie commented 2 years ago

PyBluez of course supports connecting to rfcomm devices without going the long route of using the rfcomm utility. An example can be found here.

The lookup done in BluetoothPrinterDevice.list_devices doesn't seem to be too wrong. What I don't fully understand is, why it was commented out in labelmaker/comms.py:167?

piksel commented 2 years ago

Because I couldn't get it to work on windows, but I am currently trying it from Linux. So far it can list devices, but SDP doesn't list any RFCOMM services for the printer (it does for other devices though). But yeah, work in progress.

piksel commented 2 years ago

If you explicitly pass the UUID for serial comms it actually does show up and I was successfully able to talk to the printer using a bluetooth socket:

nils@chronos:/src/pytouch-cube$ python3 btsock-test.py 
INFO:root:BTSock Test
INFO:root:Querying for devices...
INFO:root:Found devices: [TV] Samsung Q60 Series (65)
WARNING:root:No device candidate
INFO:root:Querying for devices...
INFO:root:Found devices: PT-P300BT0607, [TV] Samsung Q70 Series (55), FW-65BZ35F
INFO:labelmaker:Opening serial device connection...
[{'description': None,
  'name': 'Serial',
  'port': 1,
  'profiles': [],
  'protocol': 'RFCOMM',
  'provider': None,
  'service-classes': ['1101'],
  'service-id': None}]
INFO:labelmaker:Query status...
INFO:root:Got raw status: 80 20 42 30 72 30 0 0 0 0 c 1 0 0 0 0 0 0 0 0 0 0 0 0 3 8 0 0 0 0 0 0
INFO:labelmaker:Status: Reply to status request
INFO:labelmaker:Battery: 0
INFO:root:Connection successful!
piksel commented 2 years ago

Fully working print through bluetooth socket: image

Now I just need to clean it up...

tyalie commented 2 years ago

Oh wow. This is great